From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id B57B92C50 for ; Mon, 20 Feb 2017 15:18:21 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id v77so14633766wmv.0 for ; Mon, 20 Feb 2017 06:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=HUfgFIprVUaohi0BfIZClscA+LK1Se6MJEmPdsrrDco=; b=AwuA6urdgCr2Z9BB3nai14Pcv4KycRiAYt8bsPVLH3VjLGKffrB6jNTt1Fr64vWdyn ZD3jpUrBPwqB5S/orsazC7Hg9RUBSvWAs1tgmEGUFJCgzrmPf517phLWGoooPBEmmg1/ Cqymt0uR54hq1BAp5VaDOHalwUH2phRRQexifNbQh4qNxWsy196fBChdOaw1Upi0FaXy 2Bz2QWWxpaDWhQVwTEOjo50dmgYHVgUQ97s1qPi5wvaofp0+GBypROGTN3b90uLoyRYj FSB6lcd5b6bPqb9SsXlqcErlycpL+v/R2sy445/iA+ihKtGTWlaAafTxqKygpEQcW3To PjBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=HUfgFIprVUaohi0BfIZClscA+LK1Se6MJEmPdsrrDco=; b=Oj3QihixA8Rw4c9wEGiTBWZVdjDw8XicWi3g1XdlG3iofx4Jmkry9H6sWlAEFSlpFS 7ZPojR/qeWedNccOW/LSrorEjP1COn71kaEhq8gHrUbBrSz/VAqBvwlpYxjLDKrYWiTA t7UuZDVBIQ1h9K1+LM+BckgnjD3n095OiwKTKKS9weWZmYtcvjPyxFgjGY1VG3H/YpX7 2WdmZ1YudxhpJKiQW0r4dbE/QlbvQ/eYdJYEFfhEeKbJITJOGFOd8XxZjEe+7oL0hkDK P8Xb9rN+n7Ph+xtz0Kx8m9yVEQpgiZnQkOo+oXv668uVoe06lB5tediqHkvbKv/X+0X6 UHbw== X-Gm-Message-State: AMke39kz0CPtb3J3QkLKhSbyux7LG1CCYcFW1F//trEbLRxVYw2h4+APkytKc3qqZopSKg== X-Received: by 10.28.55.199 with SMTP id e190mr18387384wma.92.1487600301478; Mon, 20 Feb 2017 06:18:21 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id o2sm24932276wra.42.2017.02.20.06.18.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Feb 2017 06:18:16 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: david.marchand@6wind.com, shreyansh.jain@nxp.com, ferruh.yigit@intel.com Date: Mon, 20 Feb 2017 15:17:35 +0100 Message-Id: <1487600262-14382-2-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487600262-14382-1-git-send-email-jblunck@infradead.org> References: <1487600262-14382-1-git-send-email-jblunck@infradead.org> In-Reply-To: <1487152929-23627-1-git-send-email-jblunck@infradead.org> References: <1487152929-23627-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v2 1/8] eal: use different constructor priorities for initcalls 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: Mon, 20 Feb 2017 14:18:21 -0000 This introduces different initcall macros to allow for late registration of the virtual device bus. Signed-off-by: Jan Blunck Tested-by: Ferruh Yigit --- lib/librte_eal/common/include/rte_bus.h | 17 ++++++++++++++++- lib/librte_eal/common/include/rte_eal.h | 12 ++++++++++-- lib/librte_eal/common/include/rte_tailq.h | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 7c36969..9f161f2 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -50,6 +50,7 @@ extern "C" { #include #include +#include #include #include @@ -145,7 +146,21 @@ void rte_bus_dump(FILE *f); * The constructor has higher priority than PMD constructors. */ #define RTE_REGISTER_BUS(nm, bus) \ -static void __attribute__((constructor(101), used)) businitfn_ ##nm(void) \ +RTE_EAL_INIT(businitfn_ ##nm); \ +static void businitfn_ ##nm(void) \ +{\ + (bus).name = RTE_STR(nm);\ + rte_bus_register(&bus); \ +} + +/** + * Helper for late Bus registration. + * The constructor still has higher priority than PMD constructors but has + * lower priority than RTE_REGISTER_BUS. + */ +#define RTE_REGISTER_BUS_LATE(nm, bus) \ +RTE_POST_EAL_INIT(businitfn_ ##nm); \ +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 03fee50..3a6bd71 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -258,8 +258,16 @@ static inline int rte_gettid(void) return RTE_PER_LCORE(_thread_id); } -#define RTE_INIT(func) \ -static void __attribute__((constructor, used)) func(void) +#define RTE_EAL_INIT(func) \ +static void __attribute__((constructor(101), used)) func(void) + +#define RTE_POST_EAL_INIT(func) \ +static void __attribute__((constructor(102), used)) func(void) + +#define RTE_DEV_INIT(func) \ +static void __attribute__((constructor(103), used)) func(void) + +#define RTE_INIT(func) RTE_DEV_INIT(func) #ifdef __cplusplus } diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h index 3aae098..07ceec1 100644 --- a/lib/librte_eal/common/include/rte_tailq.h +++ b/lib/librte_eal/common/include/rte_tailq.h @@ -148,7 +148,7 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name); int rte_eal_tailq_register(struct rte_tailq_elem *t); #define EAL_REGISTER_TAILQ(t) \ -RTE_INIT(tailqinitfn_ ##t); \ +RTE_EAL_INIT(tailqinitfn_ ##t); \ static void tailqinitfn_ ##t(void) \ { \ if (rte_eal_tailq_register(&t) < 0) \ -- 2.7.4