DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] common/mlx5: fix obtaining IB device in LAG mode
@ 2023-06-30 12:41 Bing Zhao
  2023-07-03 13:59 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Bing Zhao @ 2023-06-30 12:41 UTC (permalink / raw)
  To: matan, viacheslavo, orika, suanmingm, rasland; +Cc: dev, rongweil, stable

In hardware LAG mode, both PFs are in the same E-Switch domain but
the VFs are in the other domains. Moreover, VF has its own dedicated
IB device.

When probing a VF created on the 1st PF, usually its PCIe address
is the same as the PF's except the function part. Then there would
be some wrong VF BDF match on the IB "bond" device due to incomplete
comparison (we do not compare the function part of BDF for bonding
devices to match all bonded PFs).

Adding one extra condition to check whether the current PCIe address
device is a VF will solve the incorrect IB device recognition. Thus
the full address comparison will be done.

Fixes: f956d3d4c33c ("net/mlx5: fix probing with secondary bonding member")
Cc: rongweil@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/common/mlx5/linux/mlx5_common_os.c | 16 +++++++++-------
 drivers/common/mlx5/mlx5_common.h          |  2 +-
 drivers/common/mlx5/mlx5_common_pci.c      |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
index aafff60eeb..2ebb8ac8b6 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.c
+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
@@ -555,7 +555,7 @@ mlx5_os_pd_prepare(struct mlx5_common_device *cdev)
 }
 
 static struct ibv_device *
-mlx5_os_get_ibv_device(const struct rte_pci_addr *addr)
+mlx5_os_get_ibv_device(const struct rte_pci_device *pci_dev)
 {
 	int n;
 	struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n);
@@ -564,6 +564,8 @@ mlx5_os_get_ibv_device(const struct rte_pci_addr *addr)
 	uint8_t guid2[32] = {0};
 	int ret1, ret2 = -1;
 	struct rte_pci_addr paddr;
+	const struct rte_pci_addr *addr = &pci_dev->addr;
+	bool is_vf_dev = mlx5_dev_is_vf_pci(pci_dev);
 
 	if (ibv_list == NULL || !n) {
 		rte_errno = ENOSYS;
@@ -579,11 +581,11 @@ mlx5_os_get_ibv_device(const struct rte_pci_addr *addr)
 		if (ret1 > 0)
 			ret2 = mlx5_get_device_guid(&paddr, guid2, sizeof(guid2));
 		/* Bond device can bond secondary PCIe */
-		if ((strstr(ibv_list[n]->name, "bond") &&
-		    ((ret1 > 0 && ret2 > 0 && !memcmp(guid1, guid2, sizeof(guid1))) ||
-		    (addr->domain == paddr.domain && addr->bus == paddr.bus &&
-		     addr->devid == paddr.devid))) ||
-		     !rte_pci_addr_cmp(addr, &paddr)) {
+		if ((strstr(ibv_list[n]->name, "bond") && !is_vf_dev &&
+		     ((ret1 > 0 && ret2 > 0 && !memcmp(guid1, guid2, sizeof(guid1))) ||
+		      (addr->domain == paddr.domain && addr->bus == paddr.bus &&
+		       addr->devid == paddr.devid))) ||
+		    !rte_pci_addr_cmp(addr, &paddr)) {
 			ibv_match = ibv_list[n];
 			break;
 		}
@@ -697,7 +699,7 @@ mlx5_os_get_ibv_dev(const struct rte_device *dev)
 	struct ibv_device *ibv;
 
 	if (mlx5_dev_is_pci(dev))
-		ibv = mlx5_os_get_ibv_device(&RTE_DEV_TO_PCI_CONST(dev)->addr);
+		ibv = mlx5_os_get_ibv_device(RTE_DEV_TO_PCI_CONST(dev));
 	else
 		ibv = mlx5_get_aux_ibv_device(RTE_DEV_TO_AUXILIARY_CONST(dev));
 	if (ibv == NULL) {
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index 42d938776a..28f9f41528 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -600,7 +600,7 @@ mlx5_dev_is_pci(const struct rte_device *dev);
  */
 __rte_internal
 bool
-mlx5_dev_is_vf_pci(struct rte_pci_device *pci_dev);
+mlx5_dev_is_vf_pci(const struct rte_pci_device *pci_dev);
 
 __rte_internal
 int
diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c
index 5122c596bc..04aad0963c 100644
--- a/drivers/common/mlx5/mlx5_common_pci.c
+++ b/drivers/common/mlx5/mlx5_common_pci.c
@@ -109,7 +109,7 @@ mlx5_dev_is_pci(const struct rte_device *dev)
 }
 
 bool
-mlx5_dev_is_vf_pci(struct rte_pci_device *pci_dev)
+mlx5_dev_is_vf_pci(const struct rte_pci_device *pci_dev)
 {
 	switch (pci_dev->id.device_id) {
 	case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:
-- 
2.34.1


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

* RE: [PATCH] common/mlx5: fix obtaining IB device in LAG mode
  2023-06-30 12:41 [PATCH] common/mlx5: fix obtaining IB device in LAG mode Bing Zhao
@ 2023-07-03 13:59 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2023-07-03 13:59 UTC (permalink / raw)
  To: Bing Zhao, Matan Azrad, Slava Ovsiienko, Ori Kam, Suanming Mou
  Cc: dev, Rongwei Liu, stable

Hi,

> -----Original Message-----
> From: Bing Zhao <bingz@nvidia.com>
> Sent: Friday, June 30, 2023 3:42 PM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Cc: dev@dpdk.org; Rongwei Liu <rongweil@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] common/mlx5: fix obtaining IB device in LAG mode
> 
> In hardware LAG mode, both PFs are in the same E-Switch domain but the VFs
> are in the other domains. Moreover, VF has its own dedicated IB device.
> 
> When probing a VF created on the 1st PF, usually its PCIe address is the same
> as the PF's except the function part. Then there would be some wrong VF BDF
> match on the IB "bond" device due to incomplete comparison (we do not
> compare the function part of BDF for bonding devices to match all bonded
> PFs).
> 
> Adding one extra condition to check whether the current PCIe address device
> is a VF will solve the incorrect IB device recognition. Thus the full address
> comparison will be done.
> 
> Fixes: f956d3d4c33c ("net/mlx5: fix probing with secondary bonding
> member")
> Cc: rongweil@nvidia.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.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:[~2023-07-03 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 12:41 [PATCH] common/mlx5: fix obtaining IB device in LAG mode Bing Zhao
2023-07-03 13:59 ` 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).