All of lore.kernel.org
 help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@redhat.com>
To: dev@dpdk.org
Subject: [PATCH 3/5] eal: move plugin loading to eal/common
Date: Fri, 16 Oct 2015 14:58:15 +0300	[thread overview]
Message-ID: <08bc213ebb41b3b3b714c7aa9e0a53b79e674dbf.1444996480.git.pmatilai@redhat.com> (raw)
In-Reply-To: <cover.1444996152.git.pmatilai@redhat.com>
In-Reply-To: <e18b068e2e25a82fb1d321a4bd4f32d41c6d83e6.1444996480.git.pmatilai@redhat.com>

There's no good reason to limit plugins to Linux, make it available
on FreeBSD too.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
---
 lib/librte_eal/bsdapp/eal/eal.c            |  2 ++
 lib/librte_eal/common/eal_common_options.c | 52 +++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_options.h        |  1 +
 lib/librte_eal/linuxapp/eal/eal.c          | 53 ------------------------------
 4 files changed, 55 insertions(+), 53 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 1b6f705..73dab89 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -543,6 +543,8 @@ rte_eal_init(int argc, char **argv)
 
 	rte_eal_mcfg_complete();
 
+	eal_plugins_init();
+
 	eal_thread_init_master(rte_config.master_lcore);
 
 	ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 1f459ac..f8fc68a 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -39,6 +39,7 @@
 #include <limits.h>
 #include <errno.h>
 #include <getopt.h>
+#include <dlfcn.h>
 
 #include <rte_eal.h>
 #include <rte_log.h>
@@ -93,6 +94,20 @@ eal_long_options[] = {
 	{0,                     0, NULL, 0                        }
 };
 
+TAILQ_HEAD(shared_driver_list, shared_driver);
+
+/* Definition for shared object drivers. */
+struct shared_driver {
+	TAILQ_ENTRY(shared_driver) next;
+
+	char    name[PATH_MAX];
+	void*   lib_handle;
+};
+
+/* List of external loadable drivers */
+static struct shared_driver_list solib_list =
+TAILQ_HEAD_INITIALIZER(solib_list);
+
 static int lcores_parsed;
 static int master_lcore_parsed;
 static int mem_parsed;
@@ -134,6 +149,37 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
 	internal_cfg->create_uio_dev = 0;
 }
 
+static int
+eal_plugin_add(const char *path)
+{
+	struct shared_driver *solib;
+
+	solib = malloc(sizeof(*solib));
+	if (solib == NULL) {
+		RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
+		return -1;
+	}
+	memset(solib, 0, sizeof(*solib));
+	strncpy(solib->name, path, PATH_MAX-1);
+	solib->name[PATH_MAX-1] = 0;
+	TAILQ_INSERT_TAIL(&solib_list, solib, next);
+
+	return 0;
+}
+
+void
+eal_plugins_init(void)
+{
+	struct shared_driver *solib = NULL;
+
+	TAILQ_FOREACH(solib, &solib_list, next) {
+		RTE_LOG(DEBUG, EAL, "open shared lib %s\n", solib->name);
+		solib->lib_handle = dlopen(solib->name, RTLD_NOW);
+		if (solib->lib_handle == NULL)
+			RTE_LOG(WARNING, EAL, "%s\n", dlerror());
+	}
+}
+
 /*
  * Parse the coremask given as argument (hexadecimal string) and fill
  * the global configuration (core role and core count) with the parsed
@@ -716,6 +762,11 @@ eal_parse_common_option(int opt, const char *optarg,
 		 * even if info or warning messages are disabled */
 		RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
 		break;
+	/* force loading of external driver */
+	case 'd':
+		if (eal_plugin_add(optarg) == -1)
+			return -1;
+		break;
 
 	/* long options */
 	case OPT_NO_HUGE_NUM:
@@ -902,6 +953,7 @@ eal_common_usage(void)
 	       "  --"OPT_PROC_TYPE"         Type of this process (primary|secondary|auto)\n"
 	       "  --"OPT_SYSLOG"            Set syslog facility\n"
 	       "  --"OPT_LOG_LEVEL"         Set default log level\n"
+	       "  -d LIB.so           Add driver (can be used multiple times)\n"
 	       "  -v                  Display version information on startup\n"
 	       "  -h, --help          This help\n"
 	       "\nEAL options for DEBUG use only:\n"
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index f6714d9..1f96825 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -93,5 +93,6 @@ int eal_adjust_config(struct internal_config *internal_cfg);
 int eal_check_common_options(struct internal_config *internal_cfg);
 void eal_common_usage(void);
 enum rte_proc_type_t eal_proc_type_detect(void);
+void eal_plugins_init(void);
 
 #endif /* EAL_OPTIONS_H */
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index d8a53e4..455243e 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -43,7 +43,6 @@
 #include <getopt.h>
 #include <sys/file.h>
 #include <fcntl.h>
-#include <dlfcn.h>
 #include <stddef.h>
 #include <errno.h>
 #include <limits.h>
@@ -90,20 +89,6 @@
 /* Allow the application to print its usage message too if set */
 static rte_usage_hook_t	rte_application_usage_hook = NULL;
 
-TAILQ_HEAD(shared_driver_list, shared_driver);
-
-/* Definition for shared object drivers. */
-struct shared_driver {
-	TAILQ_ENTRY(shared_driver) next;
-
-	char    name[PATH_MAX];
-	void*   lib_handle;
-};
-
-/* List of external loadable drivers */
-static struct shared_driver_list solib_list =
-TAILQ_HEAD_INITIALIZER(solib_list);
-
 /* early configuration structure, when memory config is not mmapped */
 static struct rte_mem_config early_mem_config;
 
@@ -350,7 +335,6 @@ eal_usage(const char *prgname)
 	printf("\nUsage: %s ", prgname);
 	eal_common_usage();
 	printf("EAL Linux options:\n"
-	       "  -d LIB.so           Add driver (can be used multiple times)\n"
 	       "  --"OPT_SOCKET_MEM"        Memory to allocate on sockets (comma separated values)\n"
 	       "  --"OPT_HUGE_DIR"          Directory where hugetlbfs is mounted\n"
 	       "  --"OPT_FILE_PREFIX"       Prefix for hugepage filenames\n"
@@ -530,37 +514,6 @@ eal_log_level_parse(int argc, char **argv)
 	optind = 0; /* reset getopt lib */
 }
 
-static int
-eal_plugin_add(const char *path)
-{
-	struct shared_driver *solib;
-
-	solib = malloc(sizeof(*solib));
-	if (solib == NULL) {
-		RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
-		return -1;
-	}
-	memset(solib, 0, sizeof(*solib));
-	strncpy(solib->name, path, PATH_MAX-1);
-	solib->name[PATH_MAX-1] = 0;
-	TAILQ_INSERT_TAIL(&solib_list, solib, next);
-
-	return 0;
-}
-
-static void
-eal_plugins_init(void)
-{
-	struct shared_driver *solib = NULL;
-
-	TAILQ_FOREACH(solib, &solib_list, next) {
-		RTE_LOG(DEBUG, EAL, "open shared lib %s\n", solib->name);
-		solib->lib_handle = dlopen(solib->name, RTLD_NOW);
-		if (solib->lib_handle == NULL)
-			RTE_LOG(WARNING, EAL, "%s\n", dlerror());
-	}
-}
-
 /* Parse the argument given in the command line of the application */
 static int
 eal_parse_args(int argc, char **argv)
@@ -598,12 +551,6 @@ eal_parse_args(int argc, char **argv)
 			eal_usage(prgname);
 			exit(EXIT_SUCCESS);
 
-		/* force loading of external driver */
-		case 'd':
-			if (eal_plugin_add(optarg) == -1)
-				return -1;
-			break;
-
 		/* long options */
 		case OPT_XEN_DOM0_NUM:
 #ifdef RTE_LIBRTE_XEN_DOM0
-- 
2.4.3

  parent reply	other threads:[~2015-10-16 11:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 11:58 [PATCH 0/2] Add support for driver directories Panu Matilainen
2015-09-25 11:58 ` [PATCH 1/2] eal: refactor plugin list append from eal_parse_args() to a helper function Panu Matilainen
2015-09-25 11:58 ` [PATCH 2/2] eal: add support for driver directory concept Panu Matilainen
2015-09-25 12:35 ` [PATCH 0/2] Add support for driver directories David Marchand
2015-09-25 13:00   ` Panu Matilainen
2015-10-14 10:41     ` Panu Matilainen
2015-10-14 11:55       ` David Marchand
2015-10-16 11:58 ` [PATCH 0/5 v2] " Panu Matilainen
2015-10-16 11:58   ` [PATCH 1/5] eal: refactor plugin list append from eal_parse_args() to a helper function Panu Matilainen
2015-10-16 11:58     ` [PATCH 2/5] eal: refactor plugin init " Panu Matilainen
2015-10-16 11:58     ` Panu Matilainen [this message]
2015-10-16 11:58     ` [PATCH 4/5] eal: add an error code to plugin init for the next step Panu Matilainen
2015-10-16 12:59       ` Bruce Richardson
2015-10-16 13:14         ` Panu Matilainen
2015-10-16 13:38           ` Panu Matilainen
2015-10-21  8:14             ` Thomas Monjalon
2015-10-16 11:58     ` [PATCH 5/5] eal: add support for driver directory concept Panu Matilainen
2015-10-16 12:57     ` [PATCH 1/5] eal: refactor plugin list append from eal_parse_args() to a helper function Bruce Richardson
2015-10-16 13:07       ` Panu Matilainen
2015-10-21  8:29   ` [PATCH 0/2 v3] Add support for driver directories Panu Matilainen
2015-10-21  8:29   ` [PATCH 1/2] eal: move plugin loading to eal/common Panu Matilainen
2015-10-21 10:15     ` David Marchand
2015-10-21 10:54       ` Panu Matilainen
2015-10-21 11:09         ` David Marchand
2015-10-21 11:15           ` Bruce Richardson
2015-10-21 11:53             ` Thomas Monjalon
2015-10-21 12:07               ` Panu Matilainen
2015-10-21  8:29   ` [PATCH 2/2] eal: add support for driver directory concept Panu Matilainen
2015-10-21  8:44     ` Thomas Monjalon
2015-10-21  9:43       ` Panu Matilainen
2015-11-10 14:28   ` [PATCH v4 0/2] Add support for driver directories Panu Matilainen
2015-11-10 15:04     ` David Marchand
2015-11-12 15:52       ` Thomas Monjalon
2015-12-03  2:07         ` Stephen Hemminger
2015-12-03  2:26           ` Thomas Monjalon
2015-12-03  7:59             ` Panu Matilainen
2015-11-10 14:28   ` [PATCH v4 1/2] eal: move plugin loading to eal/common Panu Matilainen
2015-11-10 14:28   ` [PATCH v4 2/2] eal: add support for driver directory concept Panu Matilainen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08bc213ebb41b3b3b714c7aa9e0a53b79e674dbf.1444996480.git.pmatilai@redhat.com \
    --to=pmatilai@redhat.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.