return -EINVAL;
}
- if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) {
+ if (nb_desc < BNXT_MIN_RING_DESC || nb_desc > MAX_RX_DESC_CNT) {
PMD_DRV_LOG(ERR, "nb_desc %d is invalid\n", nb_desc);
rc = -EINVAL;
goto out;
rxq->bp = bp;
rxq->mb_pool = mp;
rxq->nb_rx_desc = nb_desc;
- rxq->rx_free_thresh = rx_conf->rx_free_thresh;
+ rxq->rx_free_thresh =
+ RTE_MIN(rte_align32pow2(nb_desc) / 4, RTE_BNXT_MAX_RX_BURST);
PMD_DRV_LOG(DEBUG, "RX Buf MTU %d\n", eth_dev->data->mtu);
#ifndef _BNXT_RQX_H_
#define _BNXT_RQX_H_
+/* Maximum receive burst supported in vector mode. */
+#define RTE_BNXT_MAX_RX_BURST 32U
+
struct bnxt;
struct bnxt_rx_ring_info;
struct bnxt_cp_ring_info;
#ifndef _BNXT_RXTX_VEC_COMMON_H_
#define _BNXT_RXTX_VEC_COMMON_H_
+#include "hsi_struct_def_dpdk.h"
+#include "bnxt_rxq.h"
+#include "bnxt_rxr.h"
-#define RTE_BNXT_MAX_RX_BURST 32
-#define RTE_BNXT_MAX_TX_BURST 32
-#define RTE_BNXT_RXQ_REARM_THRESH 32
-#define RTE_BNXT_DESCS_PER_LOOP 4
+#define RTE_BNXT_DESCS_PER_LOOP 4U
#define TX_BD_FLAGS_CMPL ((1 << TX_BD_LONG_FLAGS_BD_CNT_SFT) | \
TX_BD_SHORT_FLAGS_COAL_NOW | \
#include "bnxt.h"
#include "bnxt_cpr.h"
#include "bnxt_ring.h"
-#include "bnxt_rxr.h"
-#include "bnxt_rxq.h"
-#include "hsi_struct_def_dpdk.h"
#include "bnxt_rxtx_vec_common.h"
#include "bnxt_txq.h"
struct rx_prod_pkt_bd *rxbds = &rxr->rx_desc_ring[rxq->rxrearm_start];
struct rte_mbuf **rx_bufs = &rxr->rx_buf_ring[rxq->rxrearm_start];
struct rte_mbuf *mb0, *mb1;
- int i;
+ int nb, i;
const uint64x2_t hdr_room = {0, RTE_PKTMBUF_HEADROOM};
const uint64x2_t addrmask = {0, UINT64_MAX};
- /* Pull RTE_BNXT_RXQ_REARM_THRESH more mbufs into the software ring */
- if (rte_mempool_get_bulk(rxq->mb_pool,
- (void *)rx_bufs,
- RTE_BNXT_RXQ_REARM_THRESH) < 0) {
- rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
- RTE_BNXT_RXQ_REARM_THRESH;
+ /*
+ * Number of mbufs to allocate must be a multiple of two. The
+ * allocation must not go past the end of the ring.
+ */
+ nb = RTE_MIN(rxq->rxrearm_nb & ~0x1,
+ rxq->nb_rx_desc - rxq->rxrearm_start);
+
+ /* Allocate new mbufs into the software ring */
+ if (rte_mempool_get_bulk(rxq->mb_pool, (void *)rx_bufs, nb) < 0) {
+ rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += nb;
return;
}
/* Initialize the mbufs in vector, process 2 mbufs in one loop */
- for (i = 0; i < RTE_BNXT_RXQ_REARM_THRESH; i += 2, rx_bufs += 2) {
+ for (i = 0; i < nb; i += 2, rx_bufs += 2) {
uint64x2_t buf_addr0, buf_addr1;
uint64x2_t rxbd0, rxbd1;
vst1q_u64((uint64_t *)(rxbds++), rxbd1);
}
- rxq->rxrearm_start += RTE_BNXT_RXQ_REARM_THRESH;
+ rxq->rxrearm_start += nb;
bnxt_db_write(&rxr->rx_db, rxq->rxrearm_start - 1);
if (rxq->rxrearm_start >= rxq->nb_rx_desc)
rxq->rxrearm_start = 0;
- rxq->rxrearm_nb -= RTE_BNXT_RXQ_REARM_THRESH;
+ rxq->rxrearm_nb -= nb;
}
static uint32_t
if (unlikely(!rxq->rx_started))
return 0;
- if (rxq->rxrearm_nb >= RTE_BNXT_RXQ_REARM_THRESH)
+ if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
bnxt_rxq_rearm(rxq, rxr);
/* Return no more than RTE_BNXT_MAX_RX_BURST per call. */
#include "bnxt.h"
#include "bnxt_cpr.h"
#include "bnxt_ring.h"
-#include "bnxt_rxr.h"
-#include "bnxt_rxq.h"
-#include "hsi_struct_def_dpdk.h"
#include "bnxt_rxtx_vec_common.h"
#include "bnxt_txq.h"
struct rx_prod_pkt_bd *rxbds = &rxr->rx_desc_ring[rxq->rxrearm_start];
struct rte_mbuf **rx_bufs = &rxr->rx_buf_ring[rxq->rxrearm_start];
struct rte_mbuf *mb0, *mb1;
- int i;
+ int nb, i;
const __m128i hdr_room = _mm_set_epi64x(RTE_PKTMBUF_HEADROOM, 0);
const __m128i addrmask = _mm_set_epi64x(UINT64_MAX, 0);
- /* Pull RTE_BNXT_RXQ_REARM_THRESH more mbufs into the software ring */
- if (rte_mempool_get_bulk(rxq->mb_pool,
- (void *)rx_bufs,
- RTE_BNXT_RXQ_REARM_THRESH) < 0) {
- rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
- RTE_BNXT_RXQ_REARM_THRESH;
+ /*
+ * Number of mbufs to allocate must be a multiple of two. The
+ * allocation must not go past the end of the ring.
+ */
+ nb = RTE_MIN(rxq->rxrearm_nb & ~0x1,
+ rxq->nb_rx_desc - rxq->rxrearm_start);
+
+ /* Allocate new mbufs into the software ring */
+ if (rte_mempool_get_bulk(rxq->mb_pool, (void *)rx_bufs, nb) < 0) {
+ rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += nb;
return;
}
/* Initialize the mbufs in vector, process 2 mbufs in one loop */
- for (i = 0; i < RTE_BNXT_RXQ_REARM_THRESH; i += 2, rx_bufs += 2) {
+ for (i = 0; i < nb; i += 2, rx_bufs += 2) {
__m128i buf_addr0, buf_addr1;
__m128i rxbd0, rxbd1;
_mm_store_si128((__m128i *)(rxbds++), rxbd1);
}
- rxq->rxrearm_start += RTE_BNXT_RXQ_REARM_THRESH;
+ rxq->rxrearm_start += nb;
bnxt_db_write(&rxr->rx_db, rxq->rxrearm_start - 1);
if (rxq->rxrearm_start >= rxq->nb_rx_desc)
rxq->rxrearm_start = 0;
- rxq->rxrearm_nb -= RTE_BNXT_RXQ_REARM_THRESH;
+ rxq->rxrearm_nb -= nb;
}
static uint32_t
if (unlikely(!rxq->rx_started))
return 0;
- if (rxq->rxrearm_nb >= RTE_BNXT_RXQ_REARM_THRESH)
+ if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
bnxt_rxq_rearm(rxq, rxr);
/* Return no more than RTE_BNXT_MAX_RX_BURST per call. */
return -EINVAL;
}
- if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
+ if (nb_desc < BNXT_MIN_RING_DESC || nb_desc > MAX_TX_DESC_CNT) {
PMD_DRV_LOG(ERR, "nb_desc %d is invalid", nb_desc);
rc = -EINVAL;
goto out;
}
txq->bp = bp;
txq->nb_tx_desc = nb_desc;
- txq->tx_free_thresh = tx_conf->tx_free_thresh;
+ txq->tx_free_thresh =
+ RTE_MIN(rte_align32pow2(nb_desc) / 4, RTE_BNXT_MAX_TX_BURST);
+
txq->tx_deferred_start = tx_conf->tx_deferred_start;
rc = bnxt_init_tx_ring_struct(txq, socket_id);
#ifndef _BNXT_TXQ_H_
#define _BNXT_TXQ_H_
+/* Maximum transmit burst for vector mode. */
+#define RTE_BNXT_MAX_TX_BURST 32U
+
struct bnxt_tx_ring_info;
struct bnxt_cp_ring_info;
struct bnxt_tx_queue {