net/bnxt: use appropriate type for Rx ring
authorLance Richardson <lance.richardson@broadcom.com>
Wed, 9 Sep 2020 15:52:56 +0000 (11:52 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 18 Sep 2020 16:55:09 +0000 (18:55 +0200)
Change the type of the software receive mbuf ring from an array
of structures containing an mbuf pointer to an array of pointers
to struct rte_mbuf for consistency with how this ring is currently
used by the vector mode receive function.

Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_reps.c
drivers/net/bnxt/bnxt_ring.c
drivers/net/bnxt/bnxt_rxq.c
drivers/net/bnxt/bnxt_rxr.c
drivers/net/bnxt/bnxt_rxr.h
drivers/net/bnxt/bnxt_rxtx_vec_neon.c
drivers/net/bnxt/bnxt_rxtx_vec_sse.c

index 7f9329e..26c3c1a 100644 (file)
@@ -2841,7 +2841,7 @@ bnxt_rx_descriptor_status_op(void *rx_queue, uint16_t offset)
        struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
        struct bnxt_rx_ring_info *rxr;
        struct bnxt_cp_ring_info *cpr;
-       struct bnxt_sw_rx_bd *rx_buf;
+       struct rte_mbuf *rx_buf;
        struct rx_pkt_cmpl *rxcmp;
        uint32_t cons, cp_cons;
        int rc;
@@ -2870,8 +2870,8 @@ bnxt_rx_descriptor_status_op(void *rx_queue, uint16_t offset)
                if (CMPL_VALID(rxcmp, !cpr->valid))
                        return RTE_ETH_RX_DESC_DONE;
        }
-       rx_buf = &rxr->rx_buf_ring[cons];
-       if (rx_buf->mbuf == NULL)
+       rx_buf = rxr->rx_buf_ring[cons];
+       if (rx_buf == NULL)
                return RTE_ETH_RX_DESC_UNAVAIL;
 
 
index 2f2af0d..b4ed5d6 100644 (file)
@@ -35,7 +35,7 @@ static const struct eth_dev_ops bnxt_vf_rep_dev_ops = {
 uint16_t
 bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
 {
-       struct bnxt_sw_rx_bd *prod_rx_buf;
+       struct rte_mbuf **prod_rx_buf;
        struct bnxt_rx_ring_info *rep_rxr;
        struct bnxt_rx_queue *rep_rxq;
        struct rte_eth_dev *vfr_eth_dev;
@@ -52,10 +52,9 @@ bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
        mask = rep_rxr->rx_ring_struct->ring_mask;
 
        /* Put this mbuf on the RxQ of the Representor */
-       prod_rx_buf =
-               &rep_rxr->rx_buf_ring[rep_rxr->rx_prod++ & mask];
-       if (!prod_rx_buf->mbuf) {
-               prod_rx_buf->mbuf = mbuf;
+       prod_rx_buf = &rep_rxr->rx_buf_ring[rep_rxr->rx_prod++ & mask];
+       if (!*prod_rx_buf) {
+               *prod_rx_buf = mbuf;
                vfr_bp->rx_bytes[que] += mbuf->pkt_len;
                vfr_bp->rx_pkts[que]++;
        } else {
@@ -73,7 +72,7 @@ bnxt_vf_rep_rx_burst(void *rx_queue,
                     uint16_t nb_pkts)
 {
        struct bnxt_rx_queue *rxq = rx_queue;
-       struct bnxt_sw_rx_bd *cons_rx_buf;
+       struct rte_mbuf **cons_rx_buf;
        struct bnxt_rx_ring_info *rxr;
        uint16_t nb_rx_pkts = 0;
        uint16_t mask, i;
@@ -85,11 +84,11 @@ bnxt_vf_rep_rx_burst(void *rx_queue,
        mask = rxr->rx_ring_struct->ring_mask;
        for (i = 0; i < nb_pkts; i++) {
                cons_rx_buf = &rxr->rx_buf_ring[rxr->rx_cons & mask];
-               if (!cons_rx_buf->mbuf)
+               if (*cons_rx_buf == NULL)
                        return nb_rx_pkts;
-               rx_pkts[nb_rx_pkts] = cons_rx_buf->mbuf;
+               rx_pkts[nb_rx_pkts] = *cons_rx_buf;
                rx_pkts[nb_rx_pkts]->port = rxq->port_id;
-               cons_rx_buf->mbuf = NULL;
+               *cons_rx_buf = NULL;
                nb_rx_pkts++;
                rxr->rx_cons++;
        }
@@ -557,7 +556,7 @@ int bnxt_vf_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
        struct bnxt *parent_bp = rep_bp->parent_dev->data->dev_private;
        struct bnxt_rx_queue *parent_rxq;
        struct bnxt_rx_queue *rxq;
-       struct bnxt_sw_rx_bd *buf_ring;
+       struct rte_mbuf **buf_ring;
        int rc = 0;
 
        if (queue_idx >= BNXT_MAX_VF_REP_RINGS) {
@@ -609,7 +608,7 @@ int bnxt_vf_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
                goto out;
 
        buf_ring = rte_zmalloc_socket("bnxt_rx_vfr_buf_ring",
-                                     sizeof(struct bnxt_sw_rx_bd) *
+                                     sizeof(struct rte_mbuf *) *
                                      rxq->rx_ring->rx_ring_struct->ring_size,
                                      RTE_CACHE_LINE_SIZE, socket_id);
        if (!buf_ring) {
index 8f2296b..f7f6ee8 100644 (file)
@@ -251,7 +251,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
                        rx_ring->vmem =
                            (void **)((char *)mz->addr + rx_vmem_start);
                        rx_ring_info->rx_buf_ring =
-                           (struct bnxt_sw_rx_bd *)rx_ring->vmem;
+                           (struct rte_mbuf **)rx_ring->vmem;
                }
 
                rx_ring = rx_ring_info->ag_ring_struct;
@@ -269,7 +269,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
                        rx_ring->vmem =
                            (void **)((char *)mz->addr + ag_vmem_start);
                        rx_ring_info->ag_buf_ring =
-                           (struct bnxt_sw_rx_bd *)rx_ring->vmem;
+                           (struct rte_mbuf **)rx_ring->vmem;
                }
 
                rx_ring_info->ag_bitmap =
index e42308a..db9aa1f 100644 (file)
@@ -197,7 +197,7 @@ err_out:
 
 void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
 {
-       struct bnxt_sw_rx_bd *sw_ring;
+       struct rte_mbuf **sw_ring;
        struct bnxt_tpa_info *tpa_info;
        uint16_t i;
 
@@ -210,9 +210,9 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
        if (sw_ring) {
                for (i = 0;
                     i < rxq->rx_ring->rx_ring_struct->ring_size; i++) {
-                       if (sw_ring[i].mbuf) {
-                               rte_pktmbuf_free_seg(sw_ring[i].mbuf);
-                               sw_ring[i].mbuf = NULL;
+                       if (sw_ring[i]) {
+                               rte_pktmbuf_free_seg(sw_ring[i]);
+                               sw_ring[i] = NULL;
                        }
                }
        }
@@ -221,9 +221,9 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
        if (sw_ring) {
                for (i = 0;
                     i < rxq->rx_ring->ag_ring_struct->ring_size; i++) {
-                       if (sw_ring[i].mbuf) {
-                               rte_pktmbuf_free_seg(sw_ring[i].mbuf);
-                               sw_ring[i].mbuf = NULL;
+                       if (sw_ring[i]) {
+                               rte_pktmbuf_free_seg(sw_ring[i]);
+                               sw_ring[i] = NULL;
                        }
                }
        }
index b086898..92102e3 100644 (file)
@@ -42,7 +42,7 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue *rxq,
                                     uint16_t prod)
 {
        struct rx_prod_pkt_bd *rxbd = &rxr->rx_desc_ring[prod];
-       struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[prod];
+       struct rte_mbuf **rx_buf = &rxr->rx_buf_ring[prod];
        struct rte_mbuf *mbuf;
 
        mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
@@ -51,7 +51,7 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue *rxq,
                return -ENOMEM;
        }
 
-       rx_buf->mbuf = mbuf;
+       *rx_buf = mbuf;
        mbuf->data_off = RTE_PKTMBUF_HEADROOM;
 
        rxbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
@@ -64,7 +64,7 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
                                     uint16_t prod)
 {
        struct rx_prod_pkt_bd *rxbd = &rxr->ag_desc_ring[prod];
-       struct bnxt_sw_rx_bd *rx_buf = &rxr->ag_buf_ring[prod];
+       struct rte_mbuf **rx_buf = &rxr->ag_buf_ring[prod];
        struct rte_mbuf *mbuf;
 
        if (rxbd == NULL) {
@@ -83,7 +83,7 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
                return -ENOMEM;
        }
 
-       rx_buf->mbuf = mbuf;
+       *rx_buf = mbuf;
        mbuf->data_off = RTE_PKTMBUF_HEADROOM;
 
        rxbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
@@ -95,15 +95,15 @@ static inline void bnxt_reuse_rx_mbuf(struct bnxt_rx_ring_info *rxr,
                               struct rte_mbuf *mbuf)
 {
        uint16_t prod = RING_NEXT(rxr->rx_ring_struct, rxr->rx_prod);
-       struct bnxt_sw_rx_bd *prod_rx_buf;
+       struct rte_mbuf **prod_rx_buf;
        struct rx_prod_pkt_bd *prod_bd;
 
        prod_rx_buf = &rxr->rx_buf_ring[prod];
 
-       RTE_ASSERT(prod_rx_buf->mbuf == NULL);
+       RTE_ASSERT(*prod_rx_buf == NULL);
        RTE_ASSERT(mbuf != NULL);
 
-       prod_rx_buf->mbuf = mbuf;
+       *prod_rx_buf = mbuf;
 
        prod_bd = &rxr->rx_desc_ring[prod];
 
@@ -116,13 +116,14 @@ static inline
 struct rte_mbuf *bnxt_consume_rx_buf(struct bnxt_rx_ring_info *rxr,
                                     uint16_t cons)
 {
-       struct bnxt_sw_rx_bd *cons_rx_buf;
+       struct rte_mbuf **cons_rx_buf;
        struct rte_mbuf *mbuf;
 
        cons_rx_buf = &rxr->rx_buf_ring[cons];
-       RTE_ASSERT(cons_rx_buf->mbuf != NULL);
-       mbuf = cons_rx_buf->mbuf;
-       cons_rx_buf->mbuf = NULL;
+       RTE_ASSERT(*cons_rx_buf != NULL);
+       mbuf = *cons_rx_buf;
+       *cons_rx_buf = NULL;
+
        return mbuf;
 }
 
@@ -226,7 +227,7 @@ static int bnxt_rx_pages(struct bnxt_rx_queue *rxq,
        bool is_thor_tpa = tpa_info && BNXT_CHIP_THOR(rxq->bp);
 
        for (i = 0; i < agg_buf; i++) {
-               struct bnxt_sw_rx_bd *ag_buf;
+               struct rte_mbuf **ag_buf;
                struct rte_mbuf *ag_mbuf;
 
                if (is_thor_tpa) {
@@ -245,7 +246,7 @@ static int bnxt_rx_pages(struct bnxt_rx_queue *rxq,
                ag_cons = rxcmp->opaque;
                RTE_ASSERT(ag_cons <= rxr->ag_ring_struct->ring_mask);
                ag_buf = &rxr->ag_buf_ring[ag_cons];
-               ag_mbuf = ag_buf->mbuf;
+               ag_mbuf = *ag_buf;
                RTE_ASSERT(ag_mbuf != NULL);
 
                ag_mbuf->data_len = rte_le_to_cpu_16(rxcmp->len);
@@ -256,7 +257,7 @@ static int bnxt_rx_pages(struct bnxt_rx_queue *rxq,
                last->next = ag_mbuf;
                last = ag_mbuf;
 
-               ag_buf->mbuf = NULL;
+               *ag_buf = NULL;
 
                /*
                 * As aggregation buffer consumed out of order in TPA module,
@@ -866,10 +867,10 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
                for (; cnt;
                        i = RING_NEXT(rxr->rx_ring_struct, i), cnt--) {
-                       struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i];
+                       struct rte_mbuf **rx_buf = &rxr->rx_buf_ring[i];
 
                        /* Buffer already allocated for this index. */
-                       if (rx_buf->mbuf != NULL)
+                       if (*rx_buf != NULL)
                                continue;
 
                        /* This slot is empty. Alloc buffer for Rx */
@@ -960,7 +961,7 @@ int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id)
        ring->ring_mask = ring->ring_size - 1;
        ring->bd = (void *)rxr->rx_desc_ring;
        ring->bd_dma = rxr->rx_desc_mapping;
-       ring->vmem_size = ring->ring_size * sizeof(struct bnxt_sw_rx_bd);
+       ring->vmem_size = ring->ring_size * sizeof(struct rte_mbuf *);
        ring->vmem = (void **)&rxr->rx_buf_ring;
        ring->fw_ring_id = INVALID_HW_RING_ID;
 
@@ -998,7 +999,7 @@ int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id)
        ring->ring_mask = ring->ring_size - 1;
        ring->bd = (void *)rxr->ag_desc_ring;
        ring->bd_dma = rxr->ag_desc_mapping;
-       ring->vmem_size = ring->ring_size * sizeof(struct bnxt_sw_rx_bd);
+       ring->vmem_size = ring->ring_size * sizeof(struct rte_mbuf *);
        ring->vmem = (void **)&rxr->ag_buf_ring;
        ring->fw_ring_id = INVALID_HW_RING_ID;
 
@@ -1039,7 +1040,7 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
 
        prod = rxr->rx_prod;
        for (i = 0; i < ring->ring_size; i++) {
-               if (unlikely(!rxr->rx_buf_ring[i].mbuf)) {
+               if (unlikely(!rxr->rx_buf_ring[i])) {
                        if (bnxt_alloc_rx_data(rxq, rxr, prod) != 0) {
                                PMD_DRV_LOG(WARNING,
                                            "init'ed rx ring %d with %d/%d mbufs only\n",
@@ -1057,7 +1058,7 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
        prod = rxr->ag_prod;
 
        for (i = 0; i < ring->ring_size; i++) {
-               if (unlikely(!rxr->ag_buf_ring[i].mbuf)) {
+               if (unlikely(!rxr->ag_buf_ring[i])) {
                        if (bnxt_alloc_ag_data(rxq, rxr, prod) != 0) {
                                PMD_DRV_LOG(WARNING,
                                            "init'ed AG ring %d with %d/%d mbufs only\n",
index 2bf46cd..5b9b5f3 100644 (file)
@@ -181,10 +181,6 @@ struct bnxt_tpa_info {
        struct rx_tpa_v2_abuf_cmpl      agg_arr[TPA_MAX_NUM_SEGS];
 };
 
-struct bnxt_sw_rx_bd {
-       struct rte_mbuf         *mbuf; /* data associated with RX descriptor */
-};
-
 struct bnxt_rx_ring_info {
        uint16_t                rx_prod;
        uint16_t                ag_prod;
@@ -194,8 +190,8 @@ struct bnxt_rx_ring_info {
 
        struct rx_prod_pkt_bd   *rx_desc_ring;
        struct rx_prod_pkt_bd   *ag_desc_ring;
-       struct bnxt_sw_rx_bd    *rx_buf_ring; /* sw ring */
-       struct bnxt_sw_rx_bd    *ag_buf_ring; /* sw ring */
+       struct rte_mbuf         **rx_buf_ring; /* sw ring */
+       struct rte_mbuf         **ag_buf_ring; /* sw ring */
 
        rte_iova_t              rx_desc_mapping;
        rte_iova_t              ag_desc_mapping;
index bf76c2a..eff196f 100644 (file)
@@ -29,7 +29,7 @@ static inline void
 bnxt_rxq_rearm(struct bnxt_rx_queue *rxq, struct bnxt_rx_ring_info *rxr)
 {
        struct rx_prod_pkt_bd *rxbds = &rxr->rx_desc_ring[rxq->rxrearm_start];
-       struct bnxt_sw_rx_bd *rx_bufs = &rxr->rx_buf_ring[rxq->rxrearm_start];
+       struct rte_mbuf **rx_bufs = &rxr->rx_buf_ring[rxq->rxrearm_start];
        struct rte_mbuf *mb0, *mb1;
        int i;
 
@@ -51,8 +51,8 @@ bnxt_rxq_rearm(struct bnxt_rx_queue *rxq, struct bnxt_rx_ring_info *rxr)
                uint64x2_t buf_addr0, buf_addr1;
                uint64x2_t rxbd0, rxbd1;
 
-               mb0 = rx_bufs[0].mbuf;
-               mb1 = rx_bufs[1].mbuf;
+               mb0 = rx_bufs[0];
+               mb1 = rx_bufs[1];
 
                /* Load address fields from both mbufs */
                buf_addr0 = vld1q_u64((uint64_t *)&mb0->buf_addr);
@@ -260,9 +260,9 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                        raw_cons = tmp_raw_cons;
                        cons = rxcmp->opaque;
 
-                       mbuf = rxr->rx_buf_ring[cons].mbuf;
+                       mbuf = rxr->rx_buf_ring[cons];
                        rte_prefetch0(mbuf);
-                       rxr->rx_buf_ring[cons].mbuf = NULL;
+                       rxr->rx_buf_ring[cons] = NULL;
 
                        /* Set constant fields from mbuf initializer. */
                        vst1q_u64((uint64_t *)&mbuf->rearm_data, mbuf_init);
index 98220bc..822e433 100644 (file)
@@ -33,7 +33,7 @@ static inline void
 bnxt_rxq_rearm(struct bnxt_rx_queue *rxq, struct bnxt_rx_ring_info *rxr)
 {
        struct rx_prod_pkt_bd *rxbds = &rxr->rx_desc_ring[rxq->rxrearm_start];
-       struct bnxt_sw_rx_bd *rx_bufs = &rxr->rx_buf_ring[rxq->rxrearm_start];
+       struct rte_mbuf **rx_bufs = &rxr->rx_buf_ring[rxq->rxrearm_start];
        struct rte_mbuf *mb0, *mb1;
        int i;
 
@@ -55,8 +55,8 @@ bnxt_rxq_rearm(struct bnxt_rx_queue *rxq, struct bnxt_rx_ring_info *rxr)
                __m128i buf_addr0, buf_addr1;
                __m128i rxbd0, rxbd1;
 
-               mb0 = rx_bufs[0].mbuf;
-               mb1 = rx_bufs[1].mbuf;
+               mb0 = rx_bufs[0];
+               mb1 = rx_bufs[1];
 
                /* Load address fields from both mbufs */
                buf_addr0 = _mm_loadu_si128((__m128i *)&mb0->buf_addr);
@@ -265,9 +265,9 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                        raw_cons = tmp_raw_cons;
                        cons = rxcmp->opaque;
 
-                       mbuf = rxr->rx_buf_ring[cons].mbuf;
+                       mbuf = rxr->rx_buf_ring[cons];
                        rte_prefetch0(mbuf);
-                       rxr->rx_buf_ring[cons].mbuf = NULL;
+                       rxr->rx_buf_ring[cons] = NULL;
 
                        /* Set constant fields from mbuf initializer. */
                        _mm_store_si128((__m128i *)&mbuf->rearm_data,