bus/pci: use given name as generic name
When an application requests the use of a PCI device, it can currently
interchangeably use either the longform DomBDF format (0000:00:00.0) or
the shorter BDF format (00:00.0).
When a device is inserted via the hotplug API, it must first be scanned
and then will be identified by its name using `find_device`. The name of
the device must match the name given by the user to be found and then
probed.
A new function sets the expected name for a scanned PCI device. It was
previously generated from parsing the PCI address. This canonical name
is superseded when an rte_devargs exists describing the device. In such
case, the device takes the given name found within the rte_devargs.
As the rte_devargs is linked to the rte_pci_device during scanning, it
can be avoided during the probe. Additionally, this fixes the issue of
the rte_devargs lookup not being done within rte_pci_probe_one.
Fixes: beec692c51
("eal: add name field to generic device")
Cc: stable@dpdk.org
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
This commit is contained in:
parent
7e8b266501
commit
23eaa9059e
@ -280,8 +280,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
|
||||
/* FreeBSD has no NUMA support (yet) */
|
||||
dev->device.numa_node = 0;
|
||||
|
||||
rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name));
|
||||
dev->device.name = dev->name;
|
||||
pci_name_set(dev);
|
||||
|
||||
/* FreeBSD has only one pass through driver */
|
||||
dev->kdrv = RTE_KDRV_NIC_UIO;
|
||||
@ -332,6 +331,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
|
||||
} else { /* already registered */
|
||||
dev2->kdrv = dev->kdrv;
|
||||
dev2->max_vfs = dev->max_vfs;
|
||||
pci_name_set(dev2);
|
||||
memmove(dev2->mem_resource,
|
||||
dev->mem_resource,
|
||||
sizeof(dev->mem_resource));
|
||||
|
@ -88,6 +88,29 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
pci_name_set(struct rte_pci_device *dev)
|
||||
{
|
||||
struct rte_devargs *devargs;
|
||||
|
||||
/* Each device has its internal, canonical name set. */
|
||||
rte_pci_device_name(&dev->addr,
|
||||
dev->name, sizeof(dev->name));
|
||||
devargs = pci_devargs_lookup(dev);
|
||||
dev->device.devargs = devargs;
|
||||
/* In blacklist mode, if the device is not blacklisted, no
|
||||
* rte_devargs exists for it.
|
||||
*/
|
||||
if (devargs != NULL)
|
||||
/* If an rte_devargs exists, the generic rte_device uses the
|
||||
* given name as its namea
|
||||
*/
|
||||
dev->device.name = dev->device.devargs->name;
|
||||
else
|
||||
/* Otherwise, it uses the internal, canonical form. */
|
||||
dev->device.name = dev->name;
|
||||
}
|
||||
|
||||
/* map a particular resource from a file */
|
||||
void *
|
||||
pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
|
||||
@ -396,11 +419,7 @@ rte_pci_probe(void)
|
||||
FOREACH_DEVICE_ON_PCIBUS(dev) {
|
||||
probed++;
|
||||
|
||||
/* set devargs in PCI structure */
|
||||
devargs = pci_devargs_lookup(dev);
|
||||
if (devargs != NULL)
|
||||
dev->device.devargs = devargs;
|
||||
|
||||
devargs = dev->device.devargs;
|
||||
/* probe all or only whitelisted devices */
|
||||
if (probe_all)
|
||||
ret = pci_probe_all_drivers(dev);
|
||||
|
@ -112,6 +112,11 @@ int rte_eal_log_init(const char *id, int facility);
|
||||
struct rte_pci_driver;
|
||||
struct rte_pci_device;
|
||||
|
||||
/**
|
||||
* Find the name of a PCI device.
|
||||
*/
|
||||
void pci_name_set(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Add a PCI device to the PCI Bus (append to PCI Device list). This function
|
||||
* also updates the bus references of the PCI Device (and the generic device
|
||||
|
@ -324,8 +324,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
|
||||
dev->device.numa_node = 0;
|
||||
}
|
||||
|
||||
rte_pci_device_name(addr, dev->name, sizeof(dev->name));
|
||||
dev->device.name = dev->name;
|
||||
pci_name_set(dev);
|
||||
|
||||
/* parse resources */
|
||||
snprintf(filename, sizeof(filename), "%s/resource", dirname);
|
||||
@ -373,6 +372,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
|
||||
} else { /* already registered */
|
||||
dev2->kdrv = dev->kdrv;
|
||||
dev2->max_vfs = dev->max_vfs;
|
||||
pci_name_set(dev2);
|
||||
memmove(dev2->mem_resource, dev->mem_resource,
|
||||
sizeof(dev->mem_resource));
|
||||
free(dev);
|
||||
|
Loading…
Reference in New Issue
Block a user