summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaetan Rivet <gaetan.rivet@6wind.com>2018-04-24 01:54:52 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-04-25 04:00:37 +0200
commitb65ecf1993247f90165923cd527edc798c2eeb43 (patch)
tree2de0257cdd7d0c1a67e8a9cceae801b4c2221800
parent8e6c3b795e4b1190d09444d99a6dd11b600d26fe (diff)
downloaddpdk-b65ecf1993247f90165923cd527edc798c2eeb43.zip
dpdk-b65ecf1993247f90165923cd527edc798c2eeb43.tar.gz
dpdk-b65ecf1993247f90165923cd527edc798c2eeb43.tar.xz
devargs: rename legacy API
The 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 are slightly reworked to follow the changes. Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com> Acked-by: Thomas Monjalon <thomas@monjalon.net>
-rw-r--r--app/test-pmd/cmdline.c2
-rw-r--r--doc/guides/rel_notes/deprecation.rst4
-rw-r--r--drivers/net/vdev_netvsc/vdev_netvsc.c2
-rw-r--r--examples/bond/Makefile1
-rw-r--r--examples/bond/main.c2
-rw-r--r--lib/librte_eal/common/eal_common_devargs.c9
-rw-r--r--lib/librte_eal/common/eal_common_options.c2
-rw-r--r--lib/librte_eal/common/include/rte_devargs.h46
-rw-r--r--lib/librte_eal/rte_eal_version.map3
-rw-r--r--lib/librte_ether/rte_ethdev.c46
-rw-r--r--test/test/commands.c2
11 files changed, 83 insertions, 36 deletions
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0b442c3..18470c6 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -8754,7 +8754,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/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index b35aef3..72ab33c 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -18,12 +18,8 @@ Deprecation Notices
- The enum ``rte_devtype`` was used to identify a bus and will disappear.
- Functions previously deprecated will change or disappear:
- + ``rte_eal_devargs_add``
+ ``rte_eal_devargs_type_count``
- + ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
+ ``rte_eal_devargs_parse`` will change its format and use.
- + all ``rte_devargs`` related functions will be renamed, changing the
- ``rte_eal_devargs_`` prefix to ``rte_devargs_``.
* pci: Several exposed functions are misnamed.
The following functions are deprecated starting from v17.11 and are replaced:
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 8b85711..f902dbe 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -803,7 +803,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 e7afce3..6b0324a 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -62,6 +62,7 @@ endif
CFLAGS += -DALLOW_EXPERIMENTAL_API
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 d8edc64..65e0edd 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 24d0f6f..b043415 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 40c5b26..e1a1a3c 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -153,7 +153,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 0806f23..58fbd90 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);
@@ -153,6 +155,24 @@ 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
+ * See rte_devargs_parse() for details.
+ *
+ * @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);
/**
@@ -184,6 +204,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);
@@ -193,6 +228,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 d33fbe9..42540ff 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -217,10 +217,13 @@ EXPERIMENTAL {
rte_dev_event_callback_unregister;
rte_dev_event_monitor_start;
rte_dev_event_monitor_stop;
+ rte_devargs_add;
+ rte_devargs_dump;
rte_devargs_insert;
rte_devargs_next;
rte_devargs_parse;
rte_devargs_remove;
+ rte_devargs_type_count;
rte_eal_cleanup;
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7821a88..f0f53d4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -618,27 +618,28 @@ 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_total();
- char *name = NULL;
- char *args = NULL;
+ struct rte_devargs da;
+ int ret = -1;
+
+ memset(&da, 0, sizeof(da));
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_total()) {
- ethdev_log(ERR, "No port found for device (%s)", name);
+ ethdev_log(ERR, "No port found for device (%s)", da.name);
ret = -1;
goto err;
}
@@ -656,45 +657,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) {
ethdev_log(ERR,
"Port %" PRIu16 " is bonded, cannot detach", 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;
+
+ bus = rte_bus_find_by_device(dev);
+ if (bus == NULL)
+ return -ENOENT;
- ret = rte_eal_dev_detach(rte_eth_devices[port_id].device);
+ 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 6bfdc02..94fbc31 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"))