Consolidate bus driver infrastructure
Subsystems (7)
PATCH v4 18/25 bus: factorize driver reference
In reply to David MarchandBefore this patch, setting the driver in the device object and error rollback were the responsibility of each bus probe_device function.
This patch centralizes it in the EAL's local_dev_probe function. The dev->driver field is now set before calling bus->probe_device, ensuring that drivers can rely on it being set during probe.
On error, dev->driver is cleared only if the device was not previously probed, to handle buses that support multiple probes (RTE_PCI_DRV_PROBE_AGAIN).
As a consequence, each bus implementation no longer needs to set/clear dev->driver and dev->device.driver.
In PCI bus, a side effect is that detecting a re-probe cannot use rte_dev_is_probed (which checks dev->driver != NULL) anymore. Switch to checking if intr_handle was allocated instead.
--- drivers/bus/auxiliary/auxiliary_common.c | 2 -- drivers/bus/cdx/cdx.c | 2 -- drivers/bus/dpaa/dpaa_bus.c | 6 ++---- drivers/bus/fslmc/fslmc_bus.c | 1 - drivers/bus/ifpga/ifpga_bus.c | 2 -- drivers/bus/pci/pci_common.c | 6 ++---- drivers/bus/platform/platform.c | 8 +------- drivers/bus/uacce/uacce.c | 1 - drivers/bus/vmbus/vmbus_common.c | 2 -- lib/eal/common/eal_common_bus.c | 7 +++++++ lib/eal/common/eal_common_dev.c | 12 ++++++++++++ 11 files changed, 24 insertions(+), 25 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -2
@@ -120,8 +120,6 @@ auxiliary_probe_device(struct rte_driver *drv, struct rte_device *dev) aux_dev->driver =NULL ;rte_intr_instance_free (aux_dev->intr_handle); aux_dev->intr_handle =NULL ; - }else { - aux_dev->device.driver = &aux_drv->driver; }return ret;
drivers/bus/cdx/cdx.c +0 -2
@@ -332,8 +332,6 @@ cdx_probe_device(struct rte_driver *drv, struct rte_device *dev)CDX_BUS_ERR ("Probe CDX driver: %s device: %s failed: %d" , cdx_drv->driver.name, dev_name, ret); goto error_probe; - }else { - cdx_dev->device.driver = &cdx_drv->driver; } cdx_dev->driver = cdx_drv;
drivers/bus/dpaa/dpaa_bus.c +2 -4
@@ -800,12 +800,10 @@ dpaa_bus_probe_device(struct rte_driver *drv, struct rte_device *dev)int ret; ret = dpaa_drv->probe (dpaa_drv, dpaa_dev); -if (ret !=0 ) { +if (ret !=0 )DPAA_BUS_ERR ("unable to probe: %s" , dpaa_dev->name); - }else { +else dpaa_dev->driver = dpaa_drv; - dpaa_dev->device.driver = &dpaa_drv->driver; - }return ret; }
drivers/bus/fslmc/fslmc_bus.c +0 -1
@@ -524,7 +524,6 @@ fslmc_bus_probe_device(struct rte_driver *driver, struct rte_device *rte_dev)DPAA2_BUS_ERR ("Unable to probe" ); }else { dev->driver = drv; - dev->device.driver = &drv->driver;DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); }
drivers/bus/ifpga/ifpga_bus.c +0 -2
@@ -281,8 +281,6 @@ ifpga_probe_device(struct rte_driver *drv, struct rte_device *dev) ret = afu_drv->probe (afu_dev);if (ret) afu_dev->driver =NULL ; -else - afu_dev->device.driver = &afu_drv->driver;return ret; }
drivers/bus/pci/pci_common.c +2 -4
@@ -203,7 +203,7 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)if (pci_dev->device.numa_node <0 &&rte_socket_count () >1 )PCI_LOG (INFO ,"Device %s is not NUMA-aware" , pci_dev->name); - already_probed =rte_dev_is_probed (&pci_dev->device); + already_probed = (pci_dev->intr_handle !=NULL );if (already_probed && !(pci_drv->drv_flags &RTE_PCI_DRV_PROBE_AGAIN )) {PCI_LOG (DEBUG ,"Device %s is already probed" , pci_dev->device.name);return -EEXIST ;
@@ -251,7 +251,7 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)* to use driver flags for adjusting configuration. */ pci_dev->driver = pci_drv; -if (pci_dev->driver->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { +if (pci_drv->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { ret =rte_pci_map_device (pci_dev);if (ret !=0 ) { pci_dev->driver =NULL ;
@@ -285,8 +285,6 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev) pci_dev->vfio_req_intr_handle =NULL ;rte_intr_instance_free (pci_dev->intr_handle); pci_dev->intr_handle =NULL ; - }else { - pci_dev->device.driver = &pci_drv->driver; }return ret;
drivers/bus/platform/platform.c +1 -7
@@ -329,17 +329,11 @@ device_setup(struct rte_platform_device *pdev)static int driver_call_probe (struct rte_platform_driver *pdrv,struct rte_platform_device *pdev) { -int ret; -if (pdrv->probe !=NULL ) { pdev->driver = pdrv; - ret = pdrv->probe (pdev); -if (ret) -return ret; +return pdrv->probe (pdev); } - pdev->device.driver = &pdrv->driver; -return 0 ; }
drivers/bus/uacce/uacce.c +0 -1
@@ -366,7 +366,6 @@ uacce_probe_device(struct rte_driver *drv, struct rte_device *dev)UACCE_BUS_ERR ("probe device %s with driver %s failed %d" , dev_name, uacce_drv->driver.name, ret); }else { - uacce_dev->device.driver = &uacce_drv->driver; uacce_dev->driver = uacce_drv;UACCE_BUS_DEBUG ("probe device %s with driver %s success" , dev_name, uacce_drv->driver.name);
drivers/bus/vmbus/vmbus_common.c +0 -2
@@ -119,8 +119,6 @@ vmbus_probe_device(struct rte_driver *drv, struct rte_device *dev)if (ret !=0 ) { vmbus_dev->driver =NULL ;rte_vmbus_unmap_device (vmbus_dev); - }else { - vmbus_dev->device.driver = &vmbus_drv->driver; }return ret;
lib/eal/common/eal_common_bus.c +7 -0
@@ -86,6 +86,7 @@ rte_bus_generic_probe(struct rte_bus *bus) TAILQ_FOREACH(dev, &bus->device_list, next) {struct rte_driver *drv =NULL ; +bool was_probed;int ret;if (rte_bus_device_is_ignored (bus, dev->name))
@@ -102,7 +103,13 @@ rte_bus_generic_probe(struct rte_bus *bus)if (drv ==NULL )continue ; + was_probed =rte_dev_is_probed (dev); +if (!was_probed) + dev->driver = drv; ret = bus->probe_device (drv, dev); +if (!was_probed && ret !=0 ) + dev->driver =NULL ; +if (ret >0 ) goto next_driver;
lib/eal/common/eal_common_dev.c +12 -0
@@ -229,7 +229,19 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)EAL_LOG (INFO ,"Device %s is already probed" , dev->name); ret = -EEXIST ; }else { +bool was_probed =rte_dev_is_probed (dev); + +/* +* Reference driver structure. +* This needs to be before .probe_device as some bus (like PCI) use +* driver flags for adjusting configuration. +*/ +if (!was_probed) + dev->driver = drv; ret = dev->bus->probe_device (drv, dev); +if (!was_probed && ret !=0 ) + dev->driver =NULL ; +if (ret >0 ) goto next_driver; }
Signature · 1 line
2.53.0
PATCH v4 19/25 drivers: rely on generic driver
In reply to David MarchandNow that the generic device object always references a generic driver, we can rely on this reference and stop going through the bus-specific driver reference.
--- drivers/bus/auxiliary/auxiliary_common.c | 12 +++++++----- drivers/bus/cdx/cdx.c | 2 +- drivers/bus/dpaa/dpaa_bus.c | 3 ++- drivers/bus/fslmc/fslmc_bus.c | 2 +- drivers/bus/fslmc/fslmc_vfio.c | 10 ++++++---- drivers/bus/ifpga/ifpga_bus.c | 6 ++++-- drivers/bus/pci/linux/pci_uio.c | 6 ++++-- drivers/bus/pci/pci_common.c | 20 +++++++++----------- drivers/bus/platform/platform.c | 20 ++++++++++++-------- drivers/bus/uacce/uacce.c | 5 +++-- drivers/bus/vmbus/vmbus_common.c | 3 ++- drivers/common/qat/qat_qp.c | 4 ++-- drivers/common/zsda/zsda_qp.c | 4 ++-- drivers/net/ntnic/ntnic_ethdev.c | 8 +++----- drivers/raw/cnxk_bphy/cnxk_bphy.c | 2 +- drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c | 2 +- drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 2 +- drivers/raw/ifpga/afu_pmd_core.c | 2 +- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- drivers/raw/ntb/ntb.c | 2 +- lib/ethdev/ethdev_pci.h | 7 +++++-- 21 files changed, 69 insertions(+), 55 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +7 -5
@@ -131,7 +131,7 @@ auxiliary_probe_device(struct rte_driver *drv, struct rte_device *dev)static int rte_auxiliary_driver_remove_dev (struct rte_auxiliary_device *dev) { -struct rte_auxiliary_driver *drv = dev->driver; +const struct rte_auxiliary_driver *drv =RTE_BUS_DRIVER (dev->device.driver, *drv);int ret =0 ; AUXILIARY_LOG(DEBUG, "Driver %s remove auxiliary device %s on NUMA node %i",
@@ -226,12 +226,13 @@ static int auxiliary_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { struct rte_auxiliary_device *aux_dev = RTE_BUS_DEVICE(dev, *aux_dev); +const struct rte_auxiliary_driver *aux_drv =RTE_BUS_DRIVER (dev->driver, *aux_drv); -if (aux_dev->driver->dma_map ==NULL ) { +if (aux_drv->dma_map ==NULL ) { rte_errno =ENOTSUP ;return -1 ; } -return aux_dev->driver->dma_map (aux_dev, addr, iova, len); +return aux_drv->dma_map (aux_dev, addr, iova, len); } static int
@@ -239,12 +240,13 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) {struct rte_auxiliary_device *aux_dev =RTE_BUS_DEVICE (dev, *aux_dev); +const struct rte_auxiliary_driver *aux_drv =RTE_BUS_DRIVER (dev->driver, *aux_drv); -if (aux_dev->driver->dma_unmap ==NULL ) { +if (aux_drv->dma_unmap ==NULL ) { rte_errno =ENOTSUP ;return -1 ; } -return aux_dev->driver->dma_unmap (aux_dev, addr, iova, len); +return aux_drv->dma_unmap (aux_dev, addr, iova, len); } static enum rte_iova_mode
drivers/bus/cdx/cdx.c +1 -1
@@ -382,7 +382,7 @@ rte_cdx_unregister(struct rte_cdx_driver *driver)static int cdx_detach_dev (struct rte_cdx_device *dev) { -struct rte_cdx_driver *dr = dev->driver; +const struct rte_cdx_driver *dr =RTE_BUS_DRIVER (dev->device.driver, *dr);int ret =0 ; CDX_BUS_DEBUG("detach device %s using driver: %s",
drivers/bus/dpaa/dpaa_bus.c +2 -1
@@ -815,11 +815,12 @@ dpaa_bus_cleanup(void)BUS_INIT_FUNC_TRACE (); RTE_BUS_FOREACH_DEV(dev, &rte_dpaa_bus.bus) { -struct rte_dpaa_driver *drv = dev->driver; +const struct rte_dpaa_driver *drv;int ret =0 ;if (!rte_dev_is_probed (&dev->device))continue ; + drv =RTE_BUS_DRIVER (dev->device.driver, *drv);if (drv->remove ==NULL )continue ; ret = drv->remove (dev);
drivers/bus/fslmc/fslmc_bus.c +1 -1
@@ -534,7 +534,7 @@ static int fslmc_bus_unplug(struct rte_device *rte_dev) {struct rte_dpaa2_device *dev =RTE_BUS_DEVICE (rte_dev, *dev); -struct rte_dpaa2_driver *drv = dev->driver; +const struct rte_dpaa2_driver *drv =RTE_BUS_DRIVER (rte_dev->driver, *drv);if (drv->remove !=NULL ) { drv->remove (dev);
drivers/bus/fslmc/fslmc_vfio.c +6 -4
@@ -1392,7 +1392,7 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev, int vfio_fd) {struct rte_dpaa2_object *object =NULL ; -struct rte_dpaa2_driver *drv; +const struct rte_dpaa2_driver *drv;int ret;switch (dev->dev_type) {
@@ -1411,9 +1411,11 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,case DPAA2_ETH :case DPAA2_CRYPTO :case DPAA2_QDMA : - drv = dev->driver; -if (drv && drv->remove && drv->remove (dev)) -DPAA2_BUS_ERR ("Unable to remove" ); +if (dev->device.driver !=NULL ) { + drv =RTE_BUS_DRIVER (dev->device.driver, *drv); +if (drv->remove && drv->remove (dev)) +DPAA2_BUS_ERR ("Unable to remove" ); + }break ;default :break ;
drivers/bus/ifpga/ifpga_bus.c +4 -2
@@ -296,11 +296,12 @@ ifpga_cleanup(void)int error =0 ; RTE_BUS_FOREACH_DEV(afu_dev, &rte_ifpga_bus) { -struct rte_afu_driver *drv = afu_dev->driver; +const struct rte_afu_driver *drv;int ret =0 ;if (!rte_dev_is_probed (&afu_dev->device)) goto free; + drv =RTE_BUS_DRIVER (afu_dev->device.driver, *drv);if (drv->remove ==NULL ) goto free;
@@ -326,9 +327,10 @@ static int ifpga_unplug(struct rte_device *dev) {struct rte_afu_device *afu_dev =RTE_BUS_DEVICE (dev, *afu_dev); +const struct rte_afu_driver *afu_drv =RTE_BUS_DRIVER (dev->driver, *afu_drv);int ret; - ret = afu_dev->driver->remove (afu_dev); + ret = afu_drv->remove (afu_dev);if (ret)return ret;
drivers/bus/pci/linux/pci_uio.c +4 -2
@@ -301,8 +301,10 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,struct pci_map *maps;int wc_activate =0 ; -if (dev->driver !=NULL ) - wc_activate = dev->driver->drv_flags &RTE_PCI_DRV_WC_ACTIVATE ; +if (dev->device.driver !=NULL ) { +const struct rte_pci_driver *pdrv =RTE_BUS_DRIVER (dev->device.driver, *pdrv); + wc_activate = pdrv->drv_flags &RTE_PCI_DRV_WC_ACTIVATE ; + } loc = &dev->addr; maps = uio_res->maps;
drivers/bus/pci/pci_common.c +9 -11
@@ -245,11 +245,6 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)return -ENOMEM ; } -/* -* Reference driver structure. -* This needs to be before rte_pci_map_device(), as it enables -* to use driver flags for adjusting configuration. -*/ pci_dev->driver = pci_drv;if (pci_drv->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { ret =rte_pci_map_device (pci_dev);
@@ -298,7 +293,7 @@ static int rte_pci_detach_dev(struct rte_pci_device *dev) {struct rte_pci_addr *loc; -struct rte_pci_driver *dr = dev->driver; +const struct rte_pci_driver *dr =RTE_BUS_DRIVER (dev->device.driver, *dr);int ret =0 ; loc = &dev->addr;
@@ -339,11 +334,12 @@ pci_cleanup(void)int error =0 ; RTE_BUS_FOREACH_DEV(dev, &rte_pci_bus.bus) { -struct rte_pci_driver *drv = dev->driver; +const struct rte_pci_driver *drv;int ret =0 ;if (!rte_dev_is_probed (&dev->device)) goto free; + drv =RTE_BUS_DRIVER (dev->device.driver, *drv);if (drv->remove ==NULL ) goto free;
@@ -545,9 +541,10 @@ static int pci_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { struct rte_pci_device *pdev = RTE_BUS_DEVICE(dev, *pdev); +const struct rte_pci_driver *pdrv =RTE_BUS_DRIVER (dev->driver, *pdrv); -if (pdev->driver->dma_map !=NULL ) -return pdev->driver->dma_map (pdev, addr, iova, len); +if (pdrv->dma_map !=NULL ) +return pdrv->dma_map (pdev, addr, iova, len);/** * In case driver don't provides any specific mapping * try fallback to VFIO.
@@ -564,9 +561,10 @@ static int pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { struct rte_pci_device *pdev = RTE_BUS_DEVICE(dev, *pdev); +const struct rte_pci_driver *pdrv =RTE_BUS_DRIVER (dev->driver, *pdrv); -if (pdev->driver->dma_unmap !=NULL ) -return pdev->driver->dma_unmap (pdev, addr, iova, len); +if (pdrv->dma_unmap !=NULL ) +return pdrv->dma_unmap (pdev, addr, iova, len);/** * In case driver don't provides any specific mapping * try fallback to VFIO.
drivers/bus/platform/platform.c +12 -8
@@ -408,7 +408,7 @@ platform_bus_probe_device(struct rte_driver *drv, struct rte_device *dev)static void device_release_driver (struct rte_platform_device *pdev) { -struct rte_platform_driver *pdrv = pdev->driver; +const struct rte_platform_driver *pdrv =RTE_BUS_DRIVER (pdev->device.driver, *pdrv);int ret;if (pdrv->remove !=NULL ) {
@@ -458,9 +458,10 @@ static int platform_bus_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { struct rte_platform_device *pdev = RTE_BUS_DEVICE(dev, *pdev); +const struct rte_platform_driver *pdrv =RTE_BUS_DRIVER (dev->driver, *pdrv); -if (pdev->driver->dma_map !=NULL ) -return pdev->driver->dma_map (pdev, addr, iova, len); +if (pdrv->dma_map !=NULL ) +return pdrv->dma_map (pdev, addr, iova, len);return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , (uint64_t )addr, iova, len); }
@@ -469,9 +470,10 @@ static int platform_bus_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { struct rte_platform_device *pdev = RTE_BUS_DEVICE(dev, *pdev); +const struct rte_platform_driver *pdrv =RTE_BUS_DRIVER (dev->driver, *pdrv); -if (pdev->driver->dma_unmap !=NULL ) -return pdev->driver->dma_unmap (pdev, addr, iova, len); +if (pdrv->dma_unmap !=NULL ) +return pdrv->dma_unmap (pdev, addr, iova, len);return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , (uint64_t )addr, iova, len);
@@ -480,12 +482,14 @@ platform_bus_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_tstatic enum rte_iova_mode platform_bus_get_iommu_class (void ) { -struct rte_platform_driver *pdrv; +const struct rte_platform_driver *pdrv;struct rte_platform_device *pdev; RTE_BUS_FOREACH_DEV(pdev, &platform_bus.bus) { - pdrv = pdev->driver; -if (pdrv !=NULL && pdrv->drv_flags &RTE_PLATFORM_DRV_NEED_IOVA_AS_VA ) +if (!rte_dev_is_probed (&pdev->device)) +continue ; + pdrv =RTE_BUS_DRIVER (pdev->device.driver, *pdrv); +if (pdrv->drv_flags &RTE_PLATFORM_DRV_NEED_IOVA_AS_VA )return RTE_IOVA_VA ; }
drivers/bus/uacce/uacce.c +3 -2
@@ -381,11 +381,12 @@ uacce_cleanup(void)int error =0 ; RTE_BUS_FOREACH_DEV(dev, &uacce_bus.bus) { -struct rte_uacce_driver *dr = dev->driver; +const struct rte_uacce_driver *dr;int ret =0 ;if (!rte_dev_is_probed (&dev->device)) goto free; + dr =RTE_BUS_DRIVER (dev->device.driver, *dr);if (dr->remove ==NULL ) goto free;
@@ -408,7 +409,7 @@ uacce_cleanup(void)static int uacce_detach_dev (struct rte_uacce_device *dev) { -struct rte_uacce_driver *dr = dev->driver; +const struct rte_uacce_driver *dr =RTE_BUS_DRIVER (dev->device.driver, *dr);int ret =0 ;UACCE_BUS_DEBUG ("detach device %s using driver: %s" , dev->device.name, dr->driver.name);
drivers/bus/vmbus/vmbus_common.c +2 -1
@@ -143,11 +143,12 @@ rte_vmbus_cleanup(void)int error =0 ; RTE_BUS_FOREACH_DEV(dev, &rte_vmbus_bus.bus) { -const struct rte_vmbus_driver *drv = dev->driver; +const struct rte_vmbus_driver *drv;int ret;if (!rte_dev_is_probed (&dev->device))continue ; + drv =RTE_BUS_DRIVER (dev->device.driver, *drv);if (drv->remove ==NULL )continue ;
drivers/common/qat/qat_qp.c +2 -2
@@ -174,7 +174,7 @@ qat_qp_setup(struct qat_pci_device *qat_dev,snprintf (op_cookie_pool_name,RTE_RING_NAMESIZE ,"%s%d_cookies_%s_qp%hu" , - pci_dev->driver->driver.name, qat_dev->qat_dev_id, + pci_dev->device.driver->name, qat_dev->qat_dev_id, qat_qp_conf->service_str, queue_pair_id);QAT_LOG (DEBUG ,"cookiepool: %s" , op_cookie_pool_name);
@@ -252,7 +252,7 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,*/ snprintf (queue->memz_name,sizeof (queue->memz_name),"%s_%d_%s_%s_%d_%d" , - pci_dev->driver->driver.name, qat_dev->qat_dev_id, + pci_dev->device.driver->name, qat_dev->qat_dev_id, qp_conf->service_str,"qp_mem" , queue->hw_bundle_number, queue->hw_queue_number); qp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes,
drivers/common/zsda/zsda_qp.c +2 -2
@@ -592,12 +592,12 @@ zsda_queue_create(const uint8_t dev_id, struct zsda_queue *queue,if (dir ==RING_DIR_TX )snprintf (queue->memz_name,sizeof (queue->memz_name), -"%s_%d_%s_%s_%d" , pci_dev->driver->driver.name, dev_id, +"%s_%d_%s_%s_%d" , pci_dev->device.driver->name, dev_id, qp_conf->service_str,"qptxmem" , queue->hw_queue_number);else snprintf (queue->memz_name,sizeof (queue->memz_name), -"%s_%d_%s_%s_%d" , pci_dev->driver->driver.name, dev_id, +"%s_%d_%s_%s_%d" , pci_dev->device.driver->name, dev_id, qp_conf->service_str,"qprxmem" , queue->hw_queue_number);
drivers/net/ntnic/ntnic_ethdev.c +3 -5
@@ -2676,8 +2676,7 @@ nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused) }static int -nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, -struct rte_pci_device *pci_dev) +nthw_pci_probe (struct rte_pci_driver *pci_drv,struct rte_pci_device *pci_dev) {int ret;
@@ -2711,9 +2710,8 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->id.subsystem_vendor_id, pci_dev->id.subsystem_device_id, pci_dev->name[0 ] ? pci_dev->name :"NA" , pci_dev->device.numa_node, - pci_dev->driver->driver.name ? pci_dev->driver->driver.name :"NA" , - pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA"); - + (pci_drv->driver.name !=NULL ) ? pci_drv->driver.name :"NA" , + (pci_drv->driver.alias != NULL) ? pci_drv->driver.alias : "NA"); ret =nthw_pci_dev_init (pci_dev);
drivers/raw/cnxk_bphy/cnxk_bphy.c +1 -1
@@ -351,7 +351,7 @@ bphy_rawdev_probe(struct rte_pci_driver *pci_drv, bphy_rawdev->dev_ops = &bphy_rawdev_ops; bphy_rawdev->device = &pci_dev->device; - bphy_rawdev->driver_name = pci_dev->driver->driver.name; + bphy_rawdev->driver_name = pci_dev->device.driver->name; bphy_dev = (struct bphy_device *)bphy_rawdev->dev_private; bphy_dev->mem.res0 = pci_dev->mem_resource[0 ];
drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c +1 -1
@@ -319,7 +319,7 @@ cnxk_bphy_cgx_rawdev_probe(struct rte_pci_driver *pci_drv, rawdev->dev_ops = &cnxk_bphy_cgx_rawdev_ops; rawdev->device = &pci_dev->device; - rawdev->driver_name = pci_dev->driver->driver.name; + rawdev->driver_name = pci_dev->device.driver->name; cgx = rawdev->dev_private; cgx->rcgx =rte_zmalloc (NULL ,sizeof (*rcgx),0 );
drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +1 -1
@@ -210,7 +210,7 @@ rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops; rvu_lf_rawdev->device = &pci_dev->device; - rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name; + rvu_lf_rawdev->driver_name = pci_dev->device.driver->name; roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private; roc_rvu_lf->pci_dev = pci_dev;
drivers/raw/ifpga/afu_pmd_core.c +1 -1
@@ -310,7 +310,7 @@ static int afu_rawdev_create(struct rte_afu_device *afu_dev, int socket_id) rawdev->dev_ops = &afu_rawdev_ops; rawdev->device = &afu_dev->device; - rawdev->driver_name = afu_dev->driver->driver.name; + rawdev->driver_name = afu_dev->device.driver->name; dev =afu_rawdev_get_priv (rawdev);if (!dev)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
@@ -1602,7 +1602,7 @@ ifpga_rawdev_create(struct rte_pci_device *pci_dev, rawdev->dev_ops = &ifpga_rawdev_ops; rawdev->device = &pci_dev->device; - rawdev->driver_name = pci_dev->driver->driver.name; + rawdev->driver_name = pci_dev->device.driver->name;/* must enumerate the adapter before use it */ ret =opae_adapter_enumerate (adapter);
drivers/raw/ntb/ntb.c +1 -1
@@ -1478,7 +1478,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id) rawdev->dev_ops = &ntb_ops; rawdev->device = &pci_dev->device; - rawdev->driver_name = pci_dev->driver->driver.name; + rawdev->driver_name = pci_dev->device.driver->name; ret =ntb_init_hw (rawdev, pci_dev);if (ret <0 ) {
lib/ethdev/ethdev_pci.h +5 -2
@@ -39,10 +39,13 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, eth_dev->intr_handle = pci_dev->intr_handle;if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { +const struct rte_pci_driver *pci_drv; + + pci_drv =RTE_BUS_DRIVER (pci_dev->device.driver, *pci_drv); eth_dev->data->dev_flags =0 ; -if (pci_dev->driver->drv_flags &RTE_PCI_DRV_INTR_LSC ) +if (pci_drv->drv_flags &RTE_PCI_DRV_INTR_LSC ) eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ; -if (pci_dev->driver->drv_flags &RTE_PCI_DRV_INTR_RMV ) +if (pci_drv->drv_flags &RTE_PCI_DRV_INTR_RMV ) eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_RMV ; eth_dev->data->numa_node = pci_dev->device.numa_node;
Signature · 1 line
2.53.0
PATCH v4 20/25 drivers/bus: remove bus-specific driver references
In reply to David MarchandWith the driver reference being set in the EAL before calling bus->probe_device, buses now rely on the generic device.driver field instead of maintaining their own bus-specific driver pointers.
This patch removes the use of bus-specific driver fields in favor of the generic device.driver field, accessed through the RTE_BUS_DRIVER macro in remove/cleanup paths.
--- drivers/bus/auxiliary/auxiliary_common.c | 4 ---- drivers/bus/auxiliary/bus_auxiliary_driver.h | 1 - drivers/bus/cdx/bus_cdx_driver.h | 1 - drivers/bus/cdx/cdx.c | 2 -- drivers/bus/dpaa/bus_dpaa_driver.h | 1 - drivers/bus/dpaa/dpaa_bus.c | 3 --- drivers/bus/fslmc/bus_fslmc_driver.h | 1 - drivers/bus/fslmc/fslmc_bus.c | 2 -- drivers/bus/ifpga/bus_ifpga_driver.h | 1 - drivers/bus/ifpga/ifpga_bus.c | 12 +----------- drivers/bus/pci/bus_pci_driver.h | 1 - drivers/bus/pci/pci_common.c | 5 ----- drivers/bus/platform/bus_platform_driver.h | 1 - drivers/bus/platform/platform.c | 5 +---- drivers/bus/uacce/bus_uacce_driver.h | 1 - drivers/bus/uacce/uacce.c | 3 --- drivers/bus/vmbus/bus_vmbus_driver.h | 1 - drivers/bus/vmbus/vmbus_common.c | 8 +------- 18 files changed, 3 insertions(+), 50 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -4
@@ -111,13 +111,10 @@ auxiliary_probe_device(struct rte_driver *drv, struct rte_device *dev)return -ENOMEM ; } - aux_dev->driver = aux_drv; -AUXILIARY_LOG (INFO ,"Probe auxiliary driver: %s device: %s (NUMA node %i)" , aux_drv->driver.name, aux_dev->name, aux_dev->device.numa_node); ret = aux_drv->probe (aux_drv, aux_dev);if (ret !=0 ) { - aux_dev->driver =NULL ;rte_intr_instance_free (aux_dev->intr_handle); aux_dev->intr_handle =NULL ; }
@@ -144,7 +141,6 @@ rte_auxiliary_driver_remove_dev(struct rte_auxiliary_device *dev) }/* clear driver structure */ - dev->driver =NULL ; dev->device.driver =NULL ;return 0 ;
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -1
@@ -113,7 +113,6 @@ struct rte_auxiliary_device {struct rte_device device;/**< Inherit core device */ char name[RTE_DEV_NAME_MAX_LEN +1 ];/**< ASCII device name */ struct rte_intr_handle *intr_handle;/**< Interrupt handle */ -struct rte_auxiliary_driver *driver;/**< Device driver */ };/**
drivers/bus/cdx/bus_cdx_driver.h +0 -1
@@ -54,7 +54,6 @@ struct rte_cdx_id {*/ struct rte_cdx_device {struct rte_device device;/**< Inherit core device */ -struct rte_cdx_driver *driver;/**< CDX driver used in probing */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[RTE_CDX_MAX_RESOURCE ];
drivers/bus/cdx/cdx.c +0 -2
@@ -333,7 +333,6 @@ cdx_probe_device(struct rte_driver *drv, struct rte_device *dev) cdx_drv->driver.name, dev_name, ret); goto error_probe; } - cdx_dev->driver = cdx_drv;return ret;
@@ -395,7 +394,6 @@ cdx_detach_dev(struct rte_cdx_device *dev) }/* clear driver structure */ - dev->driver =NULL ; dev->device.driver =NULL ;rte_cdx_unmap_device (dev);
drivers/bus/dpaa/bus_dpaa_driver.h +0 -1
@@ -85,7 +85,6 @@ struct rte_dpaa_device {struct rte_cryptodev *crypto_dev;struct rte_dma_dev *dmadev; }; -struct rte_dpaa_driver *driver;struct dpaa_device_id id;struct rte_intr_handle *intr_handle;enum rte_dpaa_type device_type;/**< Ethernet or crypto type device */
drivers/bus/dpaa/dpaa_bus.c +0 -3
@@ -802,8 +802,6 @@ dpaa_bus_probe_device(struct rte_driver *drv, struct rte_device *dev) ret = dpaa_drv->probe (dpaa_drv, dpaa_dev);if (ret !=0 )DPAA_BUS_ERR ("unable to probe: %s" , dpaa_dev->name); -else - dpaa_dev->driver = dpaa_drv;return ret; }
@@ -828,7 +826,6 @@ dpaa_bus_cleanup(void) rte_errno = errno;return -1 ; } - dev->driver =NULL ; dev->device.driver =NULL ; }dpaa_portal_finish ((void *)DPAA_PER_LCORE_PORTAL );
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
@@ -101,7 +101,6 @@ struct rte_dpaa2_device {uint16_t ep_object_id;/**< Endpoint DPAA2 Object ID */ char ep_name[RTE_DEV_NAME_MAX_LEN ];struct rte_intr_handle *intr_handle;/**< Interrupt handle */ -struct rte_dpaa2_driver *driver;/**< Associated driver */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ };
drivers/bus/fslmc/fslmc_bus.c +0 -2
@@ -523,7 +523,6 @@ fslmc_bus_probe_device(struct rte_driver *driver, struct rte_device *rte_dev)if (ret !=0 ) {DPAA2_BUS_ERR ("Unable to probe" ); }else { - dev->driver = drv;DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); }
@@ -538,7 +537,6 @@ fslmc_bus_unplug(struct rte_device *rte_dev)if (drv->remove !=NULL ) { drv->remove (dev); - dev->driver =NULL ; dev->device.driver =NULL ;DPAA2_BUS_INFO ("%s Un-Plugged" , dev->device.name);return 0 ;
drivers/bus/ifpga/bus_ifpga_driver.h +0 -1
@@ -75,7 +75,6 @@ struct rte_afu_device {/**< AFU Memory Resource */ struct rte_afu_shared shared;struct rte_intr_handle *intr_handle;/**< Interrupt handle */ -struct rte_afu_driver *driver;/**< Associated driver */ char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; };
drivers/bus/ifpga/ifpga_bus.c +1 -11
@@ -272,17 +272,8 @@ ifpga_probe_device(struct rte_driver *drv, struct rte_device *dev) {struct rte_afu_device *afu_dev =RTE_BUS_DEVICE (dev, *afu_dev);struct rte_afu_driver *afu_drv =RTE_BUS_DRIVER (drv, *afu_drv); -int ret; - -/* reference driver structure */ - afu_dev->driver = afu_drv; - -/* call the driver probe() function */ - ret = afu_drv->probe (afu_dev); -if (ret) - afu_dev->driver =NULL ; -return ret; +return afu_drv->probe (afu_dev); }/*
@@ -310,7 +301,6 @@ ifpga_cleanup(void) rte_errno = errno; error =-1 ; } - afu_dev->driver =NULL ; afu_dev->device.driver =NULL ; free:
drivers/bus/pci/bus_pci_driver.h +0 -1
@@ -39,7 +39,6 @@ struct rte_pci_device {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;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_pci_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */
drivers/bus/pci/pci_common.c +0 -5
@@ -245,11 +245,9 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)return -ENOMEM ; } - pci_dev->driver = pci_drv;if (pci_drv->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { ret =rte_pci_map_device (pci_dev);if (ret !=0 ) { - pci_dev->driver =NULL ;rte_intr_instance_free (pci_dev->vfio_req_intr_handle); pci_dev->vfio_req_intr_handle =NULL ;rte_intr_instance_free (pci_dev->intr_handle);
@@ -268,7 +266,6 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)if (already_probed)return ret;/* no rollback if already succeeded earlier */ if (ret) { - pci_dev->driver =NULL ; if ((pci_drv->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources.
@@ -312,7 +309,6 @@ rte_pci_detach_dev(struct rte_pci_device *dev) }/* clear driver structure */ - dev->driver =NULL ; dev->device.driver =NULL ;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )
@@ -348,7 +344,6 @@ pci_cleanup(void) rte_errno = errno; error =-1 ; } - dev->driver =NULL ; dev->device.driver =NULL ; free:
drivers/bus/platform/bus_platform_driver.h +0 -1
@@ -95,7 +95,6 @@ struct rte_platform_resource {*/ struct rte_platform_device {struct rte_device device;/**< Core device */ -struct rte_platform_driver *driver;/**< Matching device driver */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */ unsigned int num_resource;/**< Number of device resources */ struct rte_platform_resource *resource;/**< Device resources */
drivers/bus/platform/platform.c +1 -4
@@ -329,10 +329,8 @@ device_setup(struct rte_platform_device *pdev)static int driver_call_probe (struct rte_platform_driver *pdrv,struct rte_platform_device *pdev) { -if (pdrv->probe !=NULL ) { - pdev->driver = pdrv; +if (pdrv->probe !=NULL )return pdrv->probe (pdev); - }return 0 ; }
@@ -418,7 +416,6 @@ device_release_driver(struct rte_platform_device *pdev) } pdev->device.driver =NULL ; - pdev->driver =NULL ; } static int
drivers/bus/uacce/bus_uacce_driver.h +0 -1
@@ -44,7 +44,6 @@ struct rte_uacce_driver;*/ struct rte_uacce_device {struct rte_device device;/**< Inherit core device. */ -struct rte_uacce_driver *driver;/**< Driver used in probing. */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name. */ char dev_root[RTE_UACCE_DEV_PATH_SIZE ];/**< Sysfs path with device name. */ char cdev_path[RTE_UACCE_DEV_PATH_SIZE ];/**< Device path in devfs. */
drivers/bus/uacce/uacce.c +0 -3
@@ -366,7 +366,6 @@ uacce_probe_device(struct rte_driver *drv, struct rte_device *dev)UACCE_BUS_ERR ("probe device %s with driver %s failed %d" , dev_name, uacce_drv->driver.name, ret); }else { - uacce_dev->driver = uacce_drv;UACCE_BUS_DEBUG ("probe device %s with driver %s success" , dev_name, uacce_drv->driver.name); }
@@ -395,7 +394,6 @@ uacce_cleanup(void) rte_errno = errno; error =-1 ; } - dev->driver =NULL ; dev->device.driver =NULL ; free:
@@ -420,7 +418,6 @@ uacce_detach_dev(struct rte_uacce_device *dev)return ret; } - dev->driver =NULL ; dev->device.driver =NULL ;return 0 ;
drivers/bus/vmbus/bus_vmbus_driver.h +0 -1
@@ -37,7 +37,6 @@ enum hv_uio_map {* A structure describing a VMBUS device. */ struct rte_vmbus_device { -const struct rte_vmbus_driver *driver;/**< Associated driver */ struct rte_device device;/**< Inherit core device */ rte_uuid_t device_id;/**< VMBUS device id */ rte_uuid_t class_id;/**< VMBUS device type */
drivers/bus/vmbus/vmbus_common.c +1 -7
@@ -107,19 +107,14 @@ vmbus_probe_device(struct rte_driver *drv, struct rte_device *dev)if (ret !=0 )return ret; -/* reference driver structure */ - vmbus_dev->driver = vmbus_drv; -if (vmbus_dev->device.numa_node <0 &&rte_socket_count () >1 )VMBUS_LOG (INFO ,"Device %s is not NUMA-aware" , guid);/* call the driver probe() function */ VMBUS_LOG (INFO ," probe driver: %s" , vmbus_drv->driver.name); ret = vmbus_drv->probe (vmbus_drv, vmbus_dev); -if (ret !=0 ) { - vmbus_dev->driver =NULL ; +if (ret !=0 )rte_vmbus_unmap_device (vmbus_dev); - }return ret; }
@@ -158,7 +153,6 @@ rte_vmbus_cleanup(void)rte_vmbus_unmap_device (dev); - dev->driver =NULL ; dev->device.driver =NULL ;rte_bus_remove_device (&rte_vmbus_bus.bus, &dev->device);free (dev);
Signature · 1 line
2.53.0
PATCH v4 21/25 dma/idxd: remove specific bus type
In reply to David MarchandThere is nothing that requires a specific bus type.
--- drivers/dma/idxd/idxd_bus.c | 38 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-)
drivers/dma/idxd/idxd_bus.c +14 -24
@@ -41,34 +41,24 @@ struct rte_dsa_device { };/* forward prototypes */ -struct dsa_bus ;static int dsa_scan (void );static bool dsa_match (const struct rte_driver *drv,const struct rte_device *dev);static int dsa_probe_device (struct rte_driver *drv,struct rte_device *dev);static enum rte_iova_mode dsa_get_iommu_class (void );static int dsa_addr_parse (const char *name,void *addr); -/** -* Structure describing the DSA bus -*/ -struct dsa_bus { -struct rte_bus bus;/**< Inherit the generic class */ -struct rte_driver driver;/**< Driver struct for devices to point to */ +struct rte_bus dsa_bus = { + .scan = dsa_scan, + .probe = rte_bus_generic_probe, + .match = dsa_match, + .probe_device = dsa_probe_device, + .find_device = rte_bus_generic_find_device, + .get_iommu_class = dsa_get_iommu_class, + .parse = dsa_addr_parse, }; -struct dsa_bus dsa_bus = { - .bus = { - .scan = dsa_scan, - .probe = rte_bus_generic_probe, - .match = dsa_match, - .probe_device = dsa_probe_device, - .find_device = rte_bus_generic_find_device, - .get_iommu_class = dsa_get_iommu_class, - .parse = dsa_addr_parse, - }, - .driver = { - .name ="dmadev_idxd" , - }, +struct rte_driver dsa_driver = { + .name ="dmadev_idxd" , }; static inline const char *
@@ -267,7 +257,7 @@ static bool dsa_match(const struct rte_driver *drv, const struct rte_device *dev {const struct rte_dsa_device *dsa_dev =RTE_BUS_DEVICE (dev, *dsa_dev); -if (drv == &dsa_bus.driver) { +if (drv == &dsa_driver) {char type[64 ], name[64 ]; if (read_wq_string(dsa_dev, "type", type, sizeof(type)) >= 0 &&
@@ -319,7 +309,7 @@ dsa_scan(void)continue ; }strlcpy (dev->wq_name, wq->d_name,sizeof (dev->wq_name)); -rte_bus_add_device (&dsa_bus.bus, &dev->device); +rte_bus_add_device (&dsa_bus, &dev->device); devcount++;read_device_int (dev,"numa_node" , &numa_node);
@@ -357,8 +347,8 @@ dsa_addr_parse(const char *name, void *addr)return 0 ; } -RTE_REGISTER_BUS (dsa, dsa_bus.bus); +RTE_REGISTER_BUS (dsa, dsa_bus);RTE_INIT (dsa_bus_init) { -rte_bus_add_driver (&dsa_bus.bus, &dsa_bus.driver); +rte_bus_add_driver (&dsa_bus, &dsa_driver); }
Signature · 1 line
2.53.0
PATCH v4 22/25 drivers/bus: separate specific bus metadata for NXP drivers
In reply to David MarchandAs a preparation for the next commit, split the specific bus types and move specific fields to a private structure/singleton variable.
--- drivers/bus/dpaa/dpaa_bus.c | 55 ++++++++++++++++++++--------------- drivers/bus/fslmc/fslmc_bus.c | 6 ++-- drivers/bus/fslmc/private.h | 2 -- 3 files changed, 34 insertions(+), 29 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +31 -24
@@ -59,6 +59,9 @@struct rte_dpaa_bus {struct rte_bus bus; +}; + +struct rte_dpaa_bus_private {int device_count;int detected;uint32_t svr_ver;
@@ -67,6 +70,7 @@ struct rte_dpaa_bus { };static struct rte_dpaa_bus rte_dpaa_bus; +static struct rte_dpaa_bus_private dpaa_bus;static struct netcfg_info *dpaa_netcfg;/* define a variable to hold the portal_key, once created.*/
@@ -87,7 +91,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(dpaa_get_eth_port_cfg)RTE_EXPORT_INTERNAL_SYMBOL (dpaa_soc_ver) uint32_t dpaa_soc_ver(void) { -return rte_dpaa_bus.svr_ver; +return dpaa_bus.svr_ver; } struct fm_eth_port_cfg *
@@ -103,11 +107,11 @@ dpaa_push_queue_num_update(void)int ret = false;uint16_t current, new_val; - current =rte_atomic_load_explicit (&rte_dpaa_bus.push_rxq_num, + current =rte_atomic_load_explicit (&dpaa_bus.push_rxq_num, rte_memory_order_acquire); -if (current < rte_dpaa_bus.max_push_rxq_num) { +if (current < dpaa_bus.max_push_rxq_num) { new_val = current +1 ; -if (rte_atomic_compare_exchange_strong_explicit (&rte_dpaa_bus.push_rxq_num, +if (rte_atomic_compare_exchange_strong_explicit (&dpaa_bus.push_rxq_num, ¤t, new_val, rte_memory_order_release, rte_memory_order_acquire))
@@ -121,7 +125,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(dpaa_push_queue_max_num)uint16_t dpaa_push_queue_max_num (void ) { -return rte_dpaa_bus.max_push_rxq_num; +return dpaa_bus.max_push_rxq_num; } static int
@@ -204,7 +208,7 @@ dpaa_create_device_list(void)struct fm_eth_port_cfg *cfg;struct fman_if *fman_intf; - rte_dpaa_bus.device_count =0 ; + dpaa_bus.device_count =0 ;/* Creating Ethernet Devices */ for (i =0 ; dpaa_netcfg && (i < dpaa_netcfg->num_ethports); i++) {
@@ -256,7 +260,7 @@ dpaa_create_device_list(void)dpaa_add_to_device_list (dev); } - rte_dpaa_bus.device_count += i; + dpaa_bus.device_count += i;/* Unlike case of ETH, RTE_LIBRTE_DPAA_MAX_CRYPTODEV SEC devices are * constantly created only if "sec" property is found in the device
@@ -289,7 +293,7 @@ dpaa_create_device_list(void) } dev->device_type =FSL_DPAA_CRYPTO ; - dev->id.dev_id = rte_dpaa_bus.device_count + i; + dev->id.dev_id = dpaa_bus.device_count + i;/* Even though RTE_CRYPTODEV_NAME_MAX_LEN is valid length of * crypto PMD, using RTE_ETH_NAME_MAX_LEN as that is the size
@@ -306,7 +310,7 @@ dpaa_create_device_list(void)dpaa_add_to_device_list (dev); } - rte_dpaa_bus.device_count += i; + dpaa_bus.device_count += i; qdma_dpaa:/* Creating QDMA Device */
@@ -319,7 +323,7 @@ dpaa_create_device_list(void) } dev->device_type =FSL_DPAA_QDMA ; - dev->id.dev_id = rte_dpaa_bus.device_count + i; + dev->id.dev_id = dpaa_bus.device_count + i;memset (dev->name,0 ,RTE_ETH_NAME_MAX_LEN );sprintf (dev->name,"dpaa_qdma-%d" , i+1 );
@@ -331,7 +335,7 @@ dpaa_create_device_list(void)dpaa_add_to_device_list (dev); } - rte_dpaa_bus.device_count += i; + dpaa_bus.device_count += i;return 0 ;
@@ -688,10 +692,10 @@ rte_dpaa_bus_scan(void)return 0 ; } -if (rte_dpaa_bus.detected) +if (dpaa_bus.detected)return 0 ; - rte_dpaa_bus.detected =1 ; + dpaa_bus.detected =1 ;/* create the key, supplying a function that'll be invoked * when a portal affined thread will be deleted.
@@ -707,34 +711,34 @@ rte_dpaa_bus_scan(void) svr_file =fopen (DPAA_SOC_ID_FILE ,"r" );if (svr_file) {if (fscanf (svr_file,"svr:%x" , &svr_ver) >0 ) - rte_dpaa_bus.svr_ver = svr_ver &DPAA_SVR_MASK ; + dpaa_bus.svr_ver = svr_ver &DPAA_SVR_MASK ;else - rte_dpaa_bus.svr_ver =0 ; + dpaa_bus.svr_ver =0 ;fclose (svr_file); }else { - rte_dpaa_bus.svr_ver =0 ; + dpaa_bus.svr_ver =0 ; } -if (rte_dpaa_bus.svr_ver ==SVR_LS1046A_FAMILY ) { +if (dpaa_bus.svr_ver ==SVR_LS1046A_FAMILY ) {DPAA_BUS_LOG (INFO ,"This is LS1046A family SoC." ); - }else if (rte_dpaa_bus.svr_ver ==SVR_LS1043A_FAMILY ) { + }else if (dpaa_bus.svr_ver ==SVR_LS1043A_FAMILY ) {DPAA_BUS_LOG (INFO ,"This is LS1043A family SoC." ); }else {DPAA_BUS_LOG (WARNING ,"This is Unknown(%08x) DPAA1 family SoC." , - rte_dpaa_bus.svr_ver); + dpaa_bus.svr_ver); }/* Disabling the default push mode for LS1043A */ -if (rte_dpaa_bus.svr_ver ==SVR_LS1043A_FAMILY ) { - rte_dpaa_bus.max_push_rxq_num =0 ; +if (dpaa_bus.svr_ver ==SVR_LS1043A_FAMILY ) { + dpaa_bus.max_push_rxq_num =0 ;return 0 ; } penv =getenv ("DPAA_PUSH_QUEUES_NUMBER" );if (penv) - rte_dpaa_bus.max_push_rxq_num =atoi (penv); -if (rte_dpaa_bus.max_push_rxq_num >DPAA_MAX_PUSH_MODE_QUEUE ) - rte_dpaa_bus.max_push_rxq_num =DPAA_MAX_PUSH_MODE_QUEUE ; + dpaa_bus.max_push_rxq_num =atoi (penv); +if (dpaa_bus.max_push_rxq_num >DPAA_MAX_PUSH_MODE_QUEUE ) + dpaa_bus.max_push_rxq_num =DPAA_MAX_PUSH_MODE_QUEUE ;/* Device list creation is only done once */ if (!process_once) {
@@ -868,6 +872,9 @@ static struct rte_dpaa_bus rte_dpaa_bus = { .dev_iterate = rte_bus_generic_dev_iterate, .cleanup = dpaa_bus_cleanup, }, +}; + +static struct rte_dpaa_bus_private dpaa_bus = { .max_push_rxq_num =DPAA_DEFAULT_PUSH_MODE_QUEUE , .device_count =0 , };
drivers/bus/fslmc/fslmc_bus.c +3 -3
@@ -28,6 +28,7 @@#define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"struct rte_fslmc_bus rte_fslmc_bus; +static int fslmc_bus_device_count[DPAA2_DEVTYPE_MAX ];#define DPAA2_SEQN_DYNFIELD_NAME "dpaa2_seqn_dynfield"RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_seqn_dynfield_offset)
@@ -39,7 +40,7 @@ rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type) {if (device_type >=DPAA2_DEVTYPE_MAX )return 0 ; -return rte_fslmc_bus.device_count[device_type]; +return fslmc_bus_device_count[device_type]; } static void
@@ -200,7 +201,7 @@ scan_one_fslmc_device(char *dev_name) dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus.bus, dev_name);/* Update the device found into the device_count table */ - rte_fslmc_bus.device_count[dev->dev_type]++; + fslmc_bus_device_count[dev->dev_type]++;/* Add device in the fslmc device list */ insert_in_device_list (dev);
@@ -559,7 +560,6 @@ struct rte_fslmc_bus rte_fslmc_bus = { .unplug = fslmc_bus_unplug, .dev_iterate = rte_bus_generic_dev_iterate, }, - .device_count = {0}, };RTE_REGISTER_BUS (fslmc, rte_fslmc_bus.bus);
drivers/bus/fslmc/private.h +0 -2
@@ -14,8 +14,6 @@*/ struct rte_fslmc_bus {struct rte_bus bus;/**< Generic Bus object */ -int device_count[DPAA2_DEVTYPE_MAX ]; -/**< Count of all devices scanned */ };extern struct rte_fslmc_bus rte_fslmc_bus;
Signature · 1 line
2.53.0
PATCH v4 23/25 drivers/bus: remove specific bus types
In reply to David MarchandAll the buses can have a simple rte_bus object.
Mark as static whenever possible.
--- drivers/bus/auxiliary/auxiliary_common.c | 44 ++++++++------- drivers/bus/auxiliary/linux/auxiliary.c | 10 ++-- drivers/bus/auxiliary/private.h | 9 +--- drivers/bus/cdx/bus_cdx_driver.h | 1 - drivers/bus/cdx/cdx.c | 42 +++++++-------- drivers/bus/cdx/private.h | 7 --- drivers/bus/dpaa/dpaa_bus.c | 58 +++++++++----------- drivers/bus/fslmc/fslmc_bus.c | 62 +++++++++++----------- drivers/bus/fslmc/fslmc_vfio.c | 30 +++++------ drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 2 +- drivers/bus/fslmc/private.h | 9 +--- drivers/bus/pci/bsd/pci.c | 16 +++--- drivers/bus/pci/linux/pci.c | 13 +++-- drivers/bus/pci/pci_common.c | 60 ++++++++++----------- drivers/bus/pci/pci_params.c | 2 +- drivers/bus/pci/private.h | 9 +--- drivers/bus/pci/windows/pci.c | 13 +++-- drivers/bus/platform/bus_platform_driver.h | 1 - drivers/bus/platform/platform.c | 52 +++++++++--------- drivers/bus/platform/private.h | 9 ---- drivers/bus/uacce/uacce.c | 49 +++++++---------- drivers/bus/vmbus/linux/vmbus_bus.c | 10 ++-- drivers/bus/vmbus/private.h | 9 +--- drivers/bus/vmbus/vmbus_common.c | 34 ++++++------ 24 files changed, 236 insertions(+), 315 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +21 -23
@@ -56,7 +56,7 @@ auxiliary_scan(void)void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev) { - aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus.bus, aux_dev->name); + aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus, aux_dev->name); } static bool
@@ -156,7 +156,7 @@ auxiliary_parse(const char *name, void *addr)if (strlen (name) ==0 )return 0 ; - RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus) {if (drv->match (name))break ; }
@@ -170,7 +170,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_auxiliary_register)void rte_auxiliary_register (struct rte_auxiliary_driver *driver) { -rte_bus_add_driver (&auxiliary_bus.bus, &driver->driver); +rte_bus_add_driver (&auxiliary_bus, &driver->driver); }/* Unregister a driver */
@@ -178,7 +178,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_auxiliary_unregister)void rte_auxiliary_unregister (struct rte_auxiliary_driver *driver) { -rte_bus_remove_driver (&auxiliary_bus.bus, &driver->driver); +rte_bus_remove_driver (&auxiliary_bus, &driver->driver); } static int
@@ -189,7 +189,7 @@ auxiliary_unplug(struct rte_device *dev) ret =rte_auxiliary_driver_remove_dev (adev);if (ret ==0 ) { -rte_bus_remove_device (&auxiliary_bus.bus, &adev->device); +rte_bus_remove_device (&auxiliary_bus, &adev->device);rte_devargs_remove (dev->devargs);rte_intr_instance_free (adev->intr_handle);free (adev);
@@ -203,7 +203,7 @@ auxiliary_cleanup(void)struct rte_auxiliary_device *dev;int error =0 ; - RTE_BUS_FOREACH_DEV(dev, &auxiliary_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &auxiliary_bus) {int ret;if (!rte_dev_is_probed (&dev->device))
@@ -250,7 +250,7 @@ auxiliary_get_iommu_class(void) {const struct rte_auxiliary_driver *drv; - RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus) {if ((drv->drv_flags &RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA ) >0 )return RTE_IOVA_VA ; }
@@ -258,22 +258,20 @@ auxiliary_get_iommu_class(void)return RTE_IOVA_DC ; } -struct rte_auxiliary_bus auxiliary_bus = { - .bus = { - .scan = auxiliary_scan, - .probe = rte_bus_generic_probe, - .cleanup = auxiliary_cleanup, - .find_device = rte_bus_generic_find_device, - .match = auxiliary_bus_match, - .probe_device = auxiliary_probe_device, - .unplug = auxiliary_unplug, - .parse = auxiliary_parse, - .dma_map = auxiliary_dma_map, - .dma_unmap = auxiliary_dma_unmap, - .get_iommu_class = auxiliary_get_iommu_class, - .dev_iterate = rte_bus_generic_dev_iterate, - }, +struct rte_bus auxiliary_bus = { + .scan = auxiliary_scan, + .probe = rte_bus_generic_probe, + .cleanup = auxiliary_cleanup, + .find_device = rte_bus_generic_find_device, + .match = auxiliary_bus_match, + .probe_device = auxiliary_probe_device, + .unplug = auxiliary_unplug, + .parse = auxiliary_parse, + .dma_map = auxiliary_dma_map, + .dma_unmap = auxiliary_dma_unmap, + .get_iommu_class = auxiliary_get_iommu_class, + .dev_iterate = rte_bus_generic_dev_iterate, }; -RTE_REGISTER_BUS (auxiliary, auxiliary_bus.bus); +RTE_REGISTER_BUS (auxiliary, auxiliary_bus);RTE_LOG_REGISTER_DEFAULT (auxiliary_bus_logtype,NOTICE );
drivers/bus/auxiliary/linux/auxiliary.c +5 -5
@@ -48,12 +48,12 @@ auxiliary_scan_one(const char *dirname, const char *name)auxiliary_on_scan (dev);/* Device is valid, add in list (sorted) */ - RTE_BUS_FOREACH_DEV(dev2, &auxiliary_bus.bus) { + RTE_BUS_FOREACH_DEV(dev2, &auxiliary_bus) { ret =strcmp (dev->name, dev2->name);if (ret >0 )continue ;if (ret <0 ) { -rte_bus_insert_device (&auxiliary_bus.bus, &dev2->device, &dev->device); +rte_bus_insert_device (&auxiliary_bus, &dev2->device, &dev->device); }else {/* already registered */ if (rte_dev_is_probed (&dev2->device) && dev2->device.devargs != dev->device.devargs) {
@@ -65,7 +65,7 @@ auxiliary_scan_one(const char *dirname, const char *name) }return 0 ; } -rte_bus_add_device (&auxiliary_bus.bus, &dev->device); +rte_bus_add_device (&auxiliary_bus, &dev->device);return 0 ; }
@@ -109,14 +109,14 @@ auxiliary_scan(void)if (e->d_name[0 ] =='.' )continue ; -if (rte_bus_device_is_ignored (&auxiliary_bus.bus, e->d_name)) +if (rte_bus_device_is_ignored (&auxiliary_bus, e->d_name))continue ;snprintf (dirname,sizeof (dirname),"%s/%s" ,AUXILIARY_SYSFS_PATH , e->d_name);/* Ignore if no driver can handle. */ - RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus) {if (drv->match (e->d_name))break ; }
drivers/bus/auxiliary/private.h +1 -8
@@ -19,14 +19,7 @@ extern int auxiliary_bus_logtype;#define AUXILIARY_LOG (level, ...) \ RTE_LOG_LINE(level, AUXILIARY_BUS, __VA_ARGS__) -/* -* Structure describing the auxiliary bus -*/ -struct rte_auxiliary_bus { -struct rte_bus bus;/* Inherit the generic class */ -}; - -extern struct rte_auxiliary_bus auxiliary_bus; +extern struct rte_bus auxiliary_bus;/* * Test whether the auxiliary device exist.
drivers/bus/cdx/bus_cdx_driver.h +0 -1
@@ -25,7 +25,6 @@ extern "C" {/* Forward declarations */ struct rte_cdx_device ;struct rte_cdx_driver ; -struct rte_cdx_bus ;#define RTE_CDX_BUS_DEVICES_PATH "/sys/bus/cdx/devices"
drivers/bus/cdx/cdx.c +20 -22
89 lines not on this page · raw message
drivers/bus/cdx/private.h +0 -7
@@ -7,13 +7,6 @@#include "bus_cdx_driver.h" -/** -* Structure describing the CDX bus. -*/ -struct rte_cdx_bus { -struct rte_bus bus;/**< Inherit the generic class */ -}; -/** * Map a particular resource from a file. *
drivers/bus/dpaa/dpaa_bus.c +26 -32
148 lines not on this page · raw message
drivers/bus/fslmc/fslmc_bus.c +30 -32
148 lines not on this page · raw message
drivers/bus/fslmc/fslmc_vfio.c +15 -15
@@ -1554,12 +1554,12 @@ fslmc_vfio_close_group(void)return -EIO ; } - RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) {if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLOCKED ) {DPAA2_BUS_LOG (DEBUG ,"%s Blacklisted, skipping" , dev->device.name); -rte_bus_remove_device (&rte_fslmc_bus.bus, &dev->device); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);continue ; }switch (dev->dev_type) {
@@ -1599,7 +1599,7 @@ fslmc_vfio_process_group(void)bool is_dpmcp_in_blocklist = false, is_dpio_in_blocklist = false;int dpmcp_count =0 , dpio_count =0 , current_device; - RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) {if (dev->dev_type ==DPAA2_MPORTAL ) { dpmcp_count++; if (dev->device.devargs &&
@@ -1616,14 +1616,14 @@ fslmc_vfio_process_group(void)/* Search the MCP as that should be initialized first. */ current_device =0 ; - RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) {if (dev->dev_type ==DPAA2_MPORTAL ) { current_device++;if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLOCKED ) {DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , dev->device.name); -rte_bus_remove_device (&rte_fslmc_bus.bus, +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);continue ; }
@@ -1632,7 +1632,7 @@ fslmc_vfio_process_group(void) !is_dpmcp_in_blocklist) {if (dpmcp_count ==1 || current_device != dpmcp_count) { -rte_bus_remove_device (&rte_fslmc_bus.bus, +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);continue ; }
@@ -1647,7 +1647,7 @@ fslmc_vfio_process_group(void) found_mportal =1 ; } -rte_bus_remove_device (&rte_fslmc_bus.bus, &dev->device); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);free (dev); dev =NULL ;/* Ideally there is only a single dpmcp, but in case
@@ -1666,26 +1666,26 @@ fslmc_vfio_process_group(void)* other devices. */ current_device =0 ; - RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) {if (dev->dev_type ==DPAA2_DPRC ) { ret =fslmc_process_iodevices (dev);if (ret) {DPAA2_BUS_ERR ("Unable to process dprc" );return ret; } -rte_bus_remove_device (&rte_fslmc_bus.bus, &dev->device); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); } } current_device =0 ; - RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) {if (dev->dev_type ==DPAA2_IO ) current_device++;if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLOCKED ) {DPAA2_BUS_LOG (DEBUG ,"%s Blocked, skipping" , dev->device.name); -rte_bus_remove_device (&rte_fslmc_bus.bus, &dev->device); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);continue ; } if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
@@ -1693,7 +1693,7 @@ fslmc_vfio_process_group(void) dev->dev_type != DPAA2_CRYPTO && dev->dev_type != DPAA2_QDMA && dev->dev_type != DPAA2_IO) { -rte_bus_remove_device (&rte_fslmc_bus.bus, &dev->device); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);continue ; }switch (dev->dev_type) {
@@ -1735,13 +1735,13 @@ fslmc_vfio_process_group(void)if (!is_dpio_in_blocklist && dpio_count >1 ) {if (rte_eal_process_type () ==RTE_PROC_SECONDARY && current_device != dpio_count) { -rte_bus_remove_device (&rte_fslmc_bus.bus, +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);break ; }if (rte_eal_process_type () ==RTE_PROC_PRIMARY && current_device == dpio_count) { -rte_bus_remove_device (&rte_fslmc_bus.bus, +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);break ; }
@@ -1760,7 +1760,7 @@ fslmc_vfio_process_group(void)/* Unknown - ignore */ DPAA2_BUS_DEBUG ("Found unknown device (%s)" , dev->device.name); -rte_bus_remove_device (&rte_fslmc_bus.bus, &dev->device); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device);free (dev); dev =NULL ; }
drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +1 -1
@@ -49,7 +49,7 @@ rte_dpaa2_create_dprc_device(int vdev_fd __rte_unused,return ret; } - RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) {/** DPRC is always created before it's children are created.*/ dev->container = dprc_node;if (dev->dev_type ==DPAA2_ETH ) {
drivers/bus/fslmc/private.h +1 -8
@@ -9,13 +9,6 @@#include <bus_fslmc_driver.h> -/* -* FSLMC bus -*/ -struct rte_fslmc_bus { -struct rte_bus bus;/**< Generic Bus object */ -}; - -extern struct rte_fslmc_bus rte_fslmc_bus; +extern struct rte_bus rte_fslmc_bus;#endif /* BUS_FSLMC_PRIVATE_H */
drivers/bus/pci/bsd/pci.c +7 -9
@@ -297,20 +297,18 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) }/* device is valid, add in list (sorted) */ -if (TAILQ_EMPTY (&rte_pci_bus.bus.device_list)) { -rte_bus_add_device (&rte_pci_bus.bus, &dev->device); - } -else { +if (TAILQ_EMPTY (&rte_pci_bus.device_list)) { +rte_bus_add_device (&rte_pci_bus, &dev->device); + }else {struct rte_pci_device *dev2 =NULL ;int ret; - RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus.bus) { + RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);if (ret >0 )continue ;else if (ret <0 ) { -rte_bus_insert_device (&rte_pci_bus.bus, &dev2->device, - &dev->device); +rte_bus_insert_device (&rte_pci_bus, &dev2->device, &dev->device); }else {/* already registered */ dev2->kdrv = dev->kdrv; dev2->max_vfs = dev->max_vfs;
@@ -322,7 +320,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) }return 0 ; } -rte_bus_add_device (&rte_pci_bus.bus, &dev->device); +rte_bus_add_device (&rte_pci_bus, &dev->device); }return 0 ;
@@ -378,7 +376,7 @@ rte_pci_scan(void) pci_addr.function = matches[i].pc_sel.pc_func;rte_pci_device_name (&pci_addr, name,sizeof (name)); -if (rte_bus_device_is_ignored (&rte_pci_bus.bus, name)) +if (rte_bus_device_is_ignored (&rte_pci_bus, name))continue ;if (pci_scan_one (fd, &matches[i]) <0 )
drivers/bus/pci/linux/pci.c +6 -7
@@ -321,19 +321,18 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return 0 ; }/* device is valid, add in list (sorted) */ -if (TAILQ_EMPTY (&rte_pci_bus.bus.device_list)) { -rte_bus_add_device (&rte_pci_bus.bus, &dev->device); +if (TAILQ_EMPTY (&rte_pci_bus.device_list)) { +rte_bus_add_device (&rte_pci_bus, &dev->device); }else {struct rte_pci_device *dev2; - RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus.bus) { + RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);if (ret >0 )continue ;if (ret <0 ) { -rte_bus_insert_device (&rte_pci_bus.bus, &dev2->device, - &dev->device); +rte_bus_insert_device (&rte_pci_bus, &dev2->device, &dev->device); }else {/* already registered */ if (!rte_dev_is_probed (&dev2->device)) { dev2->kdrv = dev->kdrv;
@@ -377,7 +376,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return 0 ; } -rte_bus_add_device (&rte_pci_bus.bus, &dev->device); +rte_bus_add_device (&rte_pci_bus, &dev->device); }return 0 ;
@@ -458,7 +457,7 @@ rte_pci_scan(void)if (parse_pci_addr_format (e->d_name,sizeof (e->d_name), &addr) !=0 )continue ; -if (rte_bus_device_is_ignored (&rte_pci_bus.bus, e->d_name)) +if (rte_bus_device_is_ignored (&rte_pci_bus, e->d_name))continue ; snprintf(dirname, sizeof(dirname), "%s/%s",
drivers/bus/pci/pci_common.c +29 -31
126 lines not on this page · raw message
drivers/bus/pci/pci_params.c +1 -1
@@ -75,7 +75,7 @@ rte_pci_dev_iterate(const struct rte_bus *bus __rte_unused,return NULL ; } } - dev =rte_bus_generic_find_device (&rte_pci_bus.bus, start, pci_dev_match, kvargs); + dev =rte_bus_generic_find_device (&rte_pci_bus, start, pci_dev_match, kvargs);rte_kvargs_free (kvargs);return dev; }
drivers/bus/pci/private.h +1 -8
@@ -29,14 +29,7 @@ extern int pci_bus_logtype;#define RTE_PCI_DEVICE_INTERNAL_CONST (ptr) \ container_of(ptr, const struct rte_pci_device_internal, device) -/** -* Structure describing the PCI bus -*/ -struct rte_pci_bus { -struct rte_bus bus;/**< Inherit the generic class */ -}; - -extern struct rte_pci_bus rte_pci_bus; +extern struct rte_bus rte_pci_bus;struct rte_pci_driver ;struct rte_pci_device ;
drivers/bus/pci/windows/pci.c +6 -7
@@ -382,7 +382,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data) goto end;rte_pci_device_name (&addr, name,sizeof (name)); -if (rte_bus_device_is_ignored (&rte_pci_bus.bus, name)) { +if (rte_bus_device_is_ignored (&rte_pci_bus, name)) {/* * We won't add this device, but we want to continue * looking for supported devices
@@ -430,18 +430,17 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data) }/* device is valid, add in list (sorted) */ -if (TAILQ_EMPTY (&rte_pci_bus.bus.device_list)) { -rte_bus_add_device (&rte_pci_bus.bus, &dev->device); +if (TAILQ_EMPTY (&rte_pci_bus.device_list)) { +rte_bus_add_device (&rte_pci_bus, &dev->device); }else {struct rte_pci_device *dev2 =NULL ; - RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus.bus) { + RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);if (ret >0 ) {continue ; }else if (ret <0 ) { -rte_bus_insert_device (&rte_pci_bus.bus, &dev2->device, - &dev->device); +rte_bus_insert_device (&rte_pci_bus, &dev2->device, &dev->device); }else {/* already registered */ dev2->kdrv = dev->kdrv; dev2->max_vfs = dev->max_vfs;
@@ -451,7 +450,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data) }return 0 ; } -rte_bus_add_device (&rte_pci_bus.bus, &dev->device); +rte_bus_add_device (&rte_pci_bus, &dev->device); }return 0 ;
drivers/bus/platform/bus_platform_driver.h +0 -1
@@ -24,7 +24,6 @@ extern "C" {#endif /* Forward declarations */ -struct rte_platform_bus ;struct rte_platform_device ;struct rte_platform_driver ;
drivers/bus/platform/platform.c +26 -26
113 lines not on this page · raw message
drivers/bus/platform/private.h +0 -9
@@ -14,15 +14,6 @@#include "bus_platform_driver.h" -extern struct rte_platform_bus platform_bus; - -/* -* Structure describing platform bus. -*/ -struct rte_platform_bus { -struct rte_bus bus;/* Core bus */ -}; -extern int platform_bus_logtype;#define RTE_LOGTYPE_PLATFORM_BUS platform_bus_logtype#define PLATFORM_LOG_LINE (level, ...) \
drivers/bus/uacce/uacce.c +20 -29
106 lines not on this page · raw message
drivers/bus/vmbus/linux/vmbus_bus.c +4 -6
@@ -39,8 +39,6 @@ static const rte_uuid_t vmbus_nic_uuid = { 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0xe }; -extern struct rte_vmbus_bus rte_vmbus_bus; -/* Read sysfs file to get UUID */ static int parse_sysfs_uuid (const char *filename,rte_uuid_t uu)
@@ -332,7 +330,7 @@ vmbus_scan_one(const char *name) dev->monitor_id =UINT8_MAX ; } - dev->device.devargs =rte_bus_find_devargs (&rte_vmbus_bus.bus, dev_name); + dev->device.devargs =rte_bus_find_devargs (&rte_vmbus_bus, dev_name); dev->device.numa_node =SOCKET_ID_ANY ;if (vmbus_use_numa (dev)) {
@@ -356,7 +354,7 @@ vmbus_scan_one(const char *name)/* device is valid, add in list (sorted) */ VMBUS_LOG (DEBUG ,"Adding vmbus device %s" , name); - RTE_BUS_FOREACH_DEV(dev2, &rte_vmbus_bus.bus) { + RTE_BUS_FOREACH_DEV(dev2, &rte_vmbus_bus) {int ret; ret =rte_uuid_compare (dev->device_id, dev2->device_id);
@@ -364,7 +362,7 @@ vmbus_scan_one(const char *name)continue ;if (ret <0 ) { -rte_bus_insert_device (&rte_vmbus_bus.bus, &dev2->device, &dev->device); +rte_bus_insert_device (&rte_vmbus_bus, &dev2->device, &dev->device); }else {/* already registered */ VMBUS_LOG (NOTICE ,"%s already registered" , name);
@@ -374,7 +372,7 @@ vmbus_scan_one(const char *name)return 0 ; } -rte_bus_add_device (&rte_vmbus_bus.bus, &dev->device); +rte_bus_add_device (&rte_vmbus_bus, &dev->device);return 0 ; error:VMBUS_LOG (DEBUG ,"failed" );
drivers/bus/vmbus/private.h +1 -8
@@ -15,14 +15,7 @@#include <rte_eal_paging.h> #include <rte_vmbus_reg.h> -/** -* Structure describing the VM bus -*/ -struct rte_vmbus_bus { -struct rte_bus bus;/**< Inherit the generic class */ -}; - -extern struct rte_vmbus_bus rte_vmbus_bus; +extern struct rte_bus rte_vmbus_bus;extern int vmbus_logtype_bus;#define RTE_LOGTYPE_VMBUS_BUS vmbus_logtype_bus
drivers/bus/vmbus/vmbus_common.c +15 -19
@@ -23,8 +23,6 @@#include "private.h" -extern struct rte_vmbus_bus rte_vmbus_bus; -/* map a particular resource from a file */ void * vmbus_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
@@ -128,7 +126,7 @@ RTE_EXPORT_SYMBOL(rte_vmbus_probe)int rte_vmbus_probe (void ) { -return rte_bus_generic_probe (&rte_vmbus_bus.bus); +return rte_bus_generic_probe (&rte_vmbus_bus); } static int
@@ -137,7 +135,7 @@ rte_vmbus_cleanup(void)struct rte_vmbus_device *dev;int error =0 ; - RTE_BUS_FOREACH_DEV(dev, &rte_vmbus_bus.bus) { + RTE_BUS_FOREACH_DEV(dev, &rte_vmbus_bus) {const struct rte_vmbus_driver *drv;int ret;
@@ -154,7 +152,7 @@ rte_vmbus_cleanup(void)rte_vmbus_unmap_device (dev); dev->device.driver =NULL ; -rte_bus_remove_device (&rte_vmbus_bus.bus, &dev->device); +rte_bus_remove_device (&rte_vmbus_bus, &dev->device);free (dev); }
@@ -194,7 +192,7 @@ rte_vmbus_register(struct rte_vmbus_driver *driver)VMBUS_LOG (DEBUG ,"Registered driver %s" , driver->driver.name); -rte_bus_add_driver (&rte_vmbus_bus.bus, &driver->driver); +rte_bus_add_driver (&rte_vmbus_bus, &driver->driver); }/* unregister vmbus driver */
@@ -202,22 +200,20 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_vmbus_unregister)void rte_vmbus_unregister (struct rte_vmbus_driver *driver) { -rte_bus_remove_driver (&rte_vmbus_bus.bus, &driver->driver); +rte_bus_remove_driver (&rte_vmbus_bus, &driver->driver); }/* VMBUS doesn't support hotplug */ -struct rte_vmbus_bus rte_vmbus_bus = { - .bus = { - .scan = rte_vmbus_scan, - .probe = rte_bus_generic_probe, - .cleanup = rte_vmbus_cleanup, - .find_device = rte_bus_generic_find_device, - .match = vmbus_bus_match, - .probe_device = vmbus_probe_device, - .parse = vmbus_parse, - .dev_compare = vmbus_dev_compare, - }, +struct rte_bus rte_vmbus_bus = { + .scan = rte_vmbus_scan, + .probe = rte_bus_generic_probe, + .cleanup = rte_vmbus_cleanup, + .find_device = rte_bus_generic_find_device, + .match = vmbus_bus_match, + .probe_device = vmbus_probe_device, + .parse = vmbus_parse, + .dev_compare = vmbus_dev_compare, }; -RTE_REGISTER_BUS (vmbus, rte_vmbus_bus.bus); +RTE_REGISTER_BUS (vmbus, rte_vmbus_bus);RTE_LOG_REGISTER_DEFAULT (vmbus_logtype_bus,NOTICE );
Signature · 1 line
2.53.0
PATCH v4 24/25 eventdev: rename dev field to device
In reply to David MarchandRename the rte_eventdev structure field from 'dev' to 'device' to align with the naming convention used by all other device classes in DPDK (ethdev, cryptodev, bbdev, compressdev, rawdev, regexdev, dmadev, gpudev, and mldev).
This change provides consistency across all device classes: each device class structure now contains a 'struct rte_device *device' field pointing to the backing device.
--- drivers/event/cnxk/cn10k_eventdev.c | 8 ++++---- drivers/event/cnxk/cn20k_eventdev.c | 8 ++++---- drivers/event/cnxk/cn9k_eventdev.c | 6 +++--- drivers/event/cnxk/cnxk_eventdev.c | 2 +- drivers/event/dlb2/pf/dlb2_pf.c | 2 +- drivers/event/skeleton/skeleton_eventdev.c | 2 +- lib/eventdev/eventdev_pmd.h | 2 +- lib/eventdev/eventdev_pmd_pci.h | 4 ++-- lib/eventdev/eventdev_pmd_vdev.h | 2 +- lib/eventdev/rte_eventdev.c | 14 +++++++------- 10 files changed, 25 insertions(+), 25 deletions(-)
drivers/event/cnxk/cn10k_eventdev.c +4 -4
@@ -921,7 +921,7 @@ static int cn10k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, uint32_t *caps) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", ENOTSUP); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn10k", ENOTSUP);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,ENOTSUP ); *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
@@ -939,7 +939,7 @@ cn10k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, {int ret; -CNXK_VALID_DEV_OR_ERR_RET (event_dev->dev,"event_cn10k" ,EINVAL ); +CNXK_VALID_DEV_OR_ERR_RET (event_dev->device,"event_cn10k" ,EINVAL );CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,EINVAL );cn10k_sso_fp_fns_set ((struct rte_eventdev *)(uintptr_t )event_dev);
@@ -954,7 +954,7 @@ static int cn10k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn10k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,EINVAL );return cnxk_crypto_adapter_qp_del (cdev, queue_pair_id);
@@ -973,7 +973,7 @@ cn10k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,const struct rte_cryptodev *cdev, struct rte_event_crypto_adapter_vector_limits *limits) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn10k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,EINVAL ); limits->log2_sz = false;
drivers/event/cnxk/cn20k_eventdev.c +4 -4
@@ -1125,7 +1125,7 @@ static int cn20k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, uint32_t *caps) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", ENOTSUP); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn20k", ENOTSUP);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,ENOTSUP ); *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
@@ -1142,7 +1142,7 @@ cn20k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, const struct r {int ret; -CNXK_VALID_DEV_OR_ERR_RET (event_dev->dev,"event_cn20k" ,EINVAL ); +CNXK_VALID_DEV_OR_ERR_RET (event_dev->device,"event_cn20k" ,EINVAL );CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,EINVAL );cn20k_sso_fp_fns_set ((struct rte_eventdev *)(uintptr_t )event_dev);
@@ -1157,7 +1157,7 @@ static int cn20k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn20k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,EINVAL );return cnxk_crypto_adapter_qp_del (cdev, queue_pair_id);
@@ -1175,7 +1175,7 @@ cn20k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,const struct rte_cryptodev *cdev, struct rte_event_crypto_adapter_vector_limits *limits) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn20k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,EINVAL ); limits->log2_sz = false;
drivers/event/cnxk/cn9k_eventdev.c +3 -3
@@ -1038,7 +1038,7 @@ static int cn9k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, uint32_t *caps) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", ENOTSUP); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn9k", ENOTSUP);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn9k" ,ENOTSUP ); *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
@@ -1055,7 +1055,7 @@ cn9k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, {int ret; -CNXK_VALID_DEV_OR_ERR_RET (event_dev->dev,"event_cn9k" ,EINVAL ); +CNXK_VALID_DEV_OR_ERR_RET (event_dev->device,"event_cn9k" ,EINVAL );CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn9k" ,EINVAL );cn9k_sso_fp_fns_set ((struct rte_eventdev *)(uintptr_t )event_dev);
@@ -1070,7 +1070,7 @@ static int cn9k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn9k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn9k" ,EINVAL );return cnxk_crypto_adapter_qp_del (cdev, queue_pair_id);
drivers/event/cnxk/cnxk_eventdev.c +1 -1
@@ -654,7 +654,7 @@ cnxk_sso_init(struct rte_eventdev *event_dev)return -ENOMEM ; } - pci_dev =RTE_BUS_DEVICE (event_dev->dev, *pci_dev); + pci_dev =RTE_BUS_DEVICE (event_dev->device, *pci_dev); dev->sso.pci_dev = pci_dev; *(uint64_t *)mz->addr = (uint64_t )dev;
drivers/event/dlb2/pf/dlb2_pf.c +1 -1
@@ -784,7 +784,7 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)dlb2_pf_iface_fn_ptrs_init (); - pci_dev =RTE_BUS_DEVICE (eventdev->dev, *pci_dev); + pci_dev =RTE_BUS_DEVICE (eventdev->device, *pci_dev);if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { dlb2 =dlb2_pmd_priv (eventdev);/* rte_zmalloc_socket mem */
drivers/event/skeleton/skeleton_eventdev.c +1 -1
@@ -332,7 +332,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; - pci_dev =RTE_BUS_DEVICE (eventdev->dev, *pci_dev); + pci_dev =RTE_BUS_DEVICE (eventdev->device, *pci_dev); skel->reg_base = (uintptr_t )pci_dev->mem_resource[0 ].addr;if (!skel->reg_base) {
lib/eventdev/eventdev_pmd.h +1 -1
@@ -156,7 +156,7 @@ struct __rte_cache_aligned rte_eventdev {/**< Pointer to device data */ struct eventdev_ops *dev_ops;/**< Functions exported by PMD */ -struct rte_device *dev; +struct rte_device *device;/**< Device info. supplied by probing */ uint8_t attached : 1;
lib/eventdev/eventdev_pmd_pci.h +2 -2
@@ -68,7 +68,7 @@ rte_event_pmd_pci_probe_named(struct rte_pci_driver *pci_drv, "device data"); } - eventdev->dev = &pci_dev->device; + eventdev->device = &pci_dev->device;/* Invoke PMD device initialization function */ retval =devinit (eventdev);
@@ -150,7 +150,7 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,/* Free event device */ rte_event_pmd_release (eventdev); - eventdev->dev =NULL ; + eventdev->device =NULL ;return 0 ; }
lib/eventdev/eventdev_pmd_vdev.h +1 -1
@@ -67,7 +67,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,rte_panic ("Cannot allocate memzone for private device" " data" ); } - eventdev->dev = &vdev->device; + eventdev->device = &vdev->device;return eventdev; }
lib/eventdev/rte_eventdev.c +7 -7
@@ -68,8 +68,8 @@ rte_event_dev_get_dev_id(const char *name)for (i =0 ; i < eventdev_globals.nb_devs; i++) { cmp = (strncmp (rte_event_devices[i].data->name, name,RTE_EVENTDEV_NAME_MAX_LEN ) ==0 ) || - (rte_event_devices[i].dev ? (strncmp ( - rte_event_devices[i].dev->driver->name, name, + (rte_event_devices[i].device ? (strncmp ( + rte_event_devices[i].device->driver->name, name,RTE_EVENTDEV_NAME_MAX_LEN ) ==0 ) :0 );if (cmp && (rte_event_devices[i].attached ==RTE_EVENTDEV_ATTACHED )) {
@@ -114,9 +114,9 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info) dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns; - dev_info->dev = dev->dev; -if (dev->dev !=NULL && dev->dev->driver !=NULL ) - dev_info->driver_name = dev->dev->driver->name; + dev_info->dev = dev->device; +if (dev->device !=NULL && dev->device->driver !=NULL ) + dev_info->driver_name = dev->device->driver->name;rte_eventdev_trace_info_get (dev_id, dev_info, dev_info->dev);
@@ -1812,8 +1812,8 @@ handle_dev_info(const char *cmd __rte_unused,rte_tel_data_start_dict (d);rte_tel_data_add_dict_int (d,"dev_id" , dev_id); -rte_tel_data_add_dict_string (d,"dev_name" , dev->dev->name); -rte_tel_data_add_dict_string (d,"dev_driver" , dev->dev->driver->name); +rte_tel_data_add_dict_string (d,"dev_name" , dev->device->name); +rte_tel_data_add_dict_string (d,"dev_driver" , dev->device->driver->name);rte_tel_data_add_dict_string (d,"state" , dev->data->dev_started ?"started" :"stopped" );rte_tel_data_add_dict_int (d,"socket_id" , dev->data->socket_id);
Signature · 1 line
2.53.0
PATCH v4 25/25 bus: add class device conversion macro
In reply to David MarchandAdd a new helper macro RTE_CLASS_TO_BUS_DEVICE that provides a unified way to convert from any device class (ethdev, cryptodev, eventdev, etc.) to a bus-specific device type. This macro works with any device class that has a 'device' field pointing to struct rte_device.
Remove the bus-specific ethdev convenience macros (RTE_ETH_DEV_TO_PCI, RTE_ETH_DEV_TO_AUXILIARY, RTE_ETH_DEV_TO_VDEV) and replace all uses with the generic RTE_CLASS_TO_BUS_DEVICE macro.
Convert all drivers to use RTE_CLASS_TO_BUS_DEVICE instead of the pattern RTE_BUS_DEVICE(dev->device).
Simplify code that was using an intermediate struct rte_device pointer by applying RTE_CLASS_TO_BUS_DEVICE directly on the device class pointer.
This reduces code duplication and provides a consistent interface that can be used for all device classes.
---
Changes since v3:
- updated sxe2 drivers,
--- drivers/baseband/acc/rte_acc100_pmd.c | 4 +- drivers/baseband/acc/rte_vrb_pmd.c | 2 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 2 +- drivers/bus/auxiliary/bus_auxiliary_driver.h | 3 -- drivers/bus/cdx/bus_cdx_driver.h | 2 - drivers/bus/pci/bus_pci_driver.h | 3 -- drivers/bus/vdev/bus_vdev_driver.h | 3 -- drivers/compress/octeontx/otx_zip.c | 2 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 2 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 3 +- drivers/crypto/octeontx/otx_cryptodev_ops.c | 4 +- drivers/event/cnxk/cnxk_eventdev.c | 2 +- drivers/event/dlb2/pf/dlb2_pf.c | 2 +- drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/ark/ark_ethdev.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 12 +++--- drivers/net/avp/avp_ethdev.c | 22 +++++----- drivers/net/axgbe/axgbe_ethdev.c | 4 +- drivers/net/bnx2x/bnx2x_ethdev.c | 2 +- drivers/net/bnxt/bnxt_ethdev.c | 12 +++--- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 4 +- drivers/net/cnxk/cnxk_ethdev.c | 2 +- drivers/net/cnxk/cnxk_ethdev_ops.c | 2 +- drivers/net/cxgbe/cxgbe_ethdev.c | 4 +- drivers/net/cxgbe/cxgbevf_ethdev.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 16 +++----- drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++-- drivers/net/dpaa2/dpaa2_recycle.c | 6 +-- drivers/net/ena/ena_ethdev.c | 10 ++--- drivers/net/enetc/enetc4_ethdev.c | 4 +- drivers/net/enetc/enetc4_vf.c | 4 +- drivers/net/enetc/enetc_ethdev.c | 2 +- drivers/net/enic/enic_ethdev.c | 4 +- drivers/net/enic/enic_fm_flow.c | 6 +-- drivers/net/enic/enic_vf_representor.c | 2 +- drivers/net/gve/gve_ethdev.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 8 ++-- drivers/net/hinic3/base/hinic3_hwdev.c | 7 ++-- drivers/net/hinic3/hinic3_ethdev.c | 16 ++++---- drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 8 ++-- drivers/net/hns3/hns3_ethdev.c | 6 +-- drivers/net/hns3/hns3_ethdev_vf.c | 6 +-- drivers/net/hns3/hns3_rxtx.c | 4 +- drivers/net/intel/cpfl/cpfl_ethdev.c | 4 +- drivers/net/intel/cpfl/cpfl_ethdev.h | 2 +- drivers/net/intel/e1000/em_ethdev.c | 12 +++--- drivers/net/intel/e1000/em_rxtx.c | 2 +- drivers/net/intel/e1000/igb_ethdev.c | 30 +++++++------- drivers/net/intel/e1000/igb_pf.c | 2 +- drivers/net/intel/e1000/igc_ethdev.c | 22 +++++----- drivers/net/intel/fm10k/fm10k_ethdev.c | 16 ++++---- drivers/net/intel/i40e/i40e_ethdev.c | 28 ++++++------- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- drivers/net/intel/iavf/iavf_ethdev.c | 8 ++-- drivers/net/intel/ice/ice_dcf.c | 6 +-- drivers/net/intel/ice/ice_ethdev.c | 6 +-- drivers/net/intel/ice/ice_ethdev.h | 2 +- drivers/net/intel/idpf/idpf_ethdev.h | 2 +- drivers/net/intel/ipn3ke/ipn3ke_ethdev.h | 3 -- drivers/net/intel/ipn3ke/ipn3ke_representor.c | 6 +-- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 40 +++++++++---------- drivers/net/intel/ixgbe/ixgbe_flow.c | 4 +- drivers/net/intel/ixgbe/ixgbe_pf.c | 2 +- drivers/net/intel/ixgbe/ixgbe_tm.c | 2 +- .../net/intel/ixgbe/ixgbe_vf_representor.c | 2 +- drivers/net/intel/ixgbe/rte_pmd_ixgbe.c | 20 +++++----- drivers/net/nbl/nbl_core.c | 2 +- drivers/net/nbl/nbl_dev/nbl_dev.c | 6 +-- drivers/net/netvsc/hn_ethdev.c | 3 +- drivers/net/nfp/nfp_ethdev.c | 8 ++-- drivers/net/nfp/nfp_ethdev_vf.c | 6 +-- drivers/net/nfp/nfp_net_common.c | 8 ++-- drivers/net/ngbe/ngbe_ethdev.c | 20 +++++----- drivers/net/ngbe/ngbe_ethdev_vf.c | 16 ++++---- drivers/net/ngbe/ngbe_pf.c | 2 +- drivers/net/octeon_ep/otx_ep_ethdev.c | 2 +- drivers/net/octeon_ep/otx_ep_mbox.c | 6 +-- drivers/net/qede/qede_ethdev.c | 6 +-- drivers/net/r8169/r8169_ethdev.c | 6 +-- drivers/net/rnp/rnp_ethdev.c | 6 +-- drivers/net/sfc/sfc.c | 4 +- drivers/net/sfc/sfc_ethdev.c | 2 +- drivers/net/sfc/sfc_intr.c | 10 ++--- drivers/net/sfc/sfc_rx.c | 3 +- drivers/net/sfc/sfc_sriov.c | 2 +- drivers/net/sfc/sfc_tx.c | 3 +- drivers/net/sxe2/sxe2_ethdev.c | 4 +- drivers/net/thunderx/nicvf_ethdev.c | 4 +- drivers/net/txgbe/txgbe_ethdev.c | 26 ++++++------ drivers/net/txgbe/txgbe_ethdev_vf.c | 16 ++++---- drivers/net/txgbe/txgbe_flow.c | 4 +- drivers/net/txgbe/txgbe_pf.c | 2 +- drivers/net/txgbe/txgbe_tm.c | 2 +- drivers/net/virtio/virtio_pci_ethdev.c | 11 ++--- drivers/net/vmxnet3/vmxnet3_ethdev.c | 4 +- drivers/net/xsc/xsc_ethdev.c | 2 +- drivers/net/zxdh/zxdh_ethdev.c | 8 ++-- drivers/raw/ifpga/afu_pmd_n3000.c | 4 +- lib/eal/include/bus_driver.h | 18 +++++++++ 101 files changed, 338 insertions(+), 342 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +2 -2
@@ -3993,7 +3993,7 @@ acc100_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,static void acc100_bbdev_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); dev->dev_ops = &acc100_bbdev_ops; dev->enqueue_enc_ops = acc100_enqueue_enc;
@@ -4646,7 +4646,7 @@ rte_acc_configure(const char *dev_name, struct rte_acc_conf *conf) dev_name);return -ENODEV ; } -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (bbdev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (bbdev, *pci_dev);rte_bbdev_log (INFO ,"Configure dev id %x" , pci_dev->id.device_id);if (pci_dev->id.device_id ==ACC100_PF_DEVICE_ID )return acc100_configure (dev_name, conf);
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
@@ -4353,7 +4353,7 @@ vrb2_dequeue_mldts(struct rte_bbdev_queue_data *q_data,static void vrb_bbdev_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct acc_device *d = dev->data->dev_private; dev->dev_ops = &vrb_bbdev_ops;
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +2 -2
@@ -2873,7 +2873,7 @@ fpga_5gnr_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,static void fpga_5gnr_fec_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); dev->dev_ops = &fpga_5gnr_ops; dev->enqueue_ldpc_enc_ops = fpga_5gnr_enqueue_ldpc_enc;
@@ -3376,7 +3376,7 @@ int rte_fpga_5gnr_fec_configure(const char *dev_name, const struct rte_fpga_5gnr dev_name);return -ENODEV ; } -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (bbdev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (bbdev, *pci_dev);rte_bbdev_log (INFO ,"Configure dev id %x" , pci_dev->id.device_id);if (pci_dev->id.device_id ==VC_5GNR_PF_DEVICE_ID )return vc_5gnr_configure (dev_name, conf);
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +1 -1
@@ -2316,7 +2316,7 @@ fpga_dequeue_dec(struct rte_bbdev_queue_data *q_data,static void fpga_lte_fec_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); dev->dev_ops = &fpga_ops; dev->enqueue_enc_ops = fpga_enqueue_enc;
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -3
@@ -128,9 +128,6 @@ struct rte_auxiliary_driver {uint32_t drv_flags;/**< Flags RTE_AUXILIARY_DRV_*. */ }; -#define RTE_ETH_DEV_TO_AUXILIARY (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_auxiliary_device) -/** Device driver needs IOVA as VA and cannot work with IOVA as PA */ #define RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA 0x002
drivers/bus/cdx/bus_cdx_driver.h +0 -2
@@ -60,8 +60,6 @@ struct rte_cdx_device {struct rte_intr_handle *intr_handle;/**< Interrupt handle */ }; -#define RTE_ETH_DEV_TO_CDX_DEV (eth_dev) RTE_BUS_DEVICE((eth_dev)->device, struct rte_cdx_device) -#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs. */ #define RTE_CDX_DEVICE (vend, dev) \
drivers/bus/pci/bus_pci_driver.h +0 -3
@@ -47,9 +47,6 @@ struct rte_pci_device {/**< Handler of VFIO request interrupt */ }; -#define RTE_ETH_DEV_TO_PCI (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device) -#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs */ #define RTE_PCI_DEVICE (vend, dev) \
drivers/bus/vdev/bus_vdev_driver.h +0 -3
@@ -19,9 +19,6 @@ struct rte_vdev_device {struct rte_device device;/**< Inherit core device */ }; -#define RTE_ETH_DEV_TO_VDEV (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_vdev_device) -static inline const char *rte_vdev_device_name (const struct rte_vdev_device *dev) {
drivers/compress/octeontx/otx_zip.c +1 -1
@@ -142,7 +142,7 @@ zipvf_push_command(struct zipvf_qp *qp, union zip_inst_s *cmd)int zipvf_create (struct rte_compressdev *compressdev) { -struct rte_pci_device *pdev =RTE_BUS_DEVICE (compressdev->device, *pdev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (compressdev, *pdev);struct zip_vf *zipvf =NULL ;char *dev_name = compressdev->data->name;void *vbar0;
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +1 -1
@@ -481,7 +481,7 @@ cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,if (dev->data->queue_pairs[qp_id] !=NULL )cnxk_cpt_queue_pair_release (dev, qp_id); - pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (pci_dev->mem_resource[2 ].addr ==NULL ) {plt_err ("Invalid PCI mem address" );
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +1 -2
@@ -4383,7 +4383,6 @@ static int dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) {struct dpaa2_sec_dev_private *internals; -struct rte_device *dev = cryptodev->device;struct rte_dpaa2_device *dpaa2_dev;struct rte_security_ctx *security_instance;struct fsl_mc_io *dpseci;
@@ -4392,7 +4391,7 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)int retcode, hw_id;PMD_INIT_FUNC_TRACE (); - dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); + dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (cryptodev, *dpaa2_dev); hw_id = dpaa2_dev->object_id; cryptodev->driver_id = cryptodev_driver_id;
drivers/crypto/octeontx/otx_cryptodev_ops.c +2 -2
@@ -156,7 +156,7 @@ otx_cpt_que_pair_setup(struct rte_cryptodev *dev, DEFAULT_CMD_QLEN); } - pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (pci_dev->mem_resource[0 ].addr ==NULL ) {CPT_LOG_ERR ("PCI mem address null" );
@@ -1001,7 +1001,7 @@ static struct rte_cryptodev_ops cptvf_ops = {int otx_cpt_dev_create (struct rte_cryptodev *c_dev) { -struct rte_pci_device *pdev =RTE_BUS_DEVICE (c_dev->device, *pdev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (c_dev, *pdev);struct cpt_vf *cptvf =NULL ;void *reg_base;char dev_name[32 ];
drivers/event/cnxk/cnxk_eventdev.c +1 -1
@@ -654,7 +654,7 @@ cnxk_sso_init(struct rte_eventdev *event_dev)return -ENOMEM ; } - pci_dev =RTE_BUS_DEVICE (event_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (event_dev, *pci_dev); dev->sso.pci_dev = pci_dev; *(uint64_t *)mz->addr = (uint64_t )dev;
drivers/event/dlb2/pf/dlb2_pf.c +1 -1
@@ -784,7 +784,7 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)dlb2_pf_iface_fn_ptrs_init (); - pci_dev =RTE_BUS_DEVICE (eventdev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eventdev, *pci_dev);if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { dlb2 =dlb2_pmd_priv (eventdev);/* rte_zmalloc_socket mem */
drivers/event/skeleton/skeleton_eventdev.c +1 -1
@@ -332,7 +332,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; - pci_dev =RTE_BUS_DEVICE (eventdev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eventdev, *pci_dev); skel->reg_base = (uintptr_t )pci_dev->mem_resource[0 ].addr;if (!skel->reg_base) {
drivers/net/ark/ark_ethdev.c +1 -1
@@ -315,7 +315,7 @@ ark_dev_init(struct rte_eth_dev *dev)if (ret)return ret; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);rte_eth_copy_pci_info (dev, pci_dev); dev->data->dev_flags |=RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS ;
drivers/net/atlantic/atl_ethdev.c +6 -6
@@ -360,7 +360,7 @@ static int eth_atl_dev_init(struct rte_eth_dev *eth_dev) {struct atl_adapter *adapter = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);int err =0 ;
@@ -479,7 +479,7 @@ static int atl_dev_start(struct rte_eth_dev *dev) {struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;int status;
@@ -607,7 +607,7 @@ atl_dev_stop(struct rte_eth_dev *dev)struct rte_eth_link link;struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -688,7 +688,7 @@ atl_dev_set_link_down(struct rte_eth_dev *dev)static int atl_dev_close (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct aq_hw_s *hw;int ret;
@@ -1094,7 +1094,7 @@ atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)static int atl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); dev_info->max_rx_queues =AQ_HW_MAX_RX_QUEUES ; dev_info->max_tx_queues =AQ_HW_MAX_TX_QUEUES ;
@@ -1345,7 +1345,7 @@ atl_dev_link_status_print(struct rte_eth_dev *dev)#ifdef DEBUG { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); PMD_DRV_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT, pci_dev->addr.domain,
drivers/net/avp/avp_ethdev.c +11 -11
@@ -361,7 +361,7 @@ static void * avp_dev_translate_address(struct rte_eth_dev *eth_dev, rte_iova_t host_phys_addr) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_mem_resource *resource;struct rte_avp_memmap_info *info;struct rte_avp_memmap *map;
@@ -414,7 +414,7 @@ avp_dev_version_check(uint32_t version)static int avp_dev_check_regions (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_avp_memmap_info *memmap;struct rte_avp_device_info *info;struct rte_mem_resource *resource;
@@ -550,7 +550,7 @@ _avp_set_rx_queue_mappings(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id)static void _avp_set_queue_counts (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct avp_dev *avp =AVP_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);struct rte_avp_device_info *host_info;void *addr;
@@ -610,7 +610,7 @@ avp_dev_attach(struct rte_eth_dev *eth_dev)* re-run the device create utility which will parse the new host info * and setup the AVP device queue pointers. */ - ret =avp_dev_create (RTE_ETH_DEV_TO_PCI (eth_dev), eth_dev); + ret = avp_dev_create(RTE_CLASS_TO_BUS_DEVICE(eth_dev, struct rte_pci_device), eth_dev);if (ret <0 ) {PMD_DRV_LOG_LINE (ERR ,"Failed to re-create AVP device, ret=%d" , ret);
@@ -664,7 +664,7 @@ static void avp_dev_interrupt_handler(void *data) {struct rte_eth_dev *eth_dev = data; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR ].addr;uint32_t status, value;int ret;
@@ -723,7 +723,7 @@ avp_dev_interrupt_handler(void *data)static int avp_dev_enable_interrupts (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR ].addr;int ret;
@@ -748,7 +748,7 @@ avp_dev_enable_interrupts(struct rte_eth_dev *eth_dev)static int avp_dev_disable_interrupts (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR ].addr;int ret;
@@ -773,7 +773,7 @@ avp_dev_disable_interrupts(struct rte_eth_dev *eth_dev)static int avp_dev_setup_interrupts (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int ret;/* register a callback handler with UIO for interrupt notifications */
@@ -793,7 +793,7 @@ avp_dev_setup_interrupts(struct rte_eth_dev *eth_dev)static int avp_dev_migration_pending (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR ].addr;uint32_t value;
@@ -954,7 +954,7 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev)struct rte_pci_device *pci_dev;int ret; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); eth_dev->dev_ops = &avp_eth_dev_ops; eth_dev->rx_pkt_burst = &avp_recv_pkts; eth_dev->tx_pkt_burst = &avp_xmit_pkts;
@@ -1977,7 +1977,7 @@ avp_dev_tx_queue_release_all(struct rte_eth_dev *eth_dev)static int avp_dev_configure (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct avp_dev *avp =AVP_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);struct rte_avp_device_info *host_info;struct rte_avp_device_config config;
drivers/net/axgbe/axgbe_ethdev.c +2 -2
@@ -2231,7 +2231,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)rte_bit_relaxed_set32 (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; - pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); pdata->pci_dev = pci_dev; pdata->xgmac_regs =
@@ -2454,7 +2454,7 @@ axgbe_dev_close(struct rte_eth_dev *eth_dev)return 0 ; pdata = eth_dev->data->dev_private; - pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);axgbe_dev_clear_queues (eth_dev);/* disable uio intr before callback unregister */
drivers/net/bnx2x/bnx2x_ethdev.c +1 -1
@@ -639,7 +639,7 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)/* Extract key data structures */ sc = eth_dev->data->dev_private; - pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); pci_addr = pci_dev->addr; snprintf(sc->devinfo.name, NAME_SIZE, PCI_SHORT_PRI_FMT ":dpdk-port-%u",
drivers/net/bnxt/bnxt_ethdev.c +6 -6
@@ -862,7 +862,7 @@ static int bnxt_alloc_prev_ring_stats(struct bnxt *bp)static int bnxt_start_nic (struct bnxt *bp) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (bp->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (bp->eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;uint32_t queue_id, base =BNXT_MISC_VEC_ID ;
@@ -1167,7 +1167,7 @@ uint64_t bnxt_eth_rss_support(struct bnxt *bp)static int bnxt_dev_info_get_op (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *dev_info) { -struct rte_pci_device *pdev =RTE_BUS_DEVICE (eth_dev->device, *pdev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev);struct bnxt *bp = eth_dev->data->dev_private;uint16_t max_vnics, i, j, vpool, vrxq;unsigned int max_rx_rings;
@@ -1719,7 +1719,7 @@ static int bnxt_ptp_start(struct bnxt *bp)static int bnxt_dev_stop (struct rte_eth_dev *eth_dev) {struct bnxt *bp = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rte_eth_link link;uint16_t i;
@@ -5143,7 +5143,7 @@ bool bnxt_stratus_device(struct bnxt *bp)static int bnxt_map_pci_bars (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct bnxt *bp = eth_dev->data->dev_private;/* enable device (incl. PCI PM wakeup), and bus-mastering */
@@ -6600,7 +6600,7 @@ bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs)*/ static int bnxt_drv_init (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct bnxt *bp = eth_dev->data->dev_private;int rc =0 ;
@@ -6684,7 +6684,7 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)static int bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);static int version_printed;struct bnxt *bp;int rc;
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +2 -2
@@ -192,7 +192,7 @@ ulp_session_init(struct bnxt *bp,if (!bp)return NULL ; - pci_dev =RTE_BUS_DEVICE (bp->eth_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (bp->eth_dev, *pci_dev); pci_addr = &pci_dev->addr;pthread_mutex_lock (&bnxt_ulp_global_mutex);
@@ -556,7 +556,7 @@ bnxt_ulp_port_deinit(struct bnxt *bp) bp->eth_dev->data->port_id);/* Get the session details */ - pci_dev =RTE_BUS_DEVICE (bp->eth_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (bp->eth_dev, *pci_dev); pci_addr = &pci_dev->addr;pthread_mutex_lock (&bnxt_ulp_global_mutex); session =ulp_get_session (bp, pci_addr);
drivers/net/cnxk/cnxk_ethdev.c +1 -1
@@ -2177,7 +2177,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);rte_eth_copy_pci_info (eth_dev, pci_dev);/* Parse devargs string */
drivers/net/cnxk/cnxk_ethdev_ops.c +1 -1
@@ -7,7 +7,7 @@int cnxk_nix_info_get (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *devinfo) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct cnxk_eth_dev *dev =cnxk_eth_pmd_priv (eth_dev);int max_rx_pktlen;
drivers/net/cxgbe/cxgbe_ethdev.c +2 -2
@@ -1704,7 +1704,7 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev) eth_dev->dev_ops = &cxgbe_eth_dev_ops; eth_dev->rx_pkt_burst = &cxgbe_recv_pkts; eth_dev->tx_pkt_burst = &cxgbe_xmit_pkts; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* for secondary processes, we attach to ethdevs allocated by primary * and do minimal initialization.
@@ -1767,7 +1767,7 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)static int eth_cxgbe_dev_uninit (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);uint16_t port_id;int err =0 ;
drivers/net/cxgbe/cxgbevf_ethdev.c +2 -2
@@ -113,7 +113,7 @@ static int eth_cxgbevf_dev_init(struct rte_eth_dev *eth_dev) eth_dev->dev_ops = &cxgbevf_eth_dev_ops; eth_dev->rx_pkt_burst = &cxgbe_recv_pkts; eth_dev->tx_pkt_burst = &cxgbe_xmit_pkts; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* for secondary processes, we attach to ethdevs allocated by primary * and do minimal initialization.
@@ -177,7 +177,7 @@ static int eth_cxgbevf_dev_init(struct rte_eth_dev *eth_dev)static int eth_cxgbevf_dev_uninit (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);uint16_t port_id;int err =0 ;
drivers/net/dpaa/dpaa_ethdev.c +6 -10
@@ -217,7 +217,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)uint64_t rx_offloads = eth_conf->rxmode.offloads;uint64_t tx_offloads = eth_conf->txmode.offloads;struct dpaa_if *dpaa_intf = dev->data->dev_private; -struct rte_device *rdev = dev->device;struct rte_eth_link *link = &dev->data->dev_link;struct rte_dpaa_device *dpaa_dev;struct fman_if *fif = dev->process_private;
@@ -230,7 +229,7 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); - dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); + dpaa_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *dpaa_dev); intr_handle = dpaa_dev->intr_handle; __fif = container_of(fif, struct __fman_if, __if);
@@ -426,13 +425,12 @@ dpaa_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)static void dpaa_interrupt_handler (void *param) {struct rte_eth_dev *dev = param; -struct rte_device *rdev = dev->device;struct rte_dpaa_device *dpaa_dev;struct rte_intr_handle *intr_handle;uint64_t buf;int bytes_read; - dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); + dpaa_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *dpaa_dev); intr_handle = dpaa_dev->intr_handle;if (rte_intr_fd_get (intr_handle) <0 )
@@ -502,7 +500,6 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) {struct fman_if *fif = dev->process_private;struct __fman_if *__fif; -struct rte_device *rdev = dev->device;struct rte_dpaa_device *dpaa_dev;struct rte_intr_handle *intr_handle;struct rte_eth_link *link = &dev->data->dev_link;
@@ -530,7 +527,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) } } - dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); + dpaa_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *dpaa_dev); intr_handle = dpaa_dev->intr_handle; __fif = container_of(fif, struct __fman_if, __if);
@@ -1267,9 +1264,8 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,/* Set up the device interrupt handler */ if (dev->intr_handle ==NULL ) {struct rte_dpaa_device *dpaa_dev; -struct rte_device *rdev = dev->device; - dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); + dpaa_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *dpaa_dev); dev->intr_handle = dpaa_dev->intr_handle;if (rte_intr_vec_list_alloc (dev->intr_handle,NULL ,dpaa_push_queue_max_num ())) {
@@ -2119,7 +2115,7 @@ dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE (); - dpaa_device =RTE_BUS_DEVICE (eth_dev->device, *dpaa_device); + dpaa_device =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa_device); dev_id = dpaa_device->id.dev_id; cfg =dpaa_get_eth_port_cfg (dev_id); fman_intf = cfg->fman_if;
@@ -2236,7 +2232,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE (); - dpaa_device =RTE_BUS_DEVICE (eth_dev->device, *dpaa_device); + dpaa_device =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa_device); dev_id = dpaa_device->id.dev_id; dpaa_intf = eth_dev->data->dev_private; cfg =dpaa_get_eth_port_cfg (dev_id);
drivers/net/dpaa2/dpaa2_ethdev.c +3 -5
@@ -1339,7 +1339,6 @@ dpaa2_eth_setup_irqs(struct rte_eth_dev *dev, int enable)static int dpaa2_dev_start (struct rte_eth_dev *dev) { -struct rte_device *rdev = dev->device;struct rte_dpaa2_device *dpaa2_dev;struct rte_eth_dev_data *data = dev->data;struct dpaa2_dev_priv *priv = data->dev_private;
@@ -1351,7 +1350,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)int ret, i;struct rte_intr_handle *intr_handle; - dpaa2_dev =RTE_BUS_DEVICE (rdev, *dpaa2_dev); + dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *dpaa2_dev); intr_handle = dpaa2_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -1458,12 +1457,11 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)struct fsl_mc_io *dpni = dev->process_private;int ret;struct rte_eth_link link; -struct rte_device *rdev = dev->device;struct rte_intr_handle *intr_handle;struct rte_dpaa2_device *dpaa2_dev;uint16_t i; - dpaa2_dev =RTE_BUS_DEVICE (rdev, *dpaa2_dev); + dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *dpaa2_dev); intr_handle = dpaa2_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -2918,7 +2916,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } - dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); + dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa2_dev); hw_id = dpaa2_dev->object_id; ret =dpni_open (dpni_dev,CMD_PRI_LOW , hw_id, &priv->token);
drivers/net/dpaa2/dpaa2_recycle.c +2 -4
@@ -607,9 +607,8 @@ lx_serdes_eth_lpbk(uint16_t mac_id, int en)int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev) { -struct rte_device *dev = eth_dev->device;struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; -struct rte_dpaa2_device *dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); +struct rte_dpaa2_device *dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa2_dev);struct fsl_mc_io *dpni_dev = eth_dev->process_private;struct dpni_port_cfg port_cfg;int ret;
@@ -674,9 +673,8 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev) { -struct rte_device *dev = eth_dev->device;struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; -struct rte_dpaa2_device *dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); +struct rte_dpaa2_device *dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa2_dev);struct fsl_mc_io *dpni_dev = eth_dev->process_private;struct dpni_port_cfg port_cfg;int ret =0 ;
drivers/net/ena/ena_ethdev.c +5 -5
@@ -924,7 +924,7 @@ static inline void ena_indirect_table_release(struct ena_adapter *adapter)static int ena_close (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ena_adapter *adapter = dev->data->dev_private;struct ena_com_dev *ena_dev = &adapter->ena_dev;
@@ -1457,7 +1457,7 @@ static int ena_stop(struct rte_eth_dev *dev) {struct ena_adapter *adapter = dev->data->dev_private;struct ena_com_dev *ena_dev = &adapter->ena_dev; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint16_t i;int rc;
@@ -1503,7 +1503,7 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring) {struct ena_adapter *adapter = ring->adapter;struct ena_com_dev *ena_dev = &adapter->ena_dev; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ena_com_create_io_ctx ctx = /* policy set to _HOST just to satisfy icc compiler */
@@ -2422,7 +2422,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) adapter->edev_data = eth_dev->data; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); PMD_INIT_LOG_LINE(INFO, "Initializing " PCI_PRI_FMT, pci_dev->addr.domain,
@@ -3978,7 +3978,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter, struct rte_devargs *destatic int ena_setup_rx_intr (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int rc;uint16_t vectors_nb, i;
drivers/net/enetc/enetc4_ethdev.c +2 -2
@@ -956,7 +956,7 @@ enetc4_dev_hw_init(struct rte_eth_dev *eth_dev) {struct enetc_eth_hw *hw =ENETC_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); eth_dev->rx_pkt_burst = &enetc_recv_pkts_nc; eth_dev->tx_pkt_burst = &enetc_xmit_pkts_nc;
@@ -986,7 +986,7 @@ enetc4_dev_init(struct rte_eth_dev *eth_dev) {struct enetc_eth_hw *hw =ENETC_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int error =0 ;uint32_t si_cap;struct enetc_hw *enetc_hw = &hw->hw;
drivers/net/enetc/enetc4_vf.c +2 -2
@@ -1249,7 +1249,7 @@ enetc4_vf_dev_init(struct rte_eth_dev *eth_dev) {struct enetc_eth_hw *hw =ENETC_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int error =0 ;uint32_t si_cap;struct enetc_hw *enetc_hw = &hw->hw;
@@ -1297,7 +1297,7 @@ enetc4_vf_dev_intr(struct rte_eth_dev *eth_dev, bool enable)struct enetc_eth_hw *hw =ENETC_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);struct enetc_hw *enetc_hw = &hw->hw; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret =0 ;
drivers/net/enetc/enetc_ethdev.c +1 -1
@@ -886,7 +886,7 @@ static int enetc_dev_init(struct rte_eth_dev *eth_dev) {int error =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct enetc_eth_hw *hw =ENETC_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);
drivers/net/enic/enic_ethdev.c +2 -2
@@ -454,7 +454,7 @@ static uint32_t speed_capa_from_pci_id(struct rte_eth_dev *eth_dev)struct rte_pci_device *pdev;uint16_t id; - pdev =RTE_ETH_DEV_TO_PCI (eth_dev); + pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev); id = pdev->id.subsystem_device_id;for (m = vic_speed_capa_map; m->sub_devid !=0 ; m++) {if (m->sub_devid == id)
@@ -1292,7 +1292,7 @@ static int eth_enic_dev_init(struct rte_eth_dev *eth_dev, enic->rte_dev = eth_dev; enic->dev_data = eth_dev->data; - pdev =RTE_ETH_DEV_TO_PCI (eth_dev); + pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev);rte_eth_copy_pci_info (eth_dev, pdev); enic->pdev = pdev; addr = &pdev->addr;
drivers/net/enic/enic_fm_flow.c +3 -3
@@ -3229,7 +3229,7 @@ enic_fm_init(struct enic *enic)if (rte_eth_dev_is_repr (enic->rte_dev)) addr = &VF_ENIC_TO_VF_REP (enic)->bdf;else - addr = &RTE_ETH_DEV_TO_PCI (enic->rte_dev)->addr; + addr = &RTE_CLASS_TO_BUS_DEVICE(enic->rte_dev, struct rte_pci_device)->addr; rc =enic_fm_find_vnic (enic, addr, &enic->fm_vnic_handle);if (rc) { ENICPMD_LOG(ERR, "cannot find vnic handle for %x:%x:%x",
@@ -3361,7 +3361,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)if (rte_eth_dev_is_repr (pf->rte_dev))return -EINVAL ; cur = pf; - cur_a = &RTE_ETH_DEV_TO_PCI (cur->rte_dev)->addr; + cur_a = &RTE_CLASS_TO_BUS_DEVICE(cur->rte_dev, struct rte_pci_device)->addr;/* Go through ports and find another PF that is on the same adapter */ RTE_ETH_FOREACH_DEV (pid) { dev = &rte_eth_devices[pid];
@@ -3373,7 +3373,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)continue ;/* dev is another PF. Is it on the same adapter? */ prev =pmd_priv (dev); - prev_a = &RTE_ETH_DEV_TO_PCI (dev)->addr; + prev_a = &RTE_CLASS_TO_BUS_DEVICE(dev, struct rte_pci_device)->addr;if (!enic_fm_find_vnic (cur, prev_a, &vnic_h)) { ENICPMD_LOG(DEBUG, "Port %u (PF BDF %x:%x:%x) and port %u (PF BDF %x:%x:%x domain %u) are on the same VIC", cur->rte_dev->data->port_id,
drivers/net/enic/enic_vf_representor.c +1 -1
@@ -655,7 +655,7 @@ int enic_vf_representor_init(struct rte_eth_dev *eth_dev, void *init_params) }/* Check for non-existent VFs */ - pdev =RTE_ETH_DEV_TO_PCI (pf->rte_dev); + pdev =RTE_CLASS_TO_BUS_DEVICE (pf->rte_dev, *pdev);if (vf->vf_id >= pdev->max_vfs) {ENICPMD_LOG (ERR ,"VF ID is invalid. vf_id %u max_vfs %u" , vf->vf_id, pdev->max_vfs);
drivers/net/gve/gve_ethdev.c +1 -1
@@ -1491,7 +1491,7 @@ gve_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } - pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); reg_bar = pci_dev->mem_resource[GVE_REG_BAR ].addr;if (!reg_bar) {
drivers/net/hinic/hinic_pmd_ethdev.c +4 -4
@@ -1234,7 +1234,7 @@ static int hinic_dev_stop(struct rte_eth_dev *dev)static void hinic_disable_interrupt (struct rte_eth_dev *dev) {struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);int ret, retries =0 ;rte_bit_relaxed_clear32 (HINIC_DEV_INTR_EN , &nic_dev->dev_status);
@@ -2745,7 +2745,7 @@ static int hinic_nic_dev_create(struct rte_eth_dev *eth_dev) eth_dev->data->name);return -ENOMEM ; } - nic_dev->hwdev->pcidev_hdl =RTE_ETH_DEV_TO_PCI (eth_dev); + nic_dev->hwdev->pcidev_hdl =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *nic_dev->hwdev->pcidev_hdl);/* init osdep*/ rc =hinic_osdep_init (nic_dev->hwdev);
@@ -3086,7 +3086,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)u32 mac_size;int rc; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* EAL is SECONDARY and eth_dev is already created */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) {
@@ -3218,7 +3218,7 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); PMD_DRV_LOG(INFO, "Initializing pf hinic-" PCI_PRI_FMT " in %s process", pci_dev->addr.domain, pci_dev->addr.bus,
drivers/net/hinic3/base/hinic3_hwdev.c +4 -3
@@ -74,10 +74,11 @@ struct mgmt_event_handle { };bool -hinic3_is_vfio_iommu_enable (const struct rte_eth_dev *rte_dev) +hinic3_is_vfio_iommu_enable (const struct rte_eth_dev *eth_dev) { -return ((RTE_ETH_DEV_TO_PCI (rte_dev)->kdrv ==RTE_PCI_KDRV_VFIO ) && - (rte_vfio_noiommu_is_enabled () !=1 )); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); + +return pci_dev->kdrv ==RTE_PCI_KDRV_VFIO &&rte_vfio_noiommu_is_enabled () !=1 ; }int
drivers/net/hinic3/hinic3_ethdev.c +8 -8
@@ -1474,7 +1474,7 @@ hinic3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t sq_id)int hinic3_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle =PCI_DEV_TO_INTR_HANDLE (pci_dev);struct hinic3_nic_dev *nic_dev =HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV (dev);uint16_t msix_intr;
@@ -1493,7 +1493,7 @@ hinic3_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)int hinic3_dev_rx_queue_intr_disable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle =PCI_DEV_TO_INTR_HANDLE (pci_dev);struct hinic3_nic_dev *nic_dev =HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV (dev);uint16_t msix_intr;
@@ -1695,7 +1695,7 @@ static void hinic3_disable_interrupt(struct rte_eth_dev *dev) {struct hinic3_nic_dev *nic_dev =HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!hinic3_get_bit (HINIC3_DEV_INIT , &nic_dev->dev_status))return ;
@@ -1710,7 +1710,7 @@ static void hinic3_enable_interrupt(struct rte_eth_dev *dev) {struct hinic3_nic_dev *nic_dev =HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!hinic3_get_bit (HINIC3_DEV_INIT , &nic_dev->dev_status))return ;
@@ -2080,7 +2080,7 @@ hinic3_dev_release(struct rte_eth_dev *eth_dev) {struct hinic3_nic_dev *nic_dev =HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV (eth_dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int qid;/* Release io resource. */
@@ -3394,7 +3394,7 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)struct rte_pci_device *pci_dev =NULL ;int err; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* EAL is secondary and eth_dev is already created. */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) {
@@ -3460,7 +3460,7 @@ hinic3_func_init(struct rte_eth_dev *eth_dev) err = -ENOMEM ; goto alloc_hwdev_mem_fail; } - nic_dev->hwdev->pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + nic_dev->hwdev->pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *nic_dev->hwdev->pci_dev); nic_dev->hwdev->dev_handle = nic_dev; nic_dev->hwdev->eth_dev = eth_dev; nic_dev->hwdev->port_id = eth_dev->data->port_id;
@@ -3616,7 +3616,7 @@ hinic3_dev_init(struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); PMD_DRV_LOG(INFO, "Initializing %.4x:%.2x:%.2x.%x in %s process", pci_dev->addr.domain, pci_dev->addr.bus,
drivers/net/hns3/hns3_cmd.c +1 -1
@@ -551,7 +551,7 @@ hns3_set_dcb_capability(struct hns3_hw *hw)return ; eth_dev = &rte_eth_devices[hw->data->port_id]; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); device_id = pci_dev->id.device_id; if (device_id == HNS3_DEV_ID_25GE_RDMA ||
drivers/net/hns3/hns3_common.c +4 -4
@@ -812,7 +812,7 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)int hns3_map_rx_interrupt (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint16_t base =RTE_INTR_VEC_ZERO_OFFSET ;
@@ -878,7 +878,7 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev)void hns3_unmap_rx_interrupt (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw;
@@ -912,7 +912,7 @@ int hns3_restore_rx_interrupt(struct hns3_hw *hw) {struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint16_t q_id;int ret;
@@ -943,7 +943,7 @@ hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id)int ret; eth_dev = &rte_eth_devices[hw->data->port_id]; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); ret =rte_pci_read_config (pci_dev, &revision,1 ,RTE_PCI_REVISION_ID );if (ret !=1 ) {hns3_err (hw,"failed to read pci revision id, ret = %d" , ret);
drivers/net/hns3/hns3_ethdev.c +2 -4
@@ -4526,8 +4526,7 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev)static int hns3_init_pf (struct rte_eth_dev *eth_dev) { -struct rte_device *dev = eth_dev->device; -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct hns3_adapter *hns = eth_dev->data->dev_private;struct hns3_hw *hw = &hns->hw;int ret;
@@ -4656,8 +4655,7 @@ static void hns3_uninit_pf(struct rte_eth_dev *eth_dev) {struct hns3_adapter *hns = eth_dev->data->dev_private; -struct rte_device *dev = eth_dev->device; -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct hns3_hw *hw = &hns->hw;PMD_INIT_FUNC_TRACE ();
drivers/net/hns3/hns3_ethdev_vf.c +3 -3
@@ -1622,7 +1622,7 @@ hns3vf_clear_vport_list(struct hns3_hw *hw)static int hns3vf_init_vf (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct hns3_adapter *hns = eth_dev->data->dev_private;struct hns3_hw *hw = &hns->hw;int ret;
@@ -1739,7 +1739,7 @@ hns3vf_notify_uninit(struct hns3_hw *hw)static void hns3vf_uninit_vf (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct hns3_adapter *hns = eth_dev->data->dev_private;struct hns3_hw *hw = &hns->hw;
@@ -2377,7 +2377,7 @@ static int hns3vf_reinit_dev(struct hns3_adapter *hns) {struct rte_eth_dev *eth_dev = &rte_eth_devices[hns->hw.data->port_id]; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct hns3_hw *hw = &hns->hw;int ret;
drivers/net/hns3/hns3_rxtx.c +2 -2
@@ -1093,7 +1093,7 @@ hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en)int hns3_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct hns3_hw *hw =HNS3_DEV_PRIVATE_TO_HW (dev->data->dev_private);
@@ -3066,7 +3066,7 @@ hns3_tx_push_get_queue_tail_reg(struct rte_eth_dev *dev, uint16_t queue_id)#define HNS3_TX_PUSH_QUICK_DOORBELL_OFFSET 64#define HNS3_TX_PUSH_PCI_BAR_INDEX 4 -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint8_t bar_id =HNS3_TX_PUSH_PCI_BAR_INDEX ;/*
drivers/net/intel/cpfl/cpfl_ethdev.c +2 -2
@@ -2764,7 +2764,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };struct cpfl_vport_id vi;struct cpchnl2_vport_id v_id; -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -2836,7 +2836,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) }/* get the vport info */ if (adapter->base.hw.device_id ==IXD_DEV_ID_VCPF ) { - pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); vi.func_type =VCPF_CPCHNL2_FTYPE_LAN_VF ; vi.pf_id =CPFL_HOST0_CPF_ID ; vi.vf_id = pci_dev->addr.function;
drivers/net/intel/cpfl/cpfl_ethdev.h +1 -1
@@ -298,7 +298,7 @@ int vcpf_add_queues(struct cpfl_adapter_ext *adapter);int vcpf_del_queues (struct cpfl_adapter_ext *adapter);#define CPFL_DEV_TO_PCI (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device) + RTE_CLASS_TO_BUS_DEVICE(eth_dev, struct rte_pci_device)#define CPFL_ADAPTER_TO_EXT (p) \ container_of((p), struct cpfl_adapter_ext, base)#define CPFL_DEV_TO_VPORT (dev) \
drivers/net/intel/e1000/em_ethdev.c +6 -6
@@ -273,7 +273,7 @@ eth_em_dev_is_ich8(struct e1000_hw *hw)static int eth_em_dev_init (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct e1000_adapter *adapter =E1000_DEV_PRIVATE (eth_dev->data->dev_private);
@@ -563,7 +563,7 @@ eth_em_start(struct rte_eth_dev *dev)E1000_DEV_PRIVATE (dev->data->dev_private);struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret, mask;uint32_t intr_vector =0 ;
@@ -762,7 +762,7 @@ eth_em_stop(struct rte_eth_dev *dev) {struct rte_eth_link link;struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/*
@@ -816,7 +816,7 @@ eth_em_close(struct rte_eth_dev *dev)struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct e1000_adapter *adapter =E1000_DEV_PRIVATE (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;
@@ -1062,7 +1062,7 @@ static int eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/* device interrupts are only subscribed to in primary processes */
@@ -1647,7 +1647,7 @@ static int eth_em_interrupt_action(struct rte_eth_dev *dev, struct rte_intr_handle *intr_handle) { - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); struct e1000_interrupt *intr =
drivers/net/intel/e1000/em_rxtx.c +1 -1
@@ -2093,7 +2093,7 @@ em_flush_desc_rings(struct rte_eth_dev *dev) {uint32_t fextnvm11, tdlen;struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint16_t pci_cfg_status =0 ;int ret;
drivers/net/intel/e1000/igb_ethdev.c +15 -15
@@ -529,7 +529,7 @@ igb_intr_enable(struct rte_eth_dev *dev)E1000_DEV_PRIVATE_TO_INTR (dev->data->dev_private);struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; if (rte_intr_allow_others(intr_handle) &&
@@ -546,7 +546,7 @@ igb_intr_disable(struct rte_eth_dev *dev) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; if (rte_intr_allow_others(intr_handle) &&
@@ -783,7 +783,7 @@ static int eth_igb_dev_init(struct rte_eth_dev *eth_dev) {int error =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); struct e1000_vfta * shadow_vfta =
@@ -1004,7 +1004,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);rte_eth_copy_pci_info (eth_dev, pci_dev); hw->device_id = pci_dev->id.device_id;
@@ -1300,7 +1300,7 @@ eth_igb_start(struct rte_eth_dev *dev)E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct e1000_adapter *adapter =E1000_DEV_PRIVATE (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret, mask;uint32_t tqavctrl;
@@ -1537,7 +1537,7 @@ static int eth_igb_stop(struct rte_eth_dev *dev) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_eth_link link;struct rte_intr_handle *intr_handle = pci_dev->intr_handle; struct e1000_adapter *adapter =
@@ -1646,7 +1646,7 @@ eth_igb_close(struct rte_eth_dev *dev) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_link link; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct e1000_filter_info *filter_info =E1000_DEV_PRIVATE_TO_FILTER_INFO (dev->data->dev_private);
@@ -2931,7 +2931,7 @@ static int eth_igb_rxq_interrupt_setup(struct rte_eth_dev *dev)int ret;struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int misc_shift =rte_intr_allow_others (intr_handle) ?1 :0 ;struct rte_eth_dev_info dev_info;
@@ -3002,7 +3002,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev,E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct e1000_interrupt *intr =E1000_DEV_PRIVATE_TO_INTR (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_eth_link link;int ret;
@@ -3496,7 +3496,7 @@ igbvf_dev_start(struct rte_eth_dev *dev)E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct e1000_adapter *adapter =E1000_DEV_PRIVATE (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;uint32_t intr_vector =0 ;
@@ -3560,7 +3560,7 @@ igbvf_dev_start(struct rte_eth_dev *dev)static int igbvf_dev_stop (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct e1000_adapter *adapter =E1000_DEV_PRIVATE (dev->data->dev_private);
@@ -3608,7 +3608,7 @@ igbvf_dev_close(struct rte_eth_dev *dev) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_ether_addr addr; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);int ret;PMD_INIT_FUNC_TRACE ();
@@ -5410,7 +5410,7 @@ eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =E1000_MISC_VEC_ID ;
@@ -5434,7 +5434,7 @@ eth_igb_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) {struct e1000_hw *hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =E1000_MISC_VEC_ID ;
@@ -5516,7 +5516,7 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)uint32_t vec =E1000_MISC_VEC_ID ;uint32_t base =E1000_MISC_VEC_ID ;uint32_t misc_shift =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/* won't configure msix register if no mapping is done
drivers/net/intel/e1000/igb_pf.c +1 -1
@@ -29,7 +29,7 @@static inline uint16_t dev_num_vf (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);return pci_dev->max_vfs; }
drivers/net/intel/e1000/igc_ethdev.c +11 -11
@@ -440,7 +440,7 @@ static void igc_intr_other_disable(struct rte_eth_dev *dev) {struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; if (rte_intr_allow_others(intr_handle) &&
@@ -460,7 +460,7 @@ igc_intr_other_enable(struct rte_eth_dev *dev) {struct igc_interrupt *intr =IGC_DEV_PRIVATE_INTR (dev);struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; if (rte_intr_allow_others(intr_handle) &&
@@ -576,7 +576,7 @@ static void eth_igc_interrupt_action(struct rte_eth_dev *dev) {struct igc_interrupt *intr =IGC_DEV_PRIVATE_INTR (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_eth_link link;int ret;
@@ -679,7 +679,7 @@ eth_igc_stop(struct rte_eth_dev *dev) {struct igc_adapter *adapter =IGC_DEV_PRIVATE (dev);struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rte_eth_link link;
@@ -799,7 +799,7 @@ static void igc_configure_msix_intr(struct rte_eth_dev *dev) {struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_mask;
@@ -882,7 +882,7 @@ igc_rxq_interrupt_setup(struct rte_eth_dev *dev) {uint32_t mask;struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int misc_shift =rte_intr_allow_others (intr_handle) ?1 :0 ;int nb_efd;
@@ -990,7 +990,7 @@ eth_igc_start(struct rte_eth_dev *dev) {struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev);struct igc_adapter *adapter =IGC_DEV_PRIVATE (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t nsec, sec, baset_l, baset_h, tqavctrl;struct timespec system_time;
@@ -1307,7 +1307,7 @@ igc_dev_free_queues(struct rte_eth_dev *dev)static int eth_igc_close (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev);struct igc_adapter *adapter =IGC_DEV_PRIVATE (dev);
@@ -1359,7 +1359,7 @@ igc_identify_hardware(struct rte_eth_dev *dev, struct rte_pci_device *pci_dev)static int eth_igc_dev_init (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct igc_adapter *igc =IGC_DEV_PRIVATE (dev);struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev);int i, error =0 ;
@@ -2257,7 +2257,7 @@ static int eth_igc_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) {struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =IGC_MISC_VEC_ID ;
@@ -2280,7 +2280,7 @@ static int eth_igc_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) {struct e1000_hw *hw =IGC_DEV_PRIVATE_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =IGC_MISC_VEC_ID ;
drivers/net/intel/fm10k/fm10k_ethdev.c +8 -8
@@ -693,7 +693,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct fm10k_macvlan_filter_info *macvlan; -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);struct rte_intr_handle *intr_handle = pdev->intr_handle;int i, ret;struct fm10k_rx_queue *rxq;
@@ -1161,7 +1161,7 @@ static int fm10k_dev_stop(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);struct rte_intr_handle *intr_handle = pdev->intr_handle;int i;
@@ -1371,7 +1371,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);PMD_INIT_FUNC_TRACE ();
@@ -2364,7 +2364,7 @@ static int fm10k_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);/* Enable ITR */ if (hw->mac.type == fm10k_mac_pf)
@@ -2381,7 +2381,7 @@ static int fm10k_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);/* Disable ITR */ if (hw->mac.type == fm10k_mac_pf)
@@ -2397,7 +2397,7 @@ static int fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);struct rte_intr_handle *intr_handle = pdev->intr_handle;uint32_t intr_vector, vec;uint16_t queue_id;
@@ -2794,7 +2794,7 @@ static int fm10k_dev_close(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);struct rte_intr_handle *intr_handle = pdev->intr_handle;int ret;
@@ -3060,7 +3060,7 @@ static int eth_fm10k_dev_init(struct rte_eth_dev *dev) {struct fm10k_hw *hw =FM10K_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (dev, *pdev);struct rte_intr_handle *intr_handle = pdev->intr_handle;int diag, i, ret;struct fm10k_macvlan_filter_info *macvlan;
drivers/net/intel/i40e/i40e_ethdev.c +14 -14
@@ -981,7 +981,7 @@ is_floating_veb_supported(struct rte_devargs *devargs)static void config_floating_veb (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);
@@ -1549,7 +1549,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)return 0 ; }i40e_set_default_ptype_table (dev); - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); intr_handle = pci_dev->intr_handle;rte_eth_copy_pci_info (dev, pci_dev);
@@ -2041,7 +2041,7 @@ void i40e_vsi_queues_unbind_intr(struct i40e_vsi *vsi) {struct rte_eth_dev *dev =I40E_VSI_TO_ETH_DEV (vsi); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi);uint16_t msix_vect = vsi->msix_intr;
@@ -2157,7 +2157,7 @@ int i40e_vsi_queues_bind_intr(struct i40e_vsi *vsi, uint16_t itr_idx) {struct rte_eth_dev *dev =I40E_VSI_TO_ETH_DEV (vsi); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi);uint16_t msix_vect = vsi->msix_intr;
@@ -2236,7 +2236,7 @@ void i40e_vsi_enable_queues_intr(struct i40e_vsi *vsi) {struct rte_eth_dev *dev =I40E_VSI_TO_ETH_DEV (vsi); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi);struct i40e_pf *pf =I40E_VSI_TO_PF (vsi);
@@ -2263,7 +2263,7 @@ void i40e_vsi_disable_queues_intr(struct i40e_vsi *vsi) {struct rte_eth_dev *dev =I40E_VSI_TO_ETH_DEV (vsi); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_hw *hw =I40E_VSI_TO_HW (vsi);struct i40e_pf *pf =I40E_VSI_TO_PF (vsi);
@@ -2431,7 +2431,7 @@ i40e_dev_start(struct rte_eth_dev *dev)struct i40e_adapter *ad =I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);int ret, i; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;struct i40e_vsi *vsi;
@@ -2612,7 +2612,7 @@ i40e_dev_stop(struct rte_eth_dev *dev)struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct i40e_vsi *main_vsi = pf->main_vsi; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int i;
@@ -2674,7 +2674,7 @@ i40e_dev_close(struct rte_eth_dev *dev) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_filter_control_settings settings;struct rte_flow *p_flow;
@@ -3831,7 +3831,7 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct i40e_vsi *vsi = pf->main_vsi; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); dev_info->max_rx_queues = vsi->nb_qps; dev_info->max_tx_queues = vsi->nb_qps;
@@ -4884,7 +4884,7 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct i40e_hw *hw =I40E_PF_TO_HW (pf); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint16_t qp_count =0 , vsi_count =0 ;if (pci_dev->max_vfs && !hw->func_caps.sr_iov_1_1) {
@@ -10033,7 +10033,7 @@ i40e_dev_flow_ops_get(struct rte_eth_dev *dev,static void i40e_enable_extended_tag (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint32_t buf =0 ;int ret;
@@ -11219,7 +11219,7 @@ i40e_dev_get_dcb_info(struct rte_eth_dev *dev,static int i40e_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint16_t msix_intr;
@@ -11247,7 +11247,7 @@ i40e_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)static int i40e_dev_rx_queue_intr_disable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint16_t msix_intr;
drivers/net/intel/i40e/i40e_ethdev.h +1 -1
@@ -1467,7 +1467,7 @@ int i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params);int i40e_vf_representor_uninit (struct rte_eth_dev *ethdev);#define I40E_DEV_TO_PCI (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device) + RTE_CLASS_TO_BUS_DEVICE(eth_dev, struct rte_pci_device)/* I40E_DEV_PRIVATE_TO */ #define I40E_DEV_PRIVATE_TO_PF (adapter) \
drivers/net/intel/iavf/iavf_ethdev.c +4 -4
@@ -1947,7 +1947,7 @@ iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) {struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (adapter);struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter);uint16_t msix_intr;
@@ -1983,7 +1983,7 @@ iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)static int iavf_dev_rx_queue_intr_disable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint16_t msix_intr;
@@ -2767,7 +2767,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)IAVF_DEV_PRIVATE_TO_ADAPTER (eth_dev->data->dev_private);struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (adapter);struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int ret =0 ;PMD_INIT_FUNC_TRACE ();
@@ -2926,7 +2926,7 @@ static int iavf_dev_close(struct rte_eth_dev *dev) {struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);
drivers/net/intel/ice/ice_dcf.c +3 -3
@@ -658,7 +658,7 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,int ice_dcf_handle_vsi_update_event (struct ice_dcf_hw *hw) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (hw->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (hw->eth_dev, *pci_dev);int i =0 ;int err =-1 ;
@@ -738,7 +738,7 @@ dcf_get_vlan_offload_caps_v2(struct ice_dcf_hw *hw)int ice_dcf_init_hw (struct rte_eth_dev *eth_dev,struct ice_dcf_hw *hw) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int ret, size; hw->resetting = false;
@@ -873,7 +873,7 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)void ice_dcf_uninit_hw (struct rte_eth_dev *eth_dev,struct ice_dcf_hw *hw) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;if (hw->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_QOS )
drivers/net/intel/ice/ice_ethdev.c +3 -3
@@ -2623,7 +2623,7 @@ ice_dev_init(struct rte_eth_dev *dev) }ice_set_default_ptype_table (dev); - pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); intr_handle = pci_dev->intr_handle; pf->adapter =ICE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);
@@ -2956,7 +2956,7 @@ ice_dev_close(struct rte_eth_dev *dev) {struct ice_pf *pf =ICE_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct ice_hw *hw =ICE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ice_adapter *ad =ICE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);
@@ -4520,7 +4520,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)struct ice_pf *pf =ICE_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct ice_hw *hw =ICE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct ice_vsi *vsi = pf->main_vsi; -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);bool is_safe_mode = pf->adapter->is_safe_mode;u64 phy_type_low;u64 phy_type_high;
drivers/net/intel/ice/ice_ethdev.h +1 -1
@@ -708,7 +708,7 @@ struct ice_vsi_vlan_pvid_info { };#define ICE_DEV_TO_PCI (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device) + RTE_CLASS_TO_BUS_DEVICE(eth_dev, struct rte_pci_device)/* ICE_DEV_PRIVATE_TO */ #define ICE_DEV_PRIVATE_TO_PF (adapter) \
drivers/net/intel/idpf/idpf_ethdev.h +1 -1
@@ -85,7 +85,7 @@ struct idpf_adapter_ext {TAILQ_HEAD (idpf_adapter_list, idpf_adapter_ext);#define IDPF_DEV_TO_PCI (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device) + RTE_CLASS_TO_BUS_DEVICE(eth_dev, struct rte_pci_device)#define IDPF_ADAPTER_TO_EXT (p) \ container_of((p), struct idpf_adapter_ext, base)
drivers/net/intel/ipn3ke/ipn3ke_ethdev.h +0 -3
@@ -310,9 +310,6 @@ struct ipn3ke_hw {uint8_t *hw_addr; }; -#define RTE_ETH_DEV_TO_AFU (eth_dev) \ - RTE_BUS_DEVICE((eth_dev)->device, struct rte_afu_device) -/** * PCIe MMIO Access */
drivers/net/intel/ipn3ke/ipn3ke_representor.c +3 -3
@@ -2070,7 +2070,7 @@ ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)return -EINVAL ; } - afu_dev =RTE_ETH_DEV_TO_AFU (ethdev); + afu_dev =RTE_CLASS_TO_BUS_DEVICE (ethdev, *afu_dev);if (!afu_dev) {IPN3KE_AFU_PMD_ERR ("afu device to reset is NULL!" );return -EINVAL ;
@@ -2138,7 +2138,7 @@ ipn3ke_rpst_stats_getreturn -EINVAL ; } - afu_dev =RTE_ETH_DEV_TO_AFU (ethdev); + afu_dev =RTE_CLASS_TO_BUS_DEVICE (ethdev, *afu_dev);if (!afu_dev) {IPN3KE_AFU_PMD_ERR ("afu device to get statistics is NULL!" );return -EINVAL ;
@@ -2228,7 +2228,7 @@ ipn3ke_rpst_xstats_getreturn -EINVAL ; } - afu_dev =RTE_ETH_DEV_TO_AFU (ethdev); + afu_dev =RTE_CLASS_TO_BUS_DEVICE (ethdev, *afu_dev);if (!afu_dev) {IPN3KE_AFU_PMD_ERR ("afu device to get statistics is NULL!" );return -EINVAL ;
drivers/net/intel/ixgbe/ixgbe_ethdev.c +20 -20
@@ -1085,7 +1085,7 @@ static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { struct ixgbe_adapter *ad = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);
@@ -1598,7 +1598,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)int diag;uint32_t tc, tcs;struct ixgbe_adapter *ad = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private);
@@ -2264,7 +2264,7 @@ ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)static int ixgbe_check_vf_rss_rxq_num (struct rte_eth_dev *dev,uint16_t nb_rx_q) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);switch (nb_rx_q) {case 1 :
@@ -2506,7 +2506,7 @@ ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,struct rte_pci_device *pci_dev;int ret; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); ret =rte_eth_link_get_nowait (dev->data->port_id, &link);if (ret <0 )return ret;
@@ -2614,7 +2614,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct ixgbe_vf_info *vfinfo = *IXGBE_DEV_PRIVATE_TO_P_VFDATA (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;int err;
@@ -2921,7 +2921,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct ixgbe_vf_info *vfinfo = *IXGBE_DEV_PRIVATE_TO_P_VFDATA (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int vf; struct ixgbe_tm_conf *tm_conf =
@@ -3082,7 +3082,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int retries =0 ;int ret;
@@ -3970,7 +3970,7 @@ ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)static int ixgbe_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
@@ -4100,7 +4100,7 @@ static int ixgbevf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); dev_info->max_rx_queues = (uint16_t )hw->mac.max_rx_queues;
@@ -4668,7 +4668,7 @@ ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)static void ixgbe_dev_link_status_print (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_eth_link link;rte_eth_linkstatus_get (dev, &link);
@@ -4780,7 +4780,7 @@ static void ixgbe_dev_interrupt_delayed_handler(void *param) {struct rte_eth_dev *dev = (struct rte_eth_dev *)param; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ixgbe_interrupt *intr =IXGBE_DEV_PRIVATE_TO_INTR (dev->data->dev_private);
@@ -5344,7 +5344,7 @@ ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)static int ixgbe_set_default_mac_addr (struct rte_eth_dev *dev,struct rte_ether_addr *addr) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);/* * This function calls into the base driver, which in turn will use
@@ -5508,7 +5508,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint32_t intr_vector =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int err, mask =0 ;
@@ -5621,7 +5621,7 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct ixgbe_adapter *adapter = dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/*
@@ -5669,7 +5669,7 @@ static int ixgbevf_dev_close(struct rte_eth_dev *dev) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;
@@ -5975,7 +5975,7 @@ ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)static int ixgbevf_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ixgbe_interrupt *intr =IXGBE_DEV_PRIVATE_TO_INTR (dev->data->dev_private);
@@ -6005,7 +6005,7 @@ ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)IXGBE_DEV_PRIVATE_TO_INTR (dev->data->dev_private);struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =IXGBE_MISC_VEC_ID ;
@@ -6025,7 +6025,7 @@ ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)static int ixgbe_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t mask; struct ixgbe_hw *hw =
@@ -6162,7 +6162,7 @@ ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,static void ixgbevf_configure_msix (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);
@@ -6213,7 +6213,7 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev)static void ixgbe_configure_msix (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);
drivers/net/intel/ixgbe/ixgbe_flow.c +2 -2
@@ -1272,7 +1272,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,const struct rte_flow_item_e_tag *e_tag_mask;const struct rte_flow_action *act;const struct rte_flow_action_vf *act_vf; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!pattern) { rte_flow_error_set(error, EINVAL,
@@ -1430,7 +1430,7 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev, {int ret =0 ;struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint16_t vf_num; ret = cons_parse_l2_tn_filter(dev, attr, pattern,
drivers/net/intel/ixgbe/ixgbe_pf.c +1 -1
@@ -32,7 +32,7 @@static inline uint16_t dev_num_vf (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);return pci_dev->max_vfs; }
drivers/net/intel/ixgbe/ixgbe_tm.c +1 -1
@@ -365,7 +365,7 @@ ixgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no, uint16_t *base, uint16_t *nb) { uint8_t nb_tcs = ixgbe_tc_nb_get(dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint16_t vf_num = pci_dev->max_vfs; *base =0 ;
drivers/net/intel/ixgbe/ixgbe_vf_representor.c +1 -1
@@ -190,7 +190,7 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) representor->pf_ethdev = ((struct ixgbe_vf_representor *)init_params)->pf_ethdev; - pci_dev =RTE_ETH_DEV_TO_PCI (representor->pf_ethdev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (representor->pf_ethdev, *pci_dev);if (representor->vf_id >= pci_dev->max_vfs)return -ENODEV ;
drivers/net/intel/ixgbe/rte_pmd_ixgbe.c +10 -10
@@ -25,7 +25,7 @@ rte_pmd_ixgbe_set_vf_mac_addr(uint16_t port, uint16_t vf,RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -60,7 +60,7 @@ rte_pmd_ixgbe_ping_vf(uint16_t port, uint16_t vf)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -92,7 +92,7 @@ rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -123,7 +123,7 @@ rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -153,7 +153,7 @@ rte_pmd_ixgbe_set_vf_vlan_insert(uint16_t port, uint16_t vf, uint16_t vlan_id)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -252,7 +252,7 @@ rte_pmd_ixgbe_set_vf_split_drop_en(uint16_t port, uint16_t vf, uint8_t on)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -289,7 +289,7 @@ rte_pmd_ixgbe_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private);if (!is_ixgbe_supported (dev))
@@ -338,7 +338,7 @@ rte_pmd_ixgbe_set_vf_rxmode(uint16_t port, uint16_t vf,RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -386,7 +386,7 @@ rte_pmd_ixgbe_set_vf_rx(uint16_t port, uint16_t vf, uint8_t on)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
@@ -438,7 +438,7 @@ rte_pmd_ixgbe_set_vf_tx(uint16_t port, uint16_t vf, uint8_t on)RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV ); dev = &rte_eth_devices[port]; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!is_ixgbe_supported (dev))return -ENOTSUP ;
drivers/net/nbl/nbl_core.c +1 -1
@@ -32,7 +32,7 @@ static void nbl_init_func_caps(const struct rte_pci_device *pci_dev, struct nbl_int nbl_core_init (struct nbl_adapter *adapter,struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);const struct nbl_product_core_ops *product_base_ops =NULL ;struct nbl_common_info *common =NBL_ADAPTER_TO_COMMON (adapter);int ret =0 ;
drivers/net/nbl/nbl_dev/nbl_dev.c +3 -3
@@ -868,7 +868,7 @@ static int nbl_dev_common_start(struct nbl_dev_mgt *dev_mgt)struct nbl_dev_net_mgt *net_dev =NBL_DEV_MGT_TO_NET_DEV (dev_mgt);struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt);struct nbl_board_port_info *board_info; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (net_dev->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (net_dev->eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;u8 *mac;int ret;
@@ -991,7 +991,7 @@ static void nbl_dev_leonis_stop(void *p)const struct nbl_common_info *common =NBL_DEV_MGT_TO_COMMON (dev_mgt);const struct nbl_dispatch_ops *disp_ops =NBL_DEV_MGT_TO_DISP_OPS (dev_mgt);const struct nbl_channel_ops *chan_ops =NBL_DEV_MGT_TO_CHAN_OPS (dev_mgt); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (net_dev->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (net_dev->eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;u8 *mac;
@@ -1105,7 +1105,7 @@ static int nbl_dev_setup_net_dev(struct nbl_dev_mgt *dev_mgt,struct nbl_register_net_param register_param = {0 };struct nbl_register_net_result register_result = {0 };struct nbl_dev_ring_mgt *ring_mgt; -const struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +const struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int ret =0 ; net_dev =rte_zmalloc ("nbl_dev_net" ,sizeof (struct nbl_dev_net_mgt ),0 );
drivers/net/netvsc/hn_ethdev.c +1 -2
@@ -1627,7 +1627,6 @@ static int eth_hn_dev_init(struct rte_eth_dev *eth_dev) {struct hn_data *hv = eth_dev->data->dev_private; -struct rte_device *device = eth_dev->device;struct rte_vmbus_device *vmbus;uint32_t mtu;unsigned int rxr_cnt;
@@ -1638,7 +1637,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)rte_spinlock_init (&hv->hotadd_lock);LIST_INIT (&hv->hotadd_list); - vmbus =RTE_BUS_DEVICE (device, *vmbus); + vmbus =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *vmbus); eth_dev->dev_ops = &hn_eth_dev_ops; eth_dev->rx_queue_count = hn_dev_rx_queue_count; eth_dev->rx_descriptor_status = hn_dev_rx_queue_status;
drivers/net/nfp/nfp_ethdev.c +4 -4
@@ -363,7 +363,7 @@ nfp_net_start(struct rte_eth_dev *dev)struct rte_eth_txmode *txmode;struct nfp_net_hw_priv *hw_priv;struct nfp_app_fw_nic *app_fw_nic; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle; net_hw = dev->data->dev_private;
@@ -770,7 +770,7 @@ nfp_net_close(struct rte_eth_dev *dev) hw = dev->data->dev_private; pf_dev = hw_priv->pf_dev; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); app_fw_nic =NFP_PRIV_TO_APP_FW_NIC (pf_dev->app_fw_priv);/*
@@ -1022,7 +1022,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev,struct nfp_net_hw_priv *hw_priv;struct nfp_app_fw_nic *app_fw_nic; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); net_hw = eth_dev->data->dev_private; hw_init = para;
@@ -2879,7 +2879,7 @@ nfp_pci_uninit(struct rte_eth_dev *eth_dev)uint16_t port_id;struct rte_pci_device *pci_dev; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* Free up all physical ports under PF */ RTE_ETH_FOREACH_DEV_OF (port_id, &pci_dev->device)
drivers/net/nfp/nfp_ethdev_vf.c +3 -3
@@ -30,7 +30,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)struct nfp_net_hw *net_hw;struct rte_eth_conf *dev_conf;struct rte_eth_rxmode *rxmode; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;/* Disabling queues just in case... */
@@ -169,7 +169,7 @@ nfp_netvf_close(struct rte_eth_dev *dev)return 0 ; net_hw = dev->data->dev_private; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); hw_priv = dev->process_private;rte_free (net_hw->eth_xstats_base);
@@ -266,7 +266,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)const struct nfp_dev_info *dev_info; port = eth_dev->data->port_id; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); dev_info =nfp_dev_info_get (pci_dev->id.device_id);if (dev_info ==NULL ) {
drivers/net/nfp/nfp_net_common.c +4 -4
@@ -1568,7 +1568,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,struct nfp_net_hw *hw;struct rte_pci_device *pci_dev; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (rte_intr_type_get (pci_dev->intr_handle) !=RTE_INTR_HANDLE_UIO ) base =1 ;
@@ -1589,7 +1589,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,struct nfp_net_hw *hw;struct rte_pci_device *pci_dev; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (rte_intr_type_get (pci_dev->intr_handle) !=RTE_INTR_HANDLE_UIO ) base =1 ;
@@ -1606,7 +1606,7 @@ static void nfp_net_dev_link_status_print(struct rte_eth_dev *dev) {struct rte_eth_link link; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);rte_eth_linkstatus_get (dev, &link);if (link.link_status !=0 )
@@ -1635,7 +1635,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)struct rte_pci_device *pci_dev; hw =nfp_net_get_hw (dev); - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);/* Make sure all updates are written before un-masking */ rte_wmb ();
drivers/net/ngbe/ngbe_ethdev.c +10 -10
@@ -321,7 +321,7 @@ ngbe_swfw_lock_reset(struct ngbe_hw *hw)static int eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct ngbe_hw *hw =ngbe_dev_hw (eth_dev);struct ngbe_vfta *shadow_vfta =NGBE_DEV_VFTA (eth_dev);struct ngbe_hwstrip *hwstrip =NGBE_DEV_HWSTRIP (eth_dev);
@@ -958,7 +958,7 @@ ngbe_dev_start(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev);struct ngbe_hw_stats *hw_stats =NGBE_DEV_STATS (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;int err;
@@ -1160,7 +1160,7 @@ ngbe_dev_stop(struct rte_eth_dev *dev)struct ngbe_adapter *adapter =ngbe_dev_adapter (dev);struct ngbe_hw *hw =ngbe_dev_hw (dev);struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int vf;
@@ -1256,7 +1256,7 @@ static int ngbe_dev_close(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int retries =0 ;int ret;
@@ -1843,7 +1843,7 @@ ngbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)static int ngbe_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct ngbe_hw *hw =ngbe_dev_hw (dev); dev_info->max_rx_queues = (uint16_t )hw->mac.max_rx_queues;
@@ -2258,7 +2258,7 @@ ngbe_dev_interrupt_get_status(struct rte_eth_dev *dev)static void ngbe_dev_link_status_print (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_eth_link link;rte_eth_linkstatus_get (dev, &link);
@@ -2472,7 +2472,7 @@ static s32 ngbe_fc_hpbthresh_set(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);u32 max_frame_size, tc, dv_id, rx_pb;s32 kb, marker;
@@ -2653,7 +2653,7 @@ ngbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)static int ngbe_set_default_mac_addr (struct rte_eth_dev *dev,struct rte_ether_addr *addr) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);ngbe_remove_rar (dev,0 );ngbe_add_rar (dev, addr,0 , pci_dev->max_vfs);
@@ -2797,7 +2797,7 @@ ngbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)static int ngbe_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ngbe_hw *hw =ngbe_dev_hw (dev);uint32_t mask;
@@ -2867,7 +2867,7 @@ ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,static void ngbe_configure_msix (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ngbe_hw *hw =ngbe_dev_hw (dev);uint32_t queue_id, base =NGBE_MISC_VEC_ID ;
drivers/net/ngbe/ngbe_ethdev_vf.c +8 -8
@@ -152,7 +152,7 @@ eth_ngbevf_dev_init(struct rte_eth_dev *eth_dev) {int err;uint32_t tc, tcs; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ngbe_hw *hw =ngbe_dev_hw (eth_dev);struct ngbe_vfta *shadow_vfta =NGBE_DEV_VFTA (eth_dev);
@@ -465,7 +465,7 @@ static int ngbevf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);struct ngbe_hw *hw =ngbe_dev_hw (dev); dev_info->max_rx_queues = (uint16_t )hw->mac.max_rx_queues;
@@ -588,7 +588,7 @@ ngbevf_dev_start(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev);uint32_t intr_vector =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int err, mask =0 ;
@@ -688,7 +688,7 @@ ngbevf_dev_stop(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev);struct ngbe_adapter *adapter =ngbe_dev_adapter (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;if (hw->adapter_stopped)
@@ -725,7 +725,7 @@ static int ngbevf_dev_close(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;
@@ -898,7 +898,7 @@ ngbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)static int ngbevf_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ngbe_interrupt *intr =ngbe_dev_intr (dev);struct ngbe_hw *hw =ngbe_dev_hw (dev);
@@ -920,7 +920,7 @@ ngbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) {struct ngbe_interrupt *intr =ngbe_dev_intr (dev);struct ngbe_hw *hw =ngbe_dev_hw (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =NGBE_MISC_VEC_ID ;
@@ -960,7 +960,7 @@ ngbevf_set_ivar_map(struct ngbe_hw *hw, int8_t direction,static void ngbevf_configure_msix (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct ngbe_hw *hw =ngbe_dev_hw (dev);uint32_t q_idx;
drivers/net/ngbe/ngbe_pf.c +1 -1
@@ -18,7 +18,7 @@static inline uint16_t dev_num_vf (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* EM only support 7 VFs. */ return pci_dev->max_vfs;
drivers/net/octeon_ep/otx_ep_ethdev.c +1 -1
@@ -777,7 +777,7 @@ static int otx_ep_eth_dev_query_set_vf_mac(struct rte_eth_dev *eth_dev,static int otx_ep_eth_dev_init (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev);struct otx_ep_device *otx_epvf =OTX_EP_DEV (eth_dev);struct rte_ether_addr vf_mac_addr;int ret =0 ;
drivers/net/octeon_ep/otx_ep_mbox.c +3 -3
@@ -346,7 +346,7 @@ otx_ep_mbox_intr_handler(void *param) {struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;struct otx_ep_device *otx_ep = (struct otx_ep_device *)eth_dev->data->dev_private; -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev);union otx_ep_mbox_word mbox_cmd;if (otx2_read64 (otx_ep->hw_addr +CNXK_EP_R_MBOX_PF_VF_INT (0 )) &CNXK_EP_MBOX_INTR ) {
@@ -369,7 +369,7 @@ int otx_ep_mbox_init(struct rte_eth_dev *eth_dev) {struct otx_ep_device *otx_ep = (struct otx_ep_device *)eth_dev->data->dev_private; -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev);uint64_t reg_val;int rc;
@@ -402,7 +402,7 @@ void otx_ep_mbox_uninit(struct rte_eth_dev *eth_dev) {struct otx_ep_device *otx_ep = (struct otx_ep_device *)eth_dev->data->dev_private; -struct rte_pci_device *pdev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pdev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pdev);otx2_write64 (0 , otx_ep->hw_addr +CNXK_EP_R_MBOX_PF_VF_INT (0 ));
drivers/net/qede/qede_ethdev.c +3 -3
@@ -1231,7 +1231,7 @@ static int qede_args_check(const char *key, const char *val, void *opaque)static int qede_args (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_kvargs *kvlist;struct rte_devargs *devargs;int ret;
@@ -1540,7 +1540,7 @@ static void qede_poll_sp_sb_cb(void *param)static int qede_dev_close (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct qede_dev *qdev =QEDE_INIT_QDEV (eth_dev);struct ecore_dev *edev =QEDE_INIT_EDEV (qdev);int ret =0 ;
@@ -2529,7 +2529,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) adapter = eth_dev->data->dev_private; adapter->ethdev = eth_dev; edev = &adapter->edev; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); pci_addr = pci_dev->addr;PMD_INIT_FUNC_TRACE (edev);
drivers/net/r8169/r8169_ethdev.c +3 -3
@@ -301,7 +301,7 @@ rtl_dev_start(struct rte_eth_dev *dev) {struct rtl_adapter *adapter =RTL_DEV_PRIVATE (dev);struct rtl_hw *hw = &adapter->hw; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int err;
@@ -684,7 +684,7 @@ rtl_dev_interrupt_handler(void *param)static int rtl_dev_close (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rtl_adapter *adapter =RTL_DEV_PRIVATE (dev);struct rtl_hw *hw = &adapter->hw;
@@ -908,7 +908,7 @@ rtl_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_confstatic int rtl_dev_init (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rtl_adapter *adapter =RTL_DEV_PRIVATE (dev);struct rtl_hw *hw = &adapter->hw;
drivers/net/rnp/rnp_ethdev.c +3 -3
@@ -728,7 +728,7 @@ static int rnp_dev_close(struct rte_eth_dev *eth_dev)if (adapter->intr_registered && adapter->eth_dev == eth_dev)rnp_change_manage_port (adapter);if (adapter->closed_ports == adapter->inited_ports) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);if (adapter->intr_registered) {/* disable uio irq before callback unregister */ rte_intr_disable (pci_dev->intr_handle);
@@ -1667,7 +1667,7 @@ rnp_rx_reset_pool_setup(struct rnp_eth_adapter *adapter)static int rnp_eth_dev_init (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rnp_eth_port *port =RNP_DEV_TO_PORT (eth_dev);char name[RTE_ETH_NAME_MAX_LEN ] =" " ;
@@ -1798,7 +1798,7 @@ rnp_eth_dev_init(struct rte_eth_dev *eth_dev)static int rnp_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);uint16_t port_id;int err =0 ;
drivers/net/sfc/sfc.c +2 -2
@@ -781,7 +781,7 @@ static int sfc_mem_bar_init(struct sfc_adapter *sa, const efx_bar_region_t *mem_ebrp) { struct rte_eth_dev *eth_dev = sa->eth_dev; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);efsys_bar_t *ebp = &sa->mem_bar;struct rte_mem_resource *res = &pci_dev->mem_resource[mem_ebrp->ebr_index];
@@ -1283,7 +1283,7 @@ sfc_probe(struct sfc_adapter *sa) {efx_bar_region_t mem_ebrp;struct rte_eth_dev *eth_dev = sa->eth_dev; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);efx_nic_t *enp;int rc;
drivers/net/sfc/sfc_ethdev.c +1 -1
@@ -3309,7 +3309,7 @@ static int sfc_eth_dev_init(struct rte_eth_dev *dev, void *init_params) { struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct sfc_ethdev_init_data *init_data = init_params;uint32_t logtype_main;struct sfc_adapter *sa;
drivers/net/sfc/sfc_intr.c +5 -5
@@ -56,7 +56,7 @@ sfc_intr_line_handler(void *cb_arg)boolean_t fatal;uint32_t qmask;unsigned int lsc_seq = sa->port.lsc_seq; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (sa->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev);sfc_log_init (sa,"entry" );
@@ -102,7 +102,7 @@ sfc_intr_message_handler(void *cb_arg)efx_nic_t *enp = sa->nic;boolean_t fatal;unsigned int lsc_seq = sa->port.lsc_seq; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (sa->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev);sfc_log_init (sa,"entry" );
@@ -158,7 +158,7 @@ sfc_intr_start(struct sfc_adapter *sa)if (rc !=0 ) goto fail_intr_init; - pci_dev =RTE_ETH_DEV_TO_PCI (sa->eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev); intr_handle = pci_dev->intr_handle;if (intr->handler !=NULL ) {
@@ -240,7 +240,7 @@ void sfc_intr_stop(struct sfc_adapter *sa) {struct sfc_intr *intr = &sa->intr; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (sa->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev);sfc_log_init (sa,"entry" );
@@ -318,7 +318,7 @@ int sfc_intr_attach(struct sfc_adapter *sa) {struct sfc_intr *intr = &sa->intr; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (sa->eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev);sfc_log_init (sa,"entry" );
drivers/net/sfc/sfc_rx.c +2 -1
@@ -1277,8 +1277,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index, info.nic_dma_info = &sas->nic_dma_info; +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev); rc = sa->priv.dp_rx->qcreate (sa->eth_dev->data->port_id, sw_index, - &RTE_ETH_DEV_TO_PCI (sa->eth_dev)->addr, + &pci_dev->addr, socket_id, &info, &rxq_info->dp);if (rc !=0 ) goto fail_dp_rx_qcreate;
drivers/net/sfc/sfc_sriov.c +1 -1
@@ -44,7 +44,7 @@ sriov_mac_addr_assigned(const efx_vport_config_t *vport_config,int sfc_sriov_attach (struct sfc_adapter *sa) { -const struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (sa->eth_dev); +const struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev);struct sfc_sriov *sriov = &sa->sriov;efx_vport_config_t *vport_config;unsigned int i;
drivers/net/sfc/sfc_tx.c +2 -1
@@ -230,8 +230,9 @@ sfc_tx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index, info.max_pdu = encp->enc_mac_pdu_max; +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (sa->eth_dev, *pci_dev); rc = sa->priv.dp_tx->qcreate (sa->eth_dev->data->port_id, sw_index, - &RTE_ETH_DEV_TO_PCI (sa->eth_dev)->addr, + &pci_dev->addr, socket_id, &info, &txq_info->dp);if (rc !=0 ) goto fail_dp_tx_qinit;
drivers/net/sxe2/sxe2_ethdev.c +2 -2
@@ -561,7 +561,7 @@ static int32_t sxe2_dev_info_init(struct rte_eth_dev *dev) {struct sxe2_adapter *adapter =SXE2_DEV_PRIVATE_TO_ADAPTER (dev); -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct sxe2_dev_info *dev_info = &adapter->dev_info;struct sxe2_drv_dev_info_resp dev_info_resp = {0 };struct sxe2_drv_dev_fw_info_resp dev_fw_info_resp = {0 };
@@ -600,7 +600,7 @@ static int32_t sxe2_dev_info_init(struct rte_eth_dev *dev)int32_t sxe2_dev_pci_map_init (struct rte_eth_dev *dev) {struct sxe2_adapter *adapter =SXE2_DEV_PRIVATE_TO_ADAPTER (dev); -struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct sxe2_pci_map_context *map_ctxt = &adapter->map_ctxt;struct sxe2_pci_map_bar_info *bar_info =NULL ;struct sxe2_pci_map_segment_info *seg_info =NULL ;
drivers/net/thunderx/nicvf_ethdev.c +2 -2
@@ -1471,7 +1471,7 @@ static int nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { struct nicvf *nic = nicvf_pmd_priv(dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);PMD_INIT_FUNC_TRACE ();
@@ -2234,7 +2234,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev) } } - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);rte_eth_copy_pci_info (eth_dev, pci_dev); eth_dev->data->dev_flags |=RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS ;
drivers/net/txgbe/txgbe_ethdev.c +13 -13
@@ -525,7 +525,7 @@ static void txgbe_parse_devargs(struct rte_eth_dev *dev) {struct rte_eth_fdir_conf *fdir_conf =TXGBE_DEV_FDIR_CONF (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_devargs *devargs = pci_dev->device.devargs;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct rte_kvargs *kvlist;
@@ -601,7 +601,7 @@ static int eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { struct txgbe_adapter *ad = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct txgbe_hw *hw =TXGBE_DEV_HW (eth_dev);struct txgbe_vfta *shadow_vfta =TXGBE_DEV_VFTA (eth_dev);struct txgbe_hwstrip *hwstrip =TXGBE_DEV_HWSTRIP (eth_dev);
@@ -1397,7 +1397,7 @@ txgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)static int txgbe_check_vf_rss_rxq_num (struct rte_eth_dev *dev,uint16_t nb_rx_q) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);switch (nb_rx_q) {case 1 :
@@ -1664,7 +1664,7 @@ txgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,struct rte_pci_device *pci_dev;int ret; - pci_dev =RTE_ETH_DEV_TO_PCI (dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev); ret =rte_eth_link_get_nowait (dev->data->port_id, &link);if (ret <0 )return ret;
@@ -1736,7 +1736,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct txgbe_hw_stats *hw_stats =TXGBE_DEV_STATS (dev);struct txgbe_vf_info *vfinfo = *TXGBE_DEV_VFDATA (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t intr_vector =0 ;int err;
@@ -2034,7 +2034,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)struct txgbe_adapter *adapter =TXGBE_DEV_ADAPTER (dev);struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct txgbe_vf_info *vfinfo = *TXGBE_DEV_VFDATA (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int vf;struct txgbe_tm_conf *tm_conf =TXGBE_DEV_TM_CONF (dev);
@@ -2163,7 +2163,7 @@ static int txgbe_dev_close(struct rte_eth_dev *dev) {struct txgbe_hw *hw =TXGBE_DEV_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int retries =0 ;int ret;
@@ -2822,7 +2822,7 @@ txgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)static int txgbe_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct txgbe_hw *hw =TXGBE_DEV_HW (dev); dev_info->max_rx_queues = (uint16_t )hw->mac.max_rx_queues;
@@ -3500,7 +3500,7 @@ txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev,static void txgbe_dev_link_status_print (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_eth_link link;rte_eth_linkstatus_get (dev, &link);
@@ -3631,7 +3631,7 @@ static void txgbe_dev_interrupt_delayed_handler(void *param) {struct rte_eth_dev *dev = (struct rte_eth_dev *)param; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_interrupt *intr =TXGBE_DEV_INTR (dev);struct txgbe_hw *hw =TXGBE_DEV_HW (dev);
@@ -3978,7 +3978,7 @@ txgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)static int txgbe_set_default_mac_addr (struct rte_eth_dev *dev,struct rte_ether_addr *addr) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);txgbe_remove_rar (dev,0 );txgbe_add_rar (dev, addr,0 , pci_dev->max_vfs);
@@ -4149,7 +4149,7 @@ txgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)static int txgbe_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t mask;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);
@@ -4231,7 +4231,7 @@ txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,static void txgbe_configure_msix (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);uint32_t queue_id, base =TXGBE_MISC_VEC_ID ;
drivers/net/txgbe/txgbe_ethdev_vf.c +8 -8
@@ -232,7 +232,7 @@ eth_txgbevf_dev_init(struct rte_eth_dev *eth_dev)int err;uint32_t tc, tcs;struct txgbe_adapter *ad = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (eth_dev);struct txgbe_vfta *shadow_vfta =TXGBE_DEV_VFTA (eth_dev);
@@ -561,7 +561,7 @@ static int txgbevf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);struct txgbe_hw *hw =TXGBE_DEV_HW (dev); dev_info->max_rx_queues = (uint16_t )hw->mac.max_rx_queues;
@@ -696,7 +696,7 @@ txgbevf_dev_start(struct rte_eth_dev *dev) {struct txgbe_hw *hw =TXGBE_DEV_HW (dev);uint32_t intr_vector =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int err, mask =0 ;
@@ -801,7 +801,7 @@ txgbevf_dev_stop(struct rte_eth_dev *dev) {struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct txgbe_adapter *adapter =TXGBE_DEV_ADAPTER (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;if (hw->adapter_stopped)
@@ -841,7 +841,7 @@ static int txgbevf_dev_close(struct rte_eth_dev *dev) {struct txgbe_hw *hw =TXGBE_DEV_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;int ret;
@@ -1023,7 +1023,7 @@ txgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)static int txgbevf_dev_rx_queue_intr_enable (struct rte_eth_dev *dev,uint16_t queue_id) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_interrupt *intr =TXGBE_DEV_INTR (dev);struct txgbe_hw *hw =TXGBE_DEV_HW (dev);
@@ -1045,7 +1045,7 @@ txgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) {struct txgbe_interrupt *intr =TXGBE_DEV_INTR (dev);struct txgbe_hw *hw =TXGBE_DEV_HW (dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;uint32_t vec =TXGBE_MISC_VEC_ID ;
@@ -1085,7 +1085,7 @@ txgbevf_set_ivar_map(struct txgbe_hw *hw, int8_t direction,static void txgbevf_configure_msix (struct rte_eth_dev *dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);uint32_t q_idx;
drivers/net/txgbe/txgbe_flow.c +2 -2
@@ -1171,7 +1171,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,const struct rte_flow_item_e_tag *e_tag_mask;const struct rte_flow_action *act;const struct rte_flow_action_vf *act_vf; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);if (!pattern) { rte_flow_error_set(error, EINVAL,
@@ -1328,7 +1328,7 @@ txgbe_parse_l2_tn_filter(struct rte_eth_dev *dev, struct rte_flow_error *error) {int ret =0 ; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint16_t vf_num;if (!txgbe_is_pf (TXGBE_DEV_HW (dev))) {
drivers/net/txgbe/txgbe_pf.c +1 -1
@@ -33,7 +33,7 @@static inline uint16_t dev_num_vf (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);return pci_dev->max_vfs; }
drivers/net/txgbe/txgbe_tm.c +1 -1
@@ -354,7 +354,7 @@ txgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no, uint16_t *base, uint16_t *nb) { uint8_t nb_tcs = txgbe_tc_nb_get(dev); -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (dev, *pci_dev);uint16_t vf_num = pci_dev->max_vfs; *base =0 ;
drivers/net/virtio/virtio_pci_ethdev.c +6 -5
@@ -73,13 +73,13 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev) {struct virtio_pci_dev *dev = eth_dev->data->dev_private;struct virtio_hw *hw = &dev->hw; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int ret;if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { hw->port_id = eth_dev->data->port_id;VTPCI_DEV (hw) = pci_dev; - ret =vtpci_init (RTE_ETH_DEV_TO_PCI (eth_dev), dev); + ret =vtpci_init (pci_dev, dev);if (ret) {PMD_INIT_LOG (ERR ,"Failed to init PCI device" );return -1 ;
@@ -91,7 +91,7 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev)else VIRTIO_OPS (hw) = &virtio_legacy_ops; - ret =virtio_remap_pci (RTE_ETH_DEV_TO_PCI (eth_dev), dev); + ret =virtio_remap_pci (pci_dev, dev);if (ret <0 ) {PMD_INIT_LOG (ERR ,"Failed to remap PCI device" );return -1 ;
@@ -111,7 +111,7 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev)return 0 ; err_unmap: -rte_pci_unmap_device (RTE_ETH_DEV_TO_PCI (eth_dev)); +rte_pci_unmap_device (pci_dev);if (!dev->modern)vtpci_legacy_ioport_unmap (hw);
@@ -127,11 +127,12 @@ eth_virtio_pci_uninit(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE ();if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) { +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev); dev = eth_dev->data->dev_private; hw = &dev->hw;if (dev->modern) -rte_pci_unmap_device (RTE_ETH_DEV_TO_PCI (eth_dev)); +rte_pci_unmap_device (pci_dev);else vtpci_legacy_ioport_unmap (hw);return 0 ;
drivers/net/vmxnet3/vmxnet3_ethdev.c +2 -2
@@ -308,7 +308,7 @@ eth_vmxnet3_setup_capabilities(struct vmxnet3_hw *hw, struct rte_eth_dev *eth_dev) {uint32_t dcr, ptcr, value; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD ,VMXNET3_CMD_GET_MAX_CAPABILITIES );
@@ -381,7 +381,7 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_burst = &vmxnet3_xmit_pkts; eth_dev->tx_pkt_prepare = vmxnet3_prep_pkts; eth_dev->rx_queue_count = vmxnet3_dev_rx_queue_count; - pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);/* extra mbuf field is required to guess MSS */ vmxnet3_segs_dynfield_offset =
drivers/net/xsc/xsc_ethdev.c +1 -1
@@ -1048,7 +1048,7 @@ xsc_ethdev_init(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE (); priv->eth_dev = eth_dev; - priv->pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + priv->pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *priv->pci_dev); ret =xsc_dev_init (priv->pci_dev, &priv->xdev);if (ret) {
drivers/net/zxdh/zxdh_ethdev.c +4 -4
@@ -111,7 +111,7 @@ zxdh_intr_unmask(struct rte_eth_dev *dev)if (rte_intr_ack (dev->intr_handle) <0 )return -1 ; - hw->use_msix =zxdh_pci_msix_detect (RTE_ETH_DEV_TO_PCI (dev)); + hw->use_msix = zxdh_pci_msix_detect(RTE_CLASS_TO_BUS_DEVICE(dev, struct rte_pci_device));return 0 ; }
@@ -1586,7 +1586,7 @@ static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev) {struct zxdh_hw *hw = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);int ret =0 ; ret =zxdh_read_pci_caps (pci_dev, hw);
@@ -1820,7 +1820,7 @@ zxdh_get_dev_shared_data_idx(uint32_t dev_serial_id)static int zxdh_init_dev_share_data (struct rte_eth_dev *eth_dev) {struct zxdh_hw *hw = eth_dev->data->dev_private; -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);uint32_t serial_id = (pci_dev->addr.domain <<16 ) | (pci_dev->addr.bus <<8 ) | pci_dev->addr.devid;uint16_t slot_id =0 ;
@@ -2201,7 +2201,7 @@ is_inic_pf(uint16_t device_id)static int zxdh_eth_dev_init (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); +struct rte_pci_device *pci_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *pci_dev);struct zxdh_hw *hw = eth_dev->data->dev_private;int ret =0 ;
drivers/raw/ifpga/afu_pmd_n3000.c +2 -2
@@ -1467,11 +1467,11 @@ static struct rte_pci_device *n3000_afu_get_pci_dev(struct afu_rawdev *dev)if (!dev || !dev->rawdev || !dev->rawdev->device)return NULL ; - afudev =RTE_BUS_DEVICE (dev->rawdev->device, *afudev); + afudev =RTE_CLASS_TO_BUS_DEVICE (dev->rawdev, *afudev);if (!afudev->rawdev || !afudev->rawdev->device)return NULL ; - return RTE_BUS_DEVICE(afudev->rawdev->device, struct rte_pci_device); + return RTE_CLASS_TO_BUS_DEVICE(afudev->rawdev, struct rte_pci_device); } static int dma_afu_set_irqs(struct afu_rawdev *dev, uint32_t vec_start,
lib/eal/include/bus_driver.h +18 -0
@@ -461,6 +461,24 @@ void rte_bus_unregister(struct rte_bus *bus);#define RTE_BUS_DRIVER (drv, bus_drv_type) \ container_of(drv, typeof(bus_drv_type), driver) +/** +* Helper macro to convert a device class pointer to a bus-specific device type. +* Works with any device class (ethdev, cryptodev, eventdev, bbdev, etc.) that has +* a 'device' field pointing to struct rte_device. +* +* Example: RTE_CLASS_TO_BUS_DEVICE(eth_dev, *pci_dev) or +* RTE_CLASS_TO_BUS_DEVICE(eth_dev, struct rte_pci_device) +* +* @param class_dev +* Pointer to device class structure (e.g., struct rte_eth_dev *) +* @param bus_dev_type +* Bus device type for type inference (e.g., *pci_dev or struct rte_pci_device) +* @return +* Pointer to the bus-specific device structure +*/ +#define RTE_CLASS_TO_BUS_DEVICE (class_dev, bus_dev_type) \ + RTE_BUS_DEVICE((class_dev)->device, bus_dev_type) +/** * Helper macro to iterate over all devices on a bus. *
Signature · 1 line
2.53.0
Hi David,
First, this is a great refactoring, thank you very much.
I have tested this patchset on the UACCE bus and it passes. Two issues were found during testing and review:
1. Patch 25/25 fails to apply to the current main branch.
2. Patch 15/25 (bus: support multiple probing) has issues with directly enabling multiple probing. I suggest merging this patch into Patch 17/25.
The UACCE bus part has passed testing. Please add my Acked-by tag to the related commits.
Thanks.
Quoted 54 lines · David Marchand
This is a continuation of the work I started on the bus infrastructure, but this time, a lot of the changes were done by a AI "friend". It is still an unfinished topic as the current series focuses on probing only. The detaching/cleanup aspect is postponed to another release/time.
My AI "friend" really *sucked* at git and at separating unrelated changes, so it required quite a lot of massage/polishing afterwards. But it seems good enough now for upstream submission.
I would like to see this series merged in 26.07, so that we have enough time to stabilize it before the next LTS.
And seeing how it affects drivers, it is probably better to merge it the sooner possible (so Thomas does not have to solve too many conflicts when pulling next-* subtrees after, especially wrt the last patch).This series refactors the DPDK bus infrastructure to consolidate common operations and reduce code duplication across all bus drivers. Currently, each bus implements its own specific device/driver lists, probe logic, and lookup functions.
This series moves these common patterns into the EAL bus layer, providing generic helpers that all buses can use.The refactoring removes approximately 1,400 lines of duplicated code across the codebase while maintaining full functional equivalence.
Key changes:
- Factorize device and driver lists into structrte_bus
- Implement generic probe, device/driver lookup, and iteration helpers in EAL
- Introduce conversion macros (RTE_BUS_DEVICE,RTE_BUS_DRIVER,RTE_CLASS_TO_BUS_DEVICE) to safely convert between generic and bus-specific types
- Remove bus-specific device/driver types from most driver code
- Move probe logic from individual buses torte_bus_generic_probe()
- Separate NXP-specific metadata from generic bus structuresBenefits:
- Significant code reduction (~1,400 lines removed)
- Consistent behavior across all bus types
- Simplified bus driver implementation
- Easier maintenance and future enhancementsThe series is structured as a progressive refactoring:
- Remove redundant checks and helpers (patches 1-5)
- Add conversion macros and factorize lists (patches 6-8)
- Consolidate device/driver lookup and iteration (patches 9-11)
- Refactor probe logic (patches 12-15)
- Remove bus-specific types from drivers (patches 16-23)Note on ABI:
This series breaks the ABI for drivers (changes torte_pci_device,rte_pci_driver, and similar structures for other buses). However, the DPDK ABI policy does not provide guarantees for driver-level interfaces.
Hello Chengwen,
Quoted 9 lines · fengchengwen
Hi David,
First, this is a great refactoring, thank you very much.
I have tested this patchset on the UACCE bus and it passes. Two issues were found during testing and review:
1. Patch 25/25 fails to apply to the current main branch.
Yes, I am aware: next-net-intel got pulled in main after my rebase for v4.
Quoted 2 lines
2. Patch 15/25 (bus: support multiple probing) has issues with directly enabling multiple probing. I suggest merging this patch into Patch 17/25.
I am not sure I understand the issue, but I will have a look asap and post a v5.
Quoted 3 lines
The UACCE bus part has passed testing. Please add my Acked-by tag to the related commits.
Thanks a lot for your reviews and testing!
Signature · 1 line
David Marchand
v5 cover Consolidate bus driver infrastructure
In reply to David MarchandThis is a continuation of the work I started on the bus infrastructure, but this time, a lot of the changes were done by a AI "friend". It is still an unfinished topic as the current series focuses on probing only. The detaching/cleanup aspect is postponed to another release/time.
My AI "friend" really *sucked* at git and at separating unrelated changes, so it required quite a lot of massage/polishing afterwards. But it seems good enough now for upstream submission.
I would like to see this series merged in 26.07, so that we have enough time to stabilize it before the next LTS.
And seeing how it affects drivers, it is probably better to merge it the sooner possible (so Thomas does not have to solve too many conflicts when pulling next-* subtrees after, especially wrt the last patch).
This series refactors the DPDK bus infrastructure to consolidate common operations and reduce code duplication across all bus drivers. Currently, each bus implements its own specific device/driver lists, probe logic, and lookup functions.
This series moves these common patterns into the EAL bus layer, providing generic helpers that all buses can use.
The refactoring removes approximately 1,400 lines of duplicated code across the codebase while maintaining full functional equivalence.
Key changes:
- Factorize device and driver lists into struct rte_bus
- Implement generic probe, device/driver lookup, and iteration helpers in EAL
- Introduce conversion macros (RTE_BUS_DEVICE, RTE_BUS_DRIVER, RTE_CLASS_TO_BUS_DEVICE) to safely convert between generic and bus-specific types
- Remove bus-specific device/driver types from most driver code
- Move probe logic from individual buses to rte_bus_generic_probe()
- Separate NXP-specific metadata from generic bus structures
Benefits:
- Significant code reduction (~1,400 lines removed)
- Consistent behavior across all bus types
- Simplified bus driver implementation
- Easier maintenance and future enhancements
The series is structured as a progressive refactoring:
- Remove redundant checks and helpers, fix existing bugs (patches 1-7)
- Add conversion macros and factorize lists (patches 8-10)
- Consolidate device/driver lookup and iteration (patches 11-13)
- Refactor probe logic (patches 14-17)
- Remove bus-specific types from drivers (patches 18-25)
Note on ABI:
This series breaks the ABI for drivers (changes to rte_pci_device, rte_pci_driver, and similar structures for other buses). However, the DPDK ABI policy does not provide guarantees for driver-level interfaces.
Signature · 232 lines
David Marchand Changes since v4: - fixed patch 15 (transient bug for bus != pci), - rebased (conflict on net/ixgbe), Changes since v3: - rebased for recently merged net/sxe2, Changes since v2: - fixed dma/idxd probing as reported by Bruce, - moved api_ver setting (from match to scan) in bus/uacce, - fixed transient bug in the vdev code (in the middle of the series). tl;dr the high level difference for bus/vdev between v2 and v3 == 0, - fixed doxygen, - enhanced API description, Changes since v1: - fix typo in Windows code for net/mlx5, David Marchand (25): bus/ifpga: remove unused AFU lookup helper bus/uacce: set API version during scan crypto/octeontx: remove check on driver in remove dma/idxd: clear device at scan bus: remove device and driver checks in DMA map/unmap drivers/bus: remove device and driver checks in unplug drivers/bus: remove device and driver checks in plug bus: add bus conversion macros bus: factorize driver list bus: factorize device list bus: consolidate device lookup bus: consolidate device iteration bus: factorize driver lookup bus: refactor device probe bus: support multiple probe drivers/bus: initialize NXP bus specifics in scan bus: implement probe in EAL bus: factorize driver reference drivers: rely on generic driver drivers/bus: remove bus-specific driver references dma/idxd: remove specific bus type drivers/bus: separate specific bus metadata for NXP drivers drivers/bus: remove specific bus types eventdev: rename dev field to device bus: add class device conversion macro app/test/test_vdev.c | 6 +- drivers/baseband/acc/rte_acc100_pmd.c | 4 +- drivers/baseband/acc/rte_vrb_pmd.c | 2 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 +- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 2 +- drivers/bus/auxiliary/auxiliary_common.c | 256 +++----------- drivers/bus/auxiliary/auxiliary_params.c | 65 ---- drivers/bus/auxiliary/bus_auxiliary_driver.h | 17 +- drivers/bus/auxiliary/linux/auxiliary.c | 11 +- drivers/bus/auxiliary/meson.build | 5 +- drivers/bus/auxiliary/private.h | 45 +-- drivers/bus/cdx/bus_cdx_driver.h | 17 - drivers/bus/cdx/cdx.c | 259 +++----------- drivers/bus/cdx/private.h | 9 - drivers/bus/dpaa/bus_dpaa_driver.h | 10 +- drivers/bus/dpaa/dpaa_bus.c | 317 ++++++----------- drivers/bus/fslmc/bus_fslmc_driver.h | 7 +- drivers/bus/fslmc/fslmc_bus.c | 330 ++++++----------- drivers/bus/fslmc/fslmc_vfio.c | 55 ++- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 4 +- drivers/bus/fslmc/private.h | 15 +- drivers/bus/ifpga/bus_ifpga_driver.h | 32 +- drivers/bus/ifpga/ifpga_bus.c | 188 ++-------- drivers/bus/pci/bsd/pci.c | 14 +- drivers/bus/pci/bus_pci_driver.h | 15 +- drivers/bus/pci/linux/pci.c | 11 +- drivers/bus/pci/linux/pci_uio.c | 6 +- drivers/bus/pci/pci_common.c | 331 +++++------------- drivers/bus/pci/pci_params.c | 9 +- drivers/bus/pci/private.h | 64 +--- drivers/bus/pci/windows/pci.c | 11 +- drivers/bus/platform/bus_platform_driver.h | 14 - drivers/bus/platform/meson.build | 5 +- drivers/bus/platform/platform.c | 191 +++------- drivers/bus/platform/platform_params.c | 72 ---- drivers/bus/platform/private.h | 25 -- drivers/bus/uacce/bus_uacce_driver.h | 14 - drivers/bus/uacce/uacce.c | 286 ++++----------- drivers/bus/vdev/bus_vdev_driver.h | 15 +- drivers/bus/vdev/meson.build | 5 +- drivers/bus/vdev/vdev.c | 213 +++++------ drivers/bus/vdev/vdev_logs.h | 16 - drivers/bus/vdev/vdev_params.c | 64 ---- drivers/bus/vdev/vdev_private.h | 28 -- drivers/bus/vmbus/bus_vmbus_driver.h | 3 - drivers/bus/vmbus/linux/vmbus_bus.c | 11 +- drivers/bus/vmbus/private.h | 23 +- drivers/bus/vmbus/vmbus_common.c | 190 +++------- drivers/common/mlx5/linux/mlx5_common_os.c | 5 +- drivers/common/mlx5/mlx5_common.c | 2 +- drivers/common/mlx5/mlx5_common_pci.c | 2 +- drivers/common/mlx5/windows/mlx5_common_os.c | 2 +- drivers/common/qat/qat_qp.c | 4 +- drivers/common/sxe2/sxe2_common.c | 4 +- drivers/common/zsda/zsda_qp.c | 4 +- drivers/compress/octeontx/otx_zip.c | 2 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 2 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 3 +- drivers/crypto/octeontx/otx_cryptodev.c | 3 - drivers/crypto/octeontx/otx_cryptodev_ops.c | 4 +- drivers/dma/idxd/idxd_bus.c | 116 ++---- drivers/event/cnxk/cn10k_eventdev.c | 8 +- drivers/event/cnxk/cn20k_eventdev.c | 8 +- drivers/event/cnxk/cn9k_eventdev.c | 6 +- drivers/event/cnxk/cnxk_eventdev.c | 2 +- drivers/event/dlb2/pf/dlb2_pf.c | 2 +- drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/ark/ark_ethdev.c | 2 +- drivers/net/atlantic/atl_ethdev.c | 12 +- drivers/net/avp/avp_ethdev.c | 22 +- drivers/net/axgbe/axgbe_ethdev.c | 4 +- drivers/net/bnx2x/bnx2x_ethdev.c | 2 +- drivers/net/bnxt/bnxt_ethdev.c | 12 +- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 4 +- drivers/net/bonding/rte_eth_bond_args.c | 4 +- drivers/net/cnxk/cnxk_ethdev.c | 2 +- drivers/net/cnxk/cnxk_ethdev_ops.c | 2 +- drivers/net/cxgbe/cxgbe_ethdev.c | 4 +- drivers/net/cxgbe/cxgbevf_ethdev.c | 4 +- drivers/net/dpaa/dpaa_ethdev.c | 17 +- drivers/net/dpaa2/dpaa2_ethdev.c | 8 +- drivers/net/dpaa2/dpaa2_recycle.c | 8 +- drivers/net/ena/ena_ethdev.c | 10 +- drivers/net/enetc/enetc4_ethdev.c | 4 +- drivers/net/enetc/enetc4_vf.c | 4 +- drivers/net/enetc/enetc_ethdev.c | 2 +- drivers/net/enic/enic_ethdev.c | 4 +- drivers/net/enic/enic_fm_flow.c | 6 +- drivers/net/enic/enic_vf_representor.c | 2 +- drivers/net/gve/gve_ethdev.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 8 +- drivers/net/hinic3/base/hinic3_hwdev.c | 7 +- drivers/net/hinic3/hinic3_ethdev.c | 16 +- drivers/net/hns3/hns3_cmd.c | 2 +- drivers/net/hns3/hns3_common.c | 8 +- drivers/net/hns3/hns3_ethdev.c | 6 +- drivers/net/hns3/hns3_ethdev_vf.c | 6 +- drivers/net/hns3/hns3_rxtx.c | 4 +- drivers/net/intel/cpfl/cpfl_ethdev.c | 4 +- drivers/net/intel/cpfl/cpfl_ethdev.h | 2 +- drivers/net/intel/e1000/em_ethdev.c | 12 +- drivers/net/intel/e1000/em_rxtx.c | 2 +- drivers/net/intel/e1000/igb_ethdev.c | 30 +- drivers/net/intel/e1000/igb_pf.c | 2 +- drivers/net/intel/e1000/igc_ethdev.c | 22 +- drivers/net/intel/fm10k/fm10k_ethdev.c | 16 +- drivers/net/intel/i40e/i40e_ethdev.c | 28 +- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- drivers/net/intel/iavf/iavf_ethdev.c | 8 +- drivers/net/intel/ice/ice_dcf.c | 6 +- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ice/ice_ethdev.h | 2 +- drivers/net/intel/idpf/idpf_ethdev.h | 2 +- drivers/net/intel/ipn3ke/ipn3ke_ethdev.h | 13 - drivers/net/intel/ipn3ke/ipn3ke_representor.c | 6 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 40 +-- drivers/net/intel/ixgbe/ixgbe_pf.c | 2 +- drivers/net/intel/ixgbe/ixgbe_tm.c | 2 +- .../net/intel/ixgbe/ixgbe_vf_representor.c | 2 +- drivers/net/intel/ixgbe/rte_pmd_ixgbe.c | 20 +- drivers/net/mlx5/linux/mlx5_os.c | 9 +- drivers/net/mlx5/windows/mlx5_os.c | 4 +- drivers/net/nbl/nbl_core.c | 2 +- drivers/net/nbl/nbl_dev/nbl_dev.c | 6 +- drivers/net/netvsc/hn_ethdev.c | 3 +- drivers/net/nfp/nfp_ethdev.c | 8 +- drivers/net/nfp/nfp_ethdev_vf.c | 6 +- drivers/net/nfp/nfp_net_common.c | 8 +- drivers/net/ngbe/ngbe_ethdev.c | 20 +- drivers/net/ngbe/ngbe_ethdev_vf.c | 16 +- drivers/net/ngbe/ngbe_pf.c | 2 +- drivers/net/ntnic/ntnic_ethdev.c | 8 +- drivers/net/octeon_ep/otx_ep_ethdev.c | 2 +- drivers/net/octeon_ep/otx_ep_mbox.c | 6 +- drivers/net/qede/qede_ethdev.c | 6 +- drivers/net/r8169/r8169_ethdev.c | 6 +- drivers/net/rnp/rnp_ethdev.c | 6 +- drivers/net/sfc/sfc.c | 4 +- drivers/net/sfc/sfc_ethdev.c | 2 +- drivers/net/sfc/sfc_intr.c | 10 +- drivers/net/sfc/sfc_rx.c | 3 +- drivers/net/sfc/sfc_sriov.c | 2 +- drivers/net/sfc/sfc_tx.c | 3 +- drivers/net/sxe2/sxe2_ethdev.c | 8 +- drivers/net/sxe2/sxe2_ethdev.h | 3 - drivers/net/thunderx/nicvf_ethdev.c | 4 +- drivers/net/txgbe/txgbe_ethdev.c | 26 +- drivers/net/txgbe/txgbe_ethdev_vf.c | 16 +- drivers/net/txgbe/txgbe_flow.c | 4 +- drivers/net/txgbe/txgbe_pf.c | 2 +- drivers/net/txgbe/txgbe_tm.c | 2 +- drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- drivers/net/virtio/virtio_pci_ethdev.c | 11 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 4 +- drivers/net/xsc/xsc_ethdev.c | 2 +- drivers/net/zxdh/zxdh_ethdev.c | 8 +- drivers/raw/cnxk_bphy/cnxk_bphy.c | 2 +- drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c | 2 +- drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 2 +- drivers/raw/ifpga/afu_pmd_core.c | 2 +- drivers/raw/ifpga/afu_pmd_n3000.c | 4 +- drivers/raw/ifpga/ifpga_rawdev.c | 4 +- drivers/raw/ntb/ntb.c | 2 +- lib/eal/common/eal_common_bus.c | 186 +++++++++- lib/eal/common/eal_common_dev.c | 45 ++- lib/eal/common/hotplug_mp.c | 4 +- lib/eal/include/bus_driver.h | 307 +++++++++++++++- lib/eal/include/dev_driver.h | 1 + lib/eal/linux/eal_dev.c | 3 +- lib/ethdev/ethdev_pci.h | 7 +- lib/ethdev/rte_ethdev.c | 2 +- lib/eventdev/eventdev_pmd.h | 2 +- lib/eventdev/eventdev_pmd_pci.h | 4 +- lib/eventdev/eventdev_pmd_vdev.h | 2 +- lib/eventdev/rte_eventdev.c | 14 +- 175 files changed, 1687 insertions(+), 3046 deletions(-) delete mode 100644 drivers/bus/auxiliary/auxiliary_params.c delete mode 100644 drivers/bus/platform/platform_params.c delete mode 100644 drivers/bus/vdev/vdev_logs.h delete mode 100644 drivers/bus/vdev/vdev_params.c delete mode 100644 drivers/bus/vdev/vdev_private.h -- 2.53.0
PATCH v5 1/25 bus/ifpga: remove unused AFU lookup helper
This helper got left behind after another cleanup.
--- drivers/bus/ifpga/bus_ifpga_driver.h | 10 ---------- drivers/bus/ifpga/ifpga_bus.c | 13 ------------- 2 files changed, 23 deletions(-)
drivers/bus/ifpga/bus_ifpga_driver.h +0 -10
@@ -116,16 +116,6 @@ rte_ifpga_device_name(const struct rte_afu_device *afu)return NULL ; } -/** -* Find AFU by AFU name. -* -* @param name -* A pointer to AFU name string. -*/ -__rte_internal -struct rte_afu_device * -rte_ifpga_find_afu_by_name (const char *name); -/** * Register a ifpga afu device driver. *
drivers/bus/ifpga/ifpga_bus.c +0 -13
@@ -74,19 +74,6 @@ ifpga_find_afu_dev(const struct rte_rawdev *rdev,return NULL ; } -RTE_EXPORT_INTERNAL_SYMBOL (rte_ifpga_find_afu_by_name) -struct rte_afu_device * -rte_ifpga_find_afu_by_name (const char *name) -{ -struct rte_afu_device *afu_dev =NULL ; - - TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (!strcmp (afu_dev->device.name, name)) -return afu_dev; - } -return NULL ; -} -static const char *const valid_args[] = { #define IFPGA_ARG_NAME "ifpga"IFPGA_ARG_NAME ,
Signature · 1 line
2.53.0
PATCH v5 2/25 bus/uacce: set API version during scan
In reply to David MarchandMove API version parsing from the match callback to the time where the device object is allocated and filled, since this property is constant.
This avoids any side effect on the device object when calling the match callback.
--- drivers/bus/uacce/uacce.c | 53 ++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 28 deletions(-)
drivers/bus/uacce/uacce.c +25 -28
@@ -148,12 +148,35 @@ uacce_read_attr_u32(const char *dev_root, const char *attr, uint32_t *val)return 0 ; } +static uint32_t +uacce_calc_api_ver (const char *api,int *offset) +{ +int len =strlen (api); +int end = len -1 ; +unsigned long ver; + +while (end >=0 &&isdigit (api[end])) + end--; + +if (end <=0 || end == len -1 || api[end] !='v' ) +return 0 ; + + ver =strtoul (api + end +1 ,NULL ,10 ); +if (ver >UINT32_MAX ) +return 0 ; + +if (offset !=NULL ) + *offset = end +1 ; +return (uint32_t )ver; +} +static int uacce_read_api (struct rte_uacce_device *dev) {int ret =uacce_read_attr (dev->dev_root,"api" , dev->api,sizeof (dev->api) -1 );if (ret <0 )return ret; + dev->api_ver =uacce_calc_api_ver (dev->api,NULL );return 0 ; }
@@ -290,28 +313,6 @@ uacce_scan(void)return -1 ; } -static uint32_t -uacce_calc_api_ver (const char *api,int *offset) -{ -int len =strlen (api); -int end = len -1 ; -unsigned long ver; - -while (end >=0 &&isdigit (api[end])) - end--; - -if (end <=0 || end == len -1 || api[end] !='v' ) -return 0 ; - - ver =strtoul (api + end +1 ,NULL ,10 ); -if (ver >UINT32_MAX ) -return 0 ; - -if (offset !=NULL ) - *offset = end +1 ; -return (uint32_t )ver; -} -static bool uacce_match_api (const struct rte_uacce_device *dev,bool forward_compat,const struct rte_uacce_id *id_table)
@@ -330,10 +331,9 @@ uacce_match_api(const struct rte_uacce_device *dev, bool forward_compat, }static bool -uacce_match (const struct rte_uacce_driver *dr,struct rte_uacce_device *dev) +uacce_match (const struct rte_uacce_driver *dr,const struct rte_uacce_device *dev) {bool forward_compat = !!(dr->drv_flags &RTE_UACCE_DRV_FORWARD_COMPATIBILITY_DEV ); -uint32_t api_ver =uacce_calc_api_ver (dev->api,NULL );const struct rte_uacce_id *id_table;const char *map;uint32_t len;
@@ -342,10 +342,8 @@ uacce_match(const struct rte_uacce_driver *dr, struct rte_uacce_device *dev)if (!uacce_match_api (dev, forward_compat, id_table))continue ; -if (id_table->dev_alg ==NULL ) { - dev->api_ver = api_ver; +if (id_table->dev_alg ==NULL )return true; - }/* The dev->algs's algrothims is separated by new line, for * example: dev->algs could be: aaa\nbbbb\ncc, which has three
@@ -361,7 +359,6 @@ uacce_match(const struct rte_uacce_driver *dr, struct rte_uacce_device *dev)if (map[len] !='\0' && map[len] !='\n' )continue ; - dev->api_ver = api_ver;return true; }
Signature · 1 line
2.53.0
PATCH v5 3/25 crypto/octeontx: remove check on driver in remove
In reply to David MarchandThe driver reference in the bus-specific device cannot be NULL since calling the .remove is done after dereferencing this pointer.
--- drivers/crypto/octeontx/otx_cryptodev.c | 3 --- 1 file changed, 3 deletions(-)
drivers/crypto/octeontx/otx_cryptodev.c +0 -3
@@ -87,9 +87,6 @@ otx_cpt_pci_remove(struct rte_pci_device *pci_dev)if (cryptodev ==NULL )return -ENODEV ; -if (pci_dev->driver ==NULL ) -return -ENODEV ; - dev_priv = cryptodev->data->dev_private;/* free crypto device */
Signature · 1 line
2.53.0
PATCH v5 4/25 dma/idxd: clear device at scan
In reply to David MarchandCurrently, the device object is only manipulated by the dma/idxd bus callbacks and EAL is not looking too much into this object.
However, in the next refactoring, EAL will expect a clean object, like when checking that the device has been already probed
(iow dev->driver != NULL).
Request a 0'd object when allocating.
--- drivers/dma/idxd/idxd_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/idxd/idxd_bus.c +1 -1
@@ -322,7 +322,7 @@ dsa_scan(void) }IDXD_PMD_DEBUG ("%s(): found %s/%s" , __func__, path, wq->d_name); - dev =malloc (sizeof (*dev)); + dev =calloc (1 ,sizeof (*dev));if (dev ==NULL ) {closedir (dev_dir);return -ENOMEM ;
Signature · 1 line
2.53.0
PATCH v5 5/25 bus: remove device and driver checks in DMA map/unmap
In reply to David MarchandAdd rte_dev_is_probed() check in rte_dev_dma_map() and rte_dev_dma_unmap() before calling bus-specific implementations.
The device parameter passed to bus DMA map/unmap operations cannot be NULL as the caller already dereferenced the bus structure to invoke these operations.
The driver reference in the bus-specific device cannot be NULL since calling the .dma_map is done after dereferencing this pointer.
Remove redundant checks on probed device, and NULL checks on the device/driver parameter and derived device/driver pointers.
--- drivers/bus/auxiliary/auxiliary_common.c | 8 -------- drivers/bus/pci/pci_common.c | 12 ++---------- drivers/bus/platform/platform.c | 16 ++-------------- drivers/bus/vdev/vdev.c | 24 ++---------------------- lib/eal/common/eal_common_dev.c | 8 ++++++++ 5 files changed, 14 insertions(+), 54 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -8
@@ -356,10 +356,6 @@ auxiliary_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) {struct rte_auxiliary_device *aux_dev =RTE_DEV_TO_AUXILIARY (dev); -if (dev ==NULL || aux_dev->driver ==NULL ) { - rte_errno =EINVAL ; -return -1 ; - }if (aux_dev->driver->dma_map ==NULL ) { rte_errno =ENOTSUP ;return -1 ;
@@ -373,10 +369,6 @@ auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, {struct rte_auxiliary_device *aux_dev =RTE_DEV_TO_AUXILIARY (dev); -if (dev ==NULL || aux_dev->driver ==NULL ) { - rte_errno =EINVAL ; -return -1 ; - }if (aux_dev->driver->dma_unmap ==NULL ) { rte_errno =ENOTSUP ;return -1 ;
drivers/bus/pci/pci_common.c +2 -10
@@ -672,11 +672,7 @@ pci_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) {struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev); -if (!pdev || !pdev->driver) { - rte_errno =EINVAL ; -return -1 ; - } -if (pdev->driver->dma_map) +if (pdev->driver->dma_map !=NULL )return pdev->driver->dma_map (pdev, addr, iova, len);/** * In case driver don't provides any specific mapping
@@ -695,11 +691,7 @@ pci_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) {struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev); -if (!pdev || !pdev->driver) { - rte_errno =EINVAL ; -return -1 ; - } -if (pdev->driver->dma_unmap) +if (pdev->driver->dma_unmap !=NULL )return pdev->driver->dma_unmap (pdev, addr, iova, len);/** * In case driver don't provides any specific mapping
drivers/bus/platform/platform.c +2 -14
@@ -530,13 +530,7 @@ platform_bus_parse(const char *name, void *addr)static int platform_bus_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_platform_device *pdev; - - pdev =RTE_DEV_TO_PLATFORM_DEV (dev); -if (pdev ==NULL || pdev->driver ==NULL ) { - rte_errno =EINVAL ; -return -1 ; - } +struct rte_platform_device *pdev =RTE_DEV_TO_PLATFORM_DEV (dev);if (pdev->driver->dma_map !=NULL )return pdev->driver->dma_map (pdev, addr, iova, len);
@@ -547,13 +541,7 @@ platform_bus_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t lstatic int platform_bus_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_platform_device *pdev; - - pdev =RTE_DEV_TO_PLATFORM_DEV (dev); -if (pdev ==NULL || pdev->driver ==NULL ) { - rte_errno =EINVAL ; -return -1 ; - } +struct rte_platform_device *pdev =RTE_DEV_TO_PLATFORM_DEV (dev);if (pdev->driver->dma_unmap !=NULL )return pdev->driver->dma_unmap (pdev, addr, iova, len);
drivers/bus/vdev/vdev.c +2 -22
@@ -144,20 +144,10 @@ vdev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)struct rte_vdev_device *vdev =RTE_DEV_TO_VDEV (dev);const struct rte_vdev_driver *driver; -if (!vdev) { - rte_errno =EINVAL ; -return -1 ; - } - -if (!vdev->device.driver) { -VDEV_LOG (DEBUG ,"no driver attach to device %s" , dev->name); -return 1 ; - } - driver = container_of(vdev->device.driver, const struct rte_vdev_driver, driver); -if (driver->dma_map) +if (driver->dma_map !=NULL )return driver->dma_map (vdev, addr, iova, len);return 0 ;
@@ -169,20 +159,10 @@ vdev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)struct rte_vdev_device *vdev =RTE_DEV_TO_VDEV (dev);const struct rte_vdev_driver *driver; -if (!vdev) { - rte_errno =EINVAL ; -return -1 ; - } - -if (!vdev->device.driver) { -VDEV_LOG (DEBUG ,"no driver attach to device %s" , dev->name); -return 1 ; - } - driver = container_of(vdev->device.driver, const struct rte_vdev_driver, driver); -if (driver->dma_unmap) +if (driver->dma_unmap !=NULL )return driver->dma_unmap (vdev, addr, iova, len);return 0 ;
lib/eal/common/eal_common_dev.c +8 -0
@@ -829,6 +829,10 @@ int rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { + if (!rte_dev_is_probed(dev)) { + rte_errno = EINVAL; +return -1 ; + }if (dev->bus->dma_map ==NULL || len ==0 ) { rte_errno =ENOTSUP ;return -1 ;
@@ -847,6 +851,10 @@ int rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { + if (!rte_dev_is_probed(dev)) { + rte_errno = EINVAL; +return -1 ; + }if (dev->bus->dma_unmap ==NULL || len ==0 ) { rte_errno =ENOTSUP ;return -1 ;
Signature · 1 line
2.53.0
PATCH v5 6/25 drivers/bus: remove device and driver checks in unplug
In reply to David Marchandrte_dev_remove() checks if a device is probed before calling the bus unplug operation. Individual bus detach/remove functions checking that dev->driver is non-NULL are therefore redundant.
However, when the unplug operation is called at bus cleanup, care must be taken that devices are in probed state, so some check on rte_dev_is_probed() must be added.
The device parameter passed to bus unplug operations cannot be NULL as the caller already dereferenced the bus structure to invoke these operations.
The driver reference in the bus-specific device cannot be NULL since calling the .unplug is done after dereferencing this pointer.
--- drivers/bus/auxiliary/auxiliary_common.c | 14 ++++-------- drivers/bus/cdx/cdx.c | 12 +++------- drivers/bus/dpaa/dpaa_bus.c | 2 +- drivers/bus/fslmc/fslmc_bus.c | 2 +- drivers/bus/ifpga/ifpga_bus.c | 29 ++++-------------------- drivers/bus/pci/pci_common.c | 19 +++++----------- drivers/bus/platform/platform.c | 13 ++++------- drivers/bus/uacce/uacce.c | 13 +++++------ drivers/bus/vdev/vdev.c | 4 ++-- drivers/bus/vmbus/vmbus_common.c | 4 +++- 10 files changed, 36 insertions(+), 76 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +4 -10
@@ -144,16 +144,9 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,static int rte_auxiliary_driver_remove_dev (struct rte_auxiliary_device *dev) { -struct rte_auxiliary_driver *drv; +struct rte_auxiliary_driver *drv = dev->driver;int ret =0 ; -if (dev ==NULL ) -return -EINVAL ; - - drv = dev->driver; -if (drv ==NULL ) -return 0 ; -AUXILIARY_LOG (DEBUG ,"Driver %s remove auxiliary device %s on NUMA node %i" , drv->driver.name, dev->name, dev->device.numa_node);
@@ -318,10 +311,9 @@ auxiliary_plug(struct rte_device *dev)static int auxiliary_unplug (struct rte_device *dev) { -struct rte_auxiliary_device *adev; +struct rte_auxiliary_device *adev =RTE_DEV_TO_AUXILIARY (dev);int ret; - adev =RTE_DEV_TO_AUXILIARY (dev); ret =rte_auxiliary_driver_remove_dev (adev);if (ret ==0 ) {rte_auxiliary_remove_device (adev);
@@ -341,6 +333,8 @@ auxiliary_cleanup(void) RTE_TAILQ_FOREACH_SAFE(dev, &auxiliary_bus.device_list, next, tmp_dev) {int ret; +if (!rte_dev_is_probed (&dev->device)) +continue ; ret =auxiliary_unplug (&dev->device);if (ret <0 ) { rte_errno = errno;
drivers/bus/cdx/cdx.c +3 -9
@@ -501,18 +501,13 @@ cdx_remove_device(struct rte_cdx_device *cdx_dev)static int cdx_detach_dev (struct rte_cdx_device *dev) { -struct rte_cdx_driver *dr; +struct rte_cdx_driver *dr = dev->driver;int ret =0 ; -if (dev ==NULL ) -return -EINVAL ; - - dr = dev->driver; -CDX_BUS_DEBUG ("detach device %s using driver: %s" , dev->device.name, dr->driver.name); -if (dr->remove) { +if (dr->remove !=NULL ) { ret = dr->remove (dev);if (ret <0 )return ret;
@@ -539,10 +534,9 @@ cdx_plug(struct rte_device *dev)static int cdx_unplug (struct rte_device *dev) { -struct rte_cdx_device *cdx_dev; +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev);int ret; - cdx_dev =RTE_DEV_TO_CDX_DEV (dev); ret =cdx_detach_dev (cdx_dev);if (ret ==0 ) {cdx_remove_device (cdx_dev);
drivers/bus/dpaa/dpaa_bus.c +1 -1
@@ -938,7 +938,7 @@ dpaa_bus_cleanup(void)if (!rte_dev_is_probed (&dev->device))continue ; -if (!drv || !drv->remove) +if (drv->remove ==NULL )continue ; ret = drv->remove (dev);if (ret <0 ) {
drivers/bus/fslmc/fslmc_bus.c +1 -1
@@ -619,7 +619,7 @@ fslmc_bus_unplug(struct rte_device *rte_dev) struct rte_dpaa2_device, device);struct rte_dpaa2_driver *drv = dev->driver; -if (drv && drv->remove) { +if (drv->remove !=NULL ) { drv->remove (dev); dev->driver =NULL ; dev->device.driver =NULL ;
drivers/bus/ifpga/ifpga_bus.c +5 -24
@@ -365,7 +365,9 @@ ifpga_cleanup(void)struct rte_afu_driver *drv = afu_dev->driver;int ret =0 ; -if (drv ==NULL || drv->remove ==NULL ) +if (!rte_dev_is_probed (&afu_dev->device)) + goto free; +if (drv->remove ==NULL ) goto free; ret = drv->remove (afu_dev);
@@ -392,34 +394,13 @@ ifpga_plug(struct rte_device *dev)return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); } -static int -ifpga_remove_driver (struct rte_afu_device *afu_dev) -{ -const char *name; - - name =rte_ifpga_device_name (afu_dev); -if (afu_dev->driver ==NULL ) { -IFPGA_BUS_DEBUG ("no driver attach to device %s" , name); -return 1 ; - } - -return afu_dev->driver->remove (afu_dev); -} -static int ifpga_unplug (struct rte_device *dev) { -struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_device *afu_dev =RTE_DEV_TO_AFU (dev);int ret; -if (dev ==NULL ) -return -EINVAL ; - - afu_dev =RTE_DEV_TO_AFU (dev); -if (!afu_dev) -return -ENOENT ; - - ret =ifpga_remove_driver (afu_dev); + ret = afu_dev->driver->remove (afu_dev);if (ret)return ret;
drivers/bus/pci/pci_common.c +6 -13
@@ -310,13 +310,9 @@ static int rte_pci_detach_dev(struct rte_pci_device *dev) {struct rte_pci_addr *loc; -struct rte_pci_driver *dr; +struct rte_pci_driver *dr = dev->driver;int ret =0 ; -if (dev ==NULL ) -return -EINVAL ; - - dr = dev->driver; loc = &dev->addr; PCI_LOG(DEBUG, "PCI device "PCI_PRI_FMT" on NUMA socket %i",
@@ -416,7 +412,9 @@ pci_cleanup(void)struct rte_pci_driver *drv = dev->driver;int ret =0 ; -if (drv ==NULL || drv->remove ==NULL ) +if (!rte_dev_is_probed (&dev->device)) + goto free; +if (drv->remove ==NULL ) goto free; ret = drv->remove (dev);
@@ -590,13 +588,9 @@ pci_find_device_by_addr(const void *failure_addr)static int pci_hot_unplug_handler (struct rte_device *dev) { -struct rte_pci_device *pdev =NULL ; +struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev);int ret =0 ; - pdev =RTE_DEV_TO_PCI (dev); -if (!pdev) -return -1 ; -switch (pdev->kdrv) {case RTE_PCI_KDRV_VFIO :/*
@@ -654,10 +648,9 @@ pci_plug(struct rte_device *dev)static int pci_unplug (struct rte_device *dev) { -struct rte_pci_device *pdev; +struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev);int ret; - pdev =RTE_DEV_TO_PCI (dev); ret =rte_pci_detach_dev (pdev);if (ret ==0 ) {rte_pci_remove_device (pdev);
drivers/bus/platform/platform.c +5 -8
@@ -476,11 +476,10 @@ platform_bus_plug(struct rte_device *dev)static void device_release_driver (struct rte_platform_device *pdev) { -struct rte_platform_driver *pdrv; +struct rte_platform_driver *pdrv = pdev->driver;int ret; - pdrv = pdev->driver; -if (pdrv !=NULL && pdrv->remove !=NULL ) { +if (pdrv->remove !=NULL ) { ret = pdrv->remove (pdev);if (ret)PLATFORM_LOG_LINE (WARNING ,"failed to remove %s" , pdev->name);
@@ -493,11 +492,7 @@ device_release_driver(struct rte_platform_device *pdev)static int platform_bus_unplug (struct rte_device *dev) { -struct rte_platform_device *pdev; - - pdev =RTE_DEV_TO_PLATFORM_DEV (dev); -if (pdev ==NULL ) -return -EINVAL ; +struct rte_platform_device *pdev =RTE_DEV_TO_PLATFORM_DEV (dev);device_release_driver (pdev);device_cleanup (pdev);
@@ -572,6 +567,8 @@ platform_bus_cleanup(void) RTE_TAILQ_FOREACH_SAFE(pdev, &platform_bus.device_list, next, tmp) {TAILQ_REMOVE (&platform_bus.device_list, pdev, next); +if (!rte_dev_is_probed (&pdev->device)) +continue ;platform_bus_unplug (&pdev->device); }
drivers/bus/uacce/uacce.c +6 -7
@@ -450,7 +450,9 @@ uacce_cleanup(void)struct rte_uacce_driver *dr = dev->driver;int ret =0 ; -if (dr ==NULL || dr->remove ==NULL ) +if (!rte_dev_is_probed (&dev->device)) + goto free; +if (dr->remove ==NULL ) goto free; ret = dr->remove (dev);
@@ -478,14 +480,12 @@ uacce_plug(struct rte_device *dev)static int uacce_detach_dev (struct rte_uacce_device *dev) { -struct rte_uacce_driver *dr; +struct rte_uacce_driver *dr = dev->driver;int ret =0 ; - dr = dev->driver; -UACCE_BUS_DEBUG ("detach device %s using driver: %s" , dev->device.name, dr->driver.name); -if (dr->remove) { +if (dr->remove !=NULL ) { ret = dr->remove (dev);if (ret <0 )return ret;
@@ -500,10 +500,9 @@ uacce_detach_dev(struct rte_uacce_device *dev)static int uacce_unplug (struct rte_device *dev) { -struct rte_uacce_device *uacce_dev; +struct rte_uacce_device *uacce_dev =RTE_DEV_TO_UACCE_DEV (dev);int ret; - uacce_dev =RTE_DEV_TO_UACCE_DEV (dev); ret =uacce_detach_dev (uacce_dev);if (ret ==0 ) {TAILQ_REMOVE (&uacce_bus.device_list, uacce_dev, next);
drivers/bus/vdev/vdev.c +2 -2
@@ -567,9 +567,9 @@ vdev_cleanup(void) RTE_TAILQ_FOREACH_SAFE(dev, &vdev_device_list, next, tmp_dev) {const struct rte_vdev_driver *drv; -int ret =0 ; +int ret; -if (dev->device.driver ==NULL ) +if (!rte_dev_is_probed (&dev->device)) goto free; drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
drivers/bus/vmbus/vmbus_common.c +3 -1
@@ -210,7 +210,9 @@ rte_vmbus_cleanup(void)const struct rte_vmbus_driver *drv = dev->driver;int ret; -if (drv ==NULL || drv->remove ==NULL ) +if (!rte_dev_is_probed (&dev->device)) +continue ; +if (drv->remove ==NULL )continue ; ret = drv->remove (dev);
Signature · 1 line
2.53.0
PATCH v5 7/25 drivers/bus: remove device and driver checks in plug
In reply to David MarchandThe bus-specific device conversion macros all use container_of() to convert from a generic rte_device pointer to a bus-specific device structure.
A key property of container_of() is that it does NOT return NULL when given a NULL pointer as input. Instead, it returns (NULL - offset), which is a small non-NULL pointer value. This means NULL checks on container_of() results cannot work as intended.
The device parameter passed to bus probe or plug operations cannot be NULL as the caller already dereferenced the bus structure to invoke these operations. Remove redundant NULL checks on the device parameter and derived device pointers.
The driver reference in the bus-specific device cannot be NULL since calling the .plug op is done after dereferencing this pointer.
--- drivers/bus/auxiliary/auxiliary_common.c | 6 ------ drivers/bus/ifpga/ifpga_bus.c | 3 --- drivers/bus/platform/platform.c | 8 +------- 3 files changed, 1 insertion(+), 16 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +0 -6
@@ -81,9 +81,6 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,enum rte_iova_mode iova_mode;int ret; -if (drv ==NULL || dev ==NULL ) -return -EINVAL ; -/* Check if driver supports it. */ if (!auxiliary_match (drv, dev))/* Match of device and driver failed */
@@ -174,9 +171,6 @@ auxiliary_probe_all_drivers(struct rte_auxiliary_device *dev)struct rte_auxiliary_driver *drv;int rc; -if (dev ==NULL ) -return -EINVAL ; -FOREACH_DRIVER_ON_AUXILIARY_BUS (drv) {if (!drv->match (dev->name))continue ;
drivers/bus/ifpga/ifpga_bus.c +0 -3
@@ -302,9 +302,6 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)struct rte_afu_driver *drv =NULL ;int ret =0 ; -if (afu_dev ==NULL ) -return -1 ; -/* Check if a driver is already loaded */ if (rte_dev_is_probed (&afu_dev->device)) { IFPGA_BUS_DEBUG("Device %s is already probed",
drivers/bus/platform/platform.c +1 -7
@@ -458,19 +458,13 @@ platform_bus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, consstatic int platform_bus_plug (struct rte_device *dev) { -struct rte_platform_device *pdev; -if (rte_bus_device_is_ignored (&platform_bus.bus, dev->name))return -EPERM ;if (!dev_is_bound_vfio_platform (dev->name))return -EPERM ; - pdev =RTE_DEV_TO_PLATFORM_DEV (dev); -if (pdev ==NULL ) -return -EINVAL ; - -return device_attach (pdev); +return device_attach (RTE_DEV_TO_PLATFORM_DEV (dev)); } static void
Signature · 1 line
2.53.0
PATCH v5 8/25 bus: add bus conversion macros
In reply to David MarchandIntroduce two generic macros to replace all bus-specific device and driver conversion macros:
- RTE_BUS_DEVICE(dev, bus_dev_type): Converts a generic rte_device pointer to a bus-specific device structure using typeof() to infer the correct type. The second parameter can be either a struct type (e.g., struct rte_pci_device) or a dereferenced pointer variable (e.g., *pdev) for automatic type inference.
- RTE_BUS_DRIVER(drv, bus_drv_type): Converts a generic rte_driver pointer to a bus-specific driver structure using the same approach.
All bus drivers and device class drivers have been updated to use these generic macros instead of their bus-specific conversion macros (RTE_DEV_TO_*, DEV_TO_*) or direct container_of() calls.
Ethernet device convenience macros (RTE_ETH_DEV_TO_*) have been updated to use RTE_BUS_DEVICE internally.
Usage patterns:
- For pre-existing variables: pdev = RTE_BUS_DEVICE(dev, *pdev);
- For new declarations:
struct rte_pci_device *pdev = RTE_BUS_DEVICE(dev, *pdev);
- For inline conversions: foo(RTE_BUS_DEVICE(dev, struct rte_pci_device));
- For const conversions: RTE_BUS_DEVICE(dev, const struct rte_pci_device);
---
Changes since v3:
- updated new sxe2 drivers (removed unused macro SXE2_DEV_TO_PCI),
Changes since v2:
- reworded doxygen,
- fixed cdx conversion macro (even if unused),
Changes since v1:
- fix build on Windows,
--- drivers/baseband/acc/rte_acc100_pmd.c | 4 +-- drivers/baseband/acc/rte_vrb_pmd.c | 2 +- .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 +-- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 2 +- drivers/bus/auxiliary/auxiliary_common.c | 10 +++---- drivers/bus/auxiliary/bus_auxiliary_driver.h | 13 ++------ drivers/bus/cdx/bus_cdx_driver.h | 12 +------- drivers/bus/cdx/cdx.c | 6 ++-- drivers/bus/dpaa/bus_dpaa_driver.h | 7 +---- drivers/bus/dpaa/dpaa_bus.c | 4 +-- drivers/bus/fslmc/bus_fslmc_driver.h | 4 +-- drivers/bus/fslmc/fslmc_bus.c | 10 +++---- drivers/bus/ifpga/bus_ifpga_driver.h | 8 +---- drivers/bus/ifpga/ifpga_bus.c | 4 +-- drivers/bus/pci/bus_pci_driver.h | 13 ++------ drivers/bus/pci/pci_common.c | 12 ++++---- drivers/bus/pci/pci_params.c | 2 +- drivers/bus/platform/bus_platform_driver.h | 10 ------- drivers/bus/platform/platform.c | 17 +++++++---- drivers/bus/uacce/bus_uacce_driver.h | 10 ------- drivers/bus/uacce/uacce.c | 6 ++-- drivers/bus/vdev/bus_vdev_driver.h | 14 ++------- drivers/bus/vdev/vdev.c | 24 ++++++--------- drivers/common/mlx5/linux/mlx5_common_os.c | 5 ++-- drivers/common/mlx5/mlx5_common.c | 2 +- drivers/common/mlx5/mlx5_common_pci.c | 2 +- drivers/common/mlx5/windows/mlx5_common_os.c | 2 +- drivers/common/sxe2/sxe2_common.c | 4 +-- drivers/compress/octeontx/otx_zip.c | 2 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 2 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +- drivers/crypto/octeontx/otx_cryptodev_ops.c | 4 +-- drivers/event/cnxk/cnxk_eventdev.c | 2 +- drivers/event/dlb2/pf/dlb2_pf.c | 2 +- drivers/event/skeleton/skeleton_eventdev.c | 2 +- drivers/net/axgbe/axgbe_ethdev.c | 4 +-- drivers/net/bnx2x/bnx2x_ethdev.c | 2 +- drivers/net/bnxt/bnxt_ethdev.c | 2 +- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 4 +-- drivers/net/bonding/rte_eth_bond_args.c | 2 +- drivers/net/dpaa/dpaa_ethdev.c | 13 ++++---- drivers/net/dpaa2/dpaa2_ethdev.c | 6 ++-- drivers/net/dpaa2/dpaa2_recycle.c | 6 ++-- drivers/net/gve/gve_ethdev.c | 2 +- drivers/net/hns3/hns3_ethdev.c | 4 +-- drivers/net/hns3/hns3_rxtx.c | 2 +- drivers/net/intel/cpfl/cpfl_ethdev.c | 4 +-- drivers/net/intel/cpfl/cpfl_ethdev.h | 2 +- drivers/net/intel/i40e/i40e_ethdev.h | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 +-- drivers/net/intel/ice/ice_ethdev.h | 2 +- drivers/net/intel/idpf/idpf_ethdev.h | 2 +- drivers/net/intel/ipn3ke/ipn3ke_ethdev.h | 12 +------- drivers/net/mlx5/linux/mlx5_os.c | 9 +++--- drivers/net/mlx5/windows/mlx5_os.c | 4 +-- drivers/net/netvsc/hn_ethdev.c | 2 +- drivers/net/qede/qede_ethdev.c | 2 +- drivers/net/rnp/rnp_ethdev.c | 6 ++-- drivers/net/sxe2/sxe2_ethdev.c | 8 ++--- drivers/net/sxe2/sxe2_ethdev.h | 3 -- drivers/raw/ifpga/afu_pmd_n3000.c | 4 +-- lib/eal/include/bus_driver.h | 30 +++++++++++++++++++ 62 files changed, 159 insertions(+), 213 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +2 -2
@@ -3993,7 +3993,7 @@ acc100_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,static void acc100_bbdev_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); dev->dev_ops = &acc100_bbdev_ops; dev->enqueue_enc_ops = acc100_enqueue_enc;
@@ -4646,7 +4646,7 @@ rte_acc_configure(const char *dev_name, struct rte_acc_conf *conf) dev_name);return -ENODEV ; } -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (bbdev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (bbdev->device, *pci_dev);rte_bbdev_log (INFO ,"Configure dev id %x" , pci_dev->id.device_id);if (pci_dev->id.device_id ==ACC100_PF_DEVICE_ID )return acc100_configure (dev_name, conf);
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
@@ -4353,7 +4353,7 @@ vrb2_dequeue_mldts(struct rte_bbdev_queue_data *q_data,static void vrb_bbdev_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);struct acc_device *d = dev->data->dev_private; dev->dev_ops = &vrb_bbdev_ops;
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +2 -2
@@ -2873,7 +2873,7 @@ fpga_5gnr_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,static void fpga_5gnr_fec_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); dev->dev_ops = &fpga_5gnr_ops; dev->enqueue_ldpc_enc_ops = fpga_5gnr_enqueue_ldpc_enc;
@@ -3376,7 +3376,7 @@ int rte_fpga_5gnr_fec_configure(const char *dev_name, const struct rte_fpga_5gnr dev_name);return -ENODEV ; } -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (bbdev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (bbdev->device, *pci_dev);rte_bbdev_log (INFO ,"Configure dev id %x" , pci_dev->id.device_id);if (pci_dev->id.device_id ==VC_5GNR_PF_DEVICE_ID )return vc_5gnr_configure (dev_name, conf);
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +1 -1
@@ -2316,7 +2316,7 @@ fpga_dequeue_dec(struct rte_bbdev_queue_data *q_data,static void fpga_lte_fec_init (struct rte_bbdev *dev,struct rte_pci_driver *drv) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); dev->dev_ops = &fpga_ops; dev->enqueue_enc_ops = fpga_enqueue_enc;
drivers/bus/auxiliary/auxiliary_common.c +5 -5
@@ -281,7 +281,7 @@ auxiliary_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,struct rte_auxiliary_device *adev;if (start !=NULL ) { - pstart =RTE_DEV_TO_AUXILIARY_CONST (start); + pstart =RTE_BUS_DEVICE (start, *pstart); adev =TAILQ_NEXT (pstart, next); }else { adev =TAILQ_FIRST (&auxiliary_bus.device_list);
@@ -299,13 +299,13 @@ auxiliary_plug(struct rte_device *dev) {if (!auxiliary_dev_exists (dev->name))return -ENOENT ; -return auxiliary_probe_all_drivers (RTE_DEV_TO_AUXILIARY (dev)); + return auxiliary_probe_all_drivers(RTE_BUS_DEVICE(dev, struct rte_auxiliary_device)); }static int auxiliary_unplug (struct rte_device *dev) { -struct rte_auxiliary_device *adev =RTE_DEV_TO_AUXILIARY (dev); +struct rte_auxiliary_device *adev =RTE_BUS_DEVICE (dev, *adev);int ret; ret =rte_auxiliary_driver_remove_dev (adev);
@@ -342,7 +342,7 @@ auxiliary_cleanup(void)static int auxiliary_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_auxiliary_device *aux_dev =RTE_DEV_TO_AUXILIARY (dev); +struct rte_auxiliary_device *aux_dev =RTE_BUS_DEVICE (dev, *aux_dev);if (aux_dev->driver->dma_map ==NULL ) { rte_errno =ENOTSUP ;
@@ -355,7 +355,7 @@ static int auxiliary_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) { - struct rte_auxiliary_device *aux_dev = RTE_DEV_TO_AUXILIARY(dev); + struct rte_auxiliary_device *aux_dev = RTE_BUS_DEVICE(dev, *aux_dev);if (aux_dev->driver->dma_unmap ==NULL ) { rte_errno =ENOTSUP ;
drivers/bus/auxiliary/bus_auxiliary_driver.h +2 -11
@@ -22,6 +22,7 @@#include <rte_debug.h> #include <rte_interrupts.h> #include <dev_driver.h> +#include <bus_driver.h> #include <rte_kvargs.h> #ifdef __cplusplus
@@ -130,18 +131,8 @@ struct rte_auxiliary_driver {uint32_t drv_flags;/**< Flags RTE_AUXILIARY_DRV_*. */ }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_auxiliary_device. -*/ -#define RTE_DEV_TO_AUXILIARY (ptr) \ - container_of(ptr, struct rte_auxiliary_device, device) - -#define RTE_DEV_TO_AUXILIARY_CONST (ptr) \ - container_of(ptr, const struct rte_auxiliary_device, device) -#define RTE_ETH_DEV_TO_AUXILIARY (eth_dev) \ - RTE_DEV_TO_AUXILIARY((eth_dev)->device) + RTE_BUS_DEVICE((eth_dev)->device, struct rte_auxiliary_device)/** Device driver needs IOVA as VA and cannot work with IOVA as PA */ #define RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA 0x002
drivers/bus/cdx/bus_cdx_driver.h +1 -11
@@ -63,17 +63,7 @@ struct rte_cdx_device {struct rte_intr_handle *intr_handle;/**< Interrupt handle */ }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_cdx_device. -*/ -#define RTE_DEV_TO_CDX_DEV (ptr) \ - container_of(ptr, struct rte_cdx_device, device) - -#define RTE_DEV_TO_CDX_DEV_CONST (ptr) \ - container_of(ptr, const struct rte_cdx_device, device) - -#define RTE_ETH_DEV_TO_CDX_DEV (eth_dev) RTE_DEV_TO_CDX_DEV((eth_dev)->device) +#define RTE_ETH_DEV_TO_CDX_DEV (eth_dev) RTE_BUS_DEVICE((eth_dev)->device, struct rte_cdx_device)#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs. */
drivers/bus/cdx/cdx.c +3 -3
@@ -474,7 +474,7 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,struct rte_cdx_device *cdx_dev;if (start !=NULL ) { - cdx_start =RTE_DEV_TO_CDX_DEV_CONST (start); + cdx_start =RTE_BUS_DEVICE (start, *cdx_start); cdx_dev =TAILQ_NEXT (cdx_start, next); }else { cdx_dev =TAILQ_FIRST (&rte_cdx_bus.device_list);
@@ -528,13 +528,13 @@ cdx_detach_dev(struct rte_cdx_device *dev)static int cdx_plug (struct rte_device *dev) { -return cdx_probe_all_drivers (RTE_DEV_TO_CDX_DEV (dev)); + return cdx_probe_all_drivers(RTE_BUS_DEVICE(dev, struct rte_cdx_device)); }static int cdx_unplug (struct rte_device *dev) { -struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); +struct rte_cdx_device *cdx_dev =RTE_BUS_DEVICE (dev, *cdx_dev);int ret; ret =cdx_detach_dev (cdx_dev);
drivers/bus/dpaa/bus_dpaa_driver.h +1 -6
@@ -8,6 +8,7 @@#include <rte_compat.h> #include <dev_driver.h> +#include <bus_driver.h> #include <rte_mbuf_dyn.h> #include <rte_mempool.h>
@@ -49,9 +50,6 @@ dpaa_seqn(struct rte_mbuf *mbuf)#define DPAA_MEMPOOL_OPS_NAME "dpaa" -#define DEV_TO_DPAA_DEVICE (ptr) \ - container_of(ptr, struct rte_dpaa_device, device) -/* DPAA SoC identifier; If this is not available, it can be concluded * that board is non-DPAA. Single slot is currently supported. */
@@ -65,9 +63,6 @@ dpaa_seqn(struct rte_mbuf *mbuf)/** Number of supported QDMA devices */ #define RTE_DPAA_QDMA_DEVICES 1 -#define RTE_DEV_TO_DPAA_CONST (ptr) \ - container_of(ptr, const struct rte_dpaa_device, device) -struct rte_dpaa_device ;struct rte_dpaa_driver ;
drivers/bus/dpaa/dpaa_bus.c +2 -2
@@ -835,7 +835,7 @@ rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,*/ if (start !=NULL ) { - dstart =RTE_DEV_TO_DPAA_CONST (start); + dstart =RTE_BUS_DEVICE (start, *dstart); dev =TAILQ_NEXT (dstart, next); }else { dev =TAILQ_FIRST (&rte_dpaa_bus.device_list);
@@ -908,7 +908,7 @@ dpaa_bus_dev_iterate(const void *start, const char *str, dev_name = dup +strlen ("name=" );if (start !=NULL ) { - dstart =RTE_DEV_TO_DPAA_CONST (start); + dstart =RTE_BUS_DEVICE (start, *dstart); dev =TAILQ_NEXT (dstart, next); }else { dev =TAILQ_FIRST (&rte_dpaa_bus.device_list);
drivers/bus/fslmc/bus_fslmc_driver.h +1 -3
@@ -25,6 +25,7 @@#include <rte_debug.h> #include <rte_interrupts.h> #include <dev_driver.h> +#include <bus_driver.h> #include <rte_tailq.h> #include <rte_devargs.h> #include <rte_mbuf.h>
@@ -67,9 +68,6 @@ dpaa2_seqn(struct rte_mbuf *mbuf)struct rte_dpaa2_driver ; -#define RTE_DEV_TO_FSLMC_CONST (ptr) \ - container_of(ptr, const struct rte_dpaa2_device, device) -enum rte_dpaa2_dev_type {/* Devices backed by DPDK driver */ DPAA2_ETH ,/**< DPNI type device*/
drivers/bus/fslmc/fslmc_bus.c +4 -6
@@ -497,7 +497,7 @@ rte_fslmc_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,*/ if (start !=NULL ) { - dstart =RTE_DEV_TO_FSLMC_CONST (start); + dstart =RTE_BUS_DEVICE (start, *dstart); dev =TAILQ_NEXT (dstart, next); }else { dev =TAILQ_FIRST (&rte_fslmc_bus.device_list);
@@ -579,8 +579,7 @@ static int fslmc_bus_plug(struct rte_device *rte_dev) {int ret =0 ; -struct rte_dpaa2_device *dev =container_of (rte_dev, - struct rte_dpaa2_device, device); +struct rte_dpaa2_device *dev =RTE_BUS_DEVICE (rte_dev, *dev);struct rte_dpaa2_driver *drv; TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) {
@@ -615,8 +614,7 @@ fslmc_bus_plug(struct rte_device *rte_dev)static int fslmc_bus_unplug (struct rte_device *rte_dev) { -struct rte_dpaa2_device *dev =container_of (rte_dev, - struct rte_dpaa2_device, device); +struct rte_dpaa2_device *dev =RTE_BUS_DEVICE (rte_dev, *dev);struct rte_dpaa2_driver *drv = dev->driver;if (drv->remove !=NULL ) {
@@ -658,7 +656,7 @@ fslmc_bus_dev_iterate(const void *start, const char *str, dev_name = dup +strlen ("name=" );if (start !=NULL ) { - dstart =RTE_DEV_TO_FSLMC_CONST (start); + dstart =RTE_BUS_DEVICE (start, *dstart); dev =TAILQ_NEXT (dstart, next); }else { dev =TAILQ_FIRST (&rte_fslmc_bus.device_list);
drivers/bus/ifpga/bus_ifpga_driver.h +1 -7
@@ -13,6 +13,7 @@#include <rte_compat.h> #include <dev_driver.h> +#include <bus_driver.h> #include <rte_pci.h> #include <rte_interrupts.h> #include <rte_spinlock.h>
@@ -79,13 +80,6 @@ struct rte_afu_device {char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_afu_device. -*/ -#define RTE_DEV_TO_AFU (ptr) \ - container_of(ptr, struct rte_afu_device, device) -/** * Initialization function for the driver called during FPGA BUS probing. */
drivers/bus/ifpga/ifpga_bus.c +2 -2
@@ -388,13 +388,13 @@ ifpga_cleanup(void)static int ifpga_plug (struct rte_device *dev) { -return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); + return ifpga_probe_all_drivers(RTE_BUS_DEVICE(dev, struct rte_afu_device)); }static int ifpga_unplug (struct rte_device *dev) { -struct rte_afu_device *afu_dev =RTE_DEV_TO_AFU (dev); +struct rte_afu_device *afu_dev =RTE_BUS_DEVICE (dev, *afu_dev);int ret; ret = afu_dev->driver->remove (afu_dev);
drivers/bus/pci/bus_pci_driver.h +3 -10
@@ -8,6 +8,7 @@#include <rte_bus_pci.h> #include <dev_driver.h> +#include <bus_driver.h> #include <rte_compat.h> #ifdef __cplusplus
@@ -48,16 +49,8 @@ struct rte_pci_device {/**< Handler of VFIO request interrupt */ }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_pci_device. -*/ -#define RTE_DEV_TO_PCI (ptr) container_of(ptr, struct rte_pci_device, device) - -#define RTE_DEV_TO_PCI_CONST (ptr) \ - container_of(ptr, const struct rte_pci_device, device) - -#define RTE_ETH_DEV_TO_PCI (eth_dev) RTE_DEV_TO_PCI((eth_dev)->device) +#define RTE_ETH_DEV_TO_PCI (eth_dev) \ + RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device)#ifdef __cplusplus/** C++ macro used to help building up tables of device IDs */
drivers/bus/pci/pci_common.c +6 -6
@@ -542,7 +542,7 @@ pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,struct rte_pci_device *pdev;if (start !=NULL ) { - pstart =RTE_DEV_TO_PCI_CONST (start); + pstart =RTE_BUS_DEVICE (start, *pstart); pdev =TAILQ_NEXT (pstart, next); }else { pdev =TAILQ_FIRST (&rte_pci_bus.device_list);
@@ -588,7 +588,7 @@ pci_find_device_by_addr(const void *failure_addr)static int pci_hot_unplug_handler (struct rte_device *dev) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (dev, *pdev);int ret =0 ;switch (pdev->kdrv) {
@@ -642,13 +642,13 @@ pci_sigbus_handler(const void *failure_addr)static int pci_plug (struct rte_device *dev) { -return pci_probe_all_drivers (RTE_DEV_TO_PCI (dev)); + return pci_probe_all_drivers(RTE_BUS_DEVICE(dev, struct rte_pci_device)); }static int pci_unplug (struct rte_device *dev) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (dev, *pdev);int ret; ret =rte_pci_detach_dev (pdev);
@@ -663,7 +663,7 @@ pci_unplug(struct rte_device *dev)static int pci_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (dev, *pdev);if (pdev->driver->dma_map !=NULL )return pdev->driver->dma_map (pdev, addr, iova, len);
@@ -682,7 +682,7 @@ pci_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)static int pci_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (dev, *pdev);if (pdev->driver->dma_unmap !=NULL )return pdev->driver->dma_unmap (pdev, addr, iova, len);
drivers/bus/pci/pci_params.c +1 -1
@@ -49,7 +49,7 @@ pci_dev_match(const struct rte_device *dev,if (kvlist ==NULL )/* Empty string matches everything. */ return 0 ; - pdev =RTE_DEV_TO_PCI_CONST (dev); + pdev =RTE_BUS_DEVICE (dev, *pdev);/* if any field does not match. */ if (rte_kvargs_process(kvlist, pci_params_keys[RTE_PCI_PARAM_ADDR], &pci_addr_kv_cmp,
drivers/bus/platform/bus_platform_driver.h +0 -10
@@ -119,16 +119,6 @@ struct rte_platform_driver {/** Device driver needs IOVA as VA and cannot work with IOVA as PA */ #define RTE_PLATFORM_DRV_NEED_IOVA_AS_VA 0x0001 -/** -* @internal -* Helper macros used to convert core device to platform device. -*/ -#define RTE_DEV_TO_PLATFORM_DEV (ptr) \ - container_of(ptr, struct rte_platform_device, device) - -#define RTE_DEV_TO_PLATFORM_DEV_CONST (ptr) \ - container_of(ptr, const struct rte_platform_device, device) -/** Helper for platform driver registration. */ #define RTE_PMD_REGISTER_PLATFORM (nm, platform_drv) \ static const char *pdrvinit_ ## nm ## _alias; \
drivers/bus/platform/platform.c +11 -6
@@ -441,10 +441,15 @@ platform_bus_probe(void)static struct rte_device *platform_bus_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) { +const struct rte_platform_device *pstart;struct rte_platform_device *pdev; - pdev = start ?RTE_TAILQ_NEXT (RTE_DEV_TO_PLATFORM_DEV_CONST (start), next) : -RTE_TAILQ_FIRST (&platform_bus.device_list); +if (start !=NULL ) { + pstart =RTE_BUS_DEVICE (start, *pstart); + pdev =TAILQ_NEXT (pstart, next); + }else { + pdev =RTE_TAILQ_FIRST (&platform_bus.device_list); + }while (pdev) {if (cmp (&pdev->device, data) ==0 )return &pdev->device;
@@ -464,7 +469,7 @@ platform_bus_plug(struct rte_device *dev)if (!dev_is_bound_vfio_platform (dev->name))return -EPERM ; -return device_attach (RTE_DEV_TO_PLATFORM_DEV (dev)); + return device_attach(RTE_BUS_DEVICE(dev, struct rte_platform_device)); } static void
@@ -486,7 +491,7 @@ device_release_driver(struct rte_platform_device *pdev)static int platform_bus_unplug (struct rte_device *dev) { -struct rte_platform_device *pdev =RTE_DEV_TO_PLATFORM_DEV (dev); +struct rte_platform_device *pdev =RTE_BUS_DEVICE (dev, *pdev);device_release_driver (pdev);device_cleanup (pdev);
@@ -519,7 +524,7 @@ platform_bus_parse(const char *name, void *addr)static int platform_bus_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_platform_device *pdev =RTE_DEV_TO_PLATFORM_DEV (dev); +struct rte_platform_device *pdev =RTE_BUS_DEVICE (dev, *pdev);if (pdev->driver->dma_map !=NULL )return pdev->driver->dma_map (pdev, addr, iova, len);
@@ -530,7 +535,7 @@ platform_bus_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t lstatic int platform_bus_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_platform_device *pdev =RTE_DEV_TO_PLATFORM_DEV (dev); +struct rte_platform_device *pdev =RTE_BUS_DEVICE (dev, *pdev);if (pdev->driver->dma_unmap !=NULL )return pdev->driver->dma_unmap (pdev, addr, iova, len);
drivers/bus/uacce/bus_uacce_driver.h +0 -10
@@ -57,16 +57,6 @@ struct rte_uacce_device {uint32_t qfrt_sz[RTE_UACCE_QFRT_BUTT ];/**< Queue file region type's size. */ }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_uacce_device. -*/ -#define RTE_DEV_TO_UACCE_DEV (ptr) \ - container_of(ptr, struct rte_uacce_device, device) - -#define RTE_DEV_TO_UACCE_DEV_CONST (ptr) \ - container_of(ptr, const struct rte_uacce_device, device) -/** * A structure describing an ID for a UACCE driver. Each driver provides a * table of these IDs for each device that it supports.
drivers/bus/uacce/uacce.c +3 -3
@@ -474,7 +474,7 @@ uacce_cleanup(void)static int uacce_plug (struct rte_device *dev) { -return uacce_probe_all_drivers (RTE_DEV_TO_UACCE_DEV (dev)); + return uacce_probe_all_drivers(RTE_BUS_DEVICE(dev, struct rte_uacce_device)); } static int
@@ -500,7 +500,7 @@ uacce_detach_dev(struct rte_uacce_device *dev)static int uacce_unplug (struct rte_device *dev) { -struct rte_uacce_device *uacce_dev =RTE_DEV_TO_UACCE_DEV (dev); +struct rte_uacce_device *uacce_dev =RTE_BUS_DEVICE (dev, *uacce_dev);int ret; ret =uacce_detach_dev (uacce_dev);
@@ -520,7 +520,7 @@ uacce_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const voidstruct rte_uacce_device *uacce_dev;if (start !=NULL ) { - uacce_start =RTE_DEV_TO_UACCE_DEV_CONST (start); + uacce_start =RTE_BUS_DEVICE (start, *uacce_start); uacce_dev =TAILQ_NEXT (uacce_start, next); }else { uacce_dev =TAILQ_FIRST (&uacce_bus.device_list);
drivers/bus/vdev/bus_vdev_driver.h +3 -11
@@ -8,6 +8,7 @@#include <rte_bus_vdev.h> #include <rte_compat.h> #include <dev_driver.h> +#include <bus_driver.h> #include <rte_devargs.h> #ifdef __cplusplus
@@ -19,17 +20,8 @@ struct rte_vdev_device {struct rte_device device;/**< Inherit core device */ }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_vdev_device. -*/ -#define RTE_DEV_TO_VDEV (ptr) \ - container_of(ptr, struct rte_vdev_device, device) - -#define RTE_DEV_TO_VDEV_CONST (ptr) \ - container_of(ptr, const struct rte_vdev_device, device) - -#define RTE_ETH_DEV_TO_VDEV (eth_dev) RTE_DEV_TO_VDEV((eth_dev)->device) +#define RTE_ETH_DEV_TO_VDEV (eth_dev) \ + RTE_BUS_DEVICE((eth_dev)->device, struct rte_vdev_device)static inline const char *rte_vdev_device_name (const struct rte_vdev_device *dev)
drivers/bus/vdev/vdev.c +9 -15
@@ -141,11 +141,8 @@ vdev_parse(const char *name, void *addr)static int vdev_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_vdev_device *vdev =RTE_DEV_TO_VDEV (dev); -const struct rte_vdev_driver *driver; - - driver = container_of(vdev->device.driver, const struct rte_vdev_driver, - driver); +struct rte_vdev_device *vdev =RTE_BUS_DEVICE (dev, *vdev); +const struct rte_vdev_driver *driver =RTE_BUS_DRIVER (vdev->device.driver, *driver);if (driver->dma_map !=NULL )return driver->dma_map (vdev, addr, iova, len);
@@ -156,11 +153,8 @@ vdev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)static int vdev_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) { -struct rte_vdev_device *vdev =RTE_DEV_TO_VDEV (dev); -const struct rte_vdev_driver *driver; - - driver = container_of(vdev->device.driver, const struct rte_vdev_driver, - driver); +struct rte_vdev_device *vdev =RTE_BUS_DEVICE (dev, *vdev); +const struct rte_vdev_driver *driver =RTE_BUS_DRIVER (vdev->device.driver, *driver);if (driver->dma_unmap !=NULL )return driver->dma_unmap (vdev, addr, iova, len);
@@ -336,8 +330,8 @@ vdev_remove_driver(struct rte_vdev_device *dev)return 1 ; } - driver = container_of(dev->device.driver, const struct rte_vdev_driver, - driver); + driver =RTE_BUS_DRIVER (dev->device.driver, *driver); +return driver->remove (dev); }
@@ -572,7 +566,7 @@ vdev_cleanup(void)if (!rte_dev_is_probed (&dev->device)) goto free; - drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver); + drv =RTE_BUS_DRIVER (dev->device.driver, *drv);if (drv->remove ==NULL ) goto free;
@@ -599,7 +593,7 @@ rte_vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,rte_spinlock_recursive_lock (&vdev_device_list_lock);if (start !=NULL ) { - vstart =RTE_DEV_TO_VDEV_CONST (start); + vstart =RTE_BUS_DEVICE (start, *vstart); dev =TAILQ_NEXT (vstart, next); }else { dev =TAILQ_FIRST (&vdev_device_list);
@@ -617,7 +611,7 @@ rte_vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,static int vdev_plug (struct rte_device *dev) { -return vdev_probe_all_drivers (RTE_DEV_TO_VDEV (dev)); + return vdev_probe_all_drivers(RTE_BUS_DEVICE(dev, struct rte_vdev_device)); } static int
drivers/common/mlx5/linux/mlx5_common_os.c +3 -2
@@ -719,9 +719,10 @@ mlx5_os_get_ibv_dev(const struct rte_device *dev)struct ibv_device *ibv;if (mlx5_dev_is_pci (dev)) - ibv =mlx5_os_get_ibv_device (RTE_DEV_TO_PCI_CONST (dev)); + ibv = mlx5_os_get_ibv_device(RTE_BUS_DEVICE(dev, const struct rte_pci_device));else - ibv =mlx5_get_aux_ibv_device (RTE_DEV_TO_AUXILIARY_CONST (dev)); + ibv =mlx5_get_aux_ibv_device (RTE_BUS_DEVICE (dev, + const struct rte_auxiliary_device));if (ibv ==NULL ) { rte_errno =ENODEV ;DRV_LOG (ERR ,"Verbs device not found: %s" , dev->name);
drivers/common/mlx5/mlx5_common.c +1 -1
@@ -491,7 +491,7 @@ mlx5_dev_to_pci_str(const struct rte_device *dev, char *addr, size_t size)return 0 ; }#ifdef RTE_EXEC_ENV_LINUX -return mlx5_auxiliary_get_pci_str (RTE_DEV_TO_AUXILIARY_CONST (dev), + return mlx5_auxiliary_get_pci_str(RTE_BUS_DEVICE(dev, const struct rte_auxiliary_device), addr, size);#else rte_errno =ENODEV ;
drivers/common/mlx5/mlx5_common_pci.c +1 -1
@@ -138,7 +138,7 @@ mlx5_dev_pci_match(const struct mlx5_class_driver *drv,if (!mlx5_dev_is_pci (dev))return false; - pci_dev =RTE_DEV_TO_PCI_CONST (dev); + pci_dev =RTE_BUS_DEVICE (dev, *pci_dev);for (id_table = drv->id_table; id_table->vendor_id !=0 ; id_table++) {/* Check if device's ids match the class driver's ids. */
drivers/common/mlx5/windows/mlx5_common_os.c +1 -1
@@ -180,7 +180,7 @@ mlx5_os_get_devx_device(struct rte_device *dev, struct devx_device_bdf *devx_list, int n) {struct devx_device_bdf *devx_match =NULL ; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev, *pci_dev);struct rte_pci_addr *addr = &pci_dev->addr;while (n-- >0 ) {
drivers/common/sxe2/sxe2_common.c +2 -2
@@ -171,7 +171,7 @@ static int32_t sxe2_parse_class_type(const char *key, const char *value, void *astatic int32_t sxe2_common_device_setup (struct sxe2_common_device *cdev) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (cdev->dev); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (cdev->dev, *pci_dev);int32_t ret =0 ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY )
@@ -258,7 +258,7 @@ static bool sxe2_dev_pci_id_match(const struct sxe2_class_driver *cdrv, goto l_end; } - pci_dev =RTE_DEV_TO_PCI_CONST (dev); + pci_dev =RTE_BUS_DEVICE (dev, *pci_dev);for (id_table = cdrv->id_table; id_table->vendor_id !=0 ; id_table++) {
drivers/compress/octeontx/otx_zip.c +1 -1
@@ -142,7 +142,7 @@ zipvf_push_command(struct zipvf_qp *qp, union zip_inst_s *cmd)int zipvf_create (struct rte_compressdev *compressdev) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (compressdev->device); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (compressdev->device, *pdev);struct zip_vf *zipvf =NULL ;char *dev_name = compressdev->data->name;void *vbar0;
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +1 -1
@@ -481,7 +481,7 @@ cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,if (dev->data->queue_pairs[qp_id] !=NULL )cnxk_cpt_queue_pair_release (dev, qp_id); - pci_dev =RTE_DEV_TO_PCI (dev->device); + pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);if (pci_dev->mem_resource[2 ].addr ==NULL ) {plt_err ("Invalid PCI mem address" );
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +1 -1
@@ -4392,7 +4392,7 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)int retcode, hw_id;PMD_INIT_FUNC_TRACE (); - dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device); + dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); hw_id = dpaa2_dev->object_id; cryptodev->driver_id = cryptodev_driver_id;
drivers/crypto/octeontx/otx_cryptodev_ops.c +2 -2
@@ -156,7 +156,7 @@ otx_cpt_que_pair_setup(struct rte_cryptodev *dev, DEFAULT_CMD_QLEN); } - pci_dev =RTE_DEV_TO_PCI (dev->device); + pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);if (pci_dev->mem_resource[0 ].addr ==NULL ) {CPT_LOG_ERR ("PCI mem address null" );
@@ -1001,7 +1001,7 @@ static struct rte_cryptodev_ops cptvf_ops = {int otx_cpt_dev_create (struct rte_cryptodev *c_dev) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (c_dev->device); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (c_dev->device, *pdev);struct cpt_vf *cptvf =NULL ;void *reg_base;char dev_name[32 ];
drivers/event/cnxk/cnxk_eventdev.c +1 -1
@@ -654,7 +654,7 @@ cnxk_sso_init(struct rte_eventdev *event_dev)return -ENOMEM ; } - pci_dev = container_of(event_dev->dev, struct rte_pci_device, device); + pci_dev =RTE_BUS_DEVICE (event_dev->dev, *pci_dev); dev->sso.pci_dev = pci_dev; *(uint64_t *)mz->addr = (uint64_t )dev;
drivers/event/dlb2/pf/dlb2_pf.c +1 -1
@@ -784,7 +784,7 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)dlb2_pf_iface_fn_ptrs_init (); - pci_dev =RTE_DEV_TO_PCI (eventdev->dev); + pci_dev =RTE_BUS_DEVICE (eventdev->dev, *pci_dev);if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { dlb2 =dlb2_pmd_priv (eventdev);/* rte_zmalloc_socket mem */
drivers/event/skeleton/skeleton_eventdev.c +1 -1
@@ -332,7 +332,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; - pci_dev =RTE_DEV_TO_PCI (eventdev->dev); + pci_dev =RTE_BUS_DEVICE (eventdev->dev, *pci_dev); skel->reg_base = (uintptr_t )pci_dev->mem_resource[0 ].addr;if (!skel->reg_base) {
drivers/net/axgbe/axgbe_ethdev.c +2 -2
@@ -2231,7 +2231,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)rte_bit_relaxed_set32 (AXGBE_STOPPED , &pdata->dev_state); pdata->eth_dev = eth_dev; - pci_dev =RTE_DEV_TO_PCI (eth_dev->device); + pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); pdata->pci_dev = pci_dev; pdata->xgmac_regs =
@@ -2454,7 +2454,7 @@ axgbe_dev_close(struct rte_eth_dev *eth_dev)return 0 ; pdata = eth_dev->data->dev_private; - pci_dev =RTE_DEV_TO_PCI (eth_dev->device); + pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev);axgbe_dev_clear_queues (eth_dev);/* disable uio intr before callback unregister */
drivers/net/bnx2x/bnx2x_ethdev.c +1 -1
@@ -639,7 +639,7 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)/* Extract key data structures */ sc = eth_dev->data->dev_private; - pci_dev =RTE_DEV_TO_PCI (eth_dev->device); + pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); pci_addr = pci_dev->addr; snprintf(sc->devinfo.name, NAME_SIZE, PCI_SHORT_PRI_FMT ":dpdk-port-%u",
drivers/net/bnxt/bnxt_ethdev.c +1 -1
@@ -1167,7 +1167,7 @@ uint64_t bnxt_eth_rss_support(struct bnxt *bp)static int bnxt_dev_info_get_op (struct rte_eth_dev *eth_dev,struct rte_eth_dev_info *dev_info) { -struct rte_pci_device *pdev =RTE_DEV_TO_PCI (eth_dev->device); +struct rte_pci_device *pdev =RTE_BUS_DEVICE (eth_dev->device, *pdev);struct bnxt *bp = eth_dev->data->dev_private;uint16_t max_vnics, i, j, vpool, vrxq;unsigned int max_rx_rings;
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +2 -2
@@ -192,7 +192,7 @@ ulp_session_init(struct bnxt *bp,if (!bp)return NULL ; - pci_dev =RTE_DEV_TO_PCI (bp->eth_dev->device); + pci_dev =RTE_BUS_DEVICE (bp->eth_dev->device, *pci_dev); pci_addr = &pci_dev->addr;pthread_mutex_lock (&bnxt_ulp_global_mutex);
@@ -556,7 +556,7 @@ bnxt_ulp_port_deinit(struct bnxt *bp) bp->eth_dev->data->port_id);/* Get the session details */ - pci_dev =RTE_DEV_TO_PCI (bp->eth_dev->device); + pci_dev =RTE_BUS_DEVICE (bp->eth_dev->device, *pci_dev); pci_addr = &pci_dev->addr;pthread_mutex_lock (&bnxt_ulp_global_mutex); session =ulp_get_session (bp, pci_addr);
drivers/net/bonding/rte_eth_bond_args.c +1 -1
@@ -26,7 +26,7 @@ const char *pmd_bond_init_valid_arguments[] = {static inline int bond_pci_addr_cmp (const struct rte_device *dev,const void *_pci_addr) { -const struct rte_pci_device *pdev =RTE_DEV_TO_PCI_CONST (dev); +const struct rte_pci_device *pdev =RTE_BUS_DEVICE (dev, *pdev);const struct rte_pci_addr *paddr = _pci_addr;return rte_pci_addr_cmp (&pdev->addr, paddr);
drivers/net/dpaa/dpaa_ethdev.c +6 -7
@@ -230,7 +230,7 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); - dpaa_dev = container_of(rdev, struct rte_dpaa_device, device); + dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); intr_handle = dpaa_dev->intr_handle; __fif = container_of(fif, struct __fman_if, __if);
@@ -432,7 +432,7 @@ static void dpaa_interrupt_handler(void *param)uint64_t buf;int bytes_read; - dpaa_dev = container_of(rdev, struct rte_dpaa_device, device); + dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); intr_handle = dpaa_dev->intr_handle;if (rte_intr_fd_get (intr_handle) <0 )
@@ -530,7 +530,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) } } - dpaa_dev = container_of(rdev, struct rte_dpaa_device, device); + dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); intr_handle = dpaa_dev->intr_handle; __fif = container_of(fif, struct __fman_if, __if);
@@ -1269,8 +1269,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,struct rte_dpaa_device *dpaa_dev;struct rte_device *rdev = dev->device; - dpaa_dev = container_of(rdev, struct rte_dpaa_device, - device); + dpaa_dev =RTE_BUS_DEVICE (rdev, *dpaa_dev); dev->intr_handle = dpaa_dev->intr_handle;if (rte_intr_vec_list_alloc (dev->intr_handle,NULL ,dpaa_push_queue_max_num ())) {
@@ -2120,7 +2119,7 @@ dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE (); - dpaa_device =DEV_TO_DPAA_DEVICE (eth_dev->device); + dpaa_device =RTE_BUS_DEVICE (eth_dev->device, *dpaa_device); dev_id = dpaa_device->id.dev_id; cfg =dpaa_get_eth_port_cfg (dev_id); fman_intf = cfg->fman_if;
@@ -2237,7 +2236,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE (); - dpaa_device =DEV_TO_DPAA_DEVICE (eth_dev->device); + dpaa_device =RTE_BUS_DEVICE (eth_dev->device, *dpaa_device); dev_id = dpaa_device->id.dev_id; dpaa_intf = eth_dev->data->dev_private; cfg =dpaa_get_eth_port_cfg (dev_id);
drivers/net/dpaa2/dpaa2_ethdev.c +3 -3
@@ -1351,7 +1351,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)int ret, i;struct rte_intr_handle *intr_handle; - dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device); + dpaa2_dev =RTE_BUS_DEVICE (rdev, *dpaa2_dev); intr_handle = dpaa2_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -1463,7 +1463,7 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)struct rte_dpaa2_device *dpaa2_dev;uint16_t i; - dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device); + dpaa2_dev =RTE_BUS_DEVICE (rdev, *dpaa2_dev); intr_handle = dpaa2_dev->intr_handle;PMD_INIT_FUNC_TRACE ();
@@ -2918,7 +2918,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } - dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device); + dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); hw_id = dpaa2_dev->object_id; ret =dpni_open (dpni_dev,CMD_PRI_LOW , hw_id, &priv->token);
drivers/net/dpaa2/dpaa2_recycle.c +2 -4
@@ -609,8 +609,7 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev) {struct rte_device *dev = eth_dev->device;struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; -struct rte_dpaa2_device *dpaa2_dev = - container_of(dev, struct rte_dpaa2_device, device); +struct rte_dpaa2_device *dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev);struct fsl_mc_io *dpni_dev = eth_dev->process_private;struct dpni_port_cfg port_cfg;int ret;
@@ -677,8 +676,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev) {struct rte_device *dev = eth_dev->device;struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; -struct rte_dpaa2_device *dpaa2_dev = - container_of(dev, struct rte_dpaa2_device, device); +struct rte_dpaa2_device *dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev);struct fsl_mc_io *dpni_dev = eth_dev->process_private;struct dpni_port_cfg port_cfg;int ret =0 ;
drivers/net/gve/gve_ethdev.c +1 -1
@@ -1491,7 +1491,7 @@ gve_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } - pci_dev =RTE_DEV_TO_PCI (eth_dev->device); + pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev); reg_bar = pci_dev->mem_resource[GVE_REG_BAR ].addr;if (!reg_bar) {
drivers/net/hns3/hns3_ethdev.c +2 -2
@@ -4527,7 +4527,7 @@ static int hns3_init_pf(struct rte_eth_dev *eth_dev) {struct rte_device *dev = eth_dev->device; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev, *pci_dev);struct hns3_adapter *hns = eth_dev->data->dev_private;struct hns3_hw *hw = &hns->hw;int ret;
@@ -4657,7 +4657,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) {struct hns3_adapter *hns = eth_dev->data->dev_private;struct rte_device *dev = eth_dev->device; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev, *pci_dev);struct hns3_hw *hw = &hns->hw;PMD_INIT_FUNC_TRACE ();
drivers/net/hns3/hns3_rxtx.c +1 -1
@@ -3066,7 +3066,7 @@ hns3_tx_push_get_queue_tail_reg(struct rte_eth_dev *dev, uint16_t queue_id)#define HNS3_TX_PUSH_QUICK_DOORBELL_OFFSET 64#define HNS3_TX_PUSH_PCI_BAR_INDEX 4 -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);uint8_t bar_id =HNS3_TX_PUSH_PCI_BAR_INDEX ;/*
drivers/net/intel/cpfl/cpfl_ethdev.c +2 -2
@@ -2764,7 +2764,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };struct cpfl_vport_id vi;struct cpchnl2_vport_id v_id; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -2836,7 +2836,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) }/* get the vport info */ if (adapter->base.hw.device_id ==IXD_DEV_ID_VCPF ) { - pci_dev =RTE_DEV_TO_PCI (dev->device); + pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); vi.func_type =VCPF_CPCHNL2_FTYPE_LAN_VF ; vi.pf_id =CPFL_HOST0_CPF_ID ; vi.vf_id = pci_dev->addr.function;
drivers/net/intel/cpfl/cpfl_ethdev.h +1 -1
@@ -298,7 +298,7 @@ int vcpf_add_queues(struct cpfl_adapter_ext *adapter);int vcpf_del_queues (struct cpfl_adapter_ext *adapter);#define CPFL_DEV_TO_PCI (eth_dev) \ - RTE_DEV_TO_PCI((eth_dev)->device) + RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device)#define CPFL_ADAPTER_TO_EXT (p) \ container_of((p), struct cpfl_adapter_ext, base)#define CPFL_DEV_TO_VPORT (dev) \
drivers/net/intel/i40e/i40e_ethdev.h +1 -1
@@ -1467,7 +1467,7 @@ int i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params);int i40e_vf_representor_uninit (struct rte_eth_dev *ethdev);#define I40E_DEV_TO_PCI (eth_dev) \ - RTE_DEV_TO_PCI((eth_dev)->device) + RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device)/* I40E_DEV_PRIVATE_TO */ #define I40E_DEV_PRIVATE_TO_PF (adapter) \
drivers/net/intel/ice/ice_ethdev.c +2 -2
@@ -2634,7 +2634,7 @@ ice_dev_init(struct rte_eth_dev *dev) }ice_set_default_ptype_table (dev); - pci_dev =RTE_DEV_TO_PCI (dev->device); + pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev); intr_handle = pci_dev->intr_handle; pf->adapter =ICE_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);
@@ -4531,7 +4531,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)struct ice_pf *pf =ICE_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct ice_hw *hw =ICE_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct ice_vsi *vsi = pf->main_vsi; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);bool is_safe_mode = pf->adapter->is_safe_mode;u64 phy_type_low;u64 phy_type_high;
drivers/net/intel/ice/ice_ethdev.h +1 -1
@@ -711,7 +711,7 @@ struct ice_vsi_vlan_pvid_info { };#define ICE_DEV_TO_PCI (eth_dev) \ - RTE_DEV_TO_PCI((eth_dev)->device) + RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device)/* ICE_DEV_PRIVATE_TO */ #define ICE_DEV_PRIVATE_TO_PF (adapter) \
drivers/net/intel/idpf/idpf_ethdev.h +1 -1
@@ -85,7 +85,7 @@ struct idpf_adapter_ext {TAILQ_HEAD (idpf_adapter_list, idpf_adapter_ext);#define IDPF_DEV_TO_PCI (eth_dev) \ - RTE_DEV_TO_PCI((eth_dev)->device) + RTE_BUS_DEVICE((eth_dev)->device, struct rte_pci_device)#define IDPF_ADAPTER_TO_EXT (p) \ container_of((p), struct idpf_adapter_ext, base)
drivers/net/intel/ipn3ke/ipn3ke_ethdev.h +1 -11
@@ -309,18 +309,8 @@ struct ipn3ke_hw {uint8_t *hw_addr; }; -/** -* @internal -* Helper macro for drivers that need to convert to struct rte_afu_device. -*/ -#define RTE_DEV_TO_AFU (ptr) \ - container_of(ptr, struct rte_afu_device, device) - -#define RTE_DEV_TO_AFU_CONST (ptr) \ - container_of(ptr, const struct rte_afu_device, device) -#define RTE_ETH_DEV_TO_AFU (eth_dev) \ - RTE_DEV_TO_AFU((eth_dev)->device) + RTE_BUS_DEVICE((eth_dev)->device, struct rte_afu_device)/** * PCIe MMIO Access
drivers/net/mlx5/linux/mlx5_os.c +5 -4
@@ -171,7 +171,8 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh) }memset (&sh->dev_cap,0 ,sizeof (struct mlx5_dev_cap ));if (mlx5_dev_is_pci (cdev->dev)) - sh->dev_cap.vf =mlx5_dev_is_vf_pci (RTE_DEV_TO_PCI (cdev->dev)); + sh->dev_cap.vf =mlx5_dev_is_vf_pci (RTE_BUS_DEVICE (cdev->dev, + struct rte_pci_device));else sh->dev_cap.sf =1 ; sh->dev_cap.max_qp_wr = attr_ex.orig_attr.max_qp_wr;
@@ -2488,7 +2489,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,* >= 0 - MPESW device. Value is the port index of the MPESW owner. */ int mpesw =MLX5_MPESW_PORT_INVALID ; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (cdev->dev); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (cdev->dev, *pci_dev);struct mlx5_dev_spawn_data *list =NULL ;struct rte_eth_devargs eth_da = *req_eth_da;struct rte_pci_addr owner_pci = pci_dev->addr;/* Owner PF. */
@@ -3051,7 +3052,7 @@ static int mlx5_os_pci_probe(struct mlx5_common_device *cdev, struct mlx5_kvargs_ctrl *mkvlist) { - struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); + struct rte_pci_device *pci_dev = RTE_BUS_DEVICE(cdev->dev, *pci_dev);struct rte_eth_devargs eth_da = { .nb_ports =0 };int ret =0 ;uint16_t p;
@@ -3093,7 +3094,7 @@ mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev, .mpesw_port = MLX5_MPESW_PORT_INVALID, };struct rte_device *dev = cdev->dev; -struct rte_auxiliary_device *adev =RTE_DEV_TO_AUXILIARY (dev); +struct rte_auxiliary_device *adev =RTE_BUS_DEVICE (dev, *adev);struct rte_eth_dev *eth_dev;int ret =0 ;
drivers/net/mlx5/windows/mlx5_os.c +2 -2
@@ -168,7 +168,7 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)return -rte_errno; }memset (&sh->dev_cap,0 ,sizeof (struct mlx5_dev_cap )); - sh->dev_cap.vf =mlx5_dev_is_vf_pci (RTE_DEV_TO_PCI (sh->cdev->dev)); + sh->dev_cap.vf = mlx5_dev_is_vf_pci(RTE_BUS_DEVICE(sh->cdev->dev, struct rte_pci_device)); sh->dev_cap.max_cq =1 << hca_attr->log_max_cq; sh->dev_cap.max_qp =1 << hca_attr->log_max_qp; sh->dev_cap.max_qp_wr =1 << hca_attr->log_max_qp_sz;
@@ -846,7 +846,7 @@ int mlx5_os_net_probe(struct mlx5_common_device *cdev, struct mlx5_kvargs_ctrl *mkvlist) { - struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); + struct rte_pci_device *pci_dev = RTE_BUS_DEVICE(cdev->dev, *pci_dev); struct mlx5_dev_spawn_data spawn = { .pf_bond = -1, .max_port = 1,
drivers/net/netvsc/hn_ethdev.c +1 -1
@@ -1638,7 +1638,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)rte_spinlock_init (&hv->hotadd_lock);LIST_INIT (&hv->hotadd_list); - vmbus = container_of(device, struct rte_vmbus_device, device); + vmbus =RTE_BUS_DEVICE (device, *vmbus); eth_dev->dev_ops = &hn_eth_dev_ops; eth_dev->rx_queue_count = hn_dev_rx_queue_count; eth_dev->rx_descriptor_status = hn_dev_rx_queue_status;
drivers/net/qede/qede_ethdev.c +1 -1
@@ -1231,7 +1231,7 @@ static int qede_args_check(const char *key, const char *val, void *opaque)static int qede_args (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (eth_dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev);struct rte_kvargs *kvlist;struct rte_devargs *devargs;int ret;
drivers/net/rnp/rnp_ethdev.c +3 -3
@@ -728,7 +728,7 @@ static int rnp_dev_close(struct rte_eth_dev *eth_dev)if (adapter->intr_registered && adapter->eth_dev == eth_dev)rnp_change_manage_port (adapter);if (adapter->closed_ports == adapter->inited_ports) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI ((void *)eth_dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev);if (adapter->intr_registered) {/* disable uio irq before callback unregister */ rte_intr_disable (pci_dev->intr_handle);
@@ -1667,7 +1667,7 @@ rnp_rx_reset_pool_setup(struct rnp_eth_adapter *adapter)static int rnp_eth_dev_init (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI ((void *)eth_dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev);struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rnp_eth_port *port =RNP_DEV_TO_PORT (eth_dev);char name[RTE_ETH_NAME_MAX_LEN ] =" " ;
@@ -1798,7 +1798,7 @@ rnp_eth_dev_init(struct rte_eth_dev *eth_dev)static int rnp_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI ((void *)eth_dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (eth_dev->device, *pci_dev);uint16_t port_id;int err =0 ;
drivers/net/sxe2/sxe2_ethdev.c +4 -4
@@ -561,7 +561,7 @@ static int32_t sxe2_dev_info_init(struct rte_eth_dev *dev) {struct sxe2_adapter *adapter =SXE2_DEV_PRIVATE_TO_ADAPTER (dev); -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);struct sxe2_dev_info *dev_info = &adapter->dev_info;struct sxe2_drv_dev_info_resp dev_info_resp = {0 };struct sxe2_drv_dev_fw_info_resp dev_fw_info_resp = {0 };
@@ -600,7 +600,7 @@ static int32_t sxe2_dev_info_init(struct rte_eth_dev *dev)int32_t sxe2_dev_pci_map_init (struct rte_eth_dev *dev) {struct sxe2_adapter *adapter =SXE2_DEV_PRIVATE_TO_ADAPTER (dev); -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (dev->device); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev->device, *pci_dev);struct sxe2_pci_map_context *map_ctxt = &adapter->map_ctxt;struct sxe2_pci_map_bar_info *bar_info =NULL ;struct sxe2_pci_map_segment_info *seg_info =NULL ;
@@ -817,7 +817,7 @@ static int32_t sxe2_dev_uninit(struct rte_eth_dev *dev)static int32_t sxe2_eth_pmd_remove (struct sxe2_common_device *cdev) {struct rte_eth_dev *eth_dev; -struct rte_pci_device *pci_dev =RTE_DEV_TO_PCI (cdev->dev); +struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (cdev->dev, *pci_dev);int32_t ret =0 ; eth_dev =rte_eth_dev_allocated (pci_dev->device.name);
@@ -842,7 +842,7 @@ static int32_t sxe2_eth_pmd_probe_pf(struct sxe2_common_device *cdev, uint16_t owner_id __rte_unused, struct sxe2_dev_kvargs_info *kvargs) { - struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); + struct rte_pci_device *pci_dev = RTE_BUS_DEVICE(cdev->dev, *pci_dev);struct rte_eth_dev *eth_dev =NULL ;struct sxe2_adapter *adapter =NULL ;int32_t ret =0 ;
drivers/net/sxe2/sxe2_ethdev.h +0 -3
@@ -292,9 +292,6 @@ struct sxe2_adapter {#define SXE2_DEV_PRIVATE_TO_ADAPTER (dev) \ ((struct sxe2_adapter *)(dev)->data->dev_private) -#define SXE2_DEV_TO_PCI (eth_dev) \ - RTE_DEV_TO_PCI((eth_dev)->device) -void *sxe2_pci_map_addr_get (struct sxe2_adapter *adapter,enum sxe2_pci_map_resource res_type,uint16_t idx_in_func);
drivers/raw/ifpga/afu_pmd_n3000.c +2 -2
@@ -1467,11 +1467,11 @@ static struct rte_pci_device *n3000_afu_get_pci_dev(struct afu_rawdev *dev)if (!dev || !dev->rawdev || !dev->rawdev->device)return NULL ; - afudev =RTE_DEV_TO_AFU (dev->rawdev->device); + afudev =RTE_BUS_DEVICE (dev->rawdev->device, *afudev);if (!afudev->rawdev || !afudev->rawdev->device)return NULL ; -return RTE_DEV_TO_PCI (afudev->rawdev->device); + return RTE_BUS_DEVICE(afudev->rawdev->device, struct rte_pci_device); } static int dma_afu_set_irqs(struct afu_rawdev *dev, uint32_t vec_start,
lib/eal/include/bus_driver.h +30 -0
@@ -340,6 +340,36 @@ RTE_INIT_PRIO(businitfn_ ##nm, BUS) \__rte_internal void rte_bus_unregister(struct rte_bus *bus); +/** +* Helper macro to convert a generic device pointer to a bus-specific device type. +* Uses typeof to automatically determine the bus-specific type from the second argument. +* +* @param dev +* Generic rte_device pointer to convert +* @param bus_dev_type +* Type specifier: either a struct type (e.g., struct rte_pci_device) or +* a dereferenced pointer variable (e.g., *pdev) to infer the type automatically +* @return +* Pointer to the bus-specific device structure containing this rte_device +*/ +#define RTE_BUS_DEVICE (dev, bus_dev_type) \ + container_of(dev, typeof(bus_dev_type), device) + +/** +* Helper macro to convert a generic driver pointer to a bus-specific driver type. +* Uses typeof to automatically determine the bus-specific type from the second argument. +* +* @param drv +* Generic rte_driver pointer to convert +* @param bus_drv_type +* Type specifier: either a struct type (e.g., struct rte_pci_driver) or +* a dereferenced pointer variable (e.g., *pdrv) to infer the type automatically +* @return +* Pointer to the bus-specific driver structure containing this rte_driver +*/ +#define RTE_BUS_DRIVER (drv, bus_drv_type) \ + container_of(drv, typeof(bus_drv_type), driver) + #ifdef __cplusplus }#endif
Signature · 1 line
2.53.0
PATCH v5 9/25 bus: factorize driver list
In reply to David MarchandMove driver_list management from individual bus implementations to common EAL bus code. This eliminates duplication and provides a consistent API for driver registration across all buses.
Introduce rte_bus_add_driver() and rte_bus_remove_driver() helpers that manage a per-bus driver list internally in EAL. Update all buses to use these common helpers and remove bus-specific driver_list fields and iteration macros.
Store a reference to the bus object in the generic driver.
Also update the dma/idxd code that has only one hardcoded driver.
--- drivers/bus/auxiliary/auxiliary_common.c | 11 +++-- drivers/bus/auxiliary/bus_auxiliary_driver.h | 1 - drivers/bus/auxiliary/linux/auxiliary.c | 2 +- drivers/bus/auxiliary/private.h | 4 -- drivers/bus/cdx/bus_cdx_driver.h | 2 - drivers/bus/cdx/cdx.c | 12 ++---- drivers/bus/cdx/private.h | 1 - drivers/bus/dpaa/bus_dpaa_driver.h | 1 - drivers/bus/dpaa/dpaa_bus.c | 8 ++-- drivers/bus/fslmc/bus_fslmc_driver.h | 1 - drivers/bus/fslmc/fslmc_bus.c | 11 +++-- drivers/bus/fslmc/private.h | 2 - drivers/bus/ifpga/bus_ifpga_driver.h | 3 +- drivers/bus/ifpga/ifpga_bus.c | 9 ++-- drivers/bus/pci/bus_pci_driver.h | 1 - drivers/bus/pci/pci_common.c | 9 ++-- drivers/bus/pci/private.h | 4 -- drivers/bus/platform/bus_platform_driver.h | 1 - drivers/bus/platform/platform.c | 9 ++-- drivers/bus/platform/private.h | 4 -- drivers/bus/uacce/bus_uacce_driver.h | 2 - drivers/bus/uacce/uacce.c | 12 ++---- drivers/bus/vdev/bus_vdev_driver.h | 1 - drivers/bus/vdev/vdev.c | 9 ++-- drivers/bus/vmbus/bus_vmbus_driver.h | 1 - drivers/bus/vmbus/private.h | 4 -- drivers/bus/vmbus/vmbus_common.c | 7 ++-- drivers/dma/idxd/idxd_bus.c | 6 ++- lib/eal/common/eal_common_bus.c | 17 ++++++++ lib/eal/include/bus_driver.h | 44 ++++++++++++++++++++ lib/eal/include/dev_driver.h | 1 + 31 files changed, 105 insertions(+), 95 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +5 -6
@@ -171,7 +171,7 @@ auxiliary_probe_all_drivers(struct rte_auxiliary_device *dev)struct rte_auxiliary_driver *drv;int rc; -FOREACH_DRIVER_ON_AUXILIARY_BUS (drv) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) {if (!drv->match (dev->name))continue ;
@@ -226,7 +226,7 @@ auxiliary_parse(const char *name, void *addr)if (strlen (name) ==0 )return 0 ; -FOREACH_DRIVER_ON_AUXILIARY_BUS (drv) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) {if (drv->match (name))break ; }
@@ -240,7 +240,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_auxiliary_register)void rte_auxiliary_register (struct rte_auxiliary_driver *driver) { -TAILQ_INSERT_TAIL (&auxiliary_bus.driver_list, driver, next); +rte_bus_add_driver (&auxiliary_bus.bus, &driver->driver); }/* Unregister a driver */
@@ -248,7 +248,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_auxiliary_unregister)void rte_auxiliary_unregister (struct rte_auxiliary_driver *driver) { -TAILQ_REMOVE (&auxiliary_bus.driver_list, driver, next); +rte_bus_remove_driver (&auxiliary_bus.bus, &driver->driver); }/* Add a device to auxiliary bus */
@@ -369,7 +369,7 @@ auxiliary_get_iommu_class(void) {const struct rte_auxiliary_driver *drv; -FOREACH_DRIVER_ON_AUXILIARY_BUS (drv) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) {if ((drv->drv_flags &RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA ) >0 )return RTE_IOVA_VA ; }
@@ -392,7 +392,6 @@ struct rte_auxiliary_bus auxiliary_bus = { .dev_iterate = auxiliary_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(auxiliary_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(auxiliary_bus.driver_list), };RTE_REGISTER_BUS (auxiliary, auxiliary_bus.bus);
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -1
@@ -121,7 +121,6 @@ struct rte_auxiliary_device {* A structure describing an auxiliary driver. */ struct rte_auxiliary_driver { -RTE_TAILQ_ENTRY (rte_auxiliary_driver) next;/**< Next in list. */ struct rte_driver driver;/**< Inherit core driver. */ rte_auxiliary_match_t *match;/**< Device match function. */ rte_auxiliary_probe_t *probe;/**< Device probe function. */
drivers/bus/auxiliary/linux/auxiliary.c +1 -1
@@ -117,7 +117,7 @@ auxiliary_scan(void) AUXILIARY_SYSFS_PATH, e->d_name);/* Ignore if no driver can handle. */ -FOREACH_DRIVER_ON_AUXILIARY_BUS (drv) { + RTE_BUS_FOREACH_DRV(drv, &auxiliary_bus.bus) {if (drv->match (e->d_name))break ; }
drivers/bus/auxiliary/private.h +0 -4
@@ -25,7 +25,6 @@ extern int auxiliary_bus_logtype;struct rte_auxiliary_bus {struct rte_bus bus;/* Inherit the generic class */ TAILQ_HEAD(, rte_auxiliary_device) device_list; /* List of devices */ - TAILQ_HEAD(, rte_auxiliary_driver) driver_list; /* List of drivers */ };extern struct rte_auxiliary_bus auxiliary_bus;
@@ -34,9 +33,6 @@ extern struct rte_auxiliary_bus auxiliary_bus;#define FOREACH_DEVICE_ON_AUXILIARY_BUS (p) \ TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next) -#define FOREACH_DRIVER_ON_AUXILIARY_BUS (p) \ - TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next) -/* * Test whether the auxiliary device exist. */
drivers/bus/cdx/bus_cdx_driver.h +0 -2
@@ -91,9 +91,7 @@ typedef int (rte_cdx_remove_t)(struct rte_cdx_device *);* A structure describing a CDX driver. */ struct rte_cdx_driver { -RTE_TAILQ_ENTRY (rte_cdx_driver) next;/**< Next in list. */ struct rte_driver driver;/**< Inherit core driver. */ -struct rte_cdx_bus *bus;/**< CDX bus reference. */ rte_cdx_probe_t *probe;/**< Device probe function. */ rte_cdx_remove_t *remove;/**< Device remove function. */ const struct rte_cdx_id *id_table;/**< ID table, NULL terminated. */
drivers/bus/cdx/cdx.c +3 -9
@@ -88,9 +88,6 @@#define FOREACH_DEVICE_ON_CDXBUS (p) \ RTE_TAILQ_FOREACH(p, &rte_cdx_bus.device_list, next) -#define FOREACH_DRIVER_ON_CDXBUS (p) \ - RTE_TAILQ_FOREACH(p, &rte_cdx_bus.driver_list, next) -struct rte_cdx_bus rte_cdx_bus;enum cdx_params {
@@ -394,7 +391,7 @@ cdx_probe_all_drivers(struct rte_cdx_device *dev)struct rte_cdx_driver *dr =NULL ;int rc =0 ; -FOREACH_DRIVER_ON_CDXBUS (dr) { + RTE_BUS_FOREACH_DRV(dr, &rte_cdx_bus.bus) { rc =cdx_probe_one_driver (dr, dev);if (rc <0 )/* negative value is an error */
@@ -453,8 +450,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_cdx_register)void rte_cdx_register (struct rte_cdx_driver *driver) { -TAILQ_INSERT_TAIL (&rte_cdx_bus.driver_list, driver, next); - driver->bus = &rte_cdx_bus; +rte_bus_add_driver (&rte_cdx_bus.bus, &driver->driver); }/* unregister a driver */
@@ -462,8 +458,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_cdx_unregister)void rte_cdx_unregister (struct rte_cdx_driver *driver) { -TAILQ_REMOVE (&rte_cdx_bus.driver_list, driver, next); - driver->bus =NULL ; +rte_bus_remove_driver (&rte_cdx_bus.bus, &driver->driver); } static struct rte_device *
@@ -630,7 +625,6 @@ struct rte_cdx_bus rte_cdx_bus = { .dev_iterate = cdx_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_cdx_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(rte_cdx_bus.driver_list), };RTE_REGISTER_BUS (cdx, rte_cdx_bus.bus);
drivers/bus/cdx/private.h +0 -1
@@ -13,7 +13,6 @@struct rte_cdx_bus {struct rte_bus bus;/**< Inherit the generic class */ RTE_TAILQ_HEAD(, rte_cdx_device) device_list; /**< List of CDX devices */ - RTE_TAILQ_HEAD(, rte_cdx_driver) driver_list; /**< List of CDX drivers */ };/**
drivers/bus/dpaa/bus_dpaa_driver.h +0 -1
@@ -98,7 +98,6 @@ typedef int (*rte_dpaa_probe_t)(struct rte_dpaa_driver *dpaa_drv,typedef int (*rte_dpaa_remove_t )(struct rte_dpaa_device *dpaa_dev);struct rte_dpaa_driver { -TAILQ_ENTRY (rte_dpaa_driver) next;struct rte_driver driver;enum rte_dpaa_type drv_type;rte_dpaa_probe_t probe;
drivers/bus/dpaa/dpaa_bus.c +3 -5
@@ -60,7 +60,6 @@struct rte_dpaa_bus {struct rte_bus bus; TAILQ_HEAD(, rte_dpaa_device) device_list; - TAILQ_HEAD(, rte_dpaa_driver) driver_list;int device_count;int detected;uint32_t svr_ver;
@@ -618,7 +617,7 @@ rte_dpaa_driver_register(struct rte_dpaa_driver *driver)BUS_INIT_FUNC_TRACE (); -TAILQ_INSERT_TAIL (&rte_dpaa_bus.driver_list, driver, next); +rte_bus_add_driver (&rte_dpaa_bus.bus, &driver->driver); }/* un-register a dpaa bus based dpaa driver */
@@ -628,7 +627,7 @@ rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver) {BUS_INIT_FUNC_TRACE (); -TAILQ_REMOVE (&rte_dpaa_bus.driver_list, driver, next); +rte_bus_remove_driver (&rte_dpaa_bus.bus, &driver->driver); } static int
@@ -797,7 +796,7 @@ rte_dpaa_bus_probe(void)/* For each registered driver, and device, call the driver->probe */ TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) { - TAILQ_FOREACH(drv, &rte_dpaa_bus.driver_list, next) { + RTE_BUS_FOREACH_DRV(drv, &rte_dpaa_bus.bus) { ret =rte_dpaa_device_match (drv, dev);if (ret)continue ;
@@ -990,7 +989,6 @@ static struct rte_dpaa_bus rte_dpaa_bus = { }, .max_push_rxq_num = DPAA_DEFAULT_PUSH_MODE_QUEUE, .device_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(rte_dpaa_bus.driver_list), .device_count = 0, };
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
@@ -138,7 +138,6 @@ rte_fslmc_vfio_mem_dmaunmap(uint64_t iova, uint64_t size);* A structure describing a DPAA2 driver. */ struct rte_dpaa2_driver { -TAILQ_ENTRY (rte_dpaa2_driver) next;/**< Next in list. */ struct rte_driver driver;/**< Inherit core driver. */ uint32_t drv_flags;/**< Flags for controlling device.*/ enum rte_dpaa2_dev_type drv_type;/**< Driver Type */
drivers/bus/fslmc/fslmc_bus.c +5 -6
@@ -457,7 +457,7 @@ rte_fslmc_probe(void) } TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + RTE_BUS_FOREACH_DRV(drv, &rte_fslmc_bus.bus) { ret =rte_fslmc_match (drv, dev);if (ret)continue ;
@@ -522,7 +522,7 @@ rte_fslmc_driver_register(struct rte_dpaa2_driver *driver)RTE_VERIFY (driver);RTE_VERIFY (driver->probe !=NULL ); -TAILQ_INSERT_TAIL (&rte_fslmc_bus.driver_list, driver, next); +rte_bus_add_driver (&rte_fslmc_bus.bus, &driver->driver); }/*un-register a fslmc bus based dpaa2 driver */
@@ -530,7 +530,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_fslmc_driver_unregister)void rte_fslmc_driver_unregister (struct rte_dpaa2_driver *driver) { -TAILQ_REMOVE (&rte_fslmc_bus.driver_list, driver, next); +rte_bus_remove_driver (&rte_fslmc_bus.bus, &driver->driver); }/*
@@ -544,7 +544,7 @@ fslmc_all_device_support_iova(void)struct rte_dpaa2_driver *drv; TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) { - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + RTE_BUS_FOREACH_DRV(drv, &rte_fslmc_bus.bus) { ret =rte_fslmc_match (drv, dev);if (ret)continue ;
@@ -582,7 +582,7 @@ fslmc_bus_plug(struct rte_device *rte_dev)struct rte_dpaa2_device *dev =RTE_BUS_DEVICE (rte_dev, *dev);struct rte_dpaa2_driver *drv; - TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + RTE_BUS_FOREACH_DRV(drv, &rte_fslmc_bus.bus) { ret =rte_fslmc_match (drv, dev);if (ret)continue ;
@@ -688,7 +688,6 @@ struct rte_fslmc_bus rte_fslmc_bus = { .dev_iterate = fslmc_bus_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.driver_list), .device_count = {0}, };
drivers/bus/fslmc/private.h +0 -2
@@ -16,8 +16,6 @@ struct rte_fslmc_bus {struct rte_bus bus;/**< Generic Bus object */ TAILQ_HEAD(, rte_dpaa2_device) device_list;/**< FSLMC DPAA2 Device list */ - TAILQ_HEAD(, rte_dpaa2_driver) driver_list; -/**< FSLMC DPAA2 Driver list */ int device_count[DPAA2_DEVTYPE_MAX ];/**< Count of all devices scanned */ };
drivers/bus/ifpga/bus_ifpga_driver.h +1 -2
@@ -91,10 +91,9 @@ typedef int (afu_probe_t)(struct rte_afu_device *);typedef int (afu_remove_t )(struct rte_afu_device *);/** -* A structure describing a AFU device. +* A structure describing a AFU driver. */ struct rte_afu_driver { -RTE_TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ struct rte_driver driver;/**< Inherit core driver. */ afu_probe_t *probe;/**< Device Probe function. */ afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/ifpga_bus.c +3 -6
@@ -40,9 +40,6 @@ static struct rte_bus rte_ifpga_bus; static TAILQ_HEAD(, rte_afu_device) ifpga_afu_dev_list =TAILQ_HEAD_INITIALIZER (ifpga_afu_dev_list); -static TAILQ_HEAD(, rte_afu_driver) ifpga_afu_drv_list = -TAILQ_HEAD_INITIALIZER (ifpga_afu_drv_list); -/* register a ifpga bus based driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_ifpga_driver_register)
@@ -50,14 +47,14 @@ void rte_ifpga_driver_register(struct rte_afu_driver *driver) {RTE_VERIFY (driver); -TAILQ_INSERT_TAIL (&ifpga_afu_drv_list, driver, next); +rte_bus_add_driver (&rte_ifpga_bus, &driver->driver); }/* un-register a fpga bus based driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_ifpga_driver_unregister) void rte_ifpga_driver_unregister(struct rte_afu_driver *driver) { -TAILQ_REMOVE (&ifpga_afu_drv_list, driver, next); +rte_bus_remove_driver (&rte_ifpga_bus, &driver->driver); } static struct rte_afu_device *
@@ -309,7 +306,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -EEXIST ; } - TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { + RTE_BUS_FOREACH_DRV(drv, &rte_ifpga_bus) { ret =ifpga_probe_one_driver (drv, afu_dev);if (ret <0 )/* negative value is an error */
drivers/bus/pci/bus_pci_driver.h +0 -1
@@ -122,7 +122,6 @@ typedef int (pci_dma_unmap_t)(struct rte_pci_device *dev, void *addr,* A structure describing a PCI driver. */ struct rte_pci_driver { -RTE_TAILQ_ENTRY (rte_pci_driver) next;/**< Next in list. */ struct rte_driver driver;/**< Inherit core driver. */ rte_pci_probe_t *probe;/**< Device probe function. */ rte_pci_remove_t *remove;/**< Device remove function. */
drivers/bus/pci/pci_common.c +4 -5
@@ -358,7 +358,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)if (dev ==NULL )return -EINVAL ; -FOREACH_DRIVER_ON_PCIBUS (dr) { + RTE_BUS_FOREACH_DRV(dr, &rte_pci_bus.bus) { rc =rte_pci_probe_one_driver (dr, dev);if (rc <0 )/* negative value is an error */
@@ -501,7 +501,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_pci_register)void rte_pci_register (struct rte_pci_driver *driver) { -TAILQ_INSERT_TAIL (&rte_pci_bus.driver_list, driver, next); +rte_bus_add_driver (&rte_pci_bus.bus, &driver->driver); }/* unregister a driver */
@@ -509,7 +509,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_pci_unregister)void rte_pci_unregister (struct rte_pci_driver *driver) { -TAILQ_REMOVE (&rte_pci_bus.driver_list, driver, next); +rte_bus_remove_driver (&rte_pci_bus.bus, &driver->driver); }/* Add a device to PCI bus */
@@ -720,7 +720,7 @@ rte_pci_get_iommu_class(void)if (dev->kdrv ==RTE_PCI_KDRV_UNKNOWN || dev->kdrv ==RTE_PCI_KDRV_NONE )continue ; -FOREACH_DRIVER_ON_PCIBUS (drv) { + RTE_BUS_FOREACH_DRV(drv, &rte_pci_bus.bus) {enum rte_iova_mode dev_iova_mode;if (!rte_pci_match (drv, dev))
@@ -917,7 +917,6 @@ struct rte_pci_bus rte_pci_bus = { .sigbus_handler = pci_sigbus_handler, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), };RTE_REGISTER_BUS (pci, rte_pci_bus.bus);
drivers/bus/pci/private.h +0 -4
@@ -35,7 +35,6 @@ extern int pci_bus_logtype;struct rte_pci_bus {struct rte_bus bus;/**< Inherit the generic class */ RTE_TAILQ_HEAD(, rte_pci_device) device_list; /**< List of PCI devices */ - RTE_TAILQ_HEAD(, rte_pci_driver) driver_list; /**< List of PCI drivers */ };extern struct rte_pci_bus rte_pci_bus;
@@ -44,9 +43,6 @@ extern struct rte_pci_bus rte_pci_bus;#define FOREACH_DEVICE_ON_PCIBUS (p) \ RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next) -#define FOREACH_DRIVER_ON_PCIBUS (p) \ - RTE_TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next) -struct rte_pci_driver ;struct rte_pci_device ;
drivers/bus/platform/bus_platform_driver.h +0 -1
@@ -107,7 +107,6 @@ struct rte_platform_device {* A structure describing a platform device driver. */ struct rte_platform_driver { -RTE_TAILQ_ENTRY (rte_platform_driver) next;/**< Next available platform driver */ struct rte_driver driver;/**< Core driver */ rte_platform_probe_t *probe;/**< Device probe function */ rte_platform_remove_t *remove;/**< Device remove function */
drivers/bus/platform/platform.c +4 -5
@@ -33,14 +33,14 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_platform_register)void rte_platform_register (struct rte_platform_driver *pdrv) { -TAILQ_INSERT_TAIL (&platform_bus.driver_list, pdrv, next); +rte_bus_add_driver (&platform_bus.bus, &pdrv->driver); }RTE_EXPORT_INTERNAL_SYMBOL (rte_platform_unregister) voidrte_platform_unregister (struct rte_platform_driver *pdrv) { -TAILQ_REMOVE (&platform_bus.driver_list, pdrv, next); +rte_bus_remove_driver (&platform_bus.bus, &pdrv->driver); } static int
@@ -408,7 +408,7 @@ device_attach(struct rte_platform_device *pdev) {struct rte_platform_driver *pdrv; -FOREACH_DRIVER_ON_PLATFORM_BUS (pdrv) { + RTE_BUS_FOREACH_DRV(pdrv, &platform_bus.bus) {if (driver_match_device (pdrv, pdev))break ; }
@@ -510,7 +510,7 @@ platform_bus_parse(const char *name, void *addr)rte_strscpy (pdev.name, name,sizeof (pdev.name)); -FOREACH_DRIVER_ON_PLATFORM_BUS (pdrv) { + RTE_BUS_FOREACH_DRV(pdrv, &platform_bus.bus) {if (driver_match_device (pdrv, &pdev))break ; }
@@ -589,7 +589,6 @@ struct rte_platform_bus platform_bus = { .cleanup = platform_bus_cleanup, }, .device_list = TAILQ_HEAD_INITIALIZER(platform_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(platform_bus.driver_list), };RTE_REGISTER_BUS (platform, platform_bus.bus);
drivers/bus/platform/private.h +0 -4
@@ -20,16 +20,12 @@ extern struct rte_platform_bus platform_bus;#define FOREACH_DEVICE_ON_PLATFORM_BUS (p) \ RTE_TAILQ_FOREACH(p, &(platform_bus.device_list), next) -#define FOREACH_DRIVER_ON_PLATFORM_BUS (p) \ - RTE_TAILQ_FOREACH(p, &(platform_bus.driver_list), next) -/* * Structure describing platform bus. */ struct rte_platform_bus {struct rte_bus bus;/* Core bus */ RTE_TAILQ_HEAD(, rte_platform_device) device_list; /* List of bus devices */ - RTE_TAILQ_HEAD(, rte_platform_driver) driver_list; /* List of bus drivers */ };extern int platform_bus_logtype;
drivers/bus/uacce/bus_uacce_driver.h +0 -2
@@ -85,9 +85,7 @@ typedef int (rte_uacce_remove_t)(struct rte_uacce_device *);* A structure describing a UACCE driver. */ struct rte_uacce_driver { -RTE_TAILQ_ENTRY (rte_uacce_driver) next;/**< Next in list. */ struct rte_driver driver;/**< Inherit core driver. */ -struct rte_uacce_bus *bus;/**< UACCE bus reference. */ rte_uacce_probe_t *probe;/**< Device probe function. */ rte_uacce_remove_t *remove;/**< Device remove function. */ const struct rte_uacce_id *id_table;/**< ID table, NULL terminated. */
drivers/bus/uacce/uacce.c +3 -9
@@ -40,7 +40,6 @@struct rte_uacce_bus {struct rte_bus bus;/* Inherit the generic class. */ TAILQ_HEAD(, rte_uacce_device) device_list; /* List of devices. */ - TAILQ_HEAD(, rte_uacce_driver) driver_list; /* List of drivers. */ };/* Forward declaration of UACCE bus. */
@@ -57,8 +56,6 @@ static const char *const uacce_params_keys[] = {#define FOREACH_DEVICE_ON_UACCEBUS (p) \ RTE_TAILQ_FOREACH(p, &uacce_bus.device_list, next) -#define FOREACH_DRIVER_ON_UACCEBUS (p) \ - RTE_TAILQ_FOREACH(p, &uacce_bus.driver_list, next)extern int uacce_bus_logtype;#define RTE_LOGTYPE_UACCE_BUS uacce_bus_logtype
@@ -404,7 +401,7 @@ uacce_probe_all_drivers(struct rte_uacce_device *dev)struct rte_uacce_driver *dr;int rc; -FOREACH_DRIVER_ON_UACCEBUS (dr) { + RTE_BUS_FOREACH_DRV(dr, &uacce_bus.bus) { rc =uacce_probe_one_driver (dr, dev);if (rc <0 )/* negative value is an error */
@@ -686,16 +683,14 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_uacce_register)void rte_uacce_register (struct rte_uacce_driver *driver) { -TAILQ_INSERT_TAIL (&uacce_bus.driver_list, driver, next); - driver->bus = &uacce_bus; +rte_bus_add_driver (&uacce_bus.bus, &driver->driver); }RTE_EXPORT_INTERNAL_SYMBOL (rte_uacce_unregister) voidrte_uacce_unregister (struct rte_uacce_driver *driver) { -TAILQ_REMOVE (&uacce_bus.driver_list, driver, next); - driver->bus =NULL ; +rte_bus_remove_driver (&uacce_bus.bus, &driver->driver); }static struct rte_uacce_bus uacce_bus = {
@@ -710,7 +705,6 @@ static struct rte_uacce_bus uacce_bus = { .dev_iterate = uacce_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(uacce_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(uacce_bus.driver_list), };RTE_REGISTER_BUS (uacce, uacce_bus.bus);
drivers/bus/vdev/bus_vdev_driver.h +0 -1
@@ -91,7 +91,6 @@ typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr,* A virtual device driver abstraction. */ struct rte_vdev_driver { -RTE_TAILQ_ENTRY (rte_vdev_driver) next;/**< Next in list. */ struct rte_driver driver;/**< Inherited general driver. */ rte_vdev_probe_t *probe;/**< Virtual device probe function. */ rte_vdev_remove_t *remove;/**< Virtual device remove function. */
drivers/bus/vdev/vdev.c +3 -6
@@ -38,9 +38,6 @@ static TAILQ_HEAD(, rte_vdev_device) vdev_device_list =static rte_spinlock_recursive_t vdev_device_list_lock =RTE_SPINLOCK_RECURSIVE_INITIALIZER ; -static TAILQ_HEAD(, rte_vdev_driver) vdev_driver_list = -TAILQ_HEAD_INITIALIZER (vdev_driver_list); -struct vdev_custom_scan {TAILQ_ENTRY (vdev_custom_scan) next;rte_vdev_scan_callback callback;
@@ -56,7 +53,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_vdev_register)void rte_vdev_register (struct rte_vdev_driver *driver) { -TAILQ_INSERT_TAIL (&vdev_driver_list, driver, next); +rte_bus_add_driver (&rte_vdev_bus, &driver->driver); }/* unregister a driver */
@@ -64,7 +61,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_vdev_unregister)void rte_vdev_unregister (struct rte_vdev_driver *driver) { -TAILQ_REMOVE (&vdev_driver_list, driver, next); +rte_bus_remove_driver (&rte_vdev_bus, &driver->driver); }RTE_EXPORT_SYMBOL (rte_vdev_add_custom_scan)
@@ -123,7 +120,7 @@ vdev_parse(const char *name, void *addr)struct rte_vdev_driver **out = addr;struct rte_vdev_driver *driver =NULL ; - TAILQ_FOREACH(driver, &vdev_driver_list, next) { + RTE_BUS_FOREACH_DRV(driver, &rte_vdev_bus) {if (strncmp (driver->driver.name, name,strlen (driver->driver.name)) ==0 )break ;
drivers/bus/vmbus/bus_vmbus_driver.h +0 -1
@@ -68,7 +68,6 @@ typedef int (vmbus_remove_t)(struct rte_vmbus_device *);* A structure describing a VMBUS driver. */ struct rte_vmbus_driver { -RTE_TAILQ_ENTRY (rte_vmbus_driver) next;/**< Next in list. */ struct rte_driver driver;vmbus_probe_t *probe;/**< Device Probe function. */ vmbus_remove_t *remove;/**< Device Remove function. */
drivers/bus/vmbus/private.h +0 -4
@@ -21,7 +21,6 @@struct rte_vmbus_bus {struct rte_bus bus;/**< Inherit the generic class */ RTE_TAILQ_HEAD(, rte_vmbus_device) device_list; /**< List of devices */ - RTE_TAILQ_HEAD(, rte_vmbus_driver) driver_list; /**< List of drivers */ };extern struct rte_vmbus_bus rte_vmbus_bus;
@@ -30,9 +29,6 @@ extern struct rte_vmbus_bus rte_vmbus_bus;#define FOREACH_DEVICE_ON_VMBUS (p) \ RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next) -#define FOREACH_DRIVER_ON_VMBUS (p) \ - RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next) -extern int vmbus_logtype_bus;#define RTE_LOGTYPE_VMBUS_BUS vmbus_logtype_bus#define VMBUS_LOG (level, ...) \
drivers/bus/vmbus/vmbus_common.c +3 -4
@@ -155,7 +155,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)return 0 ; } -FOREACH_DRIVER_ON_VMBUS (dr) { + RTE_BUS_FOREACH_DRV(dr, &rte_vmbus_bus.bus) { rc =vmbus_probe_one_driver (dr, dev);if (rc <0 )/* negative is an error */ return -1 ;
@@ -263,7 +263,7 @@ rte_vmbus_register(struct rte_vmbus_driver *driver)VMBUS_LOG (DEBUG ,"Registered driver %s" , driver->driver.name); -TAILQ_INSERT_TAIL (&rte_vmbus_bus.driver_list, driver, next); +rte_bus_add_driver (&rte_vmbus_bus.bus, &driver->driver); }/* unregister vmbus driver */
@@ -271,7 +271,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_vmbus_unregister)void rte_vmbus_unregister (struct rte_vmbus_driver *driver) { -TAILQ_REMOVE (&rte_vmbus_bus.driver_list, driver, next); +rte_bus_remove_driver (&rte_vmbus_bus.bus, &driver->driver); }/* Add a device to VMBUS bus */
@@ -326,7 +326,6 @@ struct rte_vmbus_bus rte_vmbus_bus = { .dev_compare = vmbus_dev_compare, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.device_list), - .driver_list = TAILQ_HEAD_INITIALIZER(rte_vmbus_bus.driver_list), };RTE_REGISTER_BUS (vmbus, rte_vmbus_bus.bus);
drivers/dma/idxd/idxd_bus.c +5 -1
@@ -70,7 +70,7 @@ struct dsa_bus dsa_bus = { .parse = dsa_addr_parse, }, .driver = { - .name = "dmadev_idxd" + .name = "dmadev_idxd", }, .device_list = TAILQ_HEAD_INITIALIZER(dsa_bus.device_list), };
@@ -392,3 +392,7 @@ dsa_addr_parse(const char *name, void *addr) }RTE_REGISTER_BUS (dsa, dsa_bus.bus); +RTE_INIT (dsa_bus_init) +{ +rte_bus_add_driver (&dsa_bus.bus, &dsa_bus.driver); +}
lib/eal/common/eal_common_bus.c +17 -0
@@ -38,6 +38,7 @@ rte_bus_register(struct rte_bus *bus)/* Buses supporting driver plug also require unplug. */ RTE_VERIFY (!bus->plug || bus->unplug); +TAILQ_INIT (&bus->driver_list);TAILQ_INSERT_TAIL (&rte_bus_list, bus, next);EAL_LOG (DEBUG ,"Registered [%s] bus." ,rte_bus_name (bus)); }
@@ -369,3 +370,19 @@ rte_bus_sigbus_handler(const void *failure_addr)return ret; } + +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_add_driver) +void +rte_bus_add_driver (struct rte_bus *bus,struct rte_driver *driver) +{ +TAILQ_INSERT_TAIL (&bus->driver_list, driver, next); + driver->bus = bus; +} + +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_remove_driver) +void +rte_bus_remove_driver (struct rte_bus *bus,struct rte_driver *driver) +{ +TAILQ_REMOVE (&bus->driver_list, driver, next); + driver->bus =NULL ; +}
lib/eal/include/bus_driver.h +44 -0
56 lines not on this page · raw message
lib/eal/include/dev_driver.h +1 -0
@@ -15,6 +15,7 @@ struct rte_driver {RTE_TAILQ_ENTRY (rte_driver) next;/**< Next in list. */ const char *name;/**< Driver name. */ const char *alias;/**< Driver alias. */ +const struct rte_bus *bus;/**< Bus reference. */ };/**
Signature · 1 line
2.53.0
PATCH v5 10/25 bus: factorize device list
In reply to David MarchandMove device list from bus-specific structures to the common rte_bus structure and remove unnecessary wrapper functions. This eliminates code duplication across bus drivers.
Remove device_list from bus-specific structures and their wrapper functions (e.g., rte_pci_add_device), using EAL helpers (rte_bus_add_device, rte_bus_remove_device, rte_bus_insert_device) directly instead. Remove custom iteration macros (FOREACH_DEVICE_ON_*) and use standard TAILQ_FOREACH with rte_device* and RTE_BUS_DEVICE macro.
--- drivers/bus/auxiliary/auxiliary_common.c | 47 ++++------------ drivers/bus/auxiliary/bus_auxiliary_driver.h | 1 - drivers/bus/auxiliary/linux/auxiliary.c | 7 +-- drivers/bus/auxiliary/private.h | 20 ------- drivers/bus/cdx/bus_cdx_driver.h | 1 - drivers/bus/cdx/cdx.c | 44 ++++----------- drivers/bus/cdx/private.h | 1 - drivers/bus/dpaa/bus_dpaa_driver.h | 1 - drivers/bus/dpaa/dpaa_bus.c | 51 +++++++---------- drivers/bus/fslmc/bus_fslmc_driver.h | 1 - drivers/bus/fslmc/fslmc_bus.c | 52 ++++++++--------- drivers/bus/fslmc/fslmc_vfio.c | 45 +++++++-------- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 4 +- drivers/bus/fslmc/private.h | 2 - drivers/bus/ifpga/bus_ifpga_driver.h | 1 - drivers/bus/ifpga/ifpga_bus.c | 28 ++++------ drivers/bus/pci/bsd/pci.c | 12 ++-- drivers/bus/pci/bus_pci_driver.h | 1 - drivers/bus/pci/linux/pci.c | 12 ++-- drivers/bus/pci/pci_common.c | 55 +++++------------- drivers/bus/pci/private.h | 30 ---------- drivers/bus/pci/windows/pci.c | 12 ++-- drivers/bus/platform/bus_platform_driver.h | 1 - drivers/bus/platform/platform.c | 32 +++++------ drivers/bus/platform/private.h | 5 -- drivers/bus/uacce/bus_uacce_driver.h | 1 - drivers/bus/uacce/uacce.c | 34 +++++------ drivers/bus/vdev/bus_vdev_driver.h | 1 - drivers/bus/vdev/vdev.c | 45 +++++++-------- drivers/bus/vmbus/bus_vmbus_driver.h | 1 - drivers/bus/vmbus/linux/vmbus_bus.c | 7 +-- drivers/bus/vmbus/private.h | 10 ---- drivers/bus/vmbus/vmbus_common.c | 41 +++----------- drivers/dma/idxd/idxd_bus.c | 21 ++----- lib/eal/common/eal_common_bus.c | 27 +++++++++ lib/eal/include/bus_driver.h | 59 ++++++++++++++++++++ 36 files changed, 286 insertions(+), 427 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +11 -36
@@ -198,7 +198,7 @@ auxiliary_probe(void)size_t probed =0 , failed =0 ;int ret =0 ; -FOREACH_DEVICE_ON_AUXILIARY_BUS (dev) { + RTE_BUS_FOREACH_DEV(dev, &auxiliary_bus.bus) { probed++; ret =auxiliary_probe_all_drivers (dev);
@@ -251,45 +251,21 @@ rte_auxiliary_unregister(struct rte_auxiliary_driver *driver)rte_bus_remove_driver (&auxiliary_bus.bus, &driver->driver); } -/* Add a device to auxiliary bus */ -void -auxiliary_add_device (struct rte_auxiliary_device *aux_dev) -{ -TAILQ_INSERT_TAIL (&auxiliary_bus.device_list, aux_dev, next); -} - -/* Insert a device into a predefined position in auxiliary bus */ -void -auxiliary_insert_device (struct rte_auxiliary_device *exist_aux_dev, -struct rte_auxiliary_device *new_aux_dev) -{ -TAILQ_INSERT_BEFORE (exist_aux_dev, new_aux_dev, next); -} - -/* Remove a device from auxiliary bus */ -static void -rte_auxiliary_remove_device (struct rte_auxiliary_device *auxiliary_dev) -{ -TAILQ_REMOVE (&auxiliary_bus.device_list, auxiliary_dev, next); -} -static struct rte_device *auxiliary_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) { -const struct rte_auxiliary_device *pstart; -struct rte_auxiliary_device *adev; +struct rte_device *dev;if (start !=NULL ) { - pstart =RTE_BUS_DEVICE (start, *pstart); - adev =TAILQ_NEXT (pstart, next); + dev =TAILQ_NEXT (start, next); }else { - adev =TAILQ_FIRST (&auxiliary_bus.device_list); + dev =TAILQ_FIRST (&auxiliary_bus.bus.device_list); } -while (adev !=NULL ) { -if (cmp (&adev->device, data) ==0 ) -return &adev->device; - adev =TAILQ_NEXT (adev, next); +while (dev !=NULL ) { +if (cmp (dev, data) ==0 ) +return dev; + dev =TAILQ_NEXT (dev, next); }return NULL ; }
@@ -310,7 +286,7 @@ auxiliary_unplug(struct rte_device *dev) ret =rte_auxiliary_driver_remove_dev (adev);if (ret ==0 ) { -rte_auxiliary_remove_device (adev); +rte_bus_remove_device (&auxiliary_bus.bus, &adev->device);rte_devargs_remove (dev->devargs);rte_intr_instance_free (adev->intr_handle);free (adev);
@@ -321,10 +297,10 @@ auxiliary_unplug(struct rte_device *dev)static int auxiliary_cleanup (void ) { -struct rte_auxiliary_device *dev, *tmp_dev; +struct rte_auxiliary_device *dev;int error =0 ; - RTE_TAILQ_FOREACH_SAFE(dev, &auxiliary_bus.device_list, next, tmp_dev) { + RTE_BUS_FOREACH_DEV(dev, &auxiliary_bus.bus) {int ret;if (!rte_dev_is_probed (&dev->device))
@@ -391,7 +367,6 @@ struct rte_auxiliary_bus auxiliary_bus = { .get_iommu_class = auxiliary_get_iommu_class, .dev_iterate = auxiliary_dev_iterate, }, - .device_list = TAILQ_HEAD_INITIALIZER(auxiliary_bus.device_list), };RTE_REGISTER_BUS (auxiliary, auxiliary_bus.bus);
drivers/bus/auxiliary/bus_auxiliary_driver.h +0 -1
@@ -110,7 +110,6 @@ typedef int (rte_auxiliary_dma_unmap_t)(struct rte_auxiliary_device *dev,* A structure describing an auxiliary device. */ struct rte_auxiliary_device { -RTE_TAILQ_ENTRY (rte_auxiliary_device) next;/**< Next probed device. */ struct rte_device device;/**< Inherit core device */ char name[RTE_DEV_NAME_MAX_LEN +1 ];/**< ASCII device name */ struct rte_intr_handle *intr_handle;/**< Interrupt handle */
drivers/bus/auxiliary/linux/auxiliary.c +3 -4
@@ -35,7 +35,6 @@ auxiliary_scan_one(const char *dirname, const char *name)return -1 ; } dev->device.name = dev->name; - dev->device.bus = &auxiliary_bus.bus;/* Get NUMA node, default to 0 if not present */ snprintf(filename, sizeof(filename), "%s/%s/numa_node",
@@ -49,12 +48,12 @@ auxiliary_scan_one(const char *dirname, const char *name)auxiliary_on_scan (dev);/* Device is valid, add in list (sorted) */ - TAILQ_FOREACH(dev2, &auxiliary_bus.device_list, next) { + RTE_BUS_FOREACH_DEV(dev2, &auxiliary_bus.bus) { ret =strcmp (dev->name, dev2->name);if (ret >0 )continue ;if (ret <0 ) { -auxiliary_insert_device (dev2, dev); +rte_bus_insert_device (&auxiliary_bus.bus, &dev2->device, &dev->device); }else {/* already registered */ if (rte_dev_is_probed (&dev2->device) && dev2->device.devargs != dev->device.devargs) {
@@ -66,7 +65,7 @@ auxiliary_scan_one(const char *dirname, const char *name) }return 0 ; } -auxiliary_add_device (dev); +rte_bus_add_device (&auxiliary_bus.bus, &dev->device);return 0 ; }
drivers/bus/auxiliary/private.h +0 -20
@@ -24,15 +24,10 @@ extern int auxiliary_bus_logtype;*/ struct rte_auxiliary_bus {struct rte_bus bus;/* Inherit the generic class */ - TAILQ_HEAD(, rte_auxiliary_device) device_list; /* List of devices */ };extern struct rte_auxiliary_bus auxiliary_bus; -/* Auxiliary bus iterators */ -#define FOREACH_DEVICE_ON_AUXILIARY_BUS (p) \ - TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next) -/* * Test whether the auxiliary device exist. */
@@ -49,21 +44,6 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Add an auxiliary device to the auxiliary bus (append to auxiliary device -* list). This function also updates the bus references of the auxiliary -* device and the generic device object embedded within. -*/ -void auxiliary_add_device (struct rte_auxiliary_device *aux_dev); - -/* -* Insert an auxiliary device in the auxiliary bus at a particular location -* in the device list. It also updates the auxiliary bus reference of the -* new devices to be inserted. -*/ -void auxiliary_insert_device (struct rte_auxiliary_device *exist_aux_dev, -struct rte_auxiliary_device *new_aux_dev); -/* * Match the auxiliary driver and device by driver function. */
drivers/bus/cdx/bus_cdx_driver.h +0 -1
@@ -53,7 +53,6 @@ struct rte_cdx_id {* A structure describing a CDX device. */ struct rte_cdx_device { -RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ struct rte_cdx_driver *driver;/**< CDX driver used in probing */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */
drivers/bus/cdx/cdx.c +11 -33
106 lines not on this page · raw message
drivers/bus/cdx/private.h +0 -1
@@ -12,7 +12,6 @@*/ struct rte_cdx_bus {struct rte_bus bus;/**< Inherit the generic class */ - RTE_TAILQ_HEAD(, rte_cdx_device) device_list; /**< List of CDX devices */ };/**
drivers/bus/dpaa/bus_dpaa_driver.h +0 -1
@@ -79,7 +79,6 @@ struct dpaa_device_id { };struct rte_dpaa_device { -TAILQ_ENTRY (rte_dpaa_device) next;struct rte_device device;union {struct rte_eth_dev *eth_dev;
drivers/bus/dpaa/dpaa_bus.c +21 -30
151 lines not on this page · raw message
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
@@ -93,7 +93,6 @@ enum rte_dpaa2_dev_type {* A structure describing a DPAA2 device. */ struct rte_dpaa2_device { -TAILQ_ENTRY (rte_dpaa2_device) next;/**< Next probed DPAA2 device. */ struct rte_device device;/**< Inherit core device */ enum rte_dpaa2_dev_type dev_type;/**< Device Type */ uint16_t object_id;/**< DPAA2 Object ID */
drivers/bus/fslmc/fslmc_bus.c +22 -30
156 lines not on this page · raw message
drivers/bus/fslmc/fslmc_vfio.c +21 -24
138 lines not on this page · raw message
drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +2 -2
@@ -28,7 +28,7 @@ rte_dpaa2_create_dprc_device(int vdev_fd __rte_unused, {struct dpaa2_dprc_dev *dprc_node;struct dprc_endpoint endpoint1, endpoint2; -struct rte_dpaa2_device *dev, *dev_tmp; +struct rte_dpaa2_device *dev;int ret, dprc_id = obj->object_id;/* Allocate DPAA2 dprc handle */
@@ -49,7 +49,7 @@ rte_dpaa2_create_dprc_device(int vdev_fd __rte_unused,return ret; } - RTE_TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_tmp) { + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) {/** DPRC is always created before it's children are created.*/ dev->container = dprc_node;if (dev->dev_type ==DPAA2_ETH ) {
drivers/bus/fslmc/private.h +0 -2
@@ -14,8 +14,6 @@*/ struct rte_fslmc_bus {struct rte_bus bus;/**< Generic Bus object */ - TAILQ_HEAD(, rte_dpaa2_device) device_list; -/**< FSLMC DPAA2 Device list */ int device_count[DPAA2_DEVTYPE_MAX ];/**< Count of all devices scanned */ };
drivers/bus/ifpga/bus_ifpga_driver.h +0 -1
@@ -67,7 +67,6 @@ struct rte_afu_shared {* A structure describing a AFU device. */ struct rte_afu_device { -RTE_TAILQ_ENTRY (rte_afu_device) next;/**< Next in device list. */ struct rte_device device;/**< Inherit core device */ struct rte_rawdev *rawdev;/**< Point Rawdev */ struct rte_afu_id id;/**< AFU id within FPGA. */
drivers/bus/ifpga/ifpga_bus.c +12 -16
@@ -38,9 +38,6 @@*/ static struct rte_bus rte_ifpga_bus; -static TAILQ_HEAD(, rte_afu_device) ifpga_afu_dev_list = -TAILQ_HEAD_INITIALIZER (ifpga_afu_dev_list); -/* register a ifpga bus based driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_ifpga_driver_register) void rte_ifpga_driver_register(struct rte_afu_driver *driver)
@@ -63,7 +60,7 @@ ifpga_find_afu_dev(const struct rte_rawdev *rdev, {struct rte_afu_device *afu_dev =NULL ; - TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { + RTE_BUS_FOREACH_DEV(afu_dev, &rte_ifpga_bus) {if (afu_dev->rawdev == rdev && !ifpga_afu_id_cmp (&afu_dev->id, afu_id))return afu_dev;
@@ -139,7 +136,6 @@ ifpga_scan_one(struct rte_rawdev *rawdev,if (!afu_dev) goto end; - afu_dev->device.bus = &rte_ifpga_bus; afu_dev->device.devargs = devargs; afu_dev->device.numa_node =SOCKET_ID_ANY ; afu_dev->device.name = devargs->name;
@@ -236,7 +232,7 @@ ifpga_scan(void) afu_dev =ifpga_scan_one (rawdev, devargs);if (afu_dev !=NULL ) -TAILQ_INSERT_TAIL (&ifpga_afu_dev_list, afu_dev, next); +rte_bus_add_device (&rte_ifpga_bus, &afu_dev->device); } end:
@@ -333,7 +329,7 @@ ifpga_probe(void)struct rte_afu_device *afu_dev =NULL ;int ret =0 ; - TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { + RTE_BUS_FOREACH_DEV(afu_dev, &rte_ifpga_bus) { ret =ifpga_probe_all_drivers (afu_dev);if (ret == -EEXIST )continue ;
@@ -352,10 +348,10 @@ ifpga_probe(void)static int ifpga_cleanup (void ) { -struct rte_afu_device *afu_dev, *tmp_dev; +struct rte_afu_device *afu_dev;int error =0 ; - RTE_TAILQ_FOREACH_SAFE(afu_dev, &ifpga_afu_dev_list, next, tmp_dev) { + RTE_BUS_FOREACH_DEV(afu_dev, &rte_ifpga_bus) {struct rte_afu_driver *drv = afu_dev->driver;int ret =0 ;
@@ -373,7 +369,7 @@ ifpga_cleanup(void) afu_dev->device.driver =NULL ; free: -TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); +rte_bus_remove_device (&rte_ifpga_bus, &afu_dev->device);rte_devargs_remove (afu_dev->device.devargs);rte_intr_instance_free (afu_dev->intr_handle);free (afu_dev);
@@ -398,7 +394,7 @@ ifpga_unplug(struct rte_device *dev)if (ret)return ret; -TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); +rte_bus_remove_device (&rte_ifpga_bus, &afu_dev->device);rte_devargs_remove (dev->devargs);rte_intr_instance_free (afu_dev->intr_handle);
@@ -411,15 +407,15 @@ static struct rte_device * ifpga_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data) { - struct rte_afu_device *afu_dev; + struct rte_device *dev; - TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (start && &afu_dev->device == start) { + TAILQ_FOREACH(dev, &rte_ifpga_bus.device_list, next) { +if (start && dev == start) { start =NULL ;continue ; } -if (cmp (&afu_dev->device, data) ==0 ) -return &afu_dev->device; +if (cmp (dev, data) ==0 ) +return dev; }return NULL ;
drivers/bus/pci/bsd/pci.c +6 -6
@@ -233,7 +233,6 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)memset (pdev,0 ,sizeof (*pdev)); dev = &pdev->device; - dev->device.bus = &rte_pci_bus.bus; dev->addr.domain = conf->pc_sel.pc_domain; dev->addr.bus = conf->pc_sel.pc_bus;
@@ -298,19 +297,20 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) }/* device is valid, add in list (sorted) */ -if (TAILQ_EMPTY (&rte_pci_bus.device_list)) { -rte_pci_add_device (dev); +if (TAILQ_EMPTY (&rte_pci_bus.bus.device_list)) { +rte_bus_add_device (&rte_pci_bus.bus, &dev->device); }else {struct rte_pci_device *dev2 =NULL ;int ret; - TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { + RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus.bus) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);if (ret >0 )continue ;else if (ret <0 ) { -rte_pci_insert_device (dev2, dev); +rte_bus_insert_device (&rte_pci_bus.bus, &dev2->device, + &dev->device); }else {/* already registered */ dev2->kdrv = dev->kdrv; dev2->max_vfs = dev->max_vfs;
@@ -322,7 +322,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) }return 0 ; } -rte_pci_add_device (dev); +rte_bus_add_device (&rte_pci_bus.bus, &dev->device); }return 0 ;
drivers/bus/pci/bus_pci_driver.h +0 -1
@@ -33,7 +33,6 @@ enum rte_pci_kernel_driver {* A structure describing a PCI device. */ struct rte_pci_device { -RTE_TAILQ_ENTRY (rte_pci_device) next;/**< Next probed PCI device. */ struct rte_device device;/**< Inherit core device */ struct rte_pci_addr addr;/**< PCI location. */ struct rte_pci_id id;/**< PCI ID. */
drivers/bus/pci/linux/pci.c +6 -6
@@ -218,7 +218,6 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)memset (pdev,0 ,sizeof (*pdev)); dev = &pdev->device; - dev->device.bus = &rte_pci_bus.bus; dev->addr = *addr;/* get vendor id */
@@ -322,18 +321,19 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return 0 ; }/* device is valid, add in list (sorted) */ -if (TAILQ_EMPTY (&rte_pci_bus.device_list)) { -rte_pci_add_device (dev); +if (TAILQ_EMPTY (&rte_pci_bus.bus.device_list)) { +rte_bus_add_device (&rte_pci_bus.bus, &dev->device); }else {struct rte_pci_device *dev2; - TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { + RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus.bus) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);if (ret >0 )continue ;if (ret <0 ) { -rte_pci_insert_device (dev2, dev); +rte_bus_insert_device (&rte_pci_bus.bus, &dev2->device, + &dev->device); }else {/* already registered */ if (!rte_dev_is_probed (&dev2->device)) { dev2->kdrv = dev->kdrv;
@@ -377,7 +377,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return 0 ; } -rte_pci_add_device (dev); +rte_bus_add_device (&rte_pci_bus.bus, &dev->device); }return 0 ;
drivers/bus/pci/pci_common.c +15 -40
119 lines not on this page · raw message
drivers/bus/pci/private.h +0 -30
@@ -34,15 +34,10 @@ extern int pci_bus_logtype;*/ struct rte_pci_bus {struct rte_bus bus;/**< Inherit the generic class */ - RTE_TAILQ_HEAD(, rte_pci_device) device_list; /**< List of PCI devices */ };extern struct rte_pci_bus rte_pci_bus; -/* PCI Bus iterators */ -#define FOREACH_DEVICE_ON_PCIBUS (p) \ - RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next) -struct rte_pci_driver ;struct rte_pci_device ;
@@ -78,31 +73,6 @@ pci_common_set(struct rte_pci_device *dev);void pci_free (struct rte_pci_device_internal *pdev); -/** -* 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 -* object embedded within. -* -* @param pci_dev -* PCI device to add -* @return void -*/ -void rte_pci_add_device (struct rte_pci_device *pci_dev); - -/** -* Insert a PCI device in the PCI Bus at a particular location in the device -* list. It also updates the PCI Bus reference of the new devices to be -* inserted. -* -* @param exist_pci_dev -* Existing PCI device in PCI Bus -* @param new_pci_dev -* PCI device to be added before exist_pci_dev -* @return void -*/ -void rte_pci_insert_device (struct rte_pci_device *exist_pci_dev, -struct rte_pci_device *new_pci_dev); -/** * A structure describing a PCI mapping. */
drivers/bus/pci/windows/pci.c +6 -6
@@ -415,7 +415,6 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)memset (pdev,0 ,sizeof (*pdev)); dev = &pdev->device; - dev->device.bus = &rte_pci_bus.bus; dev->addr = addr; dev->id = pci_id; dev->max_vfs =0 ;/* TODO: get max_vfs */
@@ -431,17 +430,18 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data) }/* device is valid, add in list (sorted) */ -if (TAILQ_EMPTY (&rte_pci_bus.device_list)) { -rte_pci_add_device (dev); +if (TAILQ_EMPTY (&rte_pci_bus.bus.device_list)) { +rte_bus_add_device (&rte_pci_bus.bus, &dev->device); }else {struct rte_pci_device *dev2 =NULL ; - TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { + RTE_BUS_FOREACH_DEV(dev2, &rte_pci_bus.bus) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);if (ret >0 ) {continue ; }else if (ret <0 ) { -rte_pci_insert_device (dev2, dev); +rte_bus_insert_device (&rte_pci_bus.bus, &dev2->device, + &dev->device); }else {/* already registered */ dev2->kdrv = dev->kdrv; dev2->max_vfs = dev->max_vfs;
@@ -451,7 +451,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data) }return 0 ; } -rte_pci_add_device (dev); +rte_bus_add_device (&rte_pci_bus.bus, &dev->device); }return 0 ;
drivers/bus/platform/bus_platform_driver.h +0 -1
@@ -94,7 +94,6 @@ struct rte_platform_resource {* A structure describing a platform device. */ struct rte_platform_device { -RTE_TAILQ_ENTRY (rte_platform_device) next;/**< Next attached platform device */ struct rte_device device;/**< Core device */ struct rte_platform_driver *driver;/**< Matching device driver */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */
drivers/bus/platform/platform.c +14 -18
@@ -57,11 +57,10 @@ dev_add(const char *dev_name)rte_strscpy (pdev->name, dev_name,sizeof (pdev->name)); pdev->device.name = pdev->name; pdev->device.devargs =rte_bus_find_devargs (&platform_bus.bus, dev_name); - pdev->device.bus = &platform_bus.bus;snprintf (path,sizeof (path),PLATFORM_BUS_DEVICES_PATH "/%s/numa_node" , dev_name); pdev->device.numa_node =eal_parse_sysfs_value (path, &val) ?rte_socket_id () : val; -FOREACH_DEVICE_ON_PLATFORM_BUS (tmp) { + RTE_BUS_FOREACH_DEV(tmp, &platform_bus.bus) {if (!strcmp (tmp->name, pdev->name)) {PLATFORM_LOG_LINE (INFO ,"device %s already added" , pdev->name);
@@ -73,7 +72,7 @@ dev_add(const char *dev_name) } } -TAILQ_INSERT_HEAD (&platform_bus.device_list, pdev, next); +rte_bus_add_device (&platform_bus.bus, &pdev->device);PLATFORM_LOG_LINE (INFO ,"adding device %s to the list" , dev_name);
@@ -425,7 +424,7 @@ platform_bus_probe(void)struct rte_platform_device *pdev;int ret; -FOREACH_DEVICE_ON_PLATFORM_BUS (pdev) { + RTE_BUS_FOREACH_DEV(pdev, &platform_bus.bus) { ret =device_attach (pdev);if (ret == -EBUSY ) {PLATFORM_LOG_LINE (DEBUG ,"device %s already probed" , pdev->name);
@@ -441,20 +440,18 @@ platform_bus_probe(void)static struct rte_device *platform_bus_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) { -const struct rte_platform_device *pstart; -struct rte_platform_device *pdev; +struct rte_device *dev;if (start !=NULL ) { - pstart =RTE_BUS_DEVICE (start, *pstart); - pdev =TAILQ_NEXT (pstart, next); + dev =TAILQ_NEXT (start, next); }else { - pdev =RTE_TAILQ_FIRST (&platform_bus.device_list); + dev =RTE_TAILQ_FIRST (&platform_bus.bus.device_list); } -while (pdev) { -if (cmp (&pdev->device, data) ==0 ) -return &pdev->device; +while (dev) { +if (cmp (dev, data) ==0 ) +return dev; - pdev =RTE_TAILQ_NEXT (pdev, next); + dev =RTE_TAILQ_NEXT (dev, next); }return NULL ;
@@ -550,7 +547,7 @@ platform_bus_get_iommu_class(void)struct rte_platform_driver *pdrv;struct rte_platform_device *pdev; -FOREACH_DEVICE_ON_PLATFORM_BUS (pdev) { + RTE_BUS_FOREACH_DEV(pdev, &platform_bus.bus) { pdrv = pdev->driver;if (pdrv !=NULL && pdrv->drv_flags &RTE_PLATFORM_DRV_NEED_IOVA_AS_VA )return RTE_IOVA_VA ;
@@ -562,10 +559,10 @@ platform_bus_get_iommu_class(void)static int platform_bus_cleanup (void ) { -struct rte_platform_device *pdev, *tmp; +struct rte_platform_device *pdev; - RTE_TAILQ_FOREACH_SAFE(pdev, &platform_bus.device_list, next, tmp) { -TAILQ_REMOVE (&platform_bus.device_list, pdev, next); + RTE_BUS_FOREACH_DEV(pdev, &platform_bus.bus) { +rte_bus_remove_device (&platform_bus.bus, &pdev->device);if (!rte_dev_is_probed (&pdev->device))continue ;platform_bus_unplug (&pdev->device);
@@ -588,7 +585,6 @@ struct rte_platform_bus platform_bus = { .dev_iterate = platform_bus_dev_iterate, .cleanup = platform_bus_cleanup, }, - .device_list = TAILQ_HEAD_INITIALIZER(platform_bus.device_list), };RTE_REGISTER_BUS (platform, platform_bus.bus);
drivers/bus/platform/private.h +0 -5
@@ -16,16 +16,11 @@extern struct rte_platform_bus platform_bus; -/* Platform bus iterators. */ -#define FOREACH_DEVICE_ON_PLATFORM_BUS (p) \ - RTE_TAILQ_FOREACH(p, &(platform_bus.device_list), next) -/* * Structure describing platform bus. */ struct rte_platform_bus {struct rte_bus bus;/* Core bus */ - RTE_TAILQ_HEAD(, rte_platform_device) device_list; /* List of bus devices */ };extern int platform_bus_logtype;
drivers/bus/uacce/bus_uacce_driver.h +0 -1
@@ -43,7 +43,6 @@ struct rte_uacce_driver;* A structure describing a UACCE device. */ struct rte_uacce_device { -RTE_TAILQ_ENTRY (rte_uacce_device) next;/**< Next in device list. */ struct rte_device device;/**< Inherit core device. */ struct rte_uacce_driver *driver;/**< Driver used in probing. */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name. */
drivers/bus/uacce/uacce.c +13 -21
@@ -39,7 +39,6 @@*/ struct rte_uacce_bus {struct rte_bus bus;/* Inherit the generic class. */ - TAILQ_HEAD(, rte_uacce_device) device_list; /* List of devices. */ };/* Forward declaration of UACCE bus. */
@@ -54,9 +53,6 @@ static const char *const uacce_params_keys[] = { NULL, }; -#define FOREACH_DEVICE_ON_UACCEBUS (p) \ - RTE_TAILQ_FOREACH(p, &uacce_bus.device_list, next) -extern int uacce_bus_logtype;#define RTE_LOGTYPE_UACCE_BUS uacce_bus_logtype#define UACCE_BUS_LOG (level, ...) \
@@ -240,7 +236,6 @@ uacce_scan_one(const char *dev_name)if (!dev)return -ENOMEM ; - dev->device.bus = &uacce_bus.bus; dev->device.name = dev->name; dev->device.devargs =rte_bus_find_devargs (&uacce_bus.bus, dev_name);snprintf (dev->name,sizeof (dev->name),"%s" , dev_name);
@@ -266,7 +261,7 @@ uacce_scan_one(const char *dev_name)if (ret !=0 ) goto err; -TAILQ_INSERT_TAIL (&uacce_bus.device_list, dev, next); +rte_bus_add_device (&uacce_bus.bus, &dev->device);return 0 ; err:
@@ -422,7 +417,7 @@ uacce_probe(void)struct rte_uacce_device *dev;int ret; -FOREACH_DEVICE_ON_UACCEBUS (dev) { + RTE_BUS_FOREACH_DEV(dev, &uacce_bus.bus) { probed++; ret =uacce_probe_all_drivers (dev);
@@ -440,10 +435,10 @@ uacce_probe(void)static int uacce_cleanup (void ) { -struct rte_uacce_device *dev, *tmp_dev; +struct rte_uacce_device *dev;int error =0 ; - RTE_TAILQ_FOREACH_SAFE(dev, &uacce_bus.device_list, next, tmp_dev) { + RTE_BUS_FOREACH_DEV(dev, &uacce_bus.bus) {struct rte_uacce_driver *dr = dev->driver;int ret =0 ;
@@ -461,7 +456,7 @@ uacce_cleanup(void) dev->device.driver =NULL ; free: -TAILQ_REMOVE (&uacce_bus.device_list, dev, next); +rte_bus_remove_device (&uacce_bus.bus, &dev->device);free (dev); }
@@ -502,7 +497,7 @@ uacce_unplug(struct rte_device *dev) ret =uacce_detach_dev (uacce_dev);if (ret ==0 ) { -TAILQ_REMOVE (&uacce_bus.device_list, uacce_dev, next); +rte_bus_remove_device (&uacce_bus.bus, &uacce_dev->device);rte_devargs_remove (dev->devargs);free (uacce_dev); }
@@ -513,20 +508,18 @@ uacce_unplug(struct rte_device *dev)static struct rte_device *uacce_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) { -const struct rte_uacce_device *uacce_start; -struct rte_uacce_device *uacce_dev; +struct rte_device *dev;if (start !=NULL ) { - uacce_start =RTE_BUS_DEVICE (start, *uacce_start); - uacce_dev =TAILQ_NEXT (uacce_start, next); + dev =TAILQ_NEXT (start, next); }else { - uacce_dev =TAILQ_FIRST (&uacce_bus.device_list); + dev =TAILQ_FIRST (&uacce_bus.bus.device_list); } -while (uacce_dev !=NULL ) { -if (cmp (&uacce_dev->device, data) ==0 ) -return &uacce_dev->device; - uacce_dev =TAILQ_NEXT (uacce_dev, next); +while (dev !=NULL ) { +if (cmp (dev, data) ==0 ) +return dev; + dev =TAILQ_NEXT (dev, next); }return NULL ;
@@ -704,7 +697,6 @@ static struct rte_uacce_bus uacce_bus = { .parse = uacce_parse, .dev_iterate = uacce_dev_iterate, }, - .device_list = TAILQ_HEAD_INITIALIZER(uacce_bus.device_list), };RTE_REGISTER_BUS (uacce, uacce_bus.bus);
drivers/bus/vdev/bus_vdev_driver.h +0 -1
@@ -16,7 +16,6 @@ extern "C" {#endif struct rte_vdev_device { -RTE_TAILQ_ENTRY (rte_vdev_device) next;/**< Next attached vdev */ struct rte_device device;/**< Inherit core device */ };
drivers/bus/vdev/vdev.c +19 -26
137 lines not on this page · raw message
drivers/bus/vmbus/bus_vmbus_driver.h +0 -1
@@ -37,7 +37,6 @@ enum hv_uio_map {* A structure describing a VMBUS device. */ struct rte_vmbus_device { -RTE_TAILQ_ENTRY (rte_vmbus_device) next;/**< Next probed VMBUS device */ const struct rte_vmbus_driver *driver;/**< Associated driver */ struct rte_device device;/**< Inherit core device */ rte_uuid_t device_id;/**< VMBUS device id */
drivers/bus/vmbus/linux/vmbus_bus.c +3 -4
@@ -288,7 +288,6 @@ vmbus_scan_one(const char *name)if (dev ==NULL )return -1 ; - dev->device.bus = &rte_vmbus_bus.bus; dev->device.name = dev_name =strdup (name);if (!dev->device.name) goto error;
@@ -357,7 +356,7 @@ vmbus_scan_one(const char *name)/* device is valid, add in list (sorted) */ VMBUS_LOG (DEBUG ,"Adding vmbus device %s" , name); - TAILQ_FOREACH(dev2, &rte_vmbus_bus.device_list, next) { + RTE_BUS_FOREACH_DEV(dev2, &rte_vmbus_bus.bus) {int ret; ret =rte_uuid_compare (dev->device_id, dev2->device_id);
@@ -365,7 +364,7 @@ vmbus_scan_one(const char *name)continue ;if (ret <0 ) { -vmbus_insert_device (dev2, dev); +rte_bus_insert_device (&rte_vmbus_bus.bus, &dev2->device, &dev->device); }else {/* already registered */ VMBUS_LOG (NOTICE ,"%s already registered" , name);
@@ -375,7 +374,7 @@ vmbus_scan_one(const char *name)return 0 ; } -vmbus_add_device (dev); +rte_bus_add_device (&rte_vmbus_bus.bus, &dev->device);return 0 ; error:VMBUS_LOG (DEBUG ,"failed" );
drivers/bus/vmbus/private.h +0 -10
@@ -20,15 +20,10 @@*/ struct rte_vmbus_bus {struct rte_bus bus;/**< Inherit the generic class */ - RTE_TAILQ_HEAD(, rte_vmbus_device) device_list; /**< List of devices */ };extern struct rte_vmbus_bus rte_vmbus_bus; -/* VMBus iterators */ -#define FOREACH_DEVICE_ON_VMBUS (p) \ - RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next) -extern int vmbus_logtype_bus;#define RTE_LOGTYPE_VMBUS_BUS vmbus_logtype_bus#define VMBUS_LOG (level, ...) \
@@ -98,11 +93,6 @@ int vmbus_chan_create(const struct rte_vmbus_device *device, uint16_t relid, uint16_t subid, uint8_t monitor_id, struct vmbus_channel **new_chan); -void vmbus_add_device (struct rte_vmbus_device *vmbus_dev); -void vmbus_insert_device (struct rte_vmbus_device *exist_vmbus_dev, -struct rte_vmbus_device *new_vmbus_dev); -void vmbus_remove_device (struct rte_vmbus_device *vmbus_device); -void vmbus_uio_irq_control (const struct rte_vmbus_device *dev,int32_t onoff);int vmbus_uio_irq_read (struct rte_vmbus_device *dev);
drivers/bus/vmbus/vmbus_common.c +9 -32
82 lines not on this page · raw message
drivers/dma/idxd/idxd_bus.c +6 -15
@@ -49,16 +49,12 @@ static struct rte_device *dsa_find_device(const struct rte_device *start,static enum rte_iova_mode dsa_get_iommu_class (void );static int dsa_addr_parse (const char *name,void *addr); -/** List of devices */ -TAILQ_HEAD (dsa_device_list, rte_dsa_device); -/** * Structure describing the DSA bus */ struct dsa_bus {struct rte_bus bus;/**< Inherit the generic class */ struct rte_driver driver;/**< Driver struct for devices to point to */ -struct dsa_device_list device_list;/**< List of PCI devices */ };struct dsa_bus dsa_bus = {
@@ -72,7 +68,6 @@ struct dsa_bus dsa_bus = { .driver = { .name = "dmadev_idxd", }, - .device_list = TAILQ_HEAD_INITIALIZER(dsa_bus.device_list), }; static inline const char *
@@ -274,7 +269,7 @@ dsa_probe(void) {struct rte_dsa_device *dev; - TAILQ_FOREACH(dev, &dsa_bus.device_list, next) { + RTE_BUS_FOREACH_DEV(dev, &dsa_bus.bus) {char type[64 ], name[64 ]; if (read_wq_string(dev, "type", type, sizeof(type)) < 0 ||
@@ -332,9 +327,8 @@ dsa_scan(void)free (dev);continue ; } - dev->device.bus = &dsa_bus.bus;strlcpy (dev->wq_name, wq->d_name,sizeof (dev->wq_name)); -TAILQ_INSERT_TAIL (&dsa_bus.device_list, dev, next); +rte_bus_add_device (&dsa_bus.bus, &dev->device); devcount++;read_device_int (dev,"numa_node" , &numa_node);
@@ -350,16 +344,13 @@ static struct rte_device * dsa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data) { - struct rte_dsa_device *dev = TAILQ_FIRST(&dsa_bus.device_list); - -/* the rte_device struct must be at start of dsa structure */ -RTE_BUILD_BUG_ON (offsetof(struct rte_dsa_device , device) !=0 ); + struct rte_device *dev = TAILQ_FIRST(&dsa_bus.bus.device_list);if (start !=NULL )/* jump to start point if given */ - dev =TAILQ_NEXT ((const struct rte_dsa_device *)start, next); + dev =TAILQ_NEXT (start, next);while (dev !=NULL ) { -if (cmp (&dev->device, data) ==0 ) -return &dev->device; +if (cmp (dev, data) ==0 ) +return dev; dev =TAILQ_NEXT (dev, next); }return NULL ;
lib/eal/common/eal_common_bus.c +27 -0
@@ -38,6 +38,7 @@ rte_bus_register(struct rte_bus *bus)/* Buses supporting driver plug also require unplug. */ RTE_VERIFY (!bus->plug || bus->unplug); +TAILQ_INIT (&bus->device_list);TAILQ_INIT (&bus->driver_list);TAILQ_INSERT_TAIL (&rte_bus_list, bus, next);EAL_LOG (DEBUG ,"Registered [%s] bus." ,rte_bus_name (bus));
@@ -371,6 +372,32 @@ rte_bus_sigbus_handler(const void *failure_addr)return ret; } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_add_device) +void +rte_bus_add_device (struct rte_bus *bus,struct rte_device *dev) +{ +TAILQ_INSERT_TAIL (&bus->device_list, dev, next); + dev->bus = bus; +} + +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_remove_device) +void +rte_bus_remove_device (struct rte_bus *bus,struct rte_device *dev) +{ +TAILQ_REMOVE (&bus->device_list, dev, next); + dev->bus =NULL ; +} + +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_insert_device) +void +rte_bus_insert_device (struct rte_bus *bus, +struct rte_device *exist_dev, +struct rte_device *new_dev) +{ +TAILQ_INSERT_BEFORE (exist_dev, new_dev, next); + new_dev->bus = bus; +} +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_add_driver) voidrte_bus_add_driver (struct rte_bus *bus,struct rte_driver *driver)
lib/eal/include/bus_driver.h +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v5 11/25 bus: consolidate device lookup
In reply to David MarchandA majority of bus drivers are repeating the pattern of looping on the bus device_list and simply passing the device to the cmp callback.
Extend rte_bus_find_device_t so it takes a reference to the bus object and add rte_bus_generic_find_device() to achieve the same.
---
Changes since v2:
- converted the vdev bus too (but keeping its internal locking), this avoids intermediate errors that were fixed later in the series,
--- app/test/test_vdev.c | 6 ++--- drivers/bus/auxiliary/auxiliary_common.c | 21 +--------------- drivers/bus/auxiliary/auxiliary_params.c | 4 +-- drivers/bus/cdx/cdx.c | 25 ++---------------- drivers/bus/dpaa/dpaa_bus.c | 30 +--------------------- drivers/bus/fslmc/fslmc_bus.c | 32 +----------------------- drivers/bus/ifpga/ifpga_bus.c | 19 +------------- drivers/bus/pci/pci_common.c | 21 +--------------- drivers/bus/pci/pci_params.c | 4 +-- drivers/bus/platform/platform.c | 22 +--------------- drivers/bus/platform/platform_params.c | 9 +------ drivers/bus/uacce/uacce.c | 26 ++----------------- drivers/bus/vdev/vdev.c | 25 ++++++++---------- drivers/bus/vmbus/vmbus_common.c | 21 +--------------- drivers/dma/idxd/idxd_bus.c | 20 +-------------- drivers/net/bonding/rte_eth_bond_args.c | 2 +- drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- lib/eal/common/eal_common_bus.c | 21 +++++++++++++++- lib/eal/common/eal_common_dev.c | 4 +-- lib/eal/common/hotplug_mp.c | 4 +-- lib/eal/include/bus_driver.h | 24 ++++++++++++++++-- lib/eal/linux/eal_dev.c | 3 +-- 23 files changed, 79 insertions(+), 268 deletions(-)
app/test/test_vdev.c +3 -3
@@ -60,7 +60,7 @@ get_matching_vdev(const char *match_str) } } - dev = vdev_bus->find_device (NULL , cmp_dev_match, kvargs); + dev = vdev_bus->find_device (vdev_bus,NULL , cmp_dev_match, kvargs);rte_kvargs_free (kvargs);return dev;
@@ -82,7 +82,7 @@ test_vdev_bus(void)printf ("Failed to create vdev net_null_test0\n" ); goto fail; } - dev0 = vdev_bus->find_device (NULL , cmp_dev_name,"net_null_test0" ); + dev0 = vdev_bus->find_device (vdev_bus,NULL , cmp_dev_name,"net_null_test0" );if (dev0 ==NULL ) {printf ("Cannot find net_null_test0 vdev\n" ); goto fail;
@@ -93,7 +93,7 @@ test_vdev_bus(void)printf ("Failed to create vdev net_null_test1\n" ); goto fail; } - dev1 = vdev_bus->find_device (NULL , cmp_dev_name,"net_null_test1" ); + dev1 = vdev_bus->find_device (vdev_bus,NULL , cmp_dev_name,"net_null_test1" );if (dev1 ==NULL ) {printf ("Cannot find net_null_test1 vdev\n" ); goto fail;
drivers/bus/auxiliary/auxiliary_common.c +1 -20
@@ -251,25 +251,6 @@ rte_auxiliary_unregister(struct rte_auxiliary_driver *driver)rte_bus_remove_driver (&auxiliary_bus.bus, &driver->driver); } -static struct rte_device * -auxiliary_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev; - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =TAILQ_FIRST (&auxiliary_bus.bus.device_list); - } -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) -return dev; - dev =TAILQ_NEXT (dev, next); - } -return NULL ; -} -static int auxiliary_plug (struct rte_device *dev) {
@@ -358,7 +339,7 @@ struct rte_auxiliary_bus auxiliary_bus = { .scan = auxiliary_scan, .probe = auxiliary_probe, .cleanup = auxiliary_cleanup, - .find_device = auxiliary_find_device, + .find_device = rte_bus_generic_find_device, .plug = auxiliary_plug, .unplug = auxiliary_unplug, .parse = auxiliary_parse,
drivers/bus/auxiliary/auxiliary_params.c +1 -3
@@ -45,7 +45,6 @@ auxiliary_dev_iterate(const void *start,const char *str, const struct rte_dev_iterator *it __rte_unused) { - rte_bus_find_device_t find_device; struct rte_kvargs *kvargs = NULL;struct rte_device *dev;
@@ -58,8 +57,7 @@ auxiliary_dev_iterate(const void *start,return NULL ; } } - find_device = auxiliary_bus.bus.find_device; - dev =find_device (start, auxiliary_dev_match, kvargs); + dev =rte_bus_generic_find_device (&auxiliary_bus.bus, start, auxiliary_dev_match, kvargs);rte_kvargs_free (kvargs);return dev; }
drivers/bus/cdx/cdx.c +2 -23
@@ -449,25 +449,6 @@ rte_cdx_unregister(struct rte_cdx_driver *driver)rte_bus_remove_driver (&rte_cdx_bus.bus, &driver->driver); } -static struct rte_device * -cdx_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev; - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =TAILQ_FIRST (&rte_cdx_bus.bus.device_list); - } -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) -return dev; - dev =TAILQ_NEXT (dev, next); - } -return NULL ; -} -/* * If vendor/device ID match, call the remove() function of the * driver.
@@ -572,7 +553,6 @@ cdx_dev_iterate(const void *start,const char *str, const struct rte_dev_iterator *it __rte_unused) { - rte_bus_find_device_t find_device; struct rte_kvargs *kvargs = NULL;struct rte_device *dev;
@@ -584,8 +564,7 @@ cdx_dev_iterate(const void *start,return NULL ; } } - find_device = rte_cdx_bus.bus.find_device; - dev =find_device (start, cdx_dev_match, kvargs); + dev =rte_bus_generic_find_device (&rte_cdx_bus.bus, start, cdx_dev_match, kvargs);rte_kvargs_free (kvargs);return dev; }
@@ -594,7 +573,7 @@ struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, - .find_device = cdx_find_device, + .find_device = rte_bus_generic_find_device, .plug = cdx_plug, .unplug = cdx_unplug, .parse = cdx_parse,
drivers/bus/dpaa/dpaa_bus.c +1 -29
@@ -818,34 +818,6 @@ rte_dpaa_bus_probe(void)return 0 ; } -static struct rte_device * -rte_dpaa_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev; - -/* find_device is called with 'data' as an opaque object - just call -* cmp with this and each device object on bus. -*/ - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =TAILQ_FIRST (&rte_dpaa_bus.bus.device_list); - } - -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) { -DPAA_BUS_DEBUG ("Found dev=(%s)" , dev->name); -return dev; - } - dev =TAILQ_NEXT (dev, next); - } - -DPAA_BUS_DEBUG ("Unable to find any device" ); -return NULL ; -} -/* * Get iommu class of DPAA2 devices on the bus. */
@@ -972,7 +944,7 @@ static struct rte_dpaa_bus rte_dpaa_bus = { .probe = rte_dpaa_bus_probe, .parse = rte_dpaa_bus_parse, .dev_compare = dpaa_bus_dev_compare, - .find_device = rte_dpaa_find_device, + .find_device = rte_bus_generic_find_device, .get_iommu_class = rte_dpaa_get_iommu_class, .plug = dpaa_bus_plug, .unplug = dpaa_bus_unplug,
drivers/bus/fslmc/fslmc_bus.c +1 -31
@@ -479,36 +479,6 @@ rte_fslmc_probe(void)return 0 ; } -static struct rte_device * -rte_fslmc_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev; - -DPAA2_BUS_DEBUG ("Finding a device named %s" , (const char *)data); - -/* find_device is always called with an opaque object which should be -* passed along to the 'cmp' function iterating over all device obj -* on the bus. -*/ - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =TAILQ_FIRST (&rte_fslmc_bus.bus.device_list); - } -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) { -DPAA2_BUS_DEBUG ("Found device (%s)" , - dev->name); -return dev; - } - dev =TAILQ_NEXT (dev, next); - } - -return NULL ; -} -/*register a fslmc bus based dpaa2 driver */ RTE_EXPORT_INTERNAL_SYMBOL (rte_fslmc_driver_register) void
@@ -674,7 +644,7 @@ struct rte_fslmc_bus rte_fslmc_bus = { .cleanup = rte_fslmc_close, .parse = rte_fslmc_parse, .dev_compare = fslmc_dev_compare, - .find_device = rte_fslmc_find_device, + .find_device = rte_bus_generic_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, .plug = fslmc_bus_plug, .unplug = fslmc_bus_unplug,
drivers/bus/ifpga/ifpga_bus.c +1 -18
@@ -403,23 +403,6 @@ ifpga_unplug(struct rte_device *dev) } -static struct rte_device * -ifpga_find_device (const struct rte_device *start, -rte_dev_cmp_t cmp,const void *data) -{ -struct rte_device *dev; - - TAILQ_FOREACH(dev, &rte_ifpga_bus.device_list, next) { -if (start && dev == start) { - start =NULL ; -continue ; - } -if (cmp (dev, data) ==0 ) -return dev; - } - -return NULL ; -}static int ifpga_parse (const char *name,void *addr) {
@@ -468,7 +451,7 @@ static struct rte_bus rte_ifpga_bus = { .scan = ifpga_scan, .probe = ifpga_probe, .cleanup = ifpga_cleanup, - .find_device = ifpga_find_device, + .find_device = rte_bus_generic_find_device, .plug = ifpga_plug, .unplug = ifpga_unplug, .parse = ifpga_parse,
drivers/bus/pci/pci_common.c +1 -20
@@ -512,25 +512,6 @@ rte_pci_unregister(struct rte_pci_driver *driver)rte_bus_remove_driver (&rte_pci_bus.bus, &driver->driver); } -static struct rte_device * -pci_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev; - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =TAILQ_FIRST (&rte_pci_bus.bus.device_list); - } -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) -return dev; - dev =TAILQ_NEXT (dev, next); - } -return NULL ; -} -/* * find the device which encounter the failure, by iterate over all device on * PCI bus to check if the memory failure address is located in the range
@@ -879,7 +860,7 @@ struct rte_pci_bus rte_pci_bus = { .scan = rte_pci_scan, .probe = pci_probe, .cleanup = pci_cleanup, - .find_device = pci_find_device, + .find_device = rte_bus_generic_find_device, .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse,
drivers/bus/pci/pci_params.c +1 -3
@@ -63,7 +63,6 @@ rte_pci_dev_iterate(const void *start,const char *str, const struct rte_dev_iterator *it __rte_unused) { - rte_bus_find_device_t find_device; struct rte_kvargs *kvargs = NULL;struct rte_device *dev;
@@ -75,8 +74,7 @@ rte_pci_dev_iterate(const void *start,return NULL ; } } - find_device = rte_pci_bus.bus.find_device; - dev =find_device (start, pci_dev_match, kvargs); + dev =rte_bus_generic_find_device (&rte_pci_bus.bus, start, pci_dev_match, kvargs);rte_kvargs_free (kvargs);return dev; }
drivers/bus/platform/platform.c +1 -21
@@ -437,26 +437,6 @@ platform_bus_probe(void)return 0 ; } -static struct rte_device * -platform_bus_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) -{ -struct rte_device *dev; - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =RTE_TAILQ_FIRST (&platform_bus.bus.device_list); - } -while (dev) { -if (cmp (dev, data) ==0 ) -return dev; - - dev =RTE_TAILQ_NEXT (dev, next); - } - -return NULL ; -} -static int platform_bus_plug (struct rte_device *dev) {
@@ -575,7 +555,7 @@ struct rte_platform_bus platform_bus = { .bus = { .scan = platform_bus_scan, .probe = platform_bus_probe, - .find_device = platform_bus_find_device, + .find_device = rte_bus_generic_find_device, .plug = platform_bus_plug, .unplug = platform_bus_unplug, .parse = platform_bus_parse,
drivers/bus/platform/platform_params.c +1 -8
@@ -46,7 +46,6 @@ void * platform_bus_dev_iterate(const void *start, const char *str, const struct rte_dev_iterator *it __rte_unused) { - rte_bus_find_device_t find_device; struct rte_kvargs *kvargs = NULL;struct rte_device *dev;
@@ -59,13 +58,7 @@ platform_bus_dev_iterate(const void *start, const char *str, } } - find_device = platform_bus.bus.find_device; -if (find_device ==NULL ) { -rte_kvargs_free (kvargs); -return NULL ; - } - - dev = platform_bus.bus.find_device (start, platform_dev_match, kvargs); + dev =rte_bus_generic_find_device (&platform_bus.bus, start, platform_dev_match, kvargs);rte_kvargs_free (kvargs);return dev;
drivers/bus/uacce/uacce.c +2 -24
@@ -505,26 +505,6 @@ uacce_unplug(struct rte_device *dev)return ret; } -static struct rte_device * -uacce_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) -{ -struct rte_device *dev; - -if (start !=NULL ) { - dev =TAILQ_NEXT (start, next); - }else { - dev =TAILQ_FIRST (&uacce_bus.bus.device_list); - } - -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) -return dev; - dev =TAILQ_NEXT (dev, next); - } - -return NULL ; -} -static int uacce_parse (const char *name,void *addr) {
@@ -562,7 +542,6 @@ static void * uacce_dev_iterate(const void *start, const char *str, const struct rte_dev_iterator *it __rte_unused) { - rte_bus_find_device_t find_device; struct rte_kvargs *kvargs = NULL;struct rte_device *dev;
@@ -573,8 +552,7 @@ uacce_dev_iterate(const void *start, const char *str,return NULL ; } } - find_device = uacce_bus.bus.find_device; - dev =find_device (start, uacce_dev_match, kvargs); + dev =rte_bus_generic_find_device (&uacce_bus.bus, start, uacce_dev_match, kvargs);rte_kvargs_free (kvargs);return dev; }
@@ -693,7 +671,7 @@ static struct rte_uacce_bus uacce_bus = { .cleanup = uacce_cleanup, .plug = uacce_plug, .unplug = uacce_unplug, - .find_device = uacce_find_device, + .find_device = rte_bus_generic_find_device, .parse = uacce_parse, .dev_iterate = uacce_dev_iterate, },
drivers/bus/vdev/vdev.c +11 -14
@@ -576,28 +576,25 @@ vdev_cleanup(void)return error; } -struct rte_device * -rte_vdev_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) +static struct rte_device * +vdev_find_device (const struct rte_bus *bus,const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) {struct rte_device *dev;rte_spinlock_recursive_lock (&vdev_device_list_lock); -if (start !=NULL ) - dev =TAILQ_NEXT (start, next); -else - dev =TAILQ_FIRST (&rte_vdev_bus.device_list); - -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) -break ; - dev =TAILQ_NEXT (dev, next); - } + dev =rte_bus_generic_find_device (bus, start, cmp, data);rte_spinlock_recursive_unlock (&vdev_device_list_lock);return dev; } +struct rte_device * +rte_vdev_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) +{ +return vdev_find_device (&rte_vdev_bus, start, cmp, data); +} +static int vdev_plug (struct rte_device *dev) {
@@ -633,7 +630,7 @@ static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, .cleanup = vdev_cleanup, - .find_device = rte_vdev_find_device, + .find_device = vdev_find_device, .plug = vdev_plug, .unplug = vdev_unplug, .parse = vdev_parse,
drivers/bus/vmbus/vmbus_common.c +1 -20
@@ -275,31 +275,12 @@ rte_vmbus_unregister(struct rte_vmbus_driver *driver) }/* VMBUS doesn't support hotplug */ -static struct rte_device * -vmbus_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev; - - TAILQ_FOREACH(dev, &rte_vmbus_bus.bus.device_list, next) { -if (start && dev == start) { - start =NULL ; -continue ; - } -if (cmp (dev, data) ==0 ) -return dev; - } - -return NULL ; -} - -struct rte_vmbus_bus rte_vmbus_bus = { .bus = { .scan = rte_vmbus_scan, .probe = rte_vmbus_probe, .cleanup = rte_vmbus_cleanup, - .find_device = vmbus_find_device, + .find_device = rte_bus_generic_find_device, .parse = vmbus_parse, .dev_compare = vmbus_dev_compare, },
drivers/dma/idxd/idxd_bus.c +1 -19
@@ -44,8 +44,6 @@ struct rte_dsa_device {struct dsa_bus ;static int dsa_scan (void );static int dsa_probe (void ); -static struct rte_device *dsa_find_device (const struct rte_device *start, -rte_dev_cmp_t cmp,const void *data);static enum rte_iova_mode dsa_get_iommu_class (void );static int dsa_addr_parse (const char *name,void *addr);
@@ -61,7 +59,7 @@ struct dsa_bus dsa_bus = { .bus = { .scan = dsa_scan, .probe = dsa_probe, - .find_device = dsa_find_device, + .find_device = rte_bus_generic_find_device, .get_iommu_class = dsa_get_iommu_class, .parse = dsa_addr_parse, },
@@ -340,22 +338,6 @@ dsa_scan(void)return 0 ; } -static struct rte_device * -dsa_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data) -{ -struct rte_device *dev =TAILQ_FIRST (&dsa_bus.bus.device_list); - -if (start !=NULL )/* jump to start point if given */ - dev =TAILQ_NEXT (start, next); -while (dev !=NULL ) { -if (cmp (dev, data) ==0 ) -return dev; - dev =TAILQ_NEXT (dev, next); - } -return NULL ; -} -static enum rte_iova_mode dsa_get_iommu_class (void ) {
drivers/net/bonding/rte_eth_bond_args.c +1 -1
@@ -45,7 +45,7 @@ find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)return -1 ; } - dev = pci_bus->find_device (NULL , bond_pci_addr_cmp, pci_addr); + dev = pci_bus->find_device (pci_bus,NULL , bond_pci_addr_cmp, pci_addr);if (dev ==NULL ) {RTE_BOND_LOG (ERR ,"unable to find PCI device" );return -1 ;
drivers/net/vdev_netvsc/vdev_netvsc.c +1 -1
@@ -794,7 +794,7 @@ vdev_netvsc_scan_callback(__rte_unused void *arg) VDEV_NETVSC_DRIVER_NAME_LEN))return ; - dev = vbus->find_device (NULL , vdev_netvsc_cmp_rte_device, + dev = vbus->find_device (vbus,NULL , vdev_netvsc_cmp_rte_device,VDEV_NETVSC_DRIVER_NAME );if (dev)return ;
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
@@ -1874,7 +1874,7 @@ ifpga_cfg_remove(struct rte_vdev_device *vdev) args.port, args.bdf); bus =rte_bus_find_by_name (RTE_STR (IFPGA_BUS_NAME ));if (bus) { -if (bus->find_device (NULL , cmp_dev_name, dev_name)) { +if (bus->find_device (bus,NULL , cmp_dev_name, dev_name)) { ret =rte_eal_hotplug_remove (RTE_STR (IFPGA_BUS_NAME ), dev_name); }
lib/eal/common/eal_common_bus.c +20 -1
@@ -182,7 +182,7 @@ bus_find_device(const struct rte_bus *bus, const void *_dev) {struct rte_device *dev; - dev = bus->find_device (NULL , cmp_rte_device, _dev); + dev = bus->find_device (bus,NULL , cmp_rte_device, _dev);return dev ==NULL ; }
@@ -398,6 +398,25 @@ rte_bus_insert_device(struct rte_bus *bus, new_dev->bus = bus; } +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_generic_find_device) +struct rte_device * +rte_bus_generic_find_device (const struct rte_bus *bus,const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) +{ +struct rte_device *dev; + +if (start !=NULL ) + dev =TAILQ_NEXT (start, next); +else + dev =TAILQ_FIRST (&bus->device_list); +while (dev !=NULL ) { +if (cmp (dev, data) ==0 ) +return dev; + dev =TAILQ_NEXT (dev, next); + } +return NULL ; +} +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_add_driver) voidrte_bus_add_driver (struct rte_bus *bus,struct rte_driver *driver)
lib/eal/common/eal_common_dev.c +2 -2
@@ -207,7 +207,7 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)if (ret) goto err_devarg; - dev = da->bus->find_device (NULL , cmp_dev_name, da->name); + dev = da->bus->find_device (da->bus,NULL , cmp_dev_name, da->name);if (dev ==NULL ) {EAL_LOG (ERR ,"Cannot find device (%s)" , da->name);
@@ -347,7 +347,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)return -ENOENT ; } - dev = bus->find_device (NULL , cmp_dev_name, devname); + dev = bus->find_device (bus,NULL , cmp_dev_name, devname);if (dev ==NULL ) {EAL_LOG (ERR ,"Cannot find plugged device (%s)" , devname);return -EINVAL ;
lib/eal/common/hotplug_mp.c +2 -2
@@ -135,7 +135,7 @@ __handle_secondary_request(void *param) goto finish; } - dev = bus->find_device (NULL , cmp_dev_name, da.name); + dev = bus->find_device (bus,NULL , cmp_dev_name, da.name);if (dev ==NULL ) {EAL_LOG (ERR ,"Cannot find plugged device (%s)" , da.name); ret = -ENOENT ;
@@ -262,7 +262,7 @@ static void __handle_primary_request(void *param) goto quit; } - dev = bus->find_device (NULL , cmp_dev_name, da->name); + dev = bus->find_device (bus,NULL , cmp_dev_name, da->name);if (dev ==NULL ) {EAL_LOG (ERR ,"Cannot find plugged device (%s)" , da->name); ret = -ENOENT ;
lib/eal/include/bus_driver.h +22 -2
@@ -69,8 +69,8 @@ typedef int (*rte_bus_probe_t)(void);* The first device matching the data, NULL if none exists. */ typedef struct rte_device * -(*rte_bus_find_device_t )(const struct rte_device *start,rte_dev_cmp_t cmp, -const void *data); +(*rte_bus_find_device_t )(const struct rte_bus *bus,const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data);/** * Implementation specific probe function which is responsible for linking
@@ -430,6 +430,26 @@ void rte_bus_insert_device(struct rte_bus *bus,struct rte_device *exist_dev, struct rte_device *new_dev); +/** +* Find a device on a bus. +* +* @param bus +* A pointer to a rte_bus structure. +* @param start +* Starting point for the search. If NULL, search from the beginning. +* @param cmp +* Comparison function to match devices. +* @param data +* Data to pass to the comparison function. +* @return +* The first matching device, or NULL if not found. +*/ +__rte_internal +struct rte_device *rte_bus_generic_find_device(const struct rte_bus *bus, +const struct rte_device *start, +rte_dev_cmp_t cmp, +const void *data); +/** * Helper macro to iterate over all drivers on a bus. *
lib/eal/linux/eal_dev.c +1 -2
@@ -278,8 +278,7 @@ dev_uev_handler(__rte_unused void *param) goto failure_handle_err; } - dev = bus->find_device (NULL , cmp_dev_name, - uevent.devname); + dev = bus->find_device (bus,NULL , cmp_dev_name, uevent.devname);if (dev ==NULL ) {EAL_LOG (ERR ,"Cannot find device (%s) on " "bus (%s)" , uevent.devname, busname);
Signature · 1 line
2.53.0
PATCH v5 12/25 bus: consolidate device iteration
In reply to David MarchandMany buses (auxiliary, cdx, dpaa, fslmc, platform, uacce, vdev...) had nearly identical dev_iterate implementations using name-based matching:
- Parse kvargs with "name" parameter
- Match device name via strcmp
- Call rte_bus_find_device()
Extend bus device iterator callback and introduce rte_bus_generic_dev_iterate() generic helper in EAL.
Only the PCI bus is left with its matching on PCI address criteria.
---
Changes since v2:
- renamed some input variables in the bus header for readability,
- fixed some doxygen comments,
--- drivers/bus/auxiliary/auxiliary_common.c | 2 +- drivers/bus/auxiliary/auxiliary_params.c | 63 ----------------------- drivers/bus/auxiliary/meson.build | 5 +- drivers/bus/auxiliary/private.h | 6 --- drivers/bus/cdx/cdx.c | 52 +------------------ drivers/bus/dpaa/dpaa_bus.c | 46 +---------------- drivers/bus/fslmc/fslmc_bus.c | 46 +---------------- drivers/bus/pci/pci_params.c | 3 +- drivers/bus/pci/private.h | 6 ++- drivers/bus/platform/meson.build | 5 +- drivers/bus/platform/platform.c | 2 +- drivers/bus/platform/platform_params.c | 65 ------------------------ drivers/bus/platform/private.h | 7 --- drivers/bus/uacce/uacce.c | 48 +---------------- drivers/bus/vdev/meson.build | 5 +- drivers/bus/vdev/vdev.c | 18 +++---- drivers/bus/vdev/vdev_logs.h | 16 ------ drivers/bus/vdev/vdev_params.c | 64 ----------------------- drivers/bus/vdev/vdev_private.h | 28 ---------- lib/eal/common/eal_common_bus.c | 41 +++++++++++++++ lib/eal/common/eal_common_dev.c | 4 +- lib/eal/include/bus_driver.h | 53 ++++++++++++++++++- lib/ethdev/rte_ethdev.c | 2 +- 23 files changed, 121 insertions(+), 466 deletions(-) delete mode 100644 drivers/bus/auxiliary/auxiliary_params.c delete mode 100644 drivers/bus/platform/platform_params.c delete mode 100644 drivers/bus/vdev/vdev_logs.h delete mode 100644 drivers/bus/vdev/vdev_params.c delete mode 100644 drivers/bus/vdev/vdev_private.h
drivers/bus/auxiliary/auxiliary_common.c +1 -1
@@ -346,7 +346,7 @@ struct rte_auxiliary_bus auxiliary_bus = { .dma_map = auxiliary_dma_map, .dma_unmap = auxiliary_dma_unmap, .get_iommu_class = auxiliary_get_iommu_class, - .dev_iterate = auxiliary_dev_iterate, + .dev_iterate = rte_bus_generic_dev_iterate, }, };
drivers/bus/auxiliary/auxiliary_params.c deleted +0 -63
63 lines not on this page · raw message
drivers/bus/auxiliary/meson.build +1 -4
@@ -2,10 +2,7 @@ # Copyright (c) 2021 NVIDIA Corporation & Affiliates driver_sdk_headers += files('bus_auxiliary_driver.h') -sources = files( - 'auxiliary_common.c', - 'auxiliary_params.c', -) +sources = files('auxiliary_common.c') if is_linux cflags += '-DAUXILIARY_OS_SUPPORTED' sources += files(
drivers/bus/auxiliary/private.h +0 -6
@@ -50,10 +50,4 @@ void auxiliary_on_scan(struct rte_auxiliary_device *aux_dev);bool auxiliary_match (const struct rte_auxiliary_driver *aux_drv,const struct rte_auxiliary_device *aux_dev); -/* -* Iterate over devices, matching any device against the provided string. -*/ -void *auxiliary_dev_iterate (const void *start,const char *str, -const struct rte_dev_iterator *it); -#endif /* BUS_AUXILIARY_PRIVATE_H */
drivers/bus/cdx/cdx.c +1 -51
70 lines not on this page · raw message
drivers/bus/dpaa/dpaa_bus.c +1 -45
58 lines not on this page · raw message
drivers/bus/fslmc/fslmc_bus.c +1 -45
58 lines not on this page · raw message
drivers/bus/pci/pci_params.c +2 -1
@@ -59,7 +59,8 @@ pci_dev_match(const struct rte_device *dev, }void * -rte_pci_dev_iterate (const void *start, +rte_pci_dev_iterate(const struct rte_bus *bus __rte_unused, +const void *start,const char *str, const struct rte_dev_iterator *it __rte_unused) {
drivers/bus/pci/private.h +5 -1
@@ -258,6 +258,9 @@ rte_pci_get_iommu_class(void);* matching any device against the provided * string. * +* @param bus +* A pointer to the bus structure. +* * @param start * Iteration starting point. *
@@ -272,7 +275,8 @@ rte_pci_get_iommu_class(void);* NULL otherwise. */ void * -rte_pci_dev_iterate (const void *start, +rte_pci_dev_iterate (const struct rte_bus *bus, +const void *start,const char *str,const struct rte_dev_iterator *it);
drivers/bus/platform/meson.build +1 -4
@@ -11,8 +11,5 @@ endif require_iova_in_mbuf = false deps += ['kvargs'] -sources = files( - 'platform_params.c', - 'platform.c', -) +sources = files('platform.c') driver_sdk_headers += files('bus_platform_driver.h')
drivers/bus/platform/platform.c +1 -1
@@ -562,7 +562,7 @@ struct rte_platform_bus platform_bus = { .dma_map = platform_bus_dma_map, .dma_unmap = platform_bus_dma_unmap, .get_iommu_class = platform_bus_get_iommu_class, - .dev_iterate = platform_bus_dev_iterate, + .dev_iterate = rte_bus_generic_dev_iterate, .cleanup = platform_bus_cleanup, }, };
drivers/bus/platform/platform_params.c deleted +0 -65
65 lines not on this page · raw message
drivers/bus/platform/private.h +0 -7
@@ -28,11 +28,4 @@ extern int platform_bus_logtype;#define PLATFORM_LOG_LINE (level, ...) \ RTE_LOG_LINE(level, PLATFORM_BUS, __VA_ARGS__) -/* -* Iterate registered platform devices and find one that matches provided string. -*/ -void * -platform_bus_dev_iterate (const void *start,const char *str, - const struct rte_dev_iterator *it __rte_unused); -#endif /* PLATFORM_PRIVATE_H */
drivers/bus/uacce/uacce.c +1 -47
66 lines not on this page · raw message
drivers/bus/vdev/meson.build +1 -4
@@ -1,10 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -sources = files( - 'vdev.c', - 'vdev_params.c', -) +sources = files('vdev.c') headers = files('rte_bus_vdev.h') driver_sdk_headers = files('bus_vdev_driver.h')
drivers/bus/vdev/vdev.c +9 -9
@@ -10,12 +10,14 @@#include <stdbool.h> #include <sys/queue.h> +#include <rte_os_shim.h> #include <eal_export.h> #include <rte_eal.h> #include <dev_driver.h> #include <bus_driver.h> #include <rte_common.h> #include <rte_devargs.h> +#include <rte_log.h> #include <rte_memory.h> #include <rte_tailq.h> #include <rte_spinlock.h>
@@ -23,11 +25,15 @@#include <rte_errno.h> #include "bus_vdev_driver.h" -#include "vdev_logs.h" -#include "vdev_private.h" #define VDEV_MP_KEY "bus_vdev_mp" +int vdev_logtype_bus; +#define RTE_LOGTYPE_VDEV_BUS vdev_logtype_bus + +#define VDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, VDEV_BUS, "%s(): ", __func__, __VA_ARGS__) +/* Forward declare to access virtual bus name */ static struct rte_bus rte_vdev_bus;
@@ -589,12 +595,6 @@ vdev_find_device(const struct rte_bus *bus, const struct rte_device *start,return dev; } -struct rte_device * -rte_vdev_find_device (const struct rte_device *start,rte_dev_cmp_t cmp,const void *data) -{ -return vdev_find_device (&rte_vdev_bus, start, cmp, data); -} -static int vdev_plug (struct rte_device *dev) {
@@ -637,7 +637,7 @@ static struct rte_bus rte_vdev_bus = { .dma_map = vdev_dma_map, .dma_unmap = vdev_dma_unmap, .get_iommu_class = vdev_get_iommu_class, - .dev_iterate = rte_vdev_dev_iterate, + .dev_iterate = rte_bus_generic_dev_iterate, };RTE_REGISTER_BUS (vdev, rte_vdev_bus);
drivers/bus/vdev/vdev_logs.h deleted +0 -16
@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause -* Copyright(c) 2017 Intel Corporation -*/ - -#ifndef _VDEV_LOGS_H_ -#define _VDEV_LOGS_H_ - -#include <rte_log.h> - -extern int vdev_logtype_bus; -#define RTE_LOGTYPE_VDEV_BUS vdev_logtype_bus - -#define VDEV_LOG (level, ...) \ - RTE_LOG_LINE_PREFIX(level, VDEV_BUS, "%s(): ", __func__, __VA_ARGS__) - -#endif /* _VDEV_LOGS_H_ */
drivers/bus/vdev/vdev_params.c deleted +0 -64
64 lines not on this page · raw message
drivers/bus/vdev/vdev_private.h deleted +0 -28
@@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2018 Gaëtan Rivet -*/ - -#ifndef _VDEV_PRIVATE_H_ -#define _VDEV_PRIVATE_H_ - -#include <rte_os_shim.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct rte_device * -rte_vdev_find_device (const struct rte_device *start, -rte_dev_cmp_t cmp, -const void *data); - -void * -rte_vdev_dev_iterate (const void *start, -const char *str, -const struct rte_dev_iterator *it); - -#ifdef __cplusplus -} -#endif - -#endif /* _VDEV_PRIVATE_H_ */
lib/eal/common/eal_common_bus.c +41 -0
50 lines not on this page · raw message
lib/eal/common/eal_common_dev.c +2 -2
@@ -756,13 +756,13 @@ bus_next_dev_cmp(const struct rte_bus *bus,if (rte_errno !=0 )return -1 ;if (it->cls_str ==NULL ) { - dev = bus->dev_iterate (dev, bus_str, it); + dev = bus->dev_iterate (bus, dev, bus_str, it); goto end; }/* cls_str != NULL */ if (dev ==NULL ) { next_dev_on_bus: - dev = bus->dev_iterate (dev, bus_str, it); + dev = bus->dev_iterate (bus, dev, bus_str, it); it->device = dev; }if (dev ==NULL )
lib/eal/include/bus_driver.h +52 -1
71 lines not on this page · raw message
lib/ethdev/rte_ethdev.c +1 -1
@@ -313,7 +313,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter) iter->class_device == NULL) {/* get next rte_device to try. */ iter->device = iter->bus->dev_iterate ( - iter->device, iter->bus_str, iter); + iter->bus, iter->device, iter->bus_str, iter);if (iter->device ==NULL )break ;/* no more rte_device candidate */ }
Signature · 1 line
2.53.0
PATCH v5 13/25 bus: factorize driver lookup
In reply to David MarchandIntroduce a new bus operation 'match' that checks whether a driver can handle a given device. This separates the matching logic from iteration, with buses providing match logic and EAL providing generic iteration through rte_bus_find_driver().
The match operation returns true if a driver matches a device. Matching logic is bus-specific (e.g., ID table matching for PCI/CDX, device type matching for DPAA/FSLMC, UUID matching for IFPGA/VMBUS, name matching for vdev/platform, API/algorithm matching for uacce).
A generic helper rte_bus_find_driver() iterates through all drivers on a bus and returns the next matching driver, eliminating the need for each bus to duplicate iteration logic.
--- drivers/bus/auxiliary/auxiliary_common.c | 14 ++++----- drivers/bus/auxiliary/private.h | 6 ---- drivers/bus/cdx/cdx.c | 16 +++++----- drivers/bus/dpaa/dpaa_bus.c | 21 ++++++------- drivers/bus/fslmc/fslmc_bus.c | 23 +++++++------- drivers/bus/ifpga/ifpga_bus.c | 14 +++++---- drivers/bus/pci/pci_common.c | 20 ++++++------- drivers/bus/pci/private.h | 15 ---------- drivers/bus/platform/platform.c | 9 ++++-- drivers/bus/uacce/uacce.c | 13 ++++---- drivers/bus/vdev/vdev.c | 20 +++++++++++++ drivers/bus/vmbus/vmbus_common.c | 21 ++++--------- drivers/dma/idxd/idxd_bus.c | 35 ++++++++++++++-------- lib/eal/common/eal_common_bus.c | 19 ++++++++++++ lib/eal/include/bus_driver.h | 38 ++++++++++++++++++++++++ 15 files changed, 172 insertions(+), 112 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +7 -7
@@ -59,13 +59,12 @@ auxiliary_on_scan(struct rte_auxiliary_device *aux_dev) aux_dev->device.devargs =rte_bus_find_devargs (&auxiliary_bus.bus, aux_dev->name); } -/* -* Match the auxiliary driver and device using driver function. -*/ -bool -auxiliary_match (const struct rte_auxiliary_driver *aux_drv, -const struct rte_auxiliary_device *aux_dev) +static bool +auxiliary_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_auxiliary_driver *aux_drv =RTE_BUS_DRIVER (drv, *aux_drv); +const struct rte_auxiliary_device *aux_dev =RTE_BUS_DEVICE (dev, *aux_dev); +if (aux_drv->match ==NULL )return false;return aux_drv->match (aux_dev->name);
@@ -82,7 +81,7 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,int ret;/* Check if driver supports it. */ -if (!auxiliary_match (drv, dev)) +if (!auxiliary_bus_match (&drv->driver, &dev->device))/* Match of device and driver failed */ return 1 ;
@@ -340,6 +339,7 @@ struct rte_auxiliary_bus auxiliary_bus = { .probe = auxiliary_probe, .cleanup = auxiliary_cleanup, .find_device = rte_bus_generic_find_device, + .match = auxiliary_bus_match, .plug = auxiliary_plug, .unplug = auxiliary_unplug, .parse = auxiliary_parse,
drivers/bus/auxiliary/private.h +0 -6
@@ -44,10 +44,4 @@ int auxiliary_scan(void);*/ void auxiliary_on_scan (struct rte_auxiliary_device *aux_dev); -/* -* Match the auxiliary driver and device by driver function. -*/ -bool auxiliary_match (const struct rte_auxiliary_driver *aux_drv, -const struct rte_auxiliary_device *aux_dev); -#endif /* BUS_AUXILIARY_PRIVATE_H */
drivers/bus/cdx/cdx.c +8 -8
@@ -279,13 +279,12 @@ cdx_unmap_resource(void *requested_addr, size_t size) requested_addr, size, rte_strerror(rte_errno)); } } -/* -* Match the CDX Driver and Device using device id and vendor id. -*/ +static bool -cdx_match (const struct rte_cdx_driver *cdx_drv, -const struct rte_cdx_device *cdx_dev) +cdx_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_cdx_driver *cdx_drv =RTE_BUS_DRIVER (drv, *cdx_drv); +const struct rte_cdx_device *cdx_dev =RTE_BUS_DEVICE (dev, *cdx_dev);const struct rte_cdx_id *id_table; for (id_table = cdx_drv->id_table; id_table->vendor_id != 0;
@@ -298,10 +297,10 @@ cdx_match(const struct rte_cdx_driver *cdx_drv, id_table->device_id != RTE_CDX_ANY_ID)continue ; -return 1 ; +return true; } -return 0 ; +return false; }/*
@@ -317,7 +316,7 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,int ret;/* The device is not blocked; Check if driver supports it */ -if (!cdx_match (dr, dev)) +if (!cdx_bus_match (&dr->driver, &dev->device))/* Match of device and driver failed */ return 1 ;
@@ -524,6 +523,7 @@ struct rte_cdx_bus rte_cdx_bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = rte_bus_generic_find_device, + .match = cdx_bus_match, .plug = cdx_plug, .unplug = cdx_unplug, .parse = cdx_parse,
drivers/bus/dpaa/dpaa_bus.c +9 -12
@@ -626,19 +626,16 @@ rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver)rte_bus_remove_driver (&rte_dpaa_bus.bus, &driver->driver); } -static int -rte_dpaa_device_match (struct rte_dpaa_driver *drv, -struct rte_dpaa_device *dev) +static bool +dpaa_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { -if (!drv || !dev) { -DPAA_BUS_DEBUG ("Invalid drv or dev received." ); -return -1 ; - } +const struct rte_dpaa_driver *dpaa_drv =RTE_BUS_DRIVER (drv, *dpaa_drv); +const struct rte_dpaa_device *dpaa_dev =RTE_BUS_DEVICE (dev, *dpaa_dev); -if (drv->drv_type == dev->device_type) -return 0 ; +if (dpaa_drv->drv_type == dpaa_dev->device_type) +return true; -return -1 ; +return false; } static int
@@ -793,8 +790,7 @@ rte_dpaa_bus_probe(void)/* For each registered driver, and device, call the driver->probe */ RTE_BUS_FOREACH_DEV(dev, &rte_dpaa_bus.bus) { RTE_BUS_FOREACH_DRV(drv, &rte_dpaa_bus.bus) { - ret =rte_dpaa_device_match (drv, dev); -if (ret) +if (!dpaa_bus_match (&drv->driver, &dev->device))continue ;if (rte_dev_is_probed (&dev->device))
@@ -902,6 +898,7 @@ static struct rte_dpaa_bus rte_dpaa_bus = { .dev_compare = dpaa_bus_dev_compare, .find_device = rte_bus_generic_find_device, .get_iommu_class = rte_dpaa_get_iommu_class, + .match = dpaa_bus_match, .plug = dpaa_bus_plug, .unplug = dpaa_bus_unplug, .dev_iterate = rte_bus_generic_dev_iterate,
drivers/bus/fslmc/fslmc_bus.c +11 -12
@@ -381,14 +381,16 @@ rte_fslmc_scan(void)return 0 ; } -static int -rte_fslmc_match (struct rte_dpaa2_driver *dpaa2_drv, -struct rte_dpaa2_device *dpaa2_dev) +static bool +fslmc_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_dpaa2_driver *dpaa2_drv =RTE_BUS_DRIVER (drv, *dpaa2_drv); +const struct rte_dpaa2_device *dpaa2_dev =RTE_BUS_DEVICE (dev, *dpaa2_dev); +if (dpaa2_drv->drv_type == dpaa2_dev->dev_type) -return 0 ; +return true; -return 1 ; +return false; } static int
@@ -455,8 +457,7 @@ rte_fslmc_probe(void) RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { RTE_BUS_FOREACH_DRV(drv, &rte_fslmc_bus.bus) { - ret =rte_fslmc_match (drv, dev); -if (ret) +if (!fslmc_bus_match (&drv->driver, &dev->device))continue ;if (rte_dev_is_probed (&dev->device))
@@ -504,14 +505,12 @@ rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver)static inline int fslmc_all_device_support_iova (void ) { -int ret =0 ;struct rte_dpaa2_device *dev;struct rte_dpaa2_driver *drv; RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus.bus) { RTE_BUS_FOREACH_DRV(drv, &rte_fslmc_bus.bus) { - ret =rte_fslmc_match (drv, dev); -if (ret) +if (!fslmc_bus_match (&drv->driver, &dev->device))continue ;/* if the driver is not supporting IOVA */ if (!(drv->drv_flags &RTE_DPAA2_DRV_IOVA_AS_VA ))
@@ -548,8 +547,7 @@ fslmc_bus_plug(struct rte_device *rte_dev)struct rte_dpaa2_driver *drv; RTE_BUS_FOREACH_DRV(drv, &rte_fslmc_bus.bus) { - ret =rte_fslmc_match (drv, dev); -if (ret) +if (!fslmc_bus_match (&drv->driver, &dev->device))continue ;if (rte_dev_is_probed (&dev->device))
@@ -602,6 +600,7 @@ struct rte_fslmc_bus rte_fslmc_bus = { .dev_compare = fslmc_dev_compare, .find_device = rte_bus_generic_find_device, .get_iommu_class = rte_dpaa2_get_iommu_class, + .match = fslmc_bus_match, .plug = fslmc_bus_plug, .unplug = fslmc_bus_unplug, .dev_iterate = rte_bus_generic_dev_iterate,
drivers/bus/ifpga/ifpga_bus.c +8 -6
@@ -245,10 +245,11 @@ ifpga_scan(void)/* * Match the AFU Driver and AFU Device using the ID Table */ -static int -rte_afu_match (const struct rte_afu_driver *afu_drv, -const struct rte_afu_device *afu_dev) +static bool +ifpga_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_afu_driver *afu_drv =RTE_BUS_DRIVER (drv, *afu_drv); +const struct rte_afu_device *afu_dev =RTE_BUS_DEVICE (dev, *afu_dev);const struct rte_afu_uuid *id_table; for (id_table = afu_drv->id_table;
@@ -260,10 +261,10 @@ rte_afu_match(const struct rte_afu_driver *afu_drv, afu_dev->id.uuid.uuid_high)continue ; -return 1 ; +return true; } -return 0 ; +return false; } static int
@@ -272,7 +273,7 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv, {int ret; -if (!rte_afu_match (drv, afu_dev)) +if (!ifpga_bus_match (&drv->driver, &afu_dev->device))/* Match of device and driver failed */ return 1 ;
@@ -452,6 +453,7 @@ static struct rte_bus rte_ifpga_bus = { .probe = ifpga_probe, .cleanup = ifpga_cleanup, .find_device = rte_bus_generic_find_device, + .match = ifpga_bus_match, .plug = ifpga_plug, .unplug = ifpga_unplug, .parse = ifpga_parse,
drivers/bus/pci/pci_common.c +10 -10
@@ -141,13 +141,12 @@ pci_unmap_resource(void *requested_addr, size_t size) }else PCI_LOG (DEBUG ," PCI memory unmapped at %p" , requested_addr); } -/* -* Match the PCI Driver and Device using the ID Table -*/ -int -rte_pci_match (const struct rte_pci_driver *pci_drv, -const struct rte_pci_device *pci_dev) + +static bool +pci_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_pci_driver *pci_drv =RTE_BUS_DRIVER (drv, *pci_drv); +const struct rte_pci_device *pci_dev =RTE_BUS_DEVICE (dev, *pci_dev);const struct rte_pci_id *id_table; for (id_table = pci_drv->id_table; id_table->vendor_id != 0;
@@ -171,10 +170,10 @@ rte_pci_match(const struct rte_pci_driver *pci_drv, id_table->class_id != RTE_CLASS_ANY_ID)continue ; -return 1 ; +return true; } -return 0 ; +return false; }/*
@@ -195,7 +194,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, loc = &dev->addr;/* The device is not blocked; Check if driver supports it */ -if (!rte_pci_match (dr, dev)) +if (!pci_bus_match (&dr->driver, &dev->device))/* Match of device and driver failed */ return 1 ;
@@ -680,7 +679,7 @@ rte_pci_get_iommu_class(void) RTE_BUS_FOREACH_DRV(drv, &rte_pci_bus.bus) {enum rte_iova_mode dev_iova_mode; -if (!rte_pci_match (drv, dev)) +if (!pci_bus_match (&drv->driver, &dev->device))continue ; dev_iova_mode =pci_device_iova_mode (drv, dev);
@@ -861,6 +860,7 @@ struct rte_pci_bus rte_pci_bus = { .probe = pci_probe, .cleanup = pci_cleanup, .find_device = rte_bus_generic_find_device, + .match = pci_bus_match, .plug = pci_plug, .unplug = pci_unplug, .parse = pci_parse,
drivers/bus/pci/private.h +0 -15
@@ -217,21 +217,6 @@ pci_uio_remap_resource(struct rte_pci_device *dev);int pci_uio_map_resource_by_index (struct rte_pci_device *dev,int res_idx,struct mapped_pci_resource *uio_res,int map_idx); -/* -* Match the PCI Driver and Device using the ID Table -* -* @param pci_drv -* PCI driver from which ID table would be extracted -* @param pci_dev -* PCI device to match against the driver -* @return -* 1 for successful match -* 0 for unsuccessful match -*/ -int -rte_pci_match (const struct rte_pci_driver *pci_drv, -const struct rte_pci_device *pci_dev); -/** * OS specific callbacks for rte_pci_get_iommu_class *
drivers/bus/platform/platform.c +6 -3
@@ -371,8 +371,10 @@ driver_probe_device(struct rte_platform_driver *pdrv, struct rte_platform_device }static bool -driver_match_device (struct rte_platform_driver *pdrv,struct rte_platform_device *pdev) +platform_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_platform_driver *pdrv =RTE_BUS_DRIVER (drv, *pdrv); +const struct rte_platform_device *pdev =RTE_BUS_DEVICE (dev, *pdev);bool match = false;char *kdrv;
@@ -408,7 +410,7 @@ device_attach(struct rte_platform_device *pdev)struct rte_platform_driver *pdrv; RTE_BUS_FOREACH_DRV(pdrv, &platform_bus.bus) { -if (driver_match_device (pdrv, pdev)) +if (platform_bus_match (&pdrv->driver, &pdev->device))break ; }
@@ -488,7 +490,7 @@ platform_bus_parse(const char *name, void *addr)rte_strscpy (pdev.name, name,sizeof (pdev.name)); RTE_BUS_FOREACH_DRV(pdrv, &platform_bus.bus) { -if (driver_match_device (pdrv, &pdev)) +if (platform_bus_match (&pdrv->driver, &pdev.device))break ; }
@@ -556,6 +558,7 @@ struct rte_platform_bus platform_bus = { .scan = platform_bus_scan, .probe = platform_bus_probe, .find_device = rte_bus_generic_find_device, + .match = platform_bus_match, .plug = platform_bus_plug, .unplug = platform_bus_unplug, .parse = platform_bus_parse,
drivers/bus/uacce/uacce.c +8 -5
@@ -315,15 +315,17 @@ uacce_match_api(const struct rte_uacce_device *dev, bool forward_compat, }static bool -uacce_match (const struct rte_uacce_driver *dr,const struct rte_uacce_device *dev) +uacce_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_uacce_driver *dr =RTE_BUS_DRIVER (drv, *dr); +const struct rte_uacce_device *uacce_dev =RTE_BUS_DEVICE (dev, *uacce_dev);bool forward_compat = !!(dr->drv_flags &RTE_UACCE_DRV_FORWARD_COMPATIBILITY_DEV );const struct rte_uacce_id *id_table;const char *map;uint32_t len;for (id_table = dr->id_table; id_table->dev_api !=NULL ; id_table++) { -if (!uacce_match_api (dev, forward_compat, id_table)) +if (!uacce_match_api (uacce_dev, forward_compat, id_table))continue ;if (id_table->dev_alg ==NULL )
@@ -334,10 +336,10 @@ uacce_match(const struct rte_uacce_driver *dr, const struct rte_uacce_device *de* algorithms: aaa, bbbb and cc. * The id_table->dev_alg should be a single algrithm, e.g. bbbb. */ - map =strstr (dev->algs, id_table->dev_alg); + map =strstr (uacce_dev->algs, id_table->dev_alg);if (map ==NULL )continue ; -if (map != dev->algs && map[-1 ] !='\n' ) +if (map != uacce_dev->algs && map[-1 ] !='\n' )continue ; len =strlen (id_table->dev_alg);if (map[len] !='\0' && map[len] !='\n' )
@@ -356,7 +358,7 @@ uacce_probe_one_driver(struct rte_uacce_driver *dr, struct rte_uacce_device *devbool already_probed;int ret; -if (!uacce_match (dr, dev)) +if (!uacce_bus_match (&dr->driver, &dev->device))/* Match of device and driver failed */ return 1 ;
@@ -623,6 +625,7 @@ static struct rte_uacce_bus uacce_bus = { .scan = uacce_scan, .probe = uacce_probe, .cleanup = uacce_cleanup, + .match = uacce_bus_match, .plug = uacce_plug, .unplug = uacce_unplug, .find_device = rte_bus_generic_find_device,
drivers/bus/vdev/vdev.c +20 -0
@@ -162,6 +162,25 @@ vdev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)return 0 ; } +/* +* Check if a vdev driver matches a vdev device by name. +*/ +static bool +vdev_bus_match (const struct rte_driver *drv,const struct rte_device *dev) +{ +const char *name = dev->name; + +/* Check driver name match */ +if (strncmp (drv->name, name,strlen (drv->name)) ==0 ) +return true; + +/* Check driver alias match */ +if (drv->alias &&strncmp (drv->alias, name,strlen (drv->alias)) ==0 ) +return true; + +return false; +} +static int vdev_probe_all_drivers (struct rte_vdev_device *dev) {
@@ -631,6 +650,7 @@ static struct rte_bus rte_vdev_bus = { .probe = vdev_probe, .cleanup = vdev_cleanup, .find_device = vdev_find_device, + .match = vdev_bus_match, .plug = vdev_plug, .unplug = vdev_unplug, .parse = vdev_parse,
drivers/bus/vmbus/vmbus_common.c +6 -15
@@ -65,25 +65,15 @@ vmbus_unmap_resource(void *requested_addr, size_t size) } } -/** -* Match the VMBUS driver and device using UUID table -* -* @param drv -* VMBUS driver from which ID table would be extracted -* @param pci_dev -* VMBUS device to match against the driver -* @return -* true for successful match -* false for unsuccessful match -*/ static bool -vmbus_match (const struct rte_vmbus_driver *dr, -const struct rte_vmbus_device *dev) +vmbus_bus_match (const struct rte_driver *drv,const struct rte_device *dev) { +const struct rte_vmbus_driver *dr =RTE_BUS_DRIVER (drv, *dr); +const struct rte_vmbus_device *vmbus_dev =RTE_BUS_DEVICE (dev, *vmbus_dev);const rte_uuid_t *id_table;for (id_table = dr->id_table; !rte_uuid_is_null (*id_table); ++id_table) { -if (rte_uuid_compare (*id_table, dev->class_id) ==0 ) +if (rte_uuid_compare (*id_table, vmbus_dev->class_id) ==0 )return true; }
@@ -99,7 +89,7 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,char guid[RTE_UUID_STRLEN ];int ret; -if (!vmbus_match (dr, dev)) +if (!vmbus_bus_match (&dr->driver, &dev->device))return 1 ;/* not supported */ rte_uuid_unparse (dev->device_id, guid,sizeof (guid));
@@ -281,6 +271,7 @@ struct rte_vmbus_bus rte_vmbus_bus = { .probe = rte_vmbus_probe, .cleanup = rte_vmbus_cleanup, .find_device = rte_bus_generic_find_device, + .match = vmbus_bus_match, .parse = vmbus_parse, .dev_compare = vmbus_dev_compare, },
drivers/dma/idxd/idxd_bus.c +22 -13
@@ -43,6 +43,7 @@ struct rte_dsa_device {/* forward prototypes */ struct dsa_bus ;static int dsa_scan (void ); +static bool dsa_match (const struct rte_driver *drv,const struct rte_device *dev);static int dsa_probe (void );static enum rte_iova_mode dsa_get_iommu_class (void );static int dsa_addr_parse (const char *name,void *addr);
@@ -58,6 +59,7 @@ struct dsa_bus {struct dsa_bus dsa_bus = { .bus = { .scan = dsa_scan, + .match = dsa_match, .probe = dsa_probe, .find_device = rte_bus_generic_find_device, .get_iommu_class = dsa_get_iommu_class,
@@ -126,7 +128,7 @@ idxd_bus_mmap_wq(struct rte_dsa_device *dev) }static int -read_wq_string (struct rte_dsa_device *dev,const char *filename, +read_wq_string (const struct rte_dsa_device *dev,const char *filename,char *value,size_t valuelen) {char sysfs_node[PATH_MAX ];
@@ -241,7 +243,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev) }static int -is_for_this_process_use (struct rte_dsa_device *dev,const char *name) +is_for_this_process_use (const char *name) {char prefix[256 ];int retval =0 ;
@@ -256,9 +258,6 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)if (strncmp (name, prefix, prefixlen) ==0 && name[prefixlen] =='_' ) retval =1 ; -if (retval) - retval = !rte_bus_device_is_ignored (&dsa_bus.bus, dev->device.name); -return retval; }
@@ -268,14 +267,8 @@ dsa_probe(void)struct rte_dsa_device *dev; RTE_BUS_FOREACH_DEV(dev, &dsa_bus.bus) { -char type[64 ], name[64 ]; - -if (read_wq_string (dev,"type" , type,sizeof (type)) <0 || -read_wq_string (dev,"name" , name,sizeof (name)) <0 ) -continue ; - -if (strncmp (type,"user" ,4 ) ==0 && -is_for_this_process_use (dev, name)) { +if (dsa_match (&dsa_bus.driver, &dev->device) && + !rte_bus_device_is_ignored (&dsa_bus.bus, dev->device.name)) { dev->device.driver = &dsa_bus.driver;idxd_probe_dsa (dev);continue ;
@@ -286,6 +279,22 @@ dsa_probe(void)return 0 ; } +static bool dsa_match (const struct rte_driver *drv,const struct rte_device *dev) +{ +const struct rte_dsa_device *dsa_dev =RTE_BUS_DEVICE (dev, *dsa_dev); + +if (drv == &dsa_bus.driver) { +char type[64 ], name[64 ]; + +if (read_wq_string (dsa_dev,"type" , type,sizeof (type)) >=0 && +read_wq_string (dsa_dev,"name" , name,sizeof (name)) >=0 ) { +return strncmp (type,"user" ,4 ) ==0 &&is_for_this_process_use (name); + } + } + +return false; +} +static int dsa_scan (void ) {
lib/eal/common/eal_common_bus.c +19 -0
@@ -473,3 +473,22 @@ rte_bus_generic_dev_iterate(const struct rte_bus *bus,rte_kvargs_free (kvargs);return dev; } + +RTE_EXPORT_INTERNAL_SYMBOL (rte_bus_find_driver) +struct rte_driver * +rte_bus_find_driver (const struct rte_bus *bus,const struct rte_driver *start, +const struct rte_device *dev) +{ +struct rte_driver *drv; + +if (start !=NULL ) + drv =TAILQ_NEXT (start, next); +else + drv =TAILQ_FIRST (&bus->driver_list); +while (drv !=NULL ) { +if (bus->match (drv, dev)) +break ; + drv =TAILQ_NEXT (drv, next); + } +return drv; +}
lib/eal/include/bus_driver.h +38 -0
@@ -233,6 +233,24 @@ typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);*/ typedef int (*rte_bus_cleanup_t )(void ); +/** +* Check if a driver matches a device. +* +* This function checks whether a driver can handle a given device. +* Matching logic is bus-specific (e.g., PCI uses ID tables, vdev uses +* name matching, fslmc uses device type). +* +* @param drv +* Driver to check. +* @param dev +* Device to check against. +* +* @return +* true if the driver matches the device, false otherwise. +*/ +typedef bool (*rte_bus_match_t )(const struct rte_driver *drv, +const struct rte_device *dev); +/** * Bus scan policies */
@@ -297,6 +315,7 @@ struct rte_bus {rte_bus_scan_t scan;/**< Scan for devices attached to bus */ rte_bus_probe_t probe;/**< Probe devices on bus */ rte_bus_find_device_t find_device;/**< Find a device on the bus */ +rte_bus_match_t match;/**< Check if driver matches device */ rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */
@@ -544,6 +563,25 @@ void rte_bus_add_driver(struct rte_bus *bus, struct rte_driver *driver);__rte_internal void rte_bus_remove_driver(struct rte_bus *bus, struct rte_driver *driver); +/** +* Find the first driver that matches a device on a bus. +* +* Iterates through all registered drivers on the bus and returns the next +* one that matches the given device according to the bus's match operation. +* +* @param bus +* A pointer to a rte_bus structure. +* @param start +* Starting iteration context. +* @param dev +* A pointer to a rte_device structure. +* @return +* Pointer to the matching driver, or NULL if no match found. +*/ +__rte_internal +struct rte_driver *rte_bus_find_driver(const struct rte_bus *bus, const struct rte_driver *start, +const struct rte_device *dev); + #ifdef __cplusplus }#endif
Signature · 1 line
2.53.0
PATCH v5 24/25 eventdev: rename dev field to device
In reply to David MarchandRename the rte_eventdev structure field from 'dev' to 'device' to align with the naming convention used by all other device classes in DPDK (ethdev, cryptodev, bbdev, compressdev, rawdev, regexdev, dmadev, gpudev, and mldev).
This change provides consistency across all device classes: each device class structure now contains a 'struct rte_device *device' field pointing to the backing device.
--- drivers/event/cnxk/cn10k_eventdev.c | 8 ++++---- drivers/event/cnxk/cn20k_eventdev.c | 8 ++++---- drivers/event/cnxk/cn9k_eventdev.c | 6 +++--- drivers/event/cnxk/cnxk_eventdev.c | 2 +- drivers/event/dlb2/pf/dlb2_pf.c | 2 +- drivers/event/skeleton/skeleton_eventdev.c | 2 +- lib/eventdev/eventdev_pmd.h | 2 +- lib/eventdev/eventdev_pmd_pci.h | 4 ++-- lib/eventdev/eventdev_pmd_vdev.h | 2 +- lib/eventdev/rte_eventdev.c | 14 +++++++------- 10 files changed, 25 insertions(+), 25 deletions(-)
drivers/event/cnxk/cn10k_eventdev.c +4 -4
@@ -921,7 +921,7 @@ static int cn10k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, uint32_t *caps) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", ENOTSUP); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn10k", ENOTSUP);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,ENOTSUP ); *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
@@ -939,7 +939,7 @@ cn10k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, {int ret; -CNXK_VALID_DEV_OR_ERR_RET (event_dev->dev,"event_cn10k" ,EINVAL ); +CNXK_VALID_DEV_OR_ERR_RET (event_dev->device,"event_cn10k" ,EINVAL );CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,EINVAL );cn10k_sso_fp_fns_set ((struct rte_eventdev *)(uintptr_t )event_dev);
@@ -954,7 +954,7 @@ static int cn10k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn10k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,EINVAL );return cnxk_crypto_adapter_qp_del (cdev, queue_pair_id);
@@ -973,7 +973,7 @@ cn10k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,const struct rte_cryptodev *cdev, struct rte_event_crypto_adapter_vector_limits *limits) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn10k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn10k" ,EINVAL ); limits->log2_sz = false;
drivers/event/cnxk/cn20k_eventdev.c +4 -4
@@ -1125,7 +1125,7 @@ static int cn20k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, uint32_t *caps) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", ENOTSUP); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn20k", ENOTSUP);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,ENOTSUP ); *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
@@ -1142,7 +1142,7 @@ cn20k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, const struct r {int ret; -CNXK_VALID_DEV_OR_ERR_RET (event_dev->dev,"event_cn20k" ,EINVAL ); +CNXK_VALID_DEV_OR_ERR_RET (event_dev->device,"event_cn20k" ,EINVAL );CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,EINVAL );cn20k_sso_fp_fns_set ((struct rte_eventdev *)(uintptr_t )event_dev);
@@ -1157,7 +1157,7 @@ static int cn20k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn20k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,EINVAL );return cnxk_crypto_adapter_qp_del (cdev, queue_pair_id);
@@ -1175,7 +1175,7 @@ cn20k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,const struct rte_cryptodev *cdev, struct rte_event_crypto_adapter_vector_limits *limits) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn20k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn20k" ,EINVAL ); limits->log2_sz = false;
drivers/event/cnxk/cn9k_eventdev.c +3 -3
@@ -1038,7 +1038,7 @@ static int cn9k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, uint32_t *caps) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", ENOTSUP); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn9k", ENOTSUP);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn9k" ,ENOTSUP ); *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
@@ -1055,7 +1055,7 @@ cn9k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, {int ret; -CNXK_VALID_DEV_OR_ERR_RET (event_dev->dev,"event_cn9k" ,EINVAL ); +CNXK_VALID_DEV_OR_ERR_RET (event_dev->device,"event_cn9k" ,EINVAL );CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn9k" ,EINVAL );cn9k_sso_fp_fns_set ((struct rte_eventdev *)(uintptr_t )event_dev);
@@ -1070,7 +1070,7 @@ static int cn9k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id) { - CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", EINVAL); + CNXK_VALID_DEV_OR_ERR_RET(event_dev->device, "event_cn9k", EINVAL);CNXK_VALID_DEV_OR_ERR_RET (cdev->device,"crypto_cn9k" ,EINVAL );return cnxk_crypto_adapter_qp_del (cdev, queue_pair_id);
drivers/event/cnxk/cnxk_eventdev.c +1 -1
@@ -654,7 +654,7 @@ cnxk_sso_init(struct rte_eventdev *event_dev)return -ENOMEM ; } - pci_dev =RTE_BUS_DEVICE (event_dev->dev, *pci_dev); + pci_dev =RTE_BUS_DEVICE (event_dev->device, *pci_dev); dev->sso.pci_dev = pci_dev; *(uint64_t *)mz->addr = (uint64_t )dev;
drivers/event/dlb2/pf/dlb2_pf.c +1 -1
@@ -784,7 +784,7 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)dlb2_pf_iface_fn_ptrs_init (); - pci_dev =RTE_BUS_DEVICE (eventdev->dev, *pci_dev); + pci_dev =RTE_BUS_DEVICE (eventdev->device, *pci_dev);if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { dlb2 =dlb2_pmd_priv (eventdev);/* rte_zmalloc_socket mem */
drivers/event/skeleton/skeleton_eventdev.c +1 -1
@@ -332,7 +332,7 @@ skeleton_eventdev_init(struct rte_eventdev *eventdev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; - pci_dev =RTE_BUS_DEVICE (eventdev->dev, *pci_dev); + pci_dev =RTE_BUS_DEVICE (eventdev->device, *pci_dev); skel->reg_base = (uintptr_t )pci_dev->mem_resource[0 ].addr;if (!skel->reg_base) {
lib/eventdev/eventdev_pmd.h +1 -1
@@ -156,7 +156,7 @@ struct __rte_cache_aligned rte_eventdev {/**< Pointer to device data */ struct eventdev_ops *dev_ops;/**< Functions exported by PMD */ -struct rte_device *dev; +struct rte_device *device;/**< Device info. supplied by probing */ uint8_t attached : 1;
lib/eventdev/eventdev_pmd_pci.h +2 -2
@@ -68,7 +68,7 @@ rte_event_pmd_pci_probe_named(struct rte_pci_driver *pci_drv, "device data"); } - eventdev->dev = &pci_dev->device; + eventdev->device = &pci_dev->device;/* Invoke PMD device initialization function */ retval =devinit (eventdev);
@@ -150,7 +150,7 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,/* Free event device */ rte_event_pmd_release (eventdev); - eventdev->dev =NULL ; + eventdev->device =NULL ;return 0 ; }
lib/eventdev/eventdev_pmd_vdev.h +1 -1
@@ -67,7 +67,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,rte_panic ("Cannot allocate memzone for private device" " data" ); } - eventdev->dev = &vdev->device; + eventdev->device = &vdev->device;return eventdev; }
lib/eventdev/rte_eventdev.c +7 -7
@@ -68,8 +68,8 @@ rte_event_dev_get_dev_id(const char *name)for (i =0 ; i < eventdev_globals.nb_devs; i++) { cmp = (strncmp (rte_event_devices[i].data->name, name,RTE_EVENTDEV_NAME_MAX_LEN ) ==0 ) || - (rte_event_devices[i].dev ? (strncmp ( - rte_event_devices[i].dev->driver->name, name, + (rte_event_devices[i].device ? (strncmp ( + rte_event_devices[i].device->driver->name, name,RTE_EVENTDEV_NAME_MAX_LEN ) ==0 ) :0 );if (cmp && (rte_event_devices[i].attached ==RTE_EVENTDEV_ATTACHED )) {
@@ -114,9 +114,9 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info) dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns; - dev_info->dev = dev->dev; -if (dev->dev !=NULL && dev->dev->driver !=NULL ) - dev_info->driver_name = dev->dev->driver->name; + dev_info->dev = dev->device; +if (dev->device !=NULL && dev->device->driver !=NULL ) + dev_info->driver_name = dev->device->driver->name;rte_eventdev_trace_info_get (dev_id, dev_info, dev_info->dev);
@@ -1812,8 +1812,8 @@ handle_dev_info(const char *cmd __rte_unused,rte_tel_data_start_dict (d);rte_tel_data_add_dict_int (d,"dev_id" , dev_id); -rte_tel_data_add_dict_string (d,"dev_name" , dev->dev->name); -rte_tel_data_add_dict_string (d,"dev_driver" , dev->dev->driver->name); +rte_tel_data_add_dict_string (d,"dev_name" , dev->device->name); +rte_tel_data_add_dict_string (d,"dev_driver" , dev->device->driver->name);rte_tel_data_add_dict_string (d,"state" , dev->data->dev_started ?"started" :"stopped" );rte_tel_data_add_dict_int (d,"socket_id" , dev->data->socket_id);
Signature · 1 line
2.53.0