rmv_event_callback(void *arg)
{
struct rte_eth_dev *dev;
- struct rte_devargs *da;
- char name[32] = "";
uint8_t port_id = (intptr_t)arg;
RTE_ETH_VALID_PORTID_OR_RET(port_id);
dev = &rte_eth_devices[port_id];
- da = dev->device->devargs;
stop_port(port_id);
close_port(port_id);
- if (da->type == RTE_DEVTYPE_VIRTUAL)
- snprintf(name, sizeof(name), "%s", da->virt.drv_name);
- else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
- rte_pci_device_name(&da->pci.addr, name, sizeof(name));
- printf("removing device %s\n", name);
+ printf("removing device %s\n", dev->device->name);
rte_eal_dev_detach(dev->device);
dev->state = RTE_ETH_DEV_UNUSED;
}
#include <stdio.h>
#include <string.h>
-#include <rte_pci.h>
#include <rte_devargs.h>
#include "eal_private.h"
}
devargs->bus = bus;
- switch (devargs->type) {
- case RTE_DEVTYPE_WHITELISTED_PCI:
- case RTE_DEVTYPE_BLACKLISTED_PCI:
- /* try to parse pci identifier */
- if (bus->parse(devname, &devargs->pci.addr) != 0)
- goto fail;
-
- break;
- case RTE_DEVTYPE_VIRTUAL:
- /* save driver name */
- ret = snprintf(devargs->virt.drv_name,
- sizeof(devargs->virt.drv_name), "%s", devname);
- if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
- goto fail;
-
- break;
- }
+ /* save device name. */
+ ret = snprintf(devargs->name, sizeof(devargs->name), "%s", devname);
+ if (ret < 0 || ret >= (int)sizeof(devargs->name))
+ goto fail;
if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
{
struct rte_devargs *devargs;
- fprintf(f, "User device white list:\n");
+ fprintf(f, "User device list:\n");
TAILQ_FOREACH(devargs, &devargs_list, next) {
- if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
- fprintf(f, " PCI whitelist " PCI_PRI_FMT " %s\n",
- devargs->pci.addr.domain,
- devargs->pci.addr.bus,
- devargs->pci.addr.devid,
- devargs->pci.addr.function,
- devargs->args);
- else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
- fprintf(f, " PCI blacklist " PCI_PRI_FMT " %s\n",
- devargs->pci.addr.domain,
- devargs->pci.addr.bus,
- devargs->pci.addr.devid,
- devargs->pci.addr.function,
- devargs->args);
- else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
- fprintf(f, " VIRTUAL %s %s\n",
- devargs->virt.drv_name,
- devargs->args);
- else
- fprintf(f, " UNKNOWN %s\n", devargs->args);
+ fprintf(f, " [%s]: %s %s\n",
+ (devargs->bus ? devargs->bus->name : "??"),
+ devargs->name, devargs->args);
}
}
static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
{
struct rte_devargs *devargs;
+ struct rte_pci_addr addr;
+ struct rte_bus *pbus;
+ pbus = rte_bus_find_by_name("pci");
TAILQ_FOREACH(devargs, &devargs_list, next) {
- if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
- devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+ if (devargs->bus != pbus)
continue;
- if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+ devargs->bus->parse(devargs->name, &addr);
+ if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
return devargs;
}
return NULL;
if (args)
devargs->args = strdup(args);
- ret = snprintf(devargs->virt.drv_name,
- sizeof(devargs->virt.drv_name), "%s", name);
- if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+ ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+ if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
free(devargs->args);
free(devargs);
return NULL;
dev->device.devargs = devargs;
dev->device.numa_node = SOCKET_ID_ANY;
- dev->device.name = devargs->virt.drv_name;
+ dev->device.name = devargs->name;
ret = vdev_probe_all_drivers(dev);
if (ret) {
if (devargs->bus != vbus)
continue;
- dev = find_vdev(devargs->virt.drv_name);
+ dev = find_vdev(devargs->name);
if (dev)
continue;
dev->device.devargs = devargs;
dev->device.numa_node = SOCKET_ID_ANY;
- dev->device.name = devargs->virt.drv_name;
+ dev->device.name = devargs->name;
TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
}
#include <stdio.h>
#include <sys/queue.h>
-#include <rte_pci.h>
#include <rte_bus.h>
/**
TAILQ_ENTRY(rte_devargs) next;
/** Type of device. */
enum rte_devtype type;
- RTE_STD_C11
- union {
- /** Used if type is RTE_DEVTYPE_*_PCI. */
- struct {
- /** PCI location. */
- struct rte_pci_addr addr;
- } pci;
- /** Used if type is RTE_DEVTYPE_VIRTUAL. */
- struct {
- /** Driver name. */
- char drv_name[RTE_DEV_NAME_MAX_LEN];
- } virt;
- };
/** Bus handle for the device. */
struct rte_bus *bus;
+ /** Name of the device. */
+ char name[RTE_DEV_NAME_MAX_LEN];
/** Arguments string as given by user or "" for no argument. */
char *args;
};
rte_vdev_device_name(const struct rte_vdev_device *dev)
{
if (dev && dev->device.devargs)
- return dev->device.devargs->virt.drv_name;
+ return dev->device.devargs->name;
return NULL;
}
if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
goto fail;
devargs = TAILQ_FIRST(&devargs_list);
- if (strncmp(devargs->virt.drv_name, "net_ring1",
- sizeof(devargs->virt.drv_name)) != 0)
+ if (strncmp(devargs->name, "net_ring1",
+ sizeof(devargs->name)) != 0)
goto fail;
if (!devargs->args || strcmp(devargs->args, "k1=val,k2=val2") != 0)
goto fail;
if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
goto fail;
devargs = TAILQ_FIRST(&devargs_list);
- if (devargs->pci.addr.domain != 0 ||
- devargs->pci.addr.bus != 4 ||
- devargs->pci.addr.devid != 0 ||
- devargs->pci.addr.function != 1)
+ if (strcmp(devargs->name, "04:00.1") != 0)
goto fail;
if (!devargs->args || strcmp(devargs->args, "") != 0)
goto fail;