Skip to content

Commit 50f0260

Browse files
author
Shruti Parab
committed
bnxt_en: Mask the bd_cnt field in the TX BD properly
JIRA: https://issues.redhat.com/browse/RHEL-76565 commit 107b25d Author: Michael Chan <michael.chan@broadcom.com> Date: Fri Mar 21 14:16:38 2025 -0700 bnxt_en: Mask the bd_cnt field in the TX BD properly The bd_cnt field in the TX BD specifies the total number of BDs for the TX packet. The bd_cnt field has 5 bits and the maximum number supported is 32 with the value 0. CONFIG_MAX_SKB_FRAGS can be modified and the total number of SKB fragments can approach or exceed the maximum supported by the chip. Add a macro to properly mask the bd_cnt field so that the value 32 will be properly masked and set to 0 in the bd_cnd field. Without this patch, the out-of-range bd_cnt value will corrupt the TX BD and may cause TX timeout. The next patch will check for values exceeding 32. Fixes: 3948b05 ("net: introduce a config option to tweak MAX_SKB_FRAGS") Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com> Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250321211639.3812992-2-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Shruti Parab <shruti.parab@broadcom.com>
1 parent 4f421d3 commit 50f0260

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
564564
TX_BD_FLAGS_LHINT_512_AND_SMALLER |
565565
TX_BD_FLAGS_COAL_NOW |
566566
TX_BD_FLAGS_PACKET_END |
567-
(2 << TX_BD_FLAGS_BD_CNT_SHIFT));
567+
TX_BD_CNT(2));
568568

569569
if (skb->ip_summed == CHECKSUM_PARTIAL)
570570
tx_push1->tx_bd_hsize_lflags =
@@ -639,7 +639,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
639639

640640
dma_unmap_addr_set(tx_buf, mapping, mapping);
641641
flags = (len << TX_BD_LEN_SHIFT) | TX_BD_TYPE_LONG_TX_BD |
642-
((last_frag + 2) << TX_BD_FLAGS_BD_CNT_SHIFT);
642+
TX_BD_CNT(last_frag + 2);
643643

644644
txbd->tx_bd_haddr = cpu_to_le64(mapping);
645645
txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, txr, prod, 2 + last_frag);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct tx_bd {
8282
#define TX_OPAQUE_PROD(bp, opq) ((TX_OPAQUE_IDX(opq) + TX_OPAQUE_BDS(opq)) &\
8383
(bp)->tx_ring_mask)
8484

85+
#define TX_BD_CNT(n) (((n) << TX_BD_FLAGS_BD_CNT_SHIFT) & TX_BD_FLAGS_BD_CNT)
86+
8587
struct tx_bd_ext {
8688
__le32 tx_bd_hsize_lflags;
8789
#define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0)

drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
4848
tx_buf->page = virt_to_head_page(xdp->data);
4949

5050
txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)];
51-
flags = (len << TX_BD_LEN_SHIFT) |
52-
((num_frags + 1) << TX_BD_FLAGS_BD_CNT_SHIFT) |
51+
flags = (len << TX_BD_LEN_SHIFT) | TX_BD_CNT(num_frags + 1) |
5352
bnxt_lhint_arr[len >> 9];
5453
txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
5554
txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, txr, prod, 1 + num_frags);

0 commit comments

Comments
 (0)