Skip to content

Commit

Permalink
net/nfp: fix reconfigure logic of set MAC address
Browse files Browse the repository at this point in the history
[ 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: 2fe669f ("net/nfp: support MAC address change")

Signed-off-by: Chaoyong He <[email protected]>
  • Loading branch information
hechaoyong authored and kevintraynor committed Nov 22, 2023
1 parent 1bf47ca commit 2f4040d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/net/nfp/nfp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ 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;
uint32_t new_ctrl;

hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) &&
Expand All @@ -292,14 +293,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;
}

Expand Down

0 comments on commit 2f4040d

Please sign in to comment.