ethdev: fix port probing notification
authorThomas Monjalon <thomas@monjalon.net>
Thu, 10 May 2018 23:58:34 +0000 (01:58 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:31:53 +0000 (22:31 +0100)
The new device was notified as soon as it was allocated.
It leads to use a device which is not yet initialized.

The notification must be published after the initialization is done
by the PMD, but before the state is changed, in order to let
notified entities taking ownership before general availability.

Fixes: 29aa41e36de7 ("ethdev: add notifications for probing and removal")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev_driver.h

index 0c65030..1ff2368 100644 (file)
@@ -322,9 +322,6 @@ rte_eth_dev_allocate(const char *name)
 unlock:
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
 
-       if (eth_dev != NULL)
-               _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_NEW, NULL);
-
        return eth_dev;
 }
 
@@ -3480,6 +3477,8 @@ rte_eth_dev_probing_finish(struct rte_eth_dev *dev)
        if (dev == NULL)
                return;
 
+       _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL);
+
        dev->state = RTE_ETH_DEV_ATTACHED;
 }
 
index 3640dff..c9c825e 100644 (file)
@@ -106,6 +106,8 @@ int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
  * This is the last step of device probing.
  * It must be called after a port is allocated and initialized successfully.
  *
+ * The notification RTE_ETH_EVENT_NEW is sent to other entities
+ * (libraries and applications).
  * The state is set as RTE_ETH_DEV_ATTACHED.
  *
  * @param dev