* [PATCH 22.11] net/nfp: fix reconfigure logic of set MAC address
@ 2023-12-12 3:11 Chaoyong He
2023-12-16 0:55 ` Xueming(Steven) Li
0 siblings, 1 reply; 2+ messages in thread
From: Chaoyong He @ 2023-12-12 3:11 UTC (permalink / raw)
To: stable; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
[ 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@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
drivers/net/nfp/nfp_common.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 0fa74a43e4..33613bb2b3 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -279,7 +279,7 @@ int
nfp_net_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) &&
@@ -294,14 +294,18 @@ nfp_net_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
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH 22.11] net/nfp: fix reconfigure logic of set MAC address
2023-12-12 3:11 [PATCH 22.11] net/nfp: fix reconfigure logic of set MAC address Chaoyong He
@ 2023-12-16 0:55 ` Xueming(Steven) Li
0 siblings, 0 replies; 2+ messages in thread
From: Xueming(Steven) Li @ 2023-12-16 0:55 UTC (permalink / raw)
To: Chaoyong He, stable; +Cc: oss-drivers, Long Wu, Peng Zhang
Hi Chaoyong,
Patch applied to 22.11 LTS branch, thanks for the backporting!
> -----Original Message-----
> From: Chaoyong He <chaoyong.he@corigine.com>
> Sent: 12/12/2023 11:12
> To: stable@dpdk.org
> Cc: oss-drivers@corigine.com; Chaoyong He <chaoyong.he@corigine.com>; Long
> Wu <long.wu@corigine.com>; Peng Zhang <peng.zhang@corigine.com>
> Subject: [PATCH 22.11] net/nfp: fix reconfigure logic of set MAC address
>
> [ 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@corigine.com>
> Reviewed-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> ---
> drivers/net/nfp/nfp_common.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
> index 0fa74a43e4..33613bb2b3 100644
> --- a/drivers/net/nfp/nfp_common.c
> +++ b/drivers/net/nfp/nfp_common.c
> @@ -279,7 +279,7 @@ int
> nfp_net_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) && @@ -294,14 +294,18
> @@ nfp_net_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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-16 0:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12 3:11 [PATCH 22.11] net/nfp: fix reconfigure logic of set MAC address Chaoyong He
2023-12-16 0:55 ` Xueming(Steven) Li
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).