From 39c7fc1c17c43b3bf1ed803634b93a225dc4cc30 Mon Sep 17 00:00:00 2001 From: Yonglong Liu Date: Wed, 27 Jul 2022 11:30:22 +0800 Subject: [PATCH 1/6] net: hns3: fix not call nic_call_event() problem when reset failed driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7OPD3 CVE: NA ---------------------------- The variable reset_fail_cnt has moved into the struct rst_stats, but in hclge_reset_end_it(), still using the old reset_fail_cnt, so when reset fail, the reset_fail_cnt is always 0, and will not call nic_call_event() to notify who cares about this event. This patch use the correct variable rst_stats.reset_fail_cnt to fix the problem. Fixes: bc70c292752f ("net: hns3: add some DFX info for reset issue") Signed-off-by: Yonglong Liu --- .../hisilicon/hns3/hns3_extension/hns3pf/hclge_main_it.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_extension/hns3pf/hclge_main_it.c b/drivers/net/ethernet/hisilicon/hns3/hns3_extension/hns3pf/hclge_main_it.c index 7ac18e21a8bd..0118b9577a66 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_extension/hns3pf/hclge_main_it.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_extension/hns3pf/hclge_main_it.c @@ -159,7 +159,7 @@ bool hclge_reset_end_it(struct hnae3_handle *handle, bool done) nic_call_event(netdev, HNAE3_RESET_DONE_CUSTOM); } - if (hdev->reset_fail_cnt >= HCLGE_RESET_MAX_FAIL_CNT) { + if (hdev->rst_stats.reset_fail_cnt >= HCLGE_RESET_MAX_FAIL_CNT) { dev_err(&hdev->pdev->dev, "IT Report Reset fail!\n"); if (nic_event_call) { if (hdev->reset_type == HNAE3_FUNC_RESET) -- Gitee From dcd930893266296ba03fa64062e41650d3829730 Mon Sep 17 00:00:00 2001 From: Jie Wang Date: Fri, 10 Dec 2021 21:09:33 +0800 Subject: [PATCH 2/6] net: hns3: fix use-after-free bug in hclgevf_send_mbx_msg mainline inclusion from mainline-v5.16-rc6 commit 27cbf64a766e86f068ce6214f04c00ceb4db1af4 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7OQ7U CVE: NA ---------------------------- Currently, the hns3_remove function firstly uninstall client instance, and then uninstall acceletion engine device. The netdevice is freed in client instance uninstall process, but acceletion engine device uninstall process still use it to trace runtime information. This causes a use after free problem. So fixes it by check the instance register state to avoid use after free. Fixes: d8355240cf8f ("net: hns3: add trace event support for PF/VF mailbox") Signed-off-by: Jie Wang Signed-off-by: Yonglong Liu --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index 1e691e900500..484e1a6fe3cc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -136,7 +136,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, memcpy(&req->msg, send_msg, sizeof(struct hclge_vf_to_pf_msg)); - trace_hclge_vf_mbx_send(hdev, req); + if (test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state)) + trace_hclge_vf_mbx_send(hdev, req); /* synchronous send */ if (need_resp) { -- Gitee From 681cf91c258821c10adb276f6e477bc83d9c9cbb Mon Sep 17 00:00:00 2001 From: Yonglong Liu Date: Wed, 7 Dec 2022 11:47:10 +0800 Subject: [PATCH 3/6] net: hns3: add barrier in vf mailbox reply process driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7OQCS CVE: NA ---------------------------- In hclgevf_mbx_handler() and hclgevf_get_mbx_resp() functions, there is a typical store-store and load-load scenario between received_resp and additional_info. This patch adds barrier to fix the problem. Signed-off-by: Yonglong Liu --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index 484e1a6fe3cc..ec2b4e653893 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -82,6 +82,9 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, i++; } + /* ensure additional_info will be seen after received_resp */ + smp_rmb(); + if (i >= HCLGEVF_MAX_TRY_TIMES) { dev_err(&hdev->pdev->dev, "VF could not get mbx(%u,%u) resp(=%d) from PF in %d tries\n", @@ -240,6 +243,11 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) temp++; } + /* ensure additional_info will be seen before setting + * received_resp + */ + smp_wmb(); + if (req->match_id) { /* If match_id is not zero, it means PF support * match_id. If the match_id is right, VF get -- Gitee From 447625d22d93951e16bfa3b4b53387873a852406 Mon Sep 17 00:00:00 2001 From: Yonglong Liu Date: Fri, 21 Apr 2023 14:24:18 +0800 Subject: [PATCH 4/6] net: hns3: fix incorrect hw rss hash type of rx packet driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7ORRB CVE: NA ---------------------------- Currently, the HNS3 driver reports the rss hash type of each packet based on the rss hash tuples set. It always reports PKT_HASH_TYPE_L4, without checking the type of current packet. It's incorrect. Fixes it by reporting it base on the packet type. Fixes: 232fc64b6e62 ("net: hns3: Add HW RSS hash information to RX skb") Fixes: ea4858670717 ("net: hns3: handle the BD info on the last BD of the packet") Signed-off-by: Yonglong Liu --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index ffb4bfc5061d..78fdd32e9eb9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3132,15 +3132,26 @@ static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring, } static void hns3_set_rx_skb_rss_type(struct hns3_enet_ring *ring, - struct sk_buff *skb, u32 rss_hash) + struct sk_buff *skb, u32 rss_hash, + u32 l234info) { + enum pkt_hash_types rss_type = PKT_HASH_TYPE_NONE; struct hnae3_handle *handle = ring->tqp->handle; - enum pkt_hash_types rss_type; + int l3_type; + int l4_type; - if (rss_hash) - rss_type = handle->kinfo.rss_type; - else - rss_type = PKT_HASH_TYPE_NONE; + l3_type = hnae3_get_field(l234info, HNS3_RXD_L3ID_M, HNS3_RXD_L3ID_S); + l4_type = hnae3_get_field(l234info, HNS3_RXD_L4ID_M, HNS3_RXD_L4ID_S); + if (l3_type == HNS3_L3_TYPE_IPV4 || + l3_type == HNS3_L3_TYPE_IPV6) { + if (l4_type == HNS3_L4_TYPE_UDP || + l4_type == HNS3_L4_TYPE_TCP || + l4_type == HNS3_L4_TYPE_SCTP) + rss_type = PKT_HASH_TYPE_L4; + else if (l4_type == HNS3_L4_TYPE_IGMP || + l4_type == HNS3_L4_TYPE_ICMP) + rss_type = PKT_HASH_TYPE_L3; + } skb_set_hash(skb, rss_hash, rss_type); } @@ -3218,7 +3229,8 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb) ring->tqp_vector->rx_group.total_bytes += len; - hns3_set_rx_skb_rss_type(ring, skb, le32_to_cpu(desc->rx.rss_hash)); + hns3_set_rx_skb_rss_type(ring, skb, le32_to_cpu(desc->rx.rss_hash), + l234info); return 0; } -- Gitee From 18c4e5acdbf541098522623bf9f2118779cb943b Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Wed, 12 Jul 2023 11:02:00 +0800 Subject: [PATCH 5/6] net: hns3: fix tx timeout issue driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7OS1B CVE: NA ---------------------------- Currently, the driver knocks the ring doorbell before updating the ring->last_to_use in tx flow. if the hardware transmiting packet and napi poll scheduling are fast enough, it may get the old ring->last_to_use in drivers' napi poll. In this case, the driver will think the tx is not completed, and return directly without clear the flag __QUEUE_STATE_STACK_XOFF, which may cause tx timeout. Fixes: 62ef41ebc02c ("net: hns3: optimize the tx clean process") Signed-off-by: Jian Shen --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 78fdd32e9eb9..20703ce86281 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1440,10 +1440,14 @@ static void hns3_tx_doorbell(struct hns3_enet_ring *ring, int num, if (!ring->pending_buf) return; + /* This smp_store_release() pairs with smp_load_aquire() in + * hns3_nic_reclaim_desc(). Ensure that the BD valid bit is updated. + */ + smp_store_release(&ring->last_to_use, ring->next_to_use); + writel(ring->pending_buf, ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG); ring->pending_buf = 0; - WRITE_ONCE(ring->last_to_use, ring->next_to_use); } netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev) @@ -2629,9 +2633,8 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i) static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring, int *bytes, int *pkts, int budget) { - /* pair with ring->last_to_use update in hns3_tx_doorbell(), - * smp_store_release() is not used in hns3_tx_doorbell() because - * the doorbell operation already have the needed barrier operation. + /* This smp_load_acquire() pairs with smp_store_release() in + * hns3_tx_doorbell(). */ int ltu = smp_load_acquire(&ring->last_to_use); int ntc = ring->next_to_clean; -- Gitee From c574b6c18527add67b450b38f7832142720e227c Mon Sep 17 00:00:00 2001 From: Yonglong Liu Date: Thu, 22 Sep 2022 16:26:19 +0800 Subject: [PATCH 6/6] net: hns3: update hns3 version to 23.7.1 driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7OS1B CVE: NA ---------------------------- Signed-off-by: Yonglong Liu --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 9560121e7763..a978ab96c7ad 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -32,7 +32,7 @@ #include #include -#define HNAE3_MOD_VERSION "22.9.2" +#define HNAE3_MOD_VERSION "23.7.1" #define HNAE3_MIN_VECTOR_NUM 2 /* first one for misc, another for IO */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index 2a6e34a15e43..3b302693163b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__ -#define HNS3_CAE_MOD_VERSION "22.9.2" +#define HNS3_CAE_MOD_VERSION "23.7.1" #define CMT_ID_LEN 8 #define RESV_LEN 3 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 4472d2eb33d2..ef4463ae26cf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@ #include "hnae3.h" -#define HNS3_MOD_VERSION "22.9.2" +#define HNS3_MOD_VERSION "23.7.1" extern char hns3_driver_version[]; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 486d5e2826db..2a84772783ef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h" -#define HCLGE_MOD_VERSION "22.9.2" +#define HCLGE_MOD_VERSION "23.7.1" #define HCLGE_DRIVER_NAME "hclge" #define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 4f68ccc6f1c4..101b3fa9e2db 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h" -#define HCLGEVF_MOD_VERSION "22.9.2" +#define HCLGEVF_MOD_VERSION "23.7.1" #define HCLGEVF_DRIVER_NAME "hclgevf" #define HCLGEVF_MAX_VLAN_ID 4095 -- Gitee