DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach
@ 2016-10-07 13:01 David Marchand
  2016-10-07 13:01 ` [dpdk-dev] [PATCH 2/2] ethdev: fix vendor id in debug message David Marchand
  2016-10-10  9:52 ` [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach Thomas Monjalon
  0 siblings, 2 replies; 3+ messages in thread
From: David Marchand @ 2016-10-07 13:01 UTC (permalink / raw)
  To: thomas.monjalon; +Cc: dev, danielx.t.mrzyglod, shreyansh.jain

If a pci probe operation creates a port but, for any reason, fails to
finish this operation and decides to delete the newly created port, then
the last created port id can not be trusted anymore and any subsequent
attach operations will fail.

This problem was noticed while working on a vm that had a virtio-net
management interface bound to the virtio-net kernel driver and no port
whitelisted in the commandline:

root@ubuntu1404:~/dpdk# ./build/app/testpmd -c 0x6 --
	 -i --total-num-mbufs=2049
EAL: Detected 3 lcore(s)
EAL: Probing VFIO support...
EAL: Debug logs available - lower performance
EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using
	unreliable clock cycles !
EAL: PCI device 0000:00:03.0 on NUMA socket -1
EAL:   probe driver: 1af4:1000 (null)
rte_eth_dev_pci_probe: driver (null): eth_dev_init(vendor_id=0x6900
	device_id=0x1000) failed
EAL: No probed ethernet devices
     ^
     |
     Here, rte_eth_dev_pci_probe() fails since vtpci_init() reports an
     error. This results in a rte_eth_dev_release_port() right after a
     rte_eth_dev_allocate().

Then, if we try to attach a port using rte_eth_dev_attach:

testpmd> port attach net_ring0
Attaching a new port...
PMD: Initializing pmd_ring for net_ring0
PMD: Creating rings-backed ethdev on numa socket 0

Two solutions:
- either update the last created port index to something invalid
  (when freeing a ethdev port),
- or rely on the port count, before and after the eal attach.

The latter solution seems (well not really more robust but at least)
less fragile than the former.
We still have some issues with drivers that create multiple ethdev
ports with a single probe operation, but this was already the case.

Fixes: b0fb26685570 ("ethdev: convert to EAL hotplug")

Reported-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_ether/rte_ethdev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index c517e88..24029f0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -421,7 +421,7 @@ int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
 	int ret = -1;
-	int current = eth_dev_last_created_port;
+	int current = rte_eth_dev_count();
 	char *name = NULL;
 	char *args = NULL;
 
@@ -438,9 +438,9 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 	if (ret < 0)
 		goto err;
 
-	/* no point looking at eth_dev_last_created_port if no port exists */
-	if (!nb_ports) {
-		RTE_LOG(ERR, EAL, "No ports found for device (%s)\n", name);
+	/* no point looking at the port count if no port exists */
+	if (!rte_eth_dev_count()) {
+		RTE_LOG(ERR, EAL, "No port found for device (%s)\n", name);
 		ret = -1;
 		goto err;
 	}
@@ -448,7 +448,7 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 	/* if nothing happened, there is a bug here, since some driver told us
 	 * it did attach a device, but did not create a port.
 	 */
-	if (current == eth_dev_last_created_port) {
+	if (current == rte_eth_dev_count()) {
 		ret = -1;
 		goto err;
 	}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] [PATCH 2/2] ethdev: fix vendor id in debug message
  2016-10-07 13:01 [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach David Marchand
@ 2016-10-07 13:01 ` David Marchand
  2016-10-10  9:52 ` [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach Thomas Monjalon
  1 sibling, 0 replies; 3+ messages in thread
From: David Marchand @ 2016-10-07 13:01 UTC (permalink / raw)
  To: thomas.monjalon; +Cc: dev, danielx.t.mrzyglod, shreyansh.jain

Fixes: af75078fece3 ("first public release")

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 24029f0..88fa382 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -274,7 +274,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return 0;
 
-	RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
+	RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%x device_id=0x%x) failed\n",
 			pci_drv->driver.name,
 			(unsigned) pci_dev->id.vendor_id,
 			(unsigned) pci_dev->id.device_id);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach
  2016-10-07 13:01 [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach David Marchand
  2016-10-07 13:01 ` [dpdk-dev] [PATCH 2/2] ethdev: fix vendor id in debug message David Marchand
@ 2016-10-10  9:52 ` Thomas Monjalon
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2016-10-10  9:52 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, danielx.t.mrzyglod, shreyansh.jain

2016-10-07 15:01, David Marchand:
> If a pci probe operation creates a port but, for any reason, fails to
> finish this operation and decides to delete the newly created port, then
> the last created port id can not be trusted anymore and any subsequent
> attach operations will fail.
> 
> This problem was noticed while working on a vm that had a virtio-net
> management interface bound to the virtio-net kernel driver and no port
> whitelisted in the commandline:
[...]
> Two solutions:
> - either update the last created port index to something invalid
>   (when freeing a ethdev port),
> - or rely on the port count, before and after the eal attach.
> 
> The latter solution seems (well not really more robust but at least)
> less fragile than the former.
> We still have some issues with drivers that create multiple ethdev
> ports with a single probe operation, but this was already the case.
> 
> Fixes: b0fb26685570 ("ethdev: convert to EAL hotplug")
> 
> Reported-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> Signed-off-by: David Marchand <david.marchand@6wind.com>

Series applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-10  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-07 13:01 [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach David Marchand
2016-10-07 13:01 ` [dpdk-dev] [PATCH 2/2] ethdev: fix vendor id in debug message David Marchand
2016-10-10  9:52 ` [dpdk-dev] [PATCH 1/2] ethdev: fix hotplug attach Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).