DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
	stable@dpdk.org, Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 3/3] net/nfp: fix the reconfigure logic of set mac address
Date: Sat, 28 Oct 2023 14:23:15 +0800	[thread overview]
Message-ID: <20231028062315.1843075-4-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231028062315.1843075-1-chaoyong.he@corigine.com>

If the reconfigure API exit abnormally, the value in the config bar
will not same with the value stored in the data structure.

Fix this by add a local variable to hold the temporary value and the
logic of store it when no error happen.

Fixes: 2fe669f4bcd2 ("net/nfp: support MAC address change")
Cc: stable@dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_common.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index ac97e3bed5..a4ba16445d 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -362,8 +362,8 @@ int
 nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		struct rte_ether_addr *mac_addr)
 {
-	uint32_t ctrl;
 	uint32_t update;
+	uint32_t new_ctrl;
 	struct nfp_hw *hw;
 	struct nfp_net_hw *net_hw;
 
@@ -379,17 +379,19 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	nfp_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->ctrl;
+	new_ctrl = hw->ctrl;
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
-		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
+		new_ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
-	if (nfp_reconfig(hw, ctrl, update) != 0) {
+	if (nfp_reconfig(hw, new_ctrl, update) != 0) {
 		PMD_DRV_LOG(ERR, "MAC address update failed");
 		return -EIO;
 	}
 
+	hw->ctrl = new_ctrl;
+
 	return 0;
 }
 
-- 
2.39.1


  parent reply	other threads:[~2023-10-28  6:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-28  6:23 [PATCH 0/3] Fix some reconfigure problem Chaoyong He
2023-10-28  6:23 ` [PATCH 1/3] net/nfp: fix the reconfigure logic in PF initialization Chaoyong He
2023-10-28  6:23 ` [PATCH 2/3] net/nfp: fix the reconfigure logic in VF initialization Chaoyong He
2023-10-28  6:23 ` Chaoyong He [this message]
2023-10-31 12:55 ` [PATCH 0/3] Fix some reconfigure problem 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=20231028062315.1843075-4-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.com \
    --cc=stable@dpdk.org \
    /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).