[dpdk-dev,v2,09/15] devargs: add busname string field
Checks
Commit Message
This adds the busname as a string to struct rte_devargs. This is a generic
replacement for enum rte_devtype without tightly coupling rte_devargs to
the rte_bus structure.
Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
lib/librte_eal/common/eal_common_devargs.c | 9 +++++++++
lib/librte_eal/common/include/rte_devargs.h | 2 ++
test/test/test_devargs.c | 2 ++
3 files changed, 13 insertions(+)
@@ -128,6 +128,15 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da)
}
}
da->bus = bus;
+
+ /* Store bus name */
+ ret = snprintf(da->busname, sizeof(da->busname), "%s", bus->name);
+ if (ret < 0 || ret >= (int)sizeof(da->busname)) {
+ RTE_LOG(ERR, EAL, "Invalid bus name: \"%s\"\n", bus->name);
+ ret = -EINVAL;
+ goto fail;
+ }
+
ret = 0;
fail:
@@ -79,6 +79,8 @@ struct rte_devargs {
enum rte_devtype type;
/** Bus handle for the device. */
struct rte_bus *bus;
+ /** Name of the bus the device belongs to. */
+ char busname[RTE_DEV_NAME_MAX_LEN];
/** Name of the device. */
char name[RTE_DEV_NAME_MAX_LEN];
/** Arguments string as given by user or "" for no argument. */
@@ -135,6 +135,8 @@ test_devargs(void)
if (devargs != NULL)
goto fail;
devargs = &devargs_stack;
+ if (strcmp(devargs->busname, "pci") != 0)
+ goto fail;
if (strcmp(devargs->name, "08:00.1") != 0)
goto fail;
if (!devargs->args || strcmp(devargs->args, "foo=bar") != 0)