All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/19] Separate compile time linkage between eal lib and pmd's
@ 2014-04-10 20:47 Neil Horman
       [not found] ` <1397162846-28912-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:47 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Disconnect compile time linkage between eal library / applications and pmd's

I noticed that, while tinkering with dpdk, building for shared libraries still
resulted in all the test applications linking to all the built pmd's, despite
not actually needing them all.  We are able to tell an application at run time
(via the -d/--blacklist/--whitelist/--vdev options) which pmd's we want to use, and
so have no need to link them at all. The only reason they get pulled in is
because rte_eal_non_pci_init_etherdev and rte_pmd_init_all contain static lists
to the individual pmd init functions. The result is that, even when building as
DSO's, we have to load all the pmd libraries, which is space inefficient and
defeating of some of the purpose of shared objects. 

To correct this, I developed this patch series, which introduces two new macros,
PMD_INIT_NONPCI and PMD_INIT.  These two macros use constructors to register
their init routines at runtime, either prior to the execution of main() when
linked statically, or when dlopen is called on a DSO at run time.  The result is
that PMD's can be loaded at run time without the application or eal library
having to hold a reference to them.  They work in a very simmilar fashion to the
module_init routine in the linux kernel.

I've tested this feature using the igb and pcap pmd's, both statically and
dynamically linked with the test and testpmd sample applications, and it seems
to work well.

Note, I encountered  a few bugs along the way, which I fixed and noted in the
series.

Regards
Neil

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/19] makefiles: Fixed -share command line option error
       [not found] ` <1397162846-28912-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
@ 2014-04-10 20:49   ` Neil Horman
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
  2014-04-12 11:04   ` [PATCH 0/19] Separate compile time linkage between eal lib and pmd's Neil Horman
  1 sibling, 1 reply; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

The shared libraries built with the current makefile set produce static
libraries rather than actual shared objects.  This is due to several missing
options that are required to correctly build shared objects using ld, as well as
a mis-specified -share option (which should be -shared). Switching to the use of
CC rather than LD and fixing the -shared option corrects these problems and
builds the DSOs correctly.

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 mk/rte.lib.mk      | 4 ++--
 mk/rte.sharelib.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
index f75ca92..8a914db 100644
--- a/mk/rte.lib.mk
+++ b/mk/rte.lib.mk
@@ -68,7 +68,7 @@ O_TO_A_DO = @set -e; \
 	$(O_TO_A) && \
 	echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) -z muldefs -share $(OBJS-y) -o $(LIB)
+O_TO_S = $(CC) $(CPU_LDFLAGS) -z muldefs -shared $(OBJS-y) -o $(LIB)
 O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
 O_TO_S_DO = @set -e; \
@@ -84,7 +84,7 @@ O_TO_C_DO = @set -e; \
 	$(lib_dir) \
 	$(copy_obj)
 else
-O_TO_C = $(LD) -z muldefs -share $(OBJS-y) -o $(LIB_ONE)
+O_TO_C = $(CC) -z muldefs -shared $(OBJS-y) -o $(LIB_ONE)
 O_TO_C_STR = $(subst ','\'',$(O_TO_C)) #'# fix syntax highlight
 O_TO_C_DISP = $(if $(V),"$(O_TO_C_STR)","  LD_C $(@)")
 O_TO_C_DO = @set -e; \
diff --git a/mk/rte.sharelib.mk b/mk/rte.sharelib.mk
index 3967b51..8e821e0 100644
--- a/mk/rte.sharelib.mk
+++ b/mk/rte.sharelib.mk
@@ -45,7 +45,7 @@ sharelib: $(LIB_ONE) FORCE
 
 OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
 
-O_TO_S = $(LD) $(CPU_LDFLAGS) -share $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
+O_TO_S = $(CC) $(CPU_LDFLAGS) -shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
 O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
 O_TO_S_CMD = "cmd_$@ = $(O_TO_S_STR)"
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/19] pmd: Add PMD_INIT_NONPCI macros
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 03/19] eal: dlopen the DSO built poll mode drivers before init Neil Horman
                         ` (16 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

This macro will allow nonpci based pmd driver to register an init function with
the core eal library so that they don't need to be referenced at link time.  The
macro expands to a constructor that calls an eal library registration function,
passing a pointer to the pmd's init routine.

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_eal/common/Makefile                 |  2 +-
 lib/librte_eal/common/eal_common_nonpci_devs.c | 60 +++++++++++++++++++++++++-
 lib/librte_eal/common/include/rte_pmd.h        | 59 +++++++++++++++++++++++++
 3 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_eal/common/include/rte_pmd.h

diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index b9f3b88..e52b665 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -38,7 +38,7 @@ INC += rte_pci_dev_ids.h rte_per_lcore.h rte_prefetch.h rte_random.h
 INC += rte_rwlock.h rte_spinlock.h rte_tailq.h rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_cpuflags.h rte_version.h rte_tailq_elem.h
 INC += rte_eal_memconfig.h rte_malloc_heap.h
-INC += rte_hexdump.h rte_devargs.h
+INC += rte_hexdump.h rte_devargs.h rte_pmd.h
 
 ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)
 INC += rte_warnings.h
diff --git a/lib/librte_eal/common/eal_common_nonpci_devs.c b/lib/librte_eal/common/eal_common_nonpci_devs.c
index 71cbb1e..0f94b65 100644
--- a/lib/librte_eal/common/eal_common_nonpci_devs.c
+++ b/lib/librte_eal/common/eal_common_nonpci_devs.c
@@ -34,6 +34,8 @@
 
 #include <string.h>
 #include <inttypes.h>
+#include <string.h>
+#include <sys/queue.h>
 #include <rte_string_fns.h>
 #ifdef RTE_LIBRTE_PMD_RING
 #include <rte_eth_ring.h>
@@ -46,6 +48,8 @@
 #endif
 #include <rte_debug.h>
 #include <rte_devargs.h>
+#include <rte_pmd.h>
+#include <rte_log.h>
 #include "eal_private.h"
 
 struct device_init {
@@ -79,17 +83,54 @@ struct device_init dev_types[] = {
 		}
 };
 
+TAILQ_HEAD(pmd_nonpci_list, pmd_nonpci_entry);
+
+/* Definition for shared object drivers. */
+struct pmd_nonpci_entry {
+        TAILQ_ENTRY(pmd_noncpi_entry) next;
+
+        char    name[PATH_MAX];
+	int (*pmd_initfn)(const char *, const char *);
+};
+
+/* List of external loadable drivers */
+static struct pmd_nonpci_list pmd_nonpci_init_list =
+TAILQ_HEAD_INITIALIZER(pmd_nonpci_init_list);
+
+void rte_eal_nonpci_dev_init_register(const char *name, int (*dev_initfn)(const char *, const char *))
+{
+	struct pmd_nonpci_entry *new = malloc(sizeof(struct pmd_nonpci_entry));
+
+	if (!new) {
+		printf("Not enough memory to register %s\n", name);
+		goto out;
+	}
+
+	memset(new->name, 0, PATH_MAX);
+	strncpy(new->name, name, PATH_MAX);
+	new->name[PATH_MAX-1] = 0;
+	new->pmd_initfn = dev_initfn;
+	printf("REGISTERING INIT ROUTINE FOR %s\n", new->name);
+	TAILQ_INSERT_TAIL(&pmd_nonpci_init_list, new, next);
+out:
+	return;	
+}
+
+
 int
 rte_eal_non_pci_ethdev_init(void)
 {
 	struct rte_devargs *devargs;
+	struct pmd_nonpci_entry *entry;
 	uint8_t i;
+	int found = 0;
 
 	/* call the init function for each virtual device */
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
 
 		if (devargs->type != RTE_DEVTYPE_VIRTUAL)
 			continue;
+		found = 0;
 
 		for (i = 0; i < NUM_DEV_TYPES; i++) {
 			/* search a driver prefix in virtual device name */
@@ -98,14 +139,31 @@ rte_eal_non_pci_ethdev_init(void)
 				     sizeof(dev_types[i].dev_prefix) - 1)) {
 				dev_types[i].init_fn(devargs->virtual.drv_name,
 						     devargs->args);
+				found = 1;
 				break;
 			}
 		}
 
-		if (i == NUM_DEV_TYPES) {
+		if (found)
+			continue;
+
+		TAILQ_FOREACH(entry, &pmd_nonpci_init_list, next) {
+			if (!entry->name)
+				continue;
+			if (!strncmp(entry->name,
+				     devargs->virtual.drv_name,
+				     strlen(entry->name))) {
+				RTE_LOG(INFO, PMD, "Initalizing pmd %s\n", devargs->virtual.drv_name);
+				found = 1;
+				entry->pmd_initfn(devargs->virtual.drv_name, devargs->args);
+			}
+		}
+
+		if (!found) {
 			rte_panic("no driver found for %s\n",
 				  devargs->virtual.drv_name);
 		}
 	}
+
 	return 0;
 }
diff --git a/lib/librte_eal/common/include/rte_pmd.h b/lib/librte_eal/common/include/rte_pmd.h
new file mode 100644
index 0000000..75a4895
--- /dev/null
+++ b/lib/librte_eal/common/include/rte_pmd.h
@@ -0,0 +1,59 @@
+/*-
+ *   BSD LICENSE
+ * 
+ *   Copyright(c) 2010-2014 Neil Horman <nhorman-2XuSBdqkA4TL+VOYFs8Niw@public.gmane.org 
+ *   All rights reserved.
+ * 
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ * 
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ *
+ * API for error cause tracking
+ */
+
+#ifndef _RTE_PMD_H_
+#define _RTE_PMD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void rte_eal_nonpci_dev_init_register(const char *name, int (*dev_initfn)(const char *, const char *));
+#define PMD_INIT_NONPCI(x,n)\
+void devinitfn_ ##x(void);\
+void __attribute__((constructor, used)) devinitfn_ ##x(void)\
+{\
+	rte_eal_nonpci_dev_init_register(n,x);\
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PMD_H_ */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/19] eal: dlopen the DSO built poll mode drivers before init
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
  2014-04-10 20:49       ` [PATCH 02/19] pmd: Add PMD_INIT_NONPCI macros Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 04/19] pcap: Convert pcap poll mode driver to use new PMD_INIT_NONPCI macro Neil Horman
                         ` (15 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

We need to call dlopen on any DSO's referenced on the command line before
calling their init routines.  This provides the DSO's the opportunity to run the
constructors created by the PMD_INIT_NONPCI macro prior to the init list being
traversed.

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 905ce37..a4ad0eb 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -1046,9 +1046,6 @@ rte_eal_init(int argc, char **argv)
 
 	rte_eal_mcfg_complete();
 
-	if (rte_eal_non_pci_ethdev_init() < 0)
-		rte_panic("Cannot init non-PCI eth_devs\n");
-
 	TAILQ_FOREACH(solib, &solib_list, next) {
 		solib->lib_handle = dlopen(solib->name, RTLD_NOW);
 		if ((solib->lib_handle == NULL) && (solib->name[0] != '/')) {
@@ -1061,6 +1058,9 @@ rte_eal_init(int argc, char **argv)
 			RTE_LOG(WARNING, EAL, "%s\n", dlerror());
 	}
 
+	if (rte_eal_non_pci_ethdev_init() < 0)
+		rte_panic("Cannot init non-PCI eth_devs\n");
+
 	RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
 		rte_config.master_lcore, (int)thread_id);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/19] pcap: Convert pcap poll mode driver to use new PMD_INIT_NONPCI macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
  2014-04-10 20:49       ` [PATCH 02/19] pmd: Add PMD_INIT_NONPCI macros Neil Horman
  2014-04-10 20:49       ` [PATCH 03/19] eal: dlopen the DSO built poll mode drivers before init Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 05/19] ring: convert the ring pmd driver to use the " Neil Horman
                         ` (14 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Convert the pcap poll mode driver to link itself to libpcap and register a init
routine via the PMD_INIT_NONPCI macro

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_eal/common/eal_common_nonpci_devs.c | 9 ---------
 lib/librte_pmd_pcap/Makefile                   | 2 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c             | 2 ++
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_nonpci_devs.c b/lib/librte_eal/common/eal_common_nonpci_devs.c
index 0f94b65..d925b7f 100644
--- a/lib/librte_eal/common/eal_common_nonpci_devs.c
+++ b/lib/librte_eal/common/eal_common_nonpci_devs.c
@@ -40,9 +40,6 @@
 #ifdef RTE_LIBRTE_PMD_RING
 #include <rte_eth_ring.h>
 #endif
-#ifdef RTE_LIBRTE_PMD_PCAP
-#include <rte_eth_pcap.h>
-#endif
 #ifdef RTE_LIBRTE_PMD_XENVIRT
 #include <rte_eth_xenvirt.h>
 #endif
@@ -65,12 +62,6 @@ struct device_init dev_types[] = {
 			.init_fn = rte_pmd_ring_init
 		},
 #endif
-#ifdef RTE_LIBRTE_PMD_PCAP
-		{
-			.dev_prefix = RTE_ETH_PCAP_PARAM_NAME,
-			.init_fn = rte_pmd_pcap_init
-		},
-#endif
 #ifdef RTE_LIBRTE_PMD_XENVIRT
 		{
 			.dev_prefix = RTE_ETH_XENVIRT_PARAM_NAME,
diff --git a/lib/librte_pmd_pcap/Makefile b/lib/librte_pmd_pcap/Makefile
index 5218f28..f7653fb 100644
--- a/lib/librte_pmd_pcap/Makefile
+++ b/lib/librte_pmd_pcap/Makefile
@@ -37,6 +37,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pmd_pcap.a
 
+CPU_LDFLAGS += -lpcap
+
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c
index fe94a79..5bc81f7 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -40,6 +40,7 @@
 #include <rte_string_fns.h>
 #include <rte_cycles.h>
 #include <rte_kvargs.h>
+#include <rte_pmd.h>
 
 #include <net/if.h>
 
@@ -766,3 +767,4 @@ rte_pmd_pcap_init(const char *name, const char *params)
 
 }
 
+PMD_INIT_NONPCI(rte_pmd_pcap_init, RTE_ETH_PCAP_PARAM_NAME);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/19] ring: convert the ring pmd driver to use the PMD_INIT_NONPCI macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (2 preceding siblings ...)
  2014-04-10 20:49       ` [PATCH 04/19] pcap: Convert pcap poll mode driver to use new PMD_INIT_NONPCI macro Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 06/19] xenvert: Convert xenvirt pmd to use " Neil Horman
                         ` (13 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Separate the ring pmd from calls within the core eal library so that it will
not be loaded unless needed (or compiled in statically)

Note: The demo test application calls directly into the ring pmd driver, and
that needs to be cleaned up, so that the -d option is used on the command line
to test the proper pmd.  for now I've just added linkage to the pmd directly to
avoid build breaks and will fix up the application operation in a subsequent
patch

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 app/test/Makefile                              |  2 ++
 lib/librte_eal/common/eal_common_nonpci_devs.c | 10 +---------
 lib/librte_pmd_ring/rte_eth_ring.c             |  3 +++
 mk/rte.app.mk                                  |  4 ----
 4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/app/test/Makefile b/app/test/Makefile
index b49785e..978e331 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -36,6 +36,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 APP = test
 
+LDLIBS += -lrte_ring -lrte_pmd_ring
+
 #
 # all sources are stored in SRCS-y
 #
diff --git a/lib/librte_eal/common/eal_common_nonpci_devs.c b/lib/librte_eal/common/eal_common_nonpci_devs.c
index d925b7f..51497fd 100644
--- a/lib/librte_eal/common/eal_common_nonpci_devs.c
+++ b/lib/librte_eal/common/eal_common_nonpci_devs.c
@@ -34,12 +34,10 @@
 
 #include <string.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <string.h>
 #include <sys/queue.h>
 #include <rte_string_fns.h>
-#ifdef RTE_LIBRTE_PMD_RING
-#include <rte_eth_ring.h>
-#endif
 #ifdef RTE_LIBRTE_PMD_XENVIRT
 #include <rte_eth_xenvirt.h>
 #endif
@@ -56,12 +54,6 @@ struct device_init {
 
 #define NUM_DEV_TYPES (sizeof(dev_types)/sizeof(dev_types[0]))
 struct device_init dev_types[] = {
-#ifdef RTE_LIBRTE_PMD_RING
-		{
-			.dev_prefix = RTE_ETH_RING_PARAM_NAME,
-			.init_fn = rte_pmd_ring_init
-		},
-#endif
 #ifdef RTE_LIBRTE_PMD_XENVIRT
 		{
 			.dev_prefix = RTE_ETH_XENVIRT_PARAM_NAME,
diff --git a/lib/librte_pmd_ring/rte_eth_ring.c b/lib/librte_pmd_ring/rte_eth_ring.c
index 24635f3..9fec098 100644
--- a/lib/librte_pmd_ring/rte_eth_ring.c
+++ b/lib/librte_pmd_ring/rte_eth_ring.c
@@ -37,6 +37,7 @@
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
+#include <rte_pmd.h>
 
 struct ring_queue {
 	struct rte_ring *rng;
@@ -395,3 +396,5 @@ rte_pmd_ring_init(const char *name, const char *params)
 	}
 	return 0;
 }
+
+PMD_INIT_NONPCI(rte_pmd_ring_init, RTE_ETH_RING_PARAM_NAME);
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 072718a..cf8b942 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -133,10 +133,6 @@ ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
 LDLIBS += -lethdev
 endif
 
-ifeq ($(CONFIG_RTE_LIBRTE_PMD_RING),y)
-LDLIBS += -lrte_pmd_ring
-endif
-
 ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
 LDLIBS += -lrte_malloc
 endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/19] xenvert: Convert xenvirt pmd to use PMD_INIT_NONPCI macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (3 preceding siblings ...)
  2014-04-10 20:49       ` [PATCH 05/19] ring: convert the ring pmd driver to use the " Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 07/19] pmd: remove dead code Neil Horman
                         ` (12 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Convert the xenvirt driver to use the PMD_INIT_NONPCI macro so that we can break
the linkages between it and the core library to avoid unnneded loading when
built as a DSO

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_eal/common/eal_common_nonpci_devs.c | 9 ---------
 lib/librte_pmd_xenvirt/Makefile                | 2 ++
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c       | 3 +++
 mk/rte.app.mk                                  | 6 ------
 4 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_nonpci_devs.c b/lib/librte_eal/common/eal_common_nonpci_devs.c
index 51497fd..c65621e 100644
--- a/lib/librte_eal/common/eal_common_nonpci_devs.c
+++ b/lib/librte_eal/common/eal_common_nonpci_devs.c
@@ -38,9 +38,6 @@
 #include <string.h>
 #include <sys/queue.h>
 #include <rte_string_fns.h>
-#ifdef RTE_LIBRTE_PMD_XENVIRT
-#include <rte_eth_xenvirt.h>
-#endif
 #include <rte_debug.h>
 #include <rte_devargs.h>
 #include <rte_pmd.h>
@@ -54,12 +51,6 @@ struct device_init {
 
 #define NUM_DEV_TYPES (sizeof(dev_types)/sizeof(dev_types[0]))
 struct device_init dev_types[] = {
-#ifdef RTE_LIBRTE_PMD_XENVIRT
-		{
-			.dev_prefix = RTE_ETH_XENVIRT_PARAM_NAME,
-			.init_fn = rte_pmd_xenvirt_init
-		},
-#endif
 		{
 			.dev_prefix = "-nodev-",
 			.init_fn = NULL
diff --git a/lib/librte_pmd_xenvirt/Makefile b/lib/librte_pmd_xenvirt/Makefile
index bf6d432..d5fff3b 100644
--- a/lib/librte_pmd_xenvirt/Makefile
+++ b/lib/librte_pmd_xenvirt/Makefile
@@ -39,6 +39,8 @@ LIB = librte_pmd_xenvirt.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
+CPU_LDFLAGS += -lxenvirt
+
 #
 # all source are stored in SRCS-y
 #
diff --git a/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c b/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c
index bad8dd4..20d35dc 100644
--- a/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c
+++ b/lib/librte_pmd_xenvirt/rte_eth_xenvirt.c
@@ -53,6 +53,7 @@
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
+#include <rte_pmd.h>
 #include <cmdline_parse.h>
 #include <cmdline_parse_etheraddr.h>
 
@@ -704,3 +705,5 @@ rte_pmd_xenvirt_init(const char *name, const char *params)
 	eth_dev_xenvirt_create(name, params, rte_socket_id(), DEV_CREATE);
 	return 0;
 }
+
+PMD_INIT_NONPCI(rte_pmd_xenvirt_init, RTE_ETH_XENVIRT_PARAM_NAME);
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index cf8b942..d6fdf9e 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -158,12 +158,6 @@ ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
 LDLIBS += -lrte_eal
 endif
 
-
-ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
-LDLIBS += -lrte_pmd_xenvirt
-LDLIBS += -lxenstore
-endif
-
 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
 LDLIBS += -lrte_cmdline
 endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/19] pmd: remove dead code
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (4 preceding siblings ...)
  2014-04-10 20:49       ` [PATCH 06/19] xenvert: Convert xenvirt pmd to use " Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 08/19] test: fix test app to dynamically link pmd_pcap when needed Neil Horman
                         ` (11 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Now that we've converted the available PMD drivers to use the PMD_INIT_NONPCI
macro, we can remove the rest of the old init code

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_eal/common/eal_common_nonpci_devs.c | 34 +-------------------------
 1 file changed, 1 insertion(+), 33 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_nonpci_devs.c b/lib/librte_eal/common/eal_common_nonpci_devs.c
index c65621e..78bedf3 100644
--- a/lib/librte_eal/common/eal_common_nonpci_devs.c
+++ b/lib/librte_eal/common/eal_common_nonpci_devs.c
@@ -44,19 +44,6 @@
 #include <rte_log.h>
 #include "eal_private.h"
 
-struct device_init {
-	const char *dev_prefix;
-	int (*init_fn)(const char*, const char *);
-};
-
-#define NUM_DEV_TYPES (sizeof(dev_types)/sizeof(dev_types[0]))
-struct device_init dev_types[] = {
-		{
-			.dev_prefix = "-nodev-",
-			.init_fn = NULL
-		}
-};
-
 TAILQ_HEAD(pmd_nonpci_list, pmd_nonpci_entry);
 
 /* Definition for shared object drivers. */
@@ -96,31 +83,12 @@ rte_eal_non_pci_ethdev_init(void)
 {
 	struct rte_devargs *devargs;
 	struct pmd_nonpci_entry *entry;
-	uint8_t i;
-	int found = 0;
+	int found;
 
-	/* call the init function for each virtual device */
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-
 		if (devargs->type != RTE_DEVTYPE_VIRTUAL)
 			continue;
 		found = 0;
-
-		for (i = 0; i < NUM_DEV_TYPES; i++) {
-			/* search a driver prefix in virtual device name */
-			if (!strncmp(dev_types[i].dev_prefix,
-				    devargs->virtual.drv_name,
-				     sizeof(dev_types[i].dev_prefix) - 1)) {
-				dev_types[i].init_fn(devargs->virtual.drv_name,
-						     devargs->args);
-				found = 1;
-				break;
-			}
-		}
-
-		if (found)
-			continue;
-
 		TAILQ_FOREACH(entry, &pmd_nonpci_init_list, next) {
 			if (!entry->name)
 				continue;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/19] test: fix test app to dynamically link pmd_pcap when needed
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (5 preceding siblings ...)
  2014-04-10 20:49       ` [PATCH 07/19] pmd: remove dead code Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:49       ` [PATCH 09/19] testpmd: only link pcap pmd when statically linking Neil Horman
                         ` (10 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

the test application calls functions in the pmd_pcap driver directly.  We should fix this properly, but for now just link in the library

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 mk/rte.app.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index d6fdf9e..0499050 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -162,8 +162,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
 LDLIBS += -lrte_cmdline
 endif
 
+ifeq ($(RTE_BUILD_SHARED_LIB),n)
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
-LDLIBS += -lrte_pmd_pcap -lpcap
+LDLIBS += -lrte_pmd_pcap
+endif
 endif
 
 LDLIBS += $(EXECENV_LDLIBS)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/19] testpmd: only link pcap pmd when statically linking
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (6 preceding siblings ...)
  2014-04-10 20:49       ` [PATCH 08/19] test: fix test app to dynamically link pmd_pcap when needed Neil Horman
@ 2014-04-10 20:49       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 10/19] make: include whole archive on static link Neil Horman
                         ` (9 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:49 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

when doing a static link, we need to add -lpacp to testpmd because it will need
to resolve those symbols when it links in librte_pmd_pcap.a

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 mk/rte.app.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 0499050..2f2ff16 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -164,7 +164,7 @@ endif
 
 ifeq ($(RTE_BUILD_SHARED_LIB),n)
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
-LDLIBS += -lrte_pmd_pcap
+LDLIBS += -lrte_pmd_pcap -lpcap
 endif
 endif
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/19] make: include whole archive on static link
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (7 preceding siblings ...)
  2014-04-10 20:49       ` [PATCH 09/19] testpmd: only link pcap pmd when statically linking Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 11/19] pmd: Move rte_pmd_init_all to be non-inline Neil Horman
                         ` (8 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

This happens automatically on dyanmic linking, but when linking an archive we
need to to include the whole archive to make sure we call all the constructors.
Not doing this causes them to be discarded due to the fact theres no symbolic
reference connecting the pmds to the application.

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 mk/rte.app.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 2f2ff16..41eab08 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -198,6 +198,8 @@ endif
 ifeq ($(LINK_USING_CC),1)
 comma := ,
 LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
+LDLIBS := -Wl$(comma)--whole-archive $(LDLIBS)
+LDLIBS += -Wl,--no-whole-archive -Wl,-z -Wl,muldefs
 LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
 override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
 O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 11/19] pmd: Move rte_pmd_init_all to be non-inline
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (8 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 10/19] make: include whole archive on static link Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 12/19] pmd: Add PMD_INIT macro for use in pci based PMDs Neil Horman
                         ` (7 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw; +Cc: Neil Horman

Organizational change in support of doing dynamic init routine registration

Signed-off-by: Neil Horman <nhorman-iOcguaFf9ptWk0Htik3J/w@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c | 52 ++++++++++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 53 +------------------------------------------
 2 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a5727dd..dd378f0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -112,6 +112,58 @@ static uint8_t nb_ports = 0;
 /* spinlock for eth device callbacks */
 static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
+int rte_pmd_init_all(void)
+{
+        int ret = -ENODEV;
+
+#ifdef RTE_LIBRTE_IGB_PMD
+        if ((ret = rte_igb_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init igb PMD\n");
+                return (ret);
+        }
+        if ((ret = rte_igbvf_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init igbvf PMD\n");
+                return (ret);
+        }
+#endif /* RTE_LIBRTE_IGB_PMD */
+
+#ifdef RTE_LIBRTE_EM_PMD
+        if ((ret = rte_em_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init em PMD\n");
+                return (ret);
+        }
+#endif /* RTE_LIBRTE_EM_PMD */
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+        if ((ret = rte_ixgbe_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init ixgbe PMD\n");
+                return (ret);
+        }
+        if ((ret = rte_ixgbevf_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init ixgbevf PMD\n");
+                return (ret);
+        }
+#endif /* RTE_LIBRTE_IXGBE_PMD */
+
+#ifdef RTE_LIBRTE_VIRTIO_PMD
+        if ((ret = rte_virtio_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init virtio PMD\n");
+                return (ret);
+        }
+#endif /* RTE_LIBRTE_VIRTIO_PMD */
+
+#ifdef RTE_LIBRTE_VMXNET3_PMD
+        if ((ret = rte_vmxnet3_pmd_init()) != 0) {
+                RTE_LOG(ERR, PMD, "Cannot init vmxnet3 PMD\n");
+                return (ret);
+        }
+#endif /* RTE_LIBRTE_VMXNET3_PMD */
+
+        if (ret == -ENODEV)
+                RTE_LOG(ERR, PMD, "No PMD(s) are configured\n");
+        return (ret);
+}
+
 /**
  * The user application callback description.
  *
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index dea7471..bf2ded4 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1396,58 +1396,7 @@ extern int rte_vmxnet3_pmd_init(void);
  *   -ENODEV if there are no drivers available
  *   (e.g. if all driver config options are = n).
  */
-static inline
-int rte_pmd_init_all(void)
-{
-	int ret = -ENODEV;
-
-#ifdef RTE_LIBRTE_IGB_PMD
-	if ((ret = rte_igb_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init igb PMD\n");
-		return (ret);
-	}
-	if ((ret = rte_igbvf_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init igbvf PMD\n");
-		return (ret);
-	}
-#endif /* RTE_LIBRTE_IGB_PMD */
-
-#ifdef RTE_LIBRTE_EM_PMD
-	if ((ret = rte_em_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init em PMD\n");
-		return (ret);
-	}
-#endif /* RTE_LIBRTE_EM_PMD */
-
-#ifdef RTE_LIBRTE_IXGBE_PMD
-	if ((ret = rte_ixgbe_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init ixgbe PMD\n");
-		return (ret);
-	}
-	if ((ret = rte_ixgbevf_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init ixgbevf PMD\n");
-		return (ret);
-	}
-#endif /* RTE_LIBRTE_IXGBE_PMD */
-
-#ifdef RTE_LIBRTE_VIRTIO_PMD
-	if ((ret = rte_virtio_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init virtio PMD\n");
-		return (ret);
-	}
-#endif /* RTE_LIBRTE_VIRTIO_PMD */
-
-#ifdef RTE_LIBRTE_VMXNET3_PMD
-	if ((ret = rte_vmxnet3_pmd_init()) != 0) {
-		RTE_LOG(ERR, PMD, "Cannot init vmxnet3 PMD\n");
-		return (ret);
-	}
-#endif /* RTE_LIBRTE_VMXNET3_PMD */
-
-	if (ret == -ENODEV)
-		RTE_LOG(ERR, PMD, "No PMD(s) are configured\n");
-	return (ret);
-}
+extern int rte_pmd_init_all(void);
 
 /**
  * Configure an Ethernet device.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 12/19] pmd: Add PMD_INIT macro for use in pci based PMDs
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (9 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 11/19] pmd: Move rte_pmd_init_all to be non-inline Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 13/19] igb: Convert PMD to use new PMD_INIT macro Neil Horman
                         ` (6 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Like their non-pci counterparts, the PMD_INIT macro can be used by pci based
PMD's to register an init routine without having the core libraries reference
symbols in them directly.

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_eal/common/include/rte_pmd.h |  9 +++++++
 lib/librte_ether/rte_ethdev.c           | 44 +++++++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pmd.h b/lib/librte_eal/common/include/rte_pmd.h
index 75a4895..bcba8f8 100644
--- a/lib/librte_eal/common/include/rte_pmd.h
+++ b/lib/librte_eal/common/include/rte_pmd.h
@@ -44,7 +44,9 @@
 extern "C" {
 #endif
 
+extern void rte_pmd_register_init(int (*pmd_initfn)(void));
 extern void rte_eal_nonpci_dev_init_register(const char *name, int (*dev_initfn)(const char *, const char *));
+
 #define PMD_INIT_NONPCI(x,n)\
 void devinitfn_ ##x(void);\
 void __attribute__((constructor, used)) devinitfn_ ##x(void)\
@@ -52,6 +54,13 @@ void __attribute__((constructor, used)) devinitfn_ ##x(void)\
 	rte_eal_nonpci_dev_init_register(n,x);\
 }
 
+#define PMD_INIT(x)\
+void devinitfn_ ##x(void);\
+void __attribute__((constructor, used)) devinitfn_ ##x(void)\
+{\
+	rte_pmd_register_init(x);\
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index dd378f0..a9efe73 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -64,6 +64,7 @@
 #include <rte_mbuf.h>
 #include <rte_errno.h>
 #include <rte_spinlock.h>
+#include <rte_pmd.h>
 
 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -112,9 +113,38 @@ static uint8_t nb_ports = 0;
 /* spinlock for eth device callbacks */
 static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
+TAILQ_HEAD(pmd_list, pmd_entry);
+
+/* Definition for shared object drivers. */
+struct pmd_entry {
+        TAILQ_ENTRY(pmd_entry) next;
+        int (*pmd_initfn)(void);
+};
+
+/* List of external loadable drivers */
+static struct pmd_list pmd_init_list =
+TAILQ_HEAD_INITIALIZER(pmd_init_list);
+
+void rte_pmd_register_init(int (*pmd_initfn)(void))
+{
+        struct pmd_entry *new = malloc(sizeof(struct pmd_entry));
+
+        if (!new) {
+                printf("Not enough memory to register pci pmd\n");
+                goto out;
+        }
+
+        new->pmd_initfn = pmd_initfn;
+        TAILQ_INSERT_TAIL(&pmd_init_list, new, next);
+out:
+        return;
+
+}
+
 int rte_pmd_init_all(void)
 {
         int ret = -ENODEV;
+	struct pmd_entry *entry;
 
 #ifdef RTE_LIBRTE_IGB_PMD
         if ((ret = rte_igb_pmd_init()) != 0) {
@@ -159,9 +189,19 @@ int rte_pmd_init_all(void)
         }
 #endif /* RTE_LIBRTE_VMXNET3_PMD */
 
-        if (ret == -ENODEV)
+        if (ret == -ENODEV) {
                 RTE_LOG(ERR, PMD, "No PMD(s) are configured\n");
-        return (ret);
+		goto out;
+	}
+
+        TAILQ_FOREACH(entry, &pmd_init_list, next) {
+		ret = entry->pmd_initfn();
+		if (ret != 0)
+			break;
+        }
+
+out:
+	return ret;
 }
 
 /**
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 13/19] igb: Convert PMD to use new PMD_INIT macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (10 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 12/19] pmd: Add PMD_INIT macro for use in pci based PMDs Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 14/19] igbvf: move igbvf pmd to use " Neil Horman
                         ` (5 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Use the PMD init macro to allow separation of the pmd from the rest of the dpdk

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 examples/dpdk_qat/main.c          | 8 +++-----
 lib/librte_ether/rte_ethdev.c     | 4 ----
 lib/librte_ether/rte_ethdev.h     | 9 ---------
 lib/librte_pmd_e1000/igb_ethdev.c | 5 ++++-
 4 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c
index cdf6832..39f7df7 100644
--- a/examples/dpdk_qat/main.c
+++ b/examples/dpdk_qat/main.c
@@ -696,11 +696,9 @@ MAIN(int argc, char **argv)
 	if (ret < 0)
 		return -1;
 
-	/* init driver */
-#ifdef RTE_LIBRTE_IGB_PMD
-	if (rte_igb_pmd_init() < 0)
-		rte_panic("Cannot init igb pmd\n");
-#endif
+	/* init drivers */
+	if (rte_pmd_init_all() < 0)
+		rte_panic("PMD driver failed to init\n");
 #ifdef RTE_LIBRTE_IXGBE_PMD
 	if (rte_ixgbe_pmd_init() < 0)
 		rte_panic("Cannot init ixgbe pmd\n");
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a9efe73..6e85451 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -147,10 +147,6 @@ int rte_pmd_init_all(void)
 	struct pmd_entry *entry;
 
 #ifdef RTE_LIBRTE_IGB_PMD
-        if ((ret = rte_igb_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init igb PMD\n");
-                return (ret);
-        }
         if ((ret = rte_igbvf_pmd_init()) != 0) {
                 RTE_LOG(ERR, PMD, "Cannot init igbvf PMD\n");
                 return (ret);
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index bf2ded4..d5f2922 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1317,15 +1317,6 @@ extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
  * The initialization function of the driver for
- * Intel(r) IGB Gigabit Ethernet Controller devices.
- * This function is invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_igb_pmd_init(void);
-
-/**
- * The initialization function of the driver for
  * Intel(r) EM Gigabit Ethernet Controller devices.
  * This function is invoked once at EAL start time.
  * @return
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c
index 673b4de..df615e0 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -51,6 +51,7 @@
 #include <rte_eal.h>
 #include <rte_atomic.h>
 #include <rte_malloc.h>
+#include <rte_pmd.h>
 
 #include "e1000_logs.h"
 #include "e1000/e1000_api.h"
@@ -619,7 +620,7 @@ static struct eth_driver rte_igbvf_pmd = {
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
-int
+static int
 rte_igb_pmd_init(void)
 {
 	rte_eth_driver_register(&rte_igb_pmd);
@@ -2182,3 +2183,5 @@ eth_igb_rss_reta_query(struct rte_eth_dev *dev,
  
 	return 0;
 }
+
+PMD_INIT(rte_igb_pmd_init);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 14/19] igbvf: move igbvf pmd to use PMD_INIT macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (11 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 13/19] igb: Convert PMD to use new PMD_INIT macro Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 15/19] em: move em/e1000 " Neil Horman
                         ` (4 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Removed references to core library so that it can be linked in whenever needed

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c     | 7 -------
 lib/librte_ether/rte_ethdev.h     | 9 ---------
 lib/librte_pmd_e1000/igb_ethdev.c | 3 ++-
 3 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 6e85451..29eeef3 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -146,13 +146,6 @@ int rte_pmd_init_all(void)
         int ret = -ENODEV;
 	struct pmd_entry *entry;
 
-#ifdef RTE_LIBRTE_IGB_PMD
-        if ((ret = rte_igbvf_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init igbvf PMD\n");
-                return (ret);
-        }
-#endif /* RTE_LIBRTE_IGB_PMD */
-
 #ifdef RTE_LIBRTE_EM_PMD
         if ((ret = rte_em_pmd_init()) != 0) {
                 RTE_LOG(ERR, PMD, "Cannot init em PMD\n");
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d5f2922..6cf7a03 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1325,15 +1325,6 @@ extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 extern int rte_em_pmd_init(void);
 
 /**
- * The initialization function of the driver for 1Gbps Intel IGB_VF
- * Ethernet devices.
- * Invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_igbvf_pmd_init(void);
-
-/**
  * The initialization function of the driver for 10Gbps Intel IXGBE
  * Ethernet devices.
  * Invoked once at EAL start time.
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c
index df615e0..14e43b2 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -643,7 +643,7 @@ igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
  * Invoked one at EAL init time.
  * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
  */
-int
+static int
 rte_igbvf_pmd_init(void)
 {
 	DEBUGFUNC("rte_igbvf_pmd_init");
@@ -2185,3 +2185,4 @@ eth_igb_rss_reta_query(struct rte_eth_dev *dev,
 }
 
 PMD_INIT(rte_igb_pmd_init);
+PMD_INIT(rte_igbvf_pmd_init);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 15/19] em: move em/e1000 pmd to use PMD_INIT macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (12 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 14/19] igbvf: move igbvf pmd to use " Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 16/19] ixgbe: move ixgbe[vf] pmd's " Neil Horman
                         ` (3 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Modify the em pmd to use the PMD_INIT macro

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c    | 7 -------
 lib/librte_ether/rte_ethdev.h    | 9 ---------
 lib/librte_pmd_e1000/em_ethdev.c | 5 ++++-
 mk/rte.app.mk                    | 2 ++
 4 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 29eeef3..9a0a26a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -146,13 +146,6 @@ int rte_pmd_init_all(void)
         int ret = -ENODEV;
 	struct pmd_entry *entry;
 
-#ifdef RTE_LIBRTE_EM_PMD
-        if ((ret = rte_em_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init em PMD\n");
-                return (ret);
-        }
-#endif /* RTE_LIBRTE_EM_PMD */
-
 #ifdef RTE_LIBRTE_IXGBE_PMD
         if ((ret = rte_ixgbe_pmd_init()) != 0) {
                 RTE_LOG(ERR, PMD, "Cannot init ixgbe PMD\n");
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 6cf7a03..d06308b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1316,15 +1316,6 @@ struct eth_driver {
 extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
- * The initialization function of the driver for
- * Intel(r) EM Gigabit Ethernet Controller devices.
- * This function is invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_em_pmd_init(void);
-
-/**
  * The initialization function of the driver for 10Gbps Intel IXGBE
  * Ethernet devices.
  * Invoked once at EAL start time.
diff --git a/lib/librte_pmd_e1000/em_ethdev.c b/lib/librte_pmd_e1000/em_ethdev.c
index d8c9a9b..accb7d7 100644
--- a/lib/librte_pmd_e1000/em_ethdev.c
+++ b/lib/librte_pmd_e1000/em_ethdev.c
@@ -51,6 +51,7 @@
 #include <rte_eal.h>
 #include <rte_atomic.h>
 #include <rte_malloc.h>
+#include <rte_pmd.h>
 
 #include "e1000_logs.h"
 #include "e1000/e1000_api.h"
@@ -285,7 +286,7 @@ static struct eth_driver rte_em_pmd = {
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
-int
+static int
 rte_em_pmd_init(void)
 {
 	rte_eth_driver_register(&rte_em_pmd);
@@ -1433,3 +1434,5 @@ eth_em_rar_clear(struct rte_eth_dev *dev, uint32_t index)
 
 	e1000_rar_set(hw, addr, index);
 }
+
+PMD_INIT(rte_em_pmd_init);
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 41eab08..7435d97 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -73,9 +73,11 @@ LDLIBS += -lrte_ivshmem
 endif
 endif
 
+ifeq ($(RTE_BUILD_SHARED_LIB),n)
 ifeq ($(CONFIG_RTE_LIBRTE_E1000_PMD),y)
 LDLIBS += -lrte_pmd_e1000
 endif
+endif
 
 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
 LDLIBS += -lrte_pmd_ixgbe
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 16/19] ixgbe: move ixgbe[vf] pmd's to use PMD_INIT macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (13 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 15/19] em: move em/e1000 " Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 17/19] virtio: Move to using " Neil Horman
                         ` (2 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw; +Cc: Neil Horman

Move the ixgbe and ixgbevf pmds to use the PMD_INIT macro

Signed-off-by: Neil Horman <nhroman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 examples/dpdk_qat/main.c            |  4 ----
 examples/vmdq_dcb/main.c            |  2 +-
 lib/librte_ether/rte_ethdev.c       | 11 -----------
 lib/librte_ether/rte_ethdev.h       | 18 ------------------
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |  8 ++++++--
 mk/rte.app.mk                       |  2 ++
 6 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c
index 39f7df7..38c64c0 100644
--- a/examples/dpdk_qat/main.c
+++ b/examples/dpdk_qat/main.c
@@ -699,10 +699,6 @@ MAIN(int argc, char **argv)
 	/* init drivers */
 	if (rte_pmd_init_all() < 0)
 		rte_panic("PMD driver failed to init\n");
-#ifdef RTE_LIBRTE_IXGBE_PMD
-	if (rte_ixgbe_pmd_init() < 0)
-		rte_panic("Cannot init ixgbe pmd\n");
-#endif
 
 	if (rte_eal_pci_probe() < 0)
 		rte_panic("Cannot probe PCI\n");
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 844f334..42fc1b2 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -455,7 +455,7 @@ MAIN(int argc, char *argv[])
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid VMDQ argument\n");
 
-	if (rte_ixgbe_pmd_init() != 0 ||
+	if (rte_pmd_init_all() != 0) ||
 			rte_eal_pci_probe() != 0)
 		rte_exit(EXIT_FAILURE, "Error with NIC driver initialization\n");
 	
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9a0a26a..3d87733 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -146,17 +146,6 @@ int rte_pmd_init_all(void)
         int ret = -ENODEV;
 	struct pmd_entry *entry;
 
-#ifdef RTE_LIBRTE_IXGBE_PMD
-        if ((ret = rte_ixgbe_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init ixgbe PMD\n");
-                return (ret);
-        }
-        if ((ret = rte_ixgbevf_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init ixgbevf PMD\n");
-                return (ret);
-        }
-#endif /* RTE_LIBRTE_IXGBE_PMD */
-
 #ifdef RTE_LIBRTE_VIRTIO_PMD
         if ((ret = rte_virtio_pmd_init()) != 0) {
                 RTE_LOG(ERR, PMD, "Cannot init virtio PMD\n");
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d06308b..d9f4705 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1316,24 +1316,6 @@ struct eth_driver {
 extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
- * The initialization function of the driver for 10Gbps Intel IXGBE
- * Ethernet devices.
- * Invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_ixgbe_pmd_init(void);
-
-/**
- * The initialization function of the driver for 10Gbps Intel IXGBE_VF
- * Ethernet devices.
- * Invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_ixgbevf_pmd_init(void);
-
-/**
  * The initialization function of the driver for Qumranet virtio-net
  * Ethernet devices.
  * Invoked once at EAL start time.
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index a5a7f9a..c6bfa71 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -58,6 +58,7 @@
 #include <rte_ethdev.h>
 #include <rte_atomic.h>
 #include <rte_malloc.h>
+#include <rte_pmd.h>
 
 #include "ixgbe_logs.h"
 #include "ixgbe/ixgbe_api.h"
@@ -955,7 +956,7 @@ static struct eth_driver rte_ixgbevf_pmd = {
  * Invoked once at EAL init time.
  * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
  */
-int
+static int
 rte_ixgbe_pmd_init(void)
 {
 	PMD_INIT_FUNC_TRACE();
@@ -969,7 +970,7 @@ rte_ixgbe_pmd_init(void)
  * Invoked one at EAL init time.
  * Register itself as the [Virtual Poll Mode] Driver of PCI niantic devices.
  */
-int
+static int
 rte_ixgbevf_pmd_init(void)
 {
 	DEBUGFUNC("rte_ixgbevf_pmd_init");
@@ -3060,3 +3061,6 @@ ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
 
 	return 0;
 }
+
+PMD_INIT(rte_ixgbe_pmd_init);
+PMD_INIT(rte_ixgbevf_pmd_init);
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 7435d97..498b425 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -79,9 +79,11 @@ LDLIBS += -lrte_pmd_e1000
 endif
 endif
 
+ifeq ($(RTE_BUILD_SHARED_LIB),n)
 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
 LDLIBS += -lrte_pmd_ixgbe
 endif
+endif
 
 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 17/19] virtio: Move to using PMD_INIT macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (14 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 16/19] ixgbe: move ixgbe[vf] pmd's " Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 18/19] vmxnet3: move " Neil Horman
  2014-04-10 20:50       ` [PATCH 19/19] pmd: Not having any pci dev pmds shouldn't be fatal Neil Horman
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Move the virtio pmd to make use of the PMD_INIT macro

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c         | 7 -------
 lib/librte_ether/rte_ethdev.h         | 9 ---------
 lib/librte_pmd_virtio/virtio_ethdev.c | 6 +++++-
 mk/rte.app.mk                         | 3 ++-
 4 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 3d87733..8a3bbd1 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -146,13 +146,6 @@ int rte_pmd_init_all(void)
         int ret = -ENODEV;
 	struct pmd_entry *entry;
 
-#ifdef RTE_LIBRTE_VIRTIO_PMD
-        if ((ret = rte_virtio_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init virtio PMD\n");
-                return (ret);
-        }
-#endif /* RTE_LIBRTE_VIRTIO_PMD */
-
 #ifdef RTE_LIBRTE_VMXNET3_PMD
         if ((ret = rte_vmxnet3_pmd_init()) != 0) {
                 RTE_LOG(ERR, PMD, "Cannot init vmxnet3 PMD\n");
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d9f4705..4c57864 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1316,15 +1316,6 @@ struct eth_driver {
 extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
- * The initialization function of the driver for Qumranet virtio-net
- * Ethernet devices.
- * Invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_virtio_pmd_init(void);
-
-/**
  * The initialization function of the driver for VMware VMXNET3
  * Ethernet devices.
  * Invoked once at EAL start time.
diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c
index f107161..f7366df 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -50,6 +50,7 @@
 
 #include <rte_memory.h>
 #include <rte_eal.h>
+#include <rte_pmd.h>
 
 #include "virtio_ethdev.h"
 #include "virtio_pci.h"
@@ -486,7 +487,7 @@ static struct eth_driver rte_virtio_pmd = {
  * Register itself as the [Poll Mode] Driver of PCI virtio devices.
  * Returns 0 on success.
  */
-int
+static int
 rte_virtio_pmd_init(void)
 {
 	rte_eth_driver_register(&rte_virtio_pmd);
@@ -643,3 +644,6 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->max_rx_pktlen = VIRTIO_MAX_RX_PKTLEN;
 	dev_info->max_mac_addrs = VIRTIO_MAX_MAC_ADDRS;
 }
+
+PMD_INIT(rte_virtio_pmd_init);
+
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 498b425..2aa71e4 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -83,11 +83,12 @@ ifeq ($(RTE_BUILD_SHARED_LIB),n)
 ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y)
 LDLIBS += -lrte_pmd_ixgbe
 endif
-endif
 
 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
 endif
+endif
+
 
 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
 LDLIBS += -lrte_pmd_vmxnet3_uio
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 18/19] vmxnet3: move to using PMD_INIT macro
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (15 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 17/19] virtio: Move to using " Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  2014-04-10 20:50       ` [PATCH 19/19] pmd: Not having any pci dev pmds shouldn't be fatal Neil Horman
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Move teh vmxnet3 pmd to use the PMD_INIT macro

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c           | 13 -------------
 lib/librte_ether/rte_ethdev.h           | 10 ----------
 lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c |  5 ++++-
 mk/rte.app.mk                           |  3 +--
 4 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8a3bbd1..0b4888c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -146,25 +146,12 @@ int rte_pmd_init_all(void)
         int ret = -ENODEV;
 	struct pmd_entry *entry;
 
-#ifdef RTE_LIBRTE_VMXNET3_PMD
-        if ((ret = rte_vmxnet3_pmd_init()) != 0) {
-                RTE_LOG(ERR, PMD, "Cannot init vmxnet3 PMD\n");
-                return (ret);
-        }
-#endif /* RTE_LIBRTE_VMXNET3_PMD */
-
-        if (ret == -ENODEV) {
-                RTE_LOG(ERR, PMD, "No PMD(s) are configured\n");
-		goto out;
-	}
-
         TAILQ_FOREACH(entry, &pmd_init_list, next) {
 		ret = entry->pmd_initfn();
 		if (ret != 0)
 			break;
         }
 
-out:
 	return ret;
 }
 
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4c57864..0b38df2 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1316,16 +1316,6 @@ struct eth_driver {
 extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
- * The initialization function of the driver for VMware VMXNET3
- * Ethernet devices.
- * Invoked once at EAL start time.
- * @return
- *   0 on success
- */
-extern int rte_vmxnet3_pmd_init(void);
-
-
-/**
  * The initialization function of *all* supported and enabled drivers.
  * Right now, the following PMDs are supported:
  *  - igb
diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
index 8259cfe..ce649a4 100644
--- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
+++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
@@ -60,6 +60,7 @@
 #include <rte_atomic.h>
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
+#include <rte_pmd.h>
 
 #include "vmxnet3/vmxnet3_defs.h"
 
@@ -278,7 +279,7 @@ static struct eth_driver rte_vmxnet3_pmd = {
  * Invoked once at EAL init time.
  * Register itself as the [Poll Mode] Driver of Virtual PCI VMXNET3 devices.
  */
-int
+static int
 rte_vmxnet3_pmd_init(void)
 {
 	PMD_INIT_FUNC_TRACE();
@@ -763,3 +764,5 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
 
 }
 #endif
+
+PMD_INIT(rte_vmxnet3_pmd_init);
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 2aa71e4..15dbf2e 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -87,12 +87,11 @@ endif
 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
 endif
-endif
-
 
 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
 LDLIBS += -lrte_pmd_vmxnet3_uio
 endif
+endif
 
 ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
 LDLIBS += -lrte_timer
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 19/19] pmd: Not having any pci dev pmds shouldn't be fatal
       [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
                         ` (16 preceding siblings ...)
  2014-04-10 20:50       ` [PATCH 18/19] vmxnet3: move " Neil Horman
@ 2014-04-10 20:50       ` Neil Horman
  17 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-10 20:50 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Since we support non-pci pmds, we shouldn't return a fatal error if we didn't
load any pmds, as we may just be using a non-pci pmd

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0b4888c..a835311 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -149,9 +149,11 @@ int rte_pmd_init_all(void)
         TAILQ_FOREACH(entry, &pmd_init_list, next) {
 		ret = entry->pmd_initfn();
 		if (ret != 0)
-			break;
+			goto out;
         }
 
+	ret = 0;
+out:	
 	return ret;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/19] Separate compile time linkage between eal lib and pmd's
       [not found] ` <1397162846-28912-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
  2014-04-10 20:49   ` [PATCH 01/19] makefiles: Fixed -share command line option error Neil Horman
@ 2014-04-12 11:04   ` Neil Horman
       [not found]     ` <20140412110425.GB30887-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
  1 sibling, 1 reply; 23+ messages in thread
From: Neil Horman @ 2014-04-12 11:04 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

On Thu, Apr 10, 2014 at 04:47:07PM -0400, Neil Horman wrote:
> Disconnect compile time linkage between eal library / applications and pmd's
> 
> I noticed that, while tinkering with dpdk, building for shared libraries still
> resulted in all the test applications linking to all the built pmd's, despite
> not actually needing them all.  We are able to tell an application at run time
> (via the -d/--blacklist/--whitelist/--vdev options) which pmd's we want to use, and
> so have no need to link them at all. The only reason they get pulled in is
> because rte_eal_non_pci_init_etherdev and rte_pmd_init_all contain static lists
> to the individual pmd init functions. The result is that, even when building as
> DSO's, we have to load all the pmd libraries, which is space inefficient and
> defeating of some of the purpose of shared objects. 
> 
> To correct this, I developed this patch series, which introduces two new macros,
> PMD_INIT_NONPCI and PMD_INIT.  These two macros use constructors to register
> their init routines at runtime, either prior to the execution of main() when
> linked statically, or when dlopen is called on a DSO at run time.  The result is
> that PMD's can be loaded at run time without the application or eal library
> having to hold a reference to them.  They work in a very simmilar fashion to the
> module_init routine in the linux kernel.
> 
> I've tested this feature using the igb and pcap pmd's, both statically and
> dynamically linked with the test and testpmd sample applications, and it seems
> to work well.
> 
> Note, I encountered  a few bugs along the way, which I fixed and noted in the
> series.
> 
> Regards
> Neil
> 
> 

Self NAK on this, based on the conversation Thomas and I had about Oliviers
patches from a while back, I'm going to rebase and repost these soon.
Neil

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/19] Separate compile time linkage between eal lib and pmd's
       [not found]     ` <20140412110425.GB30887-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
@ 2014-04-15  8:31       ` Thomas Monjalon
  2014-04-15 13:46         ` Neil Horman
  0 siblings, 1 reply; 23+ messages in thread
From: Thomas Monjalon @ 2014-04-15  8:31 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev-VfR2kkLFssw

2014-04-12 07:04, Neil Horman:
> On Thu, Apr 10, 2014 at 04:47:07PM -0400, Neil Horman wrote:
> > Disconnect compile time linkage between eal library / applications and
> > pmd's
> > 
> > I noticed that, while tinkering with dpdk, building for shared libraries
> > still resulted in all the test applications linking to all the built
> > pmd's, despite not actually needing them all.  We are able to tell an
> > application at run time (via the -d/--blacklist/--whitelist/--vdev
> > options) which pmd's we want to use, and so have no need to link them at
> > all. The only reason they get pulled in is because
> > rte_eal_non_pci_init_etherdev and rte_pmd_init_all contain static lists
> > to the individual pmd init functions. The result is that, even when
> > building as DSO's, we have to load all the pmd libraries, which is space
> > inefficient and defeating of some of the purpose of shared objects.
> > 
> > To correct this, I developed this patch series, which introduces two new
> > macros, PMD_INIT_NONPCI and PMD_INIT.  These two macros use constructors
> > to register their init routines at runtime, either prior to the execution
> > of main() when linked statically, or when dlopen is called on a DSO at
> > run time.  The result is that PMD's can be loaded at run time without the
> > application or eal library having to hold a reference to them.  They work
> > in a very simmilar fashion to the module_init routine in the linux
> > kernel.
> > 
> > I've tested this feature using the igb and pcap pmd's, both statically and
> > dynamically linked with the test and testpmd sample applications, and it
> > seems to work well.
> > 
> > Note, I encountered  a few bugs along the way, which I fixed and noted in
> > the series.
> > 
> > Regards
> > Neil
> 
> Self NAK on this, based on the conversation Thomas and I had about Oliviers
> patches from a while back, I'm going to rebase and repost these soon.
> Neil

I'll be glad to get your fixes soon. So I could apply them for version 1.6.0r2 
and release it.
But I think you should post API changes (if any) in another series. Then we'll 
think if we want to push it in another branch for next major version.

Thanks Neil
-- 
Thomas

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/19] Separate compile time linkage between eal lib and pmd's
  2014-04-15  8:31       ` Thomas Monjalon
@ 2014-04-15 13:46         ` Neil Horman
  0 siblings, 0 replies; 23+ messages in thread
From: Neil Horman @ 2014-04-15 13:46 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev-VfR2kkLFssw

On Tue, Apr 15, 2014 at 10:31:25AM +0200, Thomas Monjalon wrote:
> 2014-04-12 07:04, Neil Horman:
> > On Thu, Apr 10, 2014 at 04:47:07PM -0400, Neil Horman wrote:
> > > Disconnect compile time linkage between eal library / applications and
> > > pmd's
> > > 
> > > I noticed that, while tinkering with dpdk, building for shared libraries
> > > still resulted in all the test applications linking to all the built
> > > pmd's, despite not actually needing them all.  We are able to tell an
> > > application at run time (via the -d/--blacklist/--whitelist/--vdev
> > > options) which pmd's we want to use, and so have no need to link them at
> > > all. The only reason they get pulled in is because
> > > rte_eal_non_pci_init_etherdev and rte_pmd_init_all contain static lists
> > > to the individual pmd init functions. The result is that, even when
> > > building as DSO's, we have to load all the pmd libraries, which is space
> > > inefficient and defeating of some of the purpose of shared objects.
> > > 
> > > To correct this, I developed this patch series, which introduces two new
> > > macros, PMD_INIT_NONPCI and PMD_INIT.  These two macros use constructors
> > > to register their init routines at runtime, either prior to the execution
> > > of main() when linked statically, or when dlopen is called on a DSO at
> > > run time.  The result is that PMD's can be loaded at run time without the
> > > application or eal library having to hold a reference to them.  They work
> > > in a very simmilar fashion to the module_init routine in the linux
> > > kernel.
> > > 
> > > I've tested this feature using the igb and pcap pmd's, both statically and
> > > dynamically linked with the test and testpmd sample applications, and it
> > > seems to work well.
> > > 
> > > Note, I encountered  a few bugs along the way, which I fixed and noted in
> > > the series.
> > > 
> > > Regards
> > > Neil
> > 
> > Self NAK on this, based on the conversation Thomas and I had about Oliviers
> > patches from a while back, I'm going to rebase and repost these soon.
> > Neil
> 
> I'll be glad to get your fixes soon. So I could apply them for version 1.6.0r2 
> and release it.
> But I think you should post API changes (if any) in another series. Then we'll 
> think if we want to push it in another branch for next major version.
> 
I presume at this point you're fairly close to tagging
1.6.0r2, which, based on what I see in the git tree is usually the last rc
before you merge to the next major version.  Do you want to put this in now,
before that happens, or will you commit to the first 1.7.0 rc?  If the latter,
that seems like the best time to make ABI changes, so you maximize testing

Neil

> Thanks Neil
> -- 
> Thomas
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2014-04-15 13:46 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-10 20:47 [PATCH 0/19] Separate compile time linkage between eal lib and pmd's Neil Horman
     [not found] ` <1397162846-28912-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2014-04-10 20:49   ` [PATCH 01/19] makefiles: Fixed -share command line option error Neil Horman
     [not found]     ` <1397163009-29950-1-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2014-04-10 20:49       ` [PATCH 02/19] pmd: Add PMD_INIT_NONPCI macros Neil Horman
2014-04-10 20:49       ` [PATCH 03/19] eal: dlopen the DSO built poll mode drivers before init Neil Horman
2014-04-10 20:49       ` [PATCH 04/19] pcap: Convert pcap poll mode driver to use new PMD_INIT_NONPCI macro Neil Horman
2014-04-10 20:49       ` [PATCH 05/19] ring: convert the ring pmd driver to use the " Neil Horman
2014-04-10 20:49       ` [PATCH 06/19] xenvert: Convert xenvirt pmd to use " Neil Horman
2014-04-10 20:49       ` [PATCH 07/19] pmd: remove dead code Neil Horman
2014-04-10 20:49       ` [PATCH 08/19] test: fix test app to dynamically link pmd_pcap when needed Neil Horman
2014-04-10 20:49       ` [PATCH 09/19] testpmd: only link pcap pmd when statically linking Neil Horman
2014-04-10 20:50       ` [PATCH 10/19] make: include whole archive on static link Neil Horman
2014-04-10 20:50       ` [PATCH 11/19] pmd: Move rte_pmd_init_all to be non-inline Neil Horman
2014-04-10 20:50       ` [PATCH 12/19] pmd: Add PMD_INIT macro for use in pci based PMDs Neil Horman
2014-04-10 20:50       ` [PATCH 13/19] igb: Convert PMD to use new PMD_INIT macro Neil Horman
2014-04-10 20:50       ` [PATCH 14/19] igbvf: move igbvf pmd to use " Neil Horman
2014-04-10 20:50       ` [PATCH 15/19] em: move em/e1000 " Neil Horman
2014-04-10 20:50       ` [PATCH 16/19] ixgbe: move ixgbe[vf] pmd's " Neil Horman
2014-04-10 20:50       ` [PATCH 17/19] virtio: Move to using " Neil Horman
2014-04-10 20:50       ` [PATCH 18/19] vmxnet3: move " Neil Horman
2014-04-10 20:50       ` [PATCH 19/19] pmd: Not having any pci dev pmds shouldn't be fatal Neil Horman
2014-04-12 11:04   ` [PATCH 0/19] Separate compile time linkage between eal lib and pmd's Neil Horman
     [not found]     ` <20140412110425.GB30887-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-04-15  8:31       ` Thomas Monjalon
2014-04-15 13:46         ` Neil Horman

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.