From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C9DE1A09FD; Fri, 18 Dec 2020 16:19:17 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 93BDCCBA8; Fri, 18 Dec 2020 16:17:21 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 6213DCB1A for ; Fri, 18 Dec 2020 16:17:10 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 17:17:05 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BIFH4qe010856; Fri, 18 Dec 2020 17:17:04 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 15:16:51 +0000 Message-Id: <1608304614-13908-7-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 6/9] devargs: support new global device syntax 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: , 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