DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Awan, Arsalan" <Arsalan_Awan@mentor.com>
To: Chandubabu Namburu <chandu@amd.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Selwin.Sebastian@amd.com" <Selwin.Sebastian@amd.com>
Subject: Re: [PATCH v1] net/axgbe: use PCI root complex device to distinguish AMD hardware
Date: Wed, 1 Dec 2021 08:45:28 +0000	[thread overview]
Message-ID: <1638348328079.23151@mentor.com> (raw)
In-Reply-To: <20211126102403.13223-1-chandu@amd.com>

Hi Chandu,

I have tested this in the following configurations and it works very well in all cases:

* V1000 with Yocto v3.3.2 & Linux v5.10.47
* E3000 with Yocto v3.3.2 & Linux v5.10.47
* V1000 with Ubuntu Server v20.04.3 LTS
* E3000 with Ubuntu Server v20.04.3 LTS

I think this is a much better approach than scanning the whole PCI bus and comparing
each and every device against the PCI Root Complex Device ID of the platform.

This solution looks good to me!

Acked by: Arsalan H. Awan <Arsalan_Awan@mentor.com>
________________________________________
From: Chandubabu Namburu <chandu@amd.com>
Sent: Friday, November 26, 2021 3:24 PM
To: dev@dpdk.org
Cc: Selwin.Sebastian@amd.com; Awan, Arsalan; Chandubabu Namburu
Subject: [PATCH v1] net/axgbe: use PCI root complex device to distinguish AMD hardware

"bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
RV root complex pci device does not have any kernel driver assigned
so it is removed from pci scan list which is used in
"net/axgbe: add a HW quirk for register definitions"

Get root complex device id directly from pci sysfs instead of
pci scan list

Signed-off-by: Chandubabu Namburu <chandu@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 9cd056d04a..26babde354 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -10,6 +10,8 @@
 #include "axgbe_regs.h"
 #include "rte_time.h"

+#include "eal_filesystem.h"
+
 static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int  axgbe_dev_configure(struct rte_eth_dev *dev);
 static int  axgbe_dev_start(struct rte_eth_dev *dev);
@@ -1923,28 +1925,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
        pdata->power_down = 0;
 }

-static int
-pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
+/*
+ * Return PCI root complex device id on success else 0
+ */
+static uint16_t
+get_pci_rc_devid(void)
 {
-       const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
-       const struct rte_pci_id *pcid = _pci_id;
+       char pci_sysfs[PATH_MAX];
+       const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
+       unsigned long device_id;

-       if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
-                       pdev->id.device_id == pcid->device_id)
-               return 0;
-       return 1;
-}
+       snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
+                rte_pci_get_sysfs_path(), pci_rc_addr.domain,
+                pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);

-static bool
-pci_search_device(int device_id)
-{
-       struct rte_bus *pci_bus;
-       struct rte_pci_id dev_id;
+       /* get device id */
+       if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
+               PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
+               return 0;
+       }

-       dev_id.device_id = device_id;
-       pci_bus = rte_bus_find_by_name("pci");
-       return (pci_bus != NULL) &&
-               (pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
+       return (uint16_t)device_id;
 }

 /*
@@ -1986,7 +1987,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
        /*
         * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
         */
-       if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
+       if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
                pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
                pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
        } else {
--
2.25.1


  reply	other threads:[~2021-12-01  8:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26 10:24 Chandubabu Namburu
2021-12-01  8:45 ` Awan, Arsalan [this message]
2021-12-01  9:00 ` David Marchand
2021-12-02  5:53   ` Namburu, Chandu-babu
2021-12-02 16:10 ` [PATCH v2] " Chandubabu Namburu
2021-12-22  9:27   ` Namburu, Chandu-babu
2022-01-10  6:38     ` Namburu, Chandu-babu
2022-01-17  5:40       ` Sebastian, Selwin
2022-01-17 10:22         ` Ferruh Yigit
2022-01-17 10:30           ` Sebastian, Selwin
2022-01-17 10:29         ` Sebastian, Selwin
2022-01-17 14:07           ` Ferruh Yigit

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=1638348328079.23151@mentor.com \
    --to=arsalan_awan@mentor.com \
    --cc=Selwin.Sebastian@amd.com \
    --cc=chandu@amd.com \
    --cc=dev@dpdk.org \
    /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).