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 <xuemi...@nvidia.com>
---
 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

Reply via email to