Backport two patches to stable release 20.11.4 Chengwen Feng (1): net/hns3: fix interrupt vector freeing Huisong Li (1): net/hns3: fix residual MAC after setting default MAC drivers/net/hns3/hns3_ethdev.c | 38 +++++++++---------------------- drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 3 files changed, 12 insertions(+), 29 deletions(-) -- 2.33.0
[ upstream commit 19e67d8ebced5cb12829f75c70e6c497b5925e82 ] This problem occurs in the following scenarios: 1) reset is encountered when the adapter is running. 2) set a new default MAC address After the above two steps, the old default MAC address should be not take effect. But the current behavior is contrary to that. This is due to the change of the "default_addr_setted" in hw->mac from 'true' to 'false' after the reset. As a result, the old MAC address is not removed when the new default MAC address is set. This variable controls whether to delete the old default MAC address when setting the default MAC address. It is only used when the mac_addr_set API is called for the first time. In fact, when a unicast MAC address is deleted, if the address isn't in the MAC address table, the driver doesn't return failure. So this patch remove the redundant and troublesome variables to resolve this problem. Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") Signed-off-by: Huisong Li <lihuisong@huawei.com> Signed-off-by: Min Hu (Connor) <humin29@huawei.com> --- drivers/net/hns3/hns3_ethdev.c | 38 ++++++++++------------------------ drivers/net/hns3/hns3_ethdev.h | 1 - 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index abe31c841e..d54639e767 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -1568,7 +1568,7 @@ hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) static int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - uint32_t idx, __rte_unused uint32_t pool) + __rte_unused uint32_t idx, __rte_unused uint32_t pool) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; @@ -1599,8 +1599,6 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, return ret; } - if (idx == 0) - hw->mac.default_addr_setted = true; rte_spinlock_unlock(&hw->lock); return ret; @@ -1665,30 +1663,19 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_ether_addr *oaddr; char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - bool default_addr_setted; int ret, ret_val; - /* - * It has been guaranteed that input parameter named mac_addr is valid - * address in the rte layer of DPDK framework. - */ + rte_spinlock_lock(&hw->lock); oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; - default_addr_setted = hw->mac.default_addr_setted; - if (default_addr_setted && !!rte_is_same_ether_addr(mac_addr, oaddr)) - return 0; - - rte_spinlock_lock(&hw->lock); - if (default_addr_setted) { - ret = hns3_remove_uc_addr_common(hw, oaddr); - if (ret) { - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - oaddr); - hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", - mac_str, ret); + ret = hns3_remove_uc_addr_common(hw, oaddr); + if (ret) { + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + oaddr); + hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", + mac_str, ret); - rte_spinlock_unlock(&hw->lock); - return ret; - } + rte_spinlock_unlock(&hw->lock); + return ret; } ret = hns3_add_uc_addr_common(hw, mac_addr); @@ -1707,7 +1694,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, rte_ether_addr_copy(mac_addr, (struct rte_ether_addr *)hw->mac.mac_addr); - hw->mac.default_addr_setted = true; rte_spinlock_unlock(&hw->lock); return 0; @@ -1728,7 +1714,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", mac_str, ret_val); - hw->mac.default_addr_setted = false; } rte_spinlock_unlock(&hw->lock); @@ -3168,7 +3153,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) hw->rss_dis_flag = false; memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); hw->mac.phy_addr = cfg.phy_addr; - hw->mac.default_addr_setted = false; hw->num_tx_desc = cfg.tqp_desc_num; hw->num_rx_desc = cfg.tqp_desc_num; hw->dcb_info.num_pg = 1; @@ -5111,7 +5095,7 @@ hns3_do_stop(struct hns3_adapter *hns) return ret; } } - hw->mac.default_addr_setted = false; + return 0; } diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 9d9291285e..2bb449be9d 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -172,7 +172,6 @@ enum hns3_media_type { struct hns3_mac { uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; - bool default_addr_setted; /* whether default addr(mac_addr) is set */ uint8_t media_type; uint8_t phy_addr; uint8_t link_duplex : 1; /* ETH_LINK_[HALF/FULL]_DUPLEX */ -- 2.33.0
From: Chengwen Feng <fengchengwen@huawei.com> [ upstream commit f93819cf5abc047905c464fe4abf84fa823239dd ] The intr_handle->intr_vec is allocated by rte_zmalloc(), but freed by free(), this patch fixes it. Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt") Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> --- drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 086828180b..b4a1ec0c7c 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2159,7 +2159,7 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) vf_bind_vector_error: rte_intr_efd_disable(intr_handle); if (intr_handle->intr_vec) { - free(intr_handle->intr_vec); + rte_free(intr_handle->intr_vec); intr_handle->intr_vec = NULL; } return ret; -- 2.33.0
[-- Attachment #1: Type: text/plain, Size: 592 bytes --] Hi Huisong, Thanks for backporting. Subject "20.11" is missing, append to avoid it mixed with other LTS. On Sat, 2021-11-13 at 16:34 +0800, Huisong Li wrote: Backport two patches to stable release 20.11.4 Chengwen Feng (1): net/hns3: fix interrupt vector freeing Huisong Li (1): net/hns3: fix residual MAC after setting default MAC drivers/net/hns3/hns3_ethdev.c | 38 +++++++++---------------------- drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 3 files changed, 12 insertions(+), 29 deletions(-) [-- Attachment #2: Type: text/html, Size: 1116 bytes --]
Backport two patches to stable release 20.11.4 --- v2: add "20.11" in subject Chengwen Feng (1): net/hns3: fix interrupt vector freeing Huisong Li (1): net/hns3: fix residual MAC after setting default MAC drivers/net/hns3/hns3_ethdev.c | 38 +++++++++---------------------- drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 3 files changed, 12 insertions(+), 29 deletions(-) -- 2.33.0
[ upstream commit 19e67d8ebced5cb12829f75c70e6c497b5925e82 ] This problem occurs in the following scenarios: 1) reset is encountered when the adapter is running. 2) set a new default MAC address After the above two steps, the old default MAC address should be not take effect. But the current behavior is contrary to that. This is due to the change of the "default_addr_setted" in hw->mac from 'true' to 'false' after the reset. As a result, the old MAC address is not removed when the new default MAC address is set. This variable controls whether to delete the old default MAC address when setting the default MAC address. It is only used when the mac_addr_set API is called for the first time. In fact, when a unicast MAC address is deleted, if the address isn't in the MAC address table, the driver doesn't return failure. So this patch remove the redundant and troublesome variables to resolve this problem. Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") Signed-off-by: Huisong Li <lihuisong@huawei.com> Signed-off-by: Min Hu (Connor) <humin29@huawei.com> --- drivers/net/hns3/hns3_ethdev.c | 38 ++++++++++------------------------ drivers/net/hns3/hns3_ethdev.h | 1 - 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index abe31c841e..d54639e767 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -1568,7 +1568,7 @@ hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) static int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - uint32_t idx, __rte_unused uint32_t pool) + __rte_unused uint32_t idx, __rte_unused uint32_t pool) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; @@ -1599,8 +1599,6 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, return ret; } - if (idx == 0) - hw->mac.default_addr_setted = true; rte_spinlock_unlock(&hw->lock); return ret; @@ -1665,30 +1663,19 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_ether_addr *oaddr; char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - bool default_addr_setted; int ret, ret_val; - /* - * It has been guaranteed that input parameter named mac_addr is valid - * address in the rte layer of DPDK framework. - */ + rte_spinlock_lock(&hw->lock); oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; - default_addr_setted = hw->mac.default_addr_setted; - if (default_addr_setted && !!rte_is_same_ether_addr(mac_addr, oaddr)) - return 0; - - rte_spinlock_lock(&hw->lock); - if (default_addr_setted) { - ret = hns3_remove_uc_addr_common(hw, oaddr); - if (ret) { - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - oaddr); - hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", - mac_str, ret); + ret = hns3_remove_uc_addr_common(hw, oaddr); + if (ret) { + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + oaddr); + hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", + mac_str, ret); - rte_spinlock_unlock(&hw->lock); - return ret; - } + rte_spinlock_unlock(&hw->lock); + return ret; } ret = hns3_add_uc_addr_common(hw, mac_addr); @@ -1707,7 +1694,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, rte_ether_addr_copy(mac_addr, (struct rte_ether_addr *)hw->mac.mac_addr); - hw->mac.default_addr_setted = true; rte_spinlock_unlock(&hw->lock); return 0; @@ -1728,7 +1714,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", mac_str, ret_val); - hw->mac.default_addr_setted = false; } rte_spinlock_unlock(&hw->lock); @@ -3168,7 +3153,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) hw->rss_dis_flag = false; memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); hw->mac.phy_addr = cfg.phy_addr; - hw->mac.default_addr_setted = false; hw->num_tx_desc = cfg.tqp_desc_num; hw->num_rx_desc = cfg.tqp_desc_num; hw->dcb_info.num_pg = 1; @@ -5111,7 +5095,7 @@ hns3_do_stop(struct hns3_adapter *hns) return ret; } } - hw->mac.default_addr_setted = false; + return 0; } diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 9d9291285e..2bb449be9d 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -172,7 +172,6 @@ enum hns3_media_type { struct hns3_mac { uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; - bool default_addr_setted; /* whether default addr(mac_addr) is set */ uint8_t media_type; uint8_t phy_addr; uint8_t link_duplex : 1; /* ETH_LINK_[HALF/FULL]_DUPLEX */ -- 2.33.0
From: Chengwen Feng <fengchengwen@huawei.com> [ upstream commit f93819cf5abc047905c464fe4abf84fa823239dd ] The intr_handle->intr_vec is allocated by rte_zmalloc(), but freed by free(), this patch fixes it. Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt") Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> --- drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 086828180b..b4a1ec0c7c 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2159,7 +2159,7 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) vf_bind_vector_error: rte_intr_efd_disable(intr_handle); if (intr_handle->intr_vec) { - free(intr_handle->intr_vec); + rte_free(intr_handle->intr_vec); intr_handle->intr_vec = NULL; } return ret; -- 2.33.0
On Sat, 2021-11-13 at 17:17 +0800, Huisong Li wrote:
> [ upstream commit 19e67d8ebced5cb12829f75c70e6c497b5925e82 ]
>
> This problem occurs in the following scenarios:
> 1) reset is encountered when the adapter is running.
> 2) set a new default MAC address
>
> After the above two steps, the old default MAC address should be not
> take effect. But the current behavior is contrary to that. This is due
> to the change of the "default_addr_setted" in hw->mac from 'true' to
> 'false' after the reset. As a result, the old MAC address is not removed
> when the new default MAC address is set. This variable controls whether
> to delete the old default MAC address when setting the default MAC
> address. It is only used when the mac_addr_set API is called for the
> first time. In fact, when a unicast MAC address is deleted, if the
> address isn't in the MAC address table, the driver doesn't return
> failure. So this patch remove the redundant and troublesome variables to
> resolve this problem.
>
> Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations")
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
Applied to 20.11.4 list.
One trailing tab removed, please run checkpatch next time :)
Best Regards,
Xueming Li
On Sat, 2021-11-13 at 17:17 +0800, Huisong Li wrote:
> From: Chengwen Feng <fengchengwen@huawei.com>
>
> [ upstream commit f93819cf5abc047905c464fe4abf84fa823239dd ]
>
> The intr_handle->intr_vec is allocated by rte_zmalloc(), but freed by
> free(), this patch fixes it.
>
> Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt")
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> drivers/net/hns3/hns3_ethdev_vf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
> index 086828180b..b4a1ec0c7c 100644
> --- a/drivers/net/hns3/hns3_ethdev_vf.c
> +++ b/drivers/net/hns3/hns3_ethdev_vf.c
> @@ -2159,7 +2159,7 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev)
> vf_bind_vector_error:
> rte_intr_efd_disable(intr_handle);
> if (intr_handle->intr_vec) {
> - free(intr_handle->intr_vec);
> + rte_free(intr_handle->intr_vec);
> intr_handle->intr_vec = NULL;
> }
> return ret;
Applied to 20.11.4 list, thanks!
Xueming Li
在 2021/11/27 21:55, Xueming(Steven) Li 写道: > On Sat, 2021-11-13 at 17:17 +0800, Huisong Li wrote: >> [ upstream commit 19e67d8ebced5cb12829f75c70e6c497b5925e82 ] >> >> This problem occurs in the following scenarios: >> 1) reset is encountered when the adapter is running. >> 2) set a new default MAC address >> >> After the above two steps, the old default MAC address should be not >> take effect. But the current behavior is contrary to that. This is due >> to the change of the "default_addr_setted" in hw->mac from 'true' to >> 'false' after the reset. As a result, the old MAC address is not removed >> when the new default MAC address is set. This variable controls whether >> to delete the old default MAC address when setting the default MAC >> address. It is only used when the mac_addr_set API is called for the >> first time. In fact, when a unicast MAC address is deleted, if the >> address isn't in the MAC address table, the driver doesn't return >> failure. So this patch remove the redundant and troublesome variables to >> resolve this problem. >> >> Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") >> >> Signed-off-by: Huisong Li <lihuisong@huawei.com> >> Signed-off-by: Min Hu (Connor) <humin29@huawei.com> >> --- > Applied to 20.11.4 list. > > One trailing tab removed, please run checkpatch next time :) ok,thanks😅 > > Best Regards, > Xueming Li