DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: David Marchand <david.marchand@redhat.com>,
	chenbox@nvidia.com, Long Li <longli@microsoft.com>,
	Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>
Subject: [PATCH 2/2] drivers: use function to compare PCI addresses
Date: Thu, 19 Oct 2023 17:31:53 +0200	[thread overview]
Message-ID: <20231019154125.308002-3-thomas@monjalon.net> (raw)
In-Reply-To: <20231019154125.308002-1-thomas@monjalon.net>

Some places were not using the function rte_pci_addr_cmp()
to compare 2 PCI addresses.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/mana/mana.c          | 6 ++----
 drivers/net/mlx4/mlx4.c          | 5 +----
 drivers/net/mlx5/linux/mlx5_os.c | 5 +----
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 41c3cf2595..781ed76139 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -13,6 +13,7 @@
 #include <ethdev_pci.h>
 #include <rte_kvargs.h>
 #include <rte_eal_paging.h>
+#include <rte_pci.h>
 
 #include <infiniband/verbs.h>
 #include <infiniband/manadv.h>
@@ -1464,10 +1465,7 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
 			continue;
 
 		/* Ignore if this IB device is not this PCI device */
-		if (pci_dev->addr.domain != pci_addr.domain ||
-		    pci_dev->addr.bus != pci_addr.bus ||
-		    pci_dev->addr.devid != pci_addr.devid ||
-		    pci_dev->addr.function != pci_addr.function)
+		if (rte_pci_addr_cmp(&pci_dev->addr, &pci_addr) != 0)
 			continue;
 
 		ctx = ibv_open_device(ibdev);
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 1389b606cc..a1a7e93288 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -817,10 +817,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		DEBUG("checking device \"%s\"", list[i]->name);
 		if (mlx4_ibv_device_to_pci_addr(list[i], &pci_addr))
 			continue;
-		if ((pci_dev->addr.domain != pci_addr.domain) ||
-		    (pci_dev->addr.bus != pci_addr.bus) ||
-		    (pci_dev->addr.devid != pci_addr.devid) ||
-		    (pci_dev->addr.function != pci_addr.function))
+		if (rte_pci_addr_cmp(&pci_dev->addr, &pci_addr) != 0)
 			continue;
 		vf = (pci_dev->id.device_id ==
 		      PCI_DEVICE_ID_MELLANOX_CONNECTX3VF);
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 0706e9e9b2..922490ff97 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2065,10 +2065,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
 			if (mlx5_get_pci_addr(ibv_list[ret]->ibdev_path,
 					      &pci_addr))
 				continue;
-			if (owner_pci.domain != pci_addr.domain ||
-			    owner_pci.bus != pci_addr.bus ||
-			    owner_pci.devid != pci_addr.devid ||
-			    owner_pci.function != pci_addr.function)
+			if (rte_pci_addr_cmp(&owner_pci, &pci_addr) != 0)
 				continue;
 			DRV_LOG(INFO, "PCI information matches for device \"%s\"",
 				ibv_list[ret]->name);
-- 
2.42.0


  parent reply	other threads:[~2023-10-19 15:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 15:31 [PATCH 0/2] small cleanup - use PCI lib Thomas Monjalon
2023-10-19 15:31 ` [PATCH 1/2] drivers: use macro for PCI address format Thomas Monjalon
2023-10-20  1:02   ` John Daley (johndale)
2023-10-20  3:30     ` lihuisong (C)
2023-10-19 15:31 ` Thomas Monjalon [this message]
2023-10-19 16:04   ` [PATCH 2/2] drivers: use function to compare PCI addresses Long Li
2023-10-29  8:54 ` [PATCH 0/2] small cleanup - use PCI lib Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231019154125.308002-3-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=chenbox@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=longli@microsoft.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).