Skip to content

Commit 5483bfc

Browse files
x00354690davem330
authored andcommitted
net: hns: modify tcam table and set mac key
The current definition of dsaf_drv_tbl_tcam_key is only suitable for Little-endian. If data is stored in Big-endian, this may lead to error in data use. Shift operation can make it work normally in both Big-endian and Little-endian. Signed-off-by: Qianqian Xie <[email protected]> Reviewed-by: Yisen Zhuang <[email protected]> Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d30721d commit 5483bfc

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,12 @@ static void hns_dsaf_set_mac_key(
15091509
mac_key->high.bits.mac_3 = addr[3];
15101510
mac_key->low.bits.mac_4 = addr[4];
15111511
mac_key->low.bits.mac_5 = addr[5];
1512-
mac_key->low.bits.vlan = vlan_id;
1513-
mac_key->low.bits.port = port;
1512+
dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M,
1513+
DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id);
1514+
dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M,
1515+
DSAF_TBL_TCAM_KEY_PORT_S, port);
1516+
1517+
mac_key->low.bits.port_vlan = le16_to_cpu(mac_key->low.bits.port_vlan);
15141518
}
15151519

15161520
/**
@@ -2760,8 +2764,12 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev,
27602764
if (enable) {
27612765
memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data));
27622766
memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask));
2763-
tbl_tcam_data.low.bits.port = port;
2764-
tbl_tcam_mask.low.bits.port = 0xf; /* [3:0]: port id */
2767+
dsaf_set_field(tbl_tcam_data.low.bits.port_vlan,
2768+
DSAF_TBL_TCAM_KEY_PORT_M,
2769+
DSAF_TBL_TCAM_KEY_PORT_S, port);
2770+
dsaf_set_field(tbl_tcam_mask.low.bits.port_vlan,
2771+
DSAF_TBL_TCAM_KEY_PORT_M,
2772+
DSAF_TBL_TCAM_KEY_PORT_S, 0xf);
27652773

27662774
/* SUB_QID */
27672775
dsaf_set_bit(mac_data.tbl_mcast_port_msk[0],

drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ static inline void *hns_dsaf_dev_priv(const struct dsaf_device *dsaf_dev)
357357
return (void *)((u8 *)dsaf_dev + sizeof(*dsaf_dev));
358358
}
359359

360+
#define DSAF_TBL_TCAM_KEY_PORT_S 0
361+
#define DSAF_TBL_TCAM_KEY_PORT_M (((1ULL << 4) - 1) << 0)
362+
#define DSAF_TBL_TCAM_KEY_VLAN_S 4
363+
#define DSAF_TBL_TCAM_KEY_VLAN_M (((1ULL << 12) - 1) << 4)
364+
360365
struct dsaf_drv_tbl_tcam_key {
361366
union {
362367
struct {
@@ -370,11 +375,9 @@ struct dsaf_drv_tbl_tcam_key {
370375
} high;
371376
union {
372377
struct {
373-
u32 port:4; /* port id, */
374-
/* dsaf-mode fixed 0, non-dsaf-mode port id*/
375-
u32 vlan:12; /* vlan id */
376-
u32 mac_5:8;
377-
u32 mac_4:8;
378+
u16 port_vlan;
379+
u8 mac_5;
380+
u8 mac_4;
378381
} bits;
379382

380383
u32 val;

0 commit comments

Comments
 (0)