linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Wei Fang <wei.fang@nxp.com>
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 v4 net-next 13/14] net: enetc: add loopback support for i.MX95 ENETC PF
Date: Tue, 11 Mar 2025 13:38:29 +0800	[thread overview]
Message-ID: <20250311053830.1516523-14-wei.fang@nxp.com> (raw)
In-Reply-To: <20250311053830.1516523-1-wei.fang@nxp.com>

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 <wei.fang@nxp.com>
---
 .../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 4abbbbef00ff..c169900ccb4a 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;
@@ -714,6 +729,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 |
-- 
2.34.1



  parent reply	other threads:[~2025-03-11  5:58 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11  5:38 [PATCH v4 net-next 00/14] Add more feautues for ENETC v4 - round 2 Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 01/14] net: enetc: add initial netc-lib driver to support NTMP Wei Fang
2025-03-11 12:17   ` Michal Kubiak
2025-03-13 16:35   ` Vladimir Oltean
2025-03-14  3:38     ` Wei Fang
2025-03-14 12:37       ` Vladimir Oltean
2025-03-14 13:48         ` Wei Fang
2025-03-17  9:28           ` Vladimir Oltean
2025-03-17  9:55             ` Wei Fang
2025-03-17 10:00               ` Vladimir Oltean
2025-03-17 11:39                 ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 02/14] net: enetc: add command BD ring support for i.MX95 ENETC Wei Fang
2025-03-11 12:22   ` Michal Kubiak
2025-03-13 16:49   ` Vladimir Oltean
2025-03-14  4:51     ` Wei Fang
2025-03-14 11:18       ` Vladimir Oltean
2025-03-14 13:56         ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 03/14] net: enetc: move generic MAC filterng interfaces to enetc-core Wei Fang
2025-03-17  9:42   ` Vladimir Oltean
2025-03-17 10:00     ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 04/14] net: enetc: add MAC filter for i.MX95 ENETC PF Wei Fang
2025-03-17 14:18   ` Vladimir Oltean
2025-03-18  3:19     ` Wei Fang
2025-03-18  9:29       ` Vladimir Oltean
2025-03-18  9:48         ` Wei Fang
2025-03-18  8:08     ` Claudiu Manoil
2025-03-18  8:47       ` Vladimir Oltean
2025-03-11  5:38 ` [PATCH v4 net-next 05/14] net: enetc: add debugfs interface to dump MAC filter Wei Fang
2025-03-17 14:48   ` Vladimir Oltean
2025-03-18  3:28     ` Wei Fang
2025-03-18 14:54       ` Vladimir Oltean
2025-03-11  5:38 ` [PATCH v4 net-next 06/14] net: enetc: add set/get_rss_table() to enetc_si_ops Wei Fang
2025-03-17 16:42   ` Vladimir Oltean
2025-03-18  5:06     ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 07/14] net: enetc: make enetc_set_rss_key() reusable Wei Fang
2025-03-17 16:26   ` Vladimir Oltean
2025-03-18  4:54     ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 08/14] net: enetc: add RSS support for i.MX95 ENETC PF Wei Fang
2025-03-17 15:55   ` Vladimir Oltean
2025-03-18  4:47     ` Wei Fang
2025-03-18 11:43       ` Vladimir Oltean
2025-03-18 14:00         ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 09/14] net: enetc: enable RSS feature by default Wei Fang
2025-03-17 16:33   ` Vladimir Oltean
2025-03-18  5:00     ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 10/14] net: enetc: move generic VLAN filter interfaces to enetc-core Wei Fang
2025-03-17 17:05   ` Vladimir Oltean
2025-03-18  5:12     ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 11/14] net: enetc: move generic VLAN hash filter functions to enetc_pf_common.c Wei Fang
2025-03-18 10:21   ` Vladimir Oltean
2025-03-18 13:57     ` Wei Fang
2025-03-11  5:38 ` [PATCH v4 net-next 12/14] net: enetc: add VLAN filtering support for i.MX95 ENETC PF Wei Fang
2025-03-11  5:38 ` Wei Fang [this message]
2025-03-11  5:38 ` [PATCH v4 net-next 14/14] MAINTAINERS: add new file ntmp.h to ENETC driver Wei Fang
2025-03-17 17:06   ` Vladimir Oltean
2025-03-18  5:13     ` Wei Fang
2025-03-13 13:50 ` [PATCH v4 net-next 00/14] Add more feautues for ENETC v4 - round 2 Vladimir Oltean
2025-03-14  1:28   ` Wei Fang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250311053830.1516523-14-wei.fang@nxp.com \
    --to=wei.fang@nxp.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=christophe.leroy@csgroup.eu \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).