DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH 04/10] net/hns3: fix lack of rollback after setting PVID failed
Date: Wed, 31 Mar 2021 18:01:38 +0800	[thread overview]
Message-ID: <1617184904-55349-5-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1617184904-55349-1-git-send-email-humin29@huawei.com>

From: Chengchang Tang <tangchengchang@huawei.com>

Currently, three hardware operations are involved in setting the PVID.
If any operation fails, a failure will be returned. And there may be
residual hardware configurations because no rollback is performed.

This patch adds rollback operation for setting PVID to avoid residual
hardware configuration after the PVID fails to be configured.

Fixes: 411d23b9eafb ("net/hns3: support VLAN")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 953e8a1..005e8bf 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -964,7 +964,7 @@ 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;
-	int ret;
+	int ret, err;
 
 	if (on == 0 && pvid != hw->port_base_vlan_cfg.pvid) {
 		if (hw->port_base_vlan_cfg.pvid != HNS3_INVALID_PVID)
@@ -987,7 +987,7 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on)
 	if (ret) {
 		hns3_err(hw, "failed to config rx vlan strip for pvid, "
 			 "ret = %d", ret);
-		return ret;
+		goto pvid_vlan_strip_fail;
 	}
 
 	if (pvid == HNS3_INVALID_PVID)
@@ -996,13 +996,27 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on)
 	if (ret) {
 		hns3_err(hw, "failed to update vlan filter entries, ret = %d",
 			 ret);
-		return ret;
+		goto vlan_filter_set_fail;
 	}
 
 out:
 	hw->port_base_vlan_cfg.state = port_base_vlan_state;
 	hw->port_base_vlan_cfg.pvid = on ? pvid : HNS3_INVALID_PVID;
 	return ret;
+
+vlan_filter_set_fail:
+	err = hns3_en_pvid_strip(hns, hw->port_base_vlan_cfg.state ==
+					HNS3_PORT_BASE_VLAN_ENABLE);
+	if (err)
+		hns3_err(hw, "fail to rollback pvid strip, ret = %d", err);
+
+pvid_vlan_strip_fail:
+	err = hns3_vlan_txvlan_cfg(hns, hw->port_base_vlan_cfg.state,
+					hw->port_base_vlan_cfg.pvid);
+	if (err)
+		hns3_err(hw, "fail to rollback txvlan status, ret = %d", err);
+
+	return ret;
 }
 
 static int
-- 
2.7.4


  parent reply	other threads:[~2021-03-31 10:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31 10:01 [dpdk-dev] [PATCH 00/10] some bugfixes for hns3 PMD Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 01/10] net/hns3: fix some function names for copper media type Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 02/10] net/hns3: fix set default MAC addr fail in bonding of VF Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 03/10] net/hns3: fix the FLR miss detection Min Hu (Connor)
2021-03-31 10:01 ` Min Hu (Connor) [this message]
2021-03-31 10:01 ` [dpdk-dev] [PATCH 05/10] net/hns3: fix flow control exception Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 06/10] net/hns3: fix flow counter not cleared when create Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 07/10] net/hns3: fix VF mailbox head field wrong update Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 08/10] net/hns3: support get device version when dump register Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 09/10] net/hns3: delete redundant blank line Min Hu (Connor)
2021-03-31 10:01 ` [dpdk-dev] [PATCH 10/10] net/hns3: fix code style static warning Min Hu (Connor)
2021-04-08 17:02 ` [dpdk-dev] [PATCH 00/10] some bugfixes for hns3 PMD Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1617184904-55349-5-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).