From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4395A0C4C; Wed, 1 Dec 2021 09:45:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41E434068C; Wed, 1 Dec 2021 09:45:36 +0100 (CET) Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by mails.dpdk.org (Postfix) with ESMTP id 01B9E4067B for ; Wed, 1 Dec 2021 09:45:34 +0100 (CET) IronPort-SDR: m92jP9j7df65eQYcK613hn+aIgAMcvnPcqseeHN8+pdBb5ZOOIxXc+jyGLIrVxVmzHddCpWA0K sTX2PjTb6Bhl2e4Ac3mFrkh10lr+nrM6lTT8k7Wp2ucO1CveMZA51E20qXjh364X1KI6evr8BJ M/vxZFfySFHtJR58gZZc7ltw1pElHqsHqolHtOmZIIoNZE6GgCadToVj02FILt4qtIZ3ehB0cN c/j59KIctakphvY3qfZOnmKarP2/prQJb6yJOwy2xiSB7l5mCjDXFwXde5jfgjXgi7JlY2AeC6 F46W6GNpTFrQJyTLwe57AbaO X-IronPort-AV: E=Sophos;i="5.87,278,1631606400"; d="scan'208";a="71626154" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 01 Dec 2021 00:45:34 -0800 IronPort-SDR: zDSqyN9Qj4XkFIfg7vBPwcHHE/WgcOjpC9FZS7f7QQwXqknrNvN+ObB6OvJe5aA84UfsP4X58H oiXrqpDVK6njIwHTuiMVkJCvn/og4THpwSD0fNebIFNSrY75D73z9Gy+xiD03c22BlMLDuOllr 3cRgbsIZnqs8a5GrwtJmkYnbXd83apC+/LbV1Nxn7jJz6MTi2slAt+Vz8Ae/hzKwDWf+A5eLcb bEhW26s7rJsECFmJsEag6XJ0k4Z0Kga/kkPt5wvgyF3OhkndnUtmxn8vcD9njqzB5X2RWtqEMm YsE= From: "Awan, Arsalan" To: Chandubabu Namburu , "dev@dpdk.org" CC: "Selwin.Sebastian@amd.com" Subject: Re: [PATCH v1] net/axgbe: use PCI root complex device to distinguish AMD hardware Thread-Topic: [PATCH v1] net/axgbe: use PCI root complex device to distinguish AMD hardware Thread-Index: AQHX4q/U6caQBAlgt0m7s1/Kyo5dAawdWEfi Date: Wed, 1 Dec 2021 08:45:28 +0000 Message-ID: <1638348328079.23151@mentor.com> References: <20211126102403.13223-1-chandu@amd.com> In-Reply-To: <20211126102403.13223-1-chandu@amd.com> Accept-Language: en-US, en-IE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [192.94.31.225] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Chandu,=0A= =0A= I have tested this in the following configurations and it works very well i= n all cases:=0A= =0A= * V1000 with Yocto v3.3.2 & Linux v5.10.47=0A= * E3000 with Yocto v3.3.2 & Linux v5.10.47=0A= * V1000 with Ubuntu Server v20.04.3 LTS=0A= * E3000 with Ubuntu Server v20.04.3 LTS=0A= =0A= I think this is a much better approach than scanning the whole PCI bus and = comparing=0A= each and every device against the PCI Root Complex Device ID of the platfor= m.=0A= =0A= This solution looks good to me!=0A= =0A= Acked by: Arsalan H. Awan =0A= ________________________________________=0A= From: Chandubabu Namburu =0A= Sent: Friday, November 26, 2021 3:24 PM=0A= To: dev@dpdk.org=0A= Cc: Selwin.Sebastian@amd.com; Awan, Arsalan; Chandubabu Namburu=0A= Subject: [PATCH v1] net/axgbe: use PCI root complex device to distinguish A= MD hardware=0A= =0A= "bus/pci: optimize bus scan" broke axgbe on V1000/R1000.=0A= RV root complex pci device does not have any kernel driver assigned=0A= so it is removed from pci scan list which is used in=0A= "net/axgbe: add a HW quirk for register definitions"=0A= =0A= Get root complex device id directly from pci sysfs instead of=0A= pci scan list=0A= =0A= Signed-off-by: Chandubabu Namburu =0A= ---=0A= drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------=0A= 1 file changed, 20 insertions(+), 19 deletions(-)=0A= =0A= diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_eth= dev.c=0A= index 9cd056d04a..26babde354 100644=0A= --- a/drivers/net/axgbe/axgbe_ethdev.c=0A= +++ b/drivers/net/axgbe/axgbe_ethdev.c=0A= @@ -10,6 +10,8 @@=0A= #include "axgbe_regs.h"=0A= #include "rte_time.h"=0A= =0A= +#include "eal_filesystem.h"=0A= +=0A= static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);=0A= static int axgbe_dev_configure(struct rte_eth_dev *dev);=0A= static int axgbe_dev_start(struct rte_eth_dev *dev);=0A= @@ -1923,28 +1925,27 @@ static void axgbe_default_config(struct axgbe_port = *pdata)=0A= pdata->power_down =3D 0;=0A= }=0A= =0A= -static int=0A= -pci_device_cmp(const struct rte_device *dev, const void *_pci_id)=0A= +/*=0A= + * Return PCI root complex device id on success else 0=0A= + */=0A= +static uint16_t=0A= +get_pci_rc_devid(void)=0A= {=0A= - const struct rte_pci_device *pdev =3D RTE_DEV_TO_PCI_CONST(dev);=0A= - const struct rte_pci_id *pcid =3D _pci_id;=0A= + char pci_sysfs[PATH_MAX];=0A= + const struct rte_pci_addr pci_rc_addr =3D {0, 0, 0, 0};=0A= + unsigned long device_id;=0A= =0A= - if (pdev->id.vendor_id =3D=3D AMD_PCI_VENDOR_ID &&=0A= - pdev->id.device_id =3D=3D pcid->device_id)=0A= - return 0;=0A= - return 1;=0A= -}=0A= + snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",= =0A= + rte_pci_get_sysfs_path(), pci_rc_addr.domain,=0A= + pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);= =0A= =0A= -static bool=0A= -pci_search_device(int device_id)=0A= -{=0A= - struct rte_bus *pci_bus;=0A= - struct rte_pci_id dev_id;=0A= + /* get device id */=0A= + if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {=0A= + PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");=0A= + return 0;=0A= + }=0A= =0A= - dev_id.device_id =3D device_id;=0A= - pci_bus =3D rte_bus_find_by_name("pci");=0A= - return (pci_bus !=3D NULL) &&=0A= - (pci_bus->find_device(NULL, pci_device_cmp, &dev_id) !=3D N= ULL);=0A= + return (uint16_t)device_id;=0A= }=0A= =0A= /*=0A= @@ -1986,7 +1987,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)=0A= /*=0A= * Use root complex device ID to differentiate RV AXGBE vs SNOWY AX= GBE=0A= */=0A= - if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {=0A= + if ((get_pci_rc_devid()) =3D=3D AMD_PCI_RV_ROOT_COMPLEX_ID) {=0A= pdata->xpcs_window_def_reg =3D PCS_V2_RV_WINDOW_DEF;=0A= pdata->xpcs_window_sel_reg =3D PCS_V2_RV_WINDOW_SELECT;=0A= } else {=0A= --=0A= 2.25.1=0A= =0A=