service: initialize with EAL
authorHarry van Haaren <harry.van.haaren@intel.com>
Tue, 11 Jul 2017 14:19:28 +0000 (15:19 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 16 Jul 2017 18:32:45 +0000 (20:32 +0200)
This commit shows the changes required in rte_eal_init()
to transparently launch the service threads. The threads
are launched into the service worker functions here because
after rte_eal_init() the application is not gauranteed to
call any other DPDK API.

As the registration of services happens at initialization
time, the services that require CPU time are already available
when we reach the end of rte_eal_init().

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
lib/librte_eal/bsdapp/eal/eal.c
lib/librte_eal/linuxapp/eal/eal.c

index 83801d5..80fe21d 100644 (file)
@@ -58,6 +58,7 @@
 #include <rte_errno.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
+#include <rte_service_component.h>
 #include <rte_log.h>
 #include <rte_random.h>
 #include <rte_cycles.h>
@@ -651,6 +652,14 @@ rte_eal_init(int argc, char **argv)
        rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
        rte_eal_mp_wait_lcore();
 
+       /* initialize services so vdevs register service during bus_probe. */
+       ret = rte_service_init();
+       if (ret) {
+               rte_eal_init_alert("rte_service_init() failed\n");
+               rte_errno = ENOEXEC;
+               return -1;
+       }
+
        /* Probe all the buses and devices/drivers on them */
        if (rte_bus_probe()) {
                rte_eal_init_alert("Cannot probe devices\n");
@@ -658,6 +667,15 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
+       /* initialize default service/lcore mappings and start running. Ignore
+        * -ENOTSUP, as it indicates no service coremask passed to EAL.
+        */
+       ret = rte_service_start_with_defaults();
+       if (ret < 0 && ret != -ENOTSUP) {
+               rte_errno = ENOEXEC;
+               return -1;
+       }
+
        rte_eal_mcfg_complete();
 
        return fctret;
index d03d8e3..b28bbab 100644 (file)
@@ -63,6 +63,7 @@
 #include <rte_errno.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
+#include <rte_service_component.h>
 #include <rte_log.h>
 #include <rte_random.h>
 #include <rte_cycles.h>
@@ -930,6 +931,14 @@ rte_eal_init(int argc, char **argv)
        rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
        rte_eal_mp_wait_lcore();
 
+       /* initialize services so vdevs register service during bus_probe. */
+       ret = rte_service_init();
+       if (ret) {
+               rte_eal_init_alert("rte_service_init() failed\n");
+               rte_errno = ENOEXEC;
+               return -1;
+       }
+
        /* Probe all the buses and devices/drivers on them */
        if (rte_bus_probe()) {
                rte_eal_init_alert("Cannot probe devices\n");
@@ -937,6 +946,15 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
+       /* initialize default service/lcore mappings and start running. Ignore
+        * -ENOTSUP, as it indicates no service coremask passed to EAL.
+        */
+       ret = rte_service_start_with_defaults();
+       if (ret < 0 && ret != -ENOTSUP) {
+               rte_errno = ENOEXEC;
+               return -1;
+       }
+
        rte_eal_mcfg_complete();
 
        return fctret;