From 9476c8286f6b6b3c1da3432ab663d9588a0d65b8 Mon Sep 17 00:00:00 2001 From: Yousaf Kaukab Date: Mar 22 2023 16:25:40 +0000 Subject: Merge remote-tracking branch 'origin/users/tbogendoerfer/SLE15-SP5-GA/for-next' into SLE15-SP5-GA Pull bnxt backports from Thomas Bogendoerfer --- diff --git a/patches.suse/bnxt-Do-not-read-past-the-end-of-test-names.patch b/patches.suse/bnxt-Do-not-read-past-the-end-of-test-names.patch new file mode 100644 index 0000000..ea04773 --- /dev/null +++ b/patches.suse/bnxt-Do-not-read-past-the-end-of-test-names.patch @@ -0,0 +1,86 @@ +From: Kees Cook +Date: Wed, 18 Jan 2023 12:35:01 -0800 +Subject: bnxt: Do not read past the end of test names +Patch-mainline: v6.2-rc5 +Git-commit: d3e599c090fc6977331150c5f0a69ab8ce87da21 +References: bsc#1209079 + +Test names were being concatenated based on a offset beyond the end of +the first name, which tripped the buffer overflow detection logic: + + detected buffer overflow in strnlen + [...] + Call Trace: + bnxt_ethtool_init.cold+0x18/0x18 + +Refactor struct hwrm_selftest_qlist_output to use an actual array, +and adjust the concatenation to use snprintf() rather than a series of +strncat() calls. + +Reported-by: Niklas Cassel +Link: https://lore.kernel.org/lkml/Y8F%2F1w1AZTvLglFX@x1-carbon/ +Tested-by: Niklas Cassel +Fixes: eb51365846bc ("bnxt_en: Add basic ethtool -t selftest support.") +Cc: Michael Chan +Cc: "David S. Miller" +Cc: Eric Dumazet +Cc: Jakub Kicinski +Cc: Paolo Abeni +Cc: netdev@vger.kernel.org +Signed-off-by: Kees Cook +Reviewed-by: Michael Chan +Reviewed-by: Niklas Cassel +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 13 ++++--------- + drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 9 +-------- + 2 files changed, 5 insertions(+), 17 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +@@ -3865,7 +3865,7 @@ void bnxt_ethtool_init(struct bnxt *bp) + test_info->timeout = HWRM_CMD_TIMEOUT; + for (i = 0; i < bp->num_tests; i++) { + char *str = test_info->string[i]; +- char *fw_str = resp->test0_name + i * 32; ++ char *fw_str = resp->test_name[i]; + + if (i == BNXT_MACLPBK_TEST_IDX) { + strcpy(str, "Mac loopback test (offline)"); +@@ -3876,14 +3876,9 @@ void bnxt_ethtool_init(struct bnxt *bp) + } else if (i == BNXT_IRQ_TEST_IDX) { + strcpy(str, "Interrupt_test (offline)"); + } else { +- strscpy(str, fw_str, ETH_GSTRING_LEN); +- strncat(str, " test", ETH_GSTRING_LEN - strlen(str)); +- if (test_info->offline_mask & (1 << i)) +- strncat(str, " (offline)", +- ETH_GSTRING_LEN - strlen(str)); +- else +- strncat(str, " (online)", +- ETH_GSTRING_LEN - strlen(str)); ++ snprintf(str, ETH_GSTRING_LEN, "%s test (%s)", ++ fw_str, test_info->offline_mask & (1 << i) ? ++ "offline" : "online"); + } + } + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h +@@ -10099,14 +10099,7 @@ struct hwrm_selftest_qlist_output { + u8 unused_0; + __le16 test_timeout; + u8 unused_1[2]; +- char test0_name[32]; +- char test1_name[32]; +- char test2_name[32]; +- char test3_name[32]; +- char test4_name[32]; +- char test5_name[32]; +- char test6_name[32]; +- char test7_name[32]; ++ char test_name[8][32]; + u8 eyescope_target_BER_support; + #define SELFTEST_QLIST_RESP_EYESCOPE_TARGET_BER_SUPPORT_BER_1E8_SUPPORTED 0x0UL + #define SELFTEST_QLIST_RESP_EYESCOPE_TARGET_BER_SUPPORT_BER_1E9_SUPPORTED 0x1UL diff --git a/patches.suse/bnxt-make-sure-we-return-pages-to-the-pool.patch b/patches.suse/bnxt-make-sure-we-return-pages-to-the-pool.patch new file mode 100644 index 0000000..32d7545 --- /dev/null +++ b/patches.suse/bnxt-make-sure-we-return-pages-to-the-pool.patch @@ -0,0 +1,45 @@ +From: Jakub Kicinski +Date: Tue, 10 Jan 2023 20:25:47 -0800 +Subject: bnxt: make sure we return pages to the pool +Patch-mainline: v6.2-rc4 +Git-commit: 97f5e03a4a27d27ee4fed0cdb1658c81cf2784db +References: bsc#1209079 + +Before the commit under Fixes the page would have been released +from the pool before the napi_alloc_skb() call, so normal page +freeing was fine (released page == no longer in the pool). + +After the change we just mark the page for recycling so it's still +in the pool if the skb alloc fails, we need to recycle. + +Same commit added the same bug in the new bnxt_rx_multi_page_skb(). + +Fixes: 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff") +Reviewed-by: Andy Gospodarek +Link: https://lore.kernel.org/r/20230111042547.987749-1-kuba@kernel.org +Signed-off-by: Jakub Kicinski +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -990,7 +990,7 @@ static struct sk_buff *bnxt_rx_multi_pag + DMA_ATTR_WEAK_ORDERING); + skb = build_skb(page_address(page), PAGE_SIZE); + if (!skb) { +- __free_page(page); ++ page_pool_recycle_direct(rxr->page_pool, page); + return NULL; + } + skb_mark_for_recycle(skb); +@@ -1028,7 +1028,7 @@ static struct sk_buff *bnxt_rx_page_skb( + + skb = napi_alloc_skb(&rxr->bnapi->napi, payload); + if (!skb) { +- __free_page(page); ++ page_pool_recycle_direct(rxr->page_pool, page); + return NULL; + } + diff --git a/patches.suse/bnxt_en-Avoid-order-5-memory-allocation-for-TPA-data.patch b/patches.suse/bnxt_en-Avoid-order-5-memory-allocation-for-TPA-data.patch new file mode 100644 index 0000000..849f5ba --- /dev/null +++ b/patches.suse/bnxt_en-Avoid-order-5-memory-allocation-for-TPA-data.patch @@ -0,0 +1,107 @@ +From: Michael Chan +Date: Fri, 3 Mar 2023 18:43:57 -0800 +Subject: bnxt_en: Avoid order-5 memory allocation for TPA data +Patch-mainline: v6.3-rc2 +Git-commit: accd7e23693aaaa9aa0d3e9eca0ae77d1be80ab3 +References: bsc#1209079 + +The driver needs to keep track of all the possible concurrent TPA (GRO/LRO) +completions on the aggregation ring. On P5 chips, the maximum number +of concurrent TPA is 256 and the amount of memory we allocate is order-5 +on systems using 4K pages. Memory allocation failure has been reported: + +NetworkManager: page allocation failure: order:5, mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null),cpuset=/,mems_allowed=0-1 +CPU: 15 PID: 2995 Comm: NetworkManager Kdump: loaded Not tainted 5.10.156 #1 +Hardware name: Dell Inc. PowerEdge R660/0M1CC5, BIOS 0.2.25 08/12/2022 +Call Trace: + dump_stack+0x57/0x6e + warn_alloc.cold.120+0x7b/0xdd + ? _cond_resched+0x15/0x30 + ? __alloc_pages_direct_compact+0x15f/0x170 + __alloc_pages_slowpath.constprop.108+0xc58/0xc70 + __alloc_pages_nodemask+0x2d0/0x300 + kmalloc_order+0x24/0xe0 + kmalloc_order_trace+0x19/0x80 + bnxt_alloc_mem+0x1150/0x15c0 [bnxt_en] + ? bnxt_get_func_stat_ctxs+0x13/0x60 [bnxt_en] + __bnxt_open_nic+0x12e/0x780 [bnxt_en] + bnxt_open+0x10b/0x240 [bnxt_en] + __dev_open+0xe9/0x180 + __dev_change_flags+0x1af/0x220 + dev_change_flags+0x21/0x60 + do_setlink+0x35c/0x1100 + +Instead of allocating this big chunk of memory and dividing it up for the +concurrent TPA instances, allocate each small chunk separately for each +TPA instance. This will reduce it to order-0 allocations. + +Fixes: 79632e9ba386 ("bnxt_en: Expand bnxt_tpa_info struct to support 57500 chips.") +Reviewed-by: Somnath Kotur +Reviewed-by: Damodharam Ammepalli +Reviewed-by: Pavan Chebbi +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 23 ++++++++++++----------- + 1 file changed, 12 insertions(+), 11 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -3143,7 +3143,7 @@ static int bnxt_alloc_ring(struct bnxt * + + static void bnxt_free_tpa_info(struct bnxt *bp) + { +- int i; ++ int i, j; + + for (i = 0; i < bp->rx_nr_rings; i++) { + struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; +@@ -3151,8 +3151,10 @@ static void bnxt_free_tpa_info(struct bn + kfree(rxr->rx_tpa_idx_map); + rxr->rx_tpa_idx_map = NULL; + if (rxr->rx_tpa) { +- kfree(rxr->rx_tpa[0].agg_arr); +- rxr->rx_tpa[0].agg_arr = NULL; ++ for (j = 0; j < bp->max_tpa; j++) { ++ kfree(rxr->rx_tpa[j].agg_arr); ++ rxr->rx_tpa[j].agg_arr = NULL; ++ } + } + kfree(rxr->rx_tpa); + rxr->rx_tpa = NULL; +@@ -3161,14 +3163,13 @@ static void bnxt_free_tpa_info(struct bn + + static int bnxt_alloc_tpa_info(struct bnxt *bp) + { +- int i, j, total_aggs = 0; ++ int i, j; + + bp->max_tpa = MAX_TPA; + if (bp->flags & BNXT_FLAG_CHIP_P5) { + if (!bp->max_tpa_v2) + return 0; + bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); +- total_aggs = bp->max_tpa * MAX_SKB_FRAGS; + } + + for (i = 0; i < bp->rx_nr_rings; i++) { +@@ -3182,12 +3183,12 @@ static int bnxt_alloc_tpa_info(struct bn + + if (!(bp->flags & BNXT_FLAG_CHIP_P5)) + continue; +- agg = kcalloc(total_aggs, sizeof(*agg), GFP_KERNEL); +- rxr->rx_tpa[0].agg_arr = agg; +- if (!agg) +- return -ENOMEM; +- for (j = 1; j < bp->max_tpa; j++) +- rxr->rx_tpa[j].agg_arr = agg + j * MAX_SKB_FRAGS; ++ for (j = 0; j < bp->max_tpa; j++) { ++ agg = kcalloc(MAX_SKB_FRAGS, sizeof(*agg), GFP_KERNEL); ++ if (!agg) ++ return -ENOMEM; ++ rxr->rx_tpa[j].agg_arr = agg; ++ } + rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map), + GFP_KERNEL); + if (!rxr->rx_tpa_idx_map) diff --git a/patches.suse/bnxt_en-Fix-HDS-and-jumbo-thresholds-for-RX-packets.patch b/patches.suse/bnxt_en-Fix-HDS-and-jumbo-thresholds-for-RX-packets.patch new file mode 100644 index 0000000..e9b06b7 --- /dev/null +++ b/patches.suse/bnxt_en-Fix-HDS-and-jumbo-thresholds-for-RX-packets.patch @@ -0,0 +1,48 @@ +From: Michael Chan +Date: Mon, 26 Dec 2022 22:19:40 -0500 +Subject: bnxt_en: Fix HDS and jumbo thresholds for RX packets +Patch-mainline: v6.2-rc3 +Git-commit: a056ebcc30e2f78451d66f615d2f6bdada3e6438 +References: bsc#1209079 + +The recent XDP multi-buffer feature has introduced regressions in the +setting of HDS and jumbo thresholds. HDS was accidentally disabled in +the nornmal mode without XDP. This patch restores jumbo HDS placement +when not in XDP mode. In XDP multi-buffer mode, HDS should be disabled +and the jumbo threshold should be set to the usable page size in the +first page buffer. + +Fixes: 32861236190b ("bnxt: change receive ring space parameters") +Reviewed-by: Mohammad Shuab Siddique +Reviewed-by: Ajit Khaparde +Reviewed-by: Andy Gospodarek +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -5371,15 +5371,16 @@ static int bnxt_hwrm_vnic_set_hds(struct + req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); + req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); + +- if (BNXT_RX_PAGE_MODE(bp) && !BNXT_RX_JUMBO_MODE(bp)) { ++ if (BNXT_RX_PAGE_MODE(bp)) { ++ req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); ++ } else { + req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | + VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6); + req->enables |= + cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_HDS_THRESHOLD_VALID); ++ req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); ++ req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); + } +- /* thresholds not implemented in firmware yet */ +- req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); +- req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); + req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); + return hwrm_req_send(bp, req); + } diff --git a/patches.suse/bnxt_en-Fix-XDP-RX-path.patch b/patches.suse/bnxt_en-Fix-XDP-RX-path.patch new file mode 100644 index 0000000..07c80a0 --- /dev/null +++ b/patches.suse/bnxt_en-Fix-XDP-RX-path.patch @@ -0,0 +1,73 @@ +From: Michael Chan +Date: Mon, 26 Dec 2022 22:19:38 -0500 +Subject: bnxt_en: Fix XDP RX path +Patch-mainline: v6.2-rc3 +Git-commit: 9b3e607871ea5ee90f10f5be3965fc07f2aa3ef7 +References: bsc#1209079 + +The XDP program can change the starting address of the RX data buffer and +this information needs to be passed back from bnxt_rx_xdp() to +bnxt_rx_pkt() for the XDP_PASS case so that the SKB can point correctly +to the modified buffer address. Add back the data_ptr parameter to +bnxt_rx_xdp() to make this work. + +Fixes: b231c3f3414c ("bnxt: refactor bnxt_rx_xdp to separate xdp_init_buff/xdp_prepare_buff") +Reviewed-by: Andy Gospodarek +Reviewed-by: Pavan Chebbi +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 7 +++++-- + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 4 ++-- + 3 files changed, 8 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -1937,7 +1937,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, + } + + if (xdp_active) { +- if (bnxt_rx_xdp(bp, rxr, cons, xdp, data, &len, event)) { ++ if (bnxt_rx_xdp(bp, rxr, cons, xdp, data, &data_ptr, &len, event)) { + rc = 1; + goto next_rx; + } +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +@@ -222,7 +222,8 @@ void bnxt_xdp_buff_frags_free(struct bnx + * false - packet should be passed to the stack. + */ + bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons, +- struct xdp_buff xdp, struct page *page, unsigned int *len, u8 *event) ++ struct xdp_buff xdp, struct page *page, u8 **data_ptr, ++ unsigned int *len, u8 *event) + { + struct bpf_prog *xdp_prog = READ_ONCE(rxr->xdp_prog); + struct bnxt_tx_ring_info *txr; +@@ -255,8 +256,10 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct + *event &= ~BNXT_RX_EVENT; + + *len = xdp.data_end - xdp.data; +- if (orig_data != xdp.data) ++ if (orig_data != xdp.data) { + offset = xdp.data - xdp.data_hard_start; ++ *data_ptr = xdp.data_hard_start + offset; ++ } + + switch (act) { + case XDP_PASS: +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +@@ -18,8 +18,8 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struc + struct xdp_buff *xdp); + void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts); + bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons, +- struct xdp_buff xdp, struct page *page, unsigned int *len, +- u8 *event); ++ struct xdp_buff xdp, struct page *page, u8 **data_ptr, ++ unsigned int *len, u8 *event); + int bnxt_xdp(struct net_device *dev, struct netdev_bpf *xdp); + int bnxt_xdp_xmit(struct net_device *dev, int num_frames, + struct xdp_frame **frames, u32 flags); diff --git a/patches.suse/bnxt_en-Fix-first-buffer-size-calculations-for-XDP-m.patch b/patches.suse/bnxt_en-Fix-first-buffer-size-calculations-for-XDP-m.patch new file mode 100644 index 0000000..649df82 --- /dev/null +++ b/patches.suse/bnxt_en-Fix-first-buffer-size-calculations-for-XDP-m.patch @@ -0,0 +1,118 @@ +From: Michael Chan +Date: Mon, 26 Dec 2022 22:19:39 -0500 +Subject: bnxt_en: Fix first buffer size calculations for XDP multi-buffer +Patch-mainline: v6.2-rc3 +Git-commit: 1abeacc1979fa4a756695f5030791d8f0fa934b9 +References: bsc#1209079 + +The size of the first buffer is always page size, and the useable +space is the page size minus the offset and the skb_shared_info size. +Make sure SKB and XDP buf sizes match so that the skb_shared_info +is at the same offset seen from the SKB and XDP_BUF. + +build_skb() should be passed PAGE_SIZE. xdp_init_buff() should +be passed PAGE_SIZE as well. xdp_get_shared_info_from_buff() will +automatically deduct the skb_shared_info size if the XDP buffer +has frags. There is no need to keep bp->xdp_has_frags. + +Change BNXT_PAGE_MODE_BUF_SIZE to BNXT_MAX_PAGE_MODE_MTU_SBUF +since this constant is really the MTU with ethernet header size +subtracted. + +Also fix the BNXT_MAX_PAGE_MODE_MTU macro with proper parentheses. + +Fixes: 32861236190b ("bnxt: change receive ring space parameters") +Reviewed-by: Somnath Kotur +Reviewed-by: Andy Gospodarek +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++++---- + drivers/net/ethernet/broadcom/bnxt/bnxt.h | 15 +++++++++++---- + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 7 +------ + 3 files changed, 17 insertions(+), 14 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -988,8 +988,7 @@ static struct sk_buff *bnxt_rx_multi_pag + dma_addr -= bp->rx_dma_offset; + dma_unmap_page_attrs(&bp->pdev->dev, dma_addr, PAGE_SIZE, bp->rx_dir, + DMA_ATTR_WEAK_ORDERING); +- skb = build_skb(page_address(page), BNXT_PAGE_MODE_BUF_SIZE + +- bp->rx_dma_offset); ++ skb = build_skb(page_address(page), PAGE_SIZE); + if (!skb) { + __free_page(page); + return NULL; +@@ -3966,8 +3965,10 @@ void bnxt_set_ring_params(struct bnxt *b + bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; + + if (BNXT_RX_PAGE_MODE(bp)) { +- rx_space = BNXT_PAGE_MODE_BUF_SIZE; +- rx_size = BNXT_MAX_PAGE_MODE_MTU; ++ rx_space = PAGE_SIZE; ++ rx_size = PAGE_SIZE - ++ ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - ++ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + } else { + rx_size = SKB_DATA_ALIGN(BNXT_RX_COPY_THRESH + NET_IP_ALIGN); + rx_space = rx_size + NET_SKB_PAD + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h +@@ -591,12 +591,20 @@ struct nqe_cn { + #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) + + #define BNXT_MAX_MTU 9500 +-#define BNXT_PAGE_MODE_BUF_SIZE \ ++ ++/* First RX buffer page in XDP multi-buf mode ++ * ++ * +-------------------------------------------------------------------------+ ++ * | XDP_PACKET_HEADROOM | bp->rx_buf_use_size | skb_shared_info| ++ * | (bp->rx_dma_offset) | | | ++ * +-------------------------------------------------------------------------+ ++ */ ++#define BNXT_MAX_PAGE_MODE_MTU_SBUF \ + ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ + XDP_PACKET_HEADROOM) + #define BNXT_MAX_PAGE_MODE_MTU \ +- BNXT_PAGE_MODE_BUF_SIZE - \ +- SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info)) ++ (BNXT_MAX_PAGE_MODE_MTU_SBUF - \ ++ SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info))) + + #define BNXT_MIN_PKT_SIZE 52 + +@@ -2131,7 +2139,6 @@ struct bnxt { + #define BNXT_DUMP_CRASH 1 + + struct bpf_prog *xdp_prog; +- u8 xdp_has_frags; + + struct bnxt_ptp_cfg *ptp_cfg; + u8 ptp_all_rx_tstamp; +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +@@ -193,9 +193,6 @@ void bnxt_xdp_buff_init(struct bnxt *bp, + mapping = rx_buf->mapping - bp->rx_dma_offset; + dma_sync_single_for_cpu(&pdev->dev, mapping + offset, len, bp->rx_dir); + +- if (bp->xdp_has_frags) +- buflen = BNXT_PAGE_MODE_BUF_SIZE + offset; +- + xdp_init_buff(xdp, buflen, &rxr->xdp_rxq); + xdp_prepare_buff(xdp, data_ptr - offset, offset, len, false); + } +@@ -404,10 +401,8 @@ static int bnxt_xdp_set(struct bnxt *bp, + netdev_warn(dev, "ethtool rx/tx channels must be combined to support XDP.\n"); + return -EOPNOTSUPP; + } +- if (prog) { ++ if (prog) + tx_xdp = bp->rx_nr_rings; +- bp->xdp_has_frags = prog->aux->xdp_has_frags; +- } + + tc = netdev_get_num_tc(dev); + if (!tc) diff --git a/patches.suse/bnxt_en-Fix-mqprio-and-XDP-ring-checking-logic.patch b/patches.suse/bnxt_en-Fix-mqprio-and-XDP-ring-checking-logic.patch new file mode 100644 index 0000000..ad4ec0c --- /dev/null +++ b/patches.suse/bnxt_en-Fix-mqprio-and-XDP-ring-checking-logic.patch @@ -0,0 +1,45 @@ +From: Michael Chan +Date: Fri, 10 Feb 2023 12:31:55 -0500 +Subject: bnxt_en: Fix mqprio and XDP ring checking logic +Patch-mainline: v6.2 +Git-commit: 2038cc592811209de20c4e094ca08bfb1e6fbc6c +References: bsc#1209079 + +In bnxt_reserve_rings(), there is logic to check that the number of TX +rings reserved is enough to cover all the mqprio TCs, but it fails to +account for the TX XDP rings. So the check will always fail if there +are mqprio TCs and TX XDP rings. As a result, the driver always fails +to initialize after the XDP program is attached and the device will be +brought down. A subsequent ifconfig up will also fail because the +number of TX rings is set to an inconsistent number. Fix the check to +properly account for TX XDP rings. If the check fails, set the number +of TX rings back to a consistent number after calling netdev_reset_tc(). + +Fixes: 674f50a5b026 ("bnxt_en: Implement new method to reserve rings.") +Reviewed-by: Hongguang Gao +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -9239,10 +9239,14 @@ int bnxt_reserve_rings(struct bnxt *bp, + netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); + return rc; + } +- if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) { ++ if (tcs && (bp->tx_nr_rings_per_tc * tcs != ++ bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { + netdev_err(bp->dev, "tx ring reservation failure\n"); + netdev_reset_tc(bp->dev); +- bp->tx_nr_rings_per_tc = bp->tx_nr_rings; ++ if (bp->tx_nr_rings_xdp) ++ bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; ++ else ++ bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + return -ENOMEM; + } + return 0; diff --git a/patches.suse/bnxt_en-Simplify-bnxt_xdp_buff_init.patch b/patches.suse/bnxt_en-Simplify-bnxt_xdp_buff_init.patch new file mode 100644 index 0000000..21759ce --- /dev/null +++ b/patches.suse/bnxt_en-Simplify-bnxt_xdp_buff_init.patch @@ -0,0 +1,72 @@ +From: Michael Chan +Date: Mon, 26 Dec 2022 22:19:37 -0500 +Subject: bnxt_en: Simplify bnxt_xdp_buff_init() +Patch-mainline: v6.2-rc3 +Git-commit: bbfc17e50ba2ed18dfef46b1c433d50a58566bf1 +References: bsc#1209079 + +bnxt_xdp_buff_init() does not modify the data_ptr or the len parameters, +so no need to pass in the addresses of these parameters. + +Fixes: b231c3f3414c ("bnxt: refactor bnxt_rx_xdp to separate xdp_init_buff/xdp_prepare_buff") +Reviewed-by: Andy Gospodarek +Reviewed-by: Somnath Kotur +Reviewed-by: Pavan Chebbi +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Acked-by: Thomas Bogendoerfer +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 6 +++--- + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -1922,7 +1922,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, + dma_addr = rx_buf->mapping; + + if (bnxt_xdp_attached(bp, rxr)) { +- bnxt_xdp_buff_init(bp, rxr, cons, &data_ptr, &len, &xdp); ++ bnxt_xdp_buff_init(bp, rxr, cons, data_ptr, len, &xdp); + if (agg_bufs) { + u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp, + cp_cons, agg_bufs, +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +@@ -177,7 +177,7 @@ bool bnxt_xdp_attached(struct bnxt *bp, + } + + void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, +- u16 cons, u8 **data_ptr, unsigned int *len, ++ u16 cons, u8 *data_ptr, unsigned int len, + struct xdp_buff *xdp) + { + struct bnxt_sw_rx_bd *rx_buf; +@@ -191,13 +191,13 @@ void bnxt_xdp_buff_init(struct bnxt *bp, + offset = bp->rx_offset; + + mapping = rx_buf->mapping - bp->rx_dma_offset; +- dma_sync_single_for_cpu(&pdev->dev, mapping + offset, *len, bp->rx_dir); ++ dma_sync_single_for_cpu(&pdev->dev, mapping + offset, len, bp->rx_dir); + + if (bp->xdp_has_frags) + buflen = BNXT_PAGE_MODE_BUF_SIZE + offset; + + xdp_init_buff(xdp, buflen, &rxr->xdp_rxq); +- xdp_prepare_buff(xdp, *data_ptr - offset, offset, *len, false); ++ xdp_prepare_buff(xdp, data_ptr - offset, offset, len, false); + } + + void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr, +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +@@ -27,7 +27,7 @@ int bnxt_xdp_xmit(struct net_device *dev + bool bnxt_xdp_attached(struct bnxt *bp, struct bnxt_rx_ring_info *rxr); + + void bnxt_xdp_buff_init(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, +- u16 cons, u8 **data_ptr, unsigned int *len, ++ u16 cons, u8 *data_ptr, unsigned int len, + struct xdp_buff *xdp); + void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr, + struct xdp_buff *xdp); diff --git a/series.conf b/series.conf index 3177c78..dff24d2 100644 --- a/series.conf +++ b/series.conf @@ -36714,6 +36714,10 @@ patches.suse/net-sched-fix-memory-leak-in-tcindex_set_parms.patch patches.suse/qlcnic-prevent-dcb-use-after-free-on-qlcnic_dcb_enab.patch patches.suse/nfc-Fix-potential-resource-leaks.patch + patches.suse/bnxt_en-Simplify-bnxt_xdp_buff_init.patch + patches.suse/bnxt_en-Fix-XDP-RX-path.patch + patches.suse/bnxt_en-Fix-first-buffer-size-calculations-for-XDP-m.patch + patches.suse/bnxt_en-Fix-HDS-and-jumbo-thresholds-for-RX-packets.patch patches.suse/net-phy-xgmiitorgmii-Fix-refcount-leak-in-xgmiitorgm.patch patches.suse/dt-bindings-net-sun8i-emac-Add-phy-supply-property.patch patches.suse/net-sched-atm-dont-intepret-cls-results-when-asked-t.patch @@ -36745,6 +36749,7 @@ patches.suse/s390-kexec-fix-ipl-report-address-for-kdump.patch patches.suse/nfc-pn533-Wait-for-out_urb-s-completion-in-pn533_usb.patch patches.suse/net-sched-disallow-noqueue-for-qdisc-classes.patch + patches.suse/bnxt-make-sure-we-return-pages-to-the-pool.patch patches.suse/drm-virtio-Fix-GEM-handle-creation-UAF.patch patches.suse/drm-i915-Reserve-enough-fence-slot-for-i915_vma_unbi.patch patches.suse/drm-i915-gt-Reset-twice.patch @@ -36804,6 +36809,7 @@ patches.suse/wifi-brcmfmac-fix-regression-for-Broadcom-PCIe-wifi-.patch patches.suse/wifi-rndis_wlan-Prevent-buffer-overflow-in-rndis_que.patch patches.suse/Revert-wifi-mac80211-fix-memory-leak-in-ieee80211_if.patch + patches.suse/bnxt-Do-not-read-past-the-end-of-test-names.patch patches.suse/phy-ti-fix-Kconfig-warning-and-operator-precedence.patch patches.suse/phy-rockchip-inno-usb2-Fix-missing-clk_disable_unpre.patch patches.suse/phy-Revert-phy-qualcomm-usb28nm-Add-MDM9607-init-seq.patch @@ -36878,6 +36884,7 @@ patches.suse/netlink-prevent-potential-spectre-v1-gadgets.patch patches.suse/rds-rds_rm_zerocopy_callback-use-list_first_entry.patch patches.suse/Fix-page-corruption-caused-by-racy-check-in-__free_pages.patch + patches.suse/bnxt_en-Fix-mqprio-and-XDP-ring-checking-logic.patch patches.suse/fbdev-Fix-invalid-page-access-after-closing-deferred.patch patches.suse/ibmvnic-Toggle-between-queue-types-in-affinity-mappi.patch patches.suse/rds-rds_rm_zerocopy_callback-correct-order-for-list_add_tail.patch @@ -36886,6 +36893,7 @@ patches.suse/ipmi-ssif-Remove-rtc_us_timer.patch patches.suse/ipmi-ssif-Add-a-timer-between-request-retries.patch patches.suse/ibmvnic-Assign-XPS-map-to-correct-queue-index.patch + patches.suse/bnxt_en-Avoid-order-5-memory-allocation-for-TPA-data.patch # out-of-tree patches patches.suse/locking-rwsem-Prevent-non-first-waiter-from-spinning.patch