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 C3ED3A0C5B; Fri, 26 Nov 2021 11:24:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 983CF4270F; Fri, 26 Nov 2021 11:24:30 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2050.outbound.protection.outlook.com [40.107.95.50]) by mails.dpdk.org (Postfix) with ESMTP id 6E43740C35 for ; Fri, 26 Nov 2021 11:24:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PxSkV2fl/RAIPRx6vSkwywPfPnayoXWcbMJ1hy6XYt0tiqni3zRXzku5r+J4TVk0HZPR60sH20dtcdD2lvWQh4dMwcOBcnZsUzxu9f0EOljMZjtEBYK+ynb31+4Mi0iGifD1JC+X5bQZf0ZwKJFF8V1UMmVMx3W2oTCMfdGwwf0IUrwG9YkI7aLTu1mMuRDTmByLEfOqiyyw7CzN8349ktcC2ldXOqxRI026YhDt5bCxtVkloecAX+YtcMJRARA/JJo0L+ghUuBV9Y4Kt7gl4gEaYusKT7ntdEfKb8rrv3mXV8AuPjd8U7/8OG0VYdAqhd1DlvO+0HB+CUnq3ohzCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Iz1I9D1NqzUlvOsHo53wdVz7pQ6VoaSYpJO0gc7PJEI=; b=IrRqI83UOHDu0AquMnDphSGOUUYFtydRsAlhf/D8KSp9HsB4A2Enpk+Ty+igmyUhCUYqGPxz6VKCirZmFBTJ5erj3QaCVOhINB80Vy6J6CA/0R15N0AmTchq6f53qss1AjzHZ3BZHU/1SRs5lZ5Xw7DTAAdqVAXkOVLF7PuRXner+PJNzyH38fGYlfRLUqVvMGalu8LnhYyaQCzgG0HF7wgNkMUffqy2uR7iTChjTKvhHh+wlAIhQzkEdYFumvCzUI8NMlEq+vfgd+u3zCNAIiiTHIkjm6METPOwGW0Pqhuf32knkyyWD70f+DXl5SgtKQIKTRGANxXSmT3+798t2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Iz1I9D1NqzUlvOsHo53wdVz7pQ6VoaSYpJO0gc7PJEI=; b=PimRfML33U7pBvEPo5NRWMYLxQFv4b/S2D2ApcFb4KblT2DIjpqeJosnXGXTCKDjK22EcWX93VIO9KE5z6PMB6yeaMCrxVU1OYPVsX5ufdq+XmrHRDAmsLtx/XV/ULmCtpS8AyNyQ4nE5eVUgdXs30+DXBXSo7KTwdqrToCPyXA= Received: from BN0PR04CA0004.namprd04.prod.outlook.com (2603:10b6:408:ee::9) by SN1PR12MB2464.namprd12.prod.outlook.com (2603:10b6:802:24::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.22; Fri, 26 Nov 2021 10:24:27 +0000 Received: from BN8NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::d4) by BN0PR04CA0004.outlook.office365.com (2603:10b6:408:ee::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Fri, 26 Nov 2021 10:24:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT007.mail.protection.outlook.com (10.13.177.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4734.22 via Frontend Transport; Fri, 26 Nov 2021 10:24:26 +0000 Received: from cae.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Fri, 26 Nov 2021 04:24:24 -0600 From: Chandubabu Namburu To: CC: , , Chandubabu Namburu Subject: [PATCH v1] net/axgbe: use PCI root complex device to distinguish AMD hardware Date: Fri, 26 Nov 2021 10:24:03 +0000 Message-ID: <20211126102403.13223-1-chandu@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf358198-3b73-43d2-70b3-08d9b0c6ec90 X-MS-TrafficTypeDiagnostic: SN1PR12MB2464: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: INfIOyL8OhL48dy1Y4/6/UJyqNkBt22CSulNwIpqNiR9QV3bL/aYKr11o5Msh5LGjDKGgnnhOEyNG/EvSPuFjDSsKzTv5T3Mix40HSxKIzW52yJ52mvHd/JUH2loVLTwWE2mZyo/mmH/UQ/TXfYQAg/eqYJs1SHKRp64igwOHkxrMf7idhMLNhlIeYY14wsqy6lavTH7YMhoY5Y0EmjkMjvSQtgPpbFzFephhbTY9yCXmasx4t1UKvHi1TKCKm+apwQYAg6U8fH8TrlAmQj42B40rU8IpQAFT45/ygu3EKB+TLX4/qAjCUvCpGfjoSJJ9FyrIPn/RUeKhy40KAcLJ5axHaebOUKOaoCsCJ3WKPh+ZuMA/jmEBO0NX+x9iy9N2huC3S5xel3IzBA1TGXarxON/CeoTlgsviA7h2R8G9J/A7g4iaYaBpi5xzcQlgUNwd34xhUXDzd6IfC2uBrNYhwAoiYMkMMAuNT2oA+iNVIEADZxbfcoj3xERPxN3etHgbxd3Tgv1MGL/sXwZG76nABw012nplMYw1kZv7MnHcDs5IZA78X0bNJjrzx9p4dnNrdGTfvOL45OWUC8+6aNxt5iyZT3buLjT57mPjN96T378hyYwZWjhD1hCFLH0PwilRfhqbRbg7U8+b4xuqgmou8SfLSoj7iiLsvu82w2zlSDYvaQz0bIxm3OJJ9/+0CEl1iN7wAIGNTM2e5OrdEAH2+TbWrzpiLbN/iKwJRZ8Ys= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(336012)(36860700001)(86362001)(36756003)(70586007)(8936002)(5660300002)(316002)(1076003)(6666004)(82310400004)(8676002)(2616005)(26005)(83380400001)(356005)(4326008)(16526019)(7696005)(426003)(70206006)(186003)(2906002)(47076005)(6916009)(54906003)(81166007)(508600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2021 10:24:26.8098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf358198-3b73-43d2-70b3-08d9b0c6ec90 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2464 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 "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 --- 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