From patchwork Fri Jan 3 06:06:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13925245 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 D428FE77198 for ; Fri, 3 Jan 2025 06:39:29 +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=Y+s06cyqpvZyiMaZkqGsEMJeuscE91SUhnNDLLyCPlM=; b=MfYGFlT7ZxZGFntqRt95P/PYE7 QVMwDPU5Rw7i88OTmJHRPm3bqIK57viPUcOHiYlaq5nxwZRQMQ8JLwwm2K0npTTZOLesJJvXWpT5N xFos4h+ENsiX6LHuPBv//p2guy9ZQfLUBWBbMWOB9afBAmIbGBw51/ZEVCUs+5Ty2M7kCegAmen3u tg391xBcxoqit3MOz/uBVIP2Ct0JILnvQUVzABuHQwOdiZrqx48vT+SwfkVWkShKiHWYz/N8jmlyc 0AQSbSxvYtqUYhCMM4sJo6wX2dLIi0ApJ9hyPom6s15iHvAf+mklTHHqO/kmw7GzznpWQBJ1gKTgI x6H+yFbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTbL1-0000000CEtE-1eIT; Fri, 03 Jan 2025 06:39:15 +0000 Received: from mail-am7eur03on20609.outbound.protection.outlook.com ([2a01:111:f403:260e::609] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTb6E-0000000CCXu-3nLB for linux-arm-kernel@lists.infradead.org; Fri, 03 Jan 2025 06:24:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YjrsUfQrGTbQvkbeAvpgmG62VYKol3rYuIxElNze/Bfr+QWDjcihRcrrkU7aNsb2ZzCFqsrS041Nc09r5h8DFUAVk+yA0xvtI7wUxpVD/O1l6BVGPj2aJVi9i1l1DA7KlgjvyPrqOWRsyfaACwaB6PZ+6N/tXAnQIj1rsAMs8GZhWTv8F0Gph+QJXibTi01Xik8+Ma5kWqCI3grzx7zUkdfdaYLnfkKzlu/2PTNd8KNZDaT4reYguOQbeTeVyS0cd7I21KkDruNtx59I/vXatK1YxL5YNg86yj90aKSB1hJie0+3ZvRijvS1Yu2BuLhYJ1lnFGdTCPGnZ4IkzHYH1Q== 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=Y+s06cyqpvZyiMaZkqGsEMJeuscE91SUhnNDLLyCPlM=; b=lo5d6r+3HKeMVmm+7benZwznZUfQAer8EGkXsUinuEgYjvt1ENudR/1J43Y/+hw1Py0ppJTlrtzkCbHe9BEF9CBaqhEr9VHJ6nTi8X084IsYkjlVyI0+Spbj3NsSelak7FrIQZkGjkTpGIKwdfx4GUlU0fBAqEztY3pgIWfh+/oB37qUQrvthDUiEuLTSek4qNDIjF2SP7p34NdJvGbKHEOz5/HwHtSkvQ6RP9GLb7qf8Aq3AuPndkyo6EjxeZJMwg/Qs97OjMT9qQs4WLm/kozbztJzOBvtBlSksofyCkJAxzJFdUNvI4vbd0k5B+bfj+58pavZNtGDr862Zybmsg== 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=Y+s06cyqpvZyiMaZkqGsEMJeuscE91SUhnNDLLyCPlM=; b=YwGh/TgQ7LVlw630lQPBj+WoNTDlYSWfpyq8uCfVJ1md//1FAdyKqd6zgG1QjoLpatvPqQHiJV5jc8/4FWYBzxQY0m/zbUTyxB3qNbKhfJHhJebqa0uEPTJ0uJKhfgtuSWeHRJhdtXDl52WHCMAaLiUnlcfdVd99Ab7tId7ndFc7jIHfUZfYtfNa2du+lMhHDNiYnt7lDKH1SXiOANtod8jFQWhpQWiIzLpR3I/EX5Ys5leWvFEcpg2IVonimtT+vaea/GQ20+c5DxTgw03hGA1EmT8QuLu45ShL36+vZqD2KSqkZnU3jEsZyjN1km257zBO4WihmSCneV6r/07Q4g== 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 DB9PR04MB9331.eurprd04.prod.outlook.com (2603:10a6:10:36d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 06:23:52 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8314.013; Fri, 3 Jan 2025 06:23:52 +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, christophe.leroy@csgroup.eu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH net-next 12/13] net: enetc: add loopback support for i.MX95 ENETC PF Date: Fri, 3 Jan 2025 14:06:08 +0800 Message-Id: <20250103060610.2233908-13-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com> References: <20250103060610.2233908-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB9PR04MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: 60b1bd02-191f-4837-34bf-08dd2bbf310c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: kWRrV7bg7pZ1qXl3IgRcVnlZxIFTAlM39jO2nFraqHCC9siS7tt5zwI3ayEGItKCuaQijyhye8Bcx55ZXptNF49L0CrEQJ2oKC0umsmTjtl/ZDarV3SCbQz9H0Uauh/T1XzFjT0mM6Jc5BN5se/g23lpwZMxDQVVmt3Y6lvuo2C3orP8pnXr8wC7XJD5HGxE6YWp9+i7H1jSpPrMUgrnbygOmgN4P7AnBPeEE1wkd++bMr4Y5v01WibtY+Y2134xuGqKLFIbfKh2hkOkGPWtveNVj+im/5fHXfuo43G+wlqChrfePflcXWW5PtujQZtLEp6SycIuq8oIE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Fp0Q6yrqQfpOc3WcAH7WLvOI5CcKt8CN0OmAgcG+LkedOG/VzfaGXG 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)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ifR4kfuSOR48NEMwYz5/kRnKrETofJfnbztyfZgqLCySEDfT+WVnDEJwKq4qvJakUetWEFfwbVvQAE2eZsyCDhUBllFW1LZP+GRXsC9d41ejt7eBBkep009y4UjYxVGIaB1PhXEOuh/AywiBLMrCOhG3+ShlCj44+8WXVVCCjBdrIU7oA3TBOt2FlqzpAWdENzxNCNqZB1oJs+igai/TpDfc7H6wJ+r8ai7dl0Lfy7jPs+IRGQlls1uq2NzMn/VjeDD8skOd+4UwLSR0KyWPjfkrOUZdfh5mIvlFLMdKNGSA8qAODWy9ygI2uj38pO84/fJ6Oz9Ru+1V30BCgzWmAC54zoLgRY4JzpvcIe4noqu8O/+W5wcALIoxFpJ1YSM+2Q0naTBQr6Opu8QTOxEyYAUtfSxSmrNDvj6CHLH/1lKX2qdl6AEHFDTEw56+RBXh6WfUnE8xkk/1hEIDYq1NtsxFGiCPVVSBc3fAf9szDzhzrR0mi8/fx+IqA+ViNsx32F+FJgSLkFeKshdyAZk4JPtVZuJAhJAfqa39gJftSMXLfWWw2hDHyZgNu0yoHDam/aseijFj1rURjqMXA2DDmuX7B5CL5+XEonB98DFl1eY8yAsoLCAgeZw4nE1oh2T4YuSKt9EpNzzTSEm/BxafL1dO3ydMoy/VD/6kn81mrHA1SbxPsKqQfLWTxl+1Zvrq6QryZ0fppSKkJQbmglqbYNpoRv9G5KaMW98l5FRBp4P1vg4POukVaroZ6OBiVDz1BVV4mOhMTtv7nWRZbWW880Ntut3oMGPSn/Oupy5h/RiHyMSmAApxm+dZphgkqV6/x4MXD+0L3nLItgrQpROvmzrU64UpRhnel/5OMgQtaC3PyymJnPsvLKf2dHeKRd+DuCUa69ktSiHO6hNzSHGkGcXr/nq9TLqAliE1bHp1kyJEJfgV/Bae+247IqTosKTRYyNCMRzVNQ3GbrZHPamKivXgr3NUHEOQs5wfjTgwIFqFXyvDXuHp0mvpf028dikE18ecvp666/O2Kt5BqX23CS/ChxwWHQMwl89WTKM7BFiHi+OiFw+zvTxL5IvxxvlxWs9zv/fVBnqzf23XIp2gzSv+jALj8svn5hRmMTtBAZYk/3MKjdibbfmDFhn1qxBNXX7oBv3p4dd2HVXzJ3vd86+kyu6EXfZJNqbwcQuC144k4XiFHmBSoIou1o6nwiS4vDdBwHuqaVcMXQBTL/FpuNM7FgwtHO6n812cI3Q3YJl9H9TnmkzzrGEJi/R4t8BY9zq6j0cYf9dQyVFaTRoDZxq+p/cZplM8P9KLBOhIkkh58XtLDpFypmTM9FAZs84n+fDtr8x1DD/OodSNwywMw3j3eAgcQpT0f4IFbTBQGnPKHmuPGCOvs2BBrTQvALAZgXE5Y9ZGvsgGPHDqSIzIkM4rzFb0vGYsnAAfw2Dd2rCPB+SuW++rC/LmbgIJermFs/WH5tHST7poLBbEtOzqFZWFDsx3GZvKAVGJv0dBiLjYrBhjPQePOcs9E3uzCTQzMqZXnzfVJjH8qQLkt7QpLvNh2YIEvH10SMRl4TEUE6UntLnGmkDkqJ3Ua8e7fxj5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60b1bd02-191f-4837-34bf-08dd2bbf310c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 06:23:52.0108 (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: FDIIF8zDfC2rsNfc4Iv8prbn3R+Hiky9G5NcpX7KUxUxeQowhf97wHMAkOl5MhNL3X7qRUT9g0TKqXhP/N5LFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9331 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250102_222358_945626_332CE350 X-CRM114-Status: GOOD ( 14.50 ) 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 e2eca28eec06..d460d75647f7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -709,6 +709,21 @@ static void enetc4_pf_set_rx_mode(struct net_device *ndev) queue_work(si->workqueue, &si->rx_mode_task); } +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 int enetc4_pf_set_features(struct net_device *ndev, netdev_features_t features) { @@ -722,6 +737,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 |