From patchwork Mon Jan 13 08:22:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13936950 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 143F8E7719E for ; Mon, 13 Jan 2025 08:56:11 +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=vvCzdnuJIE9/JlCNRGdk+TwR0dWiRgIn06L9QmIyikQ=; b=Yx8oY6WjvOAblDOgQc6zYoSZZw Tc64qXkgA6VLBDEzsDrcyacfrkbwH4DU7QP04MyqIh2BeQXY1JZsn073EaUkUtPa17ik/OwN418U2 JntlMW1U02HcE6y69O8RT4CTuIUxXVgfEq91isTeLh3bBRZ9FUKg+VkMexX4uCVYnW9GZspKb3R03 pR0kU5g6hzPbL854UZZmjzmZ7bbfxUEWmpDxIkqeKFGSNlTUulrdgZWCZJ9/pSVbK85h8vPYSvcc9 x/xrM6jrtBzp6uUaY+LmKFUmOM57gF5SJuQZ+gUh1u/R1eofVO5H/CLLZDspC3rgux57rXzqNOp8Y RgAh0JEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tXGEn-00000004Uct-1mDW; Mon, 13 Jan 2025 08:55:57 +0000 Received: from mail-northeuropeazlp170110001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tXG03-00000004RB2-0suC for linux-arm-kernel@lists.infradead.org; Mon, 13 Jan 2025 08:40:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Itcyjv4lNisMMzjI9O5R+E40JgdAhtj0thGcvqGJoZoDbXhKIxN27UZIqUUGfcOWekuNP6Xs/DgmDfkti5jMkZzR4nup85Yibypq+YdcXPGW5uNQXj/Pjm6HZoX6AsI6+sVTGKeQjrii968Ezh1pjWvazmfCCg+mQdC0TNitiTHVpkfJ+5jp0VlHruLJd9JPjJb1iG/IYC5cn381XjRSnBSXdKgLVT6niCYqTvwucxIRLLyq0+OA3efcpcmcqQ/M4xVNiTWko9+zfbhc4mwZYZpKowkvcJtHA9NmYf2MNE2lNLOMi6gyt6/uPmAgIS+MaqtumqsIji6ztyPAkw2UzA== 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=vvCzdnuJIE9/JlCNRGdk+TwR0dWiRgIn06L9QmIyikQ=; b=FJ7SDhYErgSLwgHfRYFb5jqPCcDxvUcUVbCiz5BdyAYxUzdAgfqTh2wIZhQ1uABrlSfRJkvc6jb0FFVQ1J5N69atRZssvykG4/CvEQ8qIiQyVTlQNVX2WsGj18ep7hBxxMkfknNH7U8q4qHccPeoJVSqtePSDm3XWo9Y/FSf9W6COAJBQ9xqzTmhlgVKfW3EeRhk2hwhblKDK37j+jg596rax9JVV/4JOMzAi0dfpaUgn3jUdB+KwSr0tIQsSZbfiqQWve+YNt/ie+zqcFnd7B5expgRWfr9BnUxNJznnhDurtu1Z3h0EPobQQqFTi6PDp2LkpxSCHy2r8uy/egpzQ== 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=vvCzdnuJIE9/JlCNRGdk+TwR0dWiRgIn06L9QmIyikQ=; b=A4878ppjhpFoZ3AOCa/Nbgwukj5FrgketedLY8SVLuLnVKcVHy4UTC8GgtNJYf9xCOmdPXxBcW1ssJWFnPZKQo3V2r12A2G8UTxrTA/GhHY2lrTDgVd/S8B6e1sqk7xW4NKL2SvdcHAI0xTnBCaDFIzCorgn+aoRtQ9M0j5LBlNJKGJ8DqvJlJaAgvEtixA+MQyg/z2E+a4jgEpnD75abrJYzOfi6ieHOB3RhxWxobHrGsDAi8w8IovZ64P/SXBXutKGX7/JBPkW+DiotuxsT5X/KN9VGow+SY66RG/JsBiPlNYAN1peFusSymfeCInMRff+ATzYt5YjPWfwTz24YQ== 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 DBBPR04MB7740.eurprd04.prod.outlook.com (2603:10a6:10:1ee::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Mon, 13 Jan 2025 08:40:39 +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.8335.017; Mon, 13 Jan 2025 08:40:39 +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 v2 net-next 12/13] net: enetc: add loopback support for i.MX95 ENETC PF Date: Mon, 13 Jan 2025 16:22:44 +0800 Message-Id: <20250113082245.2332775-13-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250113082245.2332775-1-wei.fang@nxp.com> References: <20250113082245.2332775-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:196::15) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DBBPR04MB7740:EE_ X-MS-Office365-Filtering-Correlation-Id: 2393c5c4-a9e2-4c83-516e-08dd33adf555 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|52116014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: Aq4NnGK81MFZ6npk9gw3Zcs4N3OalF17ve+sSVpnZi72Yw0pGZyXDoH1m2/V+TQ9flBufjz7eO0QvvRhaDYHazqxOEAsSFKIEJVxJdoLGYqdTL47EgZ8gfZWJ5sJKIY6lUD04HJTdBA8K0arF9OunqXh4f3eF4+CZgjRBcuJlh/F6YSPET2f8xZSo0pBymSRoOEBIVpjQe7TKg9N+PLd5+IQFJu1xpcXIrUAhAtlylcaJ+AQdNwQU1szvmjhaEYMOwenOxhkGMhZLu2wABd2cCuEeAulsnPLE9evqSXTfu+9X7jFJbvPcF8oV4vcZ+T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9o0LBd7pUFmJN74Ho4lK+BCBf5XZN4YTAyyhF1HzT76DO+MExzKBfpJtUii7RHSoF6bv2/aB 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)(366016)(7416014)(52116014)(1800799024)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OnJEu3g3XtBT/kcuh/3RrPNiwo+tAzWibd+2HR7/ikeT8rf29snvGMwTprXs1/W2+p2/nnS9X+4+zRLiFx6nB5pCGemg4jboVyN9/nWBMOmVhIkMyfYl9YmhELTFO3vAuLjZuKiLNsNJfzKPyNF84CTOKtcnPZjXCE/IoH7HUOVoBZ1SkTWRTIzOFDAk6td2NS2JaV3daBOzJ6+RG4XfVQlPiSOhNS7DEj0DDsBLxike9IivEStH62UqDqMzBdCNeIW/IKDzA4IRY/sJeHgRITgUtLUSmZGIFmcyYABacUNBOtU1F1KYmHSTye3DroPN7n0Sak2JOvlBzy3cKbPQBCOhPKJmW6AnCrcluLGvuUqXDsExUujPYvcjPgvtKHHKFH2VAFMrJGdOu/d2IXwDgWLbYV47+EBqUXSbc6uidFJOzRomn1ZGwVchence9YrpoarAOvplXIx34Cxq9Q/uwPBAv+4xxpjXuHEQ1RA4wgXjosHiXP9pwBVb6ecHGDOAi8ifD3ONme0sZID+bKxDiGbSP6HK86S57aovDX9WBoA3JRM0Rqr4mb1KJ+137oDB3T3sqhIsjALU+O7qyUavFh6HlShk1mKpratTo32ijVVrARlqKP8RwRkZmG1L1Zn2oRUvrMVDlJWjSH1K3S0K92K4vXGFWt5F7xEixg/+QAbKeHSzs/0ymBjBf0K8Vid5Ma+tOjMGFj6qs4pssQIKSKHy1XD3Zu2y69BTV2f+PJdvIiM3+Bcv+NpYLjYLH/tBlZFm3RsqoBjenyp+v/LXeVHo2+CJs6D77pFOWvZKUhJ+6dekXQtTkk1zlraUoCqNxg3RyC3i6B9xugD9bscfWZMGdXP/b6WQijdhcsjKK6U8ZDx/ty+oax23SGYRvebTo5eSECvOdp8OrnjCMRT+NpK6d95RYwrZmAUPpTAlQAqxZYaiY6DGubRY71aAXmqQ8UQEhXQCX1V++RV5DJmUfUJqLd7GLZ+sQlz6BPkbZPQ9Xycbvj7Lu7aZupJ+AJcLixO2eyBOeiQMKuhai+XujLA6s0fMKv71e4FsEE85rKN7tEsRZ4Se7BbVQfvlDxCrnoiRHQ/JFFq7wD6KtLfv8CqDpIVHiPqOS+CtKAVjJPvepudlkHKOGfPmI0N6f4QVBXkX9dY4iBlZzXmtjV2cqM9TxPiHn2ASgSIB3gCYO8inQDMke87b8XJVFlgawx4vCdPNtsVDCIj5GqevTUZ6QVYKJ0f2ibxr5WrGJfVJV0mRrNZY+UdeaW6qUR7KjQkd2MBIh4vyqoDo+XTbpHXxWfVSi8J2Jvs/GLYVJ3TOvR/KaPDz8CdXyavdsGMRtQKll6BTBrl9GaZWVTYxkRrqDFk+9g0URkd2QPmzZrILKXpwLNuuD2MHWLCGPX6VKzBtgC27EThbveDyUvpEgAxETLPo4BpEzx0RkHQ5uZMFwSBXc56H2J20BWp7py8qW8ZhvF1BBu/PDm40GwDrZDfFTF9pggLC3Gw4f04Nieb2rLdHPswEkk2OwmDIak3xxfZduVqRCJEKIxupU1P7YCxQB8dWVoJUAyMOvZWErjZ0StvoV5zTcqah/boJfOw0/8KO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2393c5c4-a9e2-4c83-516e-08dd33adf555 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2025 08:40:39.7117 (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: P/OgzMjT7o9LMihzA9Oi9qt1k5gLvwUIlyZQXWFjK2yUOU0DEbOpKHSDqutpV3NOsSmC2JQldjuCIJHs7++9JQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7740 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250113_004043_249653_59217520 X-CRM114-Status: GOOD ( 14.74 ) 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 65e6e3742ada..948d2f796bfb 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 |