All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [PATCH v3 10/10] devargs: rename legacy API
Date: Wed, 21 Mar 2018 00:20:11 +0100	[thread overview]
Message-ID: <df1accbdc7a6dae966ab176bdb7265323a8d55b1.1521587199.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1521587199.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1521587199.git.gaetan.rivet@6wind.com>

This previous symbols were deprecated for two releases.
They are now marked as such and cannot be used anymore.

They are replaced by ones respecting the new namespace that are marked
experimental.

As a result, eth_dev attach and detach is slightly reworked to follow
the changes.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/cmdline.c                      |  2 +-
 drivers/net/vdev_netvsc/vdev_netvsc.c       |  2 +-
 examples/bond/Makefile                      |  1 +
 examples/bond/main.c                        |  2 +-
 lib/librte_eal/common/eal_common_devargs.c  |  9 +++--
 lib/librte_eal/common/eal_common_options.c  |  2 +-
 lib/librte_eal/common/include/rte_devargs.h | 54 +++++++++++++++++++++++++++++
 lib/librte_eal/rte_eal_version.map          |  3 ++
 lib/librte_ether/rte_ethdev.c               | 44 +++++++++++------------
 test/test/commands.c                        |  2 +-
 10 files changed, 89 insertions(+), 32 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 40b31ad7e..6e6b4e2e2 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -8621,7 +8621,7 @@ static void cmd_dump_parsed(void *parsed_result,
 	else if (!strcmp(res->dump, "dump_mempool"))
 		rte_mempool_list_dump(stdout);
 	else if (!strcmp(res->dump, "dump_devargs"))
-		rte_eal_devargs_dump(stdout);
+		rte_devargs_dump(stdout);
 	else if (!strcmp(res->dump, "dump_log_types"))
 		rte_log_dump(stdout);
 }
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index b0bbce750..f4e88689f 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -740,7 +740,7 @@ vdev_netvsc_scan_callback(__rte_unused void *arg)
 		vdev_netvsc_cmp_rte_device, VDEV_NETVSC_DRIVER_NAME);
 	if (dev)
 		return;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME))
+	if (rte_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME))
 		DRV_LOG(ERR, "unable to add netvsc devargs.");
 }
 
diff --git a/examples/bond/Makefile b/examples/bond/Makefile
index 44d10d4f5..ce3f907de 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -59,6 +59,7 @@ CFLAGS_main.o += -Wno-return-type
 endif
 
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 LDLIBS += -lrte_pmd_bond
diff --git a/examples/bond/main.c b/examples/bond/main.c
index 455f108ee..ede1c591e 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -742,7 +742,7 @@ main(int argc, char *argv[])
 
 	/* init EAL */
 	ret = rte_eal_init(argc, argv);
-	rte_eal_devargs_dump(stdout);
+	rte_devargs_dump(stdout);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Error with EAL initialization\n");
 	argc -= ret;
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 24d0f6f44..b0434158b 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -137,8 +137,9 @@ rte_devargs_insert(struct rte_devargs *da)
 }
 
 /* store a whitelist parameter for later parsing */
+__rte_experimental
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 {
 	struct rte_devargs *devargs = NULL;
 	struct rte_bus *bus = NULL;
@@ -192,8 +193,9 @@ rte_devargs_remove(const char *busname, const char *devname)
 }
 
 /* count the number of devices of a specified type */
+__rte_experimental
 unsigned int
-rte_eal_devargs_type_count(enum rte_devtype devtype)
+rte_devargs_type_count(enum rte_devtype devtype)
 {
 	struct rte_devargs *devargs;
 	unsigned int count = 0;
@@ -207,8 +209,9 @@ rte_eal_devargs_type_count(enum rte_devtype devtype)
 }
 
 /* dump the user devices on the console */
+__rte_experimental
 void
-rte_eal_devargs_dump(FILE *f)
+rte_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 9f2f8d25a..63df21224 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -151,7 +151,7 @@ eal_option_device_parse(void)
 
 	TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
 		if (ret == 0) {
-			ret = rte_eal_devargs_add(devopt->type, devopt->arg);
+			ret = rte_devargs_add(devopt->type, devopt->arg);
 			if (ret)
 				RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
 					devopt->arg);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 07a4701b2..3ba1f2084 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -60,6 +60,7 @@ struct rte_devargs {
 };
 
 /**
+ * @deprecated
  * Parse a devargs string.
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
@@ -84,6 +85,7 @@ struct rte_devargs {
  *   - 0 on success
  *   - A negative value on error
  */
+__rte_deprecated
 int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
@@ -146,6 +148,32 @@ rte_devargs_insert(struct rte_devargs *da);
  *   - 0 on success
  *   - A negative value on error
  */
+__rte_experimental
+int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
+
+/**
+ * @deprecated
+ * Add a device to the user device list
+ *
+ * The format is
+ *
+ *     bus:device_identifier,arg1=val1,arg2=val2
+ *
+ * Examples:
+ *
+ *     pci:0000:05.00.0,arg=val
+ *     vdev:net_ring0
+ *
+ * @param devtype
+ *   The type of the device.
+ * @param devargs_str
+ *   The arguments as given by the user.
+ *
+ * @return
+ *   - 0 on success
+ *   - A negative value on error
+ */
+__rte_deprecated
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
@@ -177,6 +205,21 @@ int rte_devargs_remove(const char *busname,
  * @return
  *   The number of devices.
  */
+__rte_experimental
+unsigned int
+rte_devargs_type_count(enum rte_devtype devtype);
+
+/**
+ * @deprecated
+ * Count the number of user devices of a specified type
+ *
+ * @param devtype
+ *   The type of the devices to counted.
+ *
+ * @return
+ *   The number of devices.
+ */
+__rte_deprecated
 unsigned int
 rte_eal_devargs_type_count(enum rte_devtype devtype);
 
@@ -186,6 +229,17 @@ rte_eal_devargs_type_count(enum rte_devtype devtype);
  * @param f
  *   A pointer to a file for output
  */
+__rte_experimental
+void rte_devargs_dump(FILE *f);
+
+/**
+ * @deprecated
+ * This function dumps the list of user device and their arguments.
+ *
+ * @param f
+ *   A pointer to a file for output
+ */
+__rte_deprecated
 void rte_eal_devargs_dump(FILE *f);
 
 /**
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 1e614f088..bc24237e1 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -214,10 +214,13 @@ EXPERIMENTAL {
 	global:
 
 	rte_eal_cleanup;
+	rte_devargs_add;
+	rte_devargs_dump;
 	rte_devargs_insert;
 	rte_devargs_next;
 	rte_devargs_parse;
 	rte_devargs_remove;
+	rte_devargs_type_count;
 	rte_eal_hotplug_add;
 	rte_eal_hotplug_remove;
 	rte_eal_mbuf_user_pool_ops;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0590f0c10..027d5b535 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -596,27 +596,26 @@ eth_err(uint16_t port_id, int ret)
 int
 rte_eth_dev_attach(const char *devargs, uint16_t *port_id)
 {
-	int ret = -1;
 	int current = rte_eth_dev_count();
-	char *name = NULL;
-	char *args = NULL;
+	struct rte_devargs da = {0};
+	int ret = -1;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	/* parse devargs, then retrieve device name and args */
-	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+	/* parse devargs */
+	if (rte_devargs_parse(&da, "%s", devargs))
 		goto err;
 
-	ret = rte_eal_dev_attach(name, args);
+	ret = rte_eal_hotplug_add(da.bus->name, da.name, da.args);
 	if (ret < 0)
 		goto err;
 
 	/* no point looking at the port count if no port exists */
 	if (!rte_eth_dev_count()) {
-		RTE_LOG(ERR, EAL, "No port found for device (%s)\n", name);
+		RTE_LOG(ERR, EAL, "No port found for device (%s)\n", da.name);
 		ret = -1;
 		goto err;
 	}
@@ -633,45 +632,42 @@ rte_eth_dev_attach(const char *devargs, uint16_t *port_id)
 	ret = 0;
 
 err:
-	free(name);
-	free(args);
+	free(da.args);
 	return ret;
 }
 
 /* detach the device, then store the name of the device */
 int
-rte_eth_dev_detach(uint16_t port_id, char *name)
+rte_eth_dev_detach(uint16_t port_id, char *name __rte_unused)
 {
+	struct rte_device *dev;
+	struct rte_bus *bus;
 	uint32_t dev_flags;
 	int ret = -1;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
-	if (name == NULL) {
-		ret = -EINVAL;
-		goto err;
-	}
-
 	dev_flags = rte_eth_devices[port_id].data->dev_flags;
 	if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
 		RTE_LOG(ERR, EAL, "Port %" PRIu16 " is bonded, cannot detach\n",
 			port_id);
-		ret = -ENOTSUP;
-		goto err;
+		return -ENOTSUP;
 	}
 
-	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
-		 "%s", rte_eth_devices[port_id].data->name);
+	dev = rte_eth_devices[port_id].device;
+	if (dev == NULL)
+		return -EINVAL;
 
-	ret = rte_eal_dev_detach(rte_eth_devices[port_id].device);
+	bus = rte_bus_find_by_device(dev);
+	if (bus == NULL)
+		return -ENOENT;
+
+	ret = rte_eal_hotplug_remove(bus->name, dev->name);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	rte_eth_dev_release_port(&rte_eth_devices[port_id]);
 	return 0;
-
-err:
-	return ret;
 }
 
 static int
diff --git a/test/test/commands.c b/test/test/commands.c
index cf0b726bb..2ae78a3d0 100644
--- a/test/test/commands.c
+++ b/test/test/commands.c
@@ -132,7 +132,7 @@ static void cmd_dump_parsed(void *parsed_result,
 	else if (!strcmp(res->dump, "dump_mempool"))
 		rte_mempool_list_dump(stdout);
 	else if (!strcmp(res->dump, "dump_devargs"))
-		rte_eal_devargs_dump(stdout);
+		rte_devargs_dump(stdout);
 	else if (!strcmp(res->dump, "dump_log_types"))
 		rte_log_dump(stdout);
 	else if (!strcmp(res->dump, "dump_malloc_stats"))
-- 
2.11.0

  parent reply	other threads:[~2018-03-20 23:20 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 16:07 [PATCH 0/6] devargs cleanup Gaetan Rivet
2017-08-25 16:07 ` [PATCH 1/6] devargs: introduce iterator Gaetan Rivet
2017-08-25 16:07 ` [PATCH 2/6] devargs: introduce foreach macro Gaetan Rivet
2017-08-25 16:07 ` [PATCH 3/6] vdev: do not reference devargs_list Gaetan Rivet
2017-08-25 16:07 ` [PATCH 4/6] bus/pci: " Gaetan Rivet
2017-08-25 16:07 ` [PATCH 5/6] test: remove rte_devargs unit tests Gaetan Rivet
2017-08-25 16:07 ` [PATCH 6/6] devargs: make devargs_list private Gaetan Rivet
2017-10-12  8:21 ` [PATCH v2 00/18] devargs cleanup Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 01/18] eal: prepend busname on legacy device declaration Gaetan Rivet
2017-12-11 13:57     ` Shreyansh Jain
2017-10-12  8:21   ` [PATCH v2 02/18] eal: remove generic devtype Gaetan Rivet
2017-10-17 18:16     ` Aaron Conole
2017-10-18  8:20       ` Gaëtan Rivet
2017-10-12  8:21   ` [PATCH v2 03/18] devargs: introduce iterator Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 04/18] devargs: introduce foreach macro Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 05/18] vdev: do not reference devargs list Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 06/18] bus/pci: " Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 07/18] test: remove devargs unit tests Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 08/18] devargs: make devargs list private Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 09/18] devargs: make parsing variadic Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 10/18] devargs: require bus name prefix Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 11/18] devargs: simplify implementation Gaetan Rivet
2017-10-16 11:39     ` Shreyansh Jain
2017-10-16 11:42       ` Shreyansh Jain
2017-10-16 13:42         ` Gaëtan Rivet
2017-10-17  5:58           ` Shreyansh Jain
2017-10-12  8:21   ` [PATCH v2 12/18] eal: add generic device declaration parameter Gaetan Rivet
2017-12-13 14:26     ` Shreyansh Jain
2017-12-13 14:47       ` Gaëtan Rivet
2017-12-13 15:24         ` Shreyansh Jain
2017-10-12  8:21   ` [PATCH v2 13/18] bus: make device recognition function public Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 14/18] net/failsafe: keep legacy sub-device declaration Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 15/18] ether: use new devargs parsing function Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 16/18] devargs: remove old " Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 17/18] devargs: use proper prefix Gaetan Rivet
2017-10-12  8:21   ` [PATCH v2 18/18] doc: remove devargs deprecation notices Gaetan Rivet
2017-10-12 11:28     ` Mcnamara, John
2017-12-13 10:17     ` Shreyansh Jain
2017-12-13 10:25       ` Gaëtan Rivet
2017-12-13 10:54         ` Shreyansh Jain
2017-12-22  4:59           ` Shreyansh Jain
2017-12-22  8:33             ` Gaëtan Rivet
2017-10-17 18:18   ` [PATCH v2 00/18] devargs cleanup Aaron Conole
2017-10-18  8:36     ` Gaëtan Rivet
2018-03-20 23:20   ` [PATCH v3 00/10] " Gaetan Rivet
2018-03-20 23:20     ` [PATCH v3 01/10] devargs: introduce iterator Gaetan Rivet
2018-03-21  5:43       ` Tan, Jianfeng
2018-03-21  8:50         ` Gaëtan Rivet
2018-03-20 23:20     ` [PATCH v3 02/10] devargs: introduce foreach macro Gaetan Rivet
2018-04-22 21:42       ` Thomas Monjalon
2018-03-20 23:20     ` [PATCH v3 03/10] bus/vdev: do not reference devargs list Gaetan Rivet
2018-03-21  5:41       ` Tan, Jianfeng
2018-03-20 23:20     ` [PATCH v3 04/10] bus/pci: " Gaetan Rivet
2018-03-20 23:20     ` [PATCH v3 05/10] net/vdev_netvsc: " Gaetan Rivet
2018-03-20 23:20     ` [PATCH v3 06/10] test: remove devargs unit tests Gaetan Rivet
2018-03-20 23:20     ` [PATCH v3 07/10] devargs: make devargs list private Gaetan Rivet
2018-04-22 21:46       ` Thomas Monjalon
2018-03-20 23:20     ` [PATCH v3 08/10] devargs: make parsing variadic Gaetan Rivet
2018-04-22 21:52       ` Thomas Monjalon
2018-03-20 23:20     ` [PATCH v3 09/10] devargs: use proper namespace prefix Gaetan Rivet
2018-03-20 23:20     ` Gaetan Rivet [this message]
2018-04-22 22:00     ` [PATCH v3 00/10] devargs cleanup Thomas Monjalon
2018-04-23 22:41 ` [PATCH v4 " Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 01/10] devargs: introduce iterator Gaetan Rivet
2018-04-23 23:54     ` Stephen Hemminger
2018-04-24 10:22       ` Gaëtan Rivet
2018-04-23 22:41   ` [PATCH v4 02/10] devargs: introduce foreach macro Gaetan Rivet
2018-04-23 23:56     ` Stephen Hemminger
2018-04-24 10:26       ` Gaëtan Rivet
2018-04-23 22:41   ` [PATCH v4 03/10] bus/vdev: do not reference devargs list Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 04/10] bus/pci: " Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 05/10] net/vdev_netvsc: " Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 06/10] test: remove devargs unit tests Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 07/10] devargs: make devargs list private Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 08/10] devargs: make parsing variadic Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 09/10] devargs: use proper namespace prefix Gaetan Rivet
2018-04-23 22:41   ` [PATCH v4 10/10] devargs: rename legacy API Gaetan Rivet
2018-04-23 23:54 ` [PATCH v5 00/10] devargs cleanup Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 01/10] devargs: introduce iterator Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 02/10] bus/vdev: do not reference devargs list Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 03/10] bus/pci: " Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 04/10] net/vdev_netvsc: " Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 05/10] test: remove devargs unit tests Gaetan Rivet
2018-04-25  0:45     ` Thomas Monjalon
2018-04-23 23:54   ` [PATCH v5 06/10] devargs: make devargs list private Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 07/10] devargs: make parsing variadic Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 08/10] devargs: update devargs add documentation Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 09/10] devargs: use proper namespace prefix Gaetan Rivet
2018-04-23 23:54   ` [PATCH v5 10/10] devargs: rename legacy API Gaetan Rivet
2018-04-25  1:51     ` Thomas Monjalon
2018-04-25  1:57   ` [PATCH v5 00/10] devargs cleanup Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df1accbdc7a6dae966ab176bdb7265323a8d55b1.1521587199.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.