From patchwork Tue Mar 4 07:22:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 14000141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E24E9C282D3 for ; Tue, 4 Mar 2025 08:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VW/qrnEyG86Az3cCgIFF6sCfe/uWdPG3zLsqFfGGouk=; b=0AwzaMC0eSSs2pIhKBcdtPHWBd h1tNXOe82TiFtd2iu35b3D/bJrzJiDlDGpGCJjvEE0Xm/0nLUm5fpgLYlwFyKrgn8hkh7JFhik95f b8jqYzO5XiYE7E8QbLOLJkQeqjLyoPFgyt7g/6FPmVa8t8XZCmam9mJZpZp/cPiHoM9Zdeq0LJv6m Z09zFikFnGMhBmVdZl3ZG4ZehE7yjGTPnnCG333mgjazyGtHKAW+7CdXlTuStN+rOsJGiErg9JBXJ IXcnSMX7e61nxNNnnrBScjmZd1ukekKo9l9+Tm6973Yeph71nZMI1ypM5hP2/AZY9Pm1a2Xk+XKBK t9ZOLdzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpNCT-00000003Xtp-1Lme; Tue, 04 Mar 2025 08:00:25 +0000 Received: from mail-am0eur02on2060e.outbound.protection.outlook.com ([2a01:111:f403:2606::60e] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tpMsy-00000003TH1-3YAk for linux-arm-kernel@lists.infradead.org; Tue, 04 Mar 2025 07:40:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ojfxNbcY0UivGvzepBj6Gq3WkS3nkIAWAkike7skvHME9rcUNguUqkYypJYrZed4Y/QG7gKWR7VYLgNYE07/CjdkYIQNrAwDqK+Z/31vPFbP893g5Djfvr4HchqAk9aZ6ziT2cLMdFc6cFnMroET5AnubdfD8an+BjiZzGWkh4dDeO4PtMd3hQvA2ID2JAmUQ+91IAkDe87+YYDNP65xR+Ngdl4kogAaHpLxFdRfQQ8L7tZESiWikARYxCzYLM0k/o8qmLjlowsF5uWUSLIAwSKNHa+aleiXgJ+9kD+dhwoyLee9RMenp8qJcEwzhc2iubqEREJIKCjeJ1l+phrOwA== 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=VW/qrnEyG86Az3cCgIFF6sCfe/uWdPG3zLsqFfGGouk=; b=YS+3f8sdV9x9pWGLQbeQMGXmjy4DmjcGbPJSvC2QbY/uZPzkhiEUkw+pKDFIDlfh/usMfaSXU6LHnfRVs1BOZhxcG1NCwDqMFuLX4k22uYLgdHQl6JDKWky0TXoNl8EiyzlJjdzxNIeriMPMgCVTAt8FAYWMgmUF4ega2atDr6bJGkU1+8DHtTMELUCgdBM/uzaKcXy2GYZDgUj+GxWwoCLOzi+iG/gA8eSpR2O3uaJz8lz8H+HRjfVVQZ3mQxISu1BHaauEDOkCcNHeE2zHdGa5F+lLcwKZogh6UY8ioiS2xVkO5ossZFVy7t6pW2bCPYe1TCkl07iiv88ikStv3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VW/qrnEyG86Az3cCgIFF6sCfe/uWdPG3zLsqFfGGouk=; b=E4rEdElrJQvktIsb1PVxcOPEjo8NECpZvXPuRZdt2wKbAyEfoUt7iNX59V/L4UFRtL/XCdkz651NN9+/tkIZQTObqQleHCxK8/WcMAqkUXHhE7BficWavVwpCiva93AW+fgV4VA85gudcA1wS0UFcN5b4se7KKLvmW2447ZQjfkZfehzns7R3bgIQDIpyXIsrUciyMZGzA4xvSfgQq1aSqr9/NXODY6vhKmmg4jU1k1QFYjzVYHn1B1v++rKqoVzMHG0i/RYjNarj7V/fJxiDYObAOL96MTRSqKxLvZmCmFp4Ig05xrdZvg6xOGIU7R/meWmuhNQDJkXHemdGHtIzQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by AS8PR04MB9191.eurprd04.prod.outlook.com (2603:10a6:20b:44e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.16; Tue, 4 Mar 2025 07:40:12 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%5]) with mapi id 15.20.8466.020; Tue, 4 Mar 2025 07:40:12 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: christophe.leroy@csgroup.eu, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 net-next 12/13] net: enetc: add loopback support for i.MX95 ENETC PF Date: Tue, 4 Mar 2025 15:22:00 +0800 Message-Id: <20250304072201.1332603-13-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250304072201.1332603-1-wei.fang@nxp.com> References: <20250304072201.1332603-1-wei.fang@nxp.com> X-ClientProxiedBy: SG3P274CA0007.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::19) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|AS8PR04MB9191:EE_ X-MS-Office365-Filtering-Correlation-Id: 86132595-03b7-426a-2f95-08dd5aefcbe2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: qQByjGvh60qG9J8MVQ6mpU2UhxLpN8/Gcekx2KZMA1G51HIenjdXi1yxQoTXI3poeDVvqcTmTuzgNdqVC9DItjEq6yVB0u3WhrvZ33Xxwc9aZ77Bjb/Nm1A8exh7aPL447kAnBfzq/R0s07+ynr7v8ON1re9DYUapGQibv2CxPfYRI1ZxteoOxxwghsVWQKURkLZIo2Q5uVJgs1zLyLNZEOvp1eA9D9XWuw7ivexK1EeEscc5J36/icVnOZ8Wg0dsdYk9JZ45/1fdmcjDQo/+a3lLs/9cJ1zgf5xDCbwejsh/nHPcqtWCsMjL5mvVsA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xsBAo4MyYiPQQz+Fi/7h+4qV3DiE7a4CawE0RXVqY6EHpBQit5hBUOj/DNqEZDw0xUpJjn/gkzn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6dNuFzncxrFEbP/1kqFkao3phZjPqFxeJfOXmTEKRLdoGK2r/Qo6+ajPkJ/HZ3XcVou0nEi5mM6+QreO9shmoYW2zzeAbtkyhxcQfU8H69jV5FQvUbK5EaBveWpBZe6HIgaIZDSf1vtZEQWus9BRkT+lhngAKC2SXeIQ8qhdyVFDJCAOh0qvufImHASub/JtfDCDt37AJac/p6TN9f4ertXPXWz8SgRbtqzDBwdlPQvspmiFXuCAWYpCoV3FtwCMMpzWajVz0xBAuh84B7uEOsZE83i7qAy46JkNkdiG9tMEOcNrtOBiNuvNigGf/24WY33xMCAbQ6donbZ9Lo5h/i6v4DTRnAtJI0wIyC0Clg4vEiomIuYOf7iW4b8wAXx8vT4R5Ta187SdYzGFuE0VvhSuYswlosJmByaBWIMKh51ckBcaFQJMQvdvZQ5o9FRpMaUmD7WsogxCnfgM16l7SIP3tFBgk+IwH2pYbv6ZsBl8XEVyLMqoiWGKkQPnYR6B4sQFqCk/TBVb/Ei2x5BrkdKdpQrFPPs2u8OBNOqA6O8EDxF6LLeB0xIw2dJyHJHMT2ckoclAy7G9x/r3b2v3baxbyVHPhlRl54S6RM0SyBUxwmzYAoETV1RMa+XgICBqWXdAKhp6Lnsbu+zgq14YEuS1xYtspmKc6gi46y/ZMdJsuyLKbSnxCBg75GWuS1jsTCNQdXCaJ5+p3vSXtVTrZATSLd0FRXuA65Q7JuF/5AznoWqbLBVpENI0Zzli99R59kRxLJjdSZTOdqc2FY9gr83CjidkXDfKP7kWK9m3pc2yAA88E2ObmCgbDKmxK7rUs+8wYVm0RtBFY/1ch7YQhlUlumx6ZAkZnvQ3h0fakl9J6Vij0QmaknuZrClbjG0KVcVs81N0Ms/xtNu0C1WjoJPZJ1p/EUsax7WXf0EHD7FzJ5L+UDcaIUQaELhMgrv1Uk1NODwlwrKwv8JcKxSgt0o/8TricQsduV7UK/BUhheqHpStwH3tqigyBjKCc1nqng/2kl+PNd1x5lDR+IaiGBo/sDTG0aIn3nFJj6LoNwT+hKvzEiZE8tb1ijkVyy46uIhEa+vww1sr6W9L5ojNfd7bh1XrsFc/0bU7uPz8JMND0JX/dn6P5UAqMS2ouw5LNcQxW0sZJ5sMOf3mWI8EUpnAkEa9K39p3/0p5rL5z7JbARCV6X0AKE6L0Mj6liVJ2IhjolmresqOYipw3kdokicLLKKTaaPw+PwSXCcIuQyDsBT7rl3pYSTr8aJipKy33Vzuq98UtVyXV71qafrEqmmnVG+qwX1BbWetStarUw+Ryw8xaBCOCXksQL2SmRXCzktOUdN7/rVWWP0pdWmKrYaFBbhGftUzYblsZHja8KHvlXPoJY+uMNmCFzlTuArG3rZtHZwxHgdQx7PT8yDHhJGhG99QDlk/COQd6+PgI7Xczei9Rw5s33bKi+AJKNr3OvtlP4zsKDrw7SidqJ8V1caBF7motD001hKLWE5U1KP5EwcwSqPqTa+AjK8mS8slAxCIN8D21T/q35PgtxWXgajxBGLdMfi1mJ2tCTQcRxQpS69F4rfb3+epi8rTfCYJ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86132595-03b7-426a-2f95-08dd5aefcbe2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2025 07:40:12.2762 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4UNG46VXDt412QiZ/h+J7YtGyafVK7VfuuGtVoTtNiZeX2L9bj6qJq/vB2RQvMfGM77l64EMazxevFh4gjx+bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9191 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250303_234016_892792_EE79C895 X-CRM114-Status: GOOD ( 14.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add internal loopback support for i.MX95 ENETC PF, the default loopback mode is MAC level loopback, the MAC Tx data is looped back onto the Rx. The MAC interface runs at a fixed 1:8 ratio of NETC clock in MAC-level loopback mode, with no dependency on Tx clock. Signed-off-by: Wei Fang --- .../net/ethernet/freescale/enetc/enetc4_pf.c | 18 ++++++++++++++++++ .../ethernet/freescale/enetc/enetc_pf_common.c | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index e08d06e22898..ea859792ccfa 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -108,6 +108,21 @@ static void enetc4_pf_set_si_vlan_hash_filter(struct enetc_hw *hw, enetc_port_wr(hw, ENETC4_PSIVHFR1(si), upper_32_bits(hash)); } +static void enetc4_pf_set_loopback(struct net_device *ndev, bool en) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_si *si = priv->si; + u32 val; + + val = enetc_port_mac_rd(si, ENETC4_PM_CMD_CFG(0)); + val = u32_replace_bits(val, en ? 1 : 0, PM_CMD_CFG_LOOP_EN); + /* Default to select MAC level loopback mode if loopback is enabled. */ + val = u32_replace_bits(val, en ? LPBCK_MODE_MAC_LEVEL : 0, + PM_CMD_CFG_LPBK_MODE); + + enetc_port_mac_wr(si, ENETC4_PM_CMD_CFG(0), val); +} + static void enetc4_pf_destroy_mac_list(struct enetc_pf *pf) { struct enetc_mac_list_entry *entry; @@ -710,6 +725,9 @@ static int enetc4_pf_set_features(struct net_device *ndev, enetc4_pf_set_si_vlan_promisc(hw, 0, promisc_en); } + if (changed & NETIF_F_LOOPBACK) + enetc4_pf_set_loopback(ndev, !!(features & NETIF_F_LOOPBACK)); + enetc_set_features(ndev, features); return 0; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 3f7ccc482301..0a2b8769a175 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -134,10 +134,8 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, } /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ - if (!is_enetc_rev1(si)) { - ndev->hw_features &= ~NETIF_F_LOOPBACK; + if (!is_enetc_rev1(si)) goto end; - } ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | NETDEV_XDP_ACT_NDO_XMIT | NETDEV_XDP_ACT_RX_SG |