From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00F89A04DD for ; Wed, 28 Oct 2020 11:50:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 75A464C90; Wed, 28 Oct 2020 11:50:04 +0100 (CET) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by dpdk.org (Postfix) with ESMTP id 5286AC9FA for ; Wed, 28 Oct 2020 11:50:03 +0100 (CET) Received: by mail-wr1-f53.google.com with SMTP id b8so5190145wrn.0 for ; Wed, 28 Oct 2020 03:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f+oVDiEu9yA9HWSe6miaZOrQs9ed3Rj5KJjTOU1H9NE=; b=hSBk9V8jRBYJb6Q29q4z2+2XoZkdymnipKJ88umZTnb2MZa3PkxEzWzwD1RwcLAFhf /jjFQas6yRIGTqYSXpiiGkBqSSbmk4HfNjtVIogSB0PzG9HNbxEwT7Zl9gcQ1EyCEGaX c2YTGuYibDIT4m9WaVtA0uQnYWY+ufwwhSEqqg98eKRhJP+QrjVBGpD3oOx6Jczuh+eN Wkmy88oqUKnGFvMfKm61+J1gBEc6MdggwBQ0BVNQXe6czMMfUE05TWZ4t1ID1+wDhITk RJBQsScQ3w7pGStvEMlrT7SRfawUFsNL6NpRwzHzTYhE+iJHUpCjG7yIPwQsAZBqu1Qt DxGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f+oVDiEu9yA9HWSe6miaZOrQs9ed3Rj5KJjTOU1H9NE=; b=NzOWlekJkuMglitm6PFnWOyN3uGzUgLhGfqp+5jFIemG8jZ4E0pmGvxZCKZCiOEvlh RDanKiy90mhoXPh0Mj94Smfz+587vQetfuwBxIysCorP4bTvfVW4xA2EM1X0w3dHgQwV m//1px9fSfGASp0dyzt21Yg3u6E4SVO4pyKIqBrnUQd+4PffpF3WBM99HT6Eyf8e5jDO vqw7Uazqlays+xHAgvlivaCSFtn/XFds09KHF8Fka51EblnKs22lOMwa1JejIIFbD6GK W6C7KUhpILO/e2QX3J2emqlRIRTMC/Wclt50Y3XAmRVPvBV0ut9TQHhp1qW2wweAMR4n mnUA== X-Gm-Message-State: AOAM530Dm+n+uUZZ6qurHlrq17t/YIWma6346VnYXXGAR1afLs3zLZas WU2HCJJH4YGwtkkf6ST45wLOcUD+asA0vM1x X-Google-Smtp-Source: ABdhPJwlvp5fR4aYNVLOxOKiuE+lFKEZKFuFAeV8i3FwhBn3xF5gKUPEupWy9zI4xRE+6IsV2za65Q== X-Received: by 2002:adf:cd81:: with SMTP id q1mr8552862wrj.410.1603882201975; Wed, 28 Oct 2020 03:50:01 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id o10sm3967641wma.47.2020.10.28.03.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:50:01 -0700 (PDT) From: luca.boccassi@gmail.com To: Chengchang Tang Cc: Wei Hu , dpdk stable Date: Wed, 28 Oct 2020 10:43:54 +0000 Message-Id: <20201028104606.3504127-75-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: fix deleting default VLAN from PF' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/30/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 6f16309fc0b462eeb94fb6f2b444b32e7e9665c9 Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Tue, 22 Sep 2020 20:03:14 +0800 Subject: [PATCH] net/hns3: fix deleting default VLAN from PF [ upstream commit c1ecff85d18baa1e43e82d8cb9aebd518f0f0c7c ] Currently, the default VLAN (vlan id 0) will never be deleted from the hardware VLAN table based on hns3 PF device. As a result, even a non-zero PVID is set by calling rte_eth_dev_set_vlan_pvid based on hns3 PF device, packets with VLAN 0 and without VLAN are still received by PF driver in Rx direction. This patch deletes the restriction that VLAN 0 cannot be removed in PVID configuration to ensure packets without PVID will be filtered when PVID is set. And the patch adds VLAN 0 to the soft list when initializing vlan configuration to ensure that VLAN 0 will be deleted from the hardware VLAN table when device is closed. Fixes: 411d23b9eafb ("net/hns3: support VLAN") Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 105 +++++++++++++++------------------ 1 file changed, 48 insertions(+), 57 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 27c89abfab..76f163d129 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -35,7 +35,7 @@ #define HNS3_DEFAULT_PORT_CONF_QUEUES_NUM 1 #define HNS3_SERVICE_INTERVAL 1000000 /* us */ -#define HNS3_INVLID_PVID 0xFFFF +#define HNS3_INVALID_PVID 0xFFFF #define HNS3_FILTER_TYPE_VF 0 #define HNS3_FILTER_TYPE_PORT 1 @@ -338,8 +338,9 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) int ret = 0; /* - * When vlan filter is enabled, hardware regards vlan id 0 as the entry - * for normal packet, deleting vlan id 0 is not allowed. + * When vlan filter is enabled, hardware regards packets without vlan + * as packets with vlan 0. So, to receive packets without vlan, vlan id + * 0 is not allowed to be removed by rte_eth_dev_vlan_filter. */ if (on == 0 && vlan_id == 0) return 0; @@ -356,7 +357,7 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) writen_to_tbl = true; } - if (ret == 0 && vlan_id) { + if (ret == 0) { if (on) hns3_add_dev_vlan_table(hns, vlan_id, writen_to_tbl); else @@ -720,16 +721,6 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state, return ret; } -static void -hns3_store_port_base_vlan_info(struct hns3_adapter *hns, uint16_t pvid, int on) -{ - struct hns3_hw *hw = &hns->hw; - - hw->port_base_vlan_cfg.state = on ? - HNS3_PORT_BASE_VLAN_ENABLE : HNS3_PORT_BASE_VLAN_DISABLE; - - hw->port_base_vlan_cfg.pvid = pvid; -} static void hns3_rm_all_vlan_table(struct hns3_adapter *hns, bool is_del_list) @@ -738,10 +729,10 @@ hns3_rm_all_vlan_table(struct hns3_adapter *hns, bool is_del_list) struct hns3_pf *pf = &hns->pf; LIST_FOREACH(vlan_entry, &pf->vlan_list, next) { - if (vlan_entry->hd_tbl_status) + if (vlan_entry->hd_tbl_status) { hns3_set_port_vlan_filter(hns, vlan_entry->vlan_id, 0); - - vlan_entry->hd_tbl_status = false; + vlan_entry->hd_tbl_status = false; + } } if (is_del_list) { @@ -761,10 +752,10 @@ hns3_add_all_vlan_table(struct hns3_adapter *hns) struct hns3_pf *pf = &hns->pf; LIST_FOREACH(vlan_entry, &pf->vlan_list, next) { - if (!vlan_entry->hd_tbl_status) + if (!vlan_entry->hd_tbl_status) { hns3_set_port_vlan_filter(hns, vlan_entry->vlan_id, 1); - - vlan_entry->hd_tbl_status = true; + vlan_entry->hd_tbl_status = true; + } } } @@ -775,7 +766,7 @@ hns3_remove_all_vlan_table(struct hns3_adapter *hns) int ret; hns3_rm_all_vlan_table(hns, true); - if (hw->port_base_vlan_cfg.pvid != HNS3_INVLID_PVID) { + if (hw->port_base_vlan_cfg.pvid != HNS3_INVALID_PVID) { ret = hns3_set_port_vlan_filter(hns, hw->port_base_vlan_cfg.pvid, 0); if (ret) { @@ -788,40 +779,41 @@ hns3_remove_all_vlan_table(struct hns3_adapter *hns) static int hns3_update_vlan_filter_entries(struct hns3_adapter *hns, - uint16_t port_base_vlan_state, - uint16_t new_pvid, uint16_t old_pvid) + uint16_t port_base_vlan_state, uint16_t new_pvid) { struct hns3_hw *hw = &hns->hw; - int ret = 0; + uint16_t old_pvid; + int ret; if (port_base_vlan_state == HNS3_PORT_BASE_VLAN_ENABLE) { - if (old_pvid != HNS3_INVLID_PVID && old_pvid != 0) { + old_pvid = hw->port_base_vlan_cfg.pvid; + if (old_pvid != HNS3_INVALID_PVID) { ret = hns3_set_port_vlan_filter(hns, old_pvid, 0); if (ret) { - hns3_err(hw, - "Failed to clear clear old pvid filter, ret =%d", - ret); + hns3_err(hw, "failed to remove old pvid %u, " + "ret = %d", old_pvid, ret); return ret; } } hns3_rm_all_vlan_table(hns, false); - return hns3_set_port_vlan_filter(hns, new_pvid, 1); - } - - if (new_pvid != 0) { + ret = hns3_set_port_vlan_filter(hns, new_pvid, 1); + if (ret) { + hns3_err(hw, "failed to add new pvid %u, ret = %d", + new_pvid, ret); + return ret; + } + } else { ret = hns3_set_port_vlan_filter(hns, new_pvid, 0); if (ret) { - hns3_err(hw, "Failed to set port vlan filter, ret =%d", - ret); + hns3_err(hw, "failed to remove pvid %u, ret = %d", + new_pvid, ret); return ret; } - } - if (new_pvid == hw->port_base_vlan_cfg.pvid) hns3_add_all_vlan_table(hns); - - return ret; + } + return 0; } static int @@ -857,11 +849,10 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) { struct hns3_hw *hw = &hns->hw; uint16_t port_base_vlan_state; - uint16_t old_pvid; int ret; if (on == 0 && pvid != hw->port_base_vlan_cfg.pvid) { - if (hw->port_base_vlan_cfg.pvid != HNS3_INVLID_PVID) + if (hw->port_base_vlan_cfg.pvid != HNS3_INVALID_PVID) hns3_warn(hw, "Invalid operation! As current pvid set " "is %u, disable pvid %u is invalid", hw->port_base_vlan_cfg.pvid, pvid); @@ -884,19 +875,18 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) return ret; } - if (pvid == HNS3_INVLID_PVID) + if (pvid == HNS3_INVALID_PVID) goto out; - old_pvid = hw->port_base_vlan_cfg.pvid; - ret = hns3_update_vlan_filter_entries(hns, port_base_vlan_state, pvid, - old_pvid); + ret = hns3_update_vlan_filter_entries(hns, port_base_vlan_state, pvid); if (ret) { - hns3_err(hw, "Failed to update vlan filter entries, ret =%d", + hns3_err(hw, "failed to update vlan filter entries, ret = %d", ret); return ret; } out: - hns3_store_port_base_vlan_info(hns, pvid, on); + hw->port_base_vlan_cfg.state = port_base_vlan_state; + hw->port_base_vlan_cfg.pvid = on ? pvid : HNS3_INVALID_PVID; return ret; } @@ -919,20 +909,19 @@ hns3_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on) return ret; } -static void -init_port_base_vlan_info(struct hns3_hw *hw) -{ - hw->port_base_vlan_cfg.state = HNS3_PORT_BASE_VLAN_DISABLE; - hw->port_base_vlan_cfg.pvid = HNS3_INVLID_PVID; -} - static int hns3_default_vlan_config(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; int ret; - ret = hns3_set_port_vlan_filter(hns, 0, 1); + /* + * When vlan filter is enabled, hardware regards packets without vlan + * as packets with vlan 0. Therefore, if vlan 0 is not in the vlan + * table, packets without vlan won't be received. So, add vlan 0 as + * the default vlan. + */ + ret = hns3_vlan_filter_configure(hns, 0, 1); if (ret) hns3_err(hw, "default vlan 0 config failed, ret =%d", ret); return ret; @@ -951,8 +940,10 @@ hns3_init_vlan_config(struct hns3_adapter *hns) * ensure that the hardware configuration remains unchanged before and * after reset. */ - if (rte_atomic16_read(&hw->reset.resetting) == 0) - init_port_base_vlan_info(hw); + if (rte_atomic16_read(&hw->reset.resetting) == 0) { + hw->port_base_vlan_cfg.state = HNS3_PORT_BASE_VLAN_DISABLE; + hw->port_base_vlan_cfg.pvid = HNS3_INVALID_PVID; + } ret = hns3_vlan_filter_init(hns); if (ret) { @@ -974,7 +965,7 @@ hns3_init_vlan_config(struct hns3_adapter *hns) * and hns3_restore_vlan_conf later. */ if (rte_atomic16_read(&hw->reset.resetting) == 0) { - ret = hns3_vlan_pvid_configure(hns, HNS3_INVLID_PVID, 0); + ret = hns3_vlan_pvid_configure(hns, HNS3_INVALID_PVID, 0); if (ret) { hns3_err(hw, "pvid set fail in pf, ret =%d", ret); return ret; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:14.104554495 +0000 +++ 0075-net-hns3-fix-deleting-default-VLAN-from-PF.patch 2020-10-28 10:35:11.580831143 +0000 @@ -1,8 +1,10 @@ -From c1ecff85d18baa1e43e82d8cb9aebd518f0f0c7c Mon Sep 17 00:00:00 2001 +From 6f16309fc0b462eeb94fb6f2b444b32e7e9665c9 Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Tue, 22 Sep 2020 20:03:14 +0800 Subject: [PATCH] net/hns3: fix deleting default VLAN from PF +[ upstream commit c1ecff85d18baa1e43e82d8cb9aebd518f0f0c7c ] + Currently, the default VLAN (vlan id 0) will never be deleted from the hardware VLAN table based on hns3 PF device. As a result, even a non-zero PVID is set by calling rte_eth_dev_set_vlan_pvid based on hns3 @@ -16,7 +18,6 @@ hardware VLAN table when device is closed. Fixes: 411d23b9eafb ("net/hns3: support VLAN") -Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) @@ -25,7 +26,7 @@ 1 file changed, 48 insertions(+), 57 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 3e98df33c7..abc1742119 100644 +index 27c89abfab..76f163d129 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -35,7 +35,7 @@ @@ -37,7 +38,7 @@ #define HNS3_FILTER_TYPE_VF 0 #define HNS3_FILTER_TYPE_PORT 1 -@@ -346,8 +346,9 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) +@@ -338,8 +338,9 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) int ret = 0; /* @@ -49,7 +50,7 @@ */ if (on == 0 && vlan_id == 0) return 0; -@@ -364,7 +365,7 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) +@@ -356,7 +357,7 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) writen_to_tbl = true; } @@ -58,7 +59,7 @@ if (on) hns3_add_dev_vlan_table(hns, vlan_id, writen_to_tbl); else -@@ -743,16 +744,6 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state, +@@ -720,16 +721,6 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state, return ret; } @@ -75,7 +76,7 @@ static void hns3_rm_all_vlan_table(struct hns3_adapter *hns, bool is_del_list) -@@ -761,10 +752,10 @@ hns3_rm_all_vlan_table(struct hns3_adapter *hns, bool is_del_list) +@@ -738,10 +729,10 @@ hns3_rm_all_vlan_table(struct hns3_adapter *hns, bool is_del_list) struct hns3_pf *pf = &hns->pf; LIST_FOREACH(vlan_entry, &pf->vlan_list, next) { @@ -89,7 +90,7 @@ } if (is_del_list) { -@@ -784,10 +775,10 @@ hns3_add_all_vlan_table(struct hns3_adapter *hns) +@@ -761,10 +752,10 @@ hns3_add_all_vlan_table(struct hns3_adapter *hns) struct hns3_pf *pf = &hns->pf; LIST_FOREACH(vlan_entry, &pf->vlan_list, next) { @@ -103,7 +104,7 @@ } } -@@ -798,7 +789,7 @@ hns3_remove_all_vlan_table(struct hns3_adapter *hns) +@@ -775,7 +766,7 @@ hns3_remove_all_vlan_table(struct hns3_adapter *hns) int ret; hns3_rm_all_vlan_table(hns, true); @@ -112,7 +113,7 @@ ret = hns3_set_port_vlan_filter(hns, hw->port_base_vlan_cfg.pvid, 0); if (ret) { -@@ -811,40 +802,41 @@ hns3_remove_all_vlan_table(struct hns3_adapter *hns) +@@ -788,40 +779,41 @@ hns3_remove_all_vlan_table(struct hns3_adapter *hns) static int hns3_update_vlan_filter_entries(struct hns3_adapter *hns, @@ -171,7 +172,7 @@ } static int -@@ -883,11 +875,10 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) +@@ -857,11 +849,10 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) { struct hns3_hw *hw = &hns->hw; uint16_t port_base_vlan_state; @@ -184,7 +185,7 @@ hns3_warn(hw, "Invalid operation! As current pvid set " "is %u, disable pvid %u is invalid", hw->port_base_vlan_cfg.pvid, pvid); -@@ -910,19 +901,18 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) +@@ -884,19 +875,18 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) return ret; } @@ -209,8 +210,8 @@ return ret; } -@@ -968,20 +958,19 @@ hns3_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on) - return 0; +@@ -919,20 +909,19 @@ hns3_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on) + return ret; } -static void @@ -237,7 +238,7 @@ if (ret) hns3_err(hw, "default vlan 0 config failed, ret =%d", ret); return ret; -@@ -1000,8 +989,10 @@ hns3_init_vlan_config(struct hns3_adapter *hns) +@@ -951,8 +940,10 @@ hns3_init_vlan_config(struct hns3_adapter *hns) * ensure that the hardware configuration remains unchanged before and * after reset. */ @@ -250,7 +251,7 @@ ret = hns3_vlan_filter_init(hns); if (ret) { -@@ -1023,7 +1014,7 @@ hns3_init_vlan_config(struct hns3_adapter *hns) +@@ -974,7 +965,7 @@ hns3_init_vlan_config(struct hns3_adapter *hns) * and hns3_restore_vlan_conf later. */ if (rte_atomic16_read(&hw->reset.resetting) == 0) {