linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: dsa: mt7530: add support for changing DSA master
@ 2023-02-11 18:41 Richard van Schagen
  2023-02-13 15:10 ` Vladimir Oltean
  0 siblings, 1 reply; 2+ messages in thread
From: Richard van Schagen @ 2023-02-11 18:41 UTC (permalink / raw)
  To: Sean Wang, Landen Chao, DENG Qingfang, Andrew Lunn,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Matthias Brugger,
	AngeloGioacchino Del Regno, Arinc Unal, Frank Wunderlich
  Cc: Richard van Schagen, netdev, linux-kernel, linux-arm-kernel,
	linux-mediatek

Add support for changing the master of a port on the MT7530 DSA subdriver.


Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: Richard van Schagen <richard@routerhints.com>
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
---
 drivers/net/dsa/mt7530.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index b5ad4b4fc00c..2374166c4858 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -1072,6 +1072,35 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
 	mutex_unlock(&priv->reg_mutex);
 }
 
+static int
+mt7530_port_change_master(struct dsa_switch *ds, int port,
+			  struct net_device *master,
+			  struct netlink_ext_ack *extack)
+{
+	struct mt7530_priv *priv = ds->priv;
+	struct dsa_port *dp = dsa_to_port(ds, port);
+	struct dsa_port *cpu_dp = master->dsa_ptr;
+
+	if (netif_is_lag_master(master)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "LAG DSA master not supported");
+		return -EOPNOTSUPP;
+	}
+
+	mutex_lock(&priv->reg_mutex);
+
+	/* Move old to new cpu on User port */
+	priv->ports[port].pm &= ~PCR_MATRIX(BIT(dp->cpu_dp->index));
+	priv->ports[port].pm |= PCR_MATRIX(BIT(cpu_dp->index));
+
+	mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
+		   priv->ports[port].pm);
+
+	mutex_unlock(&priv->reg_mutex);
+
+	return 0;
+}
+
 static int
 mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 {
@@ -3157,6 +3186,7 @@ static const struct dsa_switch_ops mt7530_switch_ops = {
 	.set_ageing_time	= mt7530_set_ageing_time,
 	.port_enable		= mt7530_port_enable,
 	.port_disable		= mt7530_port_disable,
+	.port_change_master	= mt7530_port_change_master,
 	.port_change_mtu	= mt7530_port_change_mtu,
 	.port_max_mtu		= mt7530_port_max_mtu,
 	.port_stp_state_set	= mt7530_stp_state_set,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next v2] net: dsa: mt7530: add support for changing DSA master
  2023-02-11 18:41 [PATCH net-next v2] net: dsa: mt7530: add support for changing DSA master Richard van Schagen
@ 2023-02-13 15:10 ` Vladimir Oltean
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Oltean @ 2023-02-13 15:10 UTC (permalink / raw)
  To: Richard van Schagen
  Cc: Sean Wang, Landen Chao, DENG Qingfang, Andrew Lunn,
	Florian Fainelli, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno,
	Arinc Unal, Frank Wunderlich, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Sat, Feb 11, 2023 at 07:41:01PM +0100, Richard van Schagen wrote:
> Add support for changing the master of a port on the MT7530 DSA subdriver.
> 
> 
> Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> Signed-off-by: Richard van Schagen <richard@routerhints.com>
> Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> ---

Currently with this driver, the only way for a frame to reach the CPU is
via flooding. The DSA framework can do better: it can configure the driver
to only accept certain whitelisted MAC addresses, which reduces unwanted
traffic to the CPU. But it needs driver level support for some prerequisites,
namely FDB isolation, se see dsa_switch_supports_uc_filtering() and
dsa_switch_supports_mc_filtering().

If somebody decides to add support for RX filtering later to the mt7530 driver,
he might not have access to a setup with multiple CPU ports. So this
might become a blocking issue for him.

Would it make more sense to unlock RX filtering for the mt7530 driver
now, and to make the FDB entries added on the CPU ports work when
multiple CPU ports exist, too? Now seems like the most logical moment to
do that, not later.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-13 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 18:41 [PATCH net-next v2] net: dsa: mt7530: add support for changing DSA master Richard van Schagen
2023-02-13 15:10 ` Vladimir Oltean

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).