From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7851A0524; Fri, 8 Jan 2021 15:56:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 79DD4141031; Fri, 8 Jan 2021 15:55:24 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id A7EBE140FE2 for ; Fri, 8 Jan 2021 15:55:21 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 8 Jan 2021 16:55:19 +0200 Received: from nvidia.com ([172.27.8.145]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 108Et0X2013726; Fri, 8 Jan 2021 16:55:17 +0200 From: Xueming Li To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso Date: Fri, 8 Jan 2021 22:54:40 +0800 Message-Id: <20210108145441.23320-7-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 6/7] devargs: support new global device syntax X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When parsing a device syntax, try to parse new global syntax firstly, then try to parse as legacy syntax if failed. Example of new global syntax: -a bus=pci,addr=82:00.0/class=eth/driver=mlx5,dv_flow_en=1 Signed-off-by: Xueming Li --- lib/librte_eal/common/eal_common_devargs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index e1a3cd7367..a79eea12d3 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -57,6 +57,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, struct rte_class *cls = NULL; struct rte_bus *bus = NULL; const char *s = devstr; + const char *id; size_t nblayer; size_t i = 0; int ret = 0; @@ -116,6 +117,8 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, if (layers[i].kvlist == NULL) continue; kv = &layers[i].kvlist->pairs[0]; + if (!kv->key) + continue; if (strcmp(kv->key, "bus") == 0) { bus = rte_bus_find_by_name(kv->value); if (bus == NULL) { @@ -124,6 +127,14 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, ret = -EFAULT; goto get_out; } + id = rte_kvargs_get(layers[i].kvlist, "id"); + if (!id) { + RTE_LOG(ERR, EAL, "Could not find bus id \"%s\"\n", + devstr); + ret = -EFAULT; + goto get_out; + } + strncpy(devargs->name, id, sizeof(devargs->name) - 1); } else if (strcmp(kv->key, "class") == 0) { cls = rte_class_find_by_name(kv->value); if (cls == NULL) { @@ -190,6 +201,12 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev) if (da == NULL) return -EINVAL; + /* First parse according new global syntax */ + if (rte_devargs_layers_parse(da, dev) == 0 && da->bus && da->cls) + return 0; + + /* Legacy syntax check: */ + /* Retrieve eventual bus info */ do { devname = dev; -- 2.25.1