net/enetc: use bulk alloc in Rx refill ring

Since we know in advance that we're going to fill in multiple
descriptors it's convenient to allocate the buffers in batches.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Gagandeep Singh <g.singh@nxp.com>
This commit is contained in:
Alex Marginean 2020-03-02 20:02:06 +05:30 committed by Ferruh Yigit
parent 66894d983e
commit 17d13fe659

View File

@ -14,6 +14,8 @@
#include "enetc.h" #include "enetc.h"
#include "enetc_logs.h" #include "enetc_logs.h"
#define ENETC_RXBD_BUNDLE 16 /* Number of buffers to allocate at once */
static int static int
enetc_clean_tx_ring(struct enetc_bdr *tx_ring) enetc_clean_tx_ring(struct enetc_bdr *tx_ring)
{ {
@ -107,15 +109,25 @@ enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
{ {
struct enetc_swbd *rx_swbd; struct enetc_swbd *rx_swbd;
union enetc_rx_bd *rxbd; union enetc_rx_bd *rxbd;
int i, j; int i, j, k = ENETC_RXBD_BUNDLE;
struct rte_mbuf *m[ENETC_RXBD_BUNDLE];
struct rte_mempool *mb_pool;
i = rx_ring->next_to_use; i = rx_ring->next_to_use;
mb_pool = rx_ring->mb_pool;
rx_swbd = &rx_ring->q_swbd[i]; rx_swbd = &rx_ring->q_swbd[i];
rxbd = ENETC_RXBD(*rx_ring, i); rxbd = ENETC_RXBD(*rx_ring, i);
for (j = 0; j < buff_cnt; j++) { for (j = 0; j < buff_cnt; j++) {
rx_swbd->buffer_addr = (void *)(uintptr_t) /* bulk alloc for the next up to 8 BDs */
rte_cpu_to_le_64((uint64_t)(uintptr_t) if (k == ENETC_RXBD_BUNDLE) {
rte_pktmbuf_alloc(rx_ring->mb_pool)); k = 0;
int m_cnt = RTE_MIN(buff_cnt - j, ENETC_RXBD_BUNDLE);
if (rte_pktmbuf_alloc_bulk(mb_pool, m, m_cnt))
return -1;
}
rx_swbd->buffer_addr = m[k];
rxbd->w.addr = (uint64_t)(uintptr_t) rxbd->w.addr = (uint64_t)(uintptr_t)
rx_swbd->buffer_addr->buf_iova + rx_swbd->buffer_addr->buf_iova +
rx_swbd->buffer_addr->data_off; rx_swbd->buffer_addr->data_off;
@ -124,6 +136,7 @@ enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
rx_swbd++; rx_swbd++;
rxbd++; rxbd++;
i++; i++;
k++;
if (unlikely(i == rx_ring->bd_count)) { if (unlikely(i == rx_ring->bd_count)) {
i = 0; i = 0;
rxbd = ENETC_RXBD(*rx_ring, 0); rxbd = ENETC_RXBD(*rx_ring, 0);