bnxt patchset for Tx performance optimization
cover bnxt patchset for Tx performance optimization
This patchset brings in few fixes and some changes tuning the Tx datapath performance in bnxt PMD.
Please apply.
Ajit Khaparde (4):
net/bnxt: fix an issue seen with TSO net/bnxt: add support to update ipid net/bnxt: check for some error conditions in Tx path net/bnxt: support bulk free of Tx mbufs
Sriharsha Basavapatna (2):
net/bnxt: fix a couple of issues with Tx batching net/bnxt: optimize Tx batching code
drivers/net/bnxt/bnxt_txq.c | 11 +++ drivers/net/bnxt/bnxt_txq.h | 2 +- drivers/net/bnxt/bnxt_txr.c | 160 ++++++++++++++++++++++++------------ drivers/net/bnxt/bnxt_txr.h | 2 + 4 files changed, 123 insertions(+), 52 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH 1/6 net/bnxt: fix an issue seen with TSO
We wrongly update lflags in the Tx descriptor; avoid it. Also, instead of calculating the last producer index to see if mbuf segments are chained, check if the pointer is NULL to iterate through the segment list.
--- drivers/net/bnxt/bnxt_txr.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/bnxt/bnxt_txr.c +8 -7
@@ -123,7 +123,6 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,struct tx_bd_long_hi *txbd1 =NULL ;uint32_t vlan_tag_flags, cfa_action;bool long_bd = false; -uint16_t last_prod =0 ;struct rte_mbuf *m_seg;struct bnxt_sw_tx_bd *tx_buf;static const uint32_t lhint_arr[4 ] = {
@@ -143,8 +142,6 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, tx_buf = &txr->tx_buf_ring[txr->tx_prod]; tx_buf->mbuf = tx_pkt; tx_buf->nr_bds = long_bd + tx_pkt->nb_segs; - last_prod = (txr->tx_prod + tx_buf->nr_bds -1 ) & - txr->tx_ring_struct->ring_mask;if (unlikely (bnxt_tx_avail (txr) < tx_buf->nr_bds))return -ENOMEM ;
@@ -193,11 +190,17 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, txbd1->cfa_action = cfa_action;if (tx_pkt->ol_flags &PKT_TX_TCP_SEG ) { +uint16_t hdr_size; +/* TSO */ txbd1->lflags |=TX_BD_LONG_LFLAGS_LSO ; - txbd1->hdr_size = tx_pkt->l2_len + tx_pkt->l3_len + + hdr_size = tx_pkt->l2_len + tx_pkt->l3_len + tx_pkt->l4_len + tx_pkt->outer_l2_len + tx_pkt->outer_l3_len; +/* The hdr_size is multiple of 16bit units not 8bit. +* Hence divide by 2. +*/ + txbd1->hdr_size = hdr_size >>1 ; txbd1->mss = tx_pkt->tso_segsz; } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_UDP_CKSUM) ==
@@ -282,7 +285,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, m_seg = tx_pkt->next;/* i is set at the end of the if(long_bd) block */ -while (txr->tx_prod != last_prod) { +while (m_seg) { txr->tx_prod =RING_NEXT (txr->tx_ring_struct, txr->tx_prod); tx_buf = &txr->tx_buf_ring[txr->tx_prod];
@@ -295,8 +298,6 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, } txbd->flags_type |=TX_BD_LONG_FLAGS_PACKET_END ; -if (txbd1) - txbd1->lflags =rte_cpu_to_le_32 (txbd1->lflags); txr->tx_prod =RING_NEXT (txr->tx_ring_struct, txr->tx_prod);
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH 2/6 net/bnxt: add support to update ipid
In reply to Ajit KhapardeAdd support to update ipid during TSO.
--- drivers/net/bnxt/bnxt_txr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_txr.c +2 -1
@@ -193,7 +193,8 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,uint16_t hdr_size;/* TSO */ - txbd1->lflags |=TX_BD_LONG_LFLAGS_LSO ; + txbd1->lflags |=TX_BD_LONG_LFLAGS_LSO | +TX_BD_LONG_LFLAGS_T_IPID ; hdr_size = tx_pkt->l2_len + tx_pkt->l3_len + tx_pkt->l4_len + tx_pkt->outer_l2_len + tx_pkt->outer_l3_len;
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH 3/6 net/bnxt: check for some error conditions in Tx path
In reply to Ajit KhapardeThe HW can have limits on the minimum packet size it can support, or the maximum number of segments it can support. Check for such possibilities. Also check if we are going to have a 0 length buffer.
--- drivers/net/bnxt/bnxt_txr.c | 31 ++++++++++++++++++++++++++++++- drivers/net/bnxt/bnxt_txr.h | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_txr.c +30 -1
@@ -143,6 +143,33 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, tx_buf->mbuf = tx_pkt; tx_buf->nr_bds = long_bd + tx_pkt->nb_segs; +/* Check if number of Tx descriptors is above HW limit */ +if (unlikely (tx_buf->nr_bds >BNXT_MAX_TSO_SEGS )) { +PMD_DRV_LOG (ERR , +"Num descriptors %d exceeds HW limit\n" , + tx_buf->nr_bds); +return -ENOSPC ; + } + +/* If packet length is less than minimum packet size, pad it */ +if (unlikely (rte_pktmbuf_pkt_len (tx_pkt) <BNXT_MIN_PKT_SIZE )) { +uint8_t pad =BNXT_MIN_PKT_SIZE -rte_pktmbuf_pkt_len (tx_pkt); +char *seg =rte_pktmbuf_append (tx_pkt, pad); + +if (!seg) { +PMD_DRV_LOG (ERR , +"Failed to pad mbuf by %d bytes\n" , + pad); +return -ENOMEM ; + } + +/* Note: data_len, pkt len are updated in rte_pktmbuf_append */ +memset (seg,0 , pad); + } + +/* Check non zero data_len */ +RTE_VERIFY (tx_pkt->data_len); +if (unlikely (bnxt_tx_avail (txr) < tx_buf->nr_bds))return -ENOMEM ;
@@ -203,6 +230,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,*/ txbd1->hdr_size = hdr_size >>1 ; txbd1->mss = tx_pkt->tso_segsz; +RTE_VERIFY (txbd1->mss); }else if ((tx_pkt->ol_flags &PKT_TX_OIP_IIP_TCP_UDP_CKSUM ) ==PKT_TX_OIP_IIP_TCP_UDP_CKSUM ) {
@@ -285,8 +313,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, } m_seg = tx_pkt->next; -/* i is set at the end of the if(long_bd) block */ while (m_seg) { +/* Check non zero data_len */ +RTE_VERIFY (m_seg->data_len); txr->tx_prod =RING_NEXT (txr->tx_ring_struct, txr->tx_prod); tx_buf = &txr->tx_buf_ring[txr->tx_prod];
drivers/net/bnxt/bnxt_txr.h +2 -0
@@ -10,6 +10,8 @@#define MAX_TX_RINGS 16#define BNXT_TX_PUSH_THRESH 92 +#define BNXT_MAX_TSO_SEGS 32 +#define BNXT_MIN_PKT_SIZE 52#define B_TX_DB (db, prod) rte_write32((DB_KEY_TX | (prod)), db)
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH 4/6 net/bnxt: fix a couple of issues with Tx batching
In reply to Ajit KhapardeFrom: Sriharsha Basavapatna <[email protected]>
This patch addresses the following issues with Tx batching:
1. Tx stall observed in some conditions:
The batching code doesn't request for a completion when only a partial chain of packets is transmitted due to mbuf allocation errors. Because of this, Tx consumer index is not updated correctly and it eventually leads to qfull condition. Fix this by requesting a completion for the last packet in the partial chain that is transmitted successfully.
2. Tx stall seen with Jumbo frames:
With jumbo frames, number of TxBDs is > 1. While setting up these additional BDs in bnxt_start_xmit(), the flags field is being set using the OR-assignment operator. We end up using a stale value of the flags field (from a previous use of that descriptor). This results in an invalid completion and eventually leads to tx stall. Fix this to just assign the flags field with the right value.
--- drivers/net/bnxt/bnxt_txq.h | 1 - drivers/net/bnxt/bnxt_txr.c | 57 ++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 24 deletions(-)
drivers/net/bnxt/bnxt_txq.h +0 -1
@@ -24,7 +24,6 @@ struct bnxt_tx_queue {uint8_t wthresh;/* Write-back threshold reg */ uint32_t ctx_curr;/* Hardware context states */ uint8_t tx_deferred_start;/* not in global dev start */ -uint8_t cmpl_next;/* Next BD to trigger a compl */ struct bnxt *bp;int index;
drivers/net/bnxt/bnxt_txr.c +34 -23
135 lines not on this page · raw message
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH 5/6 net/bnxt: optimize Tx batching code
In reply to Ajit KhapardeFrom: Sriharsha Basavapatna <[email protected]>
This patch adds a few optimizations to Tx batching. Instead of specifying 'cmpl_next' to bnxt_start_xmit() as a hint to enable completion for a given packet, request for completion on the last successfully enqueued TxBD. This takes care of both success and error cases. It eliminates 'cmpl_next' arg and related per-packet condition checks around it.
--- drivers/net/bnxt/bnxt_txr.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/net/bnxt/bnxt_txr.c +9 -23
@@ -121,7 +121,6 @@ static inline uint32_t bnxt_tx_avail(struct bnxt_tx_queue *txq)static uint16_t bnxt_start_xmit (struct rte_mbuf *tx_pkt,struct bnxt_tx_queue *txq,uint16_t *coal_pkts, -uint16_t *cmpl_next,struct tx_bd_long **last_txbd) {struct bnxt_tx_ring_info *txr = txq->tx_ring;
@@ -184,12 +183,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, txbd->opaque = *coal_pkts; txbd->flags_type = nr_bds <<TX_BD_LONG_FLAGS_BD_CNT_SFT ; txbd->flags_type |=TX_BD_SHORT_FLAGS_COAL_NOW ; -if (!*cmpl_next) { - txbd->flags_type |=TX_BD_LONG_FLAGS_NO_CMPL ; - }else { - *coal_pkts =0 ; - *cmpl_next = false; - } + txbd->flags_type |=TX_BD_LONG_FLAGS_NO_CMPL ; txbd->len = tx_pkt->data_len;if (tx_pkt->pkt_len >=2014 ) txbd->flags_type |=TX_BD_LONG_FLAGS_LHINT_GTE2K ;
@@ -415,10 +409,10 @@ static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq)uint16_t bnxt_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts) { -struct bnxt_tx_queue *txq = tx_queue; +int rc;uint16_t nb_tx_pkts =0 ;uint16_t coal_pkts =0 ; -uint16_t cmpl_next =0 ; +struct bnxt_tx_queue *txq = tx_queue;struct tx_bd_long *last_txbd =NULL ;/* Handle TX completions */
@@ -432,27 +426,19 @@ uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* Handle TX burst request */ for (nb_tx_pkts =0 ; nb_tx_pkts < nb_pkts; nb_tx_pkts++) { -int rc; - -/* Request a completion on the last packet */ - cmpl_next |= (nb_pkts == nb_tx_pkts +1 ); coal_pkts++; rc =bnxt_start_xmit (tx_pkts[nb_tx_pkts], txq, - &coal_pkts, &cmpl_next, &last_txbd); + &coal_pkts, &last_txbd); -if (unlikely (rc)) { -/* Request a completion on the last successfully -* enqueued packet -*/ -if (last_txbd) - last_txbd->flags_type &= - ~TX_BD_LONG_FLAGS_NO_CMPL ; +if (unlikely (rc))break ; - } } -if (nb_tx_pkts) +if (likely (nb_tx_pkts)) { +/* Request a completion on the last packet */ + last_txbd->flags_type &= ~TX_BD_LONG_FLAGS_NO_CMPL ;B_TX_DB (txq->tx_ring->tx_doorbell, txq->tx_ring->tx_prod); + }return nb_tx_pkts; }
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH 6/6 net/bnxt: support bulk free of Tx mbufs
In reply to Ajit KhapardeThe driver currently uses rte_pktmbuf_free() to free each mbuf after transmit completion. This is optimized to free multiple mbufs using rte_mempool_put_bulk().
--- drivers/net/bnxt/bnxt_txq.c | 11 ++++++++ drivers/net/bnxt/bnxt_txq.h | 1 + drivers/net/bnxt/bnxt_txr.c | 50 +++++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 10 deletions(-)
drivers/net/bnxt/bnxt_txq.c +11 -0
@@ -69,6 +69,7 @@ void bnxt_tx_queue_release_op(void *tx_queue)rte_memzone_free (txq->mz); txq->mz =NULL ; +rte_free (txq->free);rte_free (txq); } }
@@ -110,6 +111,16 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, rc = -ENOMEM ; goto out; } + + txq->free =rte_zmalloc_socket (NULL , +sizeof (struct rte_mbuf *) * nb_desc, +RTE_CACHE_LINE_SIZE , socket_id); +if (!txq->free) { +PMD_DRV_LOG (ERR ,"allocation of tx mbuf free array failed!" ); +rte_free (txq); + rc = -ENOMEM ; + goto out; + } txq->bp = bp; txq->nb_tx_desc = nb_desc; txq->tx_free_thresh = tx_conf->tx_free_thresh;
drivers/net/bnxt/bnxt_txq.h +1 -0
@@ -33,6 +33,7 @@ struct bnxt_tx_queue {unsigned int cp_nr_rings;struct bnxt_cp_ring_info *cp_ring;const struct rte_memzone *mz; +struct rte_mbuf **free; };void bnxt_free_txq_stats (struct bnxt_tx_queue *txq);
drivers/net/bnxt/bnxt_txr.c +40 -10
70 lines not on this page · raw message
Signature · 1 line
2.20.1 (Apple Git-117)
Quoted 10 lines · Ajit Khaparde
This patchset brings in few fixes and some changes tuning the Tx datapath performance in bnxt PMD.
Please apply.Ajit Khaparde (4):
net/bnxt: fix an issue seen with TSO net/bnxt: add support to update ipid net/bnxt: check for some error conditions in Tx path net/bnxt: support bulk free of Tx mbufs
Quoted 3 lines
Sriharsha Basavapatna (2):
net/bnxt: fix a couple of issues with Tx batching net/bnxt: optimize Tx batching code
Series applied to dpdk-next-net/master, thanks.