net/bnxt: add multi-device infrastructure
[dpdk.git] / drivers / net / bnxt / bnxt_rxr.c
index 33bd006..039217f 100644 (file)
@@ -795,6 +795,19 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
                goto rx;
        }
        rxr->rx_prod = prod;
+
+       if (BNXT_TRUFLOW_EN(bp) && (BNXT_VF_IS_TRUSTED(bp) || BNXT_PF(bp)) &&
+           vfr_flag) {
+               bnxt_vfr_recv(mark_id, rxq->queue_id, mbuf);
+               /* Now return an error so that nb_rx_pkts is not
+                * incremented.
+                * This packet was meant to be given to the representor.
+                * So no need to account the packet and give it to
+                * parent Rx burst function.
+                */
+               rc = -ENODEV;
+               goto next_rx;
+       }
        /*
         * All MBUFs are allocated with the same size under DPDK,
         * no optimization for rx_copy_thresh
@@ -802,20 +815,6 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 rx:
        *rx_pkt = mbuf;
 
-       if (BNXT_TRUFLOW_EN(bp) &&
-           (BNXT_VF_IS_TRUSTED(bp) || BNXT_PF(bp)) &&
-           vfr_flag) {
-               if (!bnxt_vfr_recv(mark_id, rxq->queue_id, mbuf)) {
-                       /* Now return an error so that nb_rx_pkts is not
-                        * incremented.
-                        * This packet was meant to be given to the representor.
-                        * So no need to account the packet and give it to
-                        * parent Rx burst function.
-                        */
-                       rc = -ENODEV;
-               }
-       }
-
 next_rx:
 
        *raw_cons = tmp_raw_cons;
@@ -931,7 +930,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                        struct rte_mbuf **rx_buf = &rxr->rx_buf_ring[i];
 
                        /* Buffer already allocated for this index. */
-                       if (*rx_buf != NULL)
+                       if (*rx_buf != NULL && *rx_buf != &rxq->fake_mbuf)
                                continue;
 
                        /* This slot is empty. Alloc buffer for Rx */
@@ -1025,7 +1024,11 @@ 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 rte_mbuf *);
+
+       /* Allocate extra rx ring entries for vector rx. */
+       ring->vmem_size = sizeof(struct rte_mbuf *) *
+                               (ring->ring_size + RTE_BNXT_DESCS_PER_LOOP);
+
        ring->vmem = (void **)&rxr->rx_buf_ring;
        ring->fw_ring_id = INVALID_HW_RING_ID;
 
@@ -1136,6 +1139,12 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
                prod = RING_NEXT(rxr->rx_ring_struct, prod);
        }
 
+       /* Initialize dummy mbuf pointers for vector mode rx. */
+       for (i = ring->ring_size;
+            i < ring->ring_size + RTE_BNXT_DESCS_PER_LOOP; i++) {
+               rxr->rx_buf_ring[i] = &rxq->fake_mbuf;
+       }
+
        ring = rxr->ag_ring_struct;
        type = RX_PROD_AGG_BD_TYPE_RX_PROD_AGG;
        bnxt_init_rxbds(ring, type, size);