Rather than have each driver have to remember to add a constructor to it to make
sure its gets registered properly, wrap that process up in a macro to make
registration a one line affair.  This also sets the stage for us to make
registration of vdev pmds and physical pmds a uniform process

Signed-off-by: Neil Horman <nhorman at tuxdriver.com>
---
 lib/librte_eal/common/Makefile           |  2 +-
 lib/librte_eal/common/include/rte_vdev.h | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index 2f99bf4..d3e7e39 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -37,7 +37,7 @@ INC += rte_log.h rte_memcpy.h rte_memory.h rte_memzone.h 
rte_pci.h
 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_eal_memconfig.h rte_malloc_heap.h 
 INC += rte_hexdump.h rte_devargs.h rte_vdev.h

 ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)
diff --git a/lib/librte_eal/common/include/rte_vdev.h 
b/lib/librte_eal/common/include/rte_vdev.h
index 48f71b7..c7aa795 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -83,6 +83,24 @@ void rte_eal_vdev_driver_register(struct rte_vdev_driver 
*driver);
  */
 void rte_eal_vdev_driver_unregister(struct rte_vdev_driver *driver);

+enum rte_pmd_driver_type {
+       PMD_VDEV = 1
+};
+
+extern void rte_eal_nonpci_dev_init_register(const char *name, int 
(*dev_initfn)(const char *, const char *));
+#define PMD_REGISTER_DRIVER(d, t)\
+void devinitfn_ ##d(void);\
+void __attribute__((constructor, used)) devinitfn_ ##d(void)\
+{\
+       enum rte_pmd_driver_type _t = (t);\
+       switch(_t)\
+       {\
+               case PMD_VDEV:\
+                       rte_eal_vdev_driver_register(&d);\
+                       break;\
+       };\
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.8.3.1

Reply via email to