git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/szedata2: remove unused macro
[dpdk.git]
/
lib
/
librte_eal
/
common
/
eal_common_vdev.c
diff --git
a/lib/librte_eal/common/eal_common_vdev.c
b/lib/librte_eal/common/eal_common_vdev.c
index
c922297
..
baf3c5b
100644
(file)
--- a/
lib/librte_eal/common/eal_common_vdev.c
+++ b/
lib/librte_eal/common/eal_common_vdev.c
@@
-35,14
+35,17
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <stdbool.h>
#include <sys/queue.h>
#include <rte_eal.h>
#include <sys/queue.h>
#include <rte_eal.h>
+#include <rte_dev.h>
#include <rte_bus.h>
#include <rte_vdev.h>
#include <rte_common.h>
#include <rte_devargs.h>
#include <rte_memory.h>
#include <rte_bus.h>
#include <rte_vdev.h>
#include <rte_common.h>
#include <rte_devargs.h>
#include <rte_memory.h>
+#include <rte_errno.h>
/** Double linked list of virtual device drivers. */
TAILQ_HEAD(vdev_device_list, rte_vdev_device);
/** Double linked list of virtual device drivers. */
TAILQ_HEAD(vdev_device_list, rte_vdev_device);
@@
-52,32
+55,65
@@
static struct vdev_device_list vdev_device_list =
struct vdev_driver_list vdev_driver_list =
TAILQ_HEAD_INITIALIZER(vdev_driver_list);
struct vdev_driver_list vdev_driver_list =
TAILQ_HEAD_INITIALIZER(vdev_driver_list);
-static void rte_vdev_bus_register(void);
-
/* register a driver */
void
/* register a driver */
void
-rte_
eal_vdr
v_register(struct rte_vdev_driver *driver)
+rte_
vde
v_register(struct rte_vdev_driver *driver)
{
{
- rte_vdev_bus_register();
-
TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
- rte_eal_driver_register(&driver->driver);
}
/* unregister a driver */
void
}
/* unregister a driver */
void
-rte_
eal_vdr
v_unregister(struct rte_vdev_driver *driver)
+rte_
vde
v_unregister(struct rte_vdev_driver *driver)
{
{
- rte_eal_driver_unregister(&driver->driver);
TAILQ_REMOVE(&vdev_driver_list, driver, next);
}
TAILQ_REMOVE(&vdev_driver_list, driver, next);
}
+/*
+ * Parse "driver" devargs without adding a dependency on rte_kvargs.h
+ */
+static char *parse_driver_arg(const char *args)
+{
+ const char *c;
+ char *str;
+
+ if (!args || args[0] == '\0')
+ return NULL;
+
+ c = args;
+
+ do {
+ if (strncmp(c, "driver=", 7) == 0) {
+ c += 7;
+ break;
+ }
+
+ c = strchr(c, ',');
+ if (c)
+ c++;
+ } while (c);
+
+ if (c)
+ str = strdup(c);
+ else
+ str = NULL;
+
+ return str;
+}
+
static int
vdev_probe_all_drivers(struct rte_vdev_device *dev)
{
static int
vdev_probe_all_drivers(struct rte_vdev_device *dev)
{
- const char *name = rte_vdev_device_name(dev);
+ const char *name;
+ char *drv_name;
struct rte_vdev_driver *driver;
struct rte_vdev_driver *driver;
- int ret;
+ int ret = 1;
+
+ drv_name = parse_driver_arg(rte_vdev_device_args(dev));
+ name = drv_name ? drv_name : rte_vdev_device_name(dev);
+
+ RTE_LOG(DEBUG, EAL, "Search driver %s to probe device %s\n", name,
+ rte_vdev_device_name(dev));
TAILQ_FOREACH(driver, &vdev_driver_list, next) {
/*
TAILQ_FOREACH(driver, &vdev_driver_list, next) {
/*
@@
-92,7
+128,7
@@
vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver->probe(dev);
if (ret)
dev->device.driver = NULL;
ret = driver->probe(dev);
if (ret)
dev->device.driver = NULL;
-
return re
t;
+
goto ou
t;
}
}
}
}
@@
-105,11
+141,13
@@
vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver->probe(dev);
if (ret)
dev->device.driver = NULL;
ret = driver->probe(dev);
if (ret)
dev->device.driver = NULL;
-
return ret
;
+
break
;
}
}
}
}
- return 1;
+out:
+ free(drv_name);
+ return ret;
}
static struct rte_vdev_device *
}
static struct rte_vdev_device *
@@
-155,7
+193,7
@@
alloc_devargs(const char *name, const char *args)
}
int
}
int
-rte_
eal_
vdev_init(const char *name, const char *args)
+rte_vdev_init(const char *name, const char *args)
{
struct rte_vdev_device *dev;
struct rte_devargs *devargs;
{
struct rte_vdev_device *dev;
struct rte_devargs *devargs;
@@
-191,7
+229,6
@@
rte_eal_vdev_init(const char *name, const char *args)
TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
- rte_eal_device_insert(&dev->device);
TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
return 0;
TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
return 0;
@@
-219,7
+256,7
@@
vdev_remove_driver(struct rte_vdev_device *dev)
}
int
}
int
-rte_
eal_
vdev_uninit(const char *name)
+rte_vdev_uninit(const char *name)
{
struct rte_vdev_device *dev;
struct rte_devargs *devargs;
{
struct rte_vdev_device *dev;
struct rte_devargs *devargs;
@@
-239,7
+276,6
@@
rte_eal_vdev_uninit(const char *name)
return ret;
TAILQ_REMOVE(&vdev_device_list, dev, next);
return ret;
TAILQ_REMOVE(&vdev_device_list, dev, next);
- rte_eal_device_remove(&dev->device);
TAILQ_REMOVE(&devargs_list, devargs, next);
TAILQ_REMOVE(&devargs_list, devargs, next);
@@
-274,7
+310,6
@@
vdev_scan(void)
dev->device.numa_node = SOCKET_ID_ANY;
dev->device.name = devargs->virt.drv_name;
dev->device.numa_node = SOCKET_ID_ANY;
dev->device.name = devargs->virt.drv_name;
- rte_eal_device_insert(&dev->device);
TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
}
TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
}
@@
-286,12
+321,6
@@
vdev_probe(void)
{
struct rte_vdev_device *dev;
{
struct rte_vdev_device *dev;
- /*
- * Note that the dev_driver_list is populated here
- * from calls made to rte_eal_driver_register from constructor functions
- * embedded into PMD modules via the RTE_PMD_REGISTER_VDEV macro
- */
-
/* call the init function for each virtual device */
TAILQ_FOREACH(dev, &vdev_device_list, next) {
/* call the init function for each virtual device */
TAILQ_FOREACH(dev, &vdev_device_list, next) {
@@
-308,21
+337,41
@@
vdev_probe(void)
return 0;
}
return 0;
}
-static struct rte_bus rte_vdev_bus = {
- .scan = vdev_scan,
- .probe = vdev_probe,
-};
+static struct rte_device *
+vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
+ const void *data)
+{
+ struct rte_vdev_device *dev;
+ bool start_found = !start;
-RTE_INIT(rte_vdev_bus_register);
+ TAILQ_FOREACH(dev, &vdev_device_list, next) {
+ if (start_found == 0) {
+ if (&dev->device == start)
+ start_found = 1;
+ continue;
+ }
+ if (cmp(&dev->device, data) == 0)
+ return &dev->device;
+ }
+ return NULL;
+}
-static void rte_vdev_bus_register(void)
+static int
+vdev_unplug(struct rte_device *dev)
{
{
- static int registered;
+ /*
+ * The virtual bus doesn't support 'unattached' devices so this is
+ * actually equal to hotplugging removal of it.
+ */
+ return rte_vdev_uninit(dev->name);
+}
- if (registered)
- return;
+static struct rte_bus rte_vdev_bus = {
+ .scan = vdev_scan,
+ .probe = vdev_probe,
+ .find_device = vdev_find_device,
+ /* .plug = NULL, see comment on vdev_unplug */
+ .unplug = vdev_unplug,
+};
- registered = 1;
- rte_vdev_bus.name = RTE_STR(virtual);
- rte_bus_register(&rte_vdev_bus);
-}
+RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);