]> git.droids-corp.org - dpdk.git/commitdiff
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 a7d6b0c1cf75ab3c80f6beb77d3ff651e671959a..c5d63061bf3f51ab1366a9b34dd258c194606754 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 50fa474ec211809a85defa79576616945c94029b..1049f99ddca693ffa110d225790a50cd6d6a4111 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 67ff681666943d420b87d36cbde7091a84454626..bac3ea602fbe39c16f300aaf3083efb0bf9e2593 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 9d1f4a4567ae60e1eb6cb806c4d3defd091dd6a8..4cf16b4267786632535b2156111ab28deaee8184 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 ea0907d61a9bd12fbdefdb2ab251b236f363ffbe..e504bb1df9bac795d9a9d6b8183c89fd910ed6b9 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 dcf6d82947b86a6d56b5f0b892648808fa4fa901..108f1742a7239f5372d0f12fb0c244f2eb4d4669 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 84dd4f44e3a686091cea2fde24e86036c4f8c5a7..79218502ba32902b81a6e4218cb410f6be7264ce 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 ddaa9f3fdb5a6f003b41a6007af91cf7f1118f35..29b64014d772dfd99f1939a43ebaa2736baa8aed 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 d69e2f8a3ec50a8305811d99c93c34e4466832f3..c979c33772fa8e5d9866aca5fc1da186d6b65e0b 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 f6cc3e358e863498ab5ff3291c3f2cca8e7a2a00..343f8f3b1d52e1c33131ca6db1a12cd477b01e4a 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,