u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: u-boot@lists.denx.de, Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Priyanka Jain <priyanka.jain@nxp.com>
Subject: [PATCH 1/9] net: tsec: add support for promiscuous mode
Date: Tue, 28 Sep 2021 02:48:17 +0300	[thread overview]
Message-ID: <20210927234825.823582-2-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20210927234825.823582-1-vladimir.oltean@nxp.com>

The Freescale TSEC can be a DSA master, and the ports of the attached
DSA switch can have different MAC addresses compared to the TSEC.
Nonetheless, the TSEC must receive the packets on behalf of those switch
ports. Therefore, implement the promiscuous mode method to allow DSA to
set this.

Note that the init_registers() function called from eth_ops :: start
overwrites this setting. There is no reason why the RCTRL register
should be zero-initialized, so just stop clearing it so that the setting
we applied in eth_ops :: set_promisc sticks.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/tsec.c | 20 ++++++++++++++++----
 include/tsec.h     |  2 ++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index f0cf0a7559ab..6f9abdae9269 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -156,6 +156,19 @@ static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
 	return 0;
 }
 
+static int tsec_set_promisc(struct udevice *dev, bool enable)
+{
+	struct tsec_private *priv = dev_get_priv(dev);
+	struct tsec __iomem *regs = priv->regs;
+
+	if (enable)
+		setbits_be32(&regs->rctrl, RCTRL_PROM);
+	else
+		clrbits_be32(&regs->rctrl, RCTRL_PROM);
+
+	return 0;
+}
+
 /*
  * Initialized required registers to appropriate values, zeroing
  * those we don't care about (unless zero is bad, in which case,
@@ -186,8 +199,6 @@ static void init_registers(struct tsec __iomem *regs)
 	out_be32(&regs->hash.gaddr6, 0);
 	out_be32(&regs->hash.gaddr7, 0);
 
-	out_be32(&regs->rctrl, 0x00000000);
-
 	/* Init RMON mib registers */
 	memset((void *)&regs->rmon, 0, sizeof(regs->rmon));
 
@@ -454,7 +465,7 @@ void redundant_init(struct tsec_private *priv)
 		0x71, 0x72};
 
 	/* Enable promiscuous mode */
-	setbits_be32(&regs->rctrl, 0x8);
+	setbits_be32(&regs->rctrl, RCTRL_PROM);
 	/* Enable loopback mode */
 	setbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
 	/* Enable transmit and receive */
@@ -506,7 +517,7 @@ void redundant_init(struct tsec_private *priv)
 	if (fail)
 		panic("eTSEC init fail!\n");
 	/* Disable promiscuous mode */
-	clrbits_be32(&regs->rctrl, 0x8);
+	clrbits_be32(&regs->rctrl, RCTRL_PROM);
 	/* Disable loopback mode */
 	clrbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
 }
@@ -932,6 +943,7 @@ static const struct eth_ops tsec_ops = {
 	.free_pkt = tsec_free_pkt,
 	.stop = tsec_halt,
 	.mcast = tsec_mcast_addr,
+	.set_promisc = tsec_set_promisc,
 };
 
 static struct tsec_data etsec2_data = {
diff --git a/include/tsec.h b/include/tsec.h
index 5433cfd96610..044ee35a91bd 100644
--- a/include/tsec.h
+++ b/include/tsec.h
@@ -122,6 +122,8 @@
 #define ECNTRL_REDUCED_MII_MODE	0x00000004
 #define ECNTRL_SGMII_MODE	0x00000002
 
+#define RCTRL_PROM		0x00000008
+
 #ifndef CONFIG_SYS_TBIPA_VALUE
 # define CONFIG_SYS_TBIPA_VALUE	0x1f
 #endif
-- 
2.25.1


  reply	other threads:[~2021-09-27 23:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 23:48 [PATCH 0/9] Support the SJA1105 DSA switch on the NXP LS1021A-TSN board Vladimir Oltean
2021-09-27 23:48 ` Vladimir Oltean [this message]
2021-09-28 13:34   ` [PATCH 1/9] net: tsec: add support for promiscuous mode Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 2/9] include: import if_vlan.h from Linux Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 3/9] net: dsa: allow drivers to get the port OF node Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 4/9] net: introduce a helper to determine whether to use in-band autoneg Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 5/9] net: dsa: felix: configure the in-band autoneg property based on OF node info Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29 12:21     ` Vladimir Oltean
2021-09-27 23:48 ` [PATCH 6/9] net: add driver for NXP SJA1105 DSA L2 switch Vladimir Oltean
2021-09-28 13:35   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 7/9] arm: dts: ls1021a-tsn: add sja1105 and eth2 bindings Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 8/9] configs: ls1021a-tsn: enable sja1105 switch driver Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:33   ` Bin Meng
2021-09-27 23:48 ` [PATCH 9/9] configs: ls1021a-tsn: enable the generation of random Ethernet MAC addresses Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:33   ` Bin Meng

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=20210927234825.823582-2-vladimir.oltean@nxp.com \
    --to=vladimir.oltean@nxp.com \
    --cc=joe.hershberger@ni.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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).