From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 6BDD4AFD2 for ; Mon, 21 Apr 2014 16:59:59 +0200 (CEST) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1WcFhO-0007bi-Ls; Mon, 21 Apr 2014 11:00:00 -0400 From: Neil Horman To: dev@dpdk.org Date: Mon, 21 Apr 2014 10:59:27 -0400 Message-Id: <1398092379-7679-3-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1398092379-7679-1-git-send-email-nhorman@tuxdriver.com> References: <1397585169-14537-1-git-send-email-nhorman@tuxdriver.com> <1398092379-7679-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -2.9 (--) X-Spam-Status: No Subject: [dpdk-dev] [PATCH 0/X v5 02/14] pmd: Add PMD_REGISTER_DRIVER macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2014 14:59:59 -0000 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 --- 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