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 4EF09A0548; Thu, 2 Dec 2021 17:11:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7AFE40692; Thu, 2 Dec 2021 17:11:10 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2072.outbound.protection.outlook.com [40.107.243.72]) by mails.dpdk.org (Postfix) with ESMTP id 5E8124067B; Thu, 2 Dec 2021 17:11:08 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vi+VJXMH2FL4nZ74W3/UxhTRCdmOTzRHiSRosERd2084m5huqqotQ2UsbblwsdTBvbkur3VQ/YhSwl/GhtiUCB2tSQydEIrzD4WJGKp6rAsJMZMM9uRUw4KjT095nw/fjzPzRXSn/q5+6AOa67rOh1L9K0rgvrdodtTlwCcUF98TlVUeVYxxG9bD5ZZr32+7pm/iCF+S9iIwlBxqlSVQk4Ddclh/qD2pZw/vhutUR0Xpu7Hpe1C7OB3Wb71H1aS20SYhy4GiC5YqpKu2NsclHCAwPU/DBxP/4MrsX1ebG6q4Z1soYmmY6ca+l0SYNVK2WRGe1Nmggl5qhztZ8rWF8Q== 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=SXc8ytUJrtvRqsRYQZXeeQrBAWW3rbw1wcr5p0OYrrw=; b=itWq/PFzVeS06dY0OtYw6yZyMHUNqlSV0zwIOnZpbXGmPxcwgxzZ5S4yuXM6j/aBhkEV4UIXiaqirAQx5/zNB5GXKJNo1BHXNWDrNeisqK9lkMgzbMa2G97aAL8SerkQPq68W5qgA6frq72/e6tpP7rgCmCdj73CSeSSGpoZbvJ3w/YYdXcfFHCAmOfkU5Ylc6U55GpZyHmFr/uRuMmf+JD1ov0XqUrxUSszl3PV0DGVK5kArInnjZNwQ8LBoa+6FCp85Zl8f9XorowXdqMcimkMQl9UtZo4KheyOViAk0fnvqmm8LMyCNYRO54sk970dL1vwdqDj/SfKo6pEUjEcw== 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=SXc8ytUJrtvRqsRYQZXeeQrBAWW3rbw1wcr5p0OYrrw=; b=q8yv1XdNcBDSqnlt3oR15zsuWlX9fczcl5jVHQQI09ICL7FdDmoEezTrz4o8oLYSQTM95imtgxciKOGg1OwnWimDfnKGuiupJI24k8dh6leE40yjyhkKng/143HrD3yDxFO9WKOUyoUCcwiIlFmVZaHWzX7FOtviaiaVP/8aL2U= Received: from MW4PR04CA0176.namprd04.prod.outlook.com (2603:10b6:303:85::31) by CH0PR12MB5026.namprd12.prod.outlook.com (2603:10b6:610:e1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Thu, 2 Dec 2021 16:11:06 +0000 Received: from CO1NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::63) by MW4PR04CA0176.outlook.office365.com (2603:10b6:303:85::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Thu, 2 Dec 2021 16:11:06 +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 CO1NAM11FT043.mail.protection.outlook.com (10.13.174.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4755.13 via Frontend Transport; Thu, 2 Dec 2021 16:11:06 +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; Thu, 2 Dec 2021 10:11:03 -0600 From: Chandubabu Namburu To: , CC: , , , Chandubabu Namburu , Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware Date: Thu, 2 Dec 2021 16:10:34 +0000 Message-ID: <20211202161034.519226-1-chandu@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126102403.13223-1-chandu@amd.com> References: <20211126102403.13223-1-chandu@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5394220-5693-438b-08e5-08d9b5ae58ae X-MS-TrafficTypeDiagnostic: CH0PR12MB5026: 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: Ibib5MCpRTu8ifj6wsoeXJNlOchljSQ7DkM4KvaehqOkKAe2p8tsCBgBEsVL9UmOfvSW81gqH8xQeZi1AZj9Rch6CeA9UPEcrPQQDz4RJsElvxfAK1Xne6/UEg/uysjgEq52HpSnHHu24B166NW24VDD/MXN0Ij5n4RUOAZ8qNkxVfd5ITVF2vDbm/CnEZ7+oq9ChjseHKIRWpB184nEx6m5JTpdeQPcfp4j78G59wCjLTJ/az88tmKqrFG5VUkJp8J0vYT7i9toNNZ/deGdIzZSdxmIcSl2rPISX2JbQJqwecOqxp5cgtQvnHExXQcJ1ugEr4dR1gE+QW6xKj6R1Axl0b6eUN8mvKqxDFIyuXcM5ZNL+qXqHuaqnhc8wyCtW8zKJEQtIHxIkOh4z3+jCKQrXtPuHpRrUZrY9Mi3Y6InzIP0uL7p89VHV73Gq8OUwZmz6VXoPCajPul6czE8Pu9lMIMAzg2Ol+pwk/ruyJ8JKWJ43x/ZqON9W0qt6CXHVS6alzUgZa0CvWJGMjU4e0LugsCGyz+yWUWgvNLXD2nOevU00l3i/4XDSbEOQGzv6phfxDX3UrTM1AettnWO0XiHVGra3b4FvGkK8atV90AVz2urEHLmmdTz3VJWrIFAet8mtP01wXM6jReV2cm5mxeRAy0E9omkOjB7TlfTxQmOmebhRAprgE2bNBM07g+65FQuWfmxXdqvvgxtxtJlT7YH3FUS4vmCT5xU/cqKQHaKAYOK3Jd9JYmKbGrT+iEeP4ud/dOqdnGWDvSxFjJRBmWJQdDwvGN4lCX0T9eXQb+WZua3QABShDTjs739ULjE 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)(36840700001)(46966006)(40470700001)(86362001)(2906002)(4326008)(336012)(426003)(5660300002)(83380400001)(16526019)(81166007)(2616005)(36860700001)(8936002)(36756003)(7696005)(47076005)(508600001)(1076003)(186003)(82310400004)(110136005)(8676002)(70586007)(70206006)(6666004)(26005)(316002)(40460700001)(54906003)(356005)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 16:11:06.4661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5394220-5693-438b-08e5-08d9b5ae58ae 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: CO1NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5026 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. Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions) Cc: stable@dpdk.org 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 7d40c18a86..7b8d94ca3c 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); @@ -2117,28 +2119,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; } /* @@ -2180,7 +2181,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