]> git.droids-corp.org - dpdk.git/commitdiff
devargs: introduce removal function
authorGaetan Rivet <gaetan.rivet@6wind.com>
Sat, 15 Jul 2017 17:56:36 +0000 (19:56 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 19 Jul 2017 21:40:28 +0000 (00:40 +0300)
Hotplug support introduces the possibility of removing devices from the
system. Allocated resources must be freed.

Extend the rte_devargs API to allow freeing allocated resources.

This API is experimental and bound to change. It is currently designed
as a symetrical to rte_eal_devargs_add(), but the latter will evolve
shortly anyway.

Its DEVTYPE parameter is currently only used to specify scan policies,
and those will evolve in the next release. This evolution should
rationalize the rte_devargs API.

As such, the proposed API here is not the most convenient, but is
taylored to follow the current design and integrate easily with its main
use within rte_eal_hotplug_* functions.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
lib/librte_eal/bsdapp/eal/rte_eal_version.map
lib/librte_eal/common/eal_common_devargs.c
lib/librte_eal/common/include/rte_devargs.h
lib/librte_eal/linuxapp/eal/rte_eal_version.map

index 480ad234c113c58b68542b5fac17066463ff07f2..8a4f8588a9923d25b2f367f9b5e31fd2b634086f 100644 (file)
@@ -207,6 +207,7 @@ EXPERIMENTAL {
        global:
 
        rte_eal_devargs_parse;
+       rte_eal_devargs_remove;
        rte_eal_hotplug_add;
        rte_eal_hotplug_remove;
        rte_service_disable_on_lcore;
index 49d43a32856336b4cb3adf68db0553f3c461c463..bcdee131e709e2fc6b931b3e8db748be28a0e7f7 100644 (file)
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include <rte_devargs.h>
+#include <rte_tailq.h>
 #include "eal_private.h"
 
 /** Global list of user devices */
@@ -182,6 +183,24 @@ fail:
        return -1;
 }
 
+int
+rte_eal_devargs_remove(const char *busname, const char *devname)
+{
+       struct rte_devargs *d;
+       void *tmp;
+
+       TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) {
+               if (strcmp(d->bus->name, busname) == 0 &&
+                   strcmp(d->name, devname) == 0) {
+                       TAILQ_REMOVE(&devargs_list, d, next);
+                       free(d->args);
+                       free(d);
+                       return 0;
+               }
+       }
+       return 1;
+}
+
 /* count the number of devices of a specified type */
 unsigned int
 rte_eal_devargs_type_count(enum rte_devtype devtype)
index a0427cd8a7d3bb149803fca1b69b39cbd75c5d71..36453b6de8827b1f57afa4d3f175922db976a70b 100644 (file)
@@ -162,6 +162,24 @@ rte_eal_devargs_parse(const char *dev,
  */
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
+/**
+ * Remove a device from the user device list.
+ * Its resources are freed.
+ * If the devargs cannot be found, nothing happens.
+ *
+ * @param busname
+ *   bus name of the devargs to remove.
+ *
+ * @param devname
+ *   device name of the devargs to remove.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on error.
+ *   >0 if the devargs was not within the user device list.
+ */
+int rte_eal_devargs_remove(const char *busname, const char *devname);
+
 /**
  * Count the number of user devices of a specified type
  *
index fbaec39f78758d37f0eb70a1e8ea98657f3e51c1..9537be25c8b3a4fadaeb355e51496fa18e75ecec 100644 (file)
@@ -212,6 +212,7 @@ EXPERIMENTAL {
        global:
 
        rte_eal_devargs_parse;
+       rte_eal_devargs_remove;
        rte_eal_hotplug_add;
        rte_eal_hotplug_remove;
        rte_service_disable_on_lcore;