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 2C24644153; Tue, 4 Jun 2024 14:12:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E600C43691; Tue, 4 Jun 2024 14:12:26 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.65]) by mails.dpdk.org (Postfix) with ESMTP id CE020402CD; Tue, 4 Jun 2024 14:12:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ogZWFFO8BTWsex+4FWz5a6xFyvIU5iXDfZ/GnlGLvEQlYmVxOodkYZm0HOBLA91K2LuE/vyovuZskRco1Q+E7p7/hA0yFSb4nAPe2HcWZrn2yFYsJ+06kZGB5ry+SN9f+92mWMFZ/mpGdHiOUbFA0HDOSxiEvpQ7VQzWsNJkypr/qT8QeYSnCform+Tkwdvf/33feYLtdl9yaHncUWIURY+8rfTp313PyV4iFKPOBFkVexJyqgV+RAmE+ZzT+mSRq/WrqxVrHkIYuOXOHbOzHL6vpgG7W4T8efI+fwVBiJuUL5DjxSvxVDWLBH/XC/HzZNskFrcXMdzhaGSNORd5AA== 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=jMW0fqNz/n/F0sVIreDPiDkGpQzdu7njAb5ba/lrLxY=; b=EzYLcvVFXlp/sQvFsFK0G5At8dqu7z8H0HsiWBD2l+DavCi+DSu6X4tX5Hla3r5KTxekHEHi1aHmMnnBoYtCp72guFyYkqjMVDEQT4NcRx7yoCv1eGVqbeSfWkaXoHBjFc/ZROOPjuOpjAY88WoLXWincOnrPaN/+DSahl6dcpWZ1+gVSBAmskj3bPvit1YBmhL26GfjbLwNsH9HE5Cyu4yFj5Dypdiyo7ZpXEI1GGo9tjwm4VLDu/+sapHoWSPDvtl4iAT+FEMf52CozZV1UWK9JMboYvDNT7qQudt/Nqu7irbKAPDOEqYJNPhCFvidL4xxRsj1mL0aUN6po4n9+A== 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=jMW0fqNz/n/F0sVIreDPiDkGpQzdu7njAb5ba/lrLxY=; b=DMb3D2YVXCWZbDYxqzdQhfmnpIMtlXYz67aXfHBq0lF/qhl0G4jiNHPo6gZM37+WU2tXTC4c/b+Du4e1RBrKjg2vN/qB+s+kcWcpx0uZNn4G/RmRtr6qsLEbE/bbR8e+zgceSz9+B6AHWOGJ64P8OZZ/oyDEQyIQ2aWflDgFUWY= Received: from BN9PR03CA0170.namprd03.prod.outlook.com (2603:10b6:408:f4::25) by IA0PR12MB7676.namprd12.prod.outlook.com (2603:10b6:208:432::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Tue, 4 Jun 2024 12:12:20 +0000 Received: from BN3PEPF0000B374.namprd21.prod.outlook.com (2603:10b6:408:f4:cafe::ff) by BN9PR03CA0170.outlook.office365.com (2603:10b6:408:f4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.29 via Frontend Transport; Tue, 4 Jun 2024 12:12:20 +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 BN3PEPF0000B374.mail.protection.outlook.com (10.167.243.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.0 via Frontend Transport; Tue, 4 Jun 2024 12:12:19 +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, 4 Jun 2024 07:12:17 -0500 From: Venkat Kumar Ande To: CC: , Venkat Kumar Ande , , Selwin Sebastian Subject: [PATCH v3 01/25] net/axgbe: fix mdio access for non-zero ports and CL45 PHYs Date: Tue, 4 Jun 2024 17:41:33 +0530 Message-ID: <20240604121157.3052-1-venkatkumar.ande@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507124305.2318-1-VenkatKumar.Ande@amd.com> References: <20240507124305.2318-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: BN3PEPF0000B374:EE_|IA0PR12MB7676:EE_ X-MS-Office365-Filtering-Correlation-Id: f166c98d-d61c-49b6-5319-08dc848f9556 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|82310400017|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zn13///drRQA2ZrWR0i6vO0ibqzYIUd+HQUu3Atu26Hx9cxhXHFTeIIWQyjl?= =?us-ascii?Q?5XvIgRxwfPgGkp2pir736qaqUEOk7lBUioB2K9oSifIoXzxM+/ZrH2fersyN?= =?us-ascii?Q?VePs0SY3OQtAC1YAwI9F03iwVp6s8PxAh4oK3gV0Z4hDbH0CYFrs2FaLPUW/?= =?us-ascii?Q?q1Qf+kyZj6xFsOY0K8Fl1rfBElmolmv22ck515BSNiAJGHVVxjmz1h8+6c+a?= =?us-ascii?Q?hkI937mMCBs2ZYTcsbqaqfMaPY7mbhvpwy25U+UoNirlQzDosvSMrpJk8hVC?= =?us-ascii?Q?rNRqMnX+IiMNP2rIzUrr5miHw9VtvSONFXjn4Np0ObFjKNG6KyMK0vsvbbsM?= =?us-ascii?Q?+JuftTMThsEUCHi8P8rWghwYBi/FWaHr1rbJ6AaL5BAFzcP1tBGw7jzFKcql?= =?us-ascii?Q?M+FIcAikzrSm/qus9bP5Soc5T6hUAdXIoGlmpU6G+KDC1MZd/uBlbOG8TxHA?= =?us-ascii?Q?RJk6mXE5WQjIx14vM/zmlXXLaVQ8e8R6QvDL2pjpnjdW+A7wGIntTg2LzqLc?= =?us-ascii?Q?OkBn6lZc8Fdw9P/AuaB31xHhRPuHU/YGbZX39LolgEb4erJ1PUSSUrgfhiv9?= =?us-ascii?Q?nlZND3NbGb+Jw6gCPOkRtk97uye5X9Sr9jS7VuVPg6Yst1H8ZXlXPJjsBh16?= =?us-ascii?Q?OX4snF6Ip/GAJ3bZuVJeqFsD62utK5FE32W093+ty9t7qUoa/vzxB1iIu7ya?= =?us-ascii?Q?FnnppYS+i18OvAjgy2nj90iEhFp61ikWZWnLuL7dkbc4UhDYJBy2QXz8vzNo?= =?us-ascii?Q?tovzr01QC3lYuEY1mG68rTdKVthJj2dgGhJa+mFXiDGNAfOEMfN/aY0/MOt3?= =?us-ascii?Q?COvWbh6Cc/ztlRX3+oPJoFfMPgtMPBCbw/aDU7zWmM02stG6WZvzoF8qx85t?= =?us-ascii?Q?esUeu2/WOl0XQJbsYZEDrLaZmiwMb7y35SNJdhroL46Tc65wHi/w0NwManZG?= =?us-ascii?Q?Y87UbjhD+Ni48+FUJbIh+ZLyfcdShlAE/0nnnRztroMlO3j13he9tgPEA4l3?= =?us-ascii?Q?9JBt15iNRNza95duSKhgSjgPFMZ614dBNrI1BA5wFb3Ep3ABMulFIUv9pmVX?= =?us-ascii?Q?+92Yt/J6YpLtO+sIG44/wyIv5C1ixmqr2sbwLRhzhTHe5SWNcIYHL0/v6qrn?= =?us-ascii?Q?tHtv5K/zTS9qLsUIZmqpUle62pL+kzDZX+ju5hG2wVvoDknYgQIQZtrbAG4e?= =?us-ascii?Q?stiizJagHkgUAyHxfuxfJf9LQ1fUHHI3uP3qELbkMDFDXjr8Ngvpu7DsuYzJ?= =?us-ascii?Q?2st5/twceyQJkTATqZzv62yEpBn2jIcYaAo85RlY4A9iMKtqiIisdtfB4urZ?= =?us-ascii?Q?yKb5Sarq8yqgS/sLMa91sWdS5gsk3/hy4cpu82YJk56U0eWoXmuoEdAsZ2+D?= =?us-ascii?Q?RGRI+Q++Q89/z+3CmAOb5S+Wl1rCBiY6ysHihiOeozCv0bnSeg=3D=3D?= 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)(82310400017)(376005)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 12:12:19.9952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f166c98d-d61c-49b6-5319-08dc848f9556 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: BN3PEPF0000B374.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7676 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 From: Venkat Kumar Ande 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 PHY device is not detected and can't be usable. 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 Acked-by: Selwin Sebastian --- 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