* [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id
[not found] <20180509093105.25984-1-thomas@monjalon.net>
@ 2018-05-09 9:30 ` Thomas Monjalon
2018-05-09 10:44 ` Luca Boccassi
2018-05-09 9:30 ` [dpdk-stable] [PATCH 02/11] net/failsafe: fix sub-device visibility Thomas Monjalon
` (8 subsequent siblings)
9 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:30 UTC (permalink / raw)
To: matan; +Cc: stable
The owner id is 64-bit.
On 32-bit environment, it must be printed with PRIX64.
Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
lib/librte_ethdev/rte_ethdev.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index a357ee09f..72f84d2f3 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -376,7 +376,7 @@ rte_eth_is_valid_owner_id(uint64_t owner_id)
{
if (owner_id == RTE_ETH_DEV_NO_OWNER ||
rte_eth_dev_shared_data->next_owner_id <= owner_id) {
- RTE_PMD_DEBUG_TRACE("Invalid owner_id=%016lX.\n", owner_id);
+ RTE_PMD_DEBUG_TRACE("Invalid owner_id=%016"PRIX64".\n", owner_id);
return 0;
}
return 1;
@@ -426,7 +426,7 @@ _rte_eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
port_owner = &rte_eth_devices[port_id].data->owner;
if (port_owner->id != old_owner_id) {
RTE_PMD_DEBUG_TRACE("Cannot set owner to port %d already owned"
- " by %s_%016lX.\n", port_id,
+ " by %s_%016"PRIX64".\n", port_id,
port_owner->name, port_owner->id);
return -EPERM;
}
@@ -439,7 +439,7 @@ _rte_eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
port_owner->id = new_owner->id;
- RTE_PMD_DEBUG_TRACE("Port %d owner is %s_%016lX.\n", port_id,
+ RTE_PMD_DEBUG_TRACE("Port %d owner is %s_%016"PRIX64".\n", port_id,
new_owner->name, new_owner->id);
return 0;
@@ -491,8 +491,8 @@ rte_eth_dev_owner_delete(const uint64_t owner_id)
RTE_ETH_FOREACH_DEV_OWNED_BY(port_id, owner_id)
memset(&rte_eth_devices[port_id].data->owner, 0,
sizeof(struct rte_eth_dev_owner));
- RTE_PMD_DEBUG_TRACE("All port owners owned by %016X identifier"
- " have removed.\n", owner_id);
+ RTE_PMD_DEBUG_TRACE("All port owners owned by %016"PRIX64
+ " identifier have removed.\n", owner_id);
}
rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id
2018-05-09 9:30 ` [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id Thomas Monjalon
@ 2018-05-09 10:44 ` Luca Boccassi
2018-05-09 12:15 ` Thomas Monjalon
0 siblings, 1 reply; 16+ messages in thread
From: Luca Boccassi @ 2018-05-09 10:44 UTC (permalink / raw)
To: Thomas Monjalon, matan; +Cc: stable
On Wed, 2018-05-09 at 11:30 +0200, Thomas Monjalon wrote:
> The owner id is 64-bit.
> On 32-bit environment, it must be printed with PRIX64.
>
> Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> Cc: stable@dpdk.org
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> lib/librte_ethdev/rte_ethdev.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
It seems git am -3 is failing miserably on this series - if you have a
branch, could you please push it to your github fork or somewhere else
I can pull it in 18.02?
--
Kind regards,
Luca Boccassi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id
2018-05-09 10:44 ` Luca Boccassi
@ 2018-05-09 12:15 ` Thomas Monjalon
2018-05-09 13:59 ` Luca Boccassi
0 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 12:15 UTC (permalink / raw)
To: Luca Boccassi; +Cc: matan, stable
09/05/2018 12:44, Luca Boccassi:
> On Wed, 2018-05-09 at 11:30 +0200, Thomas Monjalon wrote:
> > The owner id is 64-bit.
> > On 32-bit environment, it must be printed with PRIX64.
> >
> > Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> > lib/librte_ethdev/rte_ethdev.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
>
> It seems git am -3 is failing miserably on this series - if you have a
> branch, could you please push it to your github fork or somewhere else
> I can pull it in 18.02?
I could send the series to stable@dpdk.org, when backported,
with 18.02 prefix in the title.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id
2018-05-09 12:15 ` Thomas Monjalon
@ 2018-05-09 13:59 ` Luca Boccassi
2018-05-09 14:52 ` Thomas Monjalon
0 siblings, 1 reply; 16+ messages in thread
From: Luca Boccassi @ 2018-05-09 13:59 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: matan, stable
On Wed, 2018-05-09 at 14:15 +0200, Thomas Monjalon wrote:
> 09/05/2018 12:44, Luca Boccassi:
> > On Wed, 2018-05-09 at 11:30 +0200, Thomas Monjalon wrote:
> > > The owner id is 64-bit.
> > > On 32-bit environment, it must be printed with PRIX64.
> > >
> > > Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > > ---
> > > lib/librte_ethdev/rte_ethdev.c | 10 +++++-----
> > > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > It seems git am -3 is failing miserably on this series - if you
> > have a
> > branch, could you please push it to your github fork or somewhere
> > else
> > I can pull it in 18.02?
>
> I could send the series to stable@dpdk.org, when backported,
> with 18.02 prefix in the title.
Ah sure, that's fine - given this series was sent exclusively to stable
@dpdk.org I thought it was already the backport
--
Kind regards,
Luca Boccassi
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id
2018-05-09 13:59 ` Luca Boccassi
@ 2018-05-09 14:52 ` Thomas Monjalon
0 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 14:52 UTC (permalink / raw)
To: Luca Boccassi; +Cc: matan, stable
09/05/2018 15:59, Luca Boccassi:
> On Wed, 2018-05-09 at 14:15 +0200, Thomas Monjalon wrote:
> > 09/05/2018 12:44, Luca Boccassi:
> > > On Wed, 2018-05-09 at 11:30 +0200, Thomas Monjalon wrote:
> > > > The owner id is 64-bit.
> > > > On 32-bit environment, it must be printed with PRIX64.
> > > >
> > > > Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > > > ---
> > > > lib/librte_ethdev/rte_ethdev.c | 10 +++++-----
> > > > 1 file changed, 5 insertions(+), 5 deletions(-)
> > >
> > > It seems git am -3 is failing miserably on this series - if you
> > > have a
> > > branch, could you please push it to your github fork or somewhere
> > > else
> > > I can pull it in 18.02?
> >
> > I could send the series to stable@dpdk.org, when backported,
> > with 18.02 prefix in the title.
>
> Ah sure, that's fine - given this series was sent exclusively to stable
> @dpdk.org I thought it was already the backport
It was a mistake: automatic Cc when doing internal draft send.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 02/11] net/failsafe: fix sub-device visibility
[not found] <20180509093105.25984-1-thomas@monjalon.net>
2018-05-09 9:30 ` [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id Thomas Monjalon
@ 2018-05-09 9:30 ` Thomas Monjalon
2018-05-09 9:30 ` [dpdk-stable] [PATCH 04/11] drivers/net: use higher level of probing helper for PCI Thomas Monjalon
` (7 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:30 UTC (permalink / raw)
To: matan; +Cc: stable
The iterator function rte_eth_find_next_owned_by(), used by the
iterator macro RTE_ETH_FOREACH_DEV_OWNED_BY, are ignoring the devices
which are neither ATTACHED nor REMOVED. Thus sub-devices, having
the state DEFERRED, cannot be seen with the ethdev iterator.
The state RTE_ETH_DEV_DEFERRED can be replaced by
RTE_ETH_DEV_ATTACHED + owner.
Fixes: dcd0c9c32b8d ("net/failsafe: use ownership mechanism for slaves")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Matan Azrad <matan@mellanox.com>
---
drivers/net/failsafe/failsafe_eal.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c
index ee89236f1..ce767703f 100644
--- a/drivers/net/failsafe/failsafe_eal.c
+++ b/drivers/net/failsafe/failsafe_eal.c
@@ -98,7 +98,6 @@ fs_bus_init(struct rte_eth_dev *dev)
SUB_ID(sdev) = i;
sdev->fs_dev = dev;
sdev->dev = ETH(sdev)->device;
- ETH(sdev)->state = RTE_ETH_DEV_DEFERRED;
sdev->state = DEV_PROBED;
}
return 0;
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 04/11] drivers/net: use higher level of probing helper for PCI
[not found] <20180509093105.25984-1-thomas@monjalon.net>
2018-05-09 9:30 ` [dpdk-stable] [PATCH 01/11] ethdev: fix debug log of owner id Thomas Monjalon
2018-05-09 9:30 ` [dpdk-stable] [PATCH 02/11] net/failsafe: fix sub-device visibility Thomas Monjalon
@ 2018-05-09 9:30 ` Thomas Monjalon
2018-05-09 9:30 ` [dpdk-stable] [PATCH 05/11] ethdev: add probing finish function Thomas Monjalon
` (6 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:30 UTC (permalink / raw)
To: matan; +Cc: stable
The drivers avp, bnx2x and liquidio were using the helper function
rte_eth_dev_pci_allocate() and can be replaced by
rte_eth_dev_pci_generic_probe() which calls the former.
Fixes: dcd5c8112bc3 ("ethdev: add PCI driver helpers")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/net/avp/avp_ethdev.c | 15 ++-------------
drivers/net/bnx2x/bnx2x_ethdev.c | 20 +++++---------------
drivers/net/liquidio/lio_ethdev.c | 15 ++-------------
3 files changed, 9 insertions(+), 41 deletions(-)
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index 5b3c4cebf..dc97e60e6 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -1048,19 +1048,8 @@ static int
eth_avp_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct rte_pci_device *pci_dev)
{
- struct rte_eth_dev *eth_dev;
- int ret;
-
- eth_dev = rte_eth_dev_pci_allocate(pci_dev,
- sizeof(struct avp_adapter));
- if (eth_dev == NULL)
- return -ENOMEM;
-
- ret = eth_avp_dev_init(eth_dev);
- if (ret)
- rte_eth_dev_pci_release(eth_dev);
-
- return ret;
+ return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct avp_adapter),
+ eth_avp_dev_init);
}
static int
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 6ccbb99c9..7a1e9f583 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -644,24 +644,14 @@ static struct rte_pci_driver rte_bnx2xvf_pmd;
static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
struct rte_pci_device *pci_dev)
{
- struct rte_eth_dev *eth_dev;
- int ret;
-
- eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct bnx2x_softc));
- if (!eth_dev)
- return -ENOMEM;
-
if (pci_drv == &rte_bnx2x_pmd)
- ret = eth_bnx2x_dev_init(eth_dev);
+ return rte_eth_dev_pci_generic_probe(pci_dev,
+ sizeof(struct bnx2x_softc), eth_bnx2x_dev_init);
else if (pci_drv == &rte_bnx2xvf_pmd)
- ret = eth_bnx2xvf_dev_init(eth_dev);
+ return rte_eth_dev_pci_generic_probe(pci_dev,
+ sizeof(struct bnx2x_softc), eth_bnx2xvf_dev_init);
else
- ret = -EINVAL;
-
- if (ret)
- rte_eth_dev_pci_release(eth_dev);
-
- return ret;
+ return -EINVAL;
}
static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index a13a566f9..0e0b5d84d 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -2110,19 +2110,8 @@ static int
lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct rte_pci_device *pci_dev)
{
- struct rte_eth_dev *eth_dev;
- int ret;
-
- eth_dev = rte_eth_dev_pci_allocate(pci_dev,
- sizeof(struct lio_device));
- if (eth_dev == NULL)
- return -ENOMEM;
-
- ret = lio_eth_dev_init(eth_dev);
- if (ret)
- rte_eth_dev_pci_release(eth_dev);
-
- return ret;
+ return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
+ lio_eth_dev_init);
}
static int
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 05/11] ethdev: add probing finish function
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (2 preceding siblings ...)
2018-05-09 9:30 ` [dpdk-stable] [PATCH 04/11] drivers/net: use higher level of probing helper for PCI Thomas Monjalon
@ 2018-05-09 9:30 ` Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 06/11] ethdev: allow ownership operations on unused port Thomas Monjalon
` (5 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:30 UTC (permalink / raw)
To: matan; +Cc: stable
A new hook function is added and called inside the PMDs at the end
of the device probing:
- in primary process, after allocating, init and config
- in secondary process, after attaching and local init
This new function is almost empty for now.
It will be used later to add some post-initialization processing.
For the PMDs calling the helpers rte_eth_dev_create() or
rte_eth_dev_pci_generic_probe(), the hook rte_eth_dev_probing_finish()
is called from here, and not in the PMD itself.
Note that the helper rte_eth_dev_create() could be used more,
especially for vdevs, avoiding some code duplication in PMDs.
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/net/af_packet/rte_eth_af_packet.c | 2 ++
drivers/net/ark/ark_ethdev.c | 2 ++
drivers/net/bonding/rte_eth_bond_pmd.c | 2 ++
drivers/net/cxgbe/cxgbe_ethdev.c | 1 +
drivers/net/cxgbe/cxgbe_main.c | 5 +++++
drivers/net/cxgbe/cxgbevf_ethdev.c | 1 +
drivers/net/cxgbe/cxgbevf_main.c | 5 +++++
drivers/net/dpaa/dpaa_ethdev.c | 5 ++++-
drivers/net/dpaa2/dpaa2_ethdev.c | 4 +++-
drivers/net/failsafe/failsafe.c | 2 ++
drivers/net/kni/rte_eth_kni.c | 2 ++
drivers/net/mlx4/mlx4.c | 1 +
drivers/net/mlx5/mlx5.c | 2 ++
drivers/net/mvpp2/mrvl_ethdev.c | 1 +
drivers/net/nfp/nfp_net.c | 2 ++
drivers/net/null/rte_eth_null.c | 2 ++
drivers/net/octeontx/octeontx_ethdev.c | 3 +++
drivers/net/pcap/rte_eth_pcap.c | 2 ++
drivers/net/ring/rte_eth_ring.c | 1 +
drivers/net/softnic/rte_eth_softnic.c | 3 +++
drivers/net/szedata2/rte_eth_szedata2.c | 2 ++
drivers/net/tap/rte_eth_tap.c | 2 ++
drivers/net/vhost/rte_eth_vhost.c | 2 ++
drivers/net/virtio/virtio_user_ethdev.c | 3 +++
lib/librte_ethdev/rte_ethdev.c | 9 +++++++++
lib/librte_ethdev/rte_ethdev_driver.h | 10 ++++++++++
lib/librte_ethdev/rte_ethdev_pci.h | 2 ++
lib/librte_ethdev/rte_ethdev_version.map | 1 +
test/test/virtual_pmd.c | 2 ++
29 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 12a08650c..ea47abbf8 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -911,6 +911,7 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
eth_dev->rx_pkt_burst = eth_af_packet_rx;
eth_dev->tx_pkt_burst = eth_af_packet_tx;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -934,6 +935,7 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index d275ab7e8..62e4fd35a 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -422,6 +422,8 @@ eth_ark_dev_init(struct rte_eth_dev *dev)
ark->user_data[eth_dev->data->port_id] =
ark->user_ext.dev_init(dev, ark->a_bar, p);
}
+
+ rte_eth_dev_probing_finish(eth_dev);
}
return ret;
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 0c44a9249..d0941c870 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3052,6 +3052,7 @@ bond_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &default_dev_ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -3124,6 +3125,7 @@ bond_probe(struct rte_vdev_device *dev)
rte_eth_bond_8023ad_agg_selection_set(port_id, AGG_STABLE);
}
+ rte_eth_dev_probing_finish(&rte_eth_devices[port_id]);
RTE_BOND_LOG(INFO, "Create bonded device %s on port %d in mode %u on "
"socket %u.", name, port_id, bonding_mode, socket_id);
return 0;
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 3df51b5be..ec71dc426 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -1147,6 +1147,7 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
eth_dev->rx_pkt_burst;
rest_eth_dev->tx_pkt_burst =
eth_dev->tx_pkt_burst;
+ rte_eth_dev_probing_finish(rest_eth_dev);
}
}
return 0;
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 74bccd514..9ad5e5493 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -1435,6 +1435,11 @@ int cxgbe_probe(struct adapter *adapter)
err = -1;
goto out_free;
}
+
+ if (i > 0) {
+ /* First port will be notified by upper layer */
+ rte_eth_dev_probing_finish(eth_dev);
+ }
}
if (adapter->flags & FW_OK) {
diff --git a/drivers/net/cxgbe/cxgbevf_ethdev.c b/drivers/net/cxgbe/cxgbevf_ethdev.c
index 4885b9748..a942ba6b6 100644
--- a/drivers/net/cxgbe/cxgbevf_ethdev.c
+++ b/drivers/net/cxgbe/cxgbevf_ethdev.c
@@ -138,6 +138,7 @@ static int eth_cxgbevf_dev_init(struct rte_eth_dev *eth_dev)
eth_dev->rx_pkt_burst;
rest_eth_dev->tx_pkt_burst =
eth_dev->tx_pkt_burst;
+ rte_eth_dev_probing_finish(rest_eth_dev);
}
}
return 0;
diff --git a/drivers/net/cxgbe/cxgbevf_main.c b/drivers/net/cxgbe/cxgbevf_main.c
index 6c81fd12e..5b3fb5399 100644
--- a/drivers/net/cxgbe/cxgbevf_main.c
+++ b/drivers/net/cxgbe/cxgbevf_main.c
@@ -267,6 +267,11 @@ int cxgbevf_probe(struct adapter *adapter)
err = -ENOMEM;
goto out_free;
}
+
+ if (i > 0) {
+ /* First port will be notified by upper layer */
+ rte_eth_dev_probing_finish(eth_dev);
+ }
}
if (adapter->flags & FW_OK) {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 6bf8c1590..ffeed1159 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1385,6 +1385,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
eth_dev = rte_eth_dev_attach_secondary(dpaa_dev->name);
if (!eth_dev)
return -ENOMEM;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -1434,8 +1435,10 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
/* Invoke PMD device initialization function */
diag = dpaa_dev_init(eth_dev);
- if (diag == 0)
+ if (diag == 0) {
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
+ }
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_free(eth_dev->data->dev_private);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index c304b82bd..b5dfd708b 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -2034,8 +2034,10 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
/* Invoke PMD device initialization function */
diag = dpaa2_dev_init(eth_dev);
- if (diag == 0)
+ if (diag == 0) {
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
+ }
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_free(eth_dev->data->dev_private);
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 5e7a8ba1b..fc989c4f5 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -259,6 +259,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
.fd = -1,
.type = RTE_INTR_HANDLE_EXT,
};
+ rte_eth_dev_probing_finish(dev);
return 0;
free_args:
failsafe_args_free(dev);
@@ -311,6 +312,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &failsafe_ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index b468138bd..ab63ea427 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -419,6 +419,7 @@ eth_kni_probe(struct rte_vdev_device *vdev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = ð_kni_ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -437,6 +438,7 @@ eth_kni_probe(struct rte_vdev_device *vdev)
eth_dev->rx_pkt_burst = eth_kni_rx;
eth_dev->tx_pkt_burst = eth_kni_tx;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
kni_uninit:
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 47451b651..7ad61d5a2 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -737,6 +737,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
/* Update link status once if waiting for LSC. */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
mlx4_link_update(eth_dev, 0);
+ rte_eth_dev_probing_finish(eth_dev);
continue;
port_error:
rte_free(priv);
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5190b9fcd..8c1f6d63e 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -826,6 +826,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
mlx5_select_rx_function(eth_dev);
eth_dev->tx_pkt_burst =
mlx5_select_tx_function(eth_dev);
+ rte_eth_dev_probing_finish(eth_dev);
continue;
}
DRV_LOG(DEBUG, "using port %u (%08" PRIx32 ")", port, test);
@@ -1055,6 +1056,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto port_error;
}
priv->config.max_verbs_prio = verb_priorities;
+ rte_eth_dev_probing_finish(eth_dev);
continue;
port_error:
if (priv)
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 05998bf2d..799de8ad0 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -2606,6 +2606,7 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
eth_dev->device = &vdev->device;
eth_dev->dev_ops = &mrvl_ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
out_free_mac:
rte_free(eth_dev->data->mac_addrs);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 048324ec9..02a98b983 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3130,6 +3130,8 @@ nfp_pf_create_dev(struct rte_pci_device *dev, int port, int ports,
if (ret)
rte_eth_dev_release_port(eth_dev);
+ else
+ rte_eth_dev_probing_finish(eth_dev);
rte_free(port_name);
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index f04a7d7bf..1d2e6b9e9 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -559,6 +559,7 @@ eth_dev_null_create(struct rte_vdev_device *dev,
eth_dev->tx_pkt_burst = eth_null_tx;
}
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -622,6 +623,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index 261b17f9b..1854711e4 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -1078,6 +1078,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
eth_dev->tx_pkt_burst = octeontx_xmit_pkts;
eth_dev->rx_pkt_burst = octeontx_recv_pkts;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -1162,6 +1163,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
rte_octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7]
[(nic->base_ochan >> 4) & 0xF] = data->port_id;
+ rte_eth_dev_probing_finish(eth_dev);
return data->port_id;
err:
@@ -1242,6 +1244,7 @@ octeontx_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &octeontx_dev_ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 44c4d8ee0..6bd4a7d79 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -893,6 +893,7 @@ eth_from_pcaps(struct rte_vdev_device *vdev,
else
eth_dev->tx_pkt_burst = eth_pcap_tx;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -924,6 +925,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index be934cffa..35b837c3f 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -329,6 +329,7 @@ do_eth_dev_ring_create(const char *name,
eth_dev->rx_pkt_burst = eth_ring_rx;
eth_dev->tx_pkt_burst = eth_ring_tx;
+ rte_eth_dev_probing_finish(eth_dev);
*eth_dev_p = eth_dev;
return data->port_id;
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index b1f2780c7..6b3c13e5c 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -535,6 +535,8 @@ pmd_ethdev_register(struct rte_vdev_device *vdev,
soft_dev->data->kdrv = RTE_KDRV_NONE;
soft_dev->data->numa_node = numa_node;
+ rte_eth_dev_probing_finish(soft_dev);
+
return 0;
}
@@ -748,6 +750,7 @@ pmd_probe(struct rte_vdev_device *vdev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &pmd_ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index d105e50f3..910c64d04 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1841,6 +1841,8 @@ static int szedata2_eth_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
rte_free(list_entry);
return ret;
}
+
+ rte_eth_dev_probing_finish(eth_devs[i]);
}
/*
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 172a7ba4c..01232dcdc 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1532,6 +1532,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
}
}
+ rte_eth_dev_probing_finish(dev);
return 0;
disable_rte_flow:
@@ -1728,6 +1729,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index bd42eee6b..0d000c71c 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1284,6 +1284,7 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
goto error;
}
+ rte_eth_dev_probing_finish(eth_dev);
return data->port_id;
error:
@@ -1354,6 +1355,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &ops;
+ rte_eth_dev_probing_finish(eth_dev);
return 0;
}
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 4e7b3c34f..8eab909da 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -563,6 +563,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
virtio_user_eth_dev_free(eth_dev);
goto end;
}
+
} else {
eth_dev = rte_eth_dev_attach_secondary(rte_vdev_device_name(dev));
if (!eth_dev)
@@ -575,6 +576,8 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
virtio_user_eth_dev_free(eth_dev);
goto end;
}
+
+ rte_eth_dev_probing_finish(eth_dev);
ret = 0;
end:
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 72f84d2f3..6071e3a9b 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3361,6 +3361,13 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
return rc;
}
+void
+rte_eth_dev_probing_finish(struct rte_eth_dev *dev)
+{
+ if (dev == NULL)
+ return;
+}
+
int
rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
{
@@ -3475,6 +3482,8 @@ rte_eth_dev_create(struct rte_device *device, const char *name,
goto probe_failed;
}
+ rte_eth_dev_probing_finish(ethdev);
+
return retval;
probe_failed:
/* free ports private data if primary process */
diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h
index da52b7026..3821f0b1d 100644
--- a/lib/librte_ethdev/rte_ethdev_driver.h
+++ b/lib/librte_ethdev/rte_ethdev_driver.h
@@ -101,6 +101,16 @@ void _rte_eth_dev_reset(struct rte_eth_dev *dev);
int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
enum rte_eth_event_type event, void *ret_param);
+/**
+ * @internal
+ * This is the last step of device probing.
+ * It must be called after a port is allocated and initialized successfully.
+ *
+ * @param dev
+ * New ethdev port.
+ */
+void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
+
/**
* Create memzone for HW rings.
* malloc can't be used as the physical address is needed.
diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index 603287c28..2cfd37274 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -175,6 +175,8 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev,
ret = dev_init(eth_dev);
if (ret)
rte_eth_dev_pci_release(eth_dev);
+ else
+ rte_eth_dev_probing_finish(eth_dev);
return ret;
}
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index 9c9394c58..2fe2f6ed2 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -199,6 +199,7 @@ DPDK_18.05 {
global:
rte_eth_dev_count_avail;
+ rte_eth_dev_probing_finish;
rte_eth_find_next_owned_by;
rte_flow_copy;
rte_flow_create;
diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c
index 69b4ba034..f8ddc2db8 100644
--- a/test/test/virtual_pmd.c
+++ b/test/test/virtual_pmd.c
@@ -590,6 +590,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success;
eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success;
+ rte_eth_dev_probing_finish(eth_dev);
+
return eth_dev->data->port_id;
err:
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 06/11] ethdev: allow ownership operations on unused port
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (3 preceding siblings ...)
2018-05-09 9:30 ` [dpdk-stable] [PATCH 05/11] ethdev: add probing finish function Thomas Monjalon
@ 2018-05-09 9:31 ` Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 07/11] ethdev: add lock to port allocation check Thomas Monjalon
` (4 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:31 UTC (permalink / raw)
To: matan; +Cc: stable
From: Matan Azrad <matan@mellanox.com>
When the state will be updated later than in allocation,
we may need to update the ownership of a port which is
still in state unused.
It will be used to take ownership of a port before it is
declared as available for other entities.
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
lib/librte_ethdev/rte_ethdev.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 6071e3a9b..ae86d0ba7 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -414,10 +414,14 @@ static int
_rte_eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
const struct rte_eth_dev_owner *new_owner)
{
+ struct rte_eth_dev *ethdev = &rte_eth_devices[port_id];
struct rte_eth_dev_owner *port_owner;
int sret;
- RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+ if (port_id >= RTE_MAX_ETHPORTS || ethdev->data->name[0] == '\0') {
+ RTE_PMD_DEBUG_TRACE("Port id %"PRIu16" is not allocated.\n", port_id);
+ return -ENODEV;
+ }
if (!rte_eth_is_valid_owner_id(new_owner->id) &&
!rte_eth_is_valid_owner_id(old_owner_id))
@@ -481,16 +485,17 @@ rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id)
void __rte_experimental
rte_eth_dev_owner_delete(const uint64_t owner_id)
{
- uint16_t port_id;
+ uint32_t port_id;
rte_eth_dev_shared_data_prepare();
rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
if (rte_eth_is_valid_owner_id(owner_id)) {
- RTE_ETH_FOREACH_DEV_OWNED_BY(port_id, owner_id)
- memset(&rte_eth_devices[port_id].data->owner, 0,
- sizeof(struct rte_eth_dev_owner));
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
+ if (rte_eth_devices[port_id].data->owner.id == owner_id)
+ memset(&rte_eth_devices[port_id].data->owner, 0,
+ sizeof(struct rte_eth_dev_owner));
RTE_PMD_DEBUG_TRACE("All port owners owned by %016"PRIX64
" identifier have removed.\n", owner_id);
}
@@ -502,17 +507,17 @@ int __rte_experimental
rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)
{
int ret = 0;
+ struct rte_eth_dev *ethdev = &rte_eth_devices[port_id];
rte_eth_dev_shared_data_prepare();
rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
- if (!rte_eth_dev_is_valid_port(port_id)) {
- RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+ if (port_id >= RTE_MAX_ETHPORTS || ethdev->data->name[0] == '\0') {
+ RTE_PMD_DEBUG_TRACE("Port id %"PRIu16" is not allocated.\n", port_id);
ret = -ENODEV;
} else {
- rte_memcpy(owner, &rte_eth_devices[port_id].data->owner,
- sizeof(*owner));
+ rte_memcpy(owner, ðdev->data->owner, sizeof(*owner));
}
rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 07/11] ethdev: add lock to port allocation check
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (4 preceding siblings ...)
2018-05-09 9:31 ` [dpdk-stable] [PATCH 06/11] ethdev: allow ownership operations on unused port Thomas Monjalon
@ 2018-05-09 9:31 ` Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 08/11] ethdev: fix port visibility before initialization Thomas Monjalon
` (3 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:31 UTC (permalink / raw)
To: matan; +Cc: stable
From: Matan Azrad <matan@mellanox.com>
When comparing the port name, there can be a race condition with
a thread allocating a new port and writing the name at the same time.
It can lead to match with a partial name by error.
The check of the port is now considered as a critical section
protected with locks.
This fix will be even more required for multi-process when the
port availability will rely only on the name, in a following patch.
Fixes: 84934303a17c ("ethdev: synchronize port allocation")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
lib/librte_ethdev/rte_ethdev.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index ae86d0ba7..357be2dca 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -227,8 +227,8 @@ rte_eth_dev_shared_data_prepare(void)
rte_spinlock_unlock(&rte_eth_shared_data_lock);
}
-struct rte_eth_dev *
-rte_eth_dev_allocated(const char *name)
+static struct rte_eth_dev *
+rte_eth_dev_allocated_lock_free(const char *name)
{
unsigned i;
@@ -240,6 +240,22 @@ rte_eth_dev_allocated(const char *name)
return NULL;
}
+struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+ struct rte_eth_dev *ethdev;
+
+ rte_eth_dev_shared_data_prepare();
+
+ rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
+
+ ethdev = rte_eth_dev_allocated_lock_free(name);
+
+ rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+ return ethdev;
+}
+
static uint16_t
rte_eth_dev_find_free_port(void)
{
@@ -286,7 +302,7 @@ rte_eth_dev_allocate(const char *name)
goto unlock;
}
- if (rte_eth_dev_allocated(name) != NULL) {
+ if (rte_eth_dev_allocated_lock_free(name) != NULL) {
ethdev_log(ERR,
"Ethernet Device with name %s already allocated!",
name);
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 08/11] ethdev: fix port visibility before initialization
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (5 preceding siblings ...)
2018-05-09 9:31 ` [dpdk-stable] [PATCH 07/11] ethdev: add lock to port allocation check Thomas Monjalon
@ 2018-05-09 9:31 ` Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 09/11] ethdev: fix port probing notification Thomas Monjalon
` (2 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:31 UTC (permalink / raw)
To: matan; +Cc: stable
The port was set to the state ATTACHED during allocation.
The consequence was to iterate over ports which are not initialized.
The state ATTACHED is now set as the last step of probing.
The uniqueness of port name is now checked before the availability
of a port id for allocation (order reversed).
As the state is not set on allocation anymore, it is also not checked
in the function telling whether a port is allocated or not.
The name of the port is set on allocation, so it is enough as a check.
Fixes: 5588909af21b ("ethdev: add device iterator")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
lib/librte_ethdev/rte_ethdev.c | 18 +++++++++---------
lib/librte_ethdev/rte_ethdev_driver.h | 2 ++
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 357be2dca..91cd0db11 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -233,7 +233,7 @@ rte_eth_dev_allocated_lock_free(const char *name)
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if ((rte_eth_devices[i].state == RTE_ETH_DEV_ATTACHED) &&
+ if (rte_eth_devices[i].data != NULL &&
strcmp(rte_eth_devices[i].data->name, name) == 0)
return &rte_eth_devices[i];
}
@@ -278,7 +278,6 @@ eth_dev_get(uint16_t port_id)
struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
eth_dev->data = &rte_eth_dev_shared_data->data[port_id];
- eth_dev->state = RTE_ETH_DEV_ATTACHED;
eth_dev_last_created_port = port_id;
@@ -296,16 +295,15 @@ rte_eth_dev_allocate(const char *name)
/* Synchronize port creation between primary and secondary threads. */
rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
- port_id = rte_eth_dev_find_free_port();
- if (port_id == RTE_MAX_ETHPORTS) {
- ethdev_log(ERR, "Reached maximum number of Ethernet ports");
+ if (rte_eth_dev_allocated_lock_free(name) != NULL) {
+ ethdev_log(ERR, "Ethernet device with name %s already allocated",
+ name);
goto unlock;
}
- if (rte_eth_dev_allocated_lock_free(name) != NULL) {
- ethdev_log(ERR,
- "Ethernet Device with name %s already allocated!",
- name);
+ port_id = rte_eth_dev_find_free_port();
+ if (port_id == RTE_MAX_ETHPORTS) {
+ ethdev_log(ERR, "Reached maximum number of Ethernet ports");
goto unlock;
}
@@ -3387,6 +3385,8 @@ rte_eth_dev_probing_finish(struct rte_eth_dev *dev)
{
if (dev == NULL)
return;
+
+ dev->state = RTE_ETH_DEV_ATTACHED;
}
int
diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h
index 3821f0b1d..3640dff68 100644
--- a/lib/librte_ethdev/rte_ethdev_driver.h
+++ b/lib/librte_ethdev/rte_ethdev_driver.h
@@ -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 state is set as RTE_ETH_DEV_ATTACHED.
+ *
* @param dev
* New ethdev port.
*/
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 09/11] ethdev: fix port probing notification
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (6 preceding siblings ...)
2018-05-09 9:31 ` [dpdk-stable] [PATCH 08/11] ethdev: fix port visibility before initialization Thomas Monjalon
@ 2018-05-09 9:31 ` Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 10/11] net/failsafe: fix sub-device ownership race Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 11/11] ethdev: fix port removal notification timing Thomas Monjalon
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:31 UTC (permalink / raw)
To: matan; +Cc: stable
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>
---
lib/librte_ethdev/rte_ethdev.c | 5 ++---
lib/librte_ethdev/rte_ethdev_driver.h | 2 ++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 91cd0db11..e1209bb2a 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -315,9 +315,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;
}
@@ -3386,6 +3383,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;
}
diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h
index 3640dff68..c9c825e3f 100644
--- a/lib/librte_ethdev/rte_ethdev_driver.h
+++ b/lib/librte_ethdev/rte_ethdev_driver.h
@@ -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
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 10/11] net/failsafe: fix sub-device ownership race
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (7 preceding siblings ...)
2018-05-09 9:31 ` [dpdk-stable] [PATCH 09/11] ethdev: fix port probing notification Thomas Monjalon
@ 2018-05-09 9:31 ` Thomas Monjalon
2018-05-09 9:31 ` [dpdk-stable] [PATCH 11/11] ethdev: fix port removal notification timing Thomas Monjalon
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:31 UTC (permalink / raw)
To: matan; +Cc: stable
From: Matan Azrad <matan@mellanox.com>
There is time between the sub-device port probing by the sub-device PMD
to the sub-device port ownership taking by a fail-safe port.
In this time, the port is available for the application usage. For
example, the port will be exposed to the applications which use
RTE_ETH_FOREACH_DEV iterator.
Thus, ownership unaware applications may manage the port in this time
what may cause a lot of problematic behaviors in the fail-safe
sub-device initialization.
Register to the ethdev NEW event to take the sub-device port ownership
before it becomes exposed to the application.
Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
drivers/net/failsafe/failsafe.c | 22 ++++++++++---
drivers/net/failsafe/failsafe_eal.c | 58 +++++++++++++++++++++------------
drivers/net/failsafe/failsafe_ether.c | 23 +++++++++++++
drivers/net/failsafe/failsafe_private.h | 4 +++
4 files changed, 83 insertions(+), 24 deletions(-)
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index fc989c4f5..c9d128de3 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -204,16 +204,25 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
}
snprintf(priv->my_owner.name, sizeof(priv->my_owner.name),
FAILSAFE_OWNER_NAME);
+ DEBUG("Failsafe port %u owner info: %s_%016"PRIX64, dev->data->port_id,
+ priv->my_owner.name, priv->my_owner.id);
+ ret = rte_eth_dev_callback_register(RTE_ETH_ALL, RTE_ETH_EVENT_NEW,
+ failsafe_eth_new_event_callback,
+ dev);
+ if (ret) {
+ ERROR("Failed to register NEW callback");
+ goto free_args;
+ }
ret = failsafe_eal_init(dev);
if (ret)
- goto free_args;
+ goto unregister_new_callback;
ret = fs_mutex_init(priv);
if (ret)
- goto free_args;
+ goto unregister_new_callback;
ret = failsafe_hotplug_alarm_install(dev);
if (ret) {
ERROR("Could not set up plug-in event detection");
- goto free_args;
+ goto unregister_new_callback;
}
mac = &dev->data->mac_addrs[0];
if (mac_from_arg) {
@@ -226,7 +235,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
mac);
if (ret) {
ERROR("Failed to set default MAC address");
- goto free_args;
+ goto unregister_new_callback;
}
}
} else {
@@ -261,6 +270,9 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
};
rte_eth_dev_probing_finish(dev);
return 0;
+unregister_new_callback:
+ rte_eth_dev_callback_unregister(RTE_ETH_ALL, RTE_ETH_EVENT_NEW,
+ failsafe_eth_new_event_callback, dev);
free_args:
failsafe_args_free(dev);
free_subs:
@@ -280,6 +292,8 @@ fs_rte_eth_free(const char *name)
dev = rte_eth_dev_allocated(name);
if (dev == NULL)
return -ENODEV;
+ rte_eth_dev_callback_unregister(RTE_ETH_ALL, RTE_ETH_EVENT_NEW,
+ failsafe_eth_new_event_callback, dev);
ret = failsafe_eal_uninit(dev);
if (ret)
ERROR("Error while uninitializing sub-EAL");
diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c
index ce767703f..8f1b9d845 100644
--- a/drivers/net/failsafe/failsafe_eal.c
+++ b/drivers/net/failsafe/failsafe_eal.c
@@ -10,7 +10,7 @@
static int
fs_ethdev_portid_get(const char *name, uint16_t *port_id)
{
- uint16_t pid;
+ uint32_t pid;
size_t len;
if (name == NULL) {
@@ -18,8 +18,9 @@ fs_ethdev_portid_get(const char *name, uint16_t *port_id)
return -EINVAL;
}
len = strlen(name);
- RTE_ETH_FOREACH_DEV(pid) {
- if (!strncmp(name, rte_eth_devices[pid].device->name, len)) {
+ for (pid = 0; pid < RTE_MAX_ETHPORTS; pid++) {
+ if (rte_eth_dev_is_valid_port(pid) &&
+ !strncmp(name, rte_eth_devices[pid].device->name, len)) {
*port_id = pid;
return 0;
}
@@ -41,6 +42,8 @@ fs_bus_init(struct rte_eth_dev *dev)
continue;
da = &sdev->devargs;
if (fs_ethdev_portid_get(da->name, &pid) != 0) {
+ struct rte_eth_dev_owner pid_owner;
+
ret = rte_eal_hotplug_add(da->bus->name,
da->name,
da->args);
@@ -55,12 +58,26 @@ fs_bus_init(struct rte_eth_dev *dev)
ERROR("sub_device %d init went wrong", i);
return -ENODEV;
}
+ /*
+ * The NEW callback tried to take ownership, check
+ * whether it succeed or didn't.
+ */
+ rte_eth_dev_owner_get(pid, &pid_owner);
+ if (pid_owner.id != PRIV(dev)->my_owner.id) {
+ INFO("sub_device %d owner(%s_%016"PRIX64") is not my,"
+ " owner(%s_%016"PRIX64"), will try again later",
+ i, pid_owner.name, pid_owner.id,
+ PRIV(dev)->my_owner.name,
+ PRIV(dev)->my_owner.id);
+ continue;
+ }
} else {
+ /* The sub-device port was found. */
char devstr[DEVARGS_MAXLEN] = "";
struct rte_devargs *probed_da =
rte_eth_devices[pid].device->devargs;
- /* Take control of device probed by EAL options. */
+ /* Take control of probed device. */
free(da->args);
memset(da, 0, sizeof(*da));
if (probed_da != NULL)
@@ -77,22 +94,23 @@ fs_bus_init(struct rte_eth_dev *dev)
}
INFO("Taking control of a probed sub device"
" %d named %s", i, da->name);
- }
- ret = rte_eth_dev_owner_set(pid, &PRIV(dev)->my_owner);
- if (ret < 0) {
- INFO("sub_device %d owner set failed (%s),"
- " will try again later", i, strerror(-ret));
- continue;
- } else if (strncmp(rte_eth_devices[pid].device->name, da->name,
- strlen(da->name)) != 0) {
- /*
- * The device probably was removed and its port id was
- * reallocated before ownership set.
- */
- rte_eth_dev_owner_unset(pid, PRIV(dev)->my_owner.id);
- INFO("sub_device %d was probably removed before taking"
- " ownership, will try again later", i);
- continue;
+ ret = rte_eth_dev_owner_set(pid, &PRIV(dev)->my_owner);
+ if (ret < 0) {
+ INFO("sub_device %d owner set failed (%s), "
+ "will try again later", i, strerror(-ret));
+ continue;
+ } else if (strncmp(rte_eth_devices[pid].device->name,
+ da->name, strlen(da->name)) != 0) {
+ /*
+ * The device probably was removed and its port
+ * id was reallocated before ownership set.
+ */
+ rte_eth_dev_owner_unset(pid,
+ PRIV(dev)->my_owner.id);
+ INFO("sub_device %d was removed before taking"
+ " ownership, will try again later", i);
+ continue;
+ }
}
ETH(sdev) = &rte_eth_devices[pid];
SUB_ID(sdev) = i;
diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
index b414a7884..ebce87841 100644
--- a/drivers/net/failsafe/failsafe_ether.c
+++ b/drivers/net/failsafe/failsafe_ether.c
@@ -463,3 +463,26 @@ failsafe_eth_lsc_event_callback(uint16_t port_id __rte_unused,
else
return 0;
}
+
+/* Take sub-device ownership before it becomes exposed to the application. */
+int
+failsafe_eth_new_event_callback(uint16_t port_id,
+ enum rte_eth_event_type event __rte_unused,
+ void *cb_arg, void *out __rte_unused)
+{
+ struct rte_eth_dev *fs_dev = cb_arg;
+ struct sub_device *sdev;
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ size_t len = strlen(dev->device->name);
+ uint8_t i;
+
+ FOREACH_SUBDEV_STATE(sdev, i, fs_dev, DEV_PARSED) {
+ if (sdev->state >= DEV_PROBED)
+ continue;
+ if (strncmp(sdev->devargs.name, dev->device->name, len) != 0)
+ continue;
+ rte_eth_dev_owner_set(port_id, &PRIV(fs_dev)->my_owner);
+ break;
+ }
+ return 0;
+}
diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
index b54f8e336..cd8e0b8c9 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -220,6 +220,10 @@ int failsafe_eth_rmv_event_callback(uint16_t port_id,
int failsafe_eth_lsc_event_callback(uint16_t port_id,
enum rte_eth_event_type event,
void *cb_arg, void *out);
+int
+failsafe_eth_new_event_callback(uint16_t port_id,
+ enum rte_eth_event_type event,
+ void *cb_arg, void *out);
/* GLOBALS */
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-stable] [PATCH 11/11] ethdev: fix port removal notification timing
[not found] <20180509093105.25984-1-thomas@monjalon.net>
` (8 preceding siblings ...)
2018-05-09 9:31 ` [dpdk-stable] [PATCH 10/11] net/failsafe: fix sub-device ownership race Thomas Monjalon
@ 2018-05-09 9:31 ` Thomas Monjalon
9 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2018-05-09 9:31 UTC (permalink / raw)
To: matan; +Cc: stable
From: Matan Azrad <matan@mellanox.com>
When an ethdev port is released, a destroy event is triggered to notify
the users about the released port.
A bit before the destroy event is triggered, the port becomes invalid
by changing its state to UNUSED and cleaning its data. Therefore, the
port is invalid for the destroy event callback process and the users
may get a wrong information of the port.
Move the destroy event emitting to be called before the port
invalidation.
Fixes: 133b54779aa1 ("ethdev: fix port data reset timing")
Fixes: 29aa41e36de7 ("ethdev: add notifications for probing and removal")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
lib/librte_ethdev/rte_ethdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index e1209bb2a..45ef13ab8 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -359,6 +359,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_eth_dev_shared_data_prepare();
+ _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+
rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
eth_dev->state = RTE_ETH_DEV_UNUSED;
@@ -367,8 +369,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
- _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
-
return 0;
}
--
2.16.2
^ permalink raw reply [flat|nested] 16+ messages in thread