[dpdk-dev] [PATCH 03/15] pmd: Add PMD_REGISTER_DRIVER macro
Thomas Monjalon
thomas.monjalon at 6wind.com
Wed Apr 16 13:52:49 CEST 2014
2014-04-15 14:05, Neil Horman:
> 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>
Could you explain why having a macro is better than an explicit constructor
function?
> +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;\
> + };\
Are you sure this switch is needed?
You are removing it in patch 7.
If someone else think this macro is a good idea, or not, speak now :)
--
Thomas
More information about the dev
mailing list