eal: add PMD_REGISTER_DRIVER macro
authorNeil Horman <nhorman@tuxdriver.com>
Mon, 21 Apr 2014 14:59:27 +0000 (10:59 -0400)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 20 May 2014 12:27:59 +0000 (14:27 +0200)
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@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
lib/librte_eal/common/include/rte_vdev.h

index 48f71b7..c7aa795 100644 (file)
@@ -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