#include "bnxt_rxr.h"
#include "bnxt_rxq.h"
#include "hsi_struct_def_dpdk.h"
+#include "bnxt_rxtx_vec_common.h"
#include "bnxt_txq.h"
#include "bnxt_txr.h"
* RX Ring handling
*/
-#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
-
static inline void
bnxt_rxq_rearm(struct bnxt_rx_queue *rxq, struct bnxt_rx_ring_info *rxr)
{
/* Return no more than RTE_BNXT_MAX_RX_BURST per call. */
nb_pkts = RTE_MIN(nb_pkts, RTE_BNXT_MAX_RX_BURST);
- /* Make nb_pkts an integer multiple of RTE_BNXT_DESCS_PER_LOOP */
+ /*
+ * Make nb_pkts an integer multiple of RTE_BNXT_DESCS_PER_LOOP.
+ * nb_pkts < RTE_BNXT_DESCS_PER_LOOP, just return no packet
+ */
nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_BNXT_DESCS_PER_LOOP);
+ if (!nb_pkts)
+ return 0;
/* Handle RX burst request */
while (1) {
if (!CMP_VALID(rxcmp, raw_cons, cpr->cp_ring_struct))
break;
- cpr->valid = FLIP_VALID(cons,
- cpr->cp_ring_struct->ring_mask,
- cpr->valid);
-
if (likely(CMP_TYPE(rxcmp) == RX_PKT_CMPL_TYPE_RX_L2)) {
struct rx_pkt_cmpl_hi *rxcmp1;
uint32_t tmp_raw_cons;
rte_prefetch0(mbuf);
rxr->rx_buf_ring[cons].mbuf = NULL;
- cpr->valid = FLIP_VALID(cp_cons,
- cpr->cp_ring_struct->ring_mask,
- cpr->valid);
-
/* Set constant fields from mbuf initializer. */
_mm_store_si128((__m128i *)&mbuf->rearm_data,
mbuf_init);
(RX_PKT_CMPL_METADATA_VID_MASK |
RX_PKT_CMPL_METADATA_DE |
RX_PKT_CMPL_METADATA_PRI_MASK);
- mbuf->ol_flags |= PKT_RX_VLAN;
+ mbuf->ol_flags |=
+ PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
}
bnxt_parse_csum(mbuf, rxcmp1);
rxq->rxrearm_nb += nb_rx_pkts;
cpr->cp_raw_cons = raw_cons;
+ cpr->valid = !!(cpr->cp_raw_cons & cpr->cp_ring_struct->ring_size);
if (nb_rx_pkts || evt)
bnxt_db_cq(cpr);
return nb_rx_pkts;
}
-static inline void bnxt_next_cmpl(struct bnxt_cp_ring_info *cpr, uint32_t *idx,
- bool *v, uint32_t inc)
-{
- *idx += inc;
- if (unlikely(*idx == cpr->cp_ring_struct->ring_size)) {
- *v = !*v;
- *idx = 0;
- }
-}
-
static void
bnxt_tx_cmp_vec(struct bnxt_tx_queue *txq, int nr_pkts)
{
cons = RING_CMPL(ring_mask, raw_cons);
txcmp = (struct tx_cmpl *)&cp_desc_ring[cons];
- if (!CMPL_VALID(txcmp, cpr->valid))
+ if (!CMP_VALID(txcmp, raw_cons, cp_ring_struct))
break;
- bnxt_next_cmpl(cpr, &cons, &cpr->valid, 1);
- rte_prefetch0(&cp_desc_ring[cons]);
if (likely(CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2))
nb_tx_pkts += txcmp->opaque;
RTE_LOG_DP(ERR, PMD,
"Unhandled CMP type %02x\n",
CMP_TYPE(txcmp));
- raw_cons = cons;
+ raw_cons = NEXT_RAW_CMP(raw_cons);
} while (nb_tx_pkts < ring_mask);
+ cpr->valid = !!(raw_cons & cp_ring_struct->ring_size);
if (nb_tx_pkts) {
bnxt_tx_cmp_vec(txq, nb_tx_pkts);
cpr->cp_raw_cons = raw_cons;
}
}
-#define TX_BD_FLAGS_CMPL ((1 << TX_BD_LONG_FLAGS_BD_CNT_SFT) | \
- TX_BD_SHORT_FLAGS_COAL_NOW | \
- TX_BD_SHORT_TYPE_TX_BD_SHORT | \
- TX_BD_LONG_FLAGS_PACKET_END)
-
-#define TX_BD_FLAGS_NOCMPL (TX_BD_FLAGS_CMPL | TX_BD_LONG_FLAGS_NO_CMPL)
-
-static inline uint32_t
-bnxt_xmit_flags_len(uint16_t len, uint16_t flags)
-{
- switch (len >> 9) {
- case 0:
- return flags | TX_BD_LONG_FLAGS_LHINT_LT512;
- case 1:
- return flags | TX_BD_LONG_FLAGS_LHINT_LT1K;
- case 2:
- return flags | TX_BD_LONG_FLAGS_LHINT_LT2K;
- case 3:
- return flags | TX_BD_LONG_FLAGS_LHINT_LT2K;
- default:
- return flags | TX_BD_LONG_FLAGS_LHINT_GTE2K;
- }
-}
-
static uint16_t
bnxt_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
struct bnxt_tx_queue *txq = tx_queue;
/* Tx queue was stopped; wait for it to be restarted */
- if (unlikely(txq->tx_deferred_start)) {
+ if (unlikely(!txq->tx_started)) {
PMD_DRV_LOG(DEBUG, "Tx q stopped;return\n");
return 0;
}
return nb_sent;
}
-int __attribute__((cold))
+int __rte_cold
bnxt_rxq_vec_setup(struct bnxt_rx_queue *rxq)
{
- uintptr_t p;
- struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
-
- mb_def.nb_segs = 1;
- mb_def.data_off = RTE_PKTMBUF_HEADROOM;
- mb_def.port = rxq->port_id;
- rte_mbuf_refcnt_set(&mb_def, 1);
-
- /* prevent compiler reordering: rearm_data covers previous fields */
- rte_compiler_barrier();
- p = (uintptr_t)&mb_def.rearm_data;
- rxq->mbuf_initializer = *(uint64_t *)p;
- rxq->rxrearm_nb = 0;
- rxq->rxrearm_start = 0;
- return 0;
+ return bnxt_rxq_vec_setup_common(rxq);
}