Skip to content

Commit 34eec1f

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Put the TX producer information in the TX BD opaque field
Currently, the opaque field in the TX BD is only used for debugging. The TX completion logic relies on getting one TX completion for each packet and they always complete in order. Improve this scheme by putting the producer information (ring index plus number of BDs for the packet) in the opaque field. This way, we can handle TX completion processing by looking at the last TX completion instead of counting the number of completions. Since we no longer need to count the exact number of completions, we can optimize xmit_more by disabling TX completion when the xmit_more condition is true. This will be done in later patches. This patch is only initializing the opaque field in the TX BD and is not changing the driver's TX completion logic yet. Reviewed-by: Andy Gospodarek <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3d8c60 commit 34eec1f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
432432

433433
txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)];
434434

435-
txbd->tx_bd_opaque = prod;
436-
437435
tx_buf = &txr->tx_buf_ring[prod];
438436
tx_buf->skb = skb;
439437
tx_buf->nr_frags = last_frag;
@@ -519,7 +517,9 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
519517

520518
txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type;
521519
txbd->tx_bd_haddr = txr->data_mapping;
520+
txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, prod, 2);
522521
prod = NEXT_TX(prod);
522+
tx_push->tx_bd_opaque = txbd->tx_bd_opaque;
523523
txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)];
524524
memcpy(txbd, tx_push1, sizeof(*txbd));
525525
prod = NEXT_TX(prod);
@@ -562,6 +562,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
562562
((last_frag + 2) << TX_BD_FLAGS_BD_CNT_SHIFT);
563563

564564
txbd->tx_bd_haddr = cpu_to_le64(mapping);
565+
txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, prod, 2 + last_frag);
565566

566567
prod = NEXT_TX(prod);
567568
txbd1 = (struct tx_bd_ext *)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ struct tx_bd {
6161
__le64 tx_bd_haddr;
6262
} __packed;
6363

64+
#define TX_OPAQUE_IDX_MASK 0x0000ffff
65+
#define TX_OPAQUE_BDS_MASK 0x00ff0000
66+
#define TX_OPAQUE_BDS_SHIFT 16
67+
68+
#define SET_TX_OPAQUE(bp, idx, bds) \
69+
(((bds) << TX_OPAQUE_BDS_SHIFT) | ((idx) & (bp)->tx_ring_mask))
70+
6471
struct tx_bd_ext {
6572
__le32 tx_bd_hsize_lflags;
6673
#define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
5252
((num_frags + 1) << TX_BD_FLAGS_BD_CNT_SHIFT) |
5353
bnxt_lhint_arr[len >> 9];
5454
txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
55-
txbd->tx_bd_opaque = prod;
55+
txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, prod, 1 + num_frags);
5656
txbd->tx_bd_haddr = cpu_to_le64(mapping);
5757

5858
/* now let us fill up the frags into the next buffers */

0 commit comments

Comments
 (0)