Skip to content

Commit

Permalink
net/mana: do not ring short doorbell for every mbuf alloc
Browse files Browse the repository at this point in the history
In the 32bit rx path, it rings short doorbell after receiving
one packet and allocating the new mbuf. This significantly
impacts the rx performance. Fix this problem by ringing the
short doorbell in batch.

Fixes: eeb3780 ("net/mana: use bulk mbuf allocation for Rx WQEs")
Cc: [email protected]

Signed-off-by: Wei Hu <[email protected]>
  • Loading branch information
whu2014 authored and shemminger committed Feb 7, 2025
1 parent 872e846 commit 4e6a273
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions drivers/net/mana/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ mana_alloc_and_post_rx_wqes(struct mana_rxq *rxq, uint32_t count)
uint32_t i, batch_count;
struct rte_mbuf *mbufs[MANA_MBUF_BULK];

#ifdef RTE_ARCH_32
rxq->wqe_cnt_to_short_db = 0;
#endif

more_mbufs:
batch_count = RTE_MIN(count, MANA_MBUF_BULK);
ret = rte_pktmbuf_alloc_bulk(rxq->mp, mbufs, batch_count);
Expand All @@ -132,9 +136,6 @@ mana_alloc_and_post_rx_wqes(struct mana_rxq *rxq, uint32_t count)
goto out;
}

#ifdef RTE_ARCH_32
rxq->wqe_cnt_to_short_db = 0;
#endif
for (i = 0; i < batch_count; i++) {
ret = mana_post_rx_wqe(rxq, mbufs[i]);
if (ret) {
Expand Down Expand Up @@ -448,10 +449,6 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
uint32_t i;
int polled = 0;

#ifdef RTE_ARCH_32
rxq->wqe_cnt_to_short_db = 0;
#endif

repoll:
/* Polling on new completions if we have no backlog */
if (rxq->comp_buf_idx == rxq->comp_buf_len) {
Expand Down Expand Up @@ -570,25 +567,6 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
wqe_consumed++;
if (pkt_received == pkts_n)
break;

#ifdef RTE_ARCH_32
/* Always post WQE as soon as it's consumed for short DB */
ret = mana_alloc_and_post_rx_wqes(rxq, wqe_consumed);
if (ret) {
DRV_LOG(ERR, "failed to post %d WQEs, ret %d",
wqe_consumed, ret);
return pkt_received;
}
wqe_consumed = 0;

/* Ring short doorbell if approaching the wqe increment
* limit.
*/
if (rxq->wqe_cnt_to_short_db > RX_WQE_SHORT_DB_THRESHOLD) {
mana_rq_ring_doorbell(rxq);
rxq->wqe_cnt_to_short_db = 0;
}
#endif
}

rxq->backlog_idx = pkt_idx;
Expand Down

0 comments on commit 4e6a273

Please sign in to comment.