net/octeontx: add packet receive burst function
authorJerin Jacob <jerin.jacob@caviumnetworks.com>
Sun, 8 Oct 2017 12:44:27 +0000 (18:14 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 12 Oct 2017 00:36:58 +0000 (01:36 +0100)
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
drivers/net/octeontx/octeontx_rxtx.c
drivers/net/octeontx/octeontx_rxtx.h

index 32f46ae..05f0036 100644 (file)
@@ -102,3 +102,41 @@ octeontx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
        return count; /* return number of pkts transmitted */
 }
+
+uint16_t __hot
+octeontx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+{
+       struct rte_mbuf *mbuf;
+       struct octeontx_rxq *rxq;
+       struct rte_event ev;
+       octtx_wqe_t *wqe;
+       size_t count;
+       uint16_t valid_event;
+
+       rxq = rx_queue;
+       count = 0;
+       while (count < nb_pkts) {
+               valid_event = rte_event_dequeue_burst(rxq->evdev,
+                                                       rxq->ev_ports, &ev,
+                                                       1, 0);
+               if (!valid_event)
+                       break;
+
+               wqe = (octtx_wqe_t *)(uintptr_t)ev.u64;
+               rte_prefetch_non_temporal(wqe);
+
+               /* Get mbuf from wqe */
+               mbuf = (struct rte_mbuf *)((uintptr_t)wqe -
+                                               OCTTX_PACKET_WQE_SKIP);
+               mbuf->data_off = RTE_PTR_DIFF(wqe->s.w3.addr, mbuf->buf_addr);
+               mbuf->pkt_len = wqe->s.w1.len;
+               mbuf->data_len = mbuf->pkt_len;
+               mbuf->nb_segs = 1;
+               mbuf->ol_flags = 0;
+               mbuf->port = rxq->port_id;
+               rte_mbuf_refcnt_set(mbuf, 1);
+               rx_pkts[count++] = mbuf;
+       }
+
+       return count; /* return number of pkts received */
+}
index 4a49fc1..1f91532 100644 (file)
@@ -42,5 +42,7 @@
 uint16_t
 octeontx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 
+uint16_t
+octeontx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
 #endif /* __OCTEONTX_RXTX_H__ */