From: Neil Horman Date: Mon, 21 Apr 2014 14:59:27 +0000 (-0400) Subject: eal: add PMD_REGISTER_DRIVER macro X-Git-Tag: spdx-start~10816 X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=3ac2bd97d9b2e8362348d83f711c36e52b7c2024 eal: add PMD_REGISTER_DRIVER macro 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 Acked-by: Thomas Monjalon --- diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 48f71b796c..c7aa7955df 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