From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaetan Rivet Subject: [PATCH v4 3/8] devargs: introduce insert function Date: Sat, 15 Jul 2017 19:56:37 +0200 Message-ID: <94b54d46d4e1e0472ca6dd1287fc1fada703f1f0.1499964391.git.gaetan.rivet@6wind.com> References: Cc: Gaetan Rivet To: dev@dpdk.org Return-path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id BFE8B559A for ; Sat, 15 Jul 2017 19:57:02 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id f67so49032412wmh.1 for ; Sat, 15 Jul 2017 10:57:02 -0700 (PDT) In-Reply-To: In-Reply-To: References: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Some buses will operate either in whitelist or blacklist mode. This mode is currently passed down by the rte_eal_devargs_add function with the devtype argument. When inserting devices using the hotplug API, the implicit assumption is that this device is being whitelisted, meaning that it is explicitly requested by the application to be used. This can conflict with the initial bus configuration. While the rte_eal_devargs_add API is being deprecated soon, it cannot be modified at the moment to accomodate this situation. As such, this new experimental API offers a bare interface for inserting rte_devargs without directly manipulating the global rte_devargs list. This new function expects a fully-formed rte_devargs, previously parsed and allocated. It does not check whether the new rte_devargs is compatible with current bus configuration, but will replace any eventual existing one for the same device, allowing the hotplug operation to proceed. i.e. a previously blacklisted device can be redefined as being whitelisted. Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 12 ++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 13 +++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 27 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 40cd523..8b24309 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -206,6 +206,7 @@ DPDK_17.08 { EXPERIMENTAL { global: + rte_eal_devargs_insert; rte_eal_devargs_parse; rte_eal_devargs_remove; rte_eal_hotplug_add; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index bcdee13..ff6c2a8 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -138,6 +138,18 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da) return 0; } +int +rte_eal_devargs_insert(struct rte_devargs *da) +{ + int ret; + + ret = rte_eal_devargs_remove(da->bus->name, da->name); + if (ret < 0) + return ret; + TAILQ_INSERT_TAIL(&devargs_list, da, next); + return 0; +} + /* store a whitelist parameter for later parsing */ int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 36453b6..7b63fa3 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -139,6 +139,19 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da); /** + * Insert an rte_devargs in the global list. + * + * @param da + * The devargs structure to insert. + * + * @return + * - 0 on success + * - Negative on error. + */ +int +rte_eal_devargs_insert(struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index a8ee349..81f6af3 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -211,6 +211,7 @@ DPDK_17.08 { EXPERIMENTAL { global: + rte_eal_devargs_insert; rte_eal_devargs_parse; rte_eal_devargs_remove; rte_eal_hotplug_add; -- 2.1.4