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 8E15943FC9 for ; Tue, 7 May 2024 14:43:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 886274338E; Tue, 7 May 2024 14:43:36 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) by mails.dpdk.org (Postfix) with ESMTP id 1749543385; Tue, 7 May 2024 14:43:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OUaESd3z88xjkIhrxRRZBzltpi0vd2UX7Q4opfN3QkdPHIYdoO+gqg5763xs40Si96D2fGYsnpSo5wGZAerztL2R/+8Aov7U2oeB5C/WL9JVHqggbWpahIihme82W4i/JbAEcYzpHl+Gr4s9CqZ9U1svJd7vxrn5lJLGxNOAjfaGzYQXw5ziVyWrELB9gq4e6mAZmu4sL5Bzw3SipL59iyI408wHefyOWz7TWbJRaQ+tdcJVsx2+LGd23kEODaN1yq7MkFwTQv4M394q4FKEHIMWn5QL9XNRsTKv2aWzCQVoY0z803EXMSrApi0I1Wlu4PGkHD5m8mSwVvwkqvxhVw== 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=gUZVdb0/EQ7+imRhY4rHHWLRz/PndfPyNZ64yYeAcQ4=; b=Up98WR9H8ZnuCrTfShVb+3nKKrC5BYyq/yN5WL5O2XNKouB2zJ+ic/63W4Y+l6Fq9evBZboBph5HHEGLb5acBe88jQO9NMQM0ZKBX58WDX1H2KYY53+xr+/7sVTbk6vqkBC5npwlDoazW6vUPFdmhTLYMLZVWdp8tKxY4yRINGziCJtKC1YiLbb2xE6Uzkwx5ttOihgNLRdWd3NoIHAYmCpGAWckbr8/DvX1xlB9PWi9x2vwTJ/sXSYb3v8f7NSJthpHUmYiTZ6zCHh4Ddom94AcnmeV1dvuo89sYFQmjP2PDQ10sMPdB7k/6DvwXQNChUiC/KWSD5lUx6+mb/DFaA== 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 (0) 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=gUZVdb0/EQ7+imRhY4rHHWLRz/PndfPyNZ64yYeAcQ4=; b=wzmHBp4KdQ3sgaS/HTq+7qNKV29ZqjRmxEPhPrIQBmp76xsSSMrr8PVfhONxTGIpOCtt2jDHvqRq8uzNRpuyM6gPWFERXbKWNbtOExjkz10vnMqqEgP8+stgP4XN1c5TgxmyT5zyA15jgOVVOPLrjggU/ngPH+8gEmKcviQC4G0= Received: from PH8PR15CA0015.namprd15.prod.outlook.com (2603:10b6:510:2d2::23) by LV3PR12MB9260.namprd12.prod.outlook.com (2603:10b6:408:1b4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.42; Tue, 7 May 2024 12:43:29 +0000 Received: from SN1PEPF00036F43.namprd05.prod.outlook.com (2603:10b6:510:2d2:cafe::4) by PH8PR15CA0015.outlook.office365.com (2603:10b6:510:2d2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.43 via Frontend Transport; Tue, 7 May 2024 12:43:29 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00036F43.mail.protection.outlook.com (10.167.248.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Tue, 7 May 2024 12:43:29 +0000 Received: from cae-Lilac-RMB.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.2507.35; Tue, 7 May 2024 07:43:27 -0500 From: Venkat Kumar Ande To: CC: , Venkat Kumar Ande , Subject: [PATCH v2 01/25] net/axgbe: fix mdio access for non-zero ports and CL45 PHYs Date: Tue, 7 May 2024 18:12:41 +0530 Message-ID: <20240507124305.2318-1-venkatkumar.ande@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412125013.10498-1-VenkatKumar.Ande@amd.com> References: <20240412125013.10498-1-VenkatKumar.Ande@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-TrafficTypeDiagnostic: SN1PEPF00036F43:EE_|LV3PR12MB9260:EE_ X-MS-Office365-Filtering-Correlation-Id: b5accf6e-952c-4def-dd4c-08dc6e934bd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UpAupvoYrjS4KtyMf1TiK0DshHfqjWKEbHLzl+qdF8pU5okxyGgR3xZ4wkQF?= =?us-ascii?Q?IXO9ISMSow8cUAUn3Bmhe6a6QTPbTYYBFLNScIXX99dx7Kd0M50umcVdyPxH?= =?us-ascii?Q?N2nUNmDNvWOdK0cVEQuq58z8a+ot8JBGRTibXwwUZ5S+FKyYswiLeFN1QCT2?= =?us-ascii?Q?FAh5yEeMZ52bZjSZYeMpwDmo0b0u8Sa1H2d9wywJlhUbj2GwR91eRwwCuwKc?= =?us-ascii?Q?iqZxDGG5XWiXHALTHGbURK3gLdjqlTxtUnE8fzhSOKMgSX9+fGDJ5o5guZal?= =?us-ascii?Q?9yvdhOY6a1wAIH08cjiUuWlwL0QyDyAsfuLqY50v3RFdLKXXgkxrcIF3QC/h?= =?us-ascii?Q?W55vfpokXMCxYobWiBPifTb3S6cbMph6tOgwxB8l5UN1NqEkjbGiPmFFM2kW?= =?us-ascii?Q?1iSCsGXqBqaEe397qrVtND3u7tMl0XZ9WZlYW0CvQqkE50hdZDUqq9p68ivw?= =?us-ascii?Q?ColAfbKewzS5NU4QQx//setglVkl8eTwu9fnjmt/UrMscB3s2xi4UID2Ls2D?= =?us-ascii?Q?kbPISnd6RVnOfsHKcAQXgruYZ6rp7AhAvLOaV3AxWCbnOIG4CGCmFfu3n18z?= =?us-ascii?Q?jciPFP+FiRixmoD9331YaDmCI2IzPDeQippI4uCy4YN72aF5zXUwXxyd9lqH?= =?us-ascii?Q?t9TK7m+j+gBcJz4kmpqkRRFLnMVDjj3PazzTN5UBX2DFBMe5ADfujhL9gHy4?= =?us-ascii?Q?a5ysqnaP8517urV+gtLZVRBHDBaHFd0Krsf/P2oikVHKKkzXyKPArLTTMYRT?= =?us-ascii?Q?0xf+W5tmC/2ArxK59P3a0GvT53Npde6VFgZsE3RLZje42cqxdzjfQYtcK+zV?= =?us-ascii?Q?JGqePRt9AwyPyx4dg6qbqNpjOOx9m7EdgTD712t7dQ/GuS7Iq6Axz9W7ldF2?= =?us-ascii?Q?1/M79NeBBavKLD5J9dzMHbrJOj5OryqzNKfcpeKfqQdLw26t9iaMHyKxIfah?= =?us-ascii?Q?WXX9mvSgIGQ0nUX3hSWRvVJ6m6mB8xFqWGm3Ld57vtssnA1kY3nRz3zbPQN/?= =?us-ascii?Q?nJ1bTeXS49wsDOwMLfhcXjHa+l2sY8xJRLoOkLY9B4LvvSycTof3A26XnH8r?= =?us-ascii?Q?tv0udeYT9C+XVDoDaV5AlrIRNqTzxGfyVLAzdXT4T3L7JLLR1zbnY1Md0wIu?= =?us-ascii?Q?gDH8h0J+w8vfQbp5sZAqewmXuRTaazGNytOLz4Dti86SHJ/aSRq0DmePvKUL?= =?us-ascii?Q?mvvEmRz6cBymja2ZsvvN1E5iTu6PfS8P/7v+yStOveFIUcQH5JZ98lqu2AvT?= =?us-ascii?Q?SBxzJgAkrFI62V4rdMlGW6V6l4e+EQEGbYpUQvSCwI42Ob/yeSiQA84NpesL?= =?us-ascii?Q?S2gmeDzV3RnwxQ2vFujQzaPTxx2cFjQB+0Vx/PB6p1Fg1duT9DpfK1aUjaNt?= =?us-ascii?Q?GSmjMDhkDY/A36CLF02lK1851cpc?= 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:(13230031)(1800799015)(376005)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 12:43:29.0279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5accf6e-952c-4def-dd4c-08dc6e934bd1 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: SN1PEPF00036F43.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9260 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The XGBE supports performing MDIO operations using an MDIO command request. The driver mistakenly uses the mdio port address as the MDIO command request device address instead of the MDIO command request port address. Additionally, the driver does not properly check for and create a clause 45 MDIO command Without the fix user will get a incorrect value from PHY device. Check the supplied MDIO register to determine if the request is a clause 45 operation (MII_ADDR_C45). For a clause 45 operation, extract device address and register number from the supplied MDIO register and use them to set the MDIO command request device address and register number fields. For a clause 22 operation, the MDIO request device address is set to zero and the MDIO command request register number is set to the supplied MDIO register. In either case, the supplied MDIO port address is used as the MDIO command request port address. Fixes: 4ac7516b8b39 ("net/axgbe: add phy init and related APIs") Cc: stable@dpdk.org Signed-off-by: Venkat Kumar Ande --- drivers/net/axgbe/axgbe_common.h | 2 -- drivers/net/axgbe/axgbe_dev.c | 22 ++++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h index a5d11c5832..51532fb34a 100644 --- a/drivers/net/axgbe/axgbe_common.h +++ b/drivers/net/axgbe/axgbe_common.h @@ -407,8 +407,6 @@ #define MAC_MDIOSCAR_PA_WIDTH 5 #define MAC_MDIOSCAR_RA_INDEX 0 #define MAC_MDIOSCAR_RA_WIDTH 16 -#define MAC_MDIOSCAR_REG_INDEX 0 -#define MAC_MDIOSCAR_REG_WIDTH 21 #define MAC_MDIOSCCDR_BUSY_INDEX 22 #define MAC_MDIOSCCDR_BUSY_WIDTH 1 #define MAC_MDIOSCCDR_CMD_INDEX 16 diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c index 6a7fddffca..3389954aa6 100644 --- a/drivers/net/axgbe/axgbe_dev.c +++ b/drivers/net/axgbe/axgbe_dev.c @@ -63,15 +63,27 @@ static int mdio_complete(struct axgbe_port *pdata) return 0; } +static unsigned int axgbe_create_mdio_sca(int port, int reg) +{ + unsigned int mdio_sca, da; + + da = (reg & MII_ADDR_C45) ? reg >> 16 : 0; + + mdio_sca = 0; + AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, RA, reg); + AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, PA, port); + AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, DA, da); + + return mdio_sca; +} + static int axgbe_write_ext_mii_regs(struct axgbe_port *pdata, int addr, int reg, u16 val) { unsigned int mdio_sca, mdio_sccd; uint64_t timeout; - mdio_sca = 0; - AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, REG, reg); - AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, DA, addr); + mdio_sca = axgbe_create_mdio_sca(addr, reg); AXGMAC_IOWRITE(pdata, MAC_MDIOSCAR, mdio_sca); mdio_sccd = 0; @@ -97,9 +109,7 @@ static int axgbe_read_ext_mii_regs(struct axgbe_port *pdata, int addr, unsigned int mdio_sca, mdio_sccd; uint64_t timeout; - mdio_sca = 0; - AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, REG, reg); - AXGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, DA, addr); + mdio_sca = axgbe_create_mdio_sca(addr, reg); AXGMAC_IOWRITE(pdata, MAC_MDIOSCAR, mdio_sca); mdio_sccd = 0; -- 2.34.1