app/eventdev: simplify signal handling and teardown
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Fri, 13 May 2022 16:07:14 +0000 (21:37 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 17 May 2022 14:43:04 +0000 (16:43 +0200)
Remove rte_*_dev calls from signal handler callback as signal handlers
are supposed to be light weight.

Split ethdev teardown into Rx and Tx sections, wait for
workers to finish processing after disabling Rx to allow workers
to complete processing currently held packets.

Verified SW event device on ARM64 using the following command:

./build/app/dpdk-test-eventdev -l 7-23 -s 0xf00 --vdev=event_sw0
 -a 0002:02:00.0 -- --prod_type_ethdev --nb_pkts=0 --verbose 2
 --test=pipeline_queue --stlist=o --wlcores 16-23

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
app/test-eventdev/evt_main.c
app/test-eventdev/evt_test.h
app/test-eventdev/test_perf_atq.c
app/test-eventdev/test_perf_common.c
app/test-eventdev/test_perf_common.h
app/test-eventdev/test_perf_queue.c
app/test-eventdev/test_pipeline_atq.c
app/test-eventdev/test_pipeline_common.c
app/test-eventdev/test_pipeline_common.h
app/test-eventdev/test_pipeline_queue.c

index a7d6b0c..c5d6306 100644 (file)
@@ -19,11 +19,7 @@ struct evt_test *test;
 static void
 signal_handler(int signum)
 {
-       int i;
-       static uint8_t once;
-
-       if ((signum == SIGINT || signum == SIGTERM) && !once) {
-               once = true;
+       if (signum == SIGINT || signum == SIGTERM) {
                printf("\nSignal %d received, preparing to exit...\n",
                                signum);
 
@@ -31,36 +27,7 @@ signal_handler(int signum)
                        /* request all lcores to exit from the main loop */
                        *(int *)test->test_priv = true;
                        rte_wmb();
-
-                       if (test->ops.ethdev_destroy)
-                               test->ops.ethdev_destroy(test, &opt);
-
-                       if (test->ops.cryptodev_destroy)
-                               test->ops.cryptodev_destroy(test, &opt);
-
-                       rte_eal_mp_wait_lcore();
-
-                       if (test->ops.test_result)
-                               test->ops.test_result(test, &opt);
-
-                       if (opt.prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
-                               RTE_ETH_FOREACH_DEV(i)
-                                       rte_eth_dev_close(i);
-                       }
-
-                       if (test->ops.eventdev_destroy)
-                               test->ops.eventdev_destroy(test, &opt);
-
-                       if (test->ops.mempool_destroy)
-                               test->ops.mempool_destroy(test, &opt);
-
-                       if (test->ops.test_destroy)
-                               test->ops.test_destroy(test, &opt);
                }
-
-               /* exit with the expected status */
-               signal(signum, SIG_DFL);
-               kill(getpid(), signum);
        }
 }
 
@@ -189,10 +156,29 @@ main(int argc, char **argv)
                }
        }
 
+       if (test->ops.ethdev_rx_stop)
+               test->ops.ethdev_rx_stop(test, &opt);
+
+       if (test->ops.cryptodev_destroy)
+               test->ops.cryptodev_destroy(test, &opt);
+
        rte_eal_mp_wait_lcore();
 
-       /* Print the test result */
-       ret = test->ops.test_result(test, &opt);
+       if (test->ops.test_result)
+               test->ops.test_result(test, &opt);
+
+       if (test->ops.ethdev_destroy)
+               test->ops.ethdev_destroy(test, &opt);
+
+       if (test->ops.eventdev_destroy)
+               test->ops.eventdev_destroy(test, &opt);
+
+       if (test->ops.mempool_destroy)
+               test->ops.mempool_destroy(test, &opt);
+
+       if (test->ops.test_destroy)
+               test->ops.test_destroy(test, &opt);
+
 nocap:
        if (ret == EVT_TEST_SUCCESS) {
                printf("Result: "CLGRN"%s"CLNRM"\n", "Success");
index 50fa474..1049f99 100644 (file)
@@ -41,6 +41,8 @@ typedef void (*evt_test_eventdev_destroy_t)
                (struct evt_test *test, struct evt_options *opt);
 typedef void (*evt_test_ethdev_destroy_t)
                (struct evt_test *test, struct evt_options *opt);
+typedef void (*evt_test_ethdev_rx_stop_t)(struct evt_test *test,
+                                         struct evt_options *opt);
 typedef void (*evt_test_cryptodev_destroy_t)
                (struct evt_test *test, struct evt_options *opt);
 typedef void (*evt_test_mempool_destroy_t)
@@ -60,6 +62,7 @@ struct evt_test_ops {
        evt_test_launch_lcores_t launch_lcores;
        evt_test_result_t test_result;
        evt_test_eventdev_destroy_t eventdev_destroy;
+       evt_test_ethdev_rx_stop_t ethdev_rx_stop;
        evt_test_ethdev_destroy_t ethdev_destroy;
        evt_test_cryptodev_destroy_t cryptodev_destroy;
        evt_test_mempool_destroy_t mempool_destroy;
index 67ff681..bac3ea6 100644 (file)
@@ -343,6 +343,7 @@ static const struct evt_test_ops perf_atq =  {
        .test_setup         = perf_test_setup,
        .ethdev_setup       = perf_ethdev_setup,
        .cryptodev_setup    = perf_cryptodev_setup,
+       .ethdev_rx_stop     = perf_ethdev_rx_stop,
        .mempool_setup      = perf_mempool_setup,
        .eventdev_setup     = perf_atq_eventdev_setup,
        .launch_lcores      = perf_atq_launch_lcores,
index 9d1f4a4..4cf16b4 100644 (file)
@@ -1087,7 +1087,8 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
        return 0;
 }
 
-void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
+void
+perf_ethdev_rx_stop(struct evt_test *test, struct evt_options *opt)
 {
        uint16_t i;
        RTE_SET_USED(test);
@@ -1095,6 +1096,23 @@ void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
        if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
                RTE_ETH_FOREACH_DEV(i) {
                        rte_event_eth_rx_adapter_stop(i);
+                       rte_event_eth_rx_adapter_queue_del(i, i, -1);
+                       rte_eth_dev_rx_queue_stop(i, 0);
+               }
+       }
+}
+
+void
+perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+       uint16_t i;
+       RTE_SET_USED(test);
+
+       if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
+               RTE_ETH_FOREACH_DEV(i) {
+                       rte_event_eth_tx_adapter_stop(i);
+                       rte_event_eth_tx_adapter_queue_del(i, i, -1);
+                       rte_eth_dev_tx_queue_stop(i, 0);
                        rte_eth_dev_stop(i);
                }
        }
index ea0907d..e504bb1 100644 (file)
 #include <rte_cryptodev.h>
 #include <rte_cycles.h>
 #include <rte_ethdev.h>
-#include <rte_eventdev.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_event_eth_rx_adapter.h>
+#include <rte_event_eth_tx_adapter.h>
 #include <rte_event_timer_adapter.h>
+#include <rte_eventdev.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
@@ -181,6 +182,7 @@ void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
 void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
 void perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt);
 void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
+void perf_ethdev_rx_stop(struct evt_test *test, struct evt_options *opt);
 void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
 
 #endif /* _TEST_PERF_COMMON_ */
index dcf6d82..108f174 100644 (file)
@@ -360,6 +360,7 @@ static const struct evt_test_ops perf_queue =  {
        .mempool_setup      = perf_mempool_setup,
        .ethdev_setup       = perf_ethdev_setup,
        .cryptodev_setup    = perf_cryptodev_setup,
+       .ethdev_rx_stop     = perf_ethdev_rx_stop,
        .eventdev_setup     = perf_queue_eventdev_setup,
        .launch_lcores      = perf_queue_launch_lcores,
        .eventdev_destroy   = perf_eventdev_destroy,
index 84dd4f4..7921850 100644 (file)
@@ -772,6 +772,7 @@ static const struct evt_test_ops pipeline_atq =  {
        .ethdev_setup       = pipeline_ethdev_setup,
        .eventdev_setup     = pipeline_atq_eventdev_setup,
        .launch_lcores      = pipeline_atq_launch_lcores,
+       .ethdev_rx_stop     = pipeline_ethdev_rx_stop,
        .eventdev_destroy   = pipeline_eventdev_destroy,
        .mempool_destroy    = pipeline_mempool_destroy,
        .ethdev_destroy     = pipeline_ethdev_destroy,
index ddaa9f3..29b6401 100644 (file)
@@ -505,6 +505,22 @@ pipeline_event_tx_adapter_setup(struct evt_options *opt,
        return ret;
 }
 
+void
+pipeline_ethdev_rx_stop(struct evt_test *test, struct evt_options *opt)
+{
+       uint16_t i, j;
+       RTE_SET_USED(test);
+
+       if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
+               RTE_ETH_FOREACH_DEV(i) {
+                       rte_event_eth_rx_adapter_stop(i);
+                       rte_event_eth_rx_adapter_queue_del(i, i, -1);
+                       for (j = 0; j < opt->eth_queues; j++)
+                               rte_eth_dev_rx_queue_stop(i, j);
+               }
+       }
+}
+
 void
 pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
 {
@@ -513,8 +529,9 @@ pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
        RTE_SET_USED(opt);
 
        RTE_ETH_FOREACH_DEV(i) {
-               rte_event_eth_rx_adapter_stop(i);
                rte_event_eth_tx_adapter_stop(i);
+               rte_event_eth_tx_adapter_queue_del(i, i, -1);
+               rte_eth_dev_tx_queue_stop(i, 0);
                rte_eth_dev_stop(i);
        }
 }
index d69e2f8..c979c33 100644 (file)
 
 #include <rte_cycles.h>
 #include <rte_ethdev.h>
-#include <rte_eventdev.h>
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_event_eth_tx_adapter.h>
+#include <rte_eventdev.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_prefetch.h>
-#include <rte_spinlock.h>
 #include <rte_service.h>
 #include <rte_service_component.h>
+#include <rte_spinlock.h>
 
 #include "evt_common.h"
 #include "evt_options.h"
@@ -186,6 +186,7 @@ void pipeline_opt_dump(struct evt_options *opt, uint8_t nb_queues);
 void pipeline_test_destroy(struct evt_test *test, struct evt_options *opt);
 void pipeline_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
 void pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
+void pipeline_ethdev_rx_stop(struct evt_test *test, struct evt_options *opt);
 void pipeline_mempool_destroy(struct evt_test *test, struct evt_options *opt);
 
 #endif /* _TEST_PIPELINE_COMMON_ */
index f6cc3e3..343f8f3 100644 (file)
@@ -798,6 +798,7 @@ static const struct evt_test_ops pipeline_queue =  {
        .ethdev_setup       = pipeline_ethdev_setup,
        .eventdev_setup     = pipeline_queue_eventdev_setup,
        .launch_lcores      = pipeline_queue_launch_lcores,
+       .ethdev_rx_stop     = pipeline_ethdev_rx_stop,
        .eventdev_destroy   = pipeline_eventdev_destroy,
        .mempool_destroy    = pipeline_mempool_destroy,
        .ethdev_destroy     = pipeline_ethdev_destroy,