From nobody Fri Jul 24 21:29:28 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012030.outbound.protection.outlook.com [40.107.209.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9334F476CE4; Thu, 23 Jul 2026 12:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810348; cv=fail; b=i1eVoc+jU+1z5quzZXhlIJab1RmgCz/1qf1e91S4npuT9WFlGI+xyn7KpdlfqeG/JcspyoBm+7dCVnaYcnnWzYD1rC3wHt2RkrTiZClfK00cX7/KHLoEty5Q8Til7WeEBH908N+BH7NqXcIDIcsBM05H69iQhIUNbgJs0/FCfto= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810348; c=relaxed/simple; bh=g8A01fZiMJ2FEVyrImx5TUU2wc3UfDutfJdaDibnSyw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qG+6LhMA17af4VZOCoFC/7omTGCbP33Icr0jkzXyN+O0bGG7F5ZS7d/9Iif294uKhTWuKBfGT7j3qKRXSN7QM57q2O/ef13ZwJXmsoBVKf4866g+PRt1mUbFSAL+dJQNq8FCkMC1Lgkji1V73ZakSVtm5sPQhlWnmhzSoT/vTY0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=M2TL6Gq9; arc=fail smtp.client-ip=40.107.209.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="M2TL6Gq9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xY3lPbGCvALFvKg8QMxoVPL/V1q8ULCBlVZbAidUqZPI8bpO+Jcxv2PFyE3dOEooDeXVI2Cm33CFFqkXdznWdvU6LGTWzcK6PK9R6dNjpsR6iBpWnnhdb790QajCFqAp/+vS+rD+Ms7HjXdQdltOxU86enu2AcJmZG6PgmrbsErVAqp2UX7i/9HbB9VO9b6PkknG2WezbQqbWr09HBCb5wjRcy+eY9qs0G0b2m5hI0Ap7OHNHa8d5R0tmoSCTxM4jCkAOrZkxx5QhjLUSVUdrPk7L+rpNLD7cFh2/EJHdF1mvfNuW/5gXUsii+F+CcQz+nIZ9KKEEeIsko3AD05msA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=guVufXUP0mAGwNZ8QdSuhHDcIZ3iMYwl9L8E2aaBn0E=; b=rvoHxfk2iTR2Wq+61mn9vvznEnXTJVg6dNWSuLPAMhjznWsNLnG+FWvWRxIL/L88E3JkhvXum4NyuBSDZez2nnbcwsOOkbLFSIdsTqnbRRZQCvOHvS2PXD7Ap/lTfmhadx+sWSWXsqFFVWauPIjalgLPoGDQvOgIJdnrDtJofsrN7FZqSKR+mBE4I2Za51UaDePmJ25MRnH8BWkqA6q79NRLqidDihwLN9QRtZkkhDPztd9SUFErNeemKUaI1idz86HExLc72pPoBBEJzjQdVMIYZIIQN9QSUe7YQuk/phyu1wlNV208WCLpXywAphzOhSxACLWRZH+PWmTAPYwtgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=guVufXUP0mAGwNZ8QdSuhHDcIZ3iMYwl9L8E2aaBn0E=; b=M2TL6Gq9/S0IJoY/ttx62ygP/Vz15xOoqtjVI8r7FVNSDupm0NlySGuDPZfqXSNUhOmNemhPNuC1SsTbrPb+9uy5qLPPL0LQkWhbhC+18XZBdq+K6fNONZnFbaXMMeRauSG8y/sAjNvpS7cDFpi4IOjNs4ImA3B1MtZtafOrLAE= Received: from MW4PR02CA0015.namprd02.prod.outlook.com (2603:10b6:303:16d::6) by BL3PR12MB6474.namprd12.prod.outlook.com (2603:10b6:208:3ba::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 12:39:00 +0000 Received: from MWH0EPF000C618B.namprd02.prod.outlook.com (2603:10b6:303:16d:cafe::3) by MW4PR02CA0015.outlook.office365.com (2603:10b6:303:16d::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39:00 +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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by MWH0EPF000C618B.mail.protection.outlook.com (10.167.249.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:38:59 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:38:58 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:38:58 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:38:51 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 1/7] clk: Add devm_clk_bulk_get_enable() Date: Thu, 23 Jul 2026 18:08:32 +0530 Message-ID: <20260723123838.125145-2-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C618B:EE_|BL3PR12MB6474:EE_ X-MS-Office365-Filtering-Correlation-Id: c0c2cb04-dad0-4717-8b8c-08dee8b75eb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|7416014|376014|1800799024|82310400026|921020|56012099006|10067099003|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: eaACfIfySPOob0GjLEkb8h5iZefD15hPRo3N4lA7qPN9puXiOzJzMpJT/anQuUreQP2AXvYCjDHOOcapDOwlI565Rsq0g+tqux/C7vbuOmOmZNysP+v981USVebbam7vZLEhtFT5vSRj5jDmNw5G0+Zr/LjCsB9ao+8x6YHb7PY7t/Z5nrhEJEh3EDrNUoZApw6u8yhJknHk7rChGbSFeWAFkr/ZFALttk8NtUrh39jkM0af4lGuLQrkxstqp0Bn7kbKK6+kHIBUeuRCTCA1mG8UC8oPyrHcFydST3wtFsUnjMzuIPwwCba5rDTFHWGXBFXuUTLfJyP245RdmFDXUTQo9XxEHoWZac7mjSIr+vFlXr7uSS9519F5NvKxESLKLoMHZizoMt+QhBUnu3SLLz44a0OfruVREcet0KTm+sj5BgI5LIjy/v/lpcqdWm5/AZUV6L8VeIlzj3hlPyzhnjZZk6YwhnNbAS2a6734XNxI3PYZ1athOx3PFXOjX1rgAR2MpQSF6O7ErChcO6duQoEKKJlhz7raIV2h4PZGwiHrDTex02OwI0jKL1VgFU96ok7bnUMzW4KQWXRhepuDrUoqXeOiqXHZRiV2izwOUCWDJAH/dQ2ckXpnaMDizufAHy/xd3GivaQwSVtRbt31RXU+Lz8c4ZfyklSLS5kU5t/pRKgxXVx75IbTwG+YxBm1ShmDqlVs3DNjLyiPEXdodCGq58WYQFVShmrPNcW7elJud9gVHX77AjHe8bat5YFE X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(7416014)(376014)(1800799024)(82310400026)(921020)(56012099006)(10067099003)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: csaboYG2Z6cFa2MKCftkH/FhFuzuoIU4LzLIKRJGRwKPXQG4P/lL7BrBalXJAHWlRjkWu9JVCugFIrHUdSGlV25cO7Q5JvjCYpDamc4g9P72U0t/F5g4SNPD0KCCql0fP83fvZWcDrgc3vfpgdKUURSRGbuy/HnDAsgQCjqEoUxjVC1sZGZBX2bs3fP5GQttK+36/ZnPJFRFB7jaOuJhS0V5cgHz07Ubm51StA6MJrdlvCqmCxbHT+u5m2nBlkWQHTdWLUd+C0M76oTEINpqgyaZ5EkuTQE9efbvo2MTQhwluPaYVs2rEdyilH7kgSBRq9sNomNLWr1vH0s7rKQJXUZwP7+UBuNzBVItGb1xqAs1AfJOEbQz5cXIClX/F9rVt43DmJYl/2y5Ve5XyuVpsyHmtdEWF8M6wgFTODiExoLncZHjwrp7E0aNAu/7zzMw X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:38:59.7430 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0c2cb04-dad0-4717-8b8c-08dee8b75eb4 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C618B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6474 Content-Type: text/plain; charset="utf-8" devm_clk_bulk_get_optional_enable() gets, prepares and enables a set of clocks with device-managed cleanup, but treats every clock as optional: a missing clock is silently returned as NULL instead of failing. Consumers that need a fixed set of mandatory clocks enabled for the lifetime of the device currently have to open-code devm_clk_bulk_get() followed by clk_bulk_prepare_enable(), which loses the managed disable on unbind, or fall back to per-clock devm_clk_get_enabled() calls. Add devm_clk_bulk_get_enable() as the non-optional counterpart. The underlying __devm_clk_bulk_get_enable() helper already supports the required (optional =3D false) path, so only export a thin wrapper for it. Signed-off-by: Suraj Gupta Reviewed-by: Brian Masney --- .../driver-api/driver-model/devres.rst | 1 + drivers/clk/clk-devres.c | 7 ++++++ include/linux/clk.h | 23 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentati= on/driver-api/driver-model/devres.rst index 017fb155a5bc..5067500ded5c 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -248,6 +248,7 @@ CLOCK devm_clk_put() devm_clk_bulk_get() devm_clk_bulk_get_all() + devm_clk_bulk_get_enable() devm_clk_bulk_get_optional() devm_get_clk_from_child() devm_clk_hw_register() diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 994d5bc5168b..49d4782991eb 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -222,6 +222,13 @@ static int __devm_clk_bulk_get_enable(struct device *d= ev, int num_clks, return ret; } =20 +int __must_check devm_clk_bulk_get_enable(struct device *dev, int num_clks, + struct clk_bulk_data *clks) +{ + return __devm_clk_bulk_get_enable(dev, num_clks, clks, false); +} +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_enable); + int __must_check devm_clk_bulk_get_optional_enable(struct device *dev, int= num_clks, struct clk_bulk_data *clks) { diff --git a/include/linux/clk.h b/include/linux/clk.h index 998ba3f261da..0289ac4c6e48 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -502,6 +502,22 @@ int __must_check devm_clk_bulk_get(struct device *dev,= int num_clks, */ int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_cl= ks, struct clk_bulk_data *clks); +/** + * devm_clk_bulk_get_enable - Get and enable bulk clocks (managed) + * @dev: device for clock "consumer" + * @num_clks: the number of clk_bulk_data + * @clks: pointer to the clk_bulk_data table of consumer + * + * Behaves the same as devm_clk_bulk_get() but also prepares and enables t= he + * clocks in one operation with management. The clks will automatically be + * disabled, unprepared and freed when the device is unbound. + * + * Return: 0 if all clocks specified in clk_bulk_data table are obtained a= nd + * enabled successfully. Otherwise returns valid IS_ERR() condition contai= ning + * errno. + */ +int __must_check devm_clk_bulk_get_enable(struct device *dev, int num_clks, + struct clk_bulk_data *clks); /** * devm_clk_bulk_get_optional_enable - Get and enable optional bulk clocks= (managed) * @dev: device for clock "consumer" @@ -1052,6 +1068,13 @@ static inline int __must_check devm_clk_bulk_get_opt= ional(struct device *dev, return 0; } =20 +static inline int __must_check devm_clk_bulk_get_enable(struct device *dev, + int num_clks, + struct clk_bulk_data *clks) +{ + return 0; +} + static inline int __must_check devm_clk_bulk_get_optional_enable(struct de= vice *dev, int num_clks, struct clk_bulk_data *clks) --=20 2.25.1 From nobody Fri Jul 24 21:29:28 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012033.outbound.protection.outlook.com [52.101.43.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2979647D94E; Thu, 23 Jul 2026 12:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.33 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810358; cv=fail; b=f2fWQgGrQ4VKeaUisYwoH7Cv2b7W2fM8lE2DkU9chzp0cTzyKw65q62VETfegFn/3LEmKxGV9SqYpa1jIcTS44w+NR/0Yvq5pnRB3MjRB7cOlkHbq/vSxtuf9Jm8K1uuEcdtP+fW1DGoq1oYn2vxsSlVVEPpbeX7Kl0JegSxWm8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810358; c=relaxed/simple; bh=NZXG35c8H5uRRWe4b1J5BA/X1XXitzy9kjdj3ZE+W3E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f93Hi0kLGbJEJ/uJOObDAgkFdFi0eIVX0UrPcN756SQVtV2KFhQavOxjJwHlJvlp821Wks5To65MqKidchyYAiTjJFxGbRLsLDwLDTf3AswBKDE5fdd2SA1dHuOt+XYvUrYNmYoypLT/ION1B4VSQMXZE/kzeliNpJJBGwfkz4E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=BuBaifQk; arc=fail smtp.client-ip=52.101.43.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="BuBaifQk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tqV/PKsD6GIzVIlsh/aF8lBt7xxw6cX8dnfi+EF3ZlIQ9L6ilKU4dPYmKL9sBCUibrYBQp9wgwaOMNDBiu0DkPbydPSvv0t7jPVC2b7iDLF5pSmE68O5t6T6H1CY1X34Nu+S8XVvuWgHxmn1YBPcUr8K3lEymxwvORi3GCJ2QvJR2tkR+LuaNI0nezbSZOWhoVV/+UEmveVcGntlENUd1xOMNOBkbK7i/rYtNMOqNScthvjOSv2IIFfGtl8GAR7maSNFvI74VRolnUrqtdB5njbsoqsMHd1XQ/WD2J85Ptxzzx4iZQSGJ98f+We6HjhPQLG+qUQ7WeR+92Rpd40u7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=GT55Hvmm2/JZAOAZlYrRj07fOuazW0zYIN28WEzCJmA=; b=ZcUW7BcCyiGchodKMTB1mS8OnhwLsJp565aCzEYwlQ0qSPvRYkLpxjwaCkIb4eijQxwEgvoPlWB6gmat5QRdrYDwYGja3HHm12Fxv8g0aR4gkbTh7XxdNt+Q2JJd8qp4qXATA9yta4DY4YmxAQ2pgcQm53yQxTLtGPq/kJNoniI1otrprNJv9fyoqrjrVvGLMV91+y4akrqm3Uzbb1VAiE0uK1JGYUSrswKpHBn0/JbDjKYxGflh/EjKBKWxZuTEPxFTK8ZNFuYKnAct4AAPikue+1cAdZdhw/DjZCwF0H/JFXlkrPEC1xv6ktBnK5XPdD203DU/5aXHbF7EOlfDtw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=GT55Hvmm2/JZAOAZlYrRj07fOuazW0zYIN28WEzCJmA=; b=BuBaifQkBldj4PEnyz4TzH3eVrONwEg+9EmoUGHl9p/4ziM+SSKTNuVNQOvuTBnXIVel7KZujGUeUClsmO6OTgs1TU7DcaqmM9a0MkU8X159baVTpS32I1V/IyYbhC9cAe+xgkX60li2mQXAHUe1sdnCQQ1Q+KAHJH+aOW/MLUs= Received: from MW4PR04CA0178.namprd04.prod.outlook.com (2603:10b6:303:85::33) by MW6PR12MB8913.namprd12.prod.outlook.com (2603:10b6:303:247::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 12:39:10 +0000 Received: from MWH0EPF000C6187.namprd02.prod.outlook.com (2603:10b6:303:85:cafe::75) by MW4PR04CA0178.outlook.office365.com (2603:10b6:303:85::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39:10 +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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by MWH0EPF000C6187.mail.protection.outlook.com (10.167.249.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:39:09 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:06 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:05 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:38:58 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops Date: Thu, 23 Jul 2026 18:08:33 +0530 Message-ID: <20260723123838.125145-3-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6187:EE_|MW6PR12MB8913:EE_ X-MS-Office365-Filtering-Correlation-Id: 3dd7136f-7a7b-4f76-e803-08dee8b7648e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|376014|7416014|23010399003|82310400026|11063799006|56012099006|5023799004|10067099003|6133799003|10063799003|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: s+5Adrqou2IJAQjqgzcMum/vxKzLFu5nTn3gCMwDmA8WEHhRGrFe39dmX50c9gxNu9eGMU8ps+tKifnUfJUrxFhJfUw0bOxwJpQb9S+ZuC6Q8NkmmNTUzbOnPtkFS4czSs2w4wnaXDJxXDnKlj0+y35kkiYbvKMWFWEbsDCpVbpuEOynyAVvFvZFQBBkekX8Vn6KfbrJrzUPcJ17jwBioli6bPtxM5ijuEjui14PvSv/DFOeVCDueEao+KcLYi2k8jz8w+VcTjLCBWswiqsZOmwLCTTp220/rpsWYwCK0njil54ZwzCstm8D6SkYEtfQ8+LWt3YBJg4N6ZMJjfyQOZVQ77G/YqRS8cBMKT7cZqvJ2SnDTkpIYkauRKW0lQRm1Hab/0+WqGUpRmqhXenvk+0rkc+K1jv2+CSpaoV+mppWGUh7kkkUx15CEkoIfzItVaz17bcg/BG92SGBMoEpaoIkiecYbEwWCr4lU59dVbUPiKgZp8FFy8eYVV5sg+33wzUnN+PJnUBfWhKDVrefiWpvswM8BAPwDlu57xptzbUBXK0iRhbzmQ/DocqW/GjbJ4GaVkpAvfvKI7YXK3X0l1DsIMwHT2Shep55XqIthOo53GOY/6edmKGjYqPrIeegzO6G0nZlbHW3hH6DLDB4pBL8mXNiPa7BP8nytFSp9wdYM3QMkjvhc9PNrA/U4QbSU1iOujv/nzMw6wtZTeabBWRyepzkezI61UvhfNa38K3onNWJDcWE95dz3r6S/j3J X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(376014)(7416014)(23010399003)(82310400026)(11063799006)(56012099006)(5023799004)(10067099003)(6133799003)(10063799003)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8w0tUBK0bC02ZQltJkXfUSWLwqpn6GpBeCRjox+ynEHD3nFX69NgM5mLKtD5Vcuv8NosqwbUbwAbXSFqio/qZc+yIlDE84qy9s4wPJhbqCDCOqE5FyFXBh4dFQvFH9ok4zaWqrHWKcwD+HJa8lgkPjga67xf6FP5ZtpCvB2NwBKgdnPil+sK1NqUCraJOFNeC4crN54HtaYPdx6OzcS6YUFgxQ6NwOlMKVd/0hPQ0I57kjikWuowoouFkjgUI0/R29nS4FGQ1lgcjyMHj4j4ttFwSIM8p1kGsAveTEZKYgvlfyrfH0eDrpe9IKIw1vxb9YjWnZWQF/aGNtjPSmaVnQYy2cWcXWKKb5BF+Z9qg+fO6ye5vbf7pfD7DSa62cP/FDdTuHhPW16hCUPONJxZEE/WMlOk6M/DQi+rbSTLDG5yFNScAliQ+DQPYs0amGqH X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:39:09.5531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3dd7136f-7a7b-4f76-e803-08dee8b7648e 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6187.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8913 Content-Type: text/plain; charset="utf-8" Introduce an axienet_config structure to abstract MAC-type-specific operations, preparing the driver for supporting additional MAC types beyond the existing 1G Ethernet. Add axienet_config with capability flags (mdio, mac_irq, legacy_dma, uc_filter, mc_filter, vlan, jumbo, dma_tx_csum, sw_padding, internal_pcs), the register-dump count and callbacks (clk_init, setoptions, probe_init, gt_reset, mac_init, mac_link_up, get_regs, phylink_set_caps, pcs_ops, stats_update), and populate it from the OF match table. Convert the common code to consult these capabilities and callbacks instead of open-coding 1G behavior, so a new MAC type can be added without adding MAC-specific conditionals to the shared paths. No functional change intended for the existing 1G path. Signed-off-by: Suraj Gupta --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 52 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 391 ++++++++++++------ 2 files changed, 319 insertions(+), 124 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/eth= ernet/xilinx/xilinx_axienet.h index fcd3aaef27fc..40f03c9eb382 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -545,6 +545,7 @@ struct skbuf_dma_descriptor { * @tx_ring_tail: TX skb ring buffer tail index. * @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. + * @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local { struct net_device *ndev; @@ -626,6 +627,57 @@ struct axienet_local { int tx_ring_tail; int rx_ring_head; int rx_ring_tail; + const struct axienet_config *axienet_config; +}; + +/** + * struct axienet_config - MAC-type specific configuration and operations + * @mdio: MAC has an MDIO bus for external PHY management + * @mac_irq: MAC has a dedicated core interrupt + * @legacy_dma: MAC supports the legacy (non-dmaengine) DMA mode + * @uc_filter: MAC has unicast address filter registers + * @mc_filter: MAC has multicast address filter registers + * @vlan: MAC supports VLAN frames by default + * @jumbo: MAC supports jumbo frames + * @dma_tx_csum: MAC supports TX checksum offload + * @sw_padding: Short frames must be padded in software before transmit + * @internal_pcs: MAC always drives an internal PCS + * @regs_n: Number of MAC registers exposed through ethtool -d + * @clk_init: Callback to get and enable the MAC-specific clocks + * @setoptions: Callback to program MAC hardware options + * @probe_init: Callback for MAC-specific probe-time init, or NULL if unus= ed + * @gt_reset: Callback to reset the serial transceiver (GT), or NULL if un= used + * @mac_init: Callback for MAC-specific bring-up after the DMA reset + * @mac_link_up: Callback to program link speed and pause on link up, or N= ULL + * @get_regs: Callback to dump the MAC registers for ethtool -d + * @phylink_set_caps: Callback to set phylink MAC capabilities + * @pcs_ops: phylink PCS operations for this MAC, or NULL if unused + * @stats_update: Callback to latch/accumulate the periodic MAC counters + */ +struct axienet_config { + bool mdio; + bool mac_irq; + bool legacy_dma; + bool uc_filter; + bool mc_filter; + bool vlan; + bool jumbo; + bool dma_tx_csum; + bool sw_padding; + bool internal_pcs; + unsigned int regs_n; + int (*clk_init)(struct axienet_local *lp); + void (*setoptions)(struct net_device *ndev, u32 options); + void (*probe_init)(struct axienet_local *lp); + void (*gt_reset)(struct axienet_local *lp); + int (*mac_init)(struct net_device *ndev); + void (*mac_link_up)(struct net_device *ndev, int speed, + bool tx_pause, bool rx_pause); + void (*get_regs)(struct axienet_local *lp, u32 *data); + void (*phylink_set_caps)(struct axienet_local *lp, + struct phylink_config *config); + const struct phylink_pcs_ops *pcs_ops; + void (*stats_update)(struct axienet_local *lp); }; =20 /** diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/ne= t/ethernet/xilinx/xilinx_axienet_main.c index 67d1b8e91d68..5c59423bd778 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -64,16 +65,6 @@ =20 static void axienet_rx_submit_desc(struct net_device *ndev); =20 -/* Match table for of_platform binding */ -static const struct of_device_id axienet_of_match[] =3D { - { .compatible =3D "xlnx,axi-ethernet-1.00.a", }, - { .compatible =3D "xlnx,axi-ethernet-1.01.a", }, - { .compatible =3D "xlnx,axi-ethernet-2.01.a", }, - {}, -}; - -MODULE_DEVICE_TABLE(of, axienet_of_match); - /* Option table for setting up Axi Ethernet hardware options */ static struct axienet_option axienet_options[] =3D { /* Turn on jumbo packet support for both Rx and Tx */ @@ -418,6 +409,9 @@ static void axienet_set_mac_address(struct net_device *= ndev, if (!is_valid_ether_addr(ndev->dev_addr)) eth_hw_addr_random(ndev); =20 + if (!lp->axienet_config->uc_filter) + return; + /* Set up unicast MAC address filter set its mac address */ axienet_iow(lp, XAE_UAW0_OFFSET, (ndev->dev_addr[0]) | @@ -467,6 +461,9 @@ static void axienet_set_multicast_list(struct net_devic= e *ndev) u32 reg, af0reg, af1reg; struct axienet_local *lp =3D netdev_priv(ndev); =20 + if (!lp->axienet_config->mc_filter) + return; + reg =3D axienet_ior(lp, XAE_FMI_OFFSET); reg &=3D ~XAE_FMI_PM_MASK; if (ndev->flags & IFF_PROMISC) @@ -575,14 +572,25 @@ static void axienet_stats_update(struct axienet_local= *lp, bool reset) write_seqcount_end(&lp->hw_stats_seqcount); } =20 +/** + * axienet_1g_stats_update - Refresh 1G MAC hardware statistics + * @lp: Pointer to the axienet_local structure + */ +static void axienet_1g_stats_update(struct axienet_local *lp) +{ + axienet_stats_update(lp, false); +} + static void axienet_refresh_stats(struct work_struct *work) { struct axienet_local *lp =3D container_of(work, struct axienet_local, stats_work.work); =20 - mutex_lock(&lp->stats_lock); - axienet_stats_update(lp, false); - mutex_unlock(&lp->stats_lock); + if (lp->axienet_config->stats_update) { + mutex_lock(&lp->stats_lock); + lp->axienet_config->stats_update(lp); + mutex_unlock(&lp->stats_lock); + } =20 /* Just less than 2^32 bytes at 2.5 GBit/s */ schedule_delayed_work(&lp->stats_work, 13 * HZ); @@ -693,6 +701,32 @@ static void axienet_dma_stop(struct axienet_local *lp) axienet_unlock_mii(lp); } =20 +/** + * axienet_1g_mac_init - 1G MAC-specific bring-up after the DMA reset + * @ndev: Pointer to the net_device structure + * + * Return: 0 on success or a negative error number otherwise. + */ +static int axienet_1g_mac_init(struct net_device *ndev) +{ + struct axienet_local *lp =3D netdev_priv(ndev); + u32 axienet_status; + + axienet_status =3D axienet_ior(lp, XAE_RCW1_OFFSET); + axienet_status &=3D ~XAE_RCW1_RX_MASK; + axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status); + + axienet_status =3D axienet_ior(lp, XAE_IP_OFFSET); + if (axienet_status & XAE_INT_RXRJECT_MASK) + axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK); + axienet_iow(lp, XAE_IE_OFFSET, lp->eth_irq > 0 ? + XAE_INT_RECV_ERROR_MASK : 0); + + axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK); + + return 0; +} + /** * axienet_device_reset - Reset and initialize the Axi Ethernet hardware. * @ndev: Pointer to the net_device structure @@ -708,19 +742,23 @@ static void axienet_dma_stop(struct axienet_local *lp) */ static int axienet_device_reset(struct net_device *ndev) { - u32 axienet_status; struct axienet_local *lp =3D netdev_priv(ndev); int ret; =20 + if (lp->axienet_config->gt_reset) + lp->axienet_config->gt_reset(lp); + lp->max_frm_size =3D XAE_MAX_VLAN_FRAME_SIZE; - lp->options |=3D XAE_OPTION_VLAN; + + if (lp->axienet_config->vlan) + lp->options |=3D XAE_OPTION_VLAN; lp->options &=3D (~XAE_OPTION_JUMBO); =20 if (ndev->mtu > XAE_MTU && ndev->mtu <=3D XAE_JUMBO_MTU) { lp->max_frm_size =3D ndev->mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE; =20 - if (lp->max_frm_size <=3D lp->rxmem) + if (lp->max_frm_size <=3D lp->rxmem && lp->axienet_config->jumbo) lp->options |=3D XAE_OPTION_JUMBO; } =20 @@ -737,26 +775,18 @@ static int axienet_device_reset(struct net_device *nd= ev) } } =20 - axienet_status =3D axienet_ior(lp, XAE_RCW1_OFFSET); - axienet_status &=3D ~XAE_RCW1_RX_MASK; - axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status); - - axienet_status =3D axienet_ior(lp, XAE_IP_OFFSET); - if (axienet_status & XAE_INT_RXRJECT_MASK) - axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK); - axienet_iow(lp, XAE_IE_OFFSET, lp->eth_irq > 0 ? - XAE_INT_RECV_ERROR_MASK : 0); - - axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK); + ret =3D lp->axienet_config->mac_init(ndev); + if (ret) + return ret; =20 /* Sync default options with HW but leave receiver and * transmitter disabled. */ - axienet_setoptions(ndev, lp->options & - ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + lp->axienet_config->setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); axienet_set_mac_address(ndev, NULL); axienet_set_multicast_list(ndev); - axienet_setoptions(ndev, lp->options); + lp->axienet_config->setoptions(ndev, lp->options); =20 netif_trans_update(ndev); =20 @@ -914,6 +944,13 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, stru= ct net_device *ndev) int sg_len; int ret; =20 + if (lp->axienet_config->sw_padding && eth_skb_pad(skb)) { + /* Pad short frames; the MAC does not append Ethernet padding. */ + ndev->stats.tx_dropped++; + ndev->stats.tx_errors++; + return NETDEV_TX_OK; + } + dma_dev =3D lp->tx_chan->device; sg_len =3D skb_shinfo(skb)->nr_frags + 1; if (CIRC_SPACE(lp->tx_ring_head, lp->tx_ring_tail, TX_BD_NUM_MAX) <=3D 1)= { @@ -938,19 +975,21 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, str= uct net_device *ndev) goto xmit_error_drop_skb; =20 /* Fill up app fields for checksum */ - if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { - if (lp->features & XAE_FEATURE_FULL_TX_CSUM) { - /* Tx Full Checksum Offload Enabled */ - app_metadata[0] |=3D 2; - } else if (lp->features & XAE_FEATURE_PARTIAL_TX_CSUM) { - csum_start_off =3D skb_transport_offset(skb); - csum_index_off =3D csum_start_off + skb->csum_offset; - /* Tx Partial Checksum Offload Enabled */ - app_metadata[0] |=3D 1; - app_metadata[1] =3D (csum_start_off << 16) | csum_index_off; + if (lp->axienet_config->dma_tx_csum) { + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { + if (lp->features & XAE_FEATURE_FULL_TX_CSUM) { + /* Tx Full Checksum Offload Enabled */ + app_metadata[0] |=3D 2; + } else if (lp->features & XAE_FEATURE_PARTIAL_TX_CSUM) { + csum_start_off =3D skb_transport_offset(skb); + csum_index_off =3D csum_start_off + skb->csum_offset; + /* Tx Partial Checksum Offload Enabled */ + app_metadata[0] |=3D 1; + app_metadata[1] =3D (csum_start_off << 16) | csum_index_off; + } + } else if (skb->ip_summed =3D=3D CHECKSUM_UNNECESSARY) { + app_metadata[0] |=3D 2; /* Tx Full Checksum Offload Enabled */ } - } else if (skb->ip_summed =3D=3D CHECKSUM_UNNECESSARY) { - app_metadata[0] |=3D 2; /* Tx Full Checksum Offload Enabled */ } =20 dma_tx_desc =3D dma_dev->device_prep_slave_sg(lp->tx_chan, skbuf_dma->sgl, @@ -1738,8 +1777,8 @@ static int axienet_stop(struct net_device *ndev) phylink_stop(lp->phylink); phylink_disconnect_phy(lp->phylink); =20 - axienet_setoptions(ndev, lp->options & - ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + lp->axienet_config->setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); =20 if (!lp->use_dmaengine) { axienet_dma_stop(lp); @@ -1765,7 +1804,8 @@ static int axienet_stop(struct net_device *ndev) } =20 netdev_reset_queue(ndev); - axienet_iow(lp, XAE_IE_OFFSET, 0); + if (lp->axienet_config->mac_irq) + axienet_iow(lp, XAE_IE_OFFSET, 0); =20 if (lp->eth_irq > 0) free_irq(lp->eth_irq, ndev); @@ -1934,30 +1974,18 @@ static void axienet_ethtools_get_drvinfo(struct net= _device *ndev, */ static int axienet_ethtools_get_regs_len(struct net_device *ndev) { - return sizeof(u32) * AXIENET_REGS_N; + struct axienet_local *lp =3D netdev_priv(ndev); + + return sizeof(u32) * lp->axienet_config->regs_n; } =20 /** - * axienet_ethtools_get_regs - Dump the contents of all registers present - * in AxiEthernet core. - * @ndev: Pointer to net_device structure - * @regs: Pointer to ethtool_regs structure - * @ret: Void pointer used to return the contents of the registers. - * - * This implements ethtool command for getting the Axi Ethernet register d= ump. - * Issue "ethtool -d ethX" to execute this function. + * axienet_1g_get_regs - Dump 1G MAC registers for ethtool + * @lp: Pointer to the axienet_local structure + * @data: Buffer for register values (zeroed and sized by the caller) */ -static void axienet_ethtools_get_regs(struct net_device *ndev, - struct ethtool_regs *regs, void *ret) +static void axienet_1g_get_regs(struct axienet_local *lp, u32 *data) { - u32 *data =3D (u32 *)ret; - size_t len =3D sizeof(u32) * AXIENET_REGS_N; - struct axienet_local *lp =3D netdev_priv(ndev); - - regs->version =3D 0; - regs->len =3D len; - - memset(data, 0, len); data[0] =3D axienet_ior(lp, XAE_RAF_OFFSET); data[1] =3D axienet_ior(lp, XAE_TPF_OFFSET); data[2] =3D axienet_ior(lp, XAE_IFGP_OFFSET); @@ -1998,6 +2026,31 @@ static void axienet_ethtools_get_regs(struct net_dev= ice *ndev, } } =20 +/** + * axienet_ethtools_get_regs - Dump the contents of all registers present + * in AxiEthernet core. + * @ndev: Pointer to net_device structure + * @regs: Pointer to ethtool_regs structure + * @ret: Void pointer used to return the contents of the registers. + * + * This implements ethtool command for getting the Axi Ethernet register d= ump. + * Issue "ethtool -d ethX" to execute this function. + */ +static void axienet_ethtools_get_regs(struct net_device *ndev, + struct ethtool_regs *regs, void *ret) +{ + struct axienet_local *lp =3D netdev_priv(ndev); + u32 *data =3D (u32 *)ret; + size_t len; + + len =3D sizeof(u32) * lp->axienet_config->regs_n; + regs->version =3D 0; + regs->len =3D len; + + memset(data, 0, len); + lp->axienet_config->get_regs(lp, data); +} + static void axienet_ethtools_get_ringparam(struct net_device *ndev, struct ethtool_ringparam *ering, @@ -2634,13 +2687,9 @@ static void axienet_mac_link_down(struct phylink_con= fig *config, /* nothing meaningful to do */ } =20 -static void axienet_mac_link_up(struct phylink_config *config, - struct phy_device *phy, - unsigned int mode, phy_interface_t interface, - int speed, int duplex, - bool tx_pause, bool rx_pause) +static void axienet_1g_mac_link_up(struct net_device *ndev, int speed, + bool tx_pause, bool rx_pause) { - struct net_device *ndev =3D to_net_dev(config->dev); struct axienet_local *lp =3D netdev_priv(ndev); u32 emmc_reg, fcc_reg; =20 @@ -2677,6 +2726,19 @@ static void axienet_mac_link_up(struct phylink_confi= g *config, axienet_iow(lp, XAE_FCC_OFFSET, fcc_reg); } =20 +static void axienet_mac_link_up(struct phylink_config *config, + struct phy_device *phy, + unsigned int mode, phy_interface_t interface, + int speed, int duplex, + bool tx_pause, bool rx_pause) +{ + struct net_device *ndev =3D to_net_dev(config->dev); + struct axienet_local *lp =3D netdev_priv(ndev); + + if (lp->axienet_config->mac_link_up) + lp->axienet_config->mac_link_up(ndev, speed, tx_pause, rx_pause); +} + static const struct phylink_mac_ops axienet_phylink_ops =3D { .mac_select_pcs =3D axienet_mac_select_pcs, .mac_config =3D axienet_mac_config, @@ -2694,7 +2756,6 @@ static const struct phylink_mac_ops axienet_phylink_o= ps =3D { static void axienet_dma_err_handler(struct work_struct *work) { u32 i; - u32 axienet_status; struct axidma_bd *cur_p; struct axienet_local *lp =3D container_of(work, struct axienet_local, dma_err_task); @@ -2707,8 +2768,8 @@ static void axienet_dma_err_handler(struct work_struc= t *work) napi_disable(&lp->napi_tx); napi_disable(&lp->napi_rx); =20 - axienet_setoptions(ndev, lp->options & - ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + lp->axienet_config->setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); =20 axienet_dma_stop(lp); netdev_reset_queue(ndev); @@ -2753,29 +2814,114 @@ static void axienet_dma_err_handler(struct work_st= ruct *work) =20 axienet_dma_start(lp); =20 - axienet_status =3D axienet_ior(lp, XAE_RCW1_OFFSET); - axienet_status &=3D ~XAE_RCW1_RX_MASK; - axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status); - - axienet_status =3D axienet_ior(lp, XAE_IP_OFFSET); - if (axienet_status & XAE_INT_RXRJECT_MASK) - axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK); - axienet_iow(lp, XAE_IE_OFFSET, lp->eth_irq > 0 ? - XAE_INT_RECV_ERROR_MASK : 0); - axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK); + lp->axienet_config->mac_init(ndev); =20 /* Sync default options with HW but leave receiver and * transmitter disabled. */ - axienet_setoptions(ndev, lp->options & - ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + lp->axienet_config->setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); axienet_set_mac_address(ndev, NULL); axienet_set_multicast_list(ndev); napi_enable(&lp->napi_rx); napi_enable(&lp->napi_tx); - axienet_setoptions(ndev, lp->options); + lp->axienet_config->setoptions(ndev, lp->options); } =20 +/** + * axienet_1g_phylink_set_caps - Set 1G phylink capabilities and interfaces + * @lp: Pointer to the axienet_local structure + * @config: Pointer to the phylink_config structure + */ +static void axienet_1g_phylink_set_caps(struct axienet_local *lp, + struct phylink_config *config) +{ + config->mac_capabilities |=3D MAC_10FD | MAC_100FD | MAC_1000FD; + __set_bit(lp->phy_mode, config->supported_interfaces); + if (lp->switch_x_sgmii) { + __set_bit(PHY_INTERFACE_MODE_1000BASEX, + config->supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_SGMII, + config->supported_interfaces); + } +} + +/** + * axienet_1g_clk_init - Get and enable the 1G MAC clocks + * @lp: Pointer to the axienet_local structure + * + * Return: 0 on success or a negative error number otherwise. + */ +static int axienet_1g_clk_init(struct axienet_local *lp) +{ + struct device *dev =3D lp->dev; + int ret; + + lp->axi_clk =3D devm_clk_get_optional_enabled(dev, "s_axi_lite_clk"); + if (!lp->axi_clk) { + /* For backward compatibility, if named AXI clock is not + * present, treat the first clock specified as the AXI clock. + */ + lp->axi_clk =3D devm_clk_get_optional_enabled(dev, NULL); + } + if (IS_ERR(lp->axi_clk)) + return dev_err_probe(dev, PTR_ERR(lp->axi_clk), + "could not get AXI clock\n"); + + lp->misc_clks[0].id =3D "axis_clk"; + lp->misc_clks[1].id =3D "ref_clk"; + lp->misc_clks[2].id =3D "mgt_clk"; + + ret =3D devm_clk_bulk_get_optional_enable(dev, XAE_NUM_MISC_CLOCKS, + lp->misc_clks); + if (ret) + return dev_err_probe(dev, ret, + "could not get/enable misc. clocks\n"); + + return 0; +} + +/** + * axienet_1g_probe_init - 1G MAC-specific probe-time initialization + * @lp: Pointer to the axienet_local structure + */ +static void axienet_1g_probe_init(struct axienet_local *lp) +{ + if (axienet_ior(lp, XAE_ABILITY_OFFSET) & XAE_ABILITY_STATS) + lp->features |=3D XAE_FEATURE_STATS; +} + +static const struct axienet_config axienet_1g_config =3D { + .mdio =3D true, + .mac_irq =3D true, + .legacy_dma =3D true, + .uc_filter =3D true, + .mc_filter =3D true, + .vlan =3D true, + .jumbo =3D true, + .dma_tx_csum =3D true, + .regs_n =3D AXIENET_REGS_N, + .clk_init =3D axienet_1g_clk_init, + .setoptions =3D axienet_setoptions, + .probe_init =3D axienet_1g_probe_init, + .mac_init =3D axienet_1g_mac_init, + .mac_link_up =3D axienet_1g_mac_link_up, + .get_regs =3D axienet_1g_get_regs, + .phylink_set_caps =3D axienet_1g_phylink_set_caps, + .pcs_ops =3D &axienet_pcs_ops, + .stats_update =3D axienet_1g_stats_update, +}; + +/* Match table for of_platform binding */ +static const struct of_device_id axienet_of_match[] =3D { + { .compatible =3D "xlnx,axi-ethernet-1.00.a", .data =3D &axienet_1g_confi= g }, + { .compatible =3D "xlnx,axi-ethernet-1.01.a", .data =3D &axienet_1g_confi= g }, + { .compatible =3D "xlnx,axi-ethernet-2.01.a", .data =3D &axienet_1g_confi= g }, + {}, +}; + +MODULE_DEVICE_TABLE(of, axienet_of_match); + /** * axienet_probe - Axi Ethernet probe function. * @pdev: Pointer to platform device structure. @@ -2826,27 +2972,13 @@ static int axienet_probe(struct platform_device *pd= ev) seqcount_mutex_init(&lp->hw_stats_seqcount, &lp->stats_lock); INIT_DEFERRABLE_WORK(&lp->stats_work, axienet_refresh_stats); =20 - lp->axi_clk =3D devm_clk_get_optional_enabled(&pdev->dev, - "s_axi_lite_clk"); - if (!lp->axi_clk) { - /* For backward compatibility, if named AXI clock is not present, - * treat the first clock specified as the AXI clock. - */ - lp->axi_clk =3D devm_clk_get_optional_enabled(&pdev->dev, NULL); - } - if (IS_ERR(lp->axi_clk)) - return dev_err_probe(&pdev->dev, PTR_ERR(lp->axi_clk), - "could not get AXI clock\n"); + lp->axienet_config =3D device_get_match_data(&pdev->dev); + if (!lp->axienet_config) + return -ENODEV; =20 - lp->misc_clks[0].id =3D "axis_clk"; - lp->misc_clks[1].id =3D "ref_clk"; - lp->misc_clks[2].id =3D "mgt_clk"; - - ret =3D devm_clk_bulk_get_optional_enable(&pdev->dev, XAE_NUM_MISC_CLOCKS, - lp->misc_clks); + ret =3D lp->axienet_config->clk_init(lp); if (ret) - return dev_err_probe(&pdev->dev, ret, - "could not get/enable misc. clocks\n"); + return ret; =20 /* Map device registers */ lp->regs =3D devm_platform_get_and_ioremap_resource(pdev, 0, ðres); @@ -2857,9 +2989,6 @@ static int axienet_probe(struct platform_device *pdev) /* Setup checksum offload, but default to off if not specified */ lp->features =3D 0; =20 - if (axienet_ior(lp, XAE_ABILITY_OFFSET) & XAE_ABILITY_STATS) - lp->features |=3D XAE_FEATURE_STATS; - ret =3D of_property_read_u32(pdev->dev.of_node, "xlnx,txcsum", &value); if (!ret) { switch (value) { @@ -2933,7 +3062,17 @@ static int axienet_probe(struct platform_device *pde= v) return -EINVAL; } =20 + if (lp->axienet_config->probe_init) + lp->axienet_config->probe_init(lp); + if (!of_property_present(pdev->dev.of_node, "dmas")) { + /* Non-dmaengine (legacy DMA) mode is only supported by some MACs */ + if (!lp->axienet_config->legacy_dma) { + dev_err(&pdev->dev, + "Legacy DMA mode not supported by this MAC, use dmaengine\n"); + return -EINVAL; + } + /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ np =3D of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); =20 @@ -3013,7 +3152,10 @@ static int axienet_probe(struct platform_device *pde= v) struct xilinx_vdma_config cfg; struct dma_chan *tx_chan; =20 - lp->eth_irq =3D platform_get_irq_optional(pdev, 0); + if (lp->axienet_config->mac_irq) + lp->eth_irq =3D platform_get_irq_optional(pdev, 0); + else + lp->eth_irq =3D -ENXIO; if (lp->eth_irq < 0 && lp->eth_irq !=3D -ENXIO) { return lp->eth_irq; } @@ -3066,10 +3208,12 @@ static int axienet_probe(struct platform_device *pd= ev) lp->tx_dma_cr =3D axienet_calc_cr(lp, XAXIDMA_DFT_TX_THRESHOLD, XAXIDMA_DFT_TX_USEC); =20 - ret =3D axienet_mdio_setup(lp); - if (ret) - dev_warn(&pdev->dev, - "error registering MDIO bus: %d\n", ret); + if (lp->axienet_config->mdio) { + ret =3D axienet_mdio_setup(lp); + if (ret) + dev_warn(&pdev->dev, + "error registering MDIO bus: %d\n", ret); + } =20 if (lp->phy_mode =3D=3D PHY_INTERFACE_MODE_SGMII || lp->phy_mode =3D=3D PHY_INTERFACE_MODE_1000BASEX) { @@ -3093,23 +3237,21 @@ static int axienet_probe(struct platform_device *pd= ev) goto cleanup_mdio; } of_node_put(np); - lp->pcs.ops =3D &axienet_pcs_ops; + lp->pcs.ops =3D lp->axienet_config->pcs_ops; + lp->pcs.poll =3D true; + } + + if (lp->axienet_config->internal_pcs) { + lp->pcs.ops =3D lp->axienet_config->pcs_ops; lp->pcs.poll =3D true; } =20 lp->phylink_config.dev =3D &ndev->dev; lp->phylink_config.type =3D PHYLINK_NETDEV; lp->phylink_config.mac_managed_pm =3D true; - lp->phylink_config.mac_capabilities =3D MAC_SYM_PAUSE | MAC_ASYM_PAUSE | - MAC_10FD | MAC_100FD | MAC_1000FD; + lp->phylink_config.mac_capabilities =3D MAC_SYM_PAUSE | MAC_ASYM_PAUSE; =20 - __set_bit(lp->phy_mode, lp->phylink_config.supported_interfaces); - if (lp->switch_x_sgmii) { - __set_bit(PHY_INTERFACE_MODE_1000BASEX, - lp->phylink_config.supported_interfaces); - __set_bit(PHY_INTERFACE_MODE_SGMII, - lp->phylink_config.supported_interfaces); - } + lp->axienet_config->phylink_set_caps(lp, &lp->phylink_config); =20 lp->phylink =3D phylink_create(&lp->phylink_config, pdev->dev.fwnode, lp->phy_mode, @@ -3152,7 +3294,8 @@ static void axienet_remove(struct platform_device *pd= ev) if (lp->pcs_phy) put_device(&lp->pcs_phy->dev); =20 - axienet_mdio_teardown(lp); + if (lp->mii_bus) + axienet_mdio_teardown(lp); } =20 static void axienet_shutdown(struct platform_device *pdev) --=20 2.25.1 From nobody Fri Jul 24 21:29:28 2026 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012054.outbound.protection.outlook.com [40.93.195.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 603644963B3; Thu, 23 Jul 2026 12:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810365; cv=fail; b=IgNG15BokmTc7F1v200AmxcdjSmRWsOj/SHQMM4Auxx6jydeitjQcKfr3yicBVTKd55fPhNw1YZsvkNK+46YzVNj3Ebp4FtYfD4yklwQhFFgFdPBg2C1PRJFyfU088+C0Yes0+mqLq7/D7YR2JOhDHOfqSkHcr1vvNdzOw3NNmg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810365; c=relaxed/simple; bh=y5GStdkzroy7gOOG5M0QUwrhP3qX2IJSRRKtZ2WBBP8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UYSY3DXCNEjPOMFEwNiaYre67WfjOrlxJ6DAj9UVxeVpMjkCgrNlRGgY63uneuE5B0eR1O+dGqY0/noRhhXw3ZgNG9imfKWQpLvtD5w8RSt3k8+9O48uvOsxdP5oSwBl7XiU6q70HNOyG2Rn0POlQy5Qvinb2qT0z81cK/7f+Rk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=4iTyfjiH; arc=fail smtp.client-ip=40.93.195.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="4iTyfjiH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TYeIIAQLL+T7BES6dWcqa3gqtOcacdV9cYiLzV85WYxIGlm4MQqHljb0j5woBD8QHeJF46Spyt8717eJJBNq8uuGfKpLw3WIWxmyfQb1JcSYT/nkkuVXF0yD+M+BPllEUNcPylkMuy9lK/fKQhnjdIlruNcT+DZo19qL/WsKyElDPIj3Stkxr5xyf/iDaLdtiNHS3pj7OwAxFEMSce1prANCdep0HzzK0V2Ai4DRd+fhGo66j9RoWvXfWCfpyMoFcOeA/JQvmXk+v5PsBRphGb0R9+CILpiCRWuCcjDVWLWuDRSN2pYY0g3LdahG7KzYLuBbU9nKHTlKgbKyYrK0aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=6/BYQEtQsjb6+WL1CElUeN1pQH5WgEP9ovBKrauqsJU=; b=Hhoz0R90O+Q31g3cNTs7F4JrqolMSxlUdKvTUH6THsH60pGts9cU3/zJw706JTIeXdBPx33fVDEbciS0mdYCAvU3BcszPjlzFyz3ujFXamvX5Qs0lts8P9T21ecvQlI+UbDSWcYFFs27UKCyoe5Cn9Rd4fAf2cKynoylQYUKbgrMyFKnguWfiZtPPEILxlhmNtNttBn5p30pkXE/hiMGfFnMqt49yc5blMuoVlKuIU0Xb3zy71HTAT4EPQe2PU4pq0+rP5YQJ4og2b/Repk/FFYEBsYFf1IffyWEF6aWwiND3QuyJWn9dS32rl43XUkakyJXNwMOduZjJJAsqMa8Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=6/BYQEtQsjb6+WL1CElUeN1pQH5WgEP9ovBKrauqsJU=; b=4iTyfjiHzzfO+es9w/rGc/6Wl+FBDvsFpck0SA+S0qELIp+BQddFNkbH6731O4EhDE07v5CWlArJL9SrKxdCZM4jhc9bFtVv9P11t8L8JSG/XFi3AFvPRz6uH99ydC9hzZJNNN9TtYvsYbJBcbPaFm7jJ85HJBb/HAmR0SFmJg8= Received: from MW4PR03CA0334.namprd03.prod.outlook.com (2603:10b6:303:dc::9) by MN0PR12MB6103.namprd12.prod.outlook.com (2603:10b6:208:3c9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 12:39:16 +0000 Received: from MWH0EPF000C6189.namprd02.prod.outlook.com (2603:10b6:303:dc:cafe::5b) by MW4PR03CA0334.outlook.office365.com (2603:10b6:303:dc::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39:16 +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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by MWH0EPF000C6189.mail.protection.outlook.com (10.167.249.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:39:15 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:13 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:39:06 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 3/7] dt-bindings: net: xlnx,axi-ethernet: Add 10G/25G (XXV) ethernet Date: Thu, 23 Jul 2026 18:08:34 +0530 Message-ID: <20260723123838.125145-4-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6189:EE_|MN0PR12MB6103:EE_ X-MS-Office365-Filtering-Correlation-Id: ea58e0a2-2aac-49e2-56c4-08dee8b7685d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|23010399003|376014|82310400026|36860700016|1800799024|13003099007|921020|6133799003|56012099006|11063799006|10067099003|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: QWL2S5Zb6R8YrmiVh216aRIA8JxB0OMEg+KbAeQs1okkK1z84H1Gj0aNWIcF8dxVS2pHdEP3r9b88jkGfwNX91cT27Z2kXY7tV3U6SZgrhbMnQ60S6U8DhMhyKmj+hRj3GZfx066/FEYZxIQ0PoPkt2ARdFbanH9R1mMo0WeNRktHEarbpQtH+Uvvrd0FtrtG2KOaPcrpmqscPYGQ2VX4fRQhbepXy18N36B79Ap4gs44nQxUABGyL3O58+DdIlMZiURhEqyRV6TEDVk/z7gM1zdNss69j7zcrfUNVFSZ4oCDr6f7S4Rv/9oOYJWDfcELjkSa9ConX+zgtXWgBraBCur1xWDvA4IOGVSIxrOG0ME9Q9UFIIilPU/lbfu7KKlUtBmYXZO673Ut1yIJxEr2EpFFu3Y8LLK2Qb562IfMyC1LOMGsG6B2rjE7Z3lXejN0NVT8Og6TciunAkAxvo9rt8AV42oVI5A2yUeVOr+aBN+SJA0OCbqaeoDzxYa29o27HLHXRnvs688pjE37iDsOK0Ym4tqWDqim9NLfeHM/poIRjptRbeNjCS43+8wiM+O+KULwlGDpR9k27ro0pz2KsTx8jy27rwLBWlJrxwPUOHrTtIJcC/GZrMhqP5ZvpZBUSFMAsL9ThwjGlPO/jQUKGQ2u+9UO05eDqfmhW7Yg5zhkTxahPFSqCcjooWkagq007Fw8BkNQLx0QZIIRt+fmQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(23010399003)(376014)(82310400026)(36860700016)(1800799024)(13003099007)(921020)(6133799003)(56012099006)(11063799006)(10067099003)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ewlO11Ur6+/uXKfBxAi0AA7qerwybI6UjWpXw/lA08aomjVf46ZjiCJt5IXpD9yh6H3SvbIBIdpaqsIcTxr8tLl/W0BeiVp15lPRsPRYuL8zZPv2bC4ojabIwgj40qoLp/N/wnYsFDmj4Cdgr4kOdiiy8351fqDaUmVxWXl1GmbpymXTJ6iyOKghlr8s4fEqvP2xossySds40GtBvyKQOxOOlYQtMhQLZet9dAaw/Cxs5zlYbBqtleYnK9be86V9bgZ024iXtsHVgKuv6gKvN0l8GZarGantNmpDGgRW21K/kyvEzsJsXxH7/NO99Xf1jjuGYXKkEhG5b9fPKFegSq3yVERcrw4d83KR5CnxLyYg/CzCDONr1ZrP216Ex/aZd86dXHsCJuHAVvbXSmZN+NOMGNyl02Ayvu9ur1zR7LCNCszJ5nQMr3kthmkoIYG1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:39:15.9687 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea58e0a2-2aac-49e2-56c4-08dee8b7685d 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6189.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6103 Content-Type: text/plain; charset="utf-8" The XXV Ethernet IP integrates a 10G/25G Ethernet MAC with an in-core PCS/PMA driving a high-speed serial transceiver. Extend the existing xlnx,axi-ethernet binding to describe it. Add the "xlnx,xxv-ethernet-1.0" compatible and make the resource requirements conditional based on the XXV compatible string: - "dmas", "dma-names", and "phy-mode" are required. - Interrupt properties are not required as it does not have a dedicated Ethernet core interrupt. - "phy-handle" is not required as it has internal PCS and PMA. - Add the 10gbase-r and 25gbase-r phy-mode values used by XXV. Annotate the existing compatibles, generalise the title to cover both variants, and add an example node for XXV. Define properties at top level per binding style and use if/then to constrain requirements and phy-mode per compatible. Forbid 1G-only and unused ethernet-controller properties on XXV nodes. Signed-off-by: Suraj Gupta --- .../bindings/net/xlnx,axi-ethernet.yaml | 144 ++++++++++++++---- 1 file changed, 117 insertions(+), 27 deletions(-) diff --git a/Documentation/devicetree/bindings/net/xlnx,axi-ethernet.yaml b= /Documentation/devicetree/bindings/net/xlnx,axi-ethernet.yaml index fb02e579463c..23b1a27c04e5 100644 --- a/Documentation/devicetree/bindings/net/xlnx,axi-ethernet.yaml +++ b/Documentation/devicetree/bindings/net/xlnx,axi-ethernet.yaml @@ -4,36 +4,46 @@ $id: http://devicetree.org/schemas/net/xlnx,axi-ethernet.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: AXI 1G/2.5G Ethernet Subsystem +title: Xilinx AXI Ethernet Subsystem =20 description: | - Also called AXI 1G/2.5G Ethernet Subsystem, the xilinx axi ethernet IP = core - provides connectivity to an external ethernet PHY supporting different - interfaces: MII, GMII, RGMII, SGMII, 1000BaseX. It also includes two - segments of memory for buffering TX and RX, as well as the capability of - offloading TX/RX checksum calculation off the processor. + This binding describes Xilinx AXI Ethernet subsystem IPs, including the + AXI 1G/2.5G Ethernet Subsystem and the 10G/25G (XXV) Ethernet Subsystem. + + The AXI 1G/2.5G Ethernet Subsystem provides connectivity to an external + ethernet PHY supporting different interfaces: MII, GMII, RGMII, SGMII, + 1000BaseX. It also includes two segments of memory for buffering TX and = RX, + as well as the capability of offloading TX/RX checksum calculation off t= he + processor. =20 Management configuration is done through the AXI interface, while payloa= d is sent and received through means of an AXI DMA controller. This driver includes the DMA driver code, so this driver is incompatible with AXI DMA driver. =20 + The XXV Ethernet Subsystem integrates a 10G/25G Ethernet MAC and PCS/PMA + connected to a high-speed serial transceiver. It supports the 10GBASE-R = and + 25GBASE-R line rates, with 25G operation following the 25G Ethernet + Consortium specification. Its payload is moved by an external AXI DMA + controller rather than a DMA engine integrated into the MAC. + maintainers: - Radhey Shyam Pandey =20 properties: compatible: enum: - - xlnx,axi-ethernet-1.00.a - - xlnx,axi-ethernet-1.01.a - - xlnx,axi-ethernet-2.01.a + - xlnx,axi-ethernet-1.00.a # AXI 1G/2.5G Ethernet Subsystem + - xlnx,axi-ethernet-1.01.a # AXI 1G/2.5G Ethernet Subsystem + - xlnx,axi-ethernet-2.01.a # AXI 1G/2.5G Ethernet Subsystem + - xlnx,xxv-ethernet-1.0 # 10G/25G Ethernet Subsystem =20 reg: description: - Address and length of the IO space, as well as the address - and length of the AXI DMA controller IO space, unless - axistream-connected is specified, in which case the reg - attribute of the node referenced by it is used. + Address and length of the IO space. For AXI 1G/2.5G using the legacy + embedded DMA, this also covers the AXI DMA controller IO space, unle= ss + axistream-connected is specified, in which case the reg attribute of + the node referenced by it is used. minItems: 1 maxItems: 2 =20 @@ -62,6 +72,8 @@ properties: - rgmii - sgmii - 1000base-x + - 10gbase-r + - 25gbase-r =20 xlnx,phy-type: description: @@ -93,19 +105,12 @@ properties: selected on core reset (i.e. by the basex_or_sgmii core input line). =20 clocks: - items: - - description: Clock for AXI register slave interface. - - description: AXI4-Stream clock for TXD RXD TXC and RXS interfaces. - - description: Ethernet reference clock, used by signal delay primit= ives - and transceivers. - - description: MGT reference clock (used by optional internal PCS/PM= A PHY) + minItems: 3 + maxItems: 4 =20 clock-names: - items: - - const: s_axi_lite_clk - - const: axis_clk - - const: ref_clk - - const: mgt_clk + minItems: 3 + maxItems: 4 =20 axistream-connected: $ref: /schemas/types.yaml#/definitions/phandle @@ -139,15 +144,88 @@ properties: =20 required: - compatible - - interrupts - reg - xlnx,rxmem - - phy-handle =20 allOf: - $ref: /schemas/net/ethernet-controller.yaml# =20 -additionalProperties: false + - if: + properties: + compatible: + contains: + enum: + - xlnx,axi-ethernet-1.00.a + - xlnx,axi-ethernet-1.01.a + - xlnx,axi-ethernet-2.01.a + then: + required: + - interrupts + - phy-handle + properties: + phy-mode: + enum: + - mii + - gmii + - rgmii + - sgmii + - 1000base-x + clocks: + items: + - description: Clock for AXI register slave interface. + - description: AXI4-Stream clock for TXD RXD TXC and RXS + interfaces. + - description: Ethernet reference clock, used by signal delay + primitives and transceivers. + - description: MGT reference clock (used by optional internal + PCS/PMA PHY) + clock-names: + items: + - const: s_axi_lite_clk + - const: axis_clk + - const: ref_clk + - const: mgt_clk + + - if: + properties: + compatible: + contains: + const: xlnx,xxv-ethernet-1.0 + then: + required: + - dmas + - dma-names + - phy-mode + - clocks + - clock-names + properties: + phy-mode: + enum: + - 10gbase-r + - 25gbase-r + interrupts: false + phy-handle: false + pcs-handle: false + axistream-connected: false + xlnx,phy-type: false + xlnx,txcsum: false + xlnx,rxcsum: false + xlnx,switch-x-sgmii: false + mdio: false + clocks: + maxItems: 3 + items: + - description: RX AXI4-Stream clock (rx_core_clk). + - description: GT DRP clock (dclk). + - description: AXI4-Lite register clock (s_axi_aclk). + clock-names: + maxItems: 3 + items: + - const: rx_core_clk + - const: dclk + - const: s_axi_aclk + +unevaluatedProperties: false =20 examples: - | @@ -198,3 +276,15 @@ examples: }; }; }; + + - | + ethernet@80000000 { + compatible =3D "xlnx,xxv-ethernet-1.0"; + reg =3D <0x80000000 0x10000>; + clock-names =3D "rx_core_clk", "dclk", "s_axi_aclk"; + clocks =3D <&rx_clk>, <&drp_clk>, <&axi_clk>; + dma-names =3D "tx_chan0", "rx_chan0"; + dmas =3D <&axi_dma 0>, <&axi_dma 1>; + phy-mode =3D "25gbase-r"; + xlnx,rxmem =3D <0x8000>; + }; --=20 2.25.1 From nobody Fri Jul 24 21:29:28 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011070.outbound.protection.outlook.com [40.93.194.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BD3649551D; Thu, 23 Jul 2026 12:39:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810376; cv=fail; b=LANgkEnPavljmPelv3yyg/v+DGuuHrXTbbi5a/vJp8/rSGVg+WfCmUSaV1yc7fQOHncXMdGNBTjXF6+ECp5j9DkfzapV5H07acMAKA+h+4EMS7+/7FmDsUvSzq1MnzNAYxhJI8W77JFysoFOwLnr/tsSk1detW1Z1Qsz2g0Jeu0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810376; c=relaxed/simple; bh=NuH2RxIPZ0JJLWQY/vN0nGJbKAEF42Z+SlSN1/VIXdM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iZRUzzXgzTEUAqI/N5UtgsuYCt4AtHbUclWY4C0VQVLr+E/w1/v8WOwFSeEzuFPieQRBMh4nZk/UF0IOBWW1/CNnzkeXpgjnh4jSz6nEN1TwOyjnUOObOKuP5TzsTOwr/igfJeKlDOXRecQcSmYiXWHHsqM8homqEH74CwqGLyI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=nKfPN1io; arc=fail smtp.client-ip=40.93.194.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="nKfPN1io" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WgOX5kgzVI4uUj8qyiTOA2JEn1hn2TV2Juqr36QoFlg6tdxWA3/YyYcpqCsh6x5vCdsAs25s8riOq1UpoZpGglLrarGetGssdhPdlVq/NFsR4YNk2suYpXeob/g+p1nwI636IrUQ7Kr3fXwhzl2BMu243j1C+U6ek0gZW9/QbShEBhuP04+1bSrDOzsQixtNnqna5xRRbiWQ2EbiGiVEInvLx/3jePwy5Gfy2vGHIAoZVTwYBsKKQBCCUcYLkaiOG/6ToSIKGibhn4Jeopfe3Yg+CYoqsPLgCL/dnIPII5DptTFWddkEXbil+J1nVhc36Hh1PNBPmI/F+BZ5mOMGhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=z/kJlK/0HbJJa3dFydxn76TJ6TQIdovrdHPnCMwOCgM=; b=VqXzk1oYIWFAPOOJ89raoz03ZctdI9kOnTdpbDdDougaow53Fchu8fHsylzB0/tVdhIaDLSyT2dmOmnPEbuGhI3LkG5Er3epIUno9ZbqHS0Ra52ckeWXr4G0uGh76lTfxwTj9O6vhAPx4lCpKBZgcmT2KJtVZYb75VQ/Snr28uqa6CkrfeRgY5uvAiTnKKvWJyW76HxMbWZYw+vG3MoXb+XGzgQ1I8y1ZuiAQruh6B/7WWdZiR8kh8t4tvRABvPUwXJag5vAWhsA9x+m9yA1zKvfOILJ1ADGKSOXkZrcz7LgK4G6QY1Nej4SC7o6LhBD1lkzIdu2UkLjlnQ5sisBkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=z/kJlK/0HbJJa3dFydxn76TJ6TQIdovrdHPnCMwOCgM=; b=nKfPN1iohwNeWVVaLzdcZd5zDeZChOBF9M/Eom3XvTKwZxdzz1Vpzg+HuBGEsj5pk5YPiWC3sGu6ZWz25RDsyKntu3qwPDtXR6q6b0ybLbvfIo7kbSjWfc6JXZFOK3bcX7+TBtB2FqaxMG9QjiluCl+Hw1lNxJPzZ9GPm7kjeJE= Received: from BY1P220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::7) by DM6PR12MB4451.namprd12.prod.outlook.com (2603:10b6:5:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 12:39:25 +0000 Received: from MWH0EPF000C6185.namprd02.prod.outlook.com (2603:10b6:a03:59d:cafe::93) by BY1P220CA0009.outlook.office365.com (2603:10b6:a03:59d::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39:25 +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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by MWH0EPF000C6185.mail.protection.outlook.com (10.167.249.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:39:24 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:20 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:39:13 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 4/7] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Date: Thu, 23 Jul 2026 18:08:35 +0530 Message-ID: <20260723123838.125145-5-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6185:EE_|DM6PR12MB4451:EE_ X-MS-Office365-Filtering-Correlation-Id: f53deb87-6a8e-4695-1dc8-08dee8b76d51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|82310400026|36860700016|376014|7416014|56012099006|13003099007|10067099003|921020|22082099003|18002099003|6133799003|11063799006; X-Microsoft-Antispam-Message-Info: 7wgwQOCv/swbyKx7PU09MYgxaKlJqnhZqVOta67R8W4PP2oYdMg7u6ZngqAjkFXr4MCpqPAmlFpst90BVsssuxpaTQS5gwJXUWDiYJIuhuTqgIl7kw8tzL73/hZs2HQvF9WZ15KWwxdfK6J/fHQDy2UFSkaF41oXNQdBTyCVB2gxzHHF5nL//NkioVMj5wzEE/KzUtaClAjpb3Hs9wejEcSACdW7dZ1CPlPgcV1EUO5FxmJLP58amj7/q119IiAdIVrn2x0aZjesdG+JJJUT/QnsdmrdlplhEau6itzTO/sREroHeoN4kn5/uPoOXZOtWEtnDEAr+mwjauN2pELbyACmJlrj5kjPXUgyVCIVSyqdXFz51CKg1S2sc2MSmqjYyNpQMrBLNsnpSUsrQjxvXZZg6LtqQG6uYH+ztbYjeX0whdn7YoWs93KavTufjVapi5zmfadeuOlqY2ha3SpbItTqoji5CVvPqfFJb5d5e+pt3lOe2yadb/RLD2xUP/MXZgYtjBhEMEhDRCrUGdRa2zbOSMLUlW0UBUp0BUPzu5RE+TkvUM+tpxSx9M3zLpmJwfzgbHIYe6ZI1Q9qJlbYJYvJ0TYv9KlMX+X2zn2iELIFpyE4tykd5khCN/RwPFfeQCOoULgbGTxSTlBLfrZ75dWEW4J4Gi3zxFD0+lOVL3gPlKs3RFpoqz2WB9jGjHnGr/r6CZfyZkqVUQi4gjaW/nqVLieOnzcKXRv6yh2b8CUCEqLkEdslQkIsDTY1Z3lf X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(82310400026)(36860700016)(376014)(7416014)(56012099006)(13003099007)(10067099003)(921020)(22082099003)(18002099003)(6133799003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yHOZsJFDsTZgF+dJLjVLHFIhx3jMhw9o6mx7NZ66GaXd0NxzlLvw8zp8o54JoMyq5+00Bo55W7G4iMeKQB+5TrKmKhVkumGdqY8bdNzEqCLJ5CNVDSMI0LaRkFBsSZelm+lEHRvXstmpLwueGEARvl4qcMaHiZy4CReFQHLjf2MFt2IWW9ymVbrpAEAeNVSl360PKOGyPxtVuu3Q+DscuIcjqod3lmKTPjr+lKL0BddLF83Ze0WyVScXfDtmGUDCtIyvDAT54LLH14lqaV2e90T+a+MqZ0pPtErA5apvjNbf4imA89quLFtCpPqCkWiFTJlIQ6pzjnzIzeBdUdNV3Md1OfQuNR/VA8SPRsN2MjPTQ1OmqmoAlv0wYLDwkr9/2WdatHoZSOjT9nVnAkwKiKIjF40YUstkANdXt+94nXG6FV736zoDwE6cod7cQcbM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:39:24.2766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f53deb87-6a8e-4695-1dc8-08dee8b76d51 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6185.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4451 Content-Type: text/plain; charset="utf-8" The AXI Ethernet driver currently supports only the AXI 1G Ethernet IP. Add support for the Xilinx XXV Ethernet IP[1], which implements a 10G/25G Ethernet MAC with PCS/PMA driving a high-speed serial transceiver, as specified by the 25G Ethernet Consortium. Add the XXV-specific logic in new xilinx_axienet_xxv.c/.h files and describe the MAC through an axienet_10g25g_config that provides the capability flags and callbacks (GT reset, link-ready polling, options programming, phylink caps, PCS ops, register dump and probe-time init). No MAC-specific conditionals are added to the shared paths. Also propagate the axienet_device_reset() failure in axienet_open(), which was previously overwritten by phylink_of_phy_connect() before being checked. This matters for XXV, whose mac_init() can fail on a GT reset-done timeout. [1]: https://docs.amd.com/r/en-US/pg210-25g-ethernet Signed-off-by: Suraj Gupta --- drivers/net/ethernet/xilinx/Makefile | 3 +- drivers/net/ethernet/xilinx/xilinx_axienet.h | 9 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 17 +- .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 328 ++++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 86 +++++ 5 files changed, 436 insertions(+), 7 deletions(-) create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h diff --git a/drivers/net/ethernet/xilinx/Makefile b/drivers/net/ethernet/xi= linx/Makefile index 7d7dc1771423..db90e691fec5 100644 --- a/drivers/net/ethernet/xilinx/Makefile +++ b/drivers/net/ethernet/xilinx/Makefile @@ -6,5 +6,6 @@ ll_temac-objs :=3D ll_temac_main.o ll_temac_mdio.o obj-$(CONFIG_XILINX_LL_TEMAC) +=3D ll_temac.o obj-$(CONFIG_XILINX_EMACLITE) +=3D xilinx_emaclite.o -xilinx_emac-objs :=3D xilinx_axienet_main.o xilinx_axienet_mdio.o +xilinx_emac-objs :=3D xilinx_axienet_main.o xilinx_axienet_mdio.o \ + xilinx_axienet_xxv.o obj-$(CONFIG_XILINX_AXI_EMAC) +=3D xilinx_emac.o diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/eth= ernet/xilinx/xilinx_axienet.h index 40f03c9eb382..295a1b835165 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -17,6 +17,8 @@ #include #include =20 +#include "xilinx_axienet_xxv.h" + /* Packet size info */ #define XAE_HDR_SIZE 14 /* Size of Ethernet header */ #define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */ @@ -545,6 +547,7 @@ struct skbuf_dma_descriptor { * @tx_ring_tail: TX skb ring buffer tail index. * @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. + * @xxv_ip_version: XXV IP version. * @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local { @@ -627,6 +630,7 @@ struct axienet_local { int tx_ring_tail; int rx_ring_head; int rx_ring_tail; + u32 xxv_ip_version; const struct axienet_config *axienet_config; }; =20 @@ -680,6 +684,11 @@ struct axienet_config { void (*stats_update)(struct axienet_local *lp); }; =20 +static inline struct axienet_local *pcs_to_axienet_local(struct phylink_pc= s *pcs) +{ + return container_of(pcs, struct axienet_local, pcs); +} + /** * struct axienet_option - Used to set axi ethernet hardware options * @opt: Option to be set. diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/ne= t/ethernet/xilinx/xilinx_axienet_main.c index 5c59423bd778..5bffa5b9d0b4 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1705,6 +1705,10 @@ static int axienet_open(struct net_device *ndev) axienet_lock_mii(lp); ret =3D axienet_device_reset(ndev); axienet_unlock_mii(lp); + if (ret) { + dev_err(lp->dev, "axienet_device_reset() failed: %d\n", ret); + return ret; + } =20 ret =3D phylink_of_phy_connect(lp->phylink, lp->dev->of_node, 0); if (ret) { @@ -2604,11 +2608,6 @@ static const struct ethtool_ops axienet_ethtool_dmae= ngine_ops =3D { .get_rmon_stats =3D axienet_ethtool_get_rmon_stats, }; =20 -static struct axienet_local *pcs_to_axienet_local(struct phylink_pcs *pcs) -{ - return container_of(pcs, struct axienet_local, pcs); -} - static void axienet_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode, struct phylink_link_state *state) @@ -2668,7 +2667,9 @@ static struct phylink_pcs *axienet_mac_select_pcs(str= uct phylink_config *config, struct axienet_local *lp =3D netdev_priv(ndev); =20 if (interface =3D=3D PHY_INTERFACE_MODE_1000BASEX || - interface =3D=3D PHY_INTERFACE_MODE_SGMII) + interface =3D=3D PHY_INTERFACE_MODE_SGMII || + interface =3D=3D PHY_INTERFACE_MODE_10GBASER || + interface =3D=3D PHY_INTERFACE_MODE_25GBASER) return &lp->pcs; =20 return NULL; @@ -2814,6 +2815,9 @@ static void axienet_dma_err_handler(struct work_struc= t *work) =20 axienet_dma_start(lp); =20 + /* This error handler runs only for the legacy embedded-DMA (1G) path, + * whose mac_init() cannot fail, so its return value is not checked. + */ lp->axienet_config->mac_init(ndev); =20 /* Sync default options with HW but leave receiver and @@ -2917,6 +2921,7 @@ static const struct of_device_id axienet_of_match[] = =3D { { .compatible =3D "xlnx,axi-ethernet-1.00.a", .data =3D &axienet_1g_confi= g }, { .compatible =3D "xlnx,axi-ethernet-1.01.a", .data =3D &axienet_1g_confi= g }, { .compatible =3D "xlnx,axi-ethernet-2.01.a", .data =3D &axienet_1g_confi= g }, + { .compatible =3D "xlnx,xxv-ethernet-1.0", .data =3D &axienet_10g25g_conf= ig }, {}, }; =20 diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c b/drivers/net= /ethernet/xilinx/xilinx_axienet_xxv.c new file mode 100644 index 000000000000..da3f6566a0c4 --- /dev/null +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c @@ -0,0 +1,328 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * XXV (10G/25G) support + * + * Copyright (C) 2026 Advanced Micro Devices, Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "xilinx_axienet.h" +#include "xilinx_axienet_xxv.h" + +/* readl_poll_timeout() sleep interval (us) and 1 ms total timeout for GT + * reset-done and PCS block-lock polls. Values from ZynqMP/Versal bring-up; + * PG210 does not specify these bounds. + */ +#define XXV_LINK_POLL_INTERVAL_US 10 + +/* Number of XXV (10G/25G) MAC registers exposed via ethtool -d. + * Covers configuration and status registers per Xilinx PG210. + */ +static const u32 axienet_xxv_reg_dump_offsets[XXV_REGS_N] =3D { + XXV_GT_RESET_OFFSET, + XXV_RESET_OFFSET, + XXV_MODE_OFFSET, + XXV_TC_OFFSET, + XXV_RCW1_OFFSET, + XXV_JUM_OFFSET, + XXV_VL_LENGTH_OFFSET, + XXV_TICKREG_OFFSET, + XXV_CONFIG_REVISION, + XXV_CONFIG_1588_OFFSET, + XXV_CONFIG_TX_FLOW_CTRL1_OFFSET, + XXV_CONFIG_RX_FLOW_CTRL1_OFFSET, + XXV_CONFIG_RX_FLOW_CTRL2_OFFSET, + XXV_CONFIG_RSFEC_OFFSET, + XXV_CONFIG_FEC_OFFSET, + XXV_AN_CTL1_OFFSET, + XXV_AN_CTL2_OFFSET, + XXV_AN_ABILITY_OFFSET, + XXV_LT_CTL1_OFFSET, + XXV_SWITCH_CORE_SPEED_OFFSET, + XXV_CONFIG_1588_32BIT_OFFSET, + XXV_TX_CONFIG_1588_OFFSET, + XXV_RX_CONFIG_1588_OFFSET, + XXV_GTWIZ_CTRL_OFFSET, + XXV_STATRX_STATUS0_OFFSET, + XXV_RX_STATUS_REG1, + XXV_STATRX_STATUS2_OFFSET, + XXV_STATRX_BLKLCK_OFFSET, + XXV_STAT_RX_RSFEC_STATUS_OFFSET, + XXV_STAT_RX_FEC_STATUS_OFFSET, + XXV_STAT_TX_RSFEC_STATUS_OFFSET, + XXV_STAT_TX_FLOW_CTRL1_OFFSET, + XXV_STAT_RX_FLOW_CTRL1_OFFSET, + XXV_STAT_AN_STS_OFFSET, + XXV_STAT_AN_LP_STATUS_OFFSET, + XXV_STAT_AN_LINK_CTL_OFFSET, + XXV_STAT_LT_STATUS1_OFFSET, + XXV_STAT_LT_STATUS2_OFFSET, + XXV_STAT_LT_STATUS3_OFFSET, + XXV_STAT_LT_STATUS4_OFFSET, + XXV_STAT_LT_COEFF0_OFFSET, + XXV_STAT_RX_VALID_CTRL_CODE_OFFSET, + XXV_STAT_CORE_SPEED_OFFSET, + XXV_STAT_TSN_OFFSET, + XXV_STAT_GTWIZ_OFFSET, + XXV_STAT_AN_LINK_CTL2_OFFSET, +}; + +/* Option table for setting up XXV Ethernet hardware options */ +static struct axienet_option xxvenet_options[] =3D { + { /* Turn on FCS stripping on receive packets */ + .opt =3D XAE_OPTION_FCS_STRIP, + .reg =3D XXV_RCW1_OFFSET, + .m_or =3D XXV_RCW1_FCS_MASK, + }, { /* Turn on FCS insertion on transmit packets */ + .opt =3D XAE_OPTION_FCS_INSERT, + .reg =3D XXV_TC_OFFSET, + .m_or =3D XXV_TC_FCS_MASK, + }, { /* Enable transmitter */ + .opt =3D XAE_OPTION_TXEN, + .reg =3D XXV_TC_OFFSET, + .m_or =3D XXV_TC_TX_MASK, + }, { /* Enable receiver */ + .opt =3D XAE_OPTION_RXEN, + .reg =3D XXV_RCW1_OFFSET, + .m_or =3D XXV_RCW1_RX_MASK, + }, + {} +}; + +static bool axienet_xxv_ip_has_gtwiz_status(u32 ip_version) +{ + u8 minor =3D FIELD_GET(XXV_MIN_MASK, ip_version); + u8 maj =3D ip_version & XXV_MAJ_MASK; + + if (maj =3D=3D XXV_IP_VER_GTWIZ_MAJ_MIN) + return minor >=3D XXV_IP_VER_GTWIZ_MIN_MIN; + return maj > XXV_IP_VER_GTWIZ_MAJ_MIN; +} + +/** + * axienet_xxv_setoptions - Set XXV MAC options from the option table + * @ndev: Pointer to the net_device structure + * @options: Option flags to apply + */ +static void axienet_xxv_setoptions(struct net_device *ndev, u32 options) +{ + struct axienet_local *lp =3D netdev_priv(ndev); + struct axienet_option *tp =3D xxvenet_options; + u32 reg; + + while (tp->opt) { + reg =3D axienet_ior(lp, tp->reg) & ~tp->m_or; + if (options & tp->opt) + reg |=3D tp->m_or; + axienet_iow(lp, tp->reg, reg); + tp++; + } + + lp->options |=3D options; +} + +/** + * axienet_xxv_probe_init - Initialize XXV-specific state at probe time + * @lp: Pointer to the axienet_local structure + */ +static void axienet_xxv_probe_init(struct axienet_local *lp) +{ + lp->xxv_ip_version =3D axienet_ior(lp, XXV_CONFIG_REVISION); +} + +/** + * axienet_xxv_gt_reset - Pulse the XXV GT reset line + * @lp: Pointer to the axienet_local structure + */ +static void axienet_xxv_gt_reset(struct axienet_local *lp) +{ + u32 val; + + /* Reset GT */ + val =3D axienet_ior(lp, XXV_GT_RESET_OFFSET); + val |=3D XXV_GT_RESET_MASK; + axienet_iow(lp, XXV_GT_RESET_OFFSET, val); + /* Allow 1 ms for the GT reset to settle (see timeout note above) */ + mdelay(1); + val =3D axienet_ior(lp, XXV_GT_RESET_OFFSET); + val &=3D ~XXV_GT_RESET_MASK; + axienet_iow(lp, XXV_GT_RESET_OFFSET, val); +} + +/** + * axienet_xxv_poll_link_ready - Wait for XXV GT and PCS block lock + * @ndev: Pointer to the net_device structure + * + * Poll GT wizard reset-done on IP v3.2+, then RX PCS block lock. Block-lo= ck + * failure is logged but not propagated: it depends on a live link partner= and + * reference clock, so an unplugged cable must not fail device bring-up. + * + * Return: 0 on success, or a negative error if GT reset-done times out. + */ +static int axienet_xxv_poll_link_ready(struct net_device *ndev) +{ + struct axienet_local *lp =3D netdev_priv(ndev); + u32 val; + int ret; + + /* Confirm XXV Ethernet is up: on IP v3.2+, wait for GT + * reset-done before further register access, then poll until + * RX PCS block lock is asserted. + */ + if (axienet_xxv_ip_has_gtwiz_status(lp->xxv_ip_version)) { + ret =3D readl_poll_timeout(lp->regs + XXV_STAT_GTWIZ_OFFSET, + val, (val & XXV_GTWIZ_RESET_DONE), + XXV_LINK_POLL_INTERVAL_US, + DELAY_OF_ONE_MILLISEC); + if (ret) { + netdev_err(ndev, "XXV MAC GT reset not complete! Cross-check the MAC re= f clock configuration\n"); + return ret; + } + } + + ret =3D readl_poll_timeout(lp->regs + XXV_STATRX_BLKLCK_OFFSET, + val, (val & XXV_RX_BLKLCK_MASK), + XXV_LINK_POLL_INTERVAL_US, + DELAY_OF_ONE_MILLISEC); + if (ret) + netdev_err(ndev, "XXV MAC block lock not complete! Cross-check the MAC r= ef clock configuration\n"); + + return 0; +} + +/** + * axienet_xxv_mac_init - XXV MAC-specific bring-up after the DMA reset + * @ndev: Pointer to the net_device structure + * + * Return: 0 on success or a negative error number otherwise. + */ +static int axienet_xxv_mac_init(struct net_device *ndev) +{ + struct axienet_local *lp =3D netdev_priv(ndev); + int ret; + + ret =3D axienet_xxv_poll_link_ready(ndev); + if (ret) + return ret; + + lp->options |=3D XAE_OPTION_FCS_STRIP; + lp->options |=3D XAE_OPTION_FCS_INSERT; + + return 0; +} + +static void axienet_xxv_phylink_set_capabilities(struct axienet_local *lp, + struct phylink_config *cfg) +{ + u32 core_speed; + bool rtsw; + + core_speed =3D axienet_ior(lp, XXV_STAT_CORE_SPEED_OFFSET); + /* Bit[1:0]: 00=3D25G, 01=3D10G, 10=3Druntime-switchable 25G, + * 11=3Druntime-switchable 10G. A runtime-switchable core can operate at + * either speed, so advertise both; a fixed core advertises only its + * configured speed. + */ + rtsw =3D core_speed & XXV_STAT_CORE_SPEED_RTSW_MASK; + + if (rtsw || (core_speed & XXV_STAT_CORE_SPEED_10G_MASK)) { + cfg->mac_capabilities |=3D MAC_10000FD; + __set_bit(PHY_INTERFACE_MODE_10GBASER, + cfg->supported_interfaces); + } + + if (rtsw || !(core_speed & XXV_STAT_CORE_SPEED_10G_MASK)) { + cfg->mac_capabilities |=3D MAC_25000FD; + __set_bit(PHY_INTERFACE_MODE_25GBASER, + cfg->supported_interfaces); + } +} + +static void axienet_xxv_pcs_get_state(struct phylink_pcs *pcs, + unsigned int neg_mode, + struct phylink_link_state *state) +{ + struct axienet_local *lp =3D pcs_to_axienet_local(pcs); + + state->duplex =3D DUPLEX_FULL; + state->an_complete =3D !!(axienet_ior(lp, XXV_STAT_AN_STS_OFFSET) & + XXV_AN_COMPLETE_MASK); + state->link =3D axienet_ior(lp, XXV_RX_STATUS_REG1) & + XXV_RX_STATUS_MASK; + + if (axienet_ior(lp, XXV_STAT_CORE_SPEED_OFFSET) & + XXV_STAT_CORE_SPEED_10G_MASK) + state->speed =3D SPEED_10000; + else + state->speed =3D SPEED_25000; +} + +static int axienet_xxv_pcs_config(struct phylink_pcs *pcs, unsigned int ne= g_mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) +{ + return 0; +} + +static const struct phylink_pcs_ops axienet_xxv_pcs_ops =3D { + .pcs_get_state =3D axienet_xxv_pcs_get_state, + .pcs_config =3D axienet_xxv_pcs_config, +}; + +/** + * axienet_xxv_get_regs - Dump XXV MAC registers for ethtool + * @lp: Pointer to the axienet_local structure + * @data: Buffer for register values (zeroed and sized by the caller) + */ +static void axienet_xxv_get_regs(struct axienet_local *lp, u32 *data) +{ + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(axienet_xxv_reg_dump_offsets); i++) + data[i] =3D axienet_ior(lp, axienet_xxv_reg_dump_offsets[i]); +} + +static int axienet_10g25g_clk_init(struct axienet_local *lp) +{ + struct device *dev =3D lp->dev; + int ret; + + /* The register, RX and GT DRP clocks are mandatory for MAC+PCS + * operation, so fetch them as required. + */ + lp->axi_clk =3D devm_clk_get_enabled(dev, "s_axi_aclk"); + if (IS_ERR(lp->axi_clk)) + return dev_err_probe(dev, PTR_ERR(lp->axi_clk), + "could not get AXI clock\n"); + + lp->misc_clks[0].id =3D "rx_core_clk"; + lp->misc_clks[1].id =3D "dclk"; + + ret =3D devm_clk_bulk_get_enable(dev, 2, lp->misc_clks); + if (ret) + return dev_err_probe(dev, ret, + "could not get/enable XXV clocks\n"); + + return 0; +} + +const struct axienet_config axienet_10g25g_config =3D { + .sw_padding =3D true, + .internal_pcs =3D true, + .regs_n =3D XXV_REGS_N, + .clk_init =3D axienet_10g25g_clk_init, + .setoptions =3D axienet_xxv_setoptions, + .probe_init =3D axienet_xxv_probe_init, + .gt_reset =3D axienet_xxv_gt_reset, + .mac_init =3D axienet_xxv_mac_init, + .get_regs =3D axienet_xxv_get_regs, + .phylink_set_caps =3D axienet_xxv_phylink_set_capabilities, + .pcs_ops =3D &axienet_xxv_pcs_ops, +}; diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h b/drivers/net= /ethernet/xilinx/xilinx_axienet_xxv.h new file mode 100644 index 000000000000..15a323ee05b2 --- /dev/null +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * XXV (10G/25G) support + * + * Copyright (C) 2026 Advanced Micro Devices, Inc. + */ + +#ifndef XILINX_AXIENET_XXV_H +#define XILINX_AXIENET_XXV_H + +#include + +struct axienet_local; +struct axienet_config; + +#define XXV_REGS_N 46 + +/* XXV MAC Register Definitions */ +#define XXV_GT_RESET_OFFSET 0x00000000 +#define XXV_RESET_OFFSET 0x00000004 +#define XXV_MODE_OFFSET 0x00000008 +#define XXV_TC_OFFSET 0x0000000C +#define XXV_RCW1_OFFSET 0x00000014 +#define XXV_JUM_OFFSET 0x00000018 +#define XXV_VL_LENGTH_OFFSET 0x0000001C +#define XXV_TICKREG_OFFSET 0x00000020 +#define XXV_CONFIG_REVISION 0x00000024 +#define XXV_CONFIG_1588_OFFSET 0x00000038 +#define XXV_CONFIG_TX_FLOW_CTRL1_OFFSET 0x00000040 +#define XXV_CONFIG_RX_FLOW_CTRL1_OFFSET 0x00000094 +#define XXV_CONFIG_RX_FLOW_CTRL2_OFFSET 0x00000098 +#define XXV_CONFIG_RSFEC_OFFSET 0x000000D0 +#define XXV_CONFIG_FEC_OFFSET 0x000000D4 +#define XXV_AN_CTL1_OFFSET 0x000000E0 +#define XXV_AN_CTL2_OFFSET 0x000000E4 +#define XXV_AN_ABILITY_OFFSET 0x000000F8 +#define XXV_LT_CTL1_OFFSET 0x00000100 +#define XXV_SWITCH_CORE_SPEED_OFFSET 0x00000138 +#define XXV_CONFIG_1588_32BIT_OFFSET 0x0000013C +#define XXV_TX_CONFIG_1588_OFFSET 0x00000140 +#define XXV_RX_CONFIG_1588_OFFSET 0x00000144 +#define XXV_GTWIZ_CTRL_OFFSET 0x00000154 +#define XXV_STATRX_STATUS0_OFFSET 0x00000400 +#define XXV_RX_STATUS_REG1 0x00000404 +#define XXV_STATRX_STATUS2_OFFSET 0x00000408 +#define XXV_STATRX_BLKLCK_OFFSET 0x0000040C +#define XXV_STAT_RX_RSFEC_STATUS_OFFSET 0x0000043C +#define XXV_STAT_RX_FEC_STATUS_OFFSET 0x00000448 +#define XXV_STAT_TX_RSFEC_STATUS_OFFSET 0x0000044C +#define XXV_STAT_TX_FLOW_CTRL1_OFFSET 0x00000450 +#define XXV_STAT_RX_FLOW_CTRL1_OFFSET 0x00000454 +#define XXV_STAT_AN_STS_OFFSET 0x00000458 +#define XXV_STAT_AN_LP_STATUS_OFFSET 0x0000045C +#define XXV_STAT_AN_LINK_CTL_OFFSET 0x00000460 +#define XXV_STAT_LT_STATUS1_OFFSET 0x00000464 +#define XXV_STAT_LT_STATUS2_OFFSET 0x00000468 +#define XXV_STAT_LT_STATUS3_OFFSET 0x0000046C +#define XXV_STAT_LT_STATUS4_OFFSET 0x00000470 +#define XXV_STAT_LT_COEFF0_OFFSET 0x00000474 +#define XXV_STAT_RX_VALID_CTRL_CODE_OFFSET 0x00000494 +#define XXV_STAT_CORE_SPEED_OFFSET 0x00000498 +#define XXV_STAT_TSN_OFFSET 0x0000049C +#define XXV_STAT_GTWIZ_OFFSET 0x000004A0 +#define XXV_STAT_AN_LINK_CTL2_OFFSET 0x000009F0 + +/* XXV MAC Register Mask Definitions */ +#define XXV_GT_RESET_MASK BIT(0) +#define XXV_TC_TX_MASK BIT(0) +#define XXV_RCW1_RX_MASK BIT(0) +#define XXV_RCW1_FCS_MASK BIT(1) +#define XXV_TC_FCS_MASK BIT(1) +#define XXV_RX_BLKLCK_MASK BIT(0) +#define XXV_GTWIZ_RESET_DONE (BIT(0) | BIT(1)) +#define XXV_MAJ_MASK GENMASK(7, 0) +#define XXV_MIN_MASK GENMASK(15, 8) +/* IP v3.2+ exposes GT wizard status before other register access (PG210).= */ +#define XXV_IP_VER_GTWIZ_MAJ_MIN 3 +#define XXV_IP_VER_GTWIZ_MIN_MIN 2 +#define XXV_AN_COMPLETE_MASK BIT(2) +#define XXV_STAT_CORE_SPEED_RTSW_MASK BIT(1) +#define XXV_STAT_CORE_SPEED_10G_MASK BIT(0) +#define XXV_RX_STATUS_MASK BIT(0) + +extern const struct axienet_config axienet_10g25g_config; + +#endif /* XILINX_AXIENET_XXV_H */ --=20 2.25.1 From nobody Fri Jul 24 21:29:28 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013049.outbound.protection.outlook.com [40.93.196.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75488495515; Thu, 23 Jul 2026 12:39:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810378; cv=fail; b=V4ha9YG+Xxz9Q7Xd6T5Aze7WEW4DLoK+ey2DxgESr3vLr1NVxdNAxRjnTAoSzcEtgFiNDeIdDTvfZiz33fPwErEWtAVwe6NaJrdBntss2IRspmPEwNJW3vqG6Uw9vpPP8vja7m8bbsPHjkmF7BXoBd4tZ2h34M8SBQQzQ+H/8+M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810378; c=relaxed/simple; bh=hvtCyXwKAUjo3G8xxB2TQq62cZaiGVgLl0xjYiO5KRs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yl3oeZ824b9UPylo3/F1lrrc+I3mnnuXXFguiRS5hgm0QJ+cv2RyH1QGzG1MbcN0p/X26PRymoreNV3s7Cj+5PIK70eeDjR6SGiW9uaa2A6eSNsciwfA8KbI1uFUn4SjeDWUsmfcnloOL/D0wvWQgtFbQ9nB0y2QCCVsW31k2Uo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DI7Vd00z; arc=fail smtp.client-ip=40.93.196.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DI7Vd00z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LMQ0MZzYQod30PUe0F+UKg7vlmdUW7s19sx32JU/XNXXHQTS9qEBMuPgK7WwaiOY/aCZ+NOzv43wbrJgp8c5Qmc8azD7LexKyKNIxxiICj4ywSqBEtBJ1BMIPlh0Wrta+wvH7x0kxTN5VD8kXQ+aztItzFaGTmEPMpgr8ZSY/S40rCqbtyw/rsn0sPGc/IqeKTebcJ3dr8c8YieT9GMKUEKMqGcZ06ybChbcoo6yZZakFmTZDyAXCN/qyQg7yT3Y8AzjXD3rhNEjCWERxY1nL/lnH81To6xyOQ5iq77nOu+WwhfEwSuGLk6TwyhyRT1/C5YAp1eBuE2ioYzFwWTCpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=nU3YM/BXNkpa6X8NBlT3MYByrBCoqp2orspy7P608Qk=; b=th6rIBmTYsSakhJ4D28AOQMQ1VjZMVbs+6KMfQy+RMnZR8YvGSmyk7Iq20mWKBClnJOZyfRUNfAUmSO7EWADooYNHfT0dw7VmLruGO+cYimhimLG5ZzpBl4MZGln/2fmMkOY7FU+KEkm64kvam67ZkYmnNy7wUGzVSl5GxLwx0xcRpd9LjNRZYQv0j0KSFRD96VV7l141BiDNOV1HRrJ70Z4QtLyQ1Fvx4m+xfHngF11I/hHA1diLODziCnnkDMwzaxcfaasXBwwW1IHX3CTI4S4KFeUXlygMzKTruukXonR18FqsZo08a/BrYZ76dEGdvrRm7n6D/6AxXh7cjrYfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=nU3YM/BXNkpa6X8NBlT3MYByrBCoqp2orspy7P608Qk=; b=DI7Vd00zkpzvFknjB12frCF4za6JY47sPEWMm7O9PLuT/NmEWUIFmMXcuf4FR/CTUKevlgPX9oIXtoIWePvaaVL2S5qV44CDPZp9uM5SIhd3QvIxpM4ttkZJbbakAutVOQL3QpJnc2ttuvxxx4kEEML6xX4ETE2sJKA06vjw/q8= Received: from DS7P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:223::7) by MW4PR12MB7484.namprd12.prod.outlook.com (2603:10b6:303:212::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Thu, 23 Jul 2026 12:39:30 +0000 Received: from CY4PEPF0000EE3B.namprd03.prod.outlook.com (2603:10b6:8:223:cafe::7e) by DS7P220CA0013.outlook.office365.com (2603:10b6:8:223::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39: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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000EE3B.mail.protection.outlook.com (10.167.242.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:39:29 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:28 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:27 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:39:20 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 5/7] net: xilinx: axienet: Make axienet_rmon_ranges non-static for reuse Date: Thu, 23 Jul 2026 18:08:36 +0530 Message-ID: <20260723123838.125145-6-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3B:EE_|MW4PR12MB7484:EE_ X-MS-Office365-Filtering-Correlation-Id: 315555d5-2bab-43ed-e35d-08dee8b77041 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|82310400026|36860700016|376014|7416014|56012099006|10067099003|921020|22082099003|18002099003|11063799006; X-Microsoft-Antispam-Message-Info: 7So+C9EbPwW+BvjDlsJknY92/q1i0BepgFhmNLRDZOup5T2Ym3b/WtJ60OCCCRT2H7fzpY6wDN5m5vXyctb/wsfkLqXGmQCh+/DXlm997n6GQC3BWFXeaMumM8ExUU/ak0RPF9rblcKujV9RPTF7BiAR3wIsHAPONA6XdBnxRDPC5pnLam/jSs6B0Gz42ro5xOshyjCidol9lPED7dFrvYFGjp3B7LBOMB6HMoH+gl3t8u82Wa6juoInpdFwSUw0J+E9d2IauLSMM8U09Pr7tdnP84CvfaucCxkqnImH8PF4T0u2DU7HzhzsqCIXXsslKl2d3jd4O65e1ZG8N8Ls2fAc8TuO/JlivLsy2W3RhwAjb01g3XWnkZhZNtafGH7KFlj5sRfKhP91zgpKLHEzbPpp7tpmraQskX5zZ5zQmEJdVsnfKXggdi+GsaOT/ysQBSYj3FKD4vgTvJndyr406TRcMxsCxhiMfv+KASVXDfsXO27GhtoZwo0pvyppqJaSDh9mkQ6ZUdbeKCMvp5eLwfwY9tkA1WF4DYOmLc1Ey8gvzQkMXSO+qD+5+kTmDqsE4F/qZ96+7MN/xaNSkXA2hByNyxDdYDfbV3UQTS2Jefk21pnDJJAoT+NGPtl4HWoIp1mUPlvKOIwwH+2h6Xd/6Vwoa+SH6w3VAqO+AdZtKhimRHcxf5gi8RSAGAraApihzi530PdfeSoXAwZtc60JOAZ7QvPdNHjS7vMuy3Rq4Myn+g4rFtr+/XNvb0MNl6jH X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(82310400026)(36860700016)(376014)(7416014)(56012099006)(10067099003)(921020)(22082099003)(18002099003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZbCFsvue+5nztQN99Sfy+gjKT+QOLQcJ8YQqFi4v6lk8phMgc5fnFojzun9orIeeh/7Q8BGF4dH0UvKaf0VpU1uyj9z88jCdDV3rok0GzY9zGyF+03+SahDvNhG0TbUdFXkg4EAzL/N43pLX7sNtJ9STjkOoKs8agUYcTWjDeI4ZKKKCb8mjx8i9HAv5sJDD7ES4kRsrT1lJwuRwptgctKzsdORSFxRagxVPO053C3gLgK3mbp46MopJLVX/W0/U7/lKmIqRoJZFAXEXEA/IF/An7NR1ktgS9QvyW6qTEWZlbdALOIVlO67w6JnbPtGjae/gpFY0kTfO0dDFoXObHpjSCZX4rJJhl1aGFTAWQBD+VLLtmhx/62J5Z1ktPzh1GudP4tEoQzEjVioSw2rvCtliWMtDLNM9LG4XtV1GMFl3IzxAaTn94thJPlosa6Th X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:39:29.2285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 315555d5-2bab-43ed-e35d-08dee8b77041 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7484 Content-Type: text/plain; charset="utf-8" The RMON histogram range table axienet_rmon_ranges[] is MAC-agnostic. Make it non-static and declare it in the shared xilinx_axienet.h so the upcoming XXV RMON callback can reuse the same table instead of duplicating it. Include for the range element type. No functional change intended. Signed-off-by: Suraj Gupta --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 ++++ drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/eth= ernet/xilinx/xilinx_axienet.h index 295a1b835165..a1d15b4797ce 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -10,6 +10,7 @@ #define XILINX_AXIENET_H =20 #include +#include #include #include #include @@ -802,4 +803,7 @@ static inline void axienet_dma_out_addr(struct axienet_= local *lp, off_t reg, int axienet_mdio_setup(struct axienet_local *lp); void axienet_mdio_teardown(struct axienet_local *lp); =20 +/* RMON histogram ranges shared by all MAC types */ +extern const struct ethtool_rmon_hist_range axienet_rmon_ranges[]; + #endif /* XILINX_AXI_ENET_H */ diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/ne= t/ethernet/xilinx/xilinx_axienet_main.c index 5bffa5b9d0b4..19fe2fd81f3a 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -2498,7 +2498,7 @@ axienet_ethtool_get_eth_ctrl_stats(struct net_device = *dev, } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } =20 -static const struct ethtool_rmon_hist_range axienet_rmon_ranges[] =3D { +const struct ethtool_rmon_hist_range axienet_rmon_ranges[] =3D { { 64, 64 }, { 65, 127 }, { 128, 255 }, --=20 2.25.1 From nobody Fri Jul 24 21:29:28 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013051.outbound.protection.outlook.com [40.93.201.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E1804A139D; Thu, 23 Jul 2026 12:39:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810388; cv=fail; b=q93cqcXNSqW51dHEMLNwgZpJTEc33nroEsWGgqvmozr27AX7AjSvO+3zyUvTmGArU8UZk4qyzw02oanxa/o1YOzzVxUt7do1b7JDTZtxxjgNiOxEuDLwsfH371m1zr1yp/Te8YIj3oHW6Iaw8ThokhJVp56iczX7/0Rwlu72IQA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810388; c=relaxed/simple; bh=UmcKNJjcpQo04U88CulqXHN5wLnBfMmTce8MmY16LN8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YOyjIzXGCVRg/pv1aQSMJC8zNpcYwIvyE3BB+JeoBqyw1Eyg+vvSLszeWeri/OMS3XPA+fMqxCCcfXBCwVUFYAD29jPuomsJ82bfuOwkYx2UKDiWRQ//2gSPaKE+vmoRL+rjgV+TrVGgY/wYUSEp2KNIWIzoIhwvQ3nniUD4AUE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wQ80zCWL; arc=fail smtp.client-ip=40.93.201.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wQ80zCWL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K2q+cZQ7i4nkewQDCaBGImmrWalCy7Y73ZP/fmrkN1oWoalHUvT7jtl5IwIFpEzMfMArQUoFgqVWMC62jL210S/nWsCEipRsV56bomJnTtxlMk2OkQuGshg+PZgnC2m4WH2D9dOY0QMuhol5KX7AIjUwBXKl+qNUBzpT+BaWaoohiSe3ZMVTjDmSZCD18xPZzs/I+3cfBgqdQ40HQbDd1RTd92pAg5sGfMOuAJsgkJYWZP2TVSxh2Pcm1QoVDycVfLNg5h9UxF2EDFSdkdn9y+UAkP+qApgs9lYDOmeYKK7iIRHBCEW05PIVXo1gRHlW3F6fP4xdcJ1SjnnRJ/DGJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TmcDYc7H0S6bH9oEkvwHBJoAArjFlGnTjn1pOTdkzQg=; b=K4HWOna5JmQP0fYMnt2sbiPig60LNhhO6gDFXaemmNnVezvPNUxkOdQ8bhjI3sOMQb3gU7sPd6KC7nJ1wZ6V9/NTyWVHgZHviCV21lY8aMADDBeoWSlE4nwQURTzUZP6dc88/3x5BK6odtsbJDLpBMqG5t2L1dr8TGO+CQNRufWKzQIaSUxv5bOq6pYUMhTB5vrkkV4JXhhPBU5cWRMtVvX6bXR/9N03MF1EEIpZre1q2BCdoUZFRXdEIbD+tpgovGTcWIzTJsLdw3YGTzon7lWQsAjJRtUSgp0hpDygIKZ7MXJtbiP/rbIshHaZfXEW4kWrSnoCTmAQOrnIBgEdug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=TmcDYc7H0S6bH9oEkvwHBJoAArjFlGnTjn1pOTdkzQg=; b=wQ80zCWLuNjGMfZFNsVpmiXmxqKh1Ianq4G6JOnaOpxDOoe6ihcTUM8CDZDV0I/j+C/YES6lmGgZ2dbf1ztexdB9h5lrpM3CAU+dR8VcRmKRS69VnMNu/B/5Zr/a/P94sUn1fid/WOlTsBPRs8zH2gGdKrzxI7eZjG3J7c2vAac= Received: from SJ2PR07CA0016.namprd07.prod.outlook.com (2603:10b6:a03:505::16) by MW4PR12MB7483.namprd12.prod.outlook.com (2603:10b6:303:212::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 12:39:40 +0000 Received: from MWH0EPF000C618A.namprd02.prod.outlook.com (2603:10b6:a03:505:cafe::aa) by SJ2PR07CA0016.outlook.office365.com (2603:10b6:a03:505::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39:40 +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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by MWH0EPF000C618A.mail.protection.outlook.com (10.167.249.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:39:39 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:35 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:34 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:39:28 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 6/7] net: xilinx: axienet: Dispatch statistics through axienet_config ops Date: Thu, 23 Jul 2026 18:08:37 +0530 Message-ID: <20260723123838.125145-7-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C618A:EE_|MW4PR12MB7483:EE_ X-MS-Office365-Filtering-Correlation-Id: 45ea0aed-e3d0-4440-5dd0-08dee8b776ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700016|7416014|1800799024|82310400026|23010399003|10067099003|11063799006|6133799003|56012099006|18002099003|22082099003|921020; X-Microsoft-Antispam-Message-Info: qeRZV1BbSZuoy3aAhS5vJ4OZkLntXN96N6eqGEBHfytmiM9ue31XDm87Z/rGhJ5Q6CuZ45Q/qz1IoIEmHZd5TAzT5TifQaxI5WHkj+BCXgwL76HldhGzNXsfmjvqwqHtTmSzWJlWM4BKgXUe1aA0aT/7q85m2vBSFUbBPJl398ERrBY9HP7awew4oMn7m+DGp55iYaFPn5ceXCO+kJNdBlcwg1ZC3MISze6uOx8OAVQqvoqQLfL6Y14qrJqTYrVmjwyo30uJPNTAcdVssayOc4ctsShP0IcvFCmp3F8a8YZ7QeGgI4UpOTrj+JtUhai9jHPNWRYBX/TIXbqaC9sQngPgmOr6CSn4nR24Kpo9O55rPeXtJIubVPXOPwnKm6jBprmI6+98oeCmEI57mNoTaHnqONG6qIYGXrjaO0B8miEM6GWbwMhLyivjyGAoI2GNSVnsNob7z9R9GR8yJfkzt8Ivvc4ZY4PHePKwvvA9J+ukdM4B8JETsCfbw6XzKu5cjTKEzuNq4l5o/XeePSHCjt4ZBTGLodKfUpTzzp7nc2BlTFIria9Xf9YiRhbVKrKeeClq2AZ7JzYdhQ0RGdFbxarc8RXBPkDI+Z+54ohzCCquOW9w5oCaDJQUgVGhTN42/MHX50zs1MzxiLv1jn1zJL6HKGCxm5i2bkw5rBS9z4WMXxr955JOPowX1bxF79mh+R2kHMbArOd0Gmx3QCXSqAM+57U3znxzLN4G+RbHdfzq5AwgjK+EfC60vtcy5EC3 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700016)(7416014)(1800799024)(82310400026)(23010399003)(10067099003)(11063799006)(6133799003)(56012099006)(18002099003)(22082099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vL+hfczPcKGLnMEjfped9bmLJ6+432QhAIen9Fnemtpf2mZLn9FvfNDjnOW0vJLCvUJPZ8X9/V7nxkJyfH01jSH/qPCil2eiYWZLIn8nh/aqxBNo0AMOWXglvPvjZ15YH6DBtIz/vrFLB4LLvaYKMsdfjXS8uRTCd4HOiKxROehm1uh5x1wPa+poRoEMzUkcbYSGaaS7nHTGbgj3Bxxtg4YQubAV38nGr5oaGHxLCfK9MxELTBoaM2eHCojVs4RzswufXEK8+w3JEJwn2sVFks8MHHWLsFXOss3TKrFnuxA8xv0punWDaX4v+KIEO7WHLgljIRczUbSXZaDvBMsKzW608+EIfY4JX+J4k/w2fqfHZpXfB1vudIY14Y9XTmZHhZ4VoND3cYnwBBlKfMYXE5Zk7HAZcI6/Hdx5aBHsaEDipjqPFtOOmWULLhqxaByk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:39:39.9507 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45ea0aed-e3d0-4440-5dd0-08dee8b776ad 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C618A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7483 Content-Type: text/plain; charset="utf-8" The ndo_get_stats64() and ethtool statistics callbacks read the 1G MAC hardware counters directly. Supporting a second MAC type this way would require an "if (mactype =3D=3D ...)" dispatch branch in each of the eight statistics callbacks. Add statistics operation function pointers to struct axienet_config and route get_stats64, get_ethtool_stats, get_strings, get_sset_count, get_pause_stats, get_eth_mac_stats, get_eth_ctrl_stats and get_rmon_stats through them. Factor the existing 1G counter reads into axienet_1g_*() helpers and populate axienet_1g_config with them. A NULL op means the MAC does not expose that statistics group, so a MAC without control-frame counters simply leaves get_eth_ctrl_stats unset instead of open-coding the special case in the callback. No functional change intended. Signed-off-by: Suraj Gupta --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 23 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 171 +++++++++++++----- 2 files changed, 146 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/eth= ernet/xilinx/xilinx_axienet.h index a1d15b4797ce..f286c428343f 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -658,6 +658,15 @@ struct axienet_local { * @phylink_set_caps: Callback to set phylink MAC capabilities * @pcs_ops: phylink PCS operations for this MAC, or NULL if unused * @stats_update: Callback to latch/accumulate the periodic MAC counters + * @get_stats64: Callback to read MAC counters into rtnl_link_stats64 + * @get_ethtool_stats: Callback to read MAC counters for ethtool -S + * @get_strings: Callback to fill the ethtool -S statistic name strings + * @get_sset_count: Callback returning the number of ethtool -S statistics + * @get_pause_stats: Callback to read MAC pause-frame counters + * @get_eth_mac_stats: Callback to read IEEE 802.3 MAC counters + * @get_eth_ctrl_stats: Callback to read MAC-control frame counters, or NU= LL + * if the MAC exposes no control-frame counters + * @get_rmon_stats: Callback to read RMON counters and histogram ranges */ struct axienet_config { bool mdio; @@ -683,6 +692,20 @@ struct axienet_config { struct phylink_config *config); const struct phylink_pcs_ops *pcs_ops; void (*stats_update)(struct axienet_local *lp); + void (*get_stats64)(struct axienet_local *lp, + struct rtnl_link_stats64 *stats); + void (*get_ethtool_stats)(struct axienet_local *lp, u64 *data); + void (*get_strings)(u8 *data); + int (*get_sset_count)(void); + void (*get_pause_stats)(struct axienet_local *lp, + struct ethtool_pause_stats *pause_stats); + void (*get_eth_mac_stats)(struct axienet_local *lp, + struct ethtool_eth_mac_stats *mac_stats); + void (*get_eth_ctrl_stats)(struct axienet_local *lp, + struct ethtool_eth_ctrl_stats *ctrl_stats); + void (*get_rmon_stats)(struct axienet_local *lp, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges); }; =20 static inline struct axienet_local *pcs_to_axienet_local(struct phylink_pc= s *pcs) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/ne= t/ethernet/xilinx/xilinx_axienet_main.c index 19fe2fd81f3a..198de353372a 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1874,29 +1874,11 @@ static int axienet_ioctl(struct net_device *dev, st= ruct ifreq *rq, int cmd) return phylink_mii_ioctl(lp->phylink, rq, cmd); } =20 -static void -axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stat= s) +static void axienet_1g_get_stats64(struct axienet_local *lp, + struct rtnl_link_stats64 *stats) { - struct axienet_local *lp =3D netdev_priv(dev); unsigned int start; =20 - netdev_stats_to_stats64(stats, &dev->stats); - - do { - start =3D u64_stats_fetch_begin(&lp->rx_stat_sync); - stats->rx_packets =3D u64_stats_read(&lp->rx_packets); - stats->rx_bytes =3D u64_stats_read(&lp->rx_bytes); - } while (u64_stats_fetch_retry(&lp->rx_stat_sync, start)); - - do { - start =3D u64_stats_fetch_begin(&lp->tx_stat_sync); - stats->tx_packets =3D u64_stats_read(&lp->tx_packets); - stats->tx_bytes =3D u64_stats_read(&lp->tx_bytes); - } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start)); - - if (!(lp->features & XAE_FEATURE_STATS)) - return; - do { start =3D read_seqcount_begin(&lp->hw_stats_seqcount); stats->rx_length_errors =3D @@ -1924,6 +1906,33 @@ axienet_get_stats64(struct net_device *dev, struct r= tnl_link_stats64 *stats) } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } =20 +static void +axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stat= s) +{ + struct axienet_local *lp =3D netdev_priv(dev); + unsigned int start; + + netdev_stats_to_stats64(stats, &dev->stats); + + do { + start =3D u64_stats_fetch_begin(&lp->rx_stat_sync); + stats->rx_packets =3D u64_stats_read(&lp->rx_packets); + stats->rx_bytes =3D u64_stats_read(&lp->rx_bytes); + } while (u64_stats_fetch_retry(&lp->rx_stat_sync, start)); + + do { + start =3D u64_stats_fetch_begin(&lp->tx_stat_sync); + stats->tx_packets =3D u64_stats_read(&lp->tx_packets); + stats->tx_bytes =3D u64_stats_read(&lp->tx_bytes); + } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start)); + + if (!(lp->features & XAE_FEATURE_STATS)) + return; + + if (lp->axienet_config->get_stats64) + lp->axienet_config->get_stats64(lp, stats); +} + static const struct net_device_ops axienet_netdev_ops =3D { .ndo_open =3D axienet_open, .ndo_stop =3D axienet_stop, @@ -2356,11 +2365,8 @@ static int axienet_ethtools_nway_reset(struct net_de= vice *dev) return phylink_ethtool_nway_reset(lp->phylink); } =20 -static void axienet_ethtools_get_ethtool_stats(struct net_device *dev, - struct ethtool_stats *stats, - u64 *data) +static void axienet_1g_get_ethtool_stats(struct axienet_local *lp, u64 *da= ta) { - struct axienet_local *lp =3D netdev_priv(dev); unsigned int start; =20 do { @@ -2377,6 +2383,17 @@ static void axienet_ethtools_get_ethtool_stats(struc= t net_device *dev, } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } =20 +static void axienet_ethtools_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, + u64 *data) +{ + struct axienet_local *lp =3D netdev_priv(dev); + + if (lp->features & XAE_FEATURE_STATS && + lp->axienet_config->get_ethtool_stats) + lp->axienet_config->get_ethtool_stats(lp, data); +} + static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN] =3D { "Received bytes", "Transmitted bytes", @@ -2389,12 +2406,26 @@ static const char axienet_ethtool_stats_strings[][E= TH_GSTRING_LEN] =3D { "User Defined Counter 2", }; =20 +static void axienet_1g_get_strings(u8 *data) +{ + memcpy(data, axienet_ethtool_stats_strings, + sizeof(axienet_ethtool_stats_strings)); +} + +static int axienet_1g_get_sset_count(void) +{ + return ARRAY_SIZE(axienet_ethtool_stats_strings); +} + static void axienet_ethtools_get_strings(struct net_device *dev, u32 strin= gset, u8 *data) { + struct axienet_local *lp =3D netdev_priv(dev); + switch (stringset) { case ETH_SS_STATS: - memcpy(data, axienet_ethtool_stats_strings, - sizeof(axienet_ethtool_stats_strings)); + if (lp->features & XAE_FEATURE_STATS && + lp->axienet_config->get_strings) + lp->axienet_config->get_strings(data); break; } } @@ -2405,24 +2436,20 @@ static int axienet_ethtools_get_sset_count(struct n= et_device *dev, int sset) =20 switch (sset) { case ETH_SS_STATS: - if (lp->features & XAE_FEATURE_STATS) - return ARRAY_SIZE(axienet_ethtool_stats_strings); + if (lp->features & XAE_FEATURE_STATS && + lp->axienet_config->get_sset_count) + return lp->axienet_config->get_sset_count(); fallthrough; default: return -EOPNOTSUPP; } } =20 -static void -axienet_ethtools_get_pause_stats(struct net_device *dev, - struct ethtool_pause_stats *pause_stats) +static void axienet_1g_get_pause_stats(struct axienet_local *lp, + struct ethtool_pause_stats *pause_stats) { - struct axienet_local *lp =3D netdev_priv(dev); unsigned int start; =20 - if (!(lp->features & XAE_FEATURE_STATS)) - return; - do { start =3D read_seqcount_begin(&lp->hw_stats_seqcount); pause_stats->tx_pause_frames =3D @@ -2433,15 +2460,23 @@ axienet_ethtools_get_pause_stats(struct net_device = *dev, } =20 static void -axienet_ethtool_get_eth_mac_stats(struct net_device *dev, - struct ethtool_eth_mac_stats *mac_stats) +axienet_ethtools_get_pause_stats(struct net_device *dev, + struct ethtool_pause_stats *pause_stats) { struct axienet_local *lp =3D netdev_priv(dev); - unsigned int start; =20 if (!(lp->features & XAE_FEATURE_STATS)) return; =20 + if (lp->axienet_config->get_pause_stats) + lp->axienet_config->get_pause_stats(lp, pause_stats); +} + +static void axienet_1g_get_eth_mac_stats(struct axienet_local *lp, + struct ethtool_eth_mac_stats *mac_stats) +{ + unsigned int start; + do { start =3D read_seqcount_begin(&lp->hw_stats_seqcount); mac_stats->FramesTransmittedOK =3D @@ -2478,15 +2513,24 @@ axienet_ethtool_get_eth_mac_stats(struct net_device= *dev, } =20 static void -axienet_ethtool_get_eth_ctrl_stats(struct net_device *dev, - struct ethtool_eth_ctrl_stats *ctrl_stats) +axienet_ethtool_get_eth_mac_stats(struct net_device *dev, + struct ethtool_eth_mac_stats *mac_stats) { struct axienet_local *lp =3D netdev_priv(dev); - unsigned int start; =20 if (!(lp->features & XAE_FEATURE_STATS)) return; =20 + if (lp->axienet_config->get_eth_mac_stats) + lp->axienet_config->get_eth_mac_stats(lp, mac_stats); +} + +static void +axienet_1g_get_eth_ctrl_stats(struct axienet_local *lp, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + unsigned int start; + do { start =3D read_seqcount_begin(&lp->hw_stats_seqcount); ctrl_stats->MACControlFramesTransmitted =3D @@ -2498,6 +2542,19 @@ axienet_ethtool_get_eth_ctrl_stats(struct net_device= *dev, } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } =20 +static void +axienet_ethtool_get_eth_ctrl_stats(struct net_device *dev, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct axienet_local *lp =3D netdev_priv(dev); + + if (!(lp->features & XAE_FEATURE_STATS)) + return; + + if (lp->axienet_config->get_eth_ctrl_stats) + lp->axienet_config->get_eth_ctrl_stats(lp, ctrl_stats); +} + const struct ethtool_rmon_hist_range axienet_rmon_ranges[] =3D { { 64, 64 }, { 65, 127 }, @@ -2510,16 +2567,12 @@ const struct ethtool_rmon_hist_range axienet_rmon_r= anges[] =3D { }; =20 static void -axienet_ethtool_get_rmon_stats(struct net_device *dev, - struct ethtool_rmon_stats *rmon_stats, - const struct ethtool_rmon_hist_range **ranges) +axienet_1g_get_rmon_stats(struct axienet_local *lp, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) { - struct axienet_local *lp =3D netdev_priv(dev); unsigned int start; =20 - if (!(lp->features & XAE_FEATURE_STATS)) - return; - do { start =3D read_seqcount_begin(&lp->hw_stats_seqcount); rmon_stats->undersize_pkts =3D @@ -2563,6 +2616,20 @@ axienet_ethtool_get_rmon_stats(struct net_device *de= v, *ranges =3D axienet_rmon_ranges; } =20 +static void +axienet_ethtool_get_rmon_stats(struct net_device *dev, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct axienet_local *lp =3D netdev_priv(dev); + + if (!(lp->features & XAE_FEATURE_STATS)) + return; + + if (lp->axienet_config->get_rmon_stats) + lp->axienet_config->get_rmon_stats(lp, rmon_stats, ranges); +} + static const struct ethtool_ops axienet_ethtool_ops =3D { .supported_coalesce_params =3D ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USECS | @@ -2914,6 +2981,14 @@ static const struct axienet_config axienet_1g_config= =3D { .phylink_set_caps =3D axienet_1g_phylink_set_caps, .pcs_ops =3D &axienet_pcs_ops, .stats_update =3D axienet_1g_stats_update, + .get_stats64 =3D axienet_1g_get_stats64, + .get_ethtool_stats =3D axienet_1g_get_ethtool_stats, + .get_strings =3D axienet_1g_get_strings, + .get_sset_count =3D axienet_1g_get_sset_count, + .get_pause_stats =3D axienet_1g_get_pause_stats, + .get_eth_mac_stats =3D axienet_1g_get_eth_mac_stats, + .get_eth_ctrl_stats =3D axienet_1g_get_eth_ctrl_stats, + .get_rmon_stats =3D axienet_1g_get_rmon_stats, }; =20 /* Match table for of_platform binding */ --=20 2.25.1 From nobody Fri Jul 24 21:29:28 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011014.outbound.protection.outlook.com [40.93.194.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA54C492504; Thu, 23 Jul 2026 12:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810396; cv=fail; b=F466w5G1TxsDBXA8gwxYoF15OCZfIPJNCf5siEbH/BIaqtDwChkv8K01q2pwAKekI+VJUjG5A1RcrW6zcJKRoKD3nK07I0ZOsnCA/MXtP5DR66SgVtViYDbsSnkTtKo+UeRnd3gKABYl97wgrPSMXn3vgKDeCd9tIjebE7mc1Gw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784810396; c=relaxed/simple; bh=q6MhT9c9IqKPt4uGWzj3wSWSWjrMn82dhM31t3/OyNs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g5BdZukMNVxgGsi70hd/C+7r3lM+Ubi8juE+QE9nf7BuchA4IcfG6hxmqp4SzV7qE2ZrTMp9IYthNsUmfTfkvn5misShHVf1u2UcbbUTvUi9di3s1l/HRoAO1mNycREcA5RVDIzpTNoWSPAdmQEg6InheKcGRbAof0JqiZKzFg8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2T45pE/8; arc=fail smtp.client-ip=40.93.194.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2T45pE/8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EpEIeSrLxo60t33gIqF+mjLBBCQY9p0N3kNCbcnE7nEsxjjICYjDSG3e9eZb4ZuZI5zHmxF0cb/eugmIz/2O7O8H6OUel8LPHcRS0gjRwzKxLPJEyVLbYHSUx6ELLzzQAPycA1FDcF0BGaEdqciyzIO1rXFk75gbr0MXxlc0UkrDBwE8fF6lzi8z1A1O191UKWY9rbSonuT4vcofaXsMnO296DCpA/TCHNvo0quMd0IMXoxxj5voatmdzAJRrD0RCi47w+GF7nJH+UCBQ44LfPd6hf06eZUn83uDtJBJY2gIiQglRMVr3Ru9/e0dVS/N5dv+9bTAN+nAZddeLT5/xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=YdZYKG/8RBgVgm2oIJZ3860t+NPGYeLPVKpXWCcECC0=; b=dTC/xGT+xuI+M7fEHiO20xaXU74jZIljQeRIvVPeQsfS101vYGo4V7yQE682gUz9VczKlRcOs1uUJl6f6wa8eZiBN5u865NTUoHnCt3CZ1qU0DiWcktYTE1W+1sBxbj8vepssmYEsnEU2jM6Acgh20CxdVCMqTXn2rdr8klaHoWgysPiFpM+zWqUj4xyJupp9e/oLC5ZZwjufi3z4GYb/hmcvBGonqqQIGCWf0ucIG2pP02kQr5lV2TajKLS2ILIR2sv+yYcUkwbL9+1PsbDQNYXeWI9UO+gYdbzAlv96xsIHeIJcHKFhTvQLCia1kVN7hUZJP+oYG8B70MrnxHXhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch 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=YdZYKG/8RBgVgm2oIJZ3860t+NPGYeLPVKpXWCcECC0=; b=2T45pE/8ScvcaNsE5M/Ez1PmrlQrTn3PYcbQcLOBLTJ780E5+23Auw3qZrITC8vCwxELxZLg0wRhHix7tiL68AY3Lhi8z0NZjD9+BhKumReXVt39LbplQtXzr7csrCZVFPLstskxD7loFKzpnOMc6OuiWBtmKJqme2cVRbeKB5A= Received: from DS7PR03CA0350.namprd03.prod.outlook.com (2603:10b6:8:55::27) by CY5PR12MB6408.namprd12.prod.outlook.com (2603:10b6:930:3b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Thu, 23 Jul 2026 12:39:47 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::54) by DS7PR03CA0350.outlook.office365.com (2603:10b6:8:55::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Thu, 23 Jul 2026 12:39:47 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Thu, 23 Jul 2026 12:39:46 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Thu, 23 Jul 2026 07:39:42 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Thu, 23 Jul 2026 07:39:35 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Jonathan Corbet , Shuah Khan , Michael Turquette , Stephen Boyd , Brian Masney , Russell King CC: Shyam Pandey , , , , , , , , Subject: [PATCH net-next 7/7] net: xilinx: axienet: Add statistics support for XXV ethernet Date: Thu, 23 Jul 2026 18:08:38 +0530 Message-ID: <20260723123838.125145-8-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260723123838.125145-1-suraj.gupta2@amd.com> References: <20260723123838.125145-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|CY5PR12MB6408:EE_ X-MS-Office365-Filtering-Correlation-Id: 35995fdb-2bc0-48f5-2e29-08dee8b77a73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|7416014|376014|23010399003|1800799024|82310400026|56012099006|11063799006|10067099003|6133799003|10063799003|18002099003|22082099003|3023799007|921020; X-Microsoft-Antispam-Message-Info: MwI22r4XzcFCkc0ODBRVEzte8eKsgGskAspOdJGWm9nM6mNtdXwtBSsqvZeYlDkiIzwoIy921l1+3bVBgcC2XXKG1s4BqcUfjFjWT5jaJwMfNq+BGBjZBc51yZN3jhPmoqZ9+Bx7DqGIasAlN/XPYutNVP31Nb2N3qDwuIw7E7uomWYOkCQxiRs+ENFvPeKEswTzTp6Ow8Yj5ntfMm3dFbFCcNovitoTESGJaB46BJrGWZ179+xSiGm8SX+IYjJK5s1VuOcqakJ2Qb3DZRgIbClZdkAPuqzdVqjS/L15yX8TI+oy27Fp4wXjqRtOEJJd6uVg75dk3A1AjN6oULd126Zz7j5tMP7PDix6VG1nN6PrS0C5QS4KHUmgCp7JpwDwXQkNV4nywqm+GARY7/61Ufh/WkiFppAradIXYsVu6jwLk6w2726gSR3JTzj0DnxMaM9+7/FuBLGefthWEwPdIU9fVXtUXG9EbmpuFzK8wOFRPG1Y94djS3NdzMpE2osCYLKHAWM7k5TFaK+lp6OWirFGVg/BzpHI9/Kj01ZNfA/zp83DGs6nDPil/xSSiwze/FcN2IPOMwvtymf+hmLcBaTzLMdC/Q/M7szht3E84BVF7AMo6uaj+Pp9tqALv7l7KyFslko3//PN1/Ic8Cezm4lfgjeaK4r05FdqCNiR3+PL2hnwRutVaDG40SB2LmXVxu9E5eL/seMWCXqjrXjQMqh0bw1gYK9xnKxojDO4ykUdw7shtnujkCCMEE2ETKfC X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(7416014)(376014)(23010399003)(1800799024)(82310400026)(56012099006)(11063799006)(10067099003)(6133799003)(10063799003)(18002099003)(22082099003)(3023799007)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PQeADSOYV6oHR/waNMGKavN9il584ivoYY8j7UAiY0DGlZZ7u1DGOvAXILqNKX0xEpwmi4rwlMStdMXgEwu+r1vywbdEJ4m+LzhN910G7e6sA+7jBort+moXZoggl9oHCcFdP89uDOtwS1KUIjWvr1ApWQQdC9XWMktYHIJxIYXsSkXrpv+dntQPZPaUIi7Fu5VBw3aJ4tw/Dfk7j+ffrodMlBFazNlPTHF+9voqyflqAH+xNZP95CNFwLsux+91vCa8y/LI/x060KhHoI/c4Y4F+/3/oo/Rs/ShOpWdnXsUwzGjBQr51pBONiUXidjwz8C8KV8VfgsFrdYAmgw+G6jb1ymVgOeZ/5eCj8QtXV85JStrtnP3EMIxrA6xDqTOKkGQaIUecpbiawqqkWUVJVAJDCT9LF0S9cNgIGtsW0Z31Yl7ZeEd2efB1MuYQKVB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2026 12:39:46.3611 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35995fdb-2bc0-48f5-2e29-08dee8b77a73 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6408 Content-Type: text/plain; charset="utf-8" The XXV ethernet exposes a dedicated statistics block whose counters are clear-on-tick (PG210): writing TICK_REG latches the internal accumulators into the readable registers and clears them, so each post-TICK read yields the count for the interval since the previous TICK. Software accumulates those intervals, so no last-counter delta (as used by the 1G MAC) is needed. Feed both ndo_get_stats64() and the ethtool statistics (-S, pause, MAC and RMON) from this accumulator path through the axienet_config statistics ops. MAC control statistics stay unsupported as the hardware exposes no matching counters. Signed-off-by: Suraj Gupta --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 22 +- .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 266 ++++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 55 ++++ 4 files changed, 343 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/eth= ernet/xilinx/xilinx_axienet.h index f286c428343f..2ea086fc4dc3 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -549,6 +549,7 @@ struct skbuf_dma_descriptor { * @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. * @xxv_ip_version: XXV IP version. + * @xxv_stat_base: Software accumulators for the XXV clear-on-tick counter= s. * @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local { @@ -603,6 +604,7 @@ struct axienet_local { =20 u64 hw_stat_base[STAT_COUNT]; u32 hw_last_counter[STAT_COUNT]; + u64 xxv_stat_base[XXV_STAT_COUNT]; seqcount_mutex_t hw_stats_seqcount; struct mutex stats_lock; struct delayed_work stats_work; diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/ne= t/ethernet/xilinx/xilinx_axienet_main.c index 198de353372a..e693f4a49f20 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -592,7 +592,11 @@ static void axienet_refresh_stats(struct work_struct *= work) mutex_unlock(&lp->stats_lock); } =20 - /* Just less than 2^32 bytes at 2.5 GBit/s */ + /* Re-arm the poll before any counter can overflow between updates: the + * 1G byte counter reaches just under 2^32 in this interval at 2.5 Gbit/s, + * and the XXV internal accumulators must be latched (via TICK in + * axienet_xxv_stats_update()) before they saturate at line rate. + */ schedule_delayed_work(&lp->stats_work, 13 * HZ); } =20 @@ -601,7 +605,16 @@ static int __axienet_device_reset(struct axienet_local= *lp) u32 value; int ret; =20 - /* Save statistics counters in case they will be reset */ + /* Save statistics counters in case they will be reset. + * + * The XAE_FEATURE_STATS blocks in this function read the TEMAC + * statistics registers at XAE_STATS_OFFSET, i.e. they assume the 1G + * counter layout. This is safe because __axienet_device_reset() is + * only reached on the legacy (non-dmaengine) DMA path, which the + * legacy_dma capability restricts to the 1G MAC. MACs that use their + * own statistics mechanism (e.g. XXV, which is dmaengine-only) never + * execute this path. + */ mutex_lock(&lp->stats_lock); if (lp->features & XAE_FEATURE_STATS) axienet_stats_update(lp, true); @@ -1777,6 +1790,11 @@ static int axienet_stop(struct net_device *ndev) =20 cancel_work_sync(&lp->rx_dim.work); cancel_delayed_work_sync(&lp->stats_work); + if (lp->axienet_config->stats_update) { + mutex_lock(&lp->stats_lock); + lp->axienet_config->stats_update(lp); + mutex_unlock(&lp->stats_lock); + } =20 phylink_stop(lp->phylink); phylink_disconnect_phy(lp->phylink); diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c b/drivers/net= /ethernet/xilinx/xilinx_axienet_xxv.c index da3f6566a0c4..ea4bf99fddfa 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c @@ -8,9 +8,11 @@ #include #include #include +#include #include #include #include +#include =20 #include "xilinx_axienet.h" #include "xilinx_axienet_xxv.h" @@ -95,6 +97,69 @@ static struct axienet_option xxvenet_options[] =3D { {} }; =20 +/* PG210 statistics-block offsets indexed by enum xxv_stat. Each entry is + * the 32-bit LSB register address; the corresponding MSB is at +4. + */ +static const u32 axienet_xxv_stat_offsets[XXV_STAT_COUNT] =3D { + [XXV_STAT_RX_TOTAL_PACKETS] =3D XXV_STAT_RX_TOTAL_PACKETS_OFFSET, + [XXV_STAT_RX_TOTAL_GOOD_PACKETS] =3D XXV_STAT_RX_TOTAL_GOOD_PACKETS_OFFSE= T, + [XXV_STAT_RX_TOTAL_BYTES] =3D XXV_STAT_RX_TOTAL_BYTES_OFFSET, + [XXV_STAT_RX_TOTAL_GOOD_BYTES] =3D XXV_STAT_RX_TOTAL_GOOD_BYTES_OFFSET, + [XXV_STAT_RX_BAD_FCS] =3D XXV_STAT_RX_BAD_FCS_OFFSET, + [XXV_STAT_RX_INRANGEERR] =3D XXV_STAT_RX_INRANGEERR_OFFSET, + [XXV_STAT_RX_MULTICAST] =3D XXV_STAT_RX_MULTICAST_OFFSET, + [XXV_STAT_RX_BROADCAST] =3D XXV_STAT_RX_BROADCAST_OFFSET, + [XXV_STAT_RX_UNDERSIZE] =3D XXV_STAT_RX_UNDERSIZE_OFFSET, + [XXV_STAT_RX_FRAGMENT] =3D XXV_STAT_RX_FRAGMENT_OFFSET, + [XXV_STAT_RX_JABBER] =3D XXV_STAT_RX_JABBER_OFFSET, + [XXV_STAT_RX_OVERSIZE] =3D XXV_STAT_RX_OVERSIZE_OFFSET, + [XXV_STAT_RX_PAUSE] =3D XXV_STAT_RX_PAUSE_OFFSET, + [XXV_STAT_TX_TOTAL_PACKETS] =3D XXV_STAT_TX_TOTAL_PACKETS_OFFSET, + [XXV_STAT_TX_TOTAL_GOOD_PACKETS] =3D XXV_STAT_TX_TOTAL_GOOD_PACKETS_OFFSE= T, + [XXV_STAT_TX_TOTAL_BYTES] =3D XXV_STAT_TX_TOTAL_BYTES_OFFSET, + [XXV_STAT_TX_TOTAL_GOOD_BYTES] =3D XXV_STAT_TX_TOTAL_GOOD_BYTES_OFFSET, + [XXV_STAT_TX_BAD_FCS] =3D XXV_STAT_TX_BAD_FCS_OFFSET, + [XXV_STAT_TX_FRAME_ERROR] =3D XXV_STAT_TX_FRAME_ERROR_OFFSET, + [XXV_STAT_TX_MULTICAST] =3D XXV_STAT_TX_MULTICAST_OFFSET, + [XXV_STAT_TX_BROADCAST] =3D XXV_STAT_TX_BROADCAST_OFFSET, + [XXV_STAT_TX_PAUSE] =3D XXV_STAT_TX_PAUSE_OFFSET, +}; + +/* XXV (PG210) counters exposed via ethtool -S. Only counters that have no + * standard uAPI are listed here; the totals include errored frames, so th= ey + * are distinct from the good-frame counts in rtnl_link_stats64 and the + * IEEE MAC statistics. Every other XXV counter is reported through the + * dedicated stats64, pause, MAC and RMON callbacks instead. + */ +static const enum xxv_stat axienet_xxv_priv_stats[] =3D { + XXV_STAT_RX_TOTAL_PACKETS, + XXV_STAT_RX_TOTAL_BYTES, + XXV_STAT_TX_TOTAL_PACKETS, + XXV_STAT_TX_TOTAL_BYTES, + XXV_STAT_TX_BAD_FCS, + XXV_STAT_TX_FRAME_ERROR, +}; + +static const char axienet_xxv_ethtool_stats_strings[][ETH_GSTRING_LEN] =3D= { + "RX Total Packets", + "RX Total Bytes", + "TX Total Packets", + "TX Total Bytes", + "TX Bad FCS", + "TX Frame Error", +}; + +static u64 axienet_xxv_read_counter(struct axienet_local *lp, enum xxv_sta= t stat) +{ + u32 off =3D axienet_xxv_stat_offsets[stat]; + u32 lsb, msb; + + lsb =3D axienet_ior(lp, off); + msb =3D axienet_ior(lp, off + XXV_STAT_MSB_OFFSET); + + return ((u64)msb << 32) | lsb; +} + static bool axienet_xxv_ip_has_gtwiz_status(u32 ip_version) { u8 minor =3D FIELD_GET(XXV_MIN_MASK, ip_version); @@ -134,6 +199,7 @@ static void axienet_xxv_setoptions(struct net_device *n= dev, u32 options) static void axienet_xxv_probe_init(struct axienet_local *lp) { lp->xxv_ip_version =3D axienet_ior(lp, XXV_CONFIG_REVISION); + lp->features |=3D XAE_FEATURE_STATS; } =20 /** @@ -313,6 +379,198 @@ static int axienet_10g25g_clk_init(struct axienet_loc= al *lp) return 0; } =20 +/** + * axienet_xxv_stats_update - Latch and accumulate XXV hardware counters + * @lp: Pointer to the axienet_local structure + * + * The XXV statistics counters are clear-on-tick (PG210): writing TICK_REG + * latches the internal accumulators into the readable STAT_*_LSB/MSB regi= sters + * and clears the internal accumulators. Each post-TICK read therefore ret= urns + * the count for the interval since the previous TICK, so software accumul= ates + * those intervals into lp->xxv_stat_base. A last-counter delta (as used b= y the + * free-running 1G MAC path) is not needed. + */ +static void axienet_xxv_stats_update(struct axienet_local *lp) +{ + u64 counter[XXV_STAT_COUNT]; + enum xxv_stat stat; + + /* Latch the clear-on-tick snapshot and read the counters outside the + * seqcount write section, so only the accumulator updates run inside it + * and the reader retry window stays short. + */ + axienet_iow(lp, XXV_TICKREG_OFFSET, XXV_TICKREG_STATEN_MASK); + for (stat =3D 0; stat < XXV_STAT_COUNT; stat++) + counter[stat] =3D axienet_xxv_read_counter(lp, stat); + + write_seqcount_begin(&lp->hw_stats_seqcount); + for (stat =3D 0; stat < XXV_STAT_COUNT; stat++) + lp->xxv_stat_base[stat] +=3D counter[stat]; + write_seqcount_end(&lp->hw_stats_seqcount); +} + +/** + * axienet_xxv_get_stats64 - Fill rtnl_link_stats64 from XXV counters + * @lp: Pointer to the axienet_local structure + * @stats: Output rtnl_link_stats64 structure to populate + */ +static void axienet_xxv_get_stats64(struct axienet_local *lp, + struct rtnl_link_stats64 *stats) +{ + unsigned int start; + u64 tx_hw_errors; + + do { + start =3D read_seqcount_begin(&lp->hw_stats_seqcount); + stats->rx_crc_errors =3D lp->xxv_stat_base[XXV_STAT_RX_BAD_FCS]; + /* Both in-range length errors and frame-too-long (oversize) + * frames are IEEE 802.3 length errors, so fold them together + * into rx_length_errors; rx_over_errors is reserved for receiver + * FIFO/ring overflow, which the XXV MAC does not expose. + */ + stats->rx_length_errors =3D + lp->xxv_stat_base[XXV_STAT_RX_INRANGEERR] + + lp->xxv_stat_base[XXV_STAT_RX_OVERSIZE]; + stats->rx_errors =3D lp->xxv_stat_base[XXV_STAT_RX_UNDERSIZE] + + lp->xxv_stat_base[XXV_STAT_RX_FRAGMENT] + + lp->xxv_stat_base[XXV_STAT_RX_JABBER] + + stats->rx_crc_errors + + stats->rx_length_errors; + stats->multicast =3D lp->xxv_stat_base[XXV_STAT_RX_MULTICAST]; + tx_hw_errors =3D lp->xxv_stat_base[XXV_STAT_TX_BAD_FCS] + + lp->xxv_stat_base[XXV_STAT_TX_FRAME_ERROR]; + } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); + + /* Fold the HW TX error count into the software tx_errors seeded from + * dev->stats by the caller. The XXV xmit path bumps dev->stats.tx_errors + * for frames dropped on pad failure before they reach the MAC, while the + * HW counters only cover frames the MAC actually transmitted; the two are + * disjoint. This runs once, outside the seqcount retry loop, so a racing + * stats update cannot make the accumulation re-add on retry. + */ + stats->tx_errors +=3D tx_hw_errors; +} + +/** + * axienet_xxv_get_ethtool_stats - Copy XXV counters for ethtool -S + * @lp: Pointer to the axienet_local structure + * @data: Output buffer sized for ARRAY_SIZE(axienet_xxv_priv_stats) u64 v= alues + */ +static void axienet_xxv_get_ethtool_stats(struct axienet_local *lp, u64 *d= ata) +{ + unsigned int i, start; + + do { + start =3D read_seqcount_begin(&lp->hw_stats_seqcount); + for (i =3D 0; i < ARRAY_SIZE(axienet_xxv_priv_stats); i++) + data[i] =3D lp->xxv_stat_base[axienet_xxv_priv_stats[i]]; + } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); +} + +/** + * axienet_xxv_get_strings - Copy XXV ethtool statistics name strings + * @data: Output buffer for the statistics name strings + */ +static void axienet_xxv_get_strings(u8 *data) +{ + memcpy(data, axienet_xxv_ethtool_stats_strings, + sizeof(axienet_xxv_ethtool_stats_strings)); +} + +/** + * axienet_xxv_get_sset_count - Number of XXV ethtool statistics + * + * Return: Count of XXV hardware statistics reported via ethtool -S. + */ +static int axienet_xxv_get_sset_count(void) +{ + return ARRAY_SIZE(axienet_xxv_ethtool_stats_strings); +} + +/** + * axienet_xxv_get_pause_stats - Fill ethtool pause frame statistics + * @lp: Pointer to the axienet_local structure + * @pause_stats: Output ethtool_pause_stats structure to populate + */ +static void axienet_xxv_get_pause_stats(struct axienet_local *lp, + struct ethtool_pause_stats *pause_stats) +{ + unsigned int start; + + do { + start =3D read_seqcount_begin(&lp->hw_stats_seqcount); + pause_stats->tx_pause_frames =3D + lp->xxv_stat_base[XXV_STAT_TX_PAUSE]; + pause_stats->rx_pause_frames =3D + lp->xxv_stat_base[XXV_STAT_RX_PAUSE]; + } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); +} + +/** + * axienet_xxv_get_eth_mac_stats - Fill IEEE 802.3 MAC statistics + * @lp: Pointer to the axienet_local structure + * @mac_stats: Output ethtool_eth_mac_stats structure to populate + */ +static void axienet_xxv_get_eth_mac_stats(struct axienet_local *lp, + struct ethtool_eth_mac_stats *mac_stats) +{ + unsigned int start; + + do { + start =3D read_seqcount_begin(&lp->hw_stats_seqcount); + mac_stats->FramesTransmittedOK =3D + lp->xxv_stat_base[XXV_STAT_TX_TOTAL_GOOD_PACKETS]; + mac_stats->FramesReceivedOK =3D + lp->xxv_stat_base[XXV_STAT_RX_TOTAL_GOOD_PACKETS]; + mac_stats->OctetsTransmittedOK =3D + lp->xxv_stat_base[XXV_STAT_TX_TOTAL_GOOD_BYTES]; + mac_stats->OctetsReceivedOK =3D + lp->xxv_stat_base[XXV_STAT_RX_TOTAL_GOOD_BYTES]; + mac_stats->FrameCheckSequenceErrors =3D + lp->xxv_stat_base[XXV_STAT_RX_BAD_FCS]; + mac_stats->MulticastFramesXmittedOK =3D + lp->xxv_stat_base[XXV_STAT_TX_MULTICAST]; + mac_stats->BroadcastFramesXmittedOK =3D + lp->xxv_stat_base[XXV_STAT_TX_BROADCAST]; + mac_stats->MulticastFramesReceivedOK =3D + lp->xxv_stat_base[XXV_STAT_RX_MULTICAST]; + mac_stats->BroadcastFramesReceivedOK =3D + lp->xxv_stat_base[XXV_STAT_RX_BROADCAST]; + mac_stats->InRangeLengthErrors =3D + lp->xxv_stat_base[XXV_STAT_RX_INRANGEERR]; + } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); +} + +/** + * axienet_xxv_get_rmon_stats - Fill RMON statistics and histogram ranges + * @lp: Pointer to the axienet_local structure + * @rmon_stats: Output ethtool_rmon_stats structure to populate + * @ranges: Set to the RMON histogram range table + */ +static void axienet_xxv_get_rmon_stats(struct axienet_local *lp, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + unsigned int start; + + do { + start =3D read_seqcount_begin(&lp->hw_stats_seqcount); + rmon_stats->undersize_pkts =3D + lp->xxv_stat_base[XXV_STAT_RX_UNDERSIZE]; + rmon_stats->oversize_pkts =3D + lp->xxv_stat_base[XXV_STAT_RX_OVERSIZE]; + rmon_stats->fragments =3D + lp->xxv_stat_base[XXV_STAT_RX_FRAGMENT]; + rmon_stats->jabbers =3D + lp->xxv_stat_base[XXV_STAT_RX_JABBER]; + } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); + + /* XXV currently exposes only aggregate RMON counters, not per-bin + * histogram buckets. Keep ranges NULL until histogram bins are wired. + */ + *ranges =3D NULL; +} + const struct axienet_config axienet_10g25g_config =3D { .sw_padding =3D true, .internal_pcs =3D true, @@ -325,4 +583,12 @@ const struct axienet_config axienet_10g25g_config =3D { .get_regs =3D axienet_xxv_get_regs, .phylink_set_caps =3D axienet_xxv_phylink_set_capabilities, .pcs_ops =3D &axienet_xxv_pcs_ops, + .stats_update =3D axienet_xxv_stats_update, + .get_stats64 =3D axienet_xxv_get_stats64, + .get_ethtool_stats =3D axienet_xxv_get_ethtool_stats, + .get_strings =3D axienet_xxv_get_strings, + .get_sset_count =3D axienet_xxv_get_sset_count, + .get_pause_stats =3D axienet_xxv_get_pause_stats, + .get_eth_mac_stats =3D axienet_xxv_get_eth_mac_stats, + .get_rmon_stats =3D axienet_xxv_get_rmon_stats, }; diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h b/drivers/net= /ethernet/xilinx/xilinx_axienet_xxv.h index 15a323ee05b2..ebfa7d57a859 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h @@ -63,6 +63,33 @@ struct axienet_config; #define XXV_STAT_GTWIZ_OFFSET 0x000004A0 #define XXV_STAT_AN_LINK_CTL2_OFFSET 0x000009F0 =20 +/* XXV statistics counter registers (PG210). Each counter is a pair of 32-= bit + * registers; the MSB register is XXV_STAT_MSB_OFFSET bytes above the LSB. + */ +#define XXV_STAT_MSB_OFFSET 4 +#define XXV_STAT_TX_FRAME_ERROR_OFFSET 0x000006A0 +#define XXV_STAT_TX_TOTAL_PACKETS_OFFSET 0x00000700 +#define XXV_STAT_TX_TOTAL_GOOD_PACKETS_OFFSET 0x00000708 +#define XXV_STAT_TX_TOTAL_BYTES_OFFSET 0x00000710 +#define XXV_STAT_TX_TOTAL_GOOD_BYTES_OFFSET 0x00000718 +#define XXV_STAT_TX_BAD_FCS_OFFSET 0x000007B8 +#define XXV_STAT_TX_MULTICAST_OFFSET 0x000007D8 +#define XXV_STAT_TX_BROADCAST_OFFSET 0x000007E0 +#define XXV_STAT_TX_PAUSE_OFFSET 0x000007F0 +#define XXV_STAT_RX_TOTAL_PACKETS_OFFSET 0x00000808 +#define XXV_STAT_RX_TOTAL_GOOD_PACKETS_OFFSET 0x00000810 +#define XXV_STAT_RX_TOTAL_BYTES_OFFSET 0x00000818 +#define XXV_STAT_RX_TOTAL_GOOD_BYTES_OFFSET 0x00000820 +#define XXV_STAT_RX_UNDERSIZE_OFFSET 0x00000898 +#define XXV_STAT_RX_FRAGMENT_OFFSET 0x000008A0 +#define XXV_STAT_RX_OVERSIZE_OFFSET 0x000008A8 +#define XXV_STAT_RX_JABBER_OFFSET 0x000008B8 +#define XXV_STAT_RX_BAD_FCS_OFFSET 0x000008C0 +#define XXV_STAT_RX_MULTICAST_OFFSET 0x000008E0 +#define XXV_STAT_RX_BROADCAST_OFFSET 0x000008E8 +#define XXV_STAT_RX_PAUSE_OFFSET 0x000008F8 +#define XXV_STAT_RX_INRANGEERR_OFFSET 0x00000908 + /* XXV MAC Register Mask Definitions */ #define XXV_GT_RESET_MASK BIT(0) #define XXV_TC_TX_MASK BIT(0) @@ -70,6 +97,7 @@ struct axienet_config; #define XXV_RCW1_FCS_MASK BIT(1) #define XXV_TC_FCS_MASK BIT(1) #define XXV_RX_BLKLCK_MASK BIT(0) +#define XXV_TICKREG_STATEN_MASK BIT(0) #define XXV_GTWIZ_RESET_DONE (BIT(0) | BIT(1)) #define XXV_MAJ_MASK GENMASK(7, 0) #define XXV_MIN_MASK GENMASK(15, 8) @@ -81,6 +109,33 @@ struct axienet_config; #define XXV_STAT_CORE_SPEED_10G_MASK BIT(0) #define XXV_RX_STATUS_MASK BIT(0) =20 +/* XXV (10G/25G) MAC statistics counters, used to index xxv_stat_base[]. */ +enum xxv_stat { + XXV_STAT_RX_TOTAL_PACKETS =3D 0, + XXV_STAT_RX_TOTAL_GOOD_PACKETS, + XXV_STAT_RX_TOTAL_BYTES, + XXV_STAT_RX_TOTAL_GOOD_BYTES, + XXV_STAT_RX_BAD_FCS, + XXV_STAT_RX_INRANGEERR, + XXV_STAT_RX_MULTICAST, + XXV_STAT_RX_BROADCAST, + XXV_STAT_RX_UNDERSIZE, + XXV_STAT_RX_FRAGMENT, + XXV_STAT_RX_JABBER, + XXV_STAT_RX_OVERSIZE, + XXV_STAT_RX_PAUSE, + XXV_STAT_TX_TOTAL_PACKETS, + XXV_STAT_TX_TOTAL_GOOD_PACKETS, + XXV_STAT_TX_TOTAL_BYTES, + XXV_STAT_TX_TOTAL_GOOD_BYTES, + XXV_STAT_TX_BAD_FCS, + XXV_STAT_TX_FRAME_ERROR, + XXV_STAT_TX_MULTICAST, + XXV_STAT_TX_BROADCAST, + XXV_STAT_TX_PAUSE, + XXV_STAT_COUNT, +}; + extern const struct axienet_config axienet_10g25g_config; =20 #endif /* XILINX_AXIENET_XXV_H */ --=20 2.25.1