* [dpdk-dev] [PATCH] net/mlx5: fix device scan within switch domain
@ 2019-10-07 13:56 Viacheslav Ovsiienko
2019-10-08 9:35 ` Raslan Darawsheh
0 siblings, 1 reply; 2+ messages in thread
From: Viacheslav Ovsiienko @ 2019-10-07 13:56 UTC (permalink / raw)
To: dev; +Cc: matan, rasland
In LAG configuration the devices in the same switch domain
might be spawned on the base of different PCI devices, so
we should check all devices backed by mlx5 PMD whether they
belong to specified switch domain. When the new devices are
being created it is not possible to detect whether the
sibling devices created in the current probe() loop belong
to the driver, driver field is not filled yet (it will be
done on returned success of current probe()). This patch
updates the device scanning, allowing extra match on
current backing PCI device, is being used to create siblings.
Fixes: 9f4a56d68966 ("net/mlx5: extend switch domain searching range")
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
drivers/net/mlx5/mlx5.c | 30 +++++++++++++++++++++++-------
drivers/net/mlx5/mlx5.h | 8 ++++----
drivers/net/mlx5/mlx5_ethdev.c | 4 ++--
3 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 13d112e..f886d51 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -927,7 +927,7 @@ struct mlx5_dev_spawn_data {
unsigned int c = 0;
uint16_t port_id;
- MLX5_ETH_FOREACH_DEV(port_id) {
+ MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
struct mlx5_priv *opriv =
rte_eth_devices[port_id].data->dev_private;
@@ -1546,7 +1546,7 @@ struct mlx5_dev_spawn_data {
if (sh->refcnt == 1)
return 0;
/* Find the device with shared context. */
- MLX5_ETH_FOREACH_DEV(port_id) {
+ MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
struct mlx5_priv *opriv =
rte_eth_devices[port_id].data->dev_private;
@@ -1904,7 +1904,7 @@ struct mlx5_dev_spawn_data {
* Look for sibling devices in order to reuse their switch domain
* if any, otherwise allocate one.
*/
- MLX5_ETH_FOREACH_DEV(port_id) {
+ MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
const struct mlx5_priv *opriv =
rte_eth_devices[port_id].data->dev_private;
@@ -2782,17 +2782,33 @@ struct mlx5_dev_spawn_data {
return ret;
}
+/**
+ * Look for the ethernet device belonging to mlx5 driver.
+ *
+ * @param[in] port_id
+ * port_id to start looking for device.
+ * @param[in] pci_dev
+ * Pointer to the hint PCI device. When device is being probed
+ * the its siblings (master and preceding representors might
+ * not have assigned driver yet (because the mlx5_pci_probe()
+ * is not completed yet, for this case match on hint PCI
+ * device may be used to detect sibling device.
+ *
+ * @return
+ * port_id of found device, RTE_MAX_ETHPORT if not found.
+ */
uint16_t
-mlx5_eth_find_next(uint16_t port_id)
+mlx5_eth_find_next(uint16_t port_id, struct rte_pci_device *pci_dev)
{
while (port_id < RTE_MAX_ETHPORTS) {
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
if (dev->state != RTE_ETH_DEV_UNUSED &&
dev->device &&
- dev->device->driver &&
- dev->device->driver->name &&
- !strcmp(dev->device->driver->name, MLX5_DRIVER_NAME))
+ (dev->device == &pci_dev->device ||
+ (dev->device->driver &&
+ dev->device->driver->name &&
+ !strcmp(dev->device->driver->name, MLX5_DRIVER_NAME))))
break;
port_id++;
}
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 164df11..baf945c 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -682,13 +682,13 @@ int32_t mlx5_release_dbr(struct rte_eth_dev *dev, uint32_t umem_id,
uint64_t offset);
int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *udp_tunnel);
-uint16_t mlx5_eth_find_next(uint16_t port_id);
+uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_pci_device *pci_dev);
/* Macro to iterate over all valid ports for mlx5 driver. */
-#define MLX5_ETH_FOREACH_DEV(port_id) \
- for (port_id = mlx5_eth_find_next(0); \
+#define MLX5_ETH_FOREACH_DEV(port_id, pci_dev) \
+ for (port_id = mlx5_eth_find_next(0, pci_dev); \
port_id < RTE_MAX_ETHPORTS; \
- port_id = mlx5_eth_find_next(port_id + 1))
+ port_id = mlx5_eth_find_next(port_id + 1, pci_dev))
/* mlx5_ethdev.c */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index aa645d0..f2b1752 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -601,7 +601,7 @@ struct ethtool_link_settings {
info->switch_info.port_id |=
priv->pf_bond << MLX5_PORT_ID_BONDING_PF_SHIFT;
}
- MLX5_ETH_FOREACH_DEV(port_id) {
+ MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
struct mlx5_priv *opriv =
rte_eth_devices[port_id].data->dev_private;
@@ -734,7 +734,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
priv = dev->data->dev_private;
domain_id = priv->domain_id;
assert(priv->representor);
- MLX5_ETH_FOREACH_DEV(port_id) {
+ MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
struct mlx5_priv *opriv =
rte_eth_devices[port_id].data->dev_private;
if (opriv &&
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] net/mlx5: fix device scan within switch domain
2019-10-07 13:56 [dpdk-dev] [PATCH] net/mlx5: fix device scan within switch domain Viacheslav Ovsiienko
@ 2019-10-08 9:35 ` Raslan Darawsheh
0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2019-10-08 9:35 UTC (permalink / raw)
To: Slava Ovsiienko, dev; +Cc: Matan Azrad
Hi,
> -----Original Message-----
> From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> Sent: Monday, October 7, 2019 4:56 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@mellanox.com>; Raslan Darawsheh
> <rasland@mellanox.com>
> Subject: [PATCH] net/mlx5: fix device scan within switch domain
>
> In LAG configuration the devices in the same switch domain might be
> spawned on the base of different PCI devices, so we should check all devices
> backed by mlx5 PMD whether they belong to specified switch domain. When
> the new devices are being created it is not possible to detect whether the
> sibling devices created in the current probe() loop belong to the driver, driver
> field is not filled yet (it will be done on returned success of current probe()).
> This patch updates the device scanning, allowing extra match on current
> backing PCI device, is being used to create siblings.
>
> Fixes: 9f4a56d68966 ("net/mlx5: extend switch domain searching range")
>
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-08 9:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 13:56 [dpdk-dev] [PATCH] net/mlx5: fix device scan within switch domain Viacheslav Ovsiienko
2019-10-08 9:35 ` Raslan Darawsheh
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).