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: sta...@dpdk.org Signed-off-by: Chaoyong He <chaoyong...@corigine.com> Reviewed-by: Long Wu <long...@corigine.com> Reviewed-by: Peng Zhang <peng.zh...@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