Fixes, minor changes & cleanups for the Unicast MAC VLAN table
Subsystems (4)
cover Fixes, minor changes & cleanups for the Unicast MAC VLAN table
This patch-set presents necessary modifications, fixes & cleanups related to Unicast MAC Vlan Table to support revision 0x21 hardware.
Jian Shen (5):
net: hns3: Remove the default mask configuration for mac vlan table
net: hns3: Clear mac vlan table entries when unload driver or function
reset
net: hns3: Optimize for unicast mac vlan table
net: hns3: Drop depricated mta table support
net: hns3: Fix for rx vlan id handle to support Rev 0x21 hardware
Zhongzhu Liu (1):
net: hns3: Add egress/ingress vlan filter for revision 0x21
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 3 - drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 - drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 78 ++-- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 47 +-- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 446 +++++++++------------ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 40 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 58 --- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 129 ------ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 5 - 9 files changed, 250 insertions(+), 558 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/6 net: hns3: Remove the default mask configuration for mac vlan table
From: Jian Shen <[email protected]>
The default mask configuration has been done by firmware, so the driver doesn't need to do it any more.
--- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 10 ------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 32 ---------------------- 2 files changed, 42 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +0 -10
@@ -177,7 +177,6 @@ enum hclge_opcode_type {HCLGE_OPC_MAC_VLAN_INSERT =0x1003 ,HCLGE_OPC_MAC_ETHTYPE_ADD =0x1010 ,HCLGE_OPC_MAC_ETHTYPE_REMOVE =0x1011 , -HCLGE_OPC_MAC_VLAN_MASK_SET =0x1012 ,/* Multicast linear table commands */ HCLGE_OPC_MTA_MAC_MODE_CFG = 0x1020,
@@ -591,15 +590,6 @@ struct hclge_mac_vlan_tbl_entry_cmd {u8 rsv2[6 ]; }; -#define HCLGE_VLAN_MASK_EN_B 0 -struct hclge_mac_vlan_mask_entry_cmd { -u8 rsv0[2 ]; -u8 vlan_mask; -u8 rsv1; -u8 mac_mask[6 ]; -u8 rsv2[14 ]; -}; -#define HCLGE_MAC_MGR_MASK_VLAN_B BIT(0)#define HCLGE_MAC_MGR_MASK_MAC_B BIT(1)#define HCLGE_MAC_MGR_MASK_ETHERTYPE_B BIT(2)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +0 -32
@@ -1939,36 +1939,11 @@ static int hclge_get_autoneg(struct hnae3_handle *handle)return hdev->hw.mac.autoneg; } -static int hclge_set_default_mac_vlan_mask (struct hclge_dev *hdev, -bool mask_vlan, -u8 *mac_mask) -{ -struct hclge_mac_vlan_mask_entry_cmd *req; -struct hclge_desc desc; -int status; - - req = (struct hclge_mac_vlan_mask_entry_cmd *)desc.data; -hclge_cmd_setup_basic_desc (&desc,HCLGE_OPC_MAC_VLAN_MASK_SET , false); - -hnae3_set_bit (req->vlan_mask,HCLGE_VLAN_MASK_EN_B , - mask_vlan ?1 :0 ); -ether_addr_copy (req->mac_mask, mac_mask); - - status =hclge_cmd_send (&hdev->hw, &desc,1 ); -if (status) -dev_err (&hdev->pdev->dev, -"Config mac_vlan_mask failed for cmd_send, ret =%d\n" , - status); - -return status; -} -static int hclge_mac_init (struct hclge_dev *hdev) {struct hnae3_handle *handle = &hdev->vport[0 ].nic;struct net_device *netdev = handle->kinfo.netdev;struct hclge_mac *mac = &hdev->hw.mac; -u8 mac_mask[ETH_ALEN ] = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };struct hclge_vport *vport;int mtu;int ret;
@@ -2011,13 +1986,6 @@ static int hclge_mac_init(struct hclge_dev *hdev) } } - ret =hclge_set_default_mac_vlan_mask (hdev, true, mac_mask); -if (ret) { -dev_err (&hdev->pdev->dev, -"set default mac_vlan_mask fail ret=%d\n" , ret); -return ret; - } -if (netdev) mtu = netdev->mtu;else
Signature · 1 line
2.7.4
PATCH 2/6 net: hns3: Clear mac vlan table entries when unload driver or function reset
In reply to Salil MehtaFrom: Jian Shen <[email protected]>
In original codes, the mac vlan table entries are not cleared when unload hns3 driver. The dirty mac vlan table entries will make the result of looking up mac vlan table being unexpected.
When doing core reset or global reset, the firmware will clear all the tables for driver, and driver shouldn't send any commands to firmware during reset. But when doing function reset, the driver needs to clear the tables itself.
This patch clears the mac vlan table entries for each client when unload driver or reset.
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 45 +++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +28 -17
@@ -21,6 +21,7 @@static void hns3_clear_all_ring (struct hnae3_handle *h);static void hns3_force_clear_all_rx_ring (struct hnae3_handle *h); +static void hns3_remove_hw_addr (struct net_device *netdev);static const char hns3_driver_name[] ="hns3" ;const char hns3_driver_version[] =VERMAGIC_STRING ;
@@ -3155,15 +3156,6 @@ static void hns3_init_mac_addr(struct net_device *netdev, bool init) } -static void hns3_uninit_mac_addr (struct net_device *netdev) -{ -struct hns3_nic_priv *priv =netdev_priv (netdev); -struct hnae3_handle *h = priv->ae_handle; - -if (h->ae_algo->ops->rm_uc_addr) - h->ae_algo->ops->rm_uc_addr (h, netdev->dev_addr); -} -static int hns3_restore_fd_rules (struct net_device *netdev) {struct hnae3_handle *h =hns3_get_handle (netdev);
@@ -3296,6 +3288,8 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)struct hns3_nic_priv *priv =netdev_priv (netdev);int ret; +hns3_remove_hw_addr (netdev); +if (netdev->reg_state !=NETREG_UNINITIALIZED )unregister_netdev (netdev);
@@ -3319,8 +3313,6 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset) priv->ring_data =NULL ; -hns3_uninit_mac_addr (netdev); -free_netdev (netdev); }
@@ -3392,6 +3384,25 @@ static void hns3_recover_hw_addr(struct net_device *ndev)hns3_nic_mc_sync (ndev, ha->addr); } +static void hns3_remove_hw_addr (struct net_device *netdev) +{ +struct netdev_hw_addr_list *list; +struct netdev_hw_addr *ha, *tmp; + +hns3_nic_uc_unsync (netdev, netdev->dev_addr); + +/* go through and unsync uc_addr entries to the device */ + list = &netdev->uc; +list_for_each_entry_safe (ha, tmp, &list->list, list) +hns3_nic_uc_unsync (netdev, ha->addr); + +/* go through and unsync mc_addr entries to the device */ + list = &netdev->mc; +list_for_each_entry_safe (ha, tmp, &list->list, list) +if (ha->refcount >1 ) +hns3_nic_mc_unsync (netdev, ha->addr); +} +static void hns3_clear_tx_ring (struct hns3_enet_ring *ring) {while (ring->next_to_clean != ring->next_to_use) {
@@ -3637,14 +3648,14 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)if (ret)netdev_err (netdev,"uninit ring error\n" ); -hns3_uninit_mac_addr (netdev); - -/* it is cumbersome for hardware to pick-and-choose rules for deletion -* from TCAM. Hence, for function reset software intervention is -* required to delete the rules +/* it is cumbersome for hardware to pick-and-choose entries for deletion +* from table space. Hence, for function reset software intervention is +* required to delete the entries */ -if (hns3_dev_ongoing_func_reset (ae_dev)) +if (hns3_dev_ongoing_func_reset (ae_dev)) { +hns3_remove_hw_addr (netdev);hns3_del_all_fd_rules (netdev, false); + }return ret; }
Signature · 1 line
2.7.4
PATCH 3/6 net: hns3: Optimize for unicast mac vlan table
In reply to Salil MehtaFrom: Jian Shen <[email protected]>
In previously implement for unicast mac vlan table, the space is shared by all the functions, driver does nothing when the space is exhausted. This patch preallocates the space of unicast mac vlan table for each function by software. Each function can only use its private space and available shared space, avoiding single function exhausts too much space, and other functions are unable to add unicast mac address.
--- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 11 ++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 147 ++++++++++++++++++++- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 18 +++ 3 files changed, 174 insertions(+), 2 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +11 -0
@@ -175,6 +175,7 @@ enum hclge_opcode_type {HCLGE_OPC_MAC_VLAN_REMOVE =0x1001 ,HCLGE_OPC_MAC_VLAN_TYPE_ID =0x1002 ,HCLGE_OPC_MAC_VLAN_INSERT =0x1003 , +HCLGE_OPC_MAC_VLAN_ALLOCATE =0x1004 ,HCLGE_OPC_MAC_ETHTYPE_ADD =0x1010 , HCLGE_OPC_MAC_ETHTYPE_REMOVE = 0x1011,
@@ -401,6 +402,8 @@ struct hclge_pf_res_cmd {#define HCLGE_CFG_RSS_SIZE_M GENMASK(31, 24)#define HCLGE_CFG_SPEED_ABILITY_S 0#define HCLGE_CFG_SPEED_ABILITY_M GENMASK(7, 0) +#define HCLGE_CFG_UMV_TBL_SPACE_S 16 +#define HCLGE_CFG_UMV_TBL_SPACE_M GENMASK(31, 16)struct hclge_cfg_param_cmd {__le32 offset;
@@ -590,6 +593,14 @@ struct hclge_mac_vlan_tbl_entry_cmd {u8 rsv2[6 ]; }; +#define HCLGE_UMV_SPC_ALC_B 0 +struct hclge_umv_spc_alc_cmd { +u8 allocate; +u8 rsv1[3 ]; +__le32 space_size; +u8 rsv2[16 ]; +}; +#define HCLGE_MAC_MGR_MASK_VLAN_B BIT(0)#define HCLGE_MAC_MGR_MASK_MAC_B BIT(1)#define HCLGE_MAC_MGR_MASK_ETHERTYPE_B BIT(2)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +145 -2
201 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +18 -0
@@ -14,6 +14,8 @@#define HCLGE_MOD_VERSION "1.0"#define HCLGE_DRIVER_NAME "hclge" +#define HCLGE_MAX_PF_NUM 8 +#define HCLGE_INVALID_VPORT 0xffff#define HCLGE_PF_CFG_BLOCK_SIZE 32
@@ -53,6 +55,10 @@#define HCLGE_RSS_TC_SIZE_6 64#define HCLGE_RSS_TC_SIZE_7 128 +#define HCLGE_UMV_TBL_SIZE 3072 +#define HCLGE_DEFAULT_UMV_SPACE_PER_PF \ + (HCLGE_UMV_TBL_SIZE / HCLGE_MAX_PF_NUM) +#define HCLGE_MTA_TBL_SIZE 4096#define HCLGE_TQP_RESET_TRY_TIMES 10
@@ -251,6 +257,7 @@ struct hclge_cfg {u8 default_speed;u32 numa_node_map;u8 speed_ability; +u16 umv_space; };struct hclge_tm_info {
@@ -680,6 +687,15 @@ struct hclge_dev {struct hclge_fd_cfg fd_cfg;struct hlist_head fd_rule_list;u16 hclge_fd_rule_num; + +u16 wanted_umv_size; +/* max available unicast mac vlan space */ +u16 max_umv_size; +/* private unicast mac vlan space, it's same for PF and its VFs */ +u16 priv_umv_size; +/* unicast mac vlan space shared by PF and its VFs */ +u16 share_umv_size; +struct mutex umv_mutex;/* protect share_umv_size */ };/* VPort level vlan tag configuration for TX direction */
@@ -732,6 +748,8 @@ struct hclge_vport {struct hclge_tx_vtag_cfg txvlan_cfg;struct hclge_rx_vtag_cfg rxvlan_cfg; +u16 used_umv_num; +int vport_id;struct hclge_dev *back;/* Back reference to associated dev */ struct hnae3_handle nic;
Signature · 1 line
2.7.4
PATCH 4/6 net: hns3: Drop depricated mta table support
In reply to Salil MehtaFrom: Jian Shen <[email protected]>
For mta table support has been dropped, remove the code for mta table.
--- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 3 - drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 - drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 - .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 30 --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 222 +-------------------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 24 --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 58 ------ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 129 ------------ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 5 - 9 files changed, 2 insertions(+), 474 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +0 -3
@@ -46,9 +46,6 @@ enum hclge_mbx_mac_vlan_subcode {HCLGE_MBX_MAC_VLAN_MC_MODIFY ,/* modify MC mac addr */ HCLGE_MBX_MAC_VLAN_MC_ADD ,/* add new MC mac addr */ HCLGE_MBX_MAC_VLAN_MC_REMOVE, /* remove MC mac addr */ -HCLGE_MBX_MAC_VLAN_MC_FUNC_MTA_ENABLE ,/* config func MTA enable */ -HCLGE_MBX_MAC_VLAN_MTA_TYPE_READ ,/* read func MTA type */ - HCLGE_MBX_MAC_VLAN_MTA_STATUS_UPDATE, /* update MTA status */ };/* below are per-VF vlan cfg subcodes */
drivers/net/ethernet/hisilicon/hns3/hnae3.h +0 -2
@@ -355,8 +355,6 @@ struct hnae3_ae_ops { const unsigned char *addr);int (*rm_mc_addr)(struct hnae3_handle *handle,const unsigned char *addr); -int (*update_mta_status)(struct hnae3_handle *handle); -void (*set_tso_stats)(struct hnae3_handle *handle,int enable);void (*update_stats)(struct hnae3_handle *handle,struct net_device_stats *net_stats);
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +0 -3
@@ -476,9 +476,6 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)if (netdev->flags &IFF_MULTICAST ) {if (__dev_mc_sync (netdev, hns3_nic_mc_sync, hns3_nic_mc_unsync))netdev_err (netdev,"sync mc address fail\n" ); - -if (h->ae_algo->ops->update_mta_status) - h->ae_algo->ops->update_mta_status (h); } }
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +0 -30
@@ -179,12 +179,6 @@ enum hclge_opcode_type {HCLGE_OPC_MAC_ETHTYPE_ADD =0x1010 ,HCLGE_OPC_MAC_ETHTYPE_REMOVE =0x1011 , -/* Multicast linear table commands */ -HCLGE_OPC_MTA_MAC_MODE_CFG =0x1020 , -HCLGE_OPC_MTA_MAC_FUNC_CFG =0x1021 , -HCLGE_OPC_MTA_TBL_ITEM_CFG =0x1022 , -HCLGE_OPC_MTA_TBL_ITEM_QUERY =0x1023 , -/* VLAN commands */ HCLGE_OPC_VLAN_FILTER_CTRL =0x1100 , HCLGE_OPC_VLAN_FILTER_PF_CFG = 0x1101,
@@ -623,30 +617,6 @@ struct hclge_mac_mgr_tbl_entry_cmd {u8 rsv3[2 ]; }; -#define HCLGE_CFG_MTA_MAC_SEL_S 0 -#define HCLGE_CFG_MTA_MAC_SEL_M GENMASK(1, 0) -#define HCLGE_CFG_MTA_MAC_EN_B 7 -struct hclge_mta_filter_mode_cmd { -u8 dmac_sel_en;/* Use lowest 2 bit as sel_mode, bit 7 as enable */ -u8 rsv[23 ]; -}; - -#define HCLGE_CFG_FUNC_MTA_ACCEPT_B 0 -struct hclge_cfg_func_mta_filter_cmd { -u8 accept;/* Only used lowest 1 bit */ -u8 function_id; -u8 rsv[22 ]; -}; - -#define HCLGE_CFG_MTA_ITEM_ACCEPT_B 0 -#define HCLGE_CFG_MTA_ITEM_IDX_S 0 -#define HCLGE_CFG_MTA_ITEM_IDX_M GENMASK(11, 0) -struct hclge_cfg_func_mta_item_cmd { -__le16 item_idx;/* Only used lowest 12 bit */ -u8 accept;/* Only used lowest 1 bit */ -u8 rsv[21 ]; -}; -struct hclge_mac_vlan_add_cmd {__le16 flags;__le16 mac_addr_hi16;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +2 -220
266 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +0 -24
@@ -59,8 +59,6 @@#define HCLGE_DEFAULT_UMV_SPACE_PER_PF \ (HCLGE_UMV_TBL_SIZE / HCLGE_MAX_PF_NUM) -#define HCLGE_MTA_TBL_SIZE 4096 -#define HCLGE_TQP_RESET_TRY_TIMES 10#define HCLGE_PHY_PAGE_MDIX 0
@@ -168,13 +166,6 @@ enum HCLGE_MAC_DUPLEX {HCLGE_MAC_FULL }; -enum hclge_mta_dmac_sel_type { -HCLGE_MAC_ADDR_47_36 , -HCLGE_MAC_ADDR_46_35 , -HCLGE_MAC_ADDR_45_34 , -HCLGE_MAC_ADDR_44_33 , -}; -struct hclge_mac {u8 phy_addr;u8 flag;
@@ -677,9 +668,6 @@ struct hclge_dev {u32 pkt_buf_size;/* Total pf buf size for tx/rx */ u32 mps;/* Max packet size */ -enum hclge_mta_dmac_sel_type mta_mac_sel_type; -bool enable_mta;/* Multicast filter enable */ -struct hclge_vlan_type_cfg vlan_type_cfg;unsigned long vlan_table[VLAN_N_VID ][BITS_TO_LONGS (HCLGE_VPORT_NUM )];
@@ -754,9 +742,6 @@ struct hclge_vport {struct hclge_dev *back;/* Back reference to associated dev */ struct hnae3_handle nic;struct hnae3_handle roce; - -bool accept_mta_mc;/* whether to accept mta filter multicast */ -unsigned long mta_shadow[BITS_TO_LONGS (HCLGE_MTA_TBL_SIZE )]; }; void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc,
@@ -771,15 +756,6 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport,int hclge_rm_mc_addr_common (struct hclge_vport *vport,const unsigned char *addr); -int hclge_cfg_func_mta_filter (struct hclge_dev *hdev, -u8 func_id, -bool enable); -int hclge_update_mta_status_common (struct hclge_vport *vport, -unsigned long *status, -u16 idx, -u16 count, -bool update_filter); -struct hclge_vport *hclge_get_vport (struct hnae3_handle *handle); int hclge_bind_ring_with_vector(struct hclge_vport *vport, int vector_id, bool en,
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +0 -58
70 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +0 -129
147 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +0 -5
@@ -47,9 +47,6 @@#define HCLGEVF_RSS_CFG_TBL_NUM \ (HCLGEVF_RSS_IND_TBL_SIZE / HCLGEVF_RSS_CFG_TBL_SIZE) -#define HCLGEVF_MTA_TBL_SIZE 4096 -#define HCLGEVF_MTA_TYPE_SEL_MAX 4 -/* states of hclgevf device & tasks */ enum hclgevf_states {/* device states */
@@ -157,8 +154,6 @@ struct hclgevf_dev {u16 *vector_status;int *vector_irq; -bool accept_mta_mc;/* whether to accept mta filter multicast */ -u8 mta_mac_sel_type;bool mbx_event_pending;struct hclgevf_mbx_resp_status mbx_resp;/* mailbox response */ struct hclgevf_mbx_arq_ring arq;/* mailbox async rx queue */
Signature · 1 line
2.7.4
PATCH 5/6 net: hns3: Add egress/ingress vlan filter for revision 0x21
In reply to Salil MehtaFrom: Zhongzhu Liu <[email protected]>
In revision 0x21, hw supports both ingress and egress vlan filter. This patch adds support for it.
--- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 45 +++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +36 -9
@@ -5523,7 +5523,7 @@ static int hclge_do_ioctl(struct hnae3_handle *handle, struct ifreq *ifr, }static int hclge_set_vlan_filter_ctrl (struct hclge_dev *hdev,u8 vlan_type, -bool filter_en) +u8 fe_type,bool filter_en) {struct hclge_vlan_filter_ctrl_cmd *req;struct hclge_desc desc;
@@ -5533,7 +5533,7 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data; req->vlan_type = vlan_type; - req->vlan_fe = filter_en; + req->vlan_fe = filter_en ? fe_type :0 ; ret =hclge_cmd_send (&hdev->hw, &desc,1 );if (ret)
@@ -5545,13 +5545,30 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,#define HCLGE_FILTER_TYPE_VF 0#define HCLGE_FILTER_TYPE_PORT 1 +#define HCLGE_FILTER_FE_EGRESS_V1_B BIT(0) +#define HCLGE_FILTER_FE_NIC_INGRESS_B BIT(0) +#define HCLGE_FILTER_FE_NIC_EGRESS_B BIT(1) +#define HCLGE_FILTER_FE_ROCE_INGRESS_B BIT(2) +#define HCLGE_FILTER_FE_ROCE_EGRESS_B BIT(3) +#define HCLGE_FILTER_FE_EGRESS (HCLGE_FILTER_FE_NIC_EGRESS_B \ + | HCLGE_FILTER_FE_ROCE_EGRESS_B) +#define HCLGE_FILTER_FE_INGRESS (HCLGE_FILTER_FE_NIC_INGRESS_B \ + | HCLGE_FILTER_FE_ROCE_INGRESS_B)static void hclge_enable_vlan_filter (struct hnae3_handle *handle,bool enable) {struct hclge_vport *vport =hclge_get_vport (handle);struct hclge_dev *hdev = vport->back; -hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_VF , enable); +if (hdev->pdev->revision >=0x21 ) { +hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_VF , +HCLGE_FILTER_FE_EGRESS , enable); +hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_PORT , +HCLGE_FILTER_FE_INGRESS , enable); + }else { +hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_VF , +HCLGE_FILTER_FE_EGRESS_V1_B , enable); + } } static int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid,
@@ -5853,13 +5870,23 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)int ret;int i; - ret =hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_VF , true); -if (ret) -return ret; +if (hdev->pdev->revision >=0x21 ) { + ret =hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_VF , +HCLGE_FILTER_FE_EGRESS , true); +if (ret) +return ret; - ret =hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_PORT , true); -if (ret) -return ret; + ret =hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_PORT , +HCLGE_FILTER_FE_INGRESS , true); +if (ret) +return ret; + }else { + ret =hclge_set_vlan_filter_ctrl (hdev,HCLGE_FILTER_TYPE_VF , +HCLGE_FILTER_FE_EGRESS_V1_B , + true); +if (ret) +return ret; + } hdev->vlan_type_cfg.rx_in_fst_vlan_type =HCLGE_DEF_VLAN_TYPE ; hdev->vlan_type_cfg.rx_in_sec_vlan_type =HCLGE_DEF_VLAN_TYPE ;
Signature · 1 line
2.7.4
PATCH 6/6 net: hns3: Fix for rx vlan id handle to support Rev 0x21 hardware
In reply to Salil MehtaFrom: Jian Shen <[email protected]>
In revision 0x20, we use vlan id != 0 to check whether a vlan tag has been offloaded, so vlan id 0 is not supported.
In revision 0x21, rx buffer descriptor adds two bits to indicate whether one or more vlan tags have been offloaded, so vlan id 0 is valid now.
This patch seperates the handle for vlan id 0, add vlan id 0 support for revision 0x21.
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 30 +++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +13 -17
@@ -2200,18 +2200,18 @@ static void hns3_rx_skb(struct hns3_enet_ring *ring, struct sk_buff *skb)napi_gro_receive (&ring->tqp_vector->napi, skb); } -static u16 hns3_parse_vlan_tag (struct hns3_enet_ring *ring, -struct hns3_desc *desc,u32 l234info) +static bool hns3_parse_vlan_tag (struct hns3_enet_ring *ring, +struct hns3_desc *desc,u32 l234info, +u16 *vlan_tag) {struct pci_dev *pdev = ring->tqp->handle->pdev; -u16 vlan_tag;if (pdev->revision ==0x20 ) { - vlan_tag =le16_to_cpu (desc->rx.ot_vlan_tag); -if (!(vlan_tag &VLAN_VID_MASK )) - vlan_tag =le16_to_cpu (desc->rx.vlan_tag); + *vlan_tag =le16_to_cpu (desc->rx.ot_vlan_tag); +if (!(*vlan_tag &VLAN_VID_MASK )) + *vlan_tag =le16_to_cpu (desc->rx.vlan_tag); -return vlan_tag; +return (*vlan_tag !=0 ); }#define HNS3_STRP_OUTER_VLAN 0x1
@@ -2220,17 +2220,14 @@ static u16 hns3_parse_vlan_tag(struct hns3_enet_ring *ring,switch (hnae3_get_field (l234info,HNS3_RXD_STRP_TAGP_M ,HNS3_RXD_STRP_TAGP_S )) {case HNS3_STRP_OUTER_VLAN : - vlan_tag =le16_to_cpu (desc->rx.ot_vlan_tag); -break ; + *vlan_tag =le16_to_cpu (desc->rx.ot_vlan_tag); +return true;case HNS3_STRP_INNER_VLAN : - vlan_tag =le16_to_cpu (desc->rx.vlan_tag); -break ; + *vlan_tag =le16_to_cpu (desc->rx.vlan_tag); +return true;default : - vlan_tag =0 ; -break ; +return false; } - -return vlan_tag; } static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
@@ -2332,8 +2329,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,if (netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) {u16 vlan_tag; - vlan_tag =hns3_parse_vlan_tag (ring, desc, l234info); -if (vlan_tag &VLAN_VID_MASK ) +if (hns3_parse_vlan_tag (ring, desc, l234info, &vlan_tag))__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ), vlan_tag);
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Salil Mehta <[email protected]>
Date: Fri, 5 Oct 2018 18:03:23 +0100
Quoted 2 lines
This patch-set presents necessary modifications, fixes & cleanups related to Unicast MAC Vlan Table to support revision
0x21hardware.
Series applied.