* [PATCH net-next v2 1/3] net: dsa: dsa_fastest_ageing_time return unsigned
2017-03-15 19:53 [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Vivien Didelot
@ 2017-03-15 19:53 ` Vivien Didelot
2017-03-15 20:03 ` Florian Fainelli
2017-03-15 19:53 ` [PATCH net-next v2 2/3] net: dsa: check out-of-range ageing time value Vivien Didelot
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Vivien Didelot @ 2017-03-15 19:53 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Jason Cobham, Vivien Didelot
The ageing time is defined as unsigned int, so make
dsa_fastest_ageing_time return an unsigned int instead of int.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/slave.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index c34872e1febc..cec47e843570 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -419,8 +419,8 @@ static int dsa_slave_vlan_filtering(struct net_device *dev,
return 0;
}
-static int dsa_fastest_ageing_time(struct dsa_switch *ds,
- unsigned int ageing_time)
+static unsigned int dsa_fastest_ageing_time(struct dsa_switch *ds,
+ unsigned int ageing_time)
{
int i;
--
2.12.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next v2 2/3] net: dsa: check out-of-range ageing time value
2017-03-15 19:53 [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Vivien Didelot
2017-03-15 19:53 ` [PATCH net-next v2 1/3] net: dsa: dsa_fastest_ageing_time return unsigned Vivien Didelot
@ 2017-03-15 19:53 ` Vivien Didelot
2017-03-15 20:04 ` Florian Fainelli
2017-03-15 19:53 ` [PATCH net-next v2 3/3] net: dsa: mv88e6xxx: specify ageing time limits Vivien Didelot
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Vivien Didelot @ 2017-03-15 19:53 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Jason Cobham, Vivien Didelot
If a DSA switch driver cannot program an ageing time value due to it
being out-of-range, switchdev will raise a stack trace before failing.
To fix this, add ageing_time_min and ageing_time_max members to the
dsa_switch in order for the switch drivers to optionally specify their
supported ageing time limits.
The DSA core will now check for provided ageing time limits and return
-ERANGE from the switchdev prepare phase if the value is out-of-range.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
include/net/dsa.h | 4 ++++
net/dsa/slave.c | 8 ++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index bf0e42c2a6f7..e42897fd7a96 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -233,6 +233,10 @@ struct dsa_switch {
u32 phys_mii_mask;
struct mii_bus *slave_mii_bus;
+ /* Ageing Time limits in msecs */
+ unsigned int ageing_time_min;
+ unsigned int ageing_time_max;
+
/* Dynamically allocated ports, keep last */
size_t num_ports;
struct dsa_port ports[];
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index cec47e843570..78128acfbf63 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -443,9 +443,13 @@ static int dsa_slave_ageing_time(struct net_device *dev,
unsigned long ageing_jiffies = clock_t_to_jiffies(attr->u.ageing_time);
unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies);
- /* bridge skips -EOPNOTSUPP, so skip the prepare phase */
- if (switchdev_trans_ph_prepare(trans))
+ if (switchdev_trans_ph_prepare(trans)) {
+ if (ds->ageing_time_min && ageing_time < ds->ageing_time_min)
+ return -ERANGE;
+ if (ds->ageing_time_max && ageing_time > ds->ageing_time_max)
+ return -ERANGE;
return 0;
+ }
/* Keep the fastest ageing time in case of multiple bridges */
p->dp->ageing_time = ageing_time;
--
2.12.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH net-next v2 2/3] net: dsa: check out-of-range ageing time value
2017-03-15 19:53 ` [PATCH net-next v2 2/3] net: dsa: check out-of-range ageing time value Vivien Didelot
@ 2017-03-15 20:04 ` Florian Fainelli
0 siblings, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2017-03-15 20:04 UTC (permalink / raw)
To: Vivien Didelot, netdev
Cc: linux-kernel, kernel, David S. Miller, Andrew Lunn, Jason Cobham
On 03/15/2017 12:53 PM, Vivien Didelot wrote:
> If a DSA switch driver cannot program an ageing time value due to it
> being out-of-range, switchdev will raise a stack trace before failing.
>
> To fix this, add ageing_time_min and ageing_time_max members to the
> dsa_switch in order for the switch drivers to optionally specify their
> supported ageing time limits.
>
> The DSA core will now check for provided ageing time limits and return
> -ERANGE from the switchdev prepare phase if the value is out-of-range.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
You could simplify the two changes (and remove the check for
ds->ageing_time_{min,max} by setting ds->ageing_time_min to ~0 by
default. Absolutely not critical and the code is clear as-is.
--
Florian
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v2 3/3] net: dsa: mv88e6xxx: specify ageing time limits
2017-03-15 19:53 [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Vivien Didelot
2017-03-15 19:53 ` [PATCH net-next v2 1/3] net: dsa: dsa_fastest_ageing_time return unsigned Vivien Didelot
2017-03-15 19:53 ` [PATCH net-next v2 2/3] net: dsa: check out-of-range ageing time value Vivien Didelot
@ 2017-03-15 19:53 ` Vivien Didelot
2017-03-15 20:04 ` Florian Fainelli
2017-03-15 21:05 ` [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Andrew Lunn
2017-03-15 22:34 ` David Miller
4 siblings, 1 reply; 9+ messages in thread
From: Vivien Didelot @ 2017-03-15 19:53 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Jason Cobham, Vivien Didelot
Now that DSA has ageing time limits, specify them when registering a
switch so that out-of-range values are handled correctly by the core.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reported-by: Jason Cobham <jcobham@questertangent.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 3354f99df378..2bca297d9296 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4253,6 +4253,8 @@ static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
ds->priv = chip;
ds->ops = &mv88e6xxx_switch_ops;
+ ds->ageing_time_min = chip->info->age_time_coeff;
+ ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
dev_set_drvdata(dev, ds);
--
2.12.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time
2017-03-15 19:53 [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Vivien Didelot
` (2 preceding siblings ...)
2017-03-15 19:53 ` [PATCH net-next v2 3/3] net: dsa: mv88e6xxx: specify ageing time limits Vivien Didelot
@ 2017-03-15 21:05 ` Andrew Lunn
2017-03-15 22:34 ` David Miller
4 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2017-03-15 21:05 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Jason Cobham
> This patchset fixes this by adding ageing_time_min and ageing_time_max
> fields to the dsa_switch structure, which can optionally be set by a DSA
> driver.
>
> If provided, the DSA core will check for out-of-range values in the
> SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME prepare phase and return -ERANGE
> accordingly.
>
> Finally set these limits in the mv88e6xxx driver.
Hi Vivien
Thanks for doing it this way. Nicely done.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time
2017-03-15 19:53 [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Vivien Didelot
` (3 preceding siblings ...)
2017-03-15 21:05 ` [PATCH net-next v2 0/3] net: dsa: check out-of-range ageing time Andrew Lunn
@ 2017-03-15 22:34 ` David Miller
4 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2017-03-15 22:34 UTC (permalink / raw)
To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew, jcobham
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Wed, 15 Mar 2017 15:53:47 -0400
> The ageing time limits supported by DSA drivers vary depending on the
> switch model. If a driver returns -ERANGE for out-of-range values, the
> switchdev commit phase will fail with the following stacktrace:
...
> This patchset fixes this by adding ageing_time_min and ageing_time_max
> fields to the dsa_switch structure, which can optionally be set by a DSA
> driver.
>
> If provided, the DSA core will check for out-of-range values in the
> SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME prepare phase and return -ERANGE
> accordingly.
>
> Finally set these limits in the mv88e6xxx driver.
Series applied, thanks Vivien.
^ permalink raw reply [flat|nested] 9+ messages in thread