[PATCH 20.11] net/nfp: fix reconfigure logic of set MAC address
Chaoyong He
chaoyong.he at corigine.com
Thu Nov 9 03:34:20 CET 2023
[ upstream commit d67022275d3b423850c629036d33fdfadeb874a8 ]
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")
Signed-off-by: Chaoyong He <chaoyong.he at corigine.com>
---
drivers/net/nfp/nfp_net.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 102d8f2938..ac2c99e547 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -537,7 +537,7 @@ int
nfp_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
{
struct nfp_net_hw *hw;
- uint32_t update, ctrl;
+ uint32_t update, new_ctrl;
hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) &&
@@ -552,14 +552,17 @@ nfp_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
/* Signal the NIC about the change */
update = NFP_NET_CFG_UPDATE_MACADDR;
- ctrl = hw->ctrl;
+ new_ctrl = hw->ctrl;
if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) &&
(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR))
- ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
- if (nfp_net_reconfig(hw, ctrl, update) < 0) {
+ new_ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
+ if (nfp_net_reconfig(hw, new_ctrl, update) < 0) {
PMD_INIT_LOG(INFO, "MAC address update failed");
return -EIO;
}
+
+ hw->ctrl = new_ctrl;
+
return 0;
}
--
2.39.1
More information about the stable
mailing list