net: hns3: store rx VLAN tag offload state for VF
authorJian Shen <shenjian15@huawei.com>
Wed, 30 Apr 2025 09:30:49 +0000 (17:30 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 May 2025 14:19:47 +0000 (07:19 -0700)
The VF driver missed to store the rx VLAN tag strip state when
user change the rx VLAN tag offload state. And it will default
to enable the rx vlan tag strip when re-init VF device after
reset. So if user disable rx VLAN tag offload, and trig reset,
then the HW will still strip the VLAN tag from packet nad fill
into RX BD, but the VF driver will ignore it for rx VLAN tag
offload disabled. It may cause the rx VLAN tag dropped.

Fixes: b2641e2ad456 ("net: hns3: Add support of hardware rx-vlan-offload to HNS3 VF driver")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250430093052.2400464-2-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h

index 9ba767740a043f9c8fe3201717f46372888c99c7..dada42e7e0ec96a4e346dadb5045c72a73956615 100644 (file)
@@ -1292,9 +1292,8 @@ static void hclgevf_sync_vlan_filter(struct hclgevf_dev *hdev)
        rtnl_unlock();
 }
 
-static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
+static int hclgevf_en_hw_strip_rxvtag_cmd(struct hclgevf_dev *hdev, bool enable)
 {
-       struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
        struct hclge_vf_to_pf_msg send_msg;
 
        hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
@@ -1303,6 +1302,19 @@ static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
        return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
 }
 
+static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
+{
+       struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
+       int ret;
+
+       ret = hclgevf_en_hw_strip_rxvtag_cmd(hdev, enable);
+       if (ret)
+               return ret;
+
+       hdev->rxvtag_strip_en = enable;
+       return 0;
+}
+
 static int hclgevf_reset_tqp(struct hnae3_handle *handle)
 {
 #define HCLGEVF_RESET_ALL_QUEUE_DONE   1U
@@ -2204,12 +2216,13 @@ static int hclgevf_rss_init_hw(struct hclgevf_dev *hdev)
                                          tc_valid, tc_size);
 }
 
-static int hclgevf_init_vlan_config(struct hclgevf_dev *hdev)
+static int hclgevf_init_vlan_config(struct hclgevf_dev *hdev,
+                                   bool rxvtag_strip_en)
 {
        struct hnae3_handle *nic = &hdev->nic;
        int ret;
 
-       ret = hclgevf_en_hw_strip_rxvtag(nic, true);
+       ret = hclgevf_en_hw_strip_rxvtag(nic, rxvtag_strip_en);
        if (ret) {
                dev_err(&hdev->pdev->dev,
                        "failed to enable rx vlan offload, ret = %d\n", ret);
@@ -2879,7 +2892,7 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev)
        if (ret)
                return ret;
 
-       ret = hclgevf_init_vlan_config(hdev);
+       ret = hclgevf_init_vlan_config(hdev, hdev->rxvtag_strip_en);
        if (ret) {
                dev_err(&hdev->pdev->dev,
                        "failed(%d) to initialize VLAN config\n", ret);
@@ -2994,7 +3007,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
                goto err_config;
        }
 
-       ret = hclgevf_init_vlan_config(hdev);
+       ret = hclgevf_init_vlan_config(hdev, true);
        if (ret) {
                dev_err(&hdev->pdev->dev,
                        "failed(%d) to initialize VLAN config\n", ret);
index cccef32284616bd62885ca130e19dcbe5e5cfc8a..0208425ab594f5eb20bec49a1829291f4d60a6dd 100644 (file)
@@ -253,6 +253,7 @@ struct hclgevf_dev {
        int *vector_irq;
 
        bool gro_en;
+       bool rxvtag_strip_en;
 
        unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)];