* [dpdk-dev] [PATCH] eal: add support for shared object drivers
@ 2013-06-12 7:51 Thomas Monjalon
2013-06-12 11:55 ` Olivier MATZ
[not found] ` <51B87027.40703@cs.hut.fi>
0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2013-06-12 7:51 UTC (permalink / raw)
To: dev
From: Damien Millescamps <damien.millescamps@6wind.com>
Add an option to specify libraries to be loaded before probing the PCI.
For instance, testpmd -d librte_pmd_xxx.so can be used to enable xxx driver
support on testpmd without any recompilation of testpmd.
Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com>
Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
lib/librte_eal/linuxapp/eal/eal.c | 45 ++++++++++++++++++++++++++++++++++++-
mk/exec-env/linuxapp/rte.vars.mk | 7 ++++--
2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index a63881c..14b1451 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -2,6 +2,7 @@
* BSD LICENSE
*
* Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ * Copyright(c) 2012-2013 6WIND.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,6 +43,7 @@
#include <pthread.h>
#include <getopt.h>
#include <fcntl.h>
+#include <dlfcn.h>
#include <stddef.h>
#include <errno.h>
#include <limits.h>
@@ -99,6 +101,20 @@
(in) = end + 1; \
}
+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;
@@ -265,6 +281,7 @@ eal_usage(const char *prgname)
" (multiple -b options are alowed)\n"
" -m MB : memory to allocate (default = size of hugemem)\n"
" -r NUM : force number of memory ranks (don't detect)\n"
+ " -d LIB.so : add driver (can be used multiple times)\n"
" --"OPT_HUGE_DIR" : directory where hugetlbfs is mounted\n"
" --"OPT_PROC_TYPE": type of this process\n"
" --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
@@ -391,6 +408,7 @@ eal_parse_args(int argc, char **argv)
{OPT_FILE_PREFIX, 1, 0, 0},
{0, 0, 0, 0}
};
+ struct shared_driver *solib;
argvopt = argv;
@@ -407,7 +425,7 @@ eal_parse_args(int argc, char **argv)
internal_config.vmware_tsc_map = 0;
- while ((opt = getopt_long(argc, argvopt, "b:c:m:n:r:v",
+ while ((opt = getopt_long(argc, argvopt, "b:c:d:m:n:r:v",
lgopts, &option_index)) != EOF) {
switch (opt) {
@@ -428,6 +446,18 @@ eal_parse_args(int argc, char **argv)
}
coremask_ok = 1;
break;
+ /* force loading of external driver */
+ case 'd':
+ 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, optarg, PATH_MAX-1);
+ solib->name[PATH_MAX-1] = 0;
+ TAILQ_INSERT_TAIL(&solib_list, solib, next);
+ break;
/* size of memory */
case 'm':
internal_config.memory = atoi(optarg);
@@ -538,6 +568,7 @@ rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
pthread_t thread_id;
+ struct shared_driver *solib = NULL;
thread_id = pthread_self();
@@ -625,6 +656,18 @@ rte_eal_init(int argc, char **argv)
eal_thread_init_master(rte_config.master_lcore);
+ TAILQ_FOREACH(solib, &solib_list, next) {
+ solib->lib_handle = dlopen(solib->name, RTLD_NOW);
+ if ((solib->lib_handle == NULL) && (solib->name[0] != '/')) {
+ /* relative path: try again with "./" prefix */
+ char sopath[PATH_MAX];
+ snprintf(sopath, sizeof(sopath), "./%s", solib->name);
+ solib->lib_handle = dlopen(sopath, RTLD_NOW);
+ }
+ if (solib->lib_handle == NULL)
+ RTE_LOG(WARNING, EAL, "%s\n", dlerror());
+ }
+
return fctret;
}
diff --git a/mk/exec-env/linuxapp/rte.vars.mk b/mk/exec-env/linuxapp/rte.vars.mk
index e0ed298..83e1a7d 100644
--- a/mk/exec-env/linuxapp/rte.vars.mk
+++ b/mk/exec-env/linuxapp/rte.vars.mk
@@ -43,10 +43,13 @@
#
EXECENV_CFLAGS = -pthread
-EXECENV_LDFLAGS =
+EXECENV_LDFLAGS = -export-dynamic
EXECENV_ASFLAGS =
# force applications to link with gcc/icc instead of using ld
LINK_USING_CC := 1
-export EXECENV_CFLAGS EXECENV_LDFLAGS EXECENV_ASFLAGS
+# Add library to the group to resolve symbols
+EXECENV_LDLIBS = -ldl
+
+export EXECENV_CFLAGS EXECENV_LDFLAGS EXECENV_ASFLAGS EXECENV_LDLIBS
--
1.7.10.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: add support for shared object drivers
2013-06-12 7:51 [dpdk-dev] [PATCH] eal: add support for shared object drivers Thomas Monjalon
@ 2013-06-12 11:55 ` Olivier MATZ
2013-06-12 15:12 ` Thomas Monjalon
[not found] ` <51B87027.40703@cs.hut.fi>
1 sibling, 1 reply; 6+ messages in thread
From: Olivier MATZ @ 2013-06-12 11:55 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
Hello,
On 06/12/2013 09:51 AM, Thomas Monjalon wrote:
> From: Damien Millescamps<damien.millescamps@6wind.com>
>
> Add an option to specify libraries to be loaded before probing the PCI.
Looks good to me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: add support for shared object drivers
[not found] ` <51B87027.40703@cs.hut.fi>
@ 2013-06-12 12:58 ` Antti Kantee
2013-06-12 14:54 ` Olivier MATZ
0 siblings, 1 reply; 6+ messages in thread
From: Antti Kantee @ 2013-06-12 12:58 UTC (permalink / raw)
To: dev
On 12.06.2013 09:51, Thomas Monjalon wrote:
> From: Damien Millescamps <damien.millescamps@6wind.com>
>
> Add an option to specify libraries to be loaded before probing the PCI.
>
> For instance, testpmd -d librte_pmd_xxx.so can be used to enable xxx
driver
> support on testpmd without any recompilation of testpmd.
What's the use case? Unless I'm missing something, testpmd still needs
an explicit rte_pmd_foo_init() call. It's of course not difficult to
sprinkle some __attribute__((constructor))'s into the pmd's, but without
doing that (or something equivalent), what's the purpose of the change?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: add support for shared object drivers
2013-06-12 12:58 ` Antti Kantee
@ 2013-06-12 14:54 ` Olivier MATZ
2013-06-12 15:12 ` Antti Kantee
0 siblings, 1 reply; 6+ messages in thread
From: Olivier MATZ @ 2013-06-12 14:54 UTC (permalink / raw)
To: Antti Kantee; +Cc: dev
Hi Antti,
> > For instance, testpmd -d librte_pmd_xxx.so can be used to enable xxx
> driver
> > support on testpmd without any recompilation of testpmd.
>
> What's the use case?
Load any other pmd driver dynamically (ex: mellanox driver)
> Unless I'm missing something, testpmd still needs
> an explicit rte_pmd_foo_init() call. It's of course not difficult to
> sprinkle some __attribute__((constructor))'s into the pmd's
Yes, you need to do it in the pmd's constructor.
Olivier
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: add support for shared object drivers
2013-06-12 11:55 ` Olivier MATZ
@ 2013-06-12 15:12 ` Thomas Monjalon
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2013-06-12 15:12 UTC (permalink / raw)
To: dev
12/06/2013 13:55, Olivier MATZ :
> On 06/12/2013 09:51 AM, Thomas Monjalon wrote:
> > From: Damien Millescamps<damien.millescamps@6wind.com>
> >
> > Add an option to specify libraries to be loaded before probing the PCI.
>
> Looks good to me.
pushed
--
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: add support for shared object drivers
2013-06-12 14:54 ` Olivier MATZ
@ 2013-06-12 15:12 ` Antti Kantee
0 siblings, 0 replies; 6+ messages in thread
From: Antti Kantee @ 2013-06-12 15:12 UTC (permalink / raw)
To: dev
On 12.06.2013 16:54, Olivier MATZ wrote:
>> Unless I'm missing something, testpmd still needs
>> an explicit rte_pmd_foo_init() call. It's of course not difficult to
>> sprinkle some __attribute__((constructor))'s into the pmd's
>
> Yes, you need to do it in the pmd's constructor.
Ok, I thought it had to be called after eal_init(). Still, unifying the
init conventions would be nice.
One other question popped to mind, not strictly related to the patch:
does anyone have approximate numbers on the performance penalty of using
PIC for pmd's?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-06-12 15:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-12 7:51 [dpdk-dev] [PATCH] eal: add support for shared object drivers Thomas Monjalon
2013-06-12 11:55 ` Olivier MATZ
2013-06-12 15:12 ` Thomas Monjalon
[not found] ` <51B87027.40703@cs.hut.fi>
2013-06-12 12:58 ` Antti Kantee
2013-06-12 14:54 ` Olivier MATZ
2013-06-12 15:12 ` Antti Kantee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).