eventdev: support Tx adapter event vector
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Wed, 31 Mar 2021 09:29:59 +0000 (14:59 +0530)
committerJerin Jacob <jerinj@marvell.com>
Mon, 12 Apr 2021 07:23:34 +0000 (09:23 +0200)
Add event vector support for event eth Tx adapter, the implementation
receives events from the single linked queue and based on
rte_event_vector::attr_valid transmits the vector of mbufs to a given
port, queue pair.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
lib/librte_eventdev/rte_event_eth_tx_adapter.c
lib/librte_eventdev/rte_eventdev.c

index 5b4c42d..db260bf 100644 (file)
@@ -510,6 +510,47 @@ txa_service_buffer_retry(struct rte_mbuf **pkts, uint16_t unsent,
        stats->tx_dropped += unsent - sent;
 }
 
+static uint16_t
+txa_process_event_vector(struct txa_service_data *txa,
+                        struct rte_event_vector *vec)
+{
+       struct txa_service_queue_info *tqi;
+       uint16_t port, queue, nb_tx = 0;
+       struct rte_mbuf **mbufs;
+       int i;
+
+       mbufs = (struct rte_mbuf **)vec->mbufs;
+       if (vec->attr_valid) {
+               port = vec->port;
+               queue = vec->queue;
+               tqi = txa_service_queue(txa, port, queue);
+               if (unlikely(tqi == NULL || !tqi->added)) {
+                       rte_pktmbuf_free_bulk(mbufs, vec->nb_elem);
+                       rte_mempool_put(rte_mempool_from_obj(vec), vec);
+                       return 0;
+               }
+               for (i = 0; i < vec->nb_elem; i++) {
+                       nb_tx += rte_eth_tx_buffer(port, queue, tqi->tx_buf,
+                                                  mbufs[i]);
+               }
+       } else {
+               for (i = 0; i < vec->nb_elem; i++) {
+                       port = mbufs[i]->port;
+                       queue = rte_event_eth_tx_adapter_txq_get(mbufs[i]);
+                       tqi = txa_service_queue(txa, port, queue);
+                       if (unlikely(tqi == NULL || !tqi->added)) {
+                               rte_pktmbuf_free(mbufs[i]);
+                               continue;
+                       }
+                       nb_tx += rte_eth_tx_buffer(port, queue, tqi->tx_buf,
+                                                  mbufs[i]);
+               }
+       }
+       rte_mempool_put(rte_mempool_from_obj(vec), vec);
+
+       return nb_tx;
+}
+
 static void
 txa_service_tx(struct txa_service_data *txa, struct rte_event *ev,
        uint32_t n)
@@ -522,22 +563,27 @@ txa_service_tx(struct txa_service_data *txa, struct rte_event *ev,
 
        nb_tx = 0;
        for (i = 0; i < n; i++) {
-               struct rte_mbuf *m;
                uint16_t port;
                uint16_t queue;
                struct txa_service_queue_info *tqi;
 
-               m = ev[i].mbuf;
-               port = m->port;
-               queue = rte_event_eth_tx_adapter_txq_get(m);
+               if (!(ev[i].event_type & RTE_EVENT_TYPE_VECTOR)) {
+                       struct rte_mbuf *m;
 
-               tqi = txa_service_queue(txa, port, queue);
-               if (unlikely(tqi == NULL || !tqi->added)) {
-                       rte_pktmbuf_free(m);
-                       continue;
-               }
+                       m = ev[i].mbuf;
+                       port = m->port;
+                       queue = rte_event_eth_tx_adapter_txq_get(m);
 
-               nb_tx += rte_eth_tx_buffer(port, queue, tqi->tx_buf, m);
+                       tqi = txa_service_queue(txa, port, queue);
+                       if (unlikely(tqi == NULL || !tqi->added)) {
+                               rte_pktmbuf_free(m);
+                               continue;
+                       }
+
+                       nb_tx += rte_eth_tx_buffer(port, queue, tqi->tx_buf, m);
+               } else {
+                       nb_tx += txa_process_event_vector(txa, ev[i].vec);
+               }
        }
 
        stats->tx_packets += nb_tx;
index 6282465..c9bb5d2 100644 (file)
@@ -196,7 +196,10 @@ rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
        if (caps == NULL)
                return -EINVAL;
 
-       *caps = 0;
+       if (dev->dev_ops->eth_tx_adapter_caps_get == NULL)
+               *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
+       else
+               *caps = 0;
 
        return dev->dev_ops->eth_tx_adapter_caps_get ?
                        (*dev->dev_ops->eth_tx_adapter_caps_get)(dev,