Commit 5483bfcb authored by Qianqian Xie's avatar Qianqian Xie Committed by David S. Miller

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: default avatarQianqian Xie <xieqianqian@huawei.com>
Reviewed-by: default avatarYisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d30721d4
...@@ -1509,8 +1509,12 @@ static void hns_dsaf_set_mac_key( ...@@ -1509,8 +1509,12 @@ static void hns_dsaf_set_mac_key(
mac_key->high.bits.mac_3 = addr[3]; mac_key->high.bits.mac_3 = addr[3];
mac_key->low.bits.mac_4 = addr[4]; mac_key->low.bits.mac_4 = addr[4];
mac_key->low.bits.mac_5 = addr[5]; mac_key->low.bits.mac_5 = addr[5];
mac_key->low.bits.vlan = vlan_id; dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M,
mac_key->low.bits.port = port; DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id);
dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M,
DSAF_TBL_TCAM_KEY_PORT_S, port);
mac_key->low.bits.port_vlan = le16_to_cpu(mac_key->low.bits.port_vlan);
} }
/** /**
...@@ -2760,8 +2764,12 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev, ...@@ -2760,8 +2764,12 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev,
if (enable) { if (enable) {
memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data)); memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data));
memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask)); memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask));
tbl_tcam_data.low.bits.port = port; dsaf_set_field(tbl_tcam_data.low.bits.port_vlan,
tbl_tcam_mask.low.bits.port = 0xf; /* [3:0]: port id */ DSAF_TBL_TCAM_KEY_PORT_M,
DSAF_TBL_TCAM_KEY_PORT_S, port);
dsaf_set_field(tbl_tcam_mask.low.bits.port_vlan,
DSAF_TBL_TCAM_KEY_PORT_M,
DSAF_TBL_TCAM_KEY_PORT_S, 0xf);
/* SUB_QID */ /* SUB_QID */
dsaf_set_bit(mac_data.tbl_mcast_port_msk[0], dsaf_set_bit(mac_data.tbl_mcast_port_msk[0],
......
...@@ -357,6 +357,11 @@ static inline void *hns_dsaf_dev_priv(const struct dsaf_device *dsaf_dev) ...@@ -357,6 +357,11 @@ static inline void *hns_dsaf_dev_priv(const struct dsaf_device *dsaf_dev)
return (void *)((u8 *)dsaf_dev + sizeof(*dsaf_dev)); return (void *)((u8 *)dsaf_dev + sizeof(*dsaf_dev));
} }
#define DSAF_TBL_TCAM_KEY_PORT_S 0
#define DSAF_TBL_TCAM_KEY_PORT_M (((1ULL << 4) - 1) << 0)
#define DSAF_TBL_TCAM_KEY_VLAN_S 4
#define DSAF_TBL_TCAM_KEY_VLAN_M (((1ULL << 12) - 1) << 4)
struct dsaf_drv_tbl_tcam_key { struct dsaf_drv_tbl_tcam_key {
union { union {
struct { struct {
...@@ -370,11 +375,9 @@ struct dsaf_drv_tbl_tcam_key { ...@@ -370,11 +375,9 @@ struct dsaf_drv_tbl_tcam_key {
} high; } high;
union { union {
struct { struct {
u32 port:4; /* port id, */ u16 port_vlan;
/* dsaf-mode fixed 0, non-dsaf-mode port id*/ u8 mac_5;
u32 vlan:12; /* vlan id */ u8 mac_4;
u32 mac_5:8;
u32 mac_4:8;
} bits; } bits;
u32 val; u32 val;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment