eal: allow hotplug to skip an already probed device
Subsystems (6)
RFC 1/1 eal: allow hotplug to skip an already probed device
In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
On the opposite, we could require rte_eal_hotplug_add() to try to add all matching devices, and fail if one is already probed.
That's why a new parameter is added to specify if the function must fail or not when trying to add an already probed device.
---
This patch contains only the change in the function itself as RFC.
This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_eal/common/eal_common_dev.c | 4 +++- lib/librte_eal/common/include/rte_dev.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-)
lib/librte_eal/common/eal_common_dev.c +3 -1
@@ -128,7 +128,7 @@ int rte_eal_dev_detach(struct rte_device *dev) } int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs) +const char *devargs,bool fail_existing) {struct rte_bus *bus;struct rte_device *dev;
@@ -173,6 +173,8 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn }if (dev->driver !=NULL ) { +if (!fail_existing) +return 0 ;RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }
lib/librte_eal/common/include/rte_dev.h +4 -1
@@ -201,11 +201,14 @@ int rte_eal_dev_detach(struct rte_device *dev);* capable of handling it and pass it to the driver probing function. * @param devargs * Device arguments to be passed to the driver. +* @param fail_existing +* If true and a matching device is already probed, then return -EEXIST. +* If false, then skip the already probed device without returning an error. * @return * 0 on success, negative on error. */ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, -const char *devargs); +const char *devargs,bool fail_existing);/** * @warning
Signature · 1 line
2.18.0
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Saturday, September 08, 2018 2:10 AM
To: [email protected]
Cc: [email protected]
Subject: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed device
Quoted 8 lines
In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3] It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
When having devargs with representors ("dbdf,representor=<args>") there is actually just one PCI device to probe (whose address is "dbdf", the master) while the representors themselves are net devices all using the same PCI "dbdf" address. The way to see it: when running "lspci": only the "dpdf" PCI device appears while when executing "ifconfig" - all representors are shown as net devices.
When calling rte_eal_hotplug_add() for the first time there is a flow which eventually calls the PMD probe callback (e.g. mlx5_pci_probe() in case of mlx5 PMD).
When calling rte_eal_hotplug_add() for several times we should skip failures till we reach the PMD probe callback.
Skipping failures can be done as follows:
1. In file ./lib/librte_eal/common/eal_common_dev.c, function: rte_eal_hotplug_add(), remove the following code:
if (dev->driver != NULL) {
RTE_LOG(ERR, EAL, "Device is already plugged\n");
return -EEXIST}2. In file ./drivers/bus/pci/pci_common.cm function: pci_probe_all_drivers(), remove the following code:
/* Check if a driver is already loaded */ if (dev->driver != NULL)
return -1;
However the substantial major changes are in each individual PMD probe callback when it is called several times with different devargs. For example it should not fail an already probed PCI device and just create new eth devices for new representors.
Quoted 6 lines
On the opposite, we could require
rte_eal_hotplug_add()to try to add all matching devices, and fail if one is already probed.That's why a new parameter is added to specify if the function must fail or not when trying to add an already probed device.
Please note this new parameter ("fail_existing") will have to be propagated to all PMD probe callbacks.
Otherwise, in case (fail_existing == false) a second call to rte_eal_hotplug_add() will call the PMD probe callback, which may fail unless it is aware of "fail_existing" parameter.
Alternatively "fail_existing" may be better named "enable_multi_probes".
Anyway - if the PMD probe() callback has to be updated to return a success/failure value (for more than one probe) - maybe we do not need a new parameter and can rely on the PMD probe() callback the take the decision by returning success/failure value.
The counter part of rte_eal_hotplug_add() is rte_eal_hotplug_remove() which must be updated as well. For example when representors 1 and 2 exist - then removing just representor 1 will have to make sure that the PCI device used for both representors is not unplugged since representor 2 is not removed and it uses the same PCI device as representor 1.
Quoted 58 lines
Signed-off-by Thomas Monjalon <[email protected]>---
This patch contains only the change in the function itself as RFC.This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_eal/common/eal_common_dev.c | 4 +++- lib/librte_eal/common/include/rte_dev.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_eal/common/eal_common_dev.c +1
-1@@ -128,7 +128,7 @@ int rte_eal_dev_detach(struct rte_device *dev) } int __rte_experimental rte_eal_hotplug_add(const char *busname, constchar *devname, -const char *devargs) +const char *devargs,bool fail_existing) {struct rte_bus *bus;struct rte_device *dev;@@ -173,6 +173,8 @@ int __rte_experimental rte_eal_hotplug_add(constchar *busname, const char *devn
lib/librte_eal/common/eal_common_dev.c +2
-0}if (dev->driver !=NULL ) { +if (!fail_existing) +return 0 ;RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }lib/librte_eal/common/include/rte_dev.h +4
-1@@ -201,11 +201,14 @@ int rte_eal_dev_detach(struct rte_device *dev);* capable of handling it and pass it to the driver probing function. * @param devargs * Device arguments to be passed to the driver. +* @param fail_existing +* If true and a matching device is already probed, then return -EEXIST. +* If false, then skip the already probed device without returning an error. * @return * 0 on success, negative on error. */ int __rte_experimental rte_eal_hotplug_add(const char *busname, constchar *devname, -const char *devargs); +const char *devargs,bool fail_existing);/** * @warning
--
2.18.0
Quoted 82 lines
-----Original Message-----
From: Ophir Munk
Sent: Thursday, September 13, 2018 9:30 AM
To: Thomas Monjalon <[email protected]>; [email protected]
Cc: [email protected]; Olga Shern <[email protected]>; Shahaf Shuler <[email protected]>; Asaf Penso <[email protected]>
Subject: RE: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed deviceQuoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Saturday, September 08, 2018 2:10 AM
To: [email protected]
Cc: [email protected]
Subject: [dpdk-dev] [RFC] eal: allow hotplug to skip an already probed deviceIn the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3] It will become a more frequent case when introducing wildcards and ranges in the new
devargs syntax.
Quoted 5 lines
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
When having devargs with representors ("dbdf,representor=<args>") there is actually just one PCI device to probe (whose address is "dbdf", the master) while the representors themselves are net devices all using the same PCI "dbdf" address.
The way to see it: when running "lspci": only the "dpdf" PCI device appears while when executing "ifconfig" - all representors are shown as net devices. When callingrte_eal_hotplug_add()for the first time there is a flow which eventually calls the PMD probe callback (e.g.mlx5_pci_probe()in case of mlx5 PMD).
When callingrte_eal_hotplug_add()for several times we should skip failures till we reach the PMD probe callback.Skipping failures can be done as follows:
1. In file./lib/librte_eal/common/eal_common_dev.c, function:rte_eal_hotplug_add(), remove the following code:if (dev->driver != NULL) { RTE_LOG(ERR, EAL, "Device is already plugged\n"); return -EEXIST}2. In file
./drivers/bus/pci/pci_common.cmfunction:pci_probe_all_drivers(), remove the following code:/* Check if a driver is already loaded */ if (
dev->driver!= NULL)return -1;However the substantial major changes are in each individual PMD probe callback when it is called several times with different devargs. For example it should not fail an already probed PCI device and just create new eth devices for new representors.
Quoted 6 lines
On the opposite, we could require
rte_eal_hotplug_add()to try to add all matching devices, and fail if one is already probed.That's why a new parameter is added to specify if the function must fail or not when trying to add an already probed device.
Please note this new parameter ("
fail_existing") will have to be propagated to all PMD probe callbacks.
Otherwise, in case (fail_existing== false) a second call torte_eal_hotplug_add()will call the PMD probe callback, which may fail unless it is aware of "fail_existing" parameter.
Alternatively "fail_existing" may be better named "enable_multi_probes". Anyway - if the PMDprobe()callback has to be updated to return a success/failure value (for more than one probe) - maybe we do not need a new parameter and can rely on the PMDprobe()callback the take the decision by returning success/failure value.
Quoted 6 lines
The counter part of
rte_eal_hotplug_add()isrte_eal_hotplug_remove()which must be updated as well. For example when representors 1 and 2 exist
- then removing just representor 1 will have to make sure that the PCI device used for both representors is not unplugged since representor 2 is not removed and it uses the same PCI device as representor 1.
To make it clearer: the flow initiated by calling rte_eal_hotplug_removed() should eventually call the PMD remote() callback which in turn should manage a reference count to all representor devices and decide which ones should be closed.
Quoted 59 lines
Quoted 40 lines
Signed-off-by Thomas Monjalon <[email protected]>---
This patch contains only the change in the function itself as RFC.This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_eal/common/eal_common_dev.c | 4 +++- lib/librte_eal/common/include/rte_dev.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_eal/common/eal_common_dev.c +1
-1@@ -128,7 +128,7 @@ int rte_eal_dev_detach(struct rte_device *dev) } int __rte_experimental rte_eal_hotplug_add(const char *busname, constchar *devname, -const char *devargs) +const char *devargs,bool fail_existing) {struct rte_bus *bus;struct rte_device *dev;@@ -173,6 +173,8 @@ int __rte_experimental rte_eal_hotplug_add(constchar *busname, const char *devn
lib/librte_eal/common/eal_common_dev.c +2
-0}if (dev->driver !=NULL ) { +if (!fail_existing) +return 0 ;RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }lib/librte_eal/common/include/rte_dev.h +0
-0lib/librte_eal/common/include/rte_dev.h int rte_eal_dev_detach(struct rte_device *dev); · line 206
Quoted 6 lines
lib/librte_eal/common/include/rte_dev.h +3
-0@@ -201,11 +201,14 @@ int rte_eal_dev_detach(struct rte_device *dev);* capable of handling it and pass it to the driver probing function. * @param devargs * Device arguments to be passed to the driver. +* @param fail_existing +* If true and a matching device is already probed, then return -EEXIST. +* If false, then skip the already probed device without returning an error.
Quoted 12 lines
lib/librte_eal/common/include/rte_dev.h +1
-1* @return * 0 on success, negative on error. */ int __rte_experimental rte_eal_hotplug_add(const char *busname, constchar *devname, -const char *devargs); +const char *devargs,bool fail_existing);/** * @warning
--
2.18.0
v2 cover eal: allow hotplug to skip an already probed device
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
The idea is to ease probing of range of ports attached to the same rte_device.
I becomes possible to allow probing again the same device but with a bigger range of ports in the devargs.
Instead of adding a parameter to the hotplug functions, as in the RFC, the check of an already probed device is moved to the PMDs. It gives flexibility to drivers for managing range of ports.
This series is based on top of
https://patches.dpdk.org/project/dpdk/list/?series=1579
Depends on: project/dpdk/list/?series=1579
(proposed syntax for dependencies)
Thomas Monjalon (3):
drivers/bus: move driver assignment to end of probing
eal: add function to query device status
eal: allow probing a device again
drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 22 +++++++++-------- drivers/bus/pci/pci_common.c | 20 +++++++++------- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 12 ++++++---- drivers/bus/vmbus/vmbus_common.c | 28 ++++++++++++---------- drivers/common/qat/Makefile | 3 ++- drivers/common/qat/meson.build | 1 + drivers/common/qat/qat_device.c | 3 +++ drivers/compress/octeontx/otx_zip_pmd.c | 3 +++ drivers/crypto/virtio/Makefile | 1 + drivers/crypto/virtio/meson.build | 1 + drivers/crypto/virtio/virtio_cryptodev.c | 3 +++ drivers/event/octeontx/ssovf_probe.c | 6 +++++ drivers/event/skeleton/Makefile | 1 + drivers/event/skeleton/meson.build | 1 + drivers/mempool/octeontx/Makefile | 1 + drivers/mempool/octeontx/meson.build | 2 ++ drivers/mempool/octeontx/octeontx_fpavf.c | 3 +++ drivers/net/ark/Makefile | 1 + drivers/net/ark/meson.build | 1 + drivers/net/avf/Makefile | 1 + drivers/net/avp/Makefile | 1 + drivers/net/avp/meson.build | 1 + drivers/net/axgbe/Makefile | 1 + drivers/net/axgbe/meson.build | 2 ++ drivers/net/bnx2x/Makefile | 1 + drivers/net/bnx2x/meson.build | 1 + drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/meson.build | 1 + drivers/net/cxgbe/Makefile | 1 + drivers/net/cxgbe/meson.build | 2 ++ drivers/net/e1000/Makefile | 1 + drivers/net/e1000/meson.build | 2 ++ drivers/net/enic/Makefile | 1 + drivers/net/enic/meson.build | 2 ++ drivers/net/fm10k/Makefile | 1 + drivers/net/fm10k/meson.build | 2 ++ drivers/net/i40e/i40e_ethdev.c | 3 +++ drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/ifc/ifcvf_vdpa.c | 3 +++ drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++ drivers/net/liquidio/Makefile | 1 + drivers/net/liquidio/meson.build | 1 + drivers/net/mlx4/mlx4.c | 5 +++- drivers/net/mlx5/mlx5.c | 5 +++- drivers/net/netvsc/hn_ethdev.c | 9 ++++--- drivers/net/nfp/Makefile | 1 + drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfp_net.c | 3 +++ drivers/net/octeontx/Makefile | 3 +-- drivers/net/octeontx/base/meson.build | 2 +- drivers/net/octeontx/base/octeontx_pkivf.c | 3 +++ drivers/net/octeontx/base/octeontx_pkovf.c | 3 +++ drivers/net/qede/Makefile | 1 + drivers/net/qede/meson.build | 2 ++ drivers/net/szedata2/Makefile | 1 + drivers/net/szedata2/meson.build | 1 + drivers/net/szedata2/rte_eth_szedata2.c | 3 +++ drivers/net/thunderx/Makefile | 1 + drivers/net/thunderx/meson.build | 2 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 +++ lib/librte_eal/common/eal_common_dev.c | 12 ++++++---- lib/librte_eal/common/include/rte_dev.h | 18 ++++++++++++-- lib/librte_eal/rte_eal_version.map | 1 + lib/librte_ethdev/rte_ethdev_pci.h | 3 +++ lib/librte_eventdev/rte_eventdev_pmd_pci.h | 3 +++ 68 files changed, 187 insertions(+), 56 deletions(-)
Signature · 1 line
2.19.0
PATCH v2 1/3 drivers/bus: move driver assignment to end of probing
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
However the rte_driver does not need to be referenced in rte_device before the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of a rte_device.
--- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - lib/librte_eal/common/include/rte_dev.h | 2 +- 9 files changed, 14 insertions(+), 21 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +4 -5
@@ -279,14 +279,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,/* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver;/* call the driver probe() function */ ret = drv->probe (afu_dev); -if (ret) { +if (ret) afu_dev->driver =NULL ; - afu_dev->device.driver =NULL ; - } +else + afu_dev->device.driver = &drv->driver;return ret; }
@@ -301,7 +300,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->driver !=NULL ) +if (afu_dev->device.driver !=NULL )return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
drivers/bus/pci/pci_common.c +3 -4
@@ -162,14 +162,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) { dev->driver =NULL ; - dev->device.driver =NULL ;return ret; } }
@@ -178,7 +176,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe (dr, dev);if (ret) { dev->driver =NULL ; - dev->device.driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources.
@@ -186,6 +183,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))rte_pci_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -246,7 +245,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) +if (dev->device.driver !=NULL )return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/pci/rte_bus_pci.h +1 -1
@@ -62,7 +62,7 @@ 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;/**< Associated driver */ +struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */
drivers/bus/vdev/vdev.c +2 -3
@@ -149,10 +149,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)if (vdev_parse (name, &driver))return -1 ; - dev->device.driver = &driver->driver; ret = driver->probe (dev); -if (ret) - dev->device.driver =NULL ; +if (ret ==0 ) + dev->device.driver = &driver->driver;return ret; }
drivers/bus/vmbus/vmbus_common.c +3 -2
@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dev->device.numa_node <0 ) {VMBUS_LOG (WARNING ," Invalid NUMA socket, default to 0" );
@@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) { +if (dev->device.driver !=NULL ) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
drivers/net/i40e/i40e_vf_representor.c +0 -3
@@ -486,9 +486,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)if (representor->vf_id >= pf->vf_num)return -ENODEV ; -/** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; -/* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops;
drivers/net/mlx4/mlx4.c +0 -1
@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device;rte_eth_copy_pci_info (eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver;/* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle ){ .fd =-1 ,
drivers/net/mlx5/mlx5.c +0 -1
@@ -1081,7 +1081,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err =mlx5_uar_init_primary (eth_dev);if (err) { err = rte_errno;
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -156,7 +156,7 @@ struct rte_driver {struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ -const struct rte_driver *driver;/**< Associated driver */ +const struct rte_driver *driver;/**< Driver associated after probing */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */ };
Signature · 1 line
2.19.0
PATCH v2 2/3 eal: add function to query device status
In reply to Thomas MonjalonThe function rte_dev_is_probed() is added in order to improve semantic and enforce proper check of the probing status of a device.
It will answer this rte_device query:
Is it already successfully probed or not?
--- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- drivers/bus/pci/pci_common.c | 2 +- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/vmbus_common.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 9 ++++++++- lib/librte_eal/common/include/rte_dev.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 7 files changed, 28 insertions(+), 6 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +2 -2
@@ -300,7 +300,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->device.driver !=NULL ) +if (rte_dev_is_probed (&afu_dev->device))return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
@@ -324,7 +324,7 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (afu_dev->device.driver) +if (rte_dev_is_probed (&afu_dev->device))continue ; ret =ifpga_probe_all_drivers (afu_dev);
drivers/bus/pci/pci_common.c +1 -1
@@ -245,7 +245,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) +if (rte_dev_is_probed (&dev->device))return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/vdev/vdev.c +1 -1
@@ -479,7 +479,7 @@ vdev_probe(void)* we call each driver probe. */ -if (dev->device.driver) +if (rte_dev_is_probed (&dev->device))continue ;if (vdev_probe_all_drivers (dev)) {
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -143,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) { +if (rte_dev_is_probed (&dev->device)) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
lib/librte_eal/common/eal_common_dev.c +8 -1
@@ -74,6 +74,13 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)return strcmp (dev->name, name); } +int __rte_experimental +rte_dev_is_probed (const struct rte_device *dev) +{ +/* The field driver should be set only when the probe is successful. */ +return dev->driver !=NULL ; +} +int rte_eal_dev_attach (const char *name,const char *devargs) {struct rte_bus *bus;
@@ -184,7 +191,7 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (dev->driver !=NULL ) { +if (rte_dev_is_probed (dev)) {RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }
lib/librte_eal/common/include/rte_dev.h +14 -0
@@ -161,6 +161,20 @@ struct rte_device {struct rte_devargs *devargs;/**< Device user arguments */ }; +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Query status of a device. +* +* @param dev +* Generic device pointer. +* @return +* (int)true if already probed successfully, 0 otherwise. +*/ +__rte_experimental +int rte_dev_is_probed(const struct rte_device *dev); +/** * Attach a device to a registered driver. *
lib/librte_eal/rte_eal_version.map +1 -0
@@ -279,6 +279,7 @@ EXPERIMENTAL { rte_dev_event_callback_unregister; rte_dev_event_monitor_start; rte_dev_event_monitor_stop; + rte_dev_is_probed; rte_dev_iterator_init; rte_dev_iterator_next; rte_dev_probe;
Signature · 1 line
2.19.0
PATCH v2 3/3 eal: allow probing a device again
In reply to Thomas MonjalonIn the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existing rte_device.
That's why the checks for an already probed device are moved as PMD responsibility.
Only the PMD knows the ports attached to one rte_device.
In the case of vdev, a global check is kept in insert_vdev(), assuming that a vdev will always have only one port.
In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.
As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.
--- drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 13 ++++++----- drivers/bus/pci/pci_common.c | 15 +++++++------ drivers/bus/vdev/vdev.c | 5 +++++ drivers/bus/vmbus/vmbus_common.c | 25 +++++++++++----------- drivers/common/qat/Makefile | 3 ++- drivers/common/qat/meson.build | 1 + drivers/common/qat/qat_device.c | 3 +++ drivers/compress/octeontx/otx_zip_pmd.c | 3 +++ drivers/crypto/virtio/Makefile | 1 + drivers/crypto/virtio/meson.build | 1 + drivers/crypto/virtio/virtio_cryptodev.c | 3 +++ drivers/event/octeontx/ssovf_probe.c | 6 ++++++ drivers/event/skeleton/Makefile | 1 + drivers/event/skeleton/meson.build | 1 + drivers/mempool/octeontx/Makefile | 1 + drivers/mempool/octeontx/meson.build | 2 ++ drivers/mempool/octeontx/octeontx_fpavf.c | 3 +++ drivers/net/ark/Makefile | 1 + drivers/net/ark/meson.build | 1 + drivers/net/avf/Makefile | 1 + drivers/net/avp/Makefile | 1 + drivers/net/avp/meson.build | 1 + drivers/net/axgbe/Makefile | 1 + drivers/net/axgbe/meson.build | 2 ++ drivers/net/bnx2x/Makefile | 1 + drivers/net/bnx2x/meson.build | 1 + drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/meson.build | 1 + drivers/net/cxgbe/Makefile | 1 + drivers/net/cxgbe/meson.build | 2 ++ drivers/net/e1000/Makefile | 1 + drivers/net/e1000/meson.build | 2 ++ drivers/net/enic/Makefile | 1 + drivers/net/enic/meson.build | 2 ++ drivers/net/fm10k/Makefile | 1 + drivers/net/fm10k/meson.build | 2 ++ drivers/net/i40e/i40e_ethdev.c | 3 +++ drivers/net/ifc/ifcvf_vdpa.c | 3 +++ drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++ drivers/net/liquidio/Makefile | 1 + drivers/net/liquidio/meson.build | 1 + drivers/net/mlx4/mlx4.c | 4 ++++ drivers/net/mlx5/mlx5.c | 4 ++++ drivers/net/netvsc/hn_ethdev.c | 9 +++++--- drivers/net/nfp/Makefile | 1 + drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfp_net.c | 3 +++ drivers/net/octeontx/Makefile | 3 +-- drivers/net/octeontx/base/meson.build | 2 +- drivers/net/octeontx/base/octeontx_pkivf.c | 3 +++ drivers/net/octeontx/base/octeontx_pkovf.c | 3 +++ drivers/net/qede/Makefile | 1 + drivers/net/qede/meson.build | 2 ++ drivers/net/szedata2/Makefile | 1 + drivers/net/szedata2/meson.build | 1 + drivers/net/szedata2/rte_eth_szedata2.c | 3 +++ drivers/net/thunderx/Makefile | 1 + drivers/net/thunderx/meson.build | 2 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 +++ lib/librte_eal/common/eal_common_dev.c | 5 ----- lib/librte_eal/common/include/rte_dev.h | 2 +- lib/librte_ethdev/rte_ethdev_pci.h | 3 +++ lib/librte_eventdev/rte_eventdev_pmd_pci.h | 3 +++ 65 files changed, 152 insertions(+), 36 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -0
@@ -553,6 +553,9 @@ rte_dpaa_bus_probe(void)if (ret)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (!drv->probe || (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ))
drivers/bus/fslmc/fslmc_bus.c +3 -0
@@ -384,6 +384,9 @@ rte_fslmc_probe(void)if (!drv->probe)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ) { DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
drivers/bus/ifpga/ifpga_bus.c +8 -5
@@ -5,6 +5,7 @@#include <string.h> #include <inttypes.h> #include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <sys/queue.h>
@@ -272,16 +273,22 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv, struct rte_afu_device *afu_dev) {int ret; +bool already_probed;if (!rte_afu_match (drv, afu_dev))/* Match of device and driver failed */ return 1 ; + already_probed =rte_dev_is_probed (&afu_dev->device); +/* reference driver structure */ - afu_dev->driver = drv; +if (!already_probed) + afu_dev->driver = drv;/* call the driver probe() function */ ret = drv->probe (afu_dev); +if (already_probed) +return ret;/* no rollback if already succeeded earlier */ if (ret) afu_dev->driver =NULL ;else
@@ -299,10 +306,6 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)if (afu_dev ==NULL )return -1 ; -/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&afu_dev->device)) -return 0 ; - TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {if (ifpga_probe_one_driver (drv, afu_dev)) { ret =-1 ;
drivers/bus/pci/pci_common.c +9 -6
@@ -6,6 +6,7 @@#include <string.h> #include <inttypes.h> #include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <sys/queue.h>
@@ -123,6 +124,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) {int ret; +bool already_probed;struct rte_pci_addr *loc;if ((dr ==NULL ) || (dev ==NULL ))
@@ -153,6 +155,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, dev->device.numa_node =0 ; } + already_probed =rte_dev_is_probed (&dev->device); +RTE_LOG (INFO ,EAL ," probe driver: %x:%x %s\n" , dev->id.vendor_id, dev->id.device_id, dr->driver.name);
@@ -161,9 +165,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* This needs to be before rte_pci_map_device(), as it enables to use * driver flags for adjusting configuration. */ - dev->driver = dr; +if (!already_probed) + dev->driver = dr; -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { +if (!already_probed && (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) {
@@ -174,6 +179,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* call the driver probe() function */ ret = dr->probe (dr, dev); +if (already_probed) +return ret;/* no rollback if already succeeded earlier */ if (ret) { dev->driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&
@@ -244,10 +251,6 @@ pci_probe_all_drivers(struct rte_pci_device *dev)if (dev ==NULL )return -1 ; -/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&dev->device)) -return 0 ; -FOREACH_DRIVER_ON_PCIBUS (dr) { rc =rte_pci_probe_one_driver (dr, dev);if (rc <0 )
drivers/bus/vdev/vdev.c +5 -0
@@ -225,6 +225,11 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) dev->device.name = devargs->name;if (find_vdev (name)) { +/* +* A vdev is expected to have only one port. +* So there is no reason to try probing again, +* even with new arguments. +*/ ret = -EEXIST ; goto fail; }
drivers/bus/vmbus/vmbus_common.c +13 -12
@@ -3,6 +3,7 @@* All Rights Reserved. */ +#include <stdbool.h> #include <string.h> #include <unistd.h> #include <dirent.h>
@@ -93,6 +94,7 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr, struct rte_vmbus_device *dev) {char guid[RTE_UUID_STRLEN ]; +bool already_probed;int ret;if (!vmbus_match (dr, dev))
@@ -104,13 +106,16 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* TODO add blacklisted */ -/* map resources for device */ - ret =rte_vmbus_map_device (dev); -if (ret !=0 ) -return ret; + already_probed =rte_dev_is_probed (&dev->device); +if (!already_probed) { +/* map resources for device */ + ret =rte_vmbus_map_device (dev); +if (ret !=0 ) +return ret; -/* reference driver structure */ - dev->driver = dr; +/* reference driver structure */ + dev->driver = dr; + }if (dev->device.numa_node <0 ) {VMBUS_LOG (WARNING ," Invalid NUMA socket, default to 0" );
@@ -120,6 +125,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* call the driver probe() function */ VMBUS_LOG (INFO ," probe driver: %s" , dr->driver.name); ret = dr->probe (dr, dev); +if (already_probed) +return ret;/* no rollback if already succeeded earlier */ if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev);
@@ -142,12 +149,6 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)struct rte_vmbus_driver *dr;int rc; -/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&dev->device)) { -VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" ); -return 0 ; - } -FOREACH_DRIVER_ON_VMBUS (dr) { rc =vmbus_probe_one_driver (dr, dev);if (rc <0 )/* negative is an error */
drivers/common/qat/Makefile +2 -1
@@ -8,6 +8,8 @@ QAT_CRYPTO_DIR := $(RTE_SDK)/drivers/crypto/qat QAT_COMPRESS_DIR := $(RTE_SDK)/drivers/compress/qat VPATH=$(QAT_CRYPTO_DIR):$(QAT_COMPRESS_DIR) +CFLAGS += -DALLOW_EXPERIMENTAL_API + # external library include paths CFLAGS += -I$(SRCDIR)/qat_adf CFLAGS += -I$(SRCDIR)
@@ -16,7 +18,6 @@ CFLAGS += -I$(QAT_COMPRESS_DIR) ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y) - CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_compressdev SRCS-y += qat_comp.c SRCS-y += qat_comp_pmd.c
drivers/common/qat/meson.build +1 -0
@@ -12,3 +12,4 @@ qat_sources = files('qat_common.c', qat_includes = [include_directories('.', 'qat_adf')] qat_ext_deps = [] qat_cflags = [] +allow_experimental_apis = true
drivers/common/qat/qat_device.c +3 -0
@@ -194,6 +194,9 @@ static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->addr.devid, pci_dev->addr.function); +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; + qat_pci_dev =qat_pci_device_allocate (pci_dev);if (qat_pci_dev ==NULL )return -ENODEV ;
drivers/compress/octeontx/otx_zip_pmd.c +3 -0
@@ -569,6 +569,9 @@ zip_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, (unsigned int )pci_dev->id.vendor_id, (unsigned int)pci_dev->id.device_id); +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +rte_pci_device_name (&pci_dev->addr, compressdev_name,sizeof (compressdev_name));
drivers/crypto/virtio/Makefile +1 -0
@@ -14,6 +14,7 @@ LIB = librte_pmd_virtio_crypto.a CFLAGS += -I$(RTE_SDK)/lib/librte_vhost CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API EXPORT_MAP := rte_pmd_virtio_crypto_version.map
drivers/crypto/virtio/meson.build +1 -0
@@ -6,3 +6,4 @@ deps += 'bus_pci' name = 'virtio_crypto' sources = files('virtio_cryptodev.c', 'virtio_pci.c', 'virtio_rxtx.c', 'virtqueue.c') +allow_experimental_apis = true
drivers/crypto/virtio/virtio_cryptodev.c +3 -0
@@ -1439,6 +1439,9 @@ crypto_virtio_pci_probe( pci_dev->addr.devid, pci_dev->addr.function); +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +rte_pci_device_name (&pci_dev->addr, name,sizeof (name));return crypto_virtio_create (name, pci_dev, &init_params);
drivers/event/octeontx/ssovf_probe.c +6 -0
@@ -150,6 +150,9 @@ ssowvf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +if (pci_dev->mem_resource[0 ].addr ==NULL || pci_dev->mem_resource[2 ].addr ==NULL || pci_dev->mem_resource[4 ].addr ==NULL ) {
@@ -230,6 +233,9 @@ ssovf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +if (pci_dev->mem_resource[0 ].addr ==NULL || pci_dev->mem_resource[2 ].addr ==NULL ) { mbox_log_err("Empty bars %p %p",
drivers/event/skeleton/Makefile +1 -0
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_skeleton_event.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_eventdev LDLIBS += -lrte_pci -lrte_bus_pci
drivers/event/skeleton/meson.build +1 -0
@@ -3,3 +3,4 @@ sources = files('skeleton_eventdev.c') deps += ['bus_pci', 'bus_vdev'] +allow_experimental_apis = true
drivers/mempool/octeontx/Makefile +1 -0
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_mempool_octeontx.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += $(WERROR_FLAGS) CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx/ EXPORT_MAP := rte_mempool_octeontx_version.map
drivers/mempool/octeontx/meson.build +2 -0
@@ -5,4 +5,6 @@ sources = files('octeontx_fpavf.c', 'rte_mempool_octeontx.c' ) +allow_experimental_apis = true + deps += ['mbuf', 'bus_pci', 'common_octeontx']
drivers/mempool/octeontx/octeontx_fpavf.c +3 -0
@@ -764,6 +764,9 @@ fpavf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +if (pci_dev->mem_resource[0 ].addr ==NULL ) {fpavf_log_err ("Empty bars %p " , pci_dev->mem_resource[0 ].addr);return -ENODEV ;
drivers/net/ark/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_ark.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 -I./ CFLAGS += $(WERROR_FLAGS) -Werror
drivers/net/ark/meson.build +1 -0
@@ -11,3 +11,4 @@ sources = files('ark_ddm.c', 'ark_pktgen.c', 'ark_rqp.c', 'ark_udm.c') +allow_experimental_apis = true
drivers/net/avf/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_avf.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash
drivers/net/avp/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_avp.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
drivers/net/avp/meson.build +1 -0
@@ -3,3 +3,4 @@ sources = files('avp_ethdev.c') install_headers('rte_avp_common.h', 'rte_avp_fifo.h') +allow_experimental_apis = true
drivers/net/axgbe/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_axgbe.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS)
drivers/net/axgbe/meson.build +2 -0
@@ -17,3 +17,5 @@ cflags += '-Wno-cast-qual' if arch_subdir == 'x86' sources += files('axgbe_rxtx_vec_sse.c') endif + +allow_experimental_apis = true
drivers/net/bnx2x/Makefile +1 -0
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_bnx2x.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -DZLIB_CONST
drivers/net/bnx2x/meson.build +1 -0
@@ -12,3 +12,4 @@ sources = files('bnx2x.c', 'bnx2x_vfpf.c', 'ecore_sp.c', 'elink.c') +allow_experimental_apis = true
drivers/net/bnxt/Makefile +1 -0
@@ -15,6 +15,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map LIBABIVER := 2 +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
drivers/net/bnxt/meson.build +1 -0
@@ -18,3 +18,4 @@ sources = files('bnxt_cpr.c', 'bnxt_util.c', 'bnxt_vnic.c', 'rte_pmd_bnxt.c') +allow_experimental_apis = true
drivers/net/cxgbe/Makefile +1 -0
@@ -13,6 +13,7 @@ CFLAGS += -I$(SRCDIR)/base/ CFLAGS += -I$(SRCDIR) CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API EXPORT_MAP := rte_pmd_cxgbe_version.map
drivers/net/cxgbe/meson.build +2 -0
@@ -14,3 +14,5 @@ sources = files('cxgbe_ethdev.c', 'base/t4_hw.c', 'base/t4vf_hw.c') includes += include_directories('base') + +allow_experimental_apis = true
drivers/net/e1000/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_e1000.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
drivers/net/e1000/meson.build +2 -0
@@ -15,3 +15,5 @@ sources = files( ) includes += include_directories('base') + +allow_experimental_apis = true
drivers/net/enic/Makefile +1 -0
@@ -13,6 +13,7 @@ EXPORT_MAP := rte_pmd_enic_version.map LIBABIVER := 1 +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -I$(SRCDIR)/base/ CFLAGS += -I$(SRCDIR) CFLAGS += -O3
drivers/net/enic/meson.build +2 -0
@@ -17,3 +17,5 @@ sources = files( ) deps += ['hash'] includes += include_directories('base') + +allow_experimental_apis = true
drivers/net/fm10k/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_fm10k.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS)
drivers/net/fm10k/meson.build +2 -0
@@ -14,3 +14,5 @@ if arch_subdir == 'x86' endif includes += include_directories('base') + +allow_experimental_apis = true
drivers/net/i40e/i40e_ethdev.c +3 -0
@@ -633,6 +633,9 @@ eth_i40e_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_eth_devargs eth_da = { .nb_representor_ports =0 };int i, retval; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +if (pci_dev->device.devargs) { retval =rte_eth_devargs_parse (pci_dev->device.devargs->args, ð_da);
drivers/net/ifc/ifcvf_vdpa.c +3 -0
@@ -682,6 +682,9 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; + list =rte_zmalloc ("ifcvf" ,sizeof (*list),0 );if (list ==NULL ) goto error;
drivers/net/ixgbe/ixgbe_ethdev.c +3 -0
@@ -1735,6 +1735,9 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_eth_devargs eth_da;int i, retval; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +if (pci_dev->device.devargs) { retval =rte_eth_devargs_parse (pci_dev->device.devargs->args, ð_da);
drivers/net/liquidio/Makefile +1 -0
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_lio.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)/base -I$(SRCDIR) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
drivers/net/liquidio/meson.build +1 -0
@@ -6,3 +6,4 @@ sources = files('base/lio_23xx_vf.c', 'lio_ethdev.c', 'lio_rxtx.c') includes += include_directories('base') +allow_experimental_apis = true
drivers/net/mlx4/mlx4.c +4 -0
@@ -523,6 +523,10 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) (void )pci_drv;assert (pci_drv == &mlx4_driver); + +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; + list = mlx4_glue->get_device_list (&i);if (list ==NULL ) { rte_errno = errno;
drivers/net/mlx5/mlx5.c +4 -0
@@ -1296,6 +1296,10 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,assert (pci_drv == &mlx5_driver); errno =0 ; + +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; + ibv_list = mlx5_glue->get_device_list (&ret);if (!ibv_list) { rte_errno = errno ? errno :ENOSYS ;
drivers/net/netvsc/hn_ethdev.c +6 -3
@@ -75,9 +75,6 @@ eth_dev_vmbus_allocate(struct rte_vmbus_device *dev, size_t private_data_size)struct rte_eth_dev *eth_dev;const char *name; -if (!dev) -return NULL ; - name = dev->device.name;if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) {
@@ -824,6 +821,12 @@ static int eth_hn_probe(struct rte_vmbus_driver *drv __rte_unused,PMD_INIT_FUNC_TRACE (); +if (!dev) +return -EINVAL ; + +if (rte_dev_is_probed (&dev->device)) +return -EEXIST ; + eth_dev =eth_dev_vmbus_allocate (dev,sizeof (struct hn_data ));if (!eth_dev)return -ENOMEM ;
drivers/net/nfp/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_nfp.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS)
drivers/net/nfp/meson.build +1 -0
@@ -14,3 +14,4 @@ sources = files('nfpcore/nfp_cpp_pcie_ops.c', 'nfpcore/nfp_nsp_eth.c', 'nfpcore/nfp_hwinfo.c', 'nfp_net.c') +allow_experimental_apis = true
drivers/net/nfp/nfp_net.c +3 -0
@@ -3121,6 +3121,9 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,if (!dev)return ret; +if (rte_dev_is_probed (&dev->device)) +return -EEXIST ; +/* * When device bound to UIO, the device could be used, by mistake, * by two DPDK apps, and the UIO driver does not avoid it. This
drivers/net/octeontx/Makefile +1 -2
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_octeontx.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += $(WERROR_FLAGS) CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx/ CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx/
@@ -44,8 +45,6 @@ else CFLAGS_octeontx_rxtx.o += -O3 -Ofast endif -CFLAGS_octeontx_ethdev.o += -DALLOW_EXPERIMENTAL_API - LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_common_octeontx LDLIBS += -lrte_mempool_octeontx
drivers/net/octeontx/base/meson.build +1 -1
@@ -14,7 +14,7 @@ foreach d: depends endforeach base_lib = static_library('octeontx_base', sources, - c_args: cflags, + c_args: cflags + ['-DALLOW_EXPERIMENTAL_API'], dependencies: static_objs, )
drivers/net/octeontx/base/octeontx_pkivf.c +3 -0
@@ -120,6 +120,9 @@ pkivf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +return 0 ; }
drivers/net/octeontx/base/octeontx_pkovf.c +3 -0
@@ -536,6 +536,9 @@ pkovf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +if (pci_dev->mem_resource[0 ].addr ==NULL || pci_dev->mem_resource[2 ].addr ==NULL ) { octeontx_log_err("Empty bars %p %p",
drivers/net/qede/Makefile +1 -0
@@ -10,6 +10,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_qede.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
drivers/net/qede/meson.build +2 -0
@@ -10,3 +10,5 @@ sources = files( 'qede_main.c', 'qede_rxtx.c', ) + +allow_experimental_apis = true
drivers/net/szedata2/Makefile +1 -0
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_szedata2.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lsze2
drivers/net/szedata2/meson.build +1 -0
@@ -5,3 +5,4 @@ dep = cc.find_library('sze2', required: false) build = dep.found() ext_deps += dep sources = files('rte_eth_szedata2.c') +allow_experimental_apis = true
drivers/net/szedata2/rte_eth_szedata2.c +3 -0
@@ -1804,6 +1804,9 @@ static int szedata2_eth_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,PMD_INIT_FUNC_TRACE (); +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; + ret =get_port_info (pci_dev, &port_count, port_info,SZEDATA2_MAX_PORTS );if (ret !=0 )
drivers/net/thunderx/Makefile +1 -0
@@ -9,6 +9,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_thunderx_nicvf.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += $(WERROR_FLAGS) LDLIBS += -lm
drivers/net/thunderx/meson.build +2 -0
@@ -18,3 +18,5 @@ if cc.has_argument('-Wno-maybe-uninitialized') endif includes += include_directories('base') + +allow_experimental_apis = true
drivers/raw/ifpga_rawdev/ifpga_rawdev.c +3 -0
@@ -378,6 +378,9 @@ ifpga_rawdev_create(struct rte_pci_device *pci_dev, goto cleanup; } +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +memset (name,0 ,sizeof (name));snprintf (name,RTE_RAWDEV_NAME_MAX_LEN ,"IFPGA:%x:%02x.%x" , pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
lib/librte_eal/common/eal_common_dev.c +0 -5
@@ -191,11 +191,6 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (rte_dev_is_probed (dev)) { -RTE_LOG (ERR ,EAL ,"Device is already plugged\n" ); -return -EEXIST ; - } - ret = da->bus->plug (dev);if (ret) { RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -158,7 +158,7 @@ struct rte_device {const char *name;/**< Device name */ const struct rte_driver *driver;/**< Driver associated after probing */ int numa_node;/**< NUMA node connection */ -struct rte_devargs *devargs;/**< Device user arguments */ +struct rte_devargs *devargs;/**< Arguments for latest probing */ };/**
lib/librte_ethdev/rte_ethdev_pci.h +3 -0
@@ -167,6 +167,9 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev,struct rte_eth_dev *eth_dev;int ret; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; + eth_dev =rte_eth_dev_pci_allocate (pci_dev, private_data_size);if (!eth_dev)return -ENOMEM ;
lib/librte_eventdev/rte_eventdev_pmd_pci.h +3 -0
@@ -50,6 +50,9 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,if (devinit ==NULL )return -EINVAL ; +if (rte_dev_is_probed (&pci_dev->device)) +return -EEXIST ; +rte_pci_device_name (&pci_dev->addr, eventdev_name,sizeof (eventdev_name));
Signature · 1 line
2.19.0
Re: [PATCH v2 3/3] eal: allow probing a device again
Quoted 26 lines · Thomas Monjalon
In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existingrte_device.That's why the checks for an already probed device are moved as PMD responsibility.
Only the PMD knows the ports attached to onerte_device.In the case of vdev, a global check is kept in
insert_vdev(), assuming that a vdev will always have only one port.
In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the
rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.Signed-off-by Thomas Monjalon <[email protected]>---
...
Quoted 1 line
Hey Thomas, did you consider of adding a driver flags to the rte_driver structure which has a driver re-probe flag. If this flag is disabled by default, current drivers could be left unmodified and any new driver which want to support re-probing enable this flag and then support the functionality in there probe function. Then we could check this flag in the bus driver on making a call on whether to re-probe.
Declan
Re: [PATCH v2 3/3] eal: allow probing a device again
04/10/2018 11:44, Doherty, Declan:
Quoted 28 lines · Thomas Monjalon
Quoted 19 lines
In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existingrte_device.That's why the checks for an already probed device are moved as PMD responsibility.
Only the PMD knows the ports attached to onerte_device.In the case of vdev, a global check is kept in
insert_vdev(), assuming that a vdev will always have only one port.
In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.Quoted 7 lines
As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the
rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.Signed-off-by Thomas Monjalon <[email protected]>---
Quoted 6 lines
Hey Thomas, did you consider of adding a driver flags to the
rte_driverstructure which has a driver re-probe flag. If this flag is disabled by default, current drivers could be left unmodified and any new driver which want to support re-probing enable this flag and then support the functionality in there probe function. Then we could check this flag in the bus driver on making a call on whether to re-probe.
I really don't know what is best:
- have a standard expectation for all drivers
- add a driver flag in order to remove a check
If your option is preferred, where the flag should be added?
- in rte_driver which has no flag at all so far
- in rte_pci_driver.drv_flags which may be enough (at least for now)
Opinions?
v3 cover eal: allow hotplug to skip an already probed device
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
The idea is to ease probing of range of ports attached to the same rte_device.
I becomes possible to allow probing again the same device but with a bigger range of ports in the devargs.
Instead of adding a parameter to the hotplug functions, as in the RFC, the check of an already probed device is moved to the bus and enabled PMDs. It gives flexibility to drivers for managing range of ports.
This series is based on top of
https://patches.dpdk.org/project/dpdk/list/?series=1734
Depends on: project/dpdk/list/?series=1734
(proposed syntax for dependencies)
Changes in v3 - after Declan's review:
- return error in all buses but PCI
- add a PCI driver flag to enable feature per driver
- return -EEXIST if probing again is not supported
Thomas Monjalon (3):
drivers/bus: move driver assignment to end of probing
eal: add function to query device status
eal: allow probing a device again
drivers/bus/dpaa/dpaa_bus.c | 3 ++ drivers/bus/fslmc/fslmc_bus.c | 3 ++ drivers/bus/ifpga/ifpga_bus.c | 21 +++++++------- drivers/bus/pci/pci_common.c | 38 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 6 ++-- drivers/bus/vdev/vdev.c | 12 +++++--- drivers/bus/vmbus/vmbus_common.c | 5 ++-- drivers/net/i40e/i40e_vf_representor.c | 3 -- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - lib/librte_eal/common/eal_common_dev.c | 14 +++++---- lib/librte_eal/common/include/rte_dev.h | 18 ++++++++++-- lib/librte_eal/rte_eal_version.map | 1 + 13 files changed, 82 insertions(+), 44 deletions(-)
Signature · 1 line
2.19.0
PATCH v3 1/3 drivers/bus: move driver assignment to end of probing
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
However the rte_driver does not need to be referenced in rte_device before the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of a rte_device.
--- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - lib/librte_eal/common/include/rte_dev.h | 2 +- 9 files changed, 14 insertions(+), 21 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +4 -5
@@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,/* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver;/* call the driver probe() function */ ret = drv->probe (afu_dev); -if (ret) { +if (ret) afu_dev->driver =NULL ; - afu_dev->device.driver =NULL ; - } +else + afu_dev->device.driver = &drv->driver;return ret; }
@@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->driver !=NULL ) +if (afu_dev->device.driver !=NULL )return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
drivers/bus/pci/pci_common.c +3 -4
@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) { dev->driver =NULL ; - dev->device.driver =NULL ;return ret; } }
@@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe (dr, dev);if (ret) { dev->driver =NULL ; - dev->device.driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources.
@@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))rte_pci_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) +if (dev->device.driver !=NULL )return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/pci/rte_bus_pci.h +1 -1
@@ -62,7 +62,7 @@ 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;/**< Associated driver */ +struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */
drivers/bus/vdev/vdev.c +2 -3
@@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)if (vdev_parse (name, &driver))return -1 ; - dev->device.driver = &driver->driver; ret = driver->probe (dev); -if (ret) - dev->device.driver =NULL ; +if (ret ==0 ) + dev->device.driver = &driver->driver;return ret; }
drivers/bus/vmbus/vmbus_common.c +3 -2
@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dev->device.numa_node <0 ) {VMBUS_LOG (WARNING ," Invalid NUMA socket, default to 0" );
@@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) { +if (dev->device.driver !=NULL ) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
drivers/net/i40e/i40e_vf_representor.c +0 -3
@@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)if (representor->vf_id >= pf->vf_num)return -ENODEV ; -/** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; -/* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops;
drivers/net/mlx4/mlx4.c +0 -1
@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device;rte_eth_copy_pci_info (eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver;/* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle ){ .fd =-1 ,
drivers/net/mlx5/mlx5.c +0 -1
@@ -1081,7 +1081,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err =mlx5_uar_init_primary (eth_dev);if (err) { err = rte_errno;
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -156,7 +156,7 @@ struct rte_driver {struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ -const struct rte_driver *driver;/**< Associated driver */ +const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */
Signature · 1 line
2.19.0
PATCH v3 2/3 eal: add function to query device status
In reply to Thomas MonjalonThe function rte_dev_is_probed() is added in order to improve semantic and enforce proper check of the probing status of a device.
It will answer this rte_device query:
Is it already successfully probed or not?
--- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- drivers/bus/pci/pci_common.c | 2 +- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/vmbus_common.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 9 ++++++++- lib/librte_eal/common/include/rte_dev.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 7 files changed, 28 insertions(+), 6 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +2 -2
@@ -301,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->device.driver !=NULL ) +if (rte_dev_is_probed (&afu_dev->device))return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
@@ -325,7 +325,7 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (afu_dev->device.driver) +if (rte_dev_is_probed (&afu_dev->device))continue ; ret =ifpga_probe_all_drivers (afu_dev);
drivers/bus/pci/pci_common.c +1 -1
@@ -243,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) +if (rte_dev_is_probed (&dev->device))return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/vdev/vdev.c +1 -1
@@ -481,7 +481,7 @@ vdev_probe(void)* we call each driver probe. */ -if (dev->device.driver) +if (rte_dev_is_probed (&dev->device))continue ;if (vdev_probe_all_drivers (dev)) {
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -143,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) { +if (rte_dev_is_probed (&dev->device)) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
lib/librte_eal/common/eal_common_dev.c +8 -1
@@ -74,6 +74,13 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)return strcmp (dev->name, name); } +int __rte_experimental +rte_dev_is_probed (const struct rte_device *dev) +{ +/* The field driver should be set only when the probe is successful. */ +return dev->driver !=NULL ; +} +int rte_eal_dev_attach (const char *name,const char *devargs) {struct rte_bus *bus;
@@ -189,7 +196,7 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (dev->driver !=NULL ) { +if (rte_dev_is_probed (dev)) {RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }
lib/librte_eal/common/include/rte_dev.h +14 -0
@@ -162,6 +162,20 @@ struct rte_device {struct rte_devargs *devargs;/**< Device user arguments */ }; +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Query status of a device. +* +* @param dev +* Generic device pointer. +* @return +* (int)true if already probed successfully, 0 otherwise. +*/ +__rte_experimental +int rte_dev_is_probed(const struct rte_device *dev); +/** * Attach a device to a registered driver. *
lib/librte_eal/rte_eal_version.map +1 -0
@@ -279,6 +279,7 @@ EXPERIMENTAL { rte_dev_event_callback_unregister; rte_dev_event_monitor_start; rte_dev_event_monitor_stop; + rte_dev_is_probed; rte_dev_iterator_init; rte_dev_iterator_next; rte_dev_probe;
Signature · 1 line
2.19.0
PATCH v3 3/3 eal: allow probing a device again
In reply to Thomas MonjalonIn the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existing rte_device.
That's why the check for an already probed device
is moved as bus responsibility.
In the case of vdev, a global check is kept in insert_vdev(), assuming that a vdev will always have only one port.
In the case of ifpga and vmbus, already probed devices are checked. In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.
In the case of PCI, a driver flag is added to allow PMD probing again. Only the PMD knows the ports attached to one rte_device.
As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.
--- drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 14 ++++++----- drivers/bus/pci/pci_common.c | 33 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 4 ++- drivers/bus/vdev/vdev.c | 5 ++++ lib/librte_eal/common/eal_common_dev.c | 7 ++---- lib/librte_eal/common/include/rte_dev.h | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -0
@@ -555,6 +555,9 @@ rte_dpaa_bus_probe(void)if (ret)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (!drv->probe || (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ))
drivers/bus/fslmc/fslmc_bus.c +3 -0
@@ -386,6 +386,9 @@ rte_fslmc_probe(void)if (!drv->probe)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ) { DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
drivers/bus/ifpga/ifpga_bus.c +8 -6
@@ -301,8 +301,11 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&afu_dev->device)) -return 0 ; +if (rte_dev_is_probed (&afu_dev->device)) { +IFPGA_BUS_DEBUG ("Device %s is already probed\n" , +rte_ifpga_device_name (afu_dev)); +return -EEXIST ; + } TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {if (ifpga_probe_one_driver (drv, afu_dev)) {
@@ -325,14 +328,13 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (rte_dev_is_probed (&afu_dev->device)) -continue ; - ret =ifpga_probe_all_drivers (afu_dev); +if (ret == -EEXIST ) +continue ;if (ret <0 )IFPGA_BUS_ERR ("failed to initialize %s device\n" ,rte_ifpga_device_name (afu_dev)); - } + }return ret; }
drivers/bus/pci/pci_common.c +22 -11
@@ -6,6 +6,7 @@#include <string.h> #include <inttypes.h> #include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <sys/queue.h>
@@ -121,6 +122,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) {int ret; +bool already_probed;struct rte_pci_addr *loc;if ((dr ==NULL ) || (dev ==NULL ))
@@ -151,6 +153,13 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, dev->device.numa_node =0 ; } + already_probed =rte_dev_is_probed (&dev->device); +if (already_probed && !(dr->drv_flags &RTE_PCI_DRV_PROBE_AGAIN )) { +RTE_LOG (DEBUG ,EAL ,"Device %s is already probed\n" , + dev->device.name); +return -EEXIST ; + } +RTE_LOG (INFO ,EAL ," probe driver: %x:%x %s\n" , dev->id.vendor_id, dev->id.device_id, dr->driver.name);
@@ -159,9 +168,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* This needs to be before rte_pci_map_device(), as it enables to use * driver flags for adjusting configuration. */ - dev->driver = dr; +if (!already_probed) + dev->driver = dr; -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { +if (!already_probed && (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) {
@@ -172,6 +182,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* call the driver probe() function */ ret = dr->probe (dr, dev); +if (already_probed) +return ret;/* no rollback if already succeeded earlier */ if (ret) { dev->driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&
@@ -242,10 +254,6 @@ pci_probe_all_drivers(struct rte_pci_device *dev)if (dev ==NULL )return -1 ; -/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&dev->device)) -return 0 ; -FOREACH_DRIVER_ON_PCIBUS (dr) { rc =rte_pci_probe_one_driver (dr, dev);if (rc <0 )
@@ -287,11 +295,14 @@ rte_pci_probe(void) devargs->policy == RTE_DEV_WHITELISTED) ret =pci_probe_all_drivers (dev);if (ret <0 ) { -RTE_LOG (ERR ,EAL ,"Requested device " PCI_PRI_FMT -" cannot be used\n" , dev->addr.domain, dev->addr.bus, - dev->addr.devid, dev->addr.function); - rte_errno = errno; - failed++; +if (ret != -EEXIST ) { +RTE_LOG (ERR ,EAL ,"Requested device " +PCI_PRI_FMT " cannot be used\n" , + dev->addr.domain, dev->addr.bus, + dev->addr.devid, dev->addr.function); + rte_errno = errno; + failed++; + } ret =0 ; } }
drivers/bus/pci/rte_bus_pci.h +3 -1
@@ -121,7 +121,7 @@ struct rte_pci_driver {pci_probe_t *probe;/**< Device Probe function. */ pci_remove_t *remove;/**< Device Remove function. */ const struct rte_pci_id *id_table;/**< ID table, NULL terminated. */ -uint32_t drv_flags;/**< Flags contolling handling of device. */ +uint32_t drv_flags;/**< Flags RTE_PCI_DRV_*. */ };/**
@@ -137,6 +137,8 @@ struct rte_pci_bus {#define RTE_PCI_DRV_NEED_MAPPING 0x0001/** Device needs PCI BAR mapping with enabled write combining (wc) */ #define RTE_PCI_DRV_WC_ACTIVATE 0x0002 +/** Device already probed can be probed again to check for new ports. */ +#define RTE_PCI_DRV_PROBE_AGAIN 0x0004/** Device driver supports link state interrupt */ #define RTE_PCI_DRV_INTR_LSC 0x0008/** Device driver supports device removal interrupt */
drivers/bus/vdev/vdev.c +5 -0
@@ -226,6 +226,11 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) dev->device.name = devargs->name;if (find_vdev (name)) { +/* +* A vdev is expected to have only one port. +* So there is no reason to try probing again, +* even with new arguments. +*/ ret = -EEXIST ; goto fail; }
lib/librte_eal/common/eal_common_dev.c +2 -5
@@ -196,13 +196,10 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (rte_dev_is_probed (dev)) { -RTE_LOG (ERR ,EAL ,"Device is already plugged\n" ); -return -EEXIST ; - } - ret = dev->bus->plug (dev);if (ret) { +if (rte_dev_is_probed (dev))/* if already succeeded earlier */ +return ret;/* no rollback */ RTE_LOG (ERR ,EAL ,"Driver cannot attach the device (%s)\n" , dev->name); goto err_devarg;
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -159,7 +159,7 @@ struct rte_device {const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ -struct rte_devargs *devargs;/**< Device user arguments */ +struct rte_devargs *devargs;/**< Arguments for latest probing */ };/**
Signature · 1 line
2.19.0
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
In reply to Thomas MonjalonQuoted 11 lines · Thomas Monjalon
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Signed-off-by Thomas Monjalon <[email protected]>
Re: [PATCH v3 2/3] eal: add function to query device status
In reply to Thomas MonjalonQuoted 7 lines · Thomas Monjalon
The function
rte_dev_is_probed()is added in order to improve semantic and enforce proper check of the probing status of a device.It will answer this
rte_devicequery:
Is it already successfully probed or not?Signed-off-by Thomas Monjalon <[email protected]>
Re: [PATCH v3 3/3] eal: allow probing a device again
In reply to Thomas MonjalonQuoted 20 lines · Thomas Monjalon
In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existingrte_device.That's why the check for an already probed device
is moved as bus responsibility.
In the case of vdev, a global check is kept ininsert_vdev(), assuming that a vdev will always have only one port.
In the case of ifpga and vmbus, already probed devices are checked. In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.
In the case of PCI, a driver flag is added to allow PMD probing again. Only the PMD knows the ports attached to onerte_device.
Quoted 6 lines
As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the
rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.Signed-off-by Thomas Monjalon <[email protected]>
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
In reply to Thomas MonjalonQuoted 17 lines · Thomas Monjalon
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-0
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 4 lines
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;
It breaks net/sfc and I guess other drivers which use rte_eth_dma_zone_reserve() from probe. The function makes zone name using dev->device->driver->name.
Andrew.
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.
Quoted 15 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing rte_pci_driver->driver->name. Note that rte_pci_driver is referenced in rte_pci_device.
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
Quoted 26 lines · Thomas Monjalon
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 14 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.
Quoted 5 lines
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing
rte_pci_driver->driver->name. Note thatrte_pci_driveris referenced inrte_pci_device.
Below in snprintf(), in theory it can be called for vdev as well.
const struct rte_memzone *
rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align, int socket_id)
{
char z_name[RTE_MEMZONE_NAMESIZE];
const struct rte_memzone *mz;
snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", dev->device->driver->name, ring_name, dev->data->port_id, queue_id);
mz = rte_memzone_lookup(z_name);
if (mz)
return mz;
return rte_memzone_reserve_aligned(z_name, size, socket_id, RTE_MEMZONE_IOVA_CONTIG, align); }
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
11/10/2018 13:54, Andrew Rybchenko:
Quoted 40 lines · Thomas Monjalon
Quoted 26 lines
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 14 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.Quoted 5 lines
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing
rte_pci_driver->driver->name. Note thatrte_pci_driveris referenced inrte_pci_device.Below in
snprintf(), in theory it can be called for vdev as well.const struct
rte_memzone*
rte_eth_dma_zone_reserve(const structrte_eth_dev*dev, const char*ring_name,
uint16_tqueue_id,size_tsize, unsigned align, intsocket_id)
Quoted 7 lines
{
char z_name[RTE_MEMZONE_NAMESIZE];
const struct rte_memzone *mz;
snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
dev->device->driver->name, ring_name,
dev->data->port_id, queue_id);I see, I missed it.
I think it's strange to use rte_device name for ethdev memory. Should we use the ethdev name instead?
snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
- dev->device->driver->name, ring_name,
+ dev->data->name, ring_name,
dev->data->port_id, queue_id);Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
Quoted 53 lines · Thomas Monjalon
11/10/2018 13:54, Andrew Rybchenko:
Quoted 39 lines · Thomas Monjalon
Quoted 26 lines
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 14 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.Quoted 5 lines
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing
rte_pci_driver->driver->name. Note thatrte_pci_driveris referenced inrte_pci_device.Below in
snprintf(), in theory it can be called for vdev as well.const struct
rte_memzone*
rte_eth_dma_zone_reserve(const structrte_eth_dev*dev, const char*ring_name,
uint16_tqueue_id,size_tsize, unsigned align, intsocket_id)Quoted 7 lines
{ char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", dev->device->driver->name, ring_name, dev->data->port_id, queue_id);I see, I missed it.
I think it's strange to use
rte_devicename for ethdev memory. Should we use the ethdev name instead?snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
Review
Quoted 3 lines
(quoted diff) +1
-1- dev->device->driver->name, ring_name, + dev->data->name, ring_name, dev->data->port_id, queue_id);
data->name could be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64). RTE_MEMZONE_NAMESIZE is 32. Sounds like a problem.
It is especially a problem if name may be specified/set by user.
Right now device driver writer knows the driver name, choose ring name and have limits on port and queue ID. So, the writer at least has possibility to be sure that the results will always fit z_name.
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
11/10/2018 15:15, Andrew Rybchenko:
Quoted 58 lines · Thomas Monjalon
Quoted 53 lines
11/10/2018 13:54, Andrew Rybchenko:
Quoted 39 lines · Thomas Monjalon
Quoted 26 lines
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 14 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.Quoted 5 lines
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing
rte_pci_driver->driver->name. Note thatrte_pci_driveris referenced inrte_pci_device.Below in
snprintf(), in theory it can be called for vdev as well.const struct
rte_memzone*
rte_eth_dma_zone_reserve(const structrte_eth_dev*dev, const char*ring_name,
uint16_tqueue_id,size_tsize, unsigned align, intsocket_id)Quoted 7 lines
{ char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", dev->device->driver->name, ring_name, dev->data->port_id, queue_id);I see, I missed it.
I think it's strange to use
rte_devicename for ethdev memory. Should we use the ethdev name instead?snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",Review
Quoted 3 lines
(quoted diff) +1
-1- dev->device->driver->name, ring_name, + dev->data->name, ring_name, dev->data->port_id, queue_id);
Quoted 7 lines
data->namecould be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).RTE_MEMZONE_NAMESIZEis 32. Sounds like a problem.
It is especially a problem if name may be specified/set by user.Right now device driver writer knows the driver name, choose ring name and have limits on port and queue ID. So, the writer at least has possibility to be sure that the results will always fit
z_name.
What about removing the device name from the memzone name? It is already unique thanks to port_id, queue_id and ring_name.
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
Quoted 62 lines · Thomas Monjalon
11/10/2018 15:15, Andrew Rybchenko:
Quoted 61 lines · Thomas Monjalon
Quoted 53 lines
11/10/2018 13:54, Andrew Rybchenko:
Quoted 39 lines · Thomas Monjalon
Quoted 26 lines
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 14 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.Quoted 5 lines
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing
rte_pci_driver->driver->name. Note thatrte_pci_driveris referenced inrte_pci_device.Below in
snprintf(), in theory it can be called for vdev as well.const struct
rte_memzone*
rte_eth_dma_zone_reserve(const structrte_eth_dev*dev, const char*ring_name,
uint16_tqueue_id,size_tsize, unsigned align, intsocket_id)Quoted 7 lines
{ char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", dev->device->driver->name, ring_name, dev->data->port_id, queue_id);I see, I missed it.
I think it's strange to use
rte_devicename for ethdev memory. Should we use the ethdev name instead?snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",Review
Quoted 3 lines
(quoted diff) +1
-1- dev->device->driver->name, ring_name, + dev->data->name, ring_name, dev->data->port_id, queue_id);
data->namecould be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).RTE_MEMZONE_NAMESIZEis 32. Sounds like a problem.
It is especially a problem if name may be specified/set by user.
Quoted 5 lines
Quoted 3 lines
Right now device driver writer knows the driver name, choose ring name and have limits on port and queue ID. So, the writer at least has possibility to be sure that the results will always fit
z_name.What about removing the device name from the memzone name? It is already unique thanks to
port_id,queue_idandring_name.
Driver name is nice since it simplify buggy code identification, but not that critical. Maybe we should highlight that it is ethdev (not other port/queue), i.e. ethdev_%s_%d_%d, to be sure that port_id and queue_id uniquely identify it.
Re: [PATCH v3 1/3] drivers/bus: move driver assignment to end of probing
11/10/2018 17:41, Andrew Rybchenko:
Quoted 66 lines · Thomas Monjalon
Quoted 65 lines
11/10/2018 15:15, Andrew Rybchenko:
Quoted 64 lines · Thomas Monjalon
Quoted 53 lines
11/10/2018 13:54, Andrew Rybchenko:
Quoted 39 lines · Thomas Monjalon
Quoted 26 lines
11/10/2018 12:53, Andrew Rybchenko:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 14 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 163
Quoted 11 lines
Signed-off-by Thomas Monjalon <[email protected]>---
drivers/bus/pci/pci_common.c +0
-1@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name usingdev->device->driver->name.Quoted 5 lines
Please, can you show code line where we does such access?
I checked such access before and did not find some. Anyway, it can be fixed by accessing
rte_pci_driver->driver->name. Note thatrte_pci_driveris referenced inrte_pci_device.Below in
snprintf(), in theory it can be called for vdev as well.const struct
rte_memzone*
rte_eth_dma_zone_reserve(const structrte_eth_dev*dev, const char*ring_name,
uint16_tqueue_id,size_tsize, unsigned align, intsocket_id)Quoted 7 lines
{ char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", dev->device->driver->name, ring_name, dev->data->port_id, queue_id);I see, I missed it.
I think it's strange to use
rte_devicename for ethdev memory. Should we use the ethdev name instead?snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",Review
Quoted 3 lines
(quoted diff) +1
-1- dev->device->driver->name, ring_name, + dev->data->name, ring_name, dev->data->port_id, queue_id);
data->namecould be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).RTE_MEMZONE_NAMESIZEis 32. Sounds like a problem.
It is especially a problem if name may be specified/set by user.Right now device driver writer knows the driver name, choose ring name and have limits on port and queue ID. So, the writer at least has possibility to be sure that the results will always fit
z_name.
Quoted 7 lines
Quoted 2 lines
What about removing the device name from the memzone name? It is already unique thanks to
port_id,queue_idandring_name.Driver name is nice since it simplify buggy code identification, but not that critical. Maybe we should highlight that it is ethdev (not other port/queue), i.e. ethdev_%s_%d_%d, to be sure that
port_idandqueue_iduniquely identify it.
OK, I send a patch then.
v4 cover eal: allow hotplug to skip an already probed device
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
The idea is to ease probing of range of ports attached to the same rte_device.
I becomes possible to allow probing again the same device but with a bigger range of ports in the devargs.
Instead of adding a parameter to the hotplug functions, as in the RFC, the check of an already probed device is moved to the bus and enabled PMDs. It gives flexibility to drivers for managing range of ports.
Changes in v4 - after Andrew's review:
- remove access to rte_device.driver during probing (patch 1)
Changes in v3 - after Declan's review:
- return error in all buses but PCI
- add a PCI driver flag to enable feature per driver
- return -EEXIST if probing again is not supported
Thomas Monjalon (4):
ethdev: rename memzones allocated for DMA drivers/bus: move driver assignment to end of probing
eal: add function to query device status
eal: allow probing a device again
drivers/bus/dpaa/dpaa_bus.c | 3 ++ drivers/bus/fslmc/fslmc_bus.c | 3 ++ drivers/bus/ifpga/ifpga_bus.c | 21 +++++++------- drivers/bus/pci/pci_common.c | 38 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 6 ++-- drivers/bus/vdev/vdev.c | 12 +++++--- drivers/bus/vmbus/vmbus_common.c | 5 ++-- drivers/net/i40e/i40e_vf_representor.c | 3 -- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - lib/librte_eal/common/eal_common_dev.c | 14 +++++---- lib/librte_eal/common/include/rte_dev.h | 18 ++++++++++-- lib/librte_eal/rte_eal_version.map | 1 + lib/librte_ethdev/rte_ethdev.c | 5 ++-- 14 files changed, 84 insertions(+), 47 deletions(-)
Signature · 1 line
2.19.0
PATCH v4 1/4 ethdev: rename memzones allocated for DMA
The helper rte_eth_dma_zone_reserve() is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.
In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (data->name) is not used because it may be too long and may be not set at this stage of probing.
Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/librte_ethdev/rte_ethdev.c +2 -3
@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)
Signature · 1 line
2.19.0
PATCH v4 2/4 drivers/bus: move driver assignment to end of probing
In reply to Thomas MonjalonThe PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
However the rte_driver does not need to be referenced in rte_device before the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of a rte_device.
--- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - lib/librte_eal/common/include/rte_dev.h | 2 +- 9 files changed, 14 insertions(+), 21 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +4 -5
@@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,/* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver;/* call the driver probe() function */ ret = drv->probe (afu_dev); -if (ret) { +if (ret) afu_dev->driver =NULL ; - afu_dev->device.driver =NULL ; - } +else + afu_dev->device.driver = &drv->driver;return ret; }
@@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->driver !=NULL ) +if (afu_dev->device.driver !=NULL )return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
drivers/bus/pci/pci_common.c +3 -4
@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) { dev->driver =NULL ; - dev->device.driver =NULL ;return ret; } }
@@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe (dr, dev);if (ret) { dev->driver =NULL ; - dev->device.driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources.
@@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))rte_pci_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) +if (dev->device.driver !=NULL )return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/pci/rte_bus_pci.h +1 -1
@@ -62,7 +62,7 @@ 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;/**< Associated driver */ +struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */
drivers/bus/vdev/vdev.c +2 -3
@@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)if (vdev_parse (name, &driver))return -1 ; - dev->device.driver = &driver->driver; ret = driver->probe (dev); -if (ret) - dev->device.driver =NULL ; +if (ret ==0 ) + dev->device.driver = &driver->driver;return ret; }
drivers/bus/vmbus/vmbus_common.c +3 -2
@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dev->device.numa_node <0 ) {VMBUS_LOG (WARNING ," Invalid NUMA socket, default to 0" );
@@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) { +if (dev->device.driver !=NULL ) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
drivers/net/i40e/i40e_vf_representor.c +0 -3
@@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)if (representor->vf_id >= pf->vf_num)return -ENODEV ; -/** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; -/* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops;
drivers/net/mlx4/mlx4.c +0 -1
@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device;rte_eth_copy_pci_info (eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver;/* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle ){ .fd =-1 ,
drivers/net/mlx5/mlx5.c +0 -1
@@ -1083,7 +1083,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err =mlx5_uar_init_primary (eth_dev);if (err) { err = rte_errno;
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -156,7 +156,7 @@ struct rte_driver {struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ -const struct rte_driver *driver;/**< Associated driver */ +const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */
Signature · 1 line
2.19.0
PATCH v4 3/4 eal: add function to query device status
In reply to Thomas MonjalonThe function rte_dev_is_probed() is added in order to improve semantic and enforce proper check of the probing status of a device.
It will answer this rte_device query:
Is it already successfully probed or not?
--- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- drivers/bus/pci/pci_common.c | 2 +- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/vmbus_common.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 9 ++++++++- lib/librte_eal/common/include/rte_dev.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 7 files changed, 28 insertions(+), 6 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +2 -2
@@ -301,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->device.driver !=NULL ) +if (rte_dev_is_probed (&afu_dev->device))return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
@@ -325,7 +325,7 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (afu_dev->device.driver) +if (rte_dev_is_probed (&afu_dev->device))continue ; ret =ifpga_probe_all_drivers (afu_dev);
drivers/bus/pci/pci_common.c +1 -1
@@ -243,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) +if (rte_dev_is_probed (&dev->device))return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/vdev/vdev.c +1 -1
@@ -481,7 +481,7 @@ vdev_probe(void)* we call each driver probe. */ -if (dev->device.driver) +if (rte_dev_is_probed (&dev->device))continue ;if (vdev_probe_all_drivers (dev)) {
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -143,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) { +if (rte_dev_is_probed (&dev->device)) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
lib/librte_eal/common/eal_common_dev.c +8 -1
@@ -74,6 +74,13 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)return strcmp (dev->name, name); } +int __rte_experimental +rte_dev_is_probed (const struct rte_device *dev) +{ +/* The field driver should be set only when the probe is successful. */ +return dev->driver !=NULL ; +} +int rte_eal_dev_attach (const char *name,const char *devargs) {struct rte_bus *bus;
@@ -189,7 +196,7 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (dev->driver !=NULL ) { +if (rte_dev_is_probed (dev)) {RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }
lib/librte_eal/common/include/rte_dev.h +14 -0
@@ -162,6 +162,20 @@ struct rte_device {struct rte_devargs *devargs;/**< Device user arguments */ }; +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Query status of a device. +* +* @param dev +* Generic device pointer. +* @return +* (int)true if already probed successfully, 0 otherwise. +*/ +__rte_experimental +int rte_dev_is_probed(const struct rte_device *dev); +/** * Attach a device to a registered driver. *
lib/librte_eal/rte_eal_version.map +1 -0
@@ -279,6 +279,7 @@ EXPERIMENTAL { rte_dev_event_callback_unregister; rte_dev_event_monitor_start; rte_dev_event_monitor_stop; + rte_dev_is_probed; rte_dev_iterator_init; rte_dev_iterator_next; rte_dev_probe;
Signature · 1 line
2.19.0
PATCH v4 4/4 eal: allow probing a device again
In reply to Thomas MonjalonIn the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existing rte_device.
That's why the check for an already probed device
is moved as bus responsibility.
In the case of vdev, a global check is kept in insert_vdev(), assuming that a vdev will always have only one port.
In the case of ifpga and vmbus, already probed devices are checked. In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.
In the case of PCI, a driver flag is added to allow PMD probing again. Only the PMD knows the ports attached to one rte_device.
As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.
--- drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 14 ++++++----- drivers/bus/pci/pci_common.c | 33 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 4 ++- drivers/bus/vdev/vdev.c | 5 ++++ lib/librte_eal/common/eal_common_dev.c | 7 ++---- lib/librte_eal/common/include/rte_dev.h | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -0
@@ -555,6 +555,9 @@ rte_dpaa_bus_probe(void)if (ret)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (!drv->probe || (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ))
drivers/bus/fslmc/fslmc_bus.c +3 -0
@@ -386,6 +386,9 @@ rte_fslmc_probe(void)if (!drv->probe)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ) { DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
drivers/bus/ifpga/ifpga_bus.c +8 -6
@@ -301,8 +301,11 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&afu_dev->device)) -return 0 ; +if (rte_dev_is_probed (&afu_dev->device)) { +IFPGA_BUS_DEBUG ("Device %s is already probed\n" , +rte_ifpga_device_name (afu_dev)); +return -EEXIST ; + } TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {if (ifpga_probe_one_driver (drv, afu_dev)) {
@@ -325,14 +328,13 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (rte_dev_is_probed (&afu_dev->device)) -continue ; - ret =ifpga_probe_all_drivers (afu_dev); +if (ret == -EEXIST ) +continue ;if (ret <0 )IFPGA_BUS_ERR ("failed to initialize %s device\n" ,rte_ifpga_device_name (afu_dev)); - } + }return ret; }
drivers/bus/pci/pci_common.c +22 -11
@@ -6,6 +6,7 @@#include <string.h> #include <inttypes.h> #include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <sys/queue.h>
@@ -121,6 +122,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) {int ret; +bool already_probed;struct rte_pci_addr *loc;if ((dr ==NULL ) || (dev ==NULL ))
@@ -151,6 +153,13 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, dev->device.numa_node =0 ; } + already_probed =rte_dev_is_probed (&dev->device); +if (already_probed && !(dr->drv_flags &RTE_PCI_DRV_PROBE_AGAIN )) { +RTE_LOG (DEBUG ,EAL ,"Device %s is already probed\n" , + dev->device.name); +return -EEXIST ; + } +RTE_LOG (INFO ,EAL ," probe driver: %x:%x %s\n" , dev->id.vendor_id, dev->id.device_id, dr->driver.name);
@@ -159,9 +168,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* This needs to be before rte_pci_map_device(), as it enables to use * driver flags for adjusting configuration. */ - dev->driver = dr; +if (!already_probed) + dev->driver = dr; -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { +if (!already_probed && (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) {
@@ -172,6 +182,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* call the driver probe() function */ ret = dr->probe (dr, dev); +if (already_probed) +return ret;/* no rollback if already succeeded earlier */ if (ret) { dev->driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&
@@ -242,10 +254,6 @@ pci_probe_all_drivers(struct rte_pci_device *dev)if (dev ==NULL )return -1 ; -/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&dev->device)) -return 0 ; -FOREACH_DRIVER_ON_PCIBUS (dr) { rc =rte_pci_probe_one_driver (dr, dev);if (rc <0 )
@@ -287,11 +295,14 @@ rte_pci_probe(void) devargs->policy == RTE_DEV_WHITELISTED) ret =pci_probe_all_drivers (dev);if (ret <0 ) { -RTE_LOG (ERR ,EAL ,"Requested device " PCI_PRI_FMT -" cannot be used\n" , dev->addr.domain, dev->addr.bus, - dev->addr.devid, dev->addr.function); - rte_errno = errno; - failed++; +if (ret != -EEXIST ) { +RTE_LOG (ERR ,EAL ,"Requested device " +PCI_PRI_FMT " cannot be used\n" , + dev->addr.domain, dev->addr.bus, + dev->addr.devid, dev->addr.function); + rte_errno = errno; + failed++; + } ret =0 ; } }
drivers/bus/pci/rte_bus_pci.h +3 -1
@@ -121,7 +121,7 @@ struct rte_pci_driver {pci_probe_t *probe;/**< Device Probe function. */ pci_remove_t *remove;/**< Device Remove function. */ const struct rte_pci_id *id_table;/**< ID table, NULL terminated. */ -uint32_t drv_flags;/**< Flags contolling handling of device. */ +uint32_t drv_flags;/**< Flags RTE_PCI_DRV_*. */ };/**
@@ -137,6 +137,8 @@ struct rte_pci_bus {#define RTE_PCI_DRV_NEED_MAPPING 0x0001/** Device needs PCI BAR mapping with enabled write combining (wc) */ #define RTE_PCI_DRV_WC_ACTIVATE 0x0002 +/** Device already probed can be probed again to check for new ports. */ +#define RTE_PCI_DRV_PROBE_AGAIN 0x0004/** Device driver supports link state interrupt */ #define RTE_PCI_DRV_INTR_LSC 0x0008/** Device driver supports device removal interrupt */
drivers/bus/vdev/vdev.c +5 -0
@@ -226,6 +226,11 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) dev->device.name = devargs->name;if (find_vdev (name)) { +/* +* A vdev is expected to have only one port. +* So there is no reason to try probing again, +* even with new arguments. +*/ ret = -EEXIST ; goto fail; }
lib/librte_eal/common/eal_common_dev.c +2 -5
@@ -196,13 +196,10 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (rte_dev_is_probed (dev)) { -RTE_LOG (ERR ,EAL ,"Device is already plugged\n" ); -return -EEXIST ; - } - ret = dev->bus->plug (dev);if (ret) { +if (rte_dev_is_probed (dev))/* if already succeeded earlier */ +return ret;/* no rollback */ RTE_LOG (ERR ,EAL ,"Driver cannot attach the device (%s)\n" , dev->name); goto err_devarg;
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -159,7 +159,7 @@ struct rte_device {const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ -struct rte_devargs *devargs;/**< Device user arguments */ +struct rte_devargs *devargs;/**< Arguments for latest probing */ };/**
Signature · 1 line
2.19.0
Re: [PATCH v4 2/4] drivers/bus: move driver assignment to end of probing
In reply to Thomas MonjalonHi, Thomas,
Quoted 5 lines · Thomas Monjalon
The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit1d20a073fa5e("bus/pci: reference driver structure before mapping")
Quoted 7 lines
However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Have you seen driver->name usage in drivers/net/szedata2/rte_eth_szedata2.c rte_szedata2_eth_dev_init() which is used from probe?
It looks like drivers/net/mlx5/mlx5.c mlx5_pci_probe()->mlx5_dev_spawn()->mlx5_dev_to_port_id() goes to device->driver. Is the code OK with the move?
I've added above drivers maintainers in CC.
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
In reply to Thomas MonjalonQuoted 25 lines · Thomas Monjalon
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +0
-0@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,char z_name[RTE_MEMZONE_NAMESIZE ];
lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, · line 3448
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-3const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)
LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
- app/test-pmd/config.c ring_dma_zone_lookup() which is used to look at descriptors (looks like Intel specific since has RTE_LIBRTE_I40E_16BYTE_RX_DESC conditional code)
- drivers/net/bnx2x/bnx2x_rxtx.c
- drivers/net/cxgbe/sge.c (few times)
I've not dig why bnx2x and cxgbe do not use rte_eth_dma_zone_reserve().
Re: [PATCH v4 2/4] drivers/bus: move driver assignment to end of probing
In reply to Andrew RybchenkoHi Andrew,
Quoted 14 lines · Andrew Rybchenko
Hi, Thomas,
Quoted 10 lines · Thomas Monjalon
The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Have you seen
driver->nameusage indrivers/net/szedata2/rte_eth_szedata2.crte_szedata2_eth_dev_init()which is used from probe?
for szedata2, this is easily fixed by using the driver name directly from the #define above.
(quoted diff) +0 -0
b/drivers/net/szedata2/rte_eth_szedata2.c
index 8f92e72..4e5e01c 100644
drivers/net/szedata2/rte_eth_szedata2.c +3 -3
@@ -1474,7 +1474,7 @@ struct szedata2_tx_queue {PMD_INIT_FUNC_TRACE ();PMD_INIT_LOG (INFO ,"Initializing eth_dev %s (driver %s)" , data->name, - dev->device->driver->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ));/* Fill internal private structure. */ internals->dev = dev;
@@ -1525,7 +1525,7 @@ struct szedata2_tx_queue {ether_addr_copy (ð_addr, data->mac_addrs);PMD_INIT_LOG (INFO ,"%s device %s successfully initialized" , - dev->device->driver->name, data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), data->name);return 0 ; }
@@ -1547,7 +1547,7 @@ struct szedata2_tx_queue {rte_free (dev->data->mac_addrs);PMD_DRV_LOG (INFO ,"%s device %s successfully uninitialized" , - dev->device->driver->name, dev->data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), dev->data->name);return 0 ; }
Quoted 5 lines
It looks like
drivers/net/mlx5/mlx5.cmlx5_pci_probe()->mlx5_dev_spawn()->mlx5_dev_to_port_id() goes todevice->driver. Is the code OK with the move?I've added above drivers maintainers in CC.
Jan
Quoted 11 lines · Thomas Monjalon
This is a follow-up of an idea presented at Dublin during the "hotplug talk".
The idea is to ease probing of range of ports attached to the same
rte_device.
I becomes possible to allow probing again the same device but with a bigger range of ports in the devargs.Instead of adding a parameter to the hotplug functions, as in the RFC, the check of an already probed device is moved to the bus and enabled PMDs. It gives flexibility to drivers for managing range of ports.
For the series:
As I underestand it requires fix for szedata2 and has open questions for mlx5, bnx2x, cxgbe and testpmd.
Re: [PATCH v4 2/4] drivers/bus: move driver assignment to end of probing
In reply to Jan Remeš12/10/2018 10:32, Jan Remeš:
Quoted 52 lines
Hi Andrew,
Quoted 14 lines · Andrew Rybchenko
Hi, Thomas,
Quoted 10 lines · Thomas Monjalon
The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Quoted 6 lines
Quoted 2 lines
Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Have you seen
driver->nameusage indrivers/net/szedata2/rte_eth_szedata2.crte_szedata2_eth_dev_init()which is used from probe?for szedata2, this is easily fixed by using the driver name directly from the #define above.
drivers/net/szedata2/rte_eth_szedata2.c +2
-2@@ -1474,7 +1474,7 @@ struct szedata2_tx_queue {PMD_INIT_FUNC_TRACE ();PMD_INIT_LOG (INFO ,"Initializing eth_dev %s (driver %s)" , data->name, - dev->device->driver->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ));/* Fill internal private structure. */ internals->dev = dev;@@ -1525,7 +1525,7 @@ struct szedata2_tx_queue {ether_addr_copy (ð_addr, data->mac_addrs);PMD_INIT_LOG (INFO ,"%s device %s successfully initialized" , - dev->device->driver->name, data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), data->name);return 0 ; }
drivers/net/szedata2/rte_eth_szedata2.c struct szedata2_tx_queue { · line 1553
Quoted 8 lines
drivers/net/szedata2/rte_eth_szedata2.c +1
-1@@ -1547,7 +1547,7 @@ struct szedata2_tx_queue {rte_free (dev->data->mac_addrs);PMD_DRV_LOG (INFO ,"%s device %s successfully uninitialized" , - dev->device->driver->name, dev->data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), dev->data->name);return 0 ; }
OK, I'll include such change in next version.
Re: [PATCH v4 2/4] drivers/bus: move driver assignment to end of probing
In reply to Andrew Rybchenko12/10/2018 09:44, Andrew Rybchenko:
Quoted 16 lines
Hi, Thomas,
Quoted 5 lines · Thomas Monjalon
The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit1d20a073fa5e("bus/pci: reference driver structure before mapping")Quoted 7 lines
However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>
Quoted 6 lines
Have you seen
driver->nameusage indrivers/net/szedata2/rte_eth_szedata2.crte_szedata2_eth_dev_init()which is used from probe?It looks like
drivers/net/mlx5/mlx5.cmlx5_pci_probe()->mlx5_dev_spawn()->mlx5_dev_to_port_id() goes todevice->driver. Is the code OK with the move?
This access in mlx5 looks useless.
It is comparing driver names while already comparing rte_device pointers. If 2 devices are the same, they will have the same driver... I will remove it.
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
In reply to Andrew Rybchenko12/10/2018 09:53, Andrew Rybchenko:
Quoted 43 lines · Thomas Monjalon
Quoted 25 lines
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +0
-0@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,char z_name[RTE_MEMZONE_NAMESIZE ];lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, · line 3448
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-3const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
-app/test-pmd/config.cring_dma_zone_lookup()which is used to look at descriptors (looks like Intel specific since hasRTE_LIBRTE_I40E_16BYTE_RX_DESCconditional code)
Quoted 1 line
From what I see there is no access to rte_device.driver here,
except one in exit function.
Quoted 2 lines
-
drivers/net/bnx2x/bnx2x_rxtx.c
-drivers/net/cxgbe/sge.c(few times)
In bnx2x and cxgbe, it is accessed after probing (queue setup or configure steps).
Quoted 1 line
I've not dig why bnx2x and cxgbe do not use
rte_eth_dma_zone_reserve().
Yes may be interesting to standardize them.
I will add them to this patch.
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
Quoted 43 lines · Thomas Monjalon
12/10/2018 09:53, Andrew Rybchenko:
Quoted 34 lines · Thomas Monjalon
Quoted 33 lines
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-3@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name);Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, · line 3448
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +0
-0mz =rte_memzone_lookup (z_name);if (mz)LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
-app/test-pmd/config.cring_dma_zone_lookup()which is used to look at descriptors (looks like Intel specific since hasRTE_LIBRTE_I40E_16BYTE_RX_DESCconditional code)
From what I see there is no access to rte_device.driver here,
Quoted 1 line
except one in exit function.
Yes, but testpmd will fail to find the memzone and command to take a look at descriptors will be broken.
May be it is already broken etc. I think someone from Intel should comment it.
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
Quoted 43 lines · Andrew Rybchenko
Quoted 42 lines · Thomas Monjalon
12/10/2018 09:53, Andrew Rybchenko:
Quoted 41 lines · Thomas Monjalon
Quoted 24 lines
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>---
lib/librte_ethdev/rte_ethdev.c| 5 ++---1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +0
-0lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct · line 3448
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-2@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + dev->data->port_id, queue_id, ring_name); mz = rte_memzone_lookup(z_name); if (mz)LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
-app/test-pmd/config.cring_dma_zone_lookup()which is used to look at descriptors (looks like Intel specific since hasRTE_LIBRTE_I40E_16BYTE_RX_DESCconditional code) From what I see there is no access to rte_device.driver here,
Quoted 7 lines
Quoted 1 line
except one in exit function.
Yes, but testpmd will fail to find the memzone and command to take a look at descriptors will be broken.
May be it is already broken etc. I think someone from Intel should comment it.
Potentially the following drivers may use it:
$ git grep -w \"rx_ring\" drivers/net/ drivers/net/avf/avf_rxtx.c:380: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/axgbe/axgbe_rxtx.c:91: dma = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size, 12 drivers/net/cxgbe/sge.c:1878: fwevtq ? "fwq_ring" : "rx_ring", drivers/net/e1000/em_rxtx.c:1437: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, rsize, drivers/net/e1000/igb_rxtx.c:1734: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size, drivers/net/fm10k/fm10k_ethdev.c:1878: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_id, drivers/net/i40e/i40e_rxtx.c:1853: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/ixgbe/ixgbe_rxtx.c:2966: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/nfp/nfp_net.c:1516: tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
12/10/2018 18:46, Andrew Rybchenko:
Quoted 64 lines · Andrew Rybchenko
Quoted 44 lines · Thomas Monjalon
Quoted 43 lines
12/10/2018 09:53, Andrew Rybchenko:
Quoted 42 lines · Thomas Monjalon
Quoted 25 lines
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +0
-0lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct · line 3448
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-2@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, char z_name[RTE_MEMZONE_NAMESIZE];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
-app/test-pmd/config.cring_dma_zone_lookup()which is used to look at descriptors (looks like Intel specific since hasRTE_LIBRTE_I40E_16BYTE_RX_DESCconditional code)
From what I see there is no access to rte_device.driver here,Quoted 7 lines
Quoted 1 line
except one in exit function.
Yes, but testpmd will fail to find the memzone and command to take a look at descriptors will be broken.
May be it is already broken etc. I think someone from Intel should comment it.
Potentially the following drivers may use it:
$ git grep -w \"rx_ring\" drivers/net/ drivers/net/avf/avf_rxtx.c:380: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/axgbe/axgbe_rxtx.c:91: dma = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size, 12 drivers/net/cxgbe/sge.c:1878: fwevtq ? "fwq_ring" : "rx_ring", drivers/net/e1000/em_rxtx.c:1437: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, rsize, drivers/net/e1000/igb_rxtx.c:1734: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size,
Quoted 8 lines
drivers/net/fm10k/fm10k_ethdev.c:1878: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_id, drivers/net/i40e/i40e_rxtx.c:1853: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/ixgbe/ixgbe_rxtx.c:2966: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/nfp/nfp_net.c:1516: tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
Excuse me, I really don't understand what you mean.
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
12/10/2018 19:18, Thomas Monjalon:
Quoted 74 lines
12/10/2018 18:46, Andrew Rybchenko:
Quoted 64 lines · Andrew Rybchenko
Quoted 44 lines · Thomas Monjalon
Quoted 43 lines
12/10/2018 09:53, Andrew Rybchenko:
Quoted 42 lines · Thomas Monjalon
Quoted 25 lines
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +0
-0lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct · line 3448
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-2@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, char z_name[RTE_MEMZONE_NAMESIZE];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
-app/test-pmd/config.cring_dma_zone_lookup()which is used to look at descriptors (looks like Intel specific since hasRTE_LIBRTE_I40E_16BYTE_RX_DESCconditional code)
From what I see there is no access to rte_device.driver here,Quoted 7 lines
Quoted 1 line
except one in exit function.
Yes, but testpmd will fail to find the memzone and command to take a look at descriptors will be broken.
May be it is already broken etc. I think someone from Intel should comment it.
Potentially the following drivers may use it:
$ git grep -w \"rx_ring\" drivers/net/ drivers/net/avf/avf_rxtx.c:380: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/axgbe/axgbe_rxtx.c:91: dma = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size, 12 drivers/net/cxgbe/sge.c:1878: fwevtq ? "fwq_ring" : "rx_ring", drivers/net/e1000/em_rxtx.c:1437: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, rsize, drivers/net/e1000/igb_rxtx.c:1734: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size,Quoted 8 lines
drivers/net/fm10k/fm10k_ethdev.c:1878: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_id, drivers/net/i40e/i40e_rxtx.c:1853: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/ixgbe/ixgbe_rxtx.c:2966: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/nfp/nfp_net.c:1516: tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
Quoted 1 line
Excuse me, I really don't understand what you mean.
Oh, got it!
You mean the call to rte_memzone_lookup() must expect the new memzone name. So I must update it here too, right?
Re: [PATCH v4 1/4] ethdev: rename memzones allocated for DMA
Quoted 75 lines · On October 12, 2018 20:21:32 Thomas Monjalon <[email protected]> wrote:
12/10/2018 19:18, Thomas Monjalon:
Quoted 74 lines
12/10/2018 18:46, Andrew Rybchenko:
Quoted 72 lines · Andrew Rybchenko
Quoted 44 lines · Thomas Monjalon
Quoted 43 lines
12/10/2018 09:53, Andrew Rybchenko:
Quoted 42 lines · Thomas Monjalon
Quoted 25 lines
The helper
rte_eth_dma_zone_reserve()is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.In order to avoid assigning the driver before the end of the probing (next patch), the driver name is removed from these memzone names. The ethdev name (
data->name) is not used because it may be too long and may be not set at this stage of probing.Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/librte_ethdev/rte_ethdev.c +0
-0lib/librte_ethdev/rte_ethdev.c rte_eth_dma_zone_reserve(const struct · line 3448
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +2
-2@@ -3441,9 +3441,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, char z_name[RTE_MEMZONE_NAMESIZE];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)LGTM, but I've found more places where the pattern is duplicate and testpmd frightens me:
-app/test-pmd/config.cring_dma_zone_lookup()which is used to look at descriptors (looks like Intel specific since hasRTE_LIBRTE_I40E_16BYTE_RX_DESCconditional code)
From what I see there is no access to rte_device.driver here,Quoted 7 lines
Quoted 1 line
except one in exit function.
Yes, but testpmd will fail to find the memzone and command to take a look at descriptors will be broken.
May be it is already broken etc. I think someone from Intel should comment it.
Potentially the following drivers may use it:
$ git grep -w \"rx_ring\" drivers/net/ drivers/net/avf/avf_rxtx.c:380: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/axgbe/axgbe_rxtx.c:91: dma = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size, 12 drivers/net/cxgbe/sge.c:1878: fwevtq ? "fwq_ring" : "rx_ring", drivers/net/e1000/em_rxtx.c:1437: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, rsize, drivers/net/e1000/igb_rxtx.c:1734: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size, drivers/net/fm10k/fm10k_ethdev.c:1878: mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_id, drivers/net/i40e/i40e_rxtx.c:1853: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/ixgbe/ixgbe_rxtx.c:2966: rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, drivers/net/nfp/nfp_net.c:1516: tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
Quoted 5 lines
Quoted 1 line
Excuse me, I really don't understand what you mean.
Oh, got it!
You mean the call torte_memzone_lookup()must expect the new memzone name. So I must update it here too, right?
Yes
v5 cover allow hotplug to skip an already probed device
In reply to Thomas MonjalonThis is a follow-up of an idea presented at Dublin during the "hotplug talk".
The idea is to ease probing of range of ports attached to the same rte_device.
I becomes possible to allow probing again the same device but with a bigger range of ports in the devargs.
Instead of adding a parameter to the hotplug functions, as in the RFC, the check of an already probed device is moved to the bus and enabled PMDs. It gives flexibility to drivers for managing range of ports.
Changes in v5 - after Andrew's review:
- remove driver name usage in mlx5/szedata2 probing and crypto/compress logs
- update DMA ring names in bnx2x, cxgbe, vmxnet3 and testpmd lookup
Changes in v4 - after Andrew's review:
- remove access to rte_device.driver during probing (patch 1)
Changes in v3 - after Declan's review:
- return error in all buses but PCI
- add a PCI driver flag to enable feature per driver
- return -EEXIST if probing again is not supported
Thomas Monjalon (7):
net/mlx5: remove useless driver name comparison
ethdev: rename memzones allocated for DMA
cryptodev: remove driver name from logs
compressdev: remove driver name from logs drivers/bus: move driver assignment to end of probing
eal: add function to query device status
eal: allow probing a device again
app/test-pmd/config.c | 4 +-- drivers/bus/dpaa/dpaa_bus.c | 3 ++ drivers/bus/fslmc/fslmc_bus.c | 3 ++ drivers/bus/ifpga/ifpga_bus.c | 21 +++++------ drivers/bus/pci/pci_common.c | 38 ++++++++++++-------- drivers/bus/pci/rte_bus_pci.h | 6 ++-- drivers/bus/vdev/vdev.c | 12 ++++--- drivers/bus/vmbus/vmbus_common.c | 5 +-- drivers/net/bnx2x/bnx2x_rxtx.c | 15 ++------ drivers/net/cxgbe/sge.c | 24 ++++++------- drivers/net/i40e/i40e_vf_representor.c | 3 -- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - drivers/net/mlx5/mlx5_ethdev.c | 5 +-- drivers/net/szedata2/rte_eth_szedata2.c | 6 ++-- drivers/net/vmxnet3/vmxnet3_ethdev.c | 4 +-- lib/librte_compressdev/rte_compressdev_pmd.c | 23 +++++------- lib/librte_cryptodev/rte_cryptodev_pmd.c | 23 +++++------- lib/librte_eal/common/eal_common_dev.c | 14 +++++--- lib/librte_eal/common/include/rte_dev.h | 18 ++++++++-- lib/librte_eal/rte_eal_version.map | 1 + lib/librte_ethdev/rte_ethdev.c | 5 ++- 22 files changed, 121 insertions(+), 114 deletions(-)
Signature · 1 line
2.19.0
PATCH v5 1/7 net/mlx5: remove useless driver name comparison
The function mlx5_dev_to_port_id() is returning all the ports associated to a rte_device.
It was comparing driver names while already comparing rte_device pointers. If two devices are the same, they will have the same driver. So the useless driver name comparison is removed.
--- drivers/net/mlx5/mlx5_ethdev.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/mlx5/mlx5_ethdev.c +1 -4
@@ -1305,10 +1305,7 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,RTE_ETH_FOREACH_DEV (id) {struct rte_eth_dev *ldev = &rte_eth_devices[id]; -if (!ldev->device || - !ldev->device->driver || -strcmp (ldev->device->driver->name,MLX5_DRIVER_NAME ) || - ldev->device != dev) +if (ldev->device != dev)continue ;if (n < port_list_n) port_list[n] = id;
Signature · 1 line
2.19.0
PATCH v5 2/7 ethdev: rename memzones allocated for DMA
In reply to Thomas MonjalonThe helper rte_eth_dma_zone_reserve() is called by PMDs when probing a new port.
It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe.
In order to avoid assigning the driver before the end of the probing, the driver name is removed from these memzone names.
The ethdev name (data->name) is not used because it may be too long and may be not set at this stage of probing.
Syntax of old name: <driver>_<ring>_<port>_<queue> Syntax of new name: eth_p<port>_q<queue>_<ring>
--- app/test-pmd/config.c | 4 ++-- drivers/net/bnx2x/bnx2x_rxtx.c | 15 ++------------- drivers/net/cxgbe/sge.c | 24 ++++++++++-------------- drivers/net/vmxnet3/vmxnet3_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 5 files changed, 18 insertions(+), 34 deletions(-)
app/test-pmd/config.c +2 -2
@@ -1479,8 +1479,8 @@ ring_dma_zone_lookup(const char *ring_name, portid_t port_id, uint16_t q_id)char mz_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; -snprintf (mz_name,sizeof (mz_name),"%s_%s_%d_%d" , - ports[port_id].dev_info.driver_name, ring_name, port_id, q_id); +snprintf (mz_name,sizeof (mz_name),"eth_p%d_q%d_%s" , + port_id, q_id, ring_name); mz =rte_memzone_lookup (mz_name);if (mz ==NULL ) printf("%s ring memory zoneof (port %d, queue %d) not"
drivers/net/bnx2x/bnx2x_rxtx.c +2 -13
@@ -12,19 +12,8 @@ static const struct rte_memzone * ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, uint32_t ring_size, int socket_id) { - char z_name[RTE_MEMZONE_NAMESIZE]; -const struct rte_memzone *mz; - -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); - - mz =rte_memzone_lookup (z_name); -if (mz) -return mz; - -return rte_memzone_reserve_aligned (z_name, ring_size, socket_id, -RTE_MEMZONE_IOVA_CONTIG ,BNX2X_PAGE_SIZE ); + return rte_eth_dma_zone_reserve(dev, ring_name, queue_id, + ring_size, BNX2X_PAGE_SIZE, socket_id); } static void
drivers/net/cxgbe/sge.c +10 -14
@@ -1873,10 +1873,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,/* Size needs to be multiple of 16, including status entry. */ iq->size =cxgbe_roundup (iq->size,16 ); -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - eth_dev->device->driver->name, - fwevtq ?"fwq_ring" :"rx_ring" , - eth_dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + eth_dev->data->port_id, queue_id, + fwevtq ?"fwq_ring" :"rx_ring" );snprintf (z_name_sw,sizeof (z_name_sw),"%s_sw_ring" , z_name); iq->desc = alloc_ring(iq->size, iq->iqe_len, 0, &iq->phys_addr, NULL, 0,
@@ -1938,10 +1937,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, fl->size = s->fl_starve_thres -1 +2 *8 ; fl->size =cxgbe_roundup (fl->size,8 ); -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - eth_dev->device->driver->name, - fwevtq ?"fwq_ring" :"fl_ring" , - eth_dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + eth_dev->data->port_id, queue_id, + fwevtq ?"fwq_ring" :"fl_ring" );snprintf (z_name_sw,sizeof (z_name_sw),"%s_sw_ring" , z_name); fl->desc = alloc_ring(fl->size, sizeof(__be64),
@@ -2144,9 +2142,8 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,/* Add status entries */ nentries = txq->q.size + s->stat_len /sizeof (struct tx_desc ); -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - eth_dev->device->driver->name,"tx_ring" , - eth_dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + eth_dev->data->port_id, queue_id,"tx_ring" );snprintf (z_name_sw,sizeof (z_name_sw),"%s_sw_ring" , z_name); txq->q.desc = alloc_ring(txq->q.size, sizeof(struct tx_desc),
@@ -2223,9 +2220,8 @@ int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,/* Add status entries */ nentries = txq->q.size + s->stat_len /sizeof (struct tx_desc ); -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - eth_dev->device->driver->name,"ctrl_tx_ring" , - eth_dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + eth_dev->data->port_id, queue_id,"ctrl_tx_ring" );snprintf (z_name_sw,sizeof (z_name_sw),"%s_sw_ring" , z_name); txq->q.desc = alloc_ring(txq->q.size, sizeof(struct tx_desc),
drivers/net/vmxnet3/vmxnet3_ethdev.c +2 -2
@@ -161,8 +161,8 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%d_%s" , - dev->device->driver->name, dev->data->port_id, post_string); +snprintf (z_name,sizeof (z_name),"eth_p%d_%s" , + dev->data->port_id, post_string); mz =rte_memzone_lookup (z_name);if (!reuse) {
lib/librte_ethdev/rte_ethdev.c +2 -3
@@ -3481,9 +3481,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; -snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); +snprintf (z_name,sizeof (z_name),"eth_p%d_q%d_%s" , + dev->data->port_id, queue_id, ring_name); mz =rte_memzone_lookup (z_name);if (mz)
Signature · 1 line
2.19.0
PATCH v5 3/7 cryptodev: remove driver name from logs
In reply to Thomas MonjalonThe logs printed by CDEV_LOG_* were prefixed with the driver name.
In order to avoid assigning the driver before the end of the probing, the driver name is removed from the cryptodev library logs.
--- lib/librte_cryptodev/rte_cryptodev_pmd.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
lib/librte_cryptodev/rte_cryptodev_pmd.c +8 -15
@@ -93,24 +93,20 @@ rte_cryptodev_pmd_create(const char *name,struct rte_cryptodev *cryptodev;if (params->name[0 ] !='\0' ) { -CDEV_LOG_INFO ("[%s] User specified device name = %s\n" , - device->driver->name, params->name); +CDEV_LOG_INFO ("User specified device name = %s\n" , params->name); name = params->name; } -CDEV_LOG_INFO ("[%s] - Creating cryptodev %s\n" , - device->driver->name, name); +CDEV_LOG_INFO ("Creating cryptodev %s\n" , name); -CDEV_LOG_INFO ("[%s] - Initialisation parameters - name: %s," +CDEV_LOG_INFO ("Initialisation parameters - name: %s," "socket id: %d, max queue pairs: %u" , - device->driver->name, name, - params->socket_id, params->max_nb_queue_pairs); + name, params->socket_id, params->max_nb_queue_pairs);/* allocate device structure */ cryptodev =rte_cryptodev_pmd_allocate (name, params->socket_id);if (cryptodev ==NULL ) { -CDEV_LOG_ERR ("[%s] Failed to allocate crypto device for %s" , - device->driver->name, name); +CDEV_LOG_ERR ("Failed to allocate crypto device for %s" , name);return NULL ; }
@@ -123,9 +119,8 @@ rte_cryptodev_pmd_create(const char *name, params->socket_id);if (cryptodev->data->dev_private ==NULL ) { -CDEV_LOG_ERR ("[%s] Cannot allocate memory for " -"cryptodev %s private data" , - device->driver->name, name); +CDEV_LOG_ERR ("Cannot allocate memory for cryptodev %s" +" private data" , name);rte_cryptodev_pmd_release_device (cryptodev);return NULL ;
@@ -145,9 +140,7 @@ rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev) {int retval; -CDEV_LOG_INFO ("[%s] Closing crypto device %s" , - cryptodev->device->driver->name, - cryptodev->device->name); +CDEV_LOG_INFO ("Closing crypto device %s" , cryptodev->device->name);/* free crypto device */ retval =rte_cryptodev_pmd_release_device (cryptodev);
Signature · 1 line
2.19.0
PATCH v5 4/7 compressdev: remove driver name from logs
In reply to Thomas MonjalonThe logs printed by COMPRESSDEV_LOG were prefixed with the driver name.
In order to avoid assigning the driver before the end of the probing, the driver name is removed from the compressdev library logs.
--- lib/librte_compressdev/rte_compressdev_pmd.c | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-)
lib/librte_compressdev/rte_compressdev_pmd.c +9 -14
@@ -92,24 +92,20 @@ rte_compressdev_pmd_create(const char *name,struct rte_compressdev *compressdev;if (params->name[0 ] !='\0' ) { -COMPRESSDEV_LOG (INFO ,"[%s] User specified device name = %s\n" , - device->driver->name, params->name); +COMPRESSDEV_LOG (INFO ,"User specified device name = %s\n" , + params->name); name = params->name; } -COMPRESSDEV_LOG (INFO ,"[%s] - Creating compressdev %s\n" , - device->driver->name, name); +COMPRESSDEV_LOG (INFO ,"Creating compressdev %s\n" , name); -COMPRESSDEV_LOG (INFO , -"[%s] - Init parameters - name: %s, socket id: %d" , - device->driver->name, name, - params->socket_id); +COMPRESSDEV_LOG (INFO ,"Init parameters - name: %s, socket id: %d" , + name, params->socket_id);/* allocate device structure */ compressdev =rte_compressdev_pmd_allocate (name, params->socket_id);if (compressdev ==NULL ) { -COMPRESSDEV_LOG (ERR ,"[%s] Failed to allocate comp device %s" , - device->driver->name, name); +COMPRESSDEV_LOG (ERR ,"Failed to allocate comp device %s" , name);return NULL ; }
@@ -123,8 +119,8 @@ rte_compressdev_pmd_create(const char *name,if (compressdev->data->dev_private ==NULL ) {COMPRESSDEV_LOG (ERR , -"[%s] Cannot allocate memory for compressdev %s private data" , - device->driver->name, name); +"Cannot allocate memory for compressdev" +" %s private data" , name);rte_compressdev_pmd_release_device (compressdev);return NULL ;
@@ -141,8 +137,7 @@ rte_compressdev_pmd_destroy(struct rte_compressdev *compressdev) {int retval; -COMPRESSDEV_LOG (INFO ,"[%s] Closing comp device %s" , - compressdev->device->driver->name, +COMPRESSDEV_LOG (INFO ,"Closing comp device %s" , compressdev->device->name);/* free comp device */
Signature · 1 line
2.19.0
PATCH v5 5/7 drivers/bus: move driver assignment to end of probing
In reply to Thomas MonjalonThe PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
However the rte_driver does not need to be referenced in rte_device before the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of a rte_device.
--- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - drivers/net/szedata2/rte_eth_szedata2.c | 6 +++--- lib/librte_eal/common/include/rte_dev.h | 2 +- 10 files changed, 17 insertions(+), 24 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +4 -5
@@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,/* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver;/* call the driver probe() function */ ret = drv->probe (afu_dev); -if (ret) { +if (ret) afu_dev->driver =NULL ; - afu_dev->device.driver =NULL ; - } +else + afu_dev->device.driver = &drv->driver;return ret; }
@@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->driver !=NULL ) +if (afu_dev->device.driver !=NULL )return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
drivers/bus/pci/pci_common.c +3 -4
@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) { dev->driver =NULL ; - dev->device.driver =NULL ;return ret; } }
@@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe (dr, dev);if (ret) { dev->driver =NULL ; - dev->device.driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources.
@@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))rte_pci_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) +if (dev->device.driver !=NULL )return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/pci/rte_bus_pci.h +1 -1
@@ -62,7 +62,7 @@ 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;/**< Associated driver */ +struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */
drivers/bus/vdev/vdev.c +2 -3
@@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)if (vdev_parse (name, &driver))return -1 ; - dev->device.driver = &driver->driver; ret = driver->probe (dev); -if (ret) - dev->device.driver =NULL ; +if (ret ==0 ) + dev->device.driver = &driver->driver;return ret; }
drivers/bus/vmbus/vmbus_common.c +3 -2
@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dev->device.numa_node <0 ) {VMBUS_LOG (WARNING ," Invalid NUMA socket, default to 0" );
@@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;
@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) { +if (dev->device.driver !=NULL ) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
drivers/net/i40e/i40e_vf_representor.c +0 -3
@@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)if (representor->vf_id >= pf->vf_num)return -ENODEV ; -/** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; -/* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops;
drivers/net/mlx4/mlx4.c +0 -1
@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device;rte_eth_copy_pci_info (eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver;/* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle ){ .fd =-1 ,
drivers/net/mlx5/mlx5.c +0 -1
@@ -1090,7 +1090,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err =mlx5_uar_init_primary (eth_dev);if (err) { err = rte_errno;
drivers/net/szedata2/rte_eth_szedata2.c +3 -3
@@ -1474,7 +1474,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev, struct port_info *pi)PMD_INIT_FUNC_TRACE ();PMD_INIT_LOG (INFO ,"Initializing eth_dev %s (driver %s)" , data->name, - dev->device->driver->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ));/* Fill internal private structure. */ internals->dev = dev;
@@ -1525,7 +1525,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev, struct port_info *pi)ether_addr_copy (ð_addr, data->mac_addrs);PMD_INIT_LOG (INFO ,"%s device %s successfully initialized" , - dev->device->driver->name, data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), data->name);return 0 ; }
@@ -1547,7 +1547,7 @@ rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev)rte_free (dev->data->mac_addrs);PMD_DRV_LOG (INFO ,"%s device %s successfully uninitialized" , - dev->device->driver->name, dev->data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), dev->data->name);return 0 ; }
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -156,7 +156,7 @@ struct rte_driver {struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ -const struct rte_driver *driver;/**< Associated driver */ +const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */
Signature · 1 line
2.19.0
PATCH v5 6/7 eal: add function to query device status
In reply to Thomas MonjalonThe function rte_dev_is_probed() is added in order to improve semantic and enforce proper check of the probing status of a device.
It will answer this rte_device query:
Is it already successfully probed or not?
--- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- drivers/bus/pci/pci_common.c | 2 +- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/vmbus_common.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 9 ++++++++- lib/librte_eal/common/include/rte_dev.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 7 files changed, 28 insertions(+), 6 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +2 -2
@@ -301,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->device.driver !=NULL ) +if (rte_dev_is_probed (&afu_dev->device))return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
@@ -325,7 +325,7 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (afu_dev->device.driver) +if (rte_dev_is_probed (&afu_dev->device))continue ; ret =ifpga_probe_all_drivers (afu_dev);
drivers/bus/pci/pci_common.c +1 -1
@@ -243,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) +if (rte_dev_is_probed (&dev->device))return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {
drivers/bus/vdev/vdev.c +1 -1
@@ -481,7 +481,7 @@ vdev_probe(void)* we call each driver probe. */ -if (dev->device.driver) +if (rte_dev_is_probed (&dev->device))continue ;if (vdev_probe_all_drivers (dev)) {
drivers/bus/vmbus/vmbus_common.c +1 -1
@@ -143,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->device.driver !=NULL ) { +if (rte_dev_is_probed (&dev->device)) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }
lib/librte_eal/common/eal_common_dev.c +8 -1
@@ -74,6 +74,13 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)return strcmp (dev->name, name); } +int __rte_experimental +rte_dev_is_probed (const struct rte_device *dev) +{ +/* The field driver should be set only when the probe is successful. */ +return dev->driver !=NULL ; +} +int rte_eal_dev_attach (const char *name,const char *devargs) {struct rte_bus *bus;
@@ -189,7 +196,7 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (dev->driver !=NULL ) { +if (rte_dev_is_probed (dev)) {RTE_LOG (ERR ,EAL ,"Device is already plugged\n" );return -EEXIST ; }
lib/librte_eal/common/include/rte_dev.h +14 -0
@@ -162,6 +162,20 @@ struct rte_device {struct rte_devargs *devargs;/**< Device user arguments */ }; +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice +* +* Query status of a device. +* +* @param dev +* Generic device pointer. +* @return +* (int)true if already probed successfully, 0 otherwise. +*/ +__rte_experimental +int rte_dev_is_probed(const struct rte_device *dev); +/** * Attach a device to a registered driver. *
lib/librte_eal/rte_eal_version.map +1 -0
@@ -279,6 +279,7 @@ EXPERIMENTAL { rte_dev_event_callback_unregister; rte_dev_event_monitor_start; rte_dev_event_monitor_stop; + rte_dev_is_probed; rte_dev_iterator_init; rte_dev_iterator_next; rte_dev_probe;
Signature · 1 line
2.19.0
PATCH v5 7/7 eal: allow probing a device again
In reply to Thomas MonjalonIn the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existing rte_device.
That's why the check for an already probed device
is moved as bus responsibility.
In the case of vdev, a global check is kept in insert_vdev(), assuming that a vdev will always have only one port.
In the case of ifpga and vmbus, already probed devices are checked. In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.
In the case of PCI, a driver flag is added to allow PMD probing again. Only the PMD knows the ports attached to one rte_device.
As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.
--- drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 14 ++++++----- drivers/bus/pci/pci_common.c | 33 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 4 ++- drivers/bus/vdev/vdev.c | 5 ++++ lib/librte_eal/common/eal_common_dev.c | 7 ++---- lib/librte_eal/common/include/rte_dev.h | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +3 -0
@@ -555,6 +555,9 @@ rte_dpaa_bus_probe(void)if (ret)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (!drv->probe || (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ))
drivers/bus/fslmc/fslmc_bus.c +3 -0
@@ -386,6 +386,9 @@ rte_fslmc_probe(void)if (!drv->probe)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ) { DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
drivers/bus/ifpga/ifpga_bus.c +8 -6
@@ -301,8 +301,11 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&afu_dev->device)) -return 0 ; +if (rte_dev_is_probed (&afu_dev->device)) { +IFPGA_BUS_DEBUG ("Device %s is already probed\n" , +rte_ifpga_device_name (afu_dev)); +return -EEXIST ; + } TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {if (ifpga_probe_one_driver (drv, afu_dev)) {
@@ -325,14 +328,13 @@ ifpga_probe(void)int ret =0 ; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { -if (rte_dev_is_probed (&afu_dev->device)) -continue ; - ret =ifpga_probe_all_drivers (afu_dev); +if (ret == -EEXIST ) +continue ;if (ret <0 )IFPGA_BUS_ERR ("failed to initialize %s device\n" ,rte_ifpga_device_name (afu_dev)); - } + }return ret; }
drivers/bus/pci/pci_common.c +22 -11
@@ -6,6 +6,7 @@#include <string.h> #include <inttypes.h> #include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <sys/queue.h>
@@ -121,6 +122,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) {int ret; +bool already_probed;struct rte_pci_addr *loc;if ((dr ==NULL ) || (dev ==NULL ))
@@ -151,6 +153,13 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, dev->device.numa_node =0 ; } + already_probed =rte_dev_is_probed (&dev->device); +if (already_probed && !(dr->drv_flags &RTE_PCI_DRV_PROBE_AGAIN )) { +RTE_LOG (DEBUG ,EAL ,"Device %s is already probed\n" , + dev->device.name); +return -EEXIST ; + } +RTE_LOG (INFO ,EAL ," probe driver: %x:%x %s\n" , dev->id.vendor_id, dev->id.device_id, dr->driver.name);
@@ -159,9 +168,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* This needs to be before rte_pci_map_device(), as it enables to use * driver flags for adjusting configuration. */ - dev->driver = dr; +if (!already_probed) + dev->driver = dr; -if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) { +if (!already_probed && (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING )) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) {
@@ -172,6 +182,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* call the driver probe() function */ ret = dr->probe (dr, dev); +if (already_probed) +return ret;/* no rollback if already succeeded earlier */ if (ret) { dev->driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&
@@ -242,10 +254,6 @@ pci_probe_all_drivers(struct rte_pci_device *dev)if (dev ==NULL )return -1 ; -/* Check if a driver is already loaded */ -if (rte_dev_is_probed (&dev->device)) -return 0 ; -FOREACH_DRIVER_ON_PCIBUS (dr) { rc =rte_pci_probe_one_driver (dr, dev);if (rc <0 )
@@ -287,11 +295,14 @@ rte_pci_probe(void) devargs->policy == RTE_DEV_WHITELISTED) ret =pci_probe_all_drivers (dev);if (ret <0 ) { -RTE_LOG (ERR ,EAL ,"Requested device " PCI_PRI_FMT -" cannot be used\n" , dev->addr.domain, dev->addr.bus, - dev->addr.devid, dev->addr.function); - rte_errno = errno; - failed++; +if (ret != -EEXIST ) { +RTE_LOG (ERR ,EAL ,"Requested device " +PCI_PRI_FMT " cannot be used\n" , + dev->addr.domain, dev->addr.bus, + dev->addr.devid, dev->addr.function); + rte_errno = errno; + failed++; + } ret =0 ; } }
drivers/bus/pci/rte_bus_pci.h +3 -1
@@ -121,7 +121,7 @@ struct rte_pci_driver {pci_probe_t *probe;/**< Device Probe function. */ pci_remove_t *remove;/**< Device Remove function. */ const struct rte_pci_id *id_table;/**< ID table, NULL terminated. */ -uint32_t drv_flags;/**< Flags contolling handling of device. */ +uint32_t drv_flags;/**< Flags RTE_PCI_DRV_*. */ };/**
@@ -137,6 +137,8 @@ struct rte_pci_bus {#define RTE_PCI_DRV_NEED_MAPPING 0x0001/** Device needs PCI BAR mapping with enabled write combining (wc) */ #define RTE_PCI_DRV_WC_ACTIVATE 0x0002 +/** Device already probed can be probed again to check for new ports. */ +#define RTE_PCI_DRV_PROBE_AGAIN 0x0004/** Device driver supports link state interrupt */ #define RTE_PCI_DRV_INTR_LSC 0x0008/** Device driver supports device removal interrupt */
drivers/bus/vdev/vdev.c +5 -0
@@ -226,6 +226,11 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) dev->device.name = devargs->name;if (find_vdev (name)) { +/* +* A vdev is expected to have only one port. +* So there is no reason to try probing again, +* even with new arguments. +*/ ret = -EEXIST ; goto fail; }
lib/librte_eal/common/eal_common_dev.c +2 -5
@@ -196,13 +196,10 @@ rte_dev_probe(const char *devargs) goto err_devarg; } -if (rte_dev_is_probed (dev)) { -RTE_LOG (ERR ,EAL ,"Device is already plugged\n" ); -return -EEXIST ; - } - ret = dev->bus->plug (dev);if (ret) { +if (rte_dev_is_probed (dev))/* if already succeeded earlier */ +return ret;/* no rollback */ RTE_LOG (ERR ,EAL ,"Driver cannot attach the device (%s)\n" , dev->name); goto err_devarg;
lib/librte_eal/common/include/rte_dev.h +1 -1
@@ -159,7 +159,7 @@ struct rte_device {const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ -struct rte_devargs *devargs;/**< Device user arguments */ +struct rte_devargs *devargs;/**< Arguments for latest probing */ };/**
Signature · 1 line
2.19.0
Re: [PATCH v5 1/7] net/mlx5: remove useless driver name comparison
In reply to Thomas Monjalon+Cc Yongseok and Shahaf
14/10/2018 22:47, Thomas Monjalon:
Quoted 28 lines
The function
mlx5_dev_to_port_id()is returning all the ports associated to arte_device.
It was comparing driver names while already comparingrte_devicepointers. If two devices are the same, they will have the same driver. So the useless driver name comparison is removed.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/mlx5_ethdev.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/net/mlx5/mlx5_ethdev.c +1
-4@@ -1305,10 +1305,7 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,RTE_ETH_FOREACH_DEV (id) {struct rte_eth_dev *ldev = &rte_eth_devices[id]; -if (!ldev->device || - !ldev->device->driver || -strcmp (ldev->device->driver->name,MLX5_DRIVER_NAME ) || - ldev->device != dev) +if (ldev->device != dev)continue ;if (n < port_list_n) port_list[n] = id;
Re: [PATCH v5 5/7] drivers/bus: move driver assignment to end of probing
In reply to Thomas Monjalon+Cc vmbus, ifpga, i40e, mlx and szedata2 maintainers
14/10/2018 22:47, Thomas Monjalon:
Quoted 245 lines
The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See
commit1d20a073fa5e("bus/pci: reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Tested-by Andrew Rybchenko <[email protected]>--- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - drivers/net/szedata2/rte_eth_szedata2.c | 6 +++--- lib/librte_eal/common/include/rte_dev.h | 2 +- 10 files changed, 17 insertions(+), 24 deletions(-)drivers/bus/ifpga/ifpga_bus.c +4
-5@@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,/* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver;/* call the driver probe() function */ ret = drv->probe (afu_dev); -if (ret) { +if (ret) afu_dev->driver =NULL ; - afu_dev->device.driver =NULL ; - } +else + afu_dev->device.driver = &drv->driver;return ret; }@@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->driver !=NULL ) +if (afu_dev->device.driver !=NULL )return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {drivers/bus/pci/pci_common.c +3
-4@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) { dev->driver =NULL ; - dev->device.driver =NULL ;return ret; } }@@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe (dr, dev);if (ret) { dev->driver =NULL ; - dev->device.driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources. @@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))rte_pci_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;@@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) +if (dev->device.driver !=NULL )return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {drivers/bus/pci/rte_bus_pci.h +1
-1@@ -62,7 +62,7 @@ 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;/**< Associated driver */ +struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */ drivers/bus/vdev/vdev.c +2
-3@@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)if (vdev_parse (name, &driver))return -1 ; - dev->device.driver = &driver->driver; ret = driver->probe (dev); -if (ret) - dev->device.driver =NULL ; +if (ret ==0 ) + dev->device.driver = &driver->driver;return ret; }drivers/bus/vmbus/vmbus_common.c +3
-2@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dev->device.numa_node <0 ) {VMBUS_LOG (WARNING ," Invalid NUMA socket, default to 0" );@@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)int rc;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) { +if (dev->device.driver !=NULL ) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }drivers/net/i40e/i40e_vf_representor.c +0
-3@@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)if (representor->vf_id >= pf->vf_num)return -ENODEV ; -/** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; -/* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops;drivers/net/mlx4/mlx4.c +0
-1@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device;rte_eth_copy_pci_info (eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver;/* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle ){ .fd =-1 ,drivers/net/mlx5/mlx5.c +0
-1@@ -1090,7 +1090,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err =mlx5_uar_init_primary (eth_dev);if (err) { err = rte_errno;drivers/net/szedata2/rte_eth_szedata2.c +3
-3@@ -1474,7 +1474,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev, struct port_info *pi)PMD_INIT_FUNC_TRACE ();PMD_INIT_LOG (INFO ,"Initializing eth_dev %s (driver %s)" , data->name, - dev->device->driver->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ));/* Fill internal private structure. */ internals->dev = dev;@@ -1525,7 +1525,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev, struct port_info *pi)ether_addr_copy (ð_addr, data->mac_addrs);PMD_INIT_LOG (INFO ,"%s device %s successfully initialized" , - dev->device->driver->name, data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), data->name);return 0 ; }@@ -1547,7 +1547,7 @@ rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev)rte_free (dev->data->mac_addrs);PMD_DRV_LOG (INFO ,"%s device %s successfully uninitialized" , - dev->device->driver->name, dev->data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), dev->data->name);return 0 ; }lib/librte_eal/common/include/rte_dev.h +1
-1@@ -156,7 +156,7 @@ struct rte_driver {struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ -const struct rte_driver *driver;/**< Associated driver */ +const struct rte_driver *driver;/**< Driver assigned after probing */ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */
Shahaf Shuler
Acked-byRe: [PATCH v5 1/7] net/mlx5: remove useless driver name comparison
In reply to Thomas MonjalonSunday, October 14, 2018 11:49 PM, Thomas Monjalon:
Quoted 26 lines
14/10/2018 22:47, Thomas Monjalon:
Quoted 3 lines
The function
mlx5_dev_to_port_id()is returning all the ports associated to arte_device.
It was comparing driver names while already comparingrte_devicepointers.
drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_to_port_id(const struct rte_device
Quoted 13 lines
If two devices are the same, they will have the same driver. So the useless driver name comparison is removed.
Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/mlx5_ethdev.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/mlx5/mlx5_ethdev.cindex61eda537b..cacdf8e18100644drivers/net/mlx5/mlx5_ethdev.c +0
-0@@ -1305,10 +1305,7 @@ mlx5_dev_to_port_id(const struct rte_device*dev,
uint16_t*port_list,drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,
Quoted 6 lines
drivers/net/mlx5/mlx5_ethdev.c +0
-3RTE_ETH_FOREACH_DEV (id) {struct rte_eth_dev *ldev = &rte_eth_devices[id]; - if (!ldev->device || - !ldev->device->driver || - strcmp(ldev->device->driver->name,
MLX5_DRIVER_NAME) ||
Quoted 6 lines
drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list, · line 1311
Quoted 6 lines
drivers/net/mlx5/mlx5_ethdev.c +1
-1- ldev->device != dev) +if (ldev->device != dev)continue ;if (n < port_list_n) port_list[n] = id;
Xu, Rosen
Reviewed-byRe: [PATCH v5 5/7] drivers/bus: move driver assignment to end of probing
In reply to Thomas MonjalonQuoted 68 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, October 15, 2018 4:54
To: [email protected]
Cc: [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; Xing, Beilei <[email protected]>; [email protected]; [email protected]; Xu, Rosen <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5 5/7]drivers/bus: move driver assignment to end of probing+Cc vmbus, ifpga, i40e, mlx and szedata2 maintainers
14/10/2018 22:47, Thomas Monjalon:
drivers/bus/ifpga/ifpga_bus.c ifpga_probe_all_drivers(struct rte_afu_device
Quoted 50 lines
The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See commit
1d20a073fa5e("bus/pci:
reference driver structure before mapping")However the
rte_driverdoes not need to be referenced inrte_devicebefore the device probing is done.
By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of arte_device.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Tested-by Andrew Rybchenko <[email protected]>--- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - drivers/net/szedata2/rte_eth_szedata2.c | 6 +++--- lib/librte_eal/common/include/rte_dev.h | 2 +- 10 files changed, 17 insertions(+), 24 deletions(-)(quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_bus.cindex80663328a..fca2dbace100644drivers/bus/ifpga/ifpga_bus.c +3
-4@@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,/* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver;/* call the driver probe() function */ ret = drv->probe (afu_dev); -if (ret) { +if (ret) afu_dev->driver =NULL ; - afu_dev->device.driver =NULL ; - } +else + afu_dev->device.driver = &drv->driver;return ret;}
drivers/bus/ifpga/ifpga_bus.c +0
-0@@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device
*afu_dev)
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c +1
-1return -1 ;/* Check if a driver is already loaded */ -if (afu_dev->driver !=NULL ) +if (afu_dev->device.driver !=NULL )return 0 ; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { diff --git
Quoted 211 lines
drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver
Quoted 5 lines
a/drivers/bus/pci/pci_common.cb/drivers/bus/pci/pci_common.cindexc7695d108..d63e68045100644drivers/bus/pci/pci_common.c +0
-0@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver*dr,
Quoted 23 lines
drivers/bus/pci/pci_common.c +0
-3* driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dr->drv_flags &RTE_PCI_DRV_NEED_MAPPING ) {/* map resources for devices that use igb_uio */ ret =rte_pci_map_device (dev);if (ret !=0 ) { dev->driver =NULL ; - dev->device.driver =NULL ;return ret; } }@@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe (dr, dev);if (ret) { dev->driver =NULL ; - dev->device.driver =NULL ; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&/* Don't unmap if device is unsupported and * driver needs mapped resources. drivers/bus/pci/pci_common.c rte_pci_probe_one_driver(struct rte_pci_driver *dr, · line 182
Quoted 2 lines
drivers/bus/pci/pci_common.c +0
-0@@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags &
RTE_PCI_DRV_KEEP_MAPPED_RES)))Quoted 59 lines
drivers/bus/pci/pci_common.c +3
-1rte_pci_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;@@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)return -1 ;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) +if (dev->device.driver !=NULL )return 0 ;FOREACH_DRIVER_ON_PCIBUS (dr) {(quoted diff) +0
-0
b/drivers/bus/pci/rte_bus_pci.hindex0d1955ffe..984df2b37100644drivers/bus/pci/rte_bus_pci.h +1
-1@@ -62,7 +62,7 @@ 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;/**< Associated driver */ +struct rte_pci_driver *driver;/**< PCI driver used in probing */ uint16_t max_vfs;/**< sriov enable if not zero */ enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ char name[PCI_PRI_STR_SIZE +1 ];/**< PCI location (ASCII) */ drivers/bus/vdev/vdev.c index renamed from drivers/bus/vdev/vdev.c +0
-0
0142fb2c8..3f27f3510100644drivers/bus/vdev/vdev.c +2
-3@@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)if (vdev_parse (name, &driver))return -1 ; - dev->device.driver = &driver->driver; ret = driver->probe (dev); -if (ret) - dev->device.driver =NULL ; +if (ret ==0 ) + dev->device.driver = &driver->driver;return ret; }drivers/bus/vmbus/vmbus_common.c +0
-1@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver;if (dev->device.numa_node <0 ) {Quoted 1 line
VMBUS_LOG(WARNING, " Invalid NUMA socket, default to
0"); @@
drivers/bus/vmbus/vmbus_common.c vmbus_probe_all_drivers(struct rte_vmbus_device
Quoted 10 lines
-124,6 +123,8 @@ vmbus_probe_one_driver(struct
rte_vmbus_driver*dr,drivers/bus/vmbus/vmbus_common.c +2
-0if (ret) { dev->driver =NULL ;rte_vmbus_unmap_device (dev); + }else { + dev->device.driver = &dr->driver; }return ret;@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device*dev)
drivers/net/i40e/i40e_vf_representor.c i40e_vf_representor_init(struct rte_eth_dev
Quoted 14 lines
drivers/bus/vmbus/vmbus_common.c +1
-1int rc;/* Check if a driver is already loaded */ -if (dev->driver !=NULL ) { +if (dev->device.driver !=NULL ) {VMBUS_LOG (DEBUG ,"VMBUS driver already loaded" );return 0 ; }drivers/net/i40e/i40e_vf_representor.c +0
-0@@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev*ethdev, void
*init_params)drivers/net/mlx4/mlx4.c mlx4_pci_probe(struct rte_pci_driver *pci_drv,
Quoted 15 lines
drivers/net/i40e/i40e_vf_representor.c +0
-3if (representor->vf_id >= pf->vf_num)return -ENODEV ; -/** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device- driver; -/* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops;drivers/net/mlx4/mlx4.c index renamed from drivers/net/mlx4/mlx4.c +0
-0
defc0d4b0..3de7bc53e100644drivers/net/mlx4/mlx4.c +0
-0@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv,struct
rte_pci_device*pci_dev)drivers/net/szedata2/rte_eth_szedata2.c rte_szedata2_eth_dev_init(struct rte_eth_dev
Quoted 25 lines
drivers/net/mlx4/mlx4.c +0
-1eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device;rte_eth_copy_pci_info (eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver;/* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle ){ .fd =-1 ,drivers/net/mlx5/mlx5.c index renamed from drivers/net/mlx5/mlx5.c +0
-0
795a21977..8cbfee1ba100644drivers/net/mlx5/mlx5.c +0
-1@@ -1090,7 +1090,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err =mlx5_uar_init_primary (eth_dev);if (err) { err = rte_errno;drivers/net/szedata2/rte_eth_szedata2.c +0
-0@@ -1474,7 +1474,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev*dev, struct
port_info*pi)drivers/net/szedata2/rte_eth_szedata2.c rte_szedata2_eth_dev_init(struct rte_eth_dev
Quoted 10 lines
drivers/net/szedata2/rte_eth_szedata2.c +1
-1PMD_INIT_FUNC_TRACE ();PMD_INIT_LOG (INFO ,"Initializing eth_dev %s (driver %s)" , data- name, - dev->device->driver->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ));/* Fill internal private structure. */ drivers/net/szedata2/rte_eth_szedata2.c +0
-0internals->dev = dev;@@ -1525,7 +1525,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev*dev, struct
port_info*pi)drivers/net/szedata2/rte_eth_szedata2.c rte_szedata2_eth_dev_uninit(struct rte_eth_dev
Quoted 10 lines
drivers/net/szedata2/rte_eth_szedata2.c +1
-1ether_addr_copy (ð_addr, data->mac_addrs);PMD_INIT_LOG (INFO ,"%s device %s successfully initialized" , - dev->device->driver->name, data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), data- name);return 0 ;}
drivers/net/szedata2/rte_eth_szedata2.c +0
-0@@ -1547,7 +1547,7 @@ rte_szedata2_eth_dev_uninit(struct rte_eth_dev*dev)
Quoted 24 lines
drivers/net/szedata2/rte_eth_szedata2.c +1
-1rte_free (dev->data->mac_addrs);PMD_DRV_LOG (INFO ,"%s device %s successfully uninitialized" , - dev->device->driver->name, dev->data->name); +RTE_STR (RTE_SZEDATA2_DRIVER_NAME ), dev->data- name);return 0 ;}
lib/librte_eal/common/include/rte_dev.h +2
-1@@ -156,7 +156,7 @@ struct rte_driver { struct rte_device {TAILQ_ENTRY (rte_device) next;/**< Next device */ const char *name;/**< Device name */ -const struct rte_driver *driver;/**< Associated driver */ +const struct rte_driver *driver;/**< Driver assigned after probing +*/ const struct rte_bus *bus;/**< Bus handle assigned on scan */ int numa_node;/**< NUMA node connection */ struct rte_devargs *devargs;/**< Device user arguments */
Re: [PATCH v5 3/7] cryptodev: remove driver name from logs
In reply to Thomas Monjalon+Cc Declan
14/10/2018 22:47, Thomas Monjalon:
Quoted 68 lines
The logs printed by CDEV_LOG_* were prefixed with the driver name.
In order to avoid assigning the driver before the end of the probing, the driver name is removed from the cryptodev library logs.
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_cryptodev/rte_cryptodev_pmd.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)lib/librte_cryptodev/rte_cryptodev_pmd.c +8
-15@@ -93,24 +93,20 @@ rte_cryptodev_pmd_create(const char *name,struct rte_cryptodev *cryptodev;if (params->name[0 ] !='\0' ) { -CDEV_LOG_INFO ("[%s] User specified device name = %s\n" , - device->driver->name, params->name); +CDEV_LOG_INFO ("User specified device name = %s\n" , params->name); name = params->name; } -CDEV_LOG_INFO ("[%s] - Creating cryptodev %s\n" , - device->driver->name, name); +CDEV_LOG_INFO ("Creating cryptodev %s\n" , name); -CDEV_LOG_INFO ("[%s] - Initialisation parameters - name: %s," +CDEV_LOG_INFO ("Initialisation parameters - name: %s," "socket id: %d, max queue pairs: %u" , - device->driver->name, name, - params->socket_id, params->max_nb_queue_pairs); + name, params->socket_id, params->max_nb_queue_pairs);/* allocate device structure */ cryptodev =rte_cryptodev_pmd_allocate (name, params->socket_id);if (cryptodev ==NULL ) { -CDEV_LOG_ERR ("[%s] Failed to allocate crypto device for %s" , - device->driver->name, name); +CDEV_LOG_ERR ("Failed to allocate crypto device for %s" , name);return NULL ; }@@ -123,9 +119,8 @@ rte_cryptodev_pmd_create(const char *name, params->socket_id);if (cryptodev->data->dev_private ==NULL ) { -CDEV_LOG_ERR ("[%s] Cannot allocate memory for " -"cryptodev %s private data" , - device->driver->name, name); +CDEV_LOG_ERR ("Cannot allocate memory for cryptodev %s" +" private data" , name);rte_cryptodev_pmd_release_device (cryptodev);return NULL ;@@ -145,9 +140,7 @@ rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev) {int retval; -CDEV_LOG_INFO ("[%s] Closing crypto device %s" , - cryptodev->device->driver->name, - cryptodev->device->name); +CDEV_LOG_INFO ("Closing crypto device %s" , cryptodev->device->name);/* free crypto device */ retval =rte_cryptodev_pmd_release_device (cryptodev);
Re: [PATCH v5 4/7] compressdev: remove driver name from logs
In reply to Thomas Monjalon+Cc Fiona and Ashish
14/10/2018 22:47, Thomas Monjalon:
Quoted 67 lines
The logs printed by
COMPRESSDEV_LOGwere prefixed with the driver name.In order to avoid assigning the driver before the end of the probing, the driver name is removed from the compressdev library logs.
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_compressdev/rte_compressdev_pmd.c | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-)lib/librte_compressdev/rte_compressdev_pmd.c +9
-14@@ -92,24 +92,20 @@ rte_compressdev_pmd_create(const char *name,struct rte_compressdev *compressdev;if (params->name[0 ] !='\0' ) { -COMPRESSDEV_LOG (INFO ,"[%s] User specified device name = %s\n" , - device->driver->name, params->name); +COMPRESSDEV_LOG (INFO ,"User specified device name = %s\n" , + params->name); name = params->name; } -COMPRESSDEV_LOG (INFO ,"[%s] - Creating compressdev %s\n" , - device->driver->name, name); +COMPRESSDEV_LOG (INFO ,"Creating compressdev %s\n" , name); -COMPRESSDEV_LOG (INFO , -"[%s] - Init parameters - name: %s, socket id: %d" , - device->driver->name, name, - params->socket_id); +COMPRESSDEV_LOG (INFO ,"Init parameters - name: %s, socket id: %d" , + name, params->socket_id);/* allocate device structure */ compressdev =rte_compressdev_pmd_allocate (name, params->socket_id);if (compressdev ==NULL ) { -COMPRESSDEV_LOG (ERR ,"[%s] Failed to allocate comp device %s" , - device->driver->name, name); +COMPRESSDEV_LOG (ERR ,"Failed to allocate comp device %s" , name);return NULL ; }@@ -123,8 +119,8 @@ rte_compressdev_pmd_create(const char *name,if (compressdev->data->dev_private ==NULL ) {COMPRESSDEV_LOG (ERR , -"[%s] Cannot allocate memory for compressdev %s private data" , - device->driver->name, name); +"Cannot allocate memory for compressdev" +" %s private data" , name);rte_compressdev_pmd_release_device (compressdev);return NULL ;@@ -141,8 +137,7 @@ rte_compressdev_pmd_destroy(struct rte_compressdev *compressdev) {int retval; -COMPRESSDEV_LOG (INFO ,"[%s] Closing comp device %s" , - compressdev->device->driver->name, +COMPRESSDEV_LOG (INFO ,"Closing comp device %s" , compressdev->device->name);/* free comp device */
Re: [PATCH v5 7/7] eal: allow probing a device again
In reply to Thomas MonjalonQuoted 58 lines · Thomas Monjalon
In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax.If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously.
There can be new ports to create from an existingrte_device.That's why the check for an already probed device
is moved as bus responsibility.
In the case of vdev, a global check is kept ininsert_vdev(), assuming that a vdev will always have only one port.
In the case of ifpga and vmbus, already probed devices are checked. In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency.
In the case of PCI, a driver flag is added to allow PMD probing again. Only the PMD knows the ports attached to onerte_device.As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the
rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing.Signed-off-by Thomas Monjalon <[email protected]>Reviewed-by Andrew Rybchenko <[email protected]>Tested-by Andrew Rybchenko <[email protected]>--- drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 14 ++++++----- drivers/bus/pci/pci_common.c | 33 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 4 ++- drivers/bus/vdev/vdev.c | 5 ++++ lib/librte_eal/common/eal_common_dev.c | 7 ++---- lib/librte_eal/common/include/rte_dev.h | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-)drivers/bus/dpaa/dpaa_bus.c +3
-0@@ -555,6 +555,9 @@ rte_dpaa_bus_probe(void)if (ret)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (!drv->probe || (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ))drivers/bus/fslmc/fslmc_bus.c +0
-0
drivers/bus/fslmc/fslmc_bus.c rte_fslmc_probe(void) · line 394
Quoted 9 lines
drivers/bus/fslmc/fslmc_bus.c +3
-0@@ -386,6 +386,9 @@ rte_fslmc_probe(void)if (!drv->probe)continue ; +if (rte_dev_is_probed (&dev->device)) +continue ; +if (dev->device.devargs && dev->device.devargs->policy ==RTE_DEV_BLACKLISTED ) { DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
For the dpaa/fslmc part of this patch:
Thomas Monjalon
AppliedRe: [PATCH v5 0/7] allow hotplug to skip an already probed device
In reply to Thomas Monjalon14/10/2018 22:47, Thomas Monjalon:
Quoted 8 lines
Thomas Monjalon (7):
net/mlx5: remove useless driver name comparison
ethdev: rename memzones allocated for DMA
cryptodev: remove driver name from logs
compressdev: remove driver name from logsdrivers/bus: move driver assignment to end of probing
eal: add function to query device status
eal: allow probing a device again
Applied