net/bnxt: support port representor data path
[dpdk.git] / drivers / net / bnxt / bnxt_rxr.c
index d2955ba..37b534f 100644 (file)
@@ -12,6 +12,7 @@
 #include <rte_memory.h>
 
 #include "bnxt.h"
+#include "bnxt_reps.h"
 #include "bnxt_ring.h"
 #include "bnxt_rxr.h"
 #include "bnxt_rxq.h"
@@ -412,7 +413,13 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
        bool gfid = false;
        uint32_t mark_id;
        uint32_t flags2;
+       uint32_t gfid_support = 0;
        int rc;
+       uint32_t vfr_flag;
+
+
+       if (BNXT_GFID_ENABLED(bp))
+               gfid_support = 1;
 
        cfa_code = rte_le_to_cpu_16(rxcmp1->cfa_code);
        flags2 = rte_le_to_cpu_32(rxcmp1->flags2);
@@ -427,8 +434,14 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
 
        switch (meta_fmt) {
        case 0:
-               /* Not an LFID or GFID, a flush cmd. */
-               goto skip_mark;
+               if (gfid_support) {
+                       /* Not an LFID or GFID, a flush cmd. */
+                       goto skip_mark;
+               } else {
+                       /* LFID mode, no vlan scenario */
+                       gfid = false;
+               }
+               break;
        case 4:
        case 5:
                /*
@@ -437,13 +450,19 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
                 * collisions with EEM.  Simply return without setting the mark
                 * in the mbuf.
                 */
-               if (BNXT_CFA_META_EM_TEST(meta))
-                       goto skip_mark;
-               /*
-                * It is a TCAM entry, so it is an LFID. The TCAM IDX and Mode
-                * can also be determined by decoding the meta_data.  We are not
-                * using these for now.
-                */
+               if (BNXT_CFA_META_EM_TEST(meta)) {
+                       /*This is EM hit {EM(1), GFID[27:16], 19'd0 or vtag } */
+                       gfid = true;
+                       meta >>= BNXT_RX_META_CFA_CODE_SHIFT;
+                       cfa_code |= meta << BNXT_CFA_CODE_META_SHIFT;
+               } else {
+                       /*
+                        * It is a TCAM entry, so it is an LFID.
+                        * The TCAM IDX and Mode can also be determined
+                        * by decoding the meta_data. We are not
+                        * using these for now.
+                        */
+               }
                break;
        case 6:
        case 7:
@@ -465,17 +484,15 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
                break;
        }
 
-       if (cfa_code) {
-               rc = ulp_mark_db_mark_get(bp->ulp_ctx, gfid,
-                                         cfa_code, &mark_id);
-               if (!rc) {
-                       /* Got the mark, write it to the mbuf and return */
-                       mbuf->hash.fdir.hi = mark_id;
-                       mbuf->udata64 = (cfa_code & 0xffffffffull) << 32;
-                       mbuf->hash.fdir.id = rxcmp1->cfa_code;
-                       mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
-                       return;
-               }
+       rc = ulp_mark_db_mark_get(bp->ulp_ctx, gfid,
+                                 cfa_code, &vfr_flag, &mark_id);
+       if (!rc) {
+               /* Got the mark, write it to the mbuf and return */
+               mbuf->hash.fdir.hi = mark_id;
+               mbuf->udata64 = (cfa_code & 0xffffffffull) << 32;
+               mbuf->hash.fdir.id = rxcmp1->cfa_code;
+               mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+               return;
        }
 
 skip_mark:
@@ -523,7 +540,7 @@ void bnxt_set_mark_in_mbuf(struct bnxt *bp,
 }
 
 static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
-                           struct bnxt_rx_queue *rxq, uint32_t *raw_cons)
+                      struct bnxt_rx_queue *rxq, uint32_t *raw_cons)
 {
        struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
        struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
@@ -719,6 +736,20 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 rx:
        *rx_pkt = mbuf;
 
+       if ((BNXT_VF_IS_TRUSTED(rxq->bp) || BNXT_PF(rxq->bp)) &&
+           rxq->bp->cfa_code_map && rxcmp1->cfa_code) {
+               if (!bnxt_vfr_recv(rxq->bp, rxcmp1->cfa_code, 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;
@@ -735,6 +766,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        uint32_t raw_cons = cpr->cp_raw_cons;
        uint32_t cons;
        int nb_rx_pkts = 0;
+       int nb_rep_rx_pkts = 0;
        struct rx_pkt_cmpl *rxcmp;
        uint16_t prod = rxr->rx_prod;
        uint16_t ag_prod = rxr->ag_prod;
@@ -768,6 +800,8 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                                nb_rx_pkts++;
                        if (rc == -EBUSY)       /* partial completion */
                                break;
+                       if (rc == -ENODEV)      /* completion for representor */
+                               nb_rep_rx_pkts++;
                } else if (!BNXT_NUM_ASYNC_CPR(rxq->bp)) {
                        evt =
                        bnxt_event_hwrm_resp_handler(rxq->bp,
@@ -786,7 +820,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        }
 
        cpr->cp_raw_cons = raw_cons;
-       if (!nb_rx_pkts && !evt) {
+       if (!nb_rx_pkts && !nb_rep_rx_pkts && !evt) {
                /*
                 * For PMD, there is no need to keep on pushing to REARM
                 * the doorbell if there are no new completions
@@ -987,9 +1021,9 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
                                            rxq->queue_id, i, ring->ring_size);
                                break;
                        }
-                       rxr->rx_prod = prod;
-                       prod = RING_NEXT(rxr->rx_ring_struct, prod);
                }
+               rxr->rx_prod = prod;
+               prod = RING_NEXT(rxr->rx_ring_struct, prod);
        }
 
        ring = rxr->ag_ring_struct;
@@ -1005,9 +1039,9 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
                                            rxq->queue_id, i, ring->ring_size);
                                break;
                        }
-                       rxr->ag_prod = prod;
-                       prod = RING_NEXT(rxr->ag_ring_struct, prod);
                }
+               rxr->ag_prod = prod;
+               prod = RING_NEXT(rxr->ag_ring_struct, prod);
        }
        PMD_DRV_LOG(DEBUG, "AGG Done!\n");