Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1489537 > unrolled thread

[PATCH net-next 0/4] net: dsa: add port fast ageing

Started byVivien Didelot <vivien.didelot@savoirfairelinux.com>
First post2016-09-22 23:00 +0200
Last post2016-09-23 14:10 +0200
Articles 6 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net-next 0/4] net: dsa: add port fast ageing Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-09-22 23:00 +0200
    [PATCH net-next 4/4] net: dsa: mv88e6xxx: implement DSA port fast ageing Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-09-22 23:00 +0200
    [PATCH net-next 2/4] net: dsa: add port fast ageing Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-09-22 23:00 +0200
    Re: [PATCH net-next 0/4] net: dsa: add port fast ageing Andrew Lunn <andrew@lunn.ch> - 2016-09-23 01:50 +0200
    Re: [PATCH net-next 0/4] net: dsa: add port fast ageing Florian Fainelli <f.fainelli@gmail.com> - 2016-09-23 07:40 +0200
    Re: [PATCH net-next 0/4] net: dsa: add port fast ageing David Miller <davem@davemloft.net> - 2016-09-23 14:10 +0200

#1489537 — [PATCH net-next 0/4] net: dsa: add port fast ageing

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2016-09-22 23:00 +0200
Subject[PATCH net-next 0/4] net: dsa: add port fast ageing
Message-ID<skjg6-2JH-9@gated-at.bofh.it>
Today the DSA drivers are in charge of flushing the MAC addresses
associated to a port when its STP state changes from Learning or
Forwarding, to Disabled or Blocking or Listening.

This makes the drivers more complex and hides this generic switch logic.

This patchset introduces a new optional port_fast_age operation to
dsa_switch_ops, to move this logic to the DSA layer and keep drivers
simple. b53 and mv88e6xxx are updated accordingly.

Vivien Didelot (4):
  net: dsa: add port STP state helper
  net: dsa: add port fast ageing
  net: dsa: b53: implement DSA port fast ageing
  net: dsa: mv88e6xxx: implement DSA port fast ageing

 drivers/net/dsa/b53/b53_common.c | 31 ++++++++++-----------------
 drivers/net/dsa/mv88e6xxx/chip.c | 45 ++++++++++++++++++++--------------------
 include/net/dsa.h                |  2 ++
 net/dsa/slave.c                  | 35 ++++++++++++++++++++++++-------
 4 files changed, 64 insertions(+), 49 deletions(-)

-- 
2.10.0

[toc] | [next] | [standalone]


#1489538 — [PATCH net-next 4/4] net: dsa: mv88e6xxx: implement DSA port fast ageing

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2016-09-22 23:00 +0200
Subject[PATCH net-next 4/4] net: dsa: mv88e6xxx: implement DSA port fast ageing
Message-ID<skjg6-2JH-23@gated-at.bofh.it>
In reply to#1489537
Now that the DSA layer handles port fast ageing on correct STP change,
simplify _mv88e6xxx_port_state and implement mv88e6xxx_port_fast_age.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 45 ++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 25bd3fa..122876c 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1133,31 +1133,18 @@ static int _mv88e6xxx_port_state(struct mv88e6xxx_chip *chip, int port,
 
 	oldstate = reg & PORT_CONTROL_STATE_MASK;
 
-	if (oldstate != state) {
-		/* Flush forwarding database if we're moving a port
-		 * from Learning or Forwarding state to Disabled or
-		 * Blocking or Listening state.
-		 */
-		if ((oldstate == PORT_CONTROL_STATE_LEARNING ||
-		     oldstate == PORT_CONTROL_STATE_FORWARDING) &&
-		    (state == PORT_CONTROL_STATE_DISABLED ||
-		     state == PORT_CONTROL_STATE_BLOCKING)) {
-			err = _mv88e6xxx_atu_remove(chip, 0, port, false);
-			if (err)
-				return err;
-		}
+	reg &= ~PORT_CONTROL_STATE_MASK;
+	reg |= state;
 
-		reg = (reg & ~PORT_CONTROL_STATE_MASK) | state;
-		err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg);
-		if (err)
-			return err;
+	err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg);
+	if (err)
+		return err;
 
-		netdev_dbg(ds->ports[port].netdev, "PortState %s (was %s)\n",
-			   mv88e6xxx_port_state_names[state],
-			   mv88e6xxx_port_state_names[oldstate]);
-	}
+	netdev_dbg(ds->ports[port].netdev, "PortState %s (was %s)\n",
+		   mv88e6xxx_port_state_names[state],
+		   mv88e6xxx_port_state_names[oldstate]);
 
-	return err;
+	return 0;
 }
 
 static int _mv88e6xxx_port_based_vlan_map(struct mv88e6xxx_chip *chip, int port)
@@ -1232,6 +1219,19 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
 			   mv88e6xxx_port_state_names[stp_state]);
 }
 
+static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
+{
+	struct mv88e6xxx_chip *chip = ds->priv;
+	int err;
+
+	mutex_lock(&chip->reg_lock);
+	err = _mv88e6xxx_atu_remove(chip, 0, port, false);
+	mutex_unlock(&chip->reg_lock);
+
+	if (err)
+		netdev_err(ds->ports[port].netdev, "failed to flush ATU\n");
+}
+
 static int _mv88e6xxx_port_pvid(struct mv88e6xxx_chip *chip, int port,
 				u16 *new, u16 *old)
 {
@@ -3684,6 +3684,7 @@ static struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.port_bridge_join	= mv88e6xxx_port_bridge_join,
 	.port_bridge_leave	= mv88e6xxx_port_bridge_leave,
 	.port_stp_state_set	= mv88e6xxx_port_stp_state_set,
+	.port_fast_age		= mv88e6xxx_port_fast_age,
 	.port_vlan_filtering	= mv88e6xxx_port_vlan_filtering,
 	.port_vlan_prepare	= mv88e6xxx_port_vlan_prepare,
 	.port_vlan_add		= mv88e6xxx_port_vlan_add,
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1489540 — [PATCH net-next 2/4] net: dsa: add port fast ageing

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2016-09-22 23:00 +0200
Subject[PATCH net-next 2/4] net: dsa: add port fast ageing
Message-ID<skjg6-2JH-17@gated-at.bofh.it>
In reply to#1489537
Today the DSA drivers are in charge of flushing the MAC addresses
associated to a port when its STP state changes from Learning or
Forwarding, to Disabled or Blocking or Listening.

This makes the drivers more complex and hides the generic switch logic.
Introduce a new optional port_fast_age operation to dsa_switch_ops, to
move this logic to the DSA layer and keep drivers simple.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 include/net/dsa.h |  2 ++
 net/dsa/slave.c   | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 7556646..b122196 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -143,6 +143,7 @@ struct dsa_port {
 	struct net_device	*netdev;
 	struct device_node	*dn;
 	unsigned int		ageing_time;
+	u8			stp_state;
 };
 
 struct dsa_switch {
@@ -339,6 +340,7 @@ struct dsa_switch_ops {
 	void	(*port_bridge_leave)(struct dsa_switch *ds, int port);
 	void	(*port_stp_state_set)(struct dsa_switch *ds, int port,
 				      u8 state);
+	void	(*port_fast_age)(struct dsa_switch *ds, int port);
 
 	/*
 	 * VLAN support
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index fd78d4c..6b1282c 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -71,8 +71,26 @@ static inline bool dsa_port_is_bridged(struct dsa_slave_priv *p)
 
 static void dsa_port_set_stp_state(struct dsa_switch *ds, int port, u8 state)
 {
+	struct dsa_port *dp = &ds->ports[port];
+
 	if (ds->ops->port_stp_state_set)
 		ds->ops->port_stp_state_set(ds, port, state);
+
+	if (ds->ops->port_fast_age) {
+		/* Fast age FDB entries or flush appropriate forwarding database
+		 * for the given port, if we are moving it from Learning or
+		 * Forwarding state, to Disabled or Blocking or Listening state.
+		 */
+
+		if ((dp->stp_state == BR_STATE_LEARNING ||
+		     dp->stp_state == BR_STATE_FORWARDING) &&
+		    (state == BR_STATE_DISABLED ||
+		     state == BR_STATE_BLOCKING ||
+		     state == BR_STATE_LISTENING))
+			ds->ops->port_fast_age(ds, port);
+	}
+
+	dp->stp_state = state;
 }
 
 static int dsa_slave_open(struct net_device *dev)
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1489657

FromAndrew Lunn <andrew@lunn.ch>
Date2016-09-23 01:50 +0200
Message-ID<sklUB-4sl-3@gated-at.bofh.it>
In reply to#1489537
On Thu, Sep 22, 2016 at 04:49:20PM -0400, Vivien Didelot wrote:
> Today the DSA drivers are in charge of flushing the MAC addresses
> associated to a port when its STP state changes from Learning or
> Forwarding, to Disabled or Blocking or Listening.
> 
> This makes the drivers more complex and hides this generic switch logic.
> 
> This patchset introduces a new optional port_fast_age operation to
> dsa_switch_ops, to move this logic to the DSA layer and keep drivers
> simple. b53 and mv88e6xxx are updated accordingly.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [next] | [standalone]


#1489771

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2016-09-23 07:40 +0200
Message-ID<skrnj-81v-1@gated-at.bofh.it>
In reply to#1489537

On 09/22/2016 01:49 PM, Vivien Didelot wrote:
> Today the DSA drivers are in charge of flushing the MAC addresses
> associated to a port when its STP state changes from Learning or
> Forwarding, to Disabled or Blocking or Listening.
> 
> This makes the drivers more complex and hides this generic switch logic.
> 
> This patchset introduces a new optional port_fast_age operation to
> dsa_switch_ops, to move this logic to the DSA layer and keep drivers
> simple. b53 and mv88e6xxx are updated accordingly.

This looks good, just one minor thing, both the b53 and mv88e6xxx can
actually return an error from fast ageing a port, should we account for
that? Not that we would be doing something about it though...

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> 
> Vivien Didelot (4):
>   net: dsa: add port STP state helper
>   net: dsa: add port fast ageing
>   net: dsa: b53: implement DSA port fast ageing
>   net: dsa: mv88e6xxx: implement DSA port fast ageing
> 
>  drivers/net/dsa/b53/b53_common.c | 31 ++++++++++-----------------
>  drivers/net/dsa/mv88e6xxx/chip.c | 45 ++++++++++++++++++++--------------------
>  include/net/dsa.h                |  2 ++
>  net/dsa/slave.c                  | 35 ++++++++++++++++++++++++-------
>  4 files changed, 64 insertions(+), 49 deletions(-)
> 

[toc] | [prev] | [next] | [standalone]


#1489975

FromDavid Miller <davem@davemloft.net>
Date2016-09-23 14:10 +0200
Message-ID<skxsJ-3rG-1@gated-at.bofh.it>
In reply to#1489537
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Thu, 22 Sep 2016 16:49:20 -0400

> Today the DSA drivers are in charge of flushing the MAC addresses
> associated to a port when its STP state changes from Learning or
> Forwarding, to Disabled or Blocking or Listening.
> 
> This makes the drivers more complex and hides this generic switch logic.
> 
> This patchset introduces a new optional port_fast_age operation to
> dsa_switch_ops, to move this logic to the DSA layer and keep drivers
> simple. b53 and mv88e6xxx are updated accordingly.

Series applied, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web