eal: introduce driver init macros
[dpdk.git] / lib / librte_eal / common / include / rte_pci.h
index 803c78a..cf81898 100644 (file)
@@ -470,6 +470,16 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, pci_drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{\
+       (pci_drv).name = RTE_STR(nm);\
+       rte_eal_pci_register(&pci_drv); \
+} \
+DRIVER_EXPORT_NAME(nm, __COUNTER__)
+
 /**
  * Unregister a PCI driver.
  *