[dpdk-dev,v2,14/18] net/failsafe: keep legacy sub-device declaration

Message ID bc9f9e8477b54fa894e76d69fdc9885f0651b487.1507796100.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Gaëtan Rivet Oct. 12, 2017, 8:21 a.m. UTC
  Allow users to use the same sub-device declaration format.

The rte_devargs library now requires the bus name to be prepended to
device declarations. While it is possible to use this new format, the
transition to the new one can be made smoother.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/failsafe/failsafe_args.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c
index 08ce4ad..0c98264 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -34,6 +34,7 @@ 
 #include <string.h>
 #include <errno.h>
 
+#include <rte_bus.h>
 #include <rte_debug.h>
 #include <rte_devargs.h>
 #include <rte_malloc.h>
@@ -83,12 +84,20 @@  closing_paren(const char *text)
 static int
 fs_parse_device(struct sub_device *sdev, char *args)
 {
+	struct rte_bus *bus;
 	struct rte_devargs *d;
 	int ret;
 
 	d = &sdev->devargs;
 	DEBUG("%s", args);
-	ret = rte_eal_devargs_parse(d, "%s", args);
+	bus = rte_bus_find_by_device_name(args);
+	if (bus == NULL)
+		/* args may contain the bus name */
+		ret = rte_eal_devargs_parse(d, "%s", args);
+	else
+		/* args is a device name */
+		ret = rte_eal_devargs_parse(d, "%s:%s",
+					bus->name, args);
 	if (ret) {
 		DEBUG("devargs parsing failed with code %d", ret);
 		return ret;