raw/ifpga: remove virtual devices on close
[dpdk.git] / examples / eventdev_pipeline / pipeline_worker_generic.c
index b166685..c564c80 100644 (file)
@@ -16,6 +16,7 @@ worker_generic(void *arg)
        uint8_t port_id = data->port_id;
        size_t sent = 0, received = 0;
        unsigned int lcore_id = rte_lcore_id();
+       uint16_t nb_rx = 0, nb_tx = 0;
 
        while (!fdata->done) {
 
@@ -27,8 +28,7 @@ worker_generic(void *arg)
                        continue;
                }
 
-               const uint16_t nb_rx = rte_event_dequeue_burst(dev_id, port_id,
-                               &ev, 1, 0);
+               nb_rx = rte_event_dequeue_burst(dev_id, port_id, &ev, 1, 0);
 
                if (nb_rx == 0) {
                        rte_pause();
@@ -47,11 +47,14 @@ worker_generic(void *arg)
 
                work();
 
-               while (rte_event_enqueue_burst(dev_id, port_id, &ev, 1) != 1)
-                       rte_pause();
+               do {
+                       nb_tx = rte_event_enqueue_burst(dev_id, port_id, &ev,
+                                                       1);
+               } while (!nb_tx && !fdata->done);
                sent++;
        }
 
+       worker_cleanup(dev_id, port_id, &ev, nb_tx, nb_rx);
        if (!cdata.quiet)
                printf("  worker %u thread done. RX=%zu TX=%zu\n",
                                rte_lcore_id(), received, sent);
@@ -69,10 +72,9 @@ worker_generic_burst(void *arg)
        uint8_t port_id = data->port_id;
        size_t sent = 0, received = 0;
        unsigned int lcore_id = rte_lcore_id();
+       uint16_t i, nb_rx = 0, nb_tx = 0;
 
        while (!fdata->done) {
-               uint16_t i;
-
                if (fdata->cap.scheduler)
                        fdata->cap.scheduler(lcore_id);
 
@@ -81,8 +83,8 @@ worker_generic_burst(void *arg)
                        continue;
                }
 
-               const uint16_t nb_rx = rte_event_dequeue_burst(dev_id, port_id,
-                               events, RTE_DIM(events), 0);
+               nb_rx = rte_event_dequeue_burst(dev_id, port_id, events,
+                                               RTE_DIM(events), 0);
 
                if (nb_rx == 0) {
                        rte_pause();
@@ -103,8 +105,7 @@ worker_generic_burst(void *arg)
 
                        work();
                }
-               uint16_t nb_tx = rte_event_enqueue_burst(dev_id, port_id,
-                               events, nb_rx);
+               nb_tx = rte_event_enqueue_burst(dev_id, port_id, events, nb_rx);
                while (nb_tx < nb_rx && !fdata->done)
                        nb_tx += rte_event_enqueue_burst(dev_id, port_id,
                                                        events + nb_tx,
@@ -112,6 +113,8 @@ worker_generic_burst(void *arg)
                sent += nb_tx;
        }
 
+       worker_cleanup(dev_id, port_id, events, nb_tx, nb_rx);
+
        if (!cdata.quiet)
                printf("  worker %u thread done. RX=%zu TX=%zu\n",
                                rte_lcore_id(), received, sent);
@@ -284,13 +287,13 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        struct rte_eth_rxconf rx_conf;
        static const struct rte_eth_conf port_conf_default = {
                .rxmode = {
-                       .mq_mode = ETH_MQ_RX_RSS,
+                       .mq_mode = RTE_ETH_MQ_RX_RSS,
                },
                .rx_adv_conf = {
                        .rss_conf = {
-                               .rss_hf = ETH_RSS_IP |
-                                         ETH_RSS_TCP |
-                                         ETH_RSS_UDP,
+                               .rss_hf = RTE_ETH_RSS_IP |
+                                         RTE_ETH_RSS_TCP |
+                                         RTE_ETH_RSS_UDP,
                        }
                }
        };
@@ -312,12 +315,12 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
                return retval;
        }
 
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+       if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
                port_conf.txmode.offloads |=
-                       DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+                       RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_RSS_HASH)
-               port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+       if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_RSS_HASH)
+               port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
        rx_conf = dev_info.default_rxconf;
        rx_conf.offloads = port_conf.rxmode.offloads;