The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is
referenced early inside the PCI device structure. See
commit
1d20a073fa5e ("bus/pci: reference driver structure before mapping")
However the rte_driver does not need to be referenced in rte_device
before the device probing is done.
By moving back this assignment at the end of the device probing,
it becomes possible to make clear the status of a rte_device.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Tested-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
/* reference driver structure */
afu_dev->driver = drv;
- afu_dev->device.driver = &drv->driver;
/* call the driver probe() function */
ret = drv->probe(afu_dev);
- if (ret) {
+ if (ret)
afu_dev->driver = NULL;
- afu_dev->device.driver = NULL;
- }
+ else
+ afu_dev->device.driver = &drv->driver;
return ret;
}
return -1;
/* Check if a driver is already loaded */
- if (afu_dev->driver != NULL)
+ if (afu_dev->device.driver != NULL)
return 0;
TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
* driver flags for adjusting configuration.
*/
dev->driver = dr;
- dev->device.driver = &dr->driver;
if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
/* map resources for devices that use igb_uio */
ret = rte_pci_map_device(dev);
if (ret != 0) {
dev->driver = NULL;
- dev->device.driver = NULL;
return ret;
}
}
ret = dr->probe(dr, dev);
if (ret) {
dev->driver = NULL;
- dev->device.driver = NULL;
if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&
/* Don't unmap if device is unsupported and
* driver needs mapped resources.
!(ret > 0 &&
(dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))
rte_pci_unmap_device(dev);
+ } else {
+ dev->device.driver = &dr->driver;
}
return ret;
return -1;
/* Check if a driver is already loaded */
- if (dev->driver != NULL)
+ if (dev->device.driver != NULL)
return 0;
FOREACH_DRIVER_ON_PCIBUS(dr) {
struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
/**< PCI Memory Resource */
struct rte_intr_handle intr_handle; /**< Interrupt handle */
- struct rte_pci_driver *driver; /**< Associated driver */
+ struct rte_pci_driver *driver; /**< PCI driver used in probing */
uint16_t max_vfs; /**< sriov enable if not zero */
enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */
char name[PCI_PRI_STR_SIZE+1]; /**< PCI location (ASCII) */
if (vdev_parse(name, &driver))
return -1;
- dev->device.driver = &driver->driver;
ret = driver->probe(dev);
- if (ret)
- dev->device.driver = NULL;
+ if (ret == 0)
+ dev->device.driver = &driver->driver;
return ret;
}
/* reference driver structure */
dev->driver = dr;
- dev->device.driver = &dr->driver;
if (dev->device.numa_node < 0) {
VMBUS_LOG(WARNING, " Invalid NUMA socket, default to 0");
if (ret) {
dev->driver = NULL;
rte_vmbus_unmap_device(dev);
+ } else {
+ dev->device.driver = &dr->driver;
}
return ret;
int rc;
/* Check if a driver is already loaded */
- if (dev->driver != NULL) {
+ if (dev->device.driver != NULL) {
VMBUS_LOG(DEBUG, "VMBUS driver already loaded");
return 0;
}
if (representor->vf_id >= pf->vf_num)
return -ENODEV;
- /** representor shares the same driver as it's PF device */
- ethdev->device->driver = representor->adapter->eth_dev->device->driver;
-
/* Set representor device ops */
ethdev->dev_ops = &i40e_representor_dev_ops;
eth_dev->data->mac_addrs = priv->mac;
eth_dev->device = &pci_dev->device;
rte_eth_copy_pci_info(eth_dev, pci_dev);
- eth_dev->device->driver = &mlx4_driver.driver;
/* Initialize local interrupt handle for current port. */
priv->intr_handle = (struct rte_intr_handle){
.fd = -1,
priv->dev_data = eth_dev->data;
eth_dev->data->mac_addrs = priv->mac;
eth_dev->device = dpdk_dev;
- eth_dev->device->driver = &mlx5_driver.driver;
err = mlx5_uar_init_primary(eth_dev);
if (err) {
err = rte_errno;
PMD_INIT_FUNC_TRACE();
PMD_INIT_LOG(INFO, "Initializing eth_dev %s (driver %s)", data->name,
- dev->device->driver->name);
+ RTE_STR(RTE_SZEDATA2_DRIVER_NAME));
/* Fill internal private structure. */
internals->dev = dev;
ether_addr_copy(ð_addr, data->mac_addrs);
PMD_INIT_LOG(INFO, "%s device %s successfully initialized",
- dev->device->driver->name, data->name);
+ RTE_STR(RTE_SZEDATA2_DRIVER_NAME), data->name);
return 0;
}
rte_free(dev->data->mac_addrs);
PMD_DRV_LOG(INFO, "%s device %s successfully uninitialized",
- dev->device->driver->name, dev->data->name);
+ RTE_STR(RTE_SZEDATA2_DRIVER_NAME), dev->data->name);
return 0;
}
struct rte_device {
TAILQ_ENTRY(rte_device) next; /**< Next device */
const char *name; /**< Device name */
- const struct rte_driver *driver;/**< Associated driver */
+ const struct rte_driver *driver; /**< Driver assigned after probing */
const struct rte_bus *bus; /**< Bus handle assigned on scan */
int numa_node; /**< NUMA node connection */
struct rte_devargs *devargs; /**< Device user arguments */