From b344eb5d941a7522ff27b6b7b5419f68c3fea9a0 Mon Sep 17 00:00:00 2001 From: Xueming Li Date: Tue, 13 Apr 2021 03:14:12 +0000 Subject: [PATCH] devargs: parse global device syntax When parsing a devargs, try to parse using the global device syntax first. Fallback on legacy syntax on error. Example of new global device syntax: -a bus=pci,addr=82:00.0/class=eth/driver=mlx5,dv_flow_en=1 Signed-off-by: Xueming Li Reviewed-by: Gaetan Rivet --- doc/guides/rel_notes/release_21_11.rst | 7 +++++++ lib/eal/common/eal_common_devargs.c | 10 +++++++++- lib/ethdev/rte_ethdev.c | 1 - 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index d707a554ef..675b573834 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Enabled new devargs parser.** + + * Enabled devargs syntax + ``bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z`` + * Added bus-level parsing of the devargs syntax. + * Kept compatibility with the legacy syntax as parsing fallback. + Removed Items ------------- diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c index d0c6d5c2a9..7ab9e71b2a 100644 --- a/lib/eal/common/eal_common_devargs.c +++ b/lib/eal/common/eal_common_devargs.c @@ -125,7 +125,6 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, layers[i].str = s; layers[i].kvlist = rte_kvargs_parse_delim(s, NULL, "/"); if (layers[i].kvlist == NULL) { - RTE_LOG(ERR, EAL, "Could not parse %s\n", s); ret = -EINVAL; goto get_out; } @@ -224,6 +223,15 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev) if (da == NULL) return -EINVAL; + /* First parse according global device syntax. */ + if (rte_devargs_layers_parse(da, dev) == 0) { + if (da->bus != NULL || da->cls != NULL) + return 0; + rte_devargs_reset(da); + } + + /* Otherwise fallback to legacy syntax: */ + /* Retrieve eventual bus info */ do { devname = dev; diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 9d95cd11e1..daf5ca9242 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -214,7 +214,6 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) * - 0000:08:00.0,representor=[1-3] * - pci:0000:06:00.0,representor=[0,5] * - class=eth,mac=00:11:22:33:44:55 - * A new syntax is in development (not yet supported): * - bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z */ -- 2.20.1