From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f169.google.com (mail-wr0-f169.google.com [209.85.128.169]) by dpdk.org (Postfix) with ESMTP id 39AB22C8 for ; Fri, 7 Jul 2017 02:03:42 +0200 (CEST) Received: by mail-wr0-f169.google.com with SMTP id k67so24088823wrc.2 for ; Thu, 06 Jul 2017 17:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=A2rq2/mH/qIw0j4TLj415CA4gitvxWR8AD1sZg4vgSM=; b=A+zMYdz939IXvrEF6I7eAJQsWIg8jskkBUKhh65zyo2iuRMRXBo666M78dQzfwIREQ 1QAhaxsksXgNdOdNt4ztEU1Au+wOV13/0H1cChf0H8l56FEdLA1xddXheTJLldY9Qn2t p/FhFFXM7OTtDKAjFnbhY1JaJRbaQEA7mFcnCCqJQFiZdP7RfUl8cGBGq6LbaV9JDqAc ru7fTRrxRqVb+PCiA7zTTwc+3zLEjPVlrlGn02JfU61W2OejocP8tSVv90ZZv5jvvOKQ wdYR2QFcF+Zs+clFXtHsW2emUGkYirVyRNwJ++ir4oUb5DFc20D1R+Br38gRayks/5p3 DzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=A2rq2/mH/qIw0j4TLj415CA4gitvxWR8AD1sZg4vgSM=; b=hRrchG+WMrp0NpiXaGhhn975mC1JRowhxT3ODc23wvpTbe/oYmP5FdbdGjVdFDONeZ RWeWlDtZf+tWbc03Oz+7d6j0KL+bLd3uMPAnIbNqZVXA1WxN9f+0WYMSvp/so5+NG26h 6COuqebHNBEix1t8RXQ6dL1lrgjtoIfnJrS8V9eYOu+tatGnjQp/ckVtuxK6b2/byAuT PjErDTCfeV8941T16Y5HZsOZuy0ucEPQXhAqP31cnFdGO4oCUsiUxMReTZJbcjVmK/A4 UfialftvwMoaoEaHi259s3mVMikKABrsTu994lXSmpfGYl5R1BV0UGOyQjqeXmpZ1LT6 1OdQ== X-Gm-Message-State: AIVw113OsJU7rX3YQPUtKprR3/hJHFj8wYdAkrxf1F7/a5FVDLJb+zsU NLC5V6FeZIdzlbqc1OA= X-Received: by 10.28.129.205 with SMTP id c196mr252373wmd.120.1499385821440; Thu, 06 Jul 2017 17:03:41 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id p7sm2364921wmf.11.2017.07.06.17.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 17:03:40 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Thomas Monjalon Date: Fri, 7 Jul 2017 02:03:07 +0200 Message-Id: <81e3a4a14332d9f0b48ba92d64dc14c3fd8c1273.1499384335.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v8 1/6] bus: fix driver registration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jul 2017 00:03:42 -0000 From: Thomas Monjalon The bus name was stored with embedded double quotes. Indeed the bus name is given with a string in a macro, which is not used elsewhere. These macros are useless because the buses are drivers, so they must not have any API for the application writer. The registration can be done with a hardcoded value without quotes. There is another (small) benefit of not using macros for driver names: it is to have a meaningful constructor function name. For instance, it was businitfn_PCI_BUS_NAME instead of businitfn_pci. The bus registration macro is also changed to use the new RTE_INIT_PRIO macro, similar to RTE_INIT used for other drivers. The priority is the highest (101) in order to be sure that the bus driver is registered before its device drivers. Fixes: 0fd1a0eaae19 ("pci: add bus driver") Fixes: fea892e35f21 ("bus/vdev: use standard bus registration") Fixes: 7e7df6d0a41d ("bus/fslmc: introduce fsl-mc bus driver") Signed-off-by: Thomas Monjalon Reviewed-by: Santosh Shukla Acked-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_bus.c | 2 +- drivers/bus/fslmc/rte_fslmc.h | 3 --- lib/librte_eal/common/eal_common_bus.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 2 +- lib/librte_eal/common/eal_common_pci.c | 2 +- lib/librte_eal/common/eal_common_vdev.c | 2 +- lib/librte_eal/common/include/rte_bus.h | 3 ++- lib/librte_eal/common/include/rte_eal.h | 3 +++ lib/librte_eal/common/include/rte_pci.h | 3 --- lib/librte_eal/common/include/rte_vdev.h | 2 -- 10 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index 1e3bbee..f9e2211 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -161,4 +161,4 @@ struct rte_fslmc_bus rte_fslmc_bus = { .driver_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.driver_list), }; -RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus); +RTE_REGISTER_BUS(fslmc, rte_fslmc_bus.bus); diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h index 040ab95..8f35278 100644 --- a/drivers/bus/fslmc/rte_fslmc.h +++ b/drivers/bus/fslmc/rte_fslmc.h @@ -56,9 +56,6 @@ extern "C" { #include #include -/** Name of FSLMC Bus */ -#define FSLMC_BUS_NAME "FSLMC" - struct rte_dpaa2_driver; /* DPAA2 Device and Driver lists for FSLMC bus */ diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 87b0c6e..fd59b7c 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -92,7 +92,7 @@ rte_bus_probe(void) struct rte_bus *bus, *vbus = NULL; TAILQ_FOREACH(bus, &rte_bus_list, next) { - if (!strcmp(bus->name, "virtual")) { + if (!strcmp(bus->name, "vdev")) { vbus = bus; continue; } diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 4ee52fd..32e12b5 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -74,7 +74,7 @@ int rte_eal_dev_attach(const char *name, const char *devargs) return -EINVAL; } - ret = rte_eal_hotplug_add("PCI", name, devargs); + ret = rte_eal_hotplug_add("pci", name, devargs); if (ret && ret != -EINVAL) return ret; diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 5ee100e..2c99049 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -549,4 +549,4 @@ struct rte_pci_bus rte_pci_bus = { .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), }; -RTE_REGISTER_BUS(PCI_BUS_NAME, rte_pci_bus.bus); +RTE_REGISTER_BUS(pci, rte_pci_bus.bus); diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index baf3c5b..3bad0c4 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -374,4 +374,4 @@ static struct rte_bus rte_vdev_bus = { .unplug = vdev_unplug, }; -RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus); +RTE_REGISTER_BUS(vdev, rte_vdev_bus); diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 2f1c911..773b0d7 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -256,7 +256,8 @@ struct rte_bus *rte_bus_find_by_name(const char *busname); * The constructor has higher priority than PMD constructors. */ #define RTE_REGISTER_BUS(nm, bus) \ -static void __attribute__((constructor(101), used)) businitfn_ ##nm(void) \ +RTE_INIT_PRIO(businitfn_ ##nm, 101); \ +static void businitfn_ ##nm(void) \ {\ (bus).name = RTE_STR(nm);\ rte_bus_register(&bus); \ diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index abf020b..6b7c5ca 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -286,6 +286,9 @@ static inline int rte_gettid(void) #define RTE_INIT(func) \ static void __attribute__((constructor, used)) func(void) +#define RTE_INIT_PRIO(func, prio) \ +static void __attribute__((constructor(prio), used)) func(void) + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index e416714..406d918 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -77,9 +77,6 @@ const char *pci_get_sysfs_path(void); /** Maximum number of PCI resources. */ #define PCI_MAX_RESOURCE 6 -/** Name of PCI Bus */ -#define PCI_BUS_NAME "PCI" - /* Forward declarations */ struct rte_pci_device; struct rte_pci_driver; diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 2d02c68..e6b678e 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -41,8 +41,6 @@ extern "C" { #include #include -#define VIRTUAL_BUS_NAME "virtual" - struct rte_vdev_device { TAILQ_ENTRY(rte_vdev_device) next; /**< Next attached vdev */ struct rte_device device; /**< Inherit core device */ -- 2.1.4