Commit 072bb190 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: change scope of ageing time setter

Change the scope of the switchdev bridge ageing time attribute setter
from the DSA slave device to the generic DSA port, so that the future
port-wide API can also be used for other port types, such as CPU and DSA
links.

Also ds->ports is now a contiguous array of dsa_port structures, thus
their addresses cannot be NULL. Remove the useless check in
dsa_fastest_ageing_time.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c02c4175
...@@ -412,21 +412,19 @@ static unsigned int dsa_fastest_ageing_time(struct dsa_switch *ds, ...@@ -412,21 +412,19 @@ static unsigned int dsa_fastest_ageing_time(struct dsa_switch *ds,
for (i = 0; i < ds->num_ports; ++i) { for (i = 0; i < ds->num_ports; ++i) {
struct dsa_port *dp = &ds->ports[i]; struct dsa_port *dp = &ds->ports[i];
if (dp && dp->ageing_time && dp->ageing_time < ageing_time) if (dp->ageing_time && dp->ageing_time < ageing_time)
ageing_time = dp->ageing_time; ageing_time = dp->ageing_time;
} }
return ageing_time; return ageing_time;
} }
static int dsa_slave_ageing_time(struct net_device *dev, static int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
const struct switchdev_attr *attr,
struct switchdev_trans *trans) struct switchdev_trans *trans)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); unsigned long ageing_jiffies = clock_t_to_jiffies(ageing_clock);
struct dsa_switch *ds = p->dp->ds;
unsigned long ageing_jiffies = clock_t_to_jiffies(attr->u.ageing_time);
unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies); unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies);
struct dsa_switch *ds = dp->ds;
if (switchdev_trans_ph_prepare(trans)) { if (switchdev_trans_ph_prepare(trans)) {
if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) if (ds->ageing_time_min && ageing_time < ds->ageing_time_min)
...@@ -437,7 +435,7 @@ static int dsa_slave_ageing_time(struct net_device *dev, ...@@ -437,7 +435,7 @@ static int dsa_slave_ageing_time(struct net_device *dev,
} }
/* Keep the fastest ageing time in case of multiple bridges */ /* Keep the fastest ageing time in case of multiple bridges */
p->dp->ageing_time = ageing_time; dp->ageing_time = ageing_time;
ageing_time = dsa_fastest_ageing_time(ds, ageing_time); ageing_time = dsa_fastest_ageing_time(ds, ageing_time);
if (ds->ops->set_ageing_time) if (ds->ops->set_ageing_time)
...@@ -463,7 +461,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev, ...@@ -463,7 +461,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
trans); trans);
break; break;
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME: case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
ret = dsa_slave_ageing_time(dev, attr, trans); ret = dsa_port_ageing_time(dp, attr->u.ageing_time, trans);
break; break;
default: default:
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment