net: dsa: make the STP state function return void
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Wed, 6 Apr 2016 15:55:03 +0000 (11:55 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Apr 2016 20:50:40 +0000 (16:50 -0400)
The DSA layer doesn't care about the return code of the port_stp_update
routine, so make it void in the layer and the DSA drivers.

Replace the useless dsa_slave_stp_update function with a
dsa_slave_stp_state function used to reply to the switchdev
SWITCHDEV_ATTR_ID_PORT_STP_STATE attribute.

In the meantime, rename port_stp_update to port_stp_state_set to
explicit the state change.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/networking/dsa/dsa.txt
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/mv88e6171.c
drivers/net/dsa/mv88e6352.c
drivers/net/dsa/mv88e6xxx.c
drivers/net/dsa/mv88e6xxx.h
include/net/dsa.h
net/dsa/slave.c

index 013b670..ba698c5 100644 (file)
@@ -533,7 +533,7 @@ Bridge layer
   out at the switch hardware for the switch to (re) learn MAC addresses behind
   this port.
 
-- port_stp_update: bridge layer function invoked when a given switch port STP
+- port_stp_state_set: bridge layer function invoked when a given switch port STP
   state is computed by the bridge layer and should be propagated to switch
   hardware to forward/block/learn traffic. The switch driver is responsible for
   computing a STP state change based on current and asked parameters and perform
index 95944d5..2bba1d9 100644 (file)
@@ -545,12 +545,11 @@ static void bcm_sf2_sw_br_leave(struct dsa_switch *ds, int port)
        priv->port_sts[port].bridge_dev = NULL;
 }
 
-static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
-                                      u8 state)
+static void bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
+                                       u8 state)
 {
        struct bcm_sf2_priv *priv = ds_to_priv(ds);
        u8 hw_state, cur_hw_state;
-       int ret = 0;
        u32 reg;
 
        reg = core_readl(priv, CORE_G_PCTL_PORT(port));
@@ -574,7 +573,7 @@ static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
                break;
        default:
                pr_err("%s: invalid STP state: %d\n", __func__, state);
-               return -EINVAL;
+               return;
        }
 
        /* Fast-age ARL entries if we are moving a port from Learning or
@@ -584,10 +583,9 @@ static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
        if (cur_hw_state != hw_state) {
                if (cur_hw_state >= G_MISTP_LEARN_STATE &&
                    hw_state <= G_MISTP_LISTEN_STATE) {
-                       ret = bcm_sf2_sw_fast_age_port(ds, port);
-                       if (ret) {
+                       if (bcm_sf2_sw_fast_age_port(ds, port)) {
                                pr_err("%s: fast-ageing failed\n", __func__);
-                               return ret;
+                               return;
                        }
                }
        }
@@ -596,8 +594,6 @@ static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
        reg &= ~(G_MISTP_STATE_MASK << G_MISTP_STATE_SHIFT);
        reg |= hw_state;
        core_writel(priv, reg, CORE_G_PCTL_PORT(port));
-
-       return 0;
 }
 
 /* Address Resolution Logic routines */
@@ -1387,7 +1383,7 @@ static struct dsa_switch_driver bcm_sf2_switch_driver = {
        .set_eee                = bcm_sf2_sw_set_eee,
        .port_bridge_join       = bcm_sf2_sw_br_join,
        .port_bridge_leave      = bcm_sf2_sw_br_leave,
-       .port_stp_update        = bcm_sf2_sw_br_set_stp_state,
+       .port_stp_state_set     = bcm_sf2_sw_br_set_stp_state,
        .port_fdb_prepare       = bcm_sf2_sw_fdb_prepare,
        .port_fdb_add           = bcm_sf2_sw_fdb_add,
        .port_fdb_del           = bcm_sf2_sw_fdb_del,
index c0164b9..0e62f3b 100644 (file)
@@ -105,7 +105,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
        .get_regs               = mv88e6xxx_get_regs,
        .port_bridge_join       = mv88e6xxx_port_bridge_join,
        .port_bridge_leave      = mv88e6xxx_port_bridge_leave,
-       .port_stp_update        = mv88e6xxx_port_stp_update,
+       .port_stp_state_set     = mv88e6xxx_port_stp_state_set,
        .port_vlan_filtering    = mv88e6xxx_port_vlan_filtering,
        .port_vlan_prepare      = mv88e6xxx_port_vlan_prepare,
        .port_vlan_add          = mv88e6xxx_port_vlan_add,
index 5f528ab..7f452e4 100644 (file)
@@ -326,7 +326,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
        .get_regs               = mv88e6xxx_get_regs,
        .port_bridge_join       = mv88e6xxx_port_bridge_join,
        .port_bridge_leave      = mv88e6xxx_port_bridge_leave,
-       .port_stp_update        = mv88e6xxx_port_stp_update,
+       .port_stp_state_set     = mv88e6xxx_port_stp_state_set,
        .port_vlan_filtering    = mv88e6xxx_port_vlan_filtering,
        .port_vlan_prepare      = mv88e6xxx_port_vlan_prepare,
        .port_vlan_add          = mv88e6xxx_port_vlan_add,
index 0dda281..53c545c 100644 (file)
@@ -1193,7 +1193,7 @@ static int _mv88e6xxx_port_based_vlan_map(struct dsa_switch *ds, int port)
        return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_BASE_VLAN, reg);
 }
 
-int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
+void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
 {
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
        int stp_state;
@@ -1215,14 +1215,12 @@ int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state)
                break;
        }
 
-       /* mv88e6xxx_port_stp_update may be called with softirqs disabled,
+       /* mv88e6xxx_port_stp_state_set may be called with softirqs disabled,
         * so we can not update the port state directly but need to schedule it.
         */
        ps->ports[port].state = stp_state;
        set_bit(port, ps->port_state_update_mask);
        schedule_work(&ps->bridge_work);
-
-       return 0;
 }
 
 static int _mv88e6xxx_port_pvid(struct dsa_switch *ds, int port, u16 *new,
index 26a424a..4944855 100644 (file)
@@ -497,7 +497,7 @@ int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
 int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
                               struct net_device *bridge);
 void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port);
-int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state);
+void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, u8 state);
 int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
                                  bool vlan_filtering);
 int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
index 6463bb2..2123981 100644 (file)
@@ -299,8 +299,8 @@ struct dsa_switch_driver {
        int     (*port_bridge_join)(struct dsa_switch *ds, int port,
                                    struct net_device *bridge);
        void    (*port_bridge_leave)(struct dsa_switch *ds, int port);
-       int     (*port_stp_update)(struct dsa_switch *ds, int port,
-                                  u8 state);
+       void    (*port_stp_state_set)(struct dsa_switch *ds, int port,
+                                     u8 state);
 
        /*
         * VLAN support
index a575f03..088215c 100644 (file)
@@ -104,8 +104,8 @@ static int dsa_slave_open(struct net_device *dev)
                        goto clear_promisc;
        }
 
-       if (ds->drv->port_stp_update)
-               ds->drv->port_stp_update(ds, p->port, stp_state);
+       if (ds->drv->port_stp_state_set)
+               ds->drv->port_stp_state_set(ds, p->port, stp_state);
 
        if (p->phy)
                phy_start(p->phy);
@@ -147,8 +147,8 @@ static int dsa_slave_close(struct net_device *dev)
        if (ds->drv->port_disable)
                ds->drv->port_disable(ds, p->port, p->phy);
 
-       if (ds->drv->port_stp_update)
-               ds->drv->port_stp_update(ds, p->port, BR_STATE_DISABLED);
+       if (ds->drv->port_stp_state_set)
+               ds->drv->port_stp_state_set(ds, p->port, BR_STATE_DISABLED);
 
        return 0;
 }
@@ -305,16 +305,19 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return -EOPNOTSUPP;
 }
 
-static int dsa_slave_stp_update(struct net_device *dev, u8 state)
+static int dsa_slave_stp_state_set(struct net_device *dev,
+                                  const struct switchdev_attr *attr,
+                                  struct switchdev_trans *trans)
 {
        struct dsa_slave_priv *p = netdev_priv(dev);
        struct dsa_switch *ds = p->parent;
-       int ret = -EOPNOTSUPP;
 
-       if (ds->drv->port_stp_update)
-               ret = ds->drv->port_stp_update(ds, p->port, state);
+       if (switchdev_trans_ph_prepare(trans))
+               return ds->drv->port_stp_state_set ? 0 : -EOPNOTSUPP;
 
-       return ret;
+       ds->drv->port_stp_state_set(ds, p->port, attr->u.stp_state);
+
+       return 0;
 }
 
 static int dsa_slave_vlan_filtering(struct net_device *dev,
@@ -339,17 +342,11 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
                                   const struct switchdev_attr *attr,
                                   struct switchdev_trans *trans)
 {
-       struct dsa_slave_priv *p = netdev_priv(dev);
-       struct dsa_switch *ds = p->parent;
        int ret;
 
        switch (attr->id) {
        case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
-               if (switchdev_trans_ph_prepare(trans))
-                       ret = ds->drv->port_stp_update ? 0 : -EOPNOTSUPP;
-               else
-                       ret = ds->drv->port_stp_update(ds, p->port,
-                                                      attr->u.stp_state);
+               ret = dsa_slave_stp_state_set(dev, attr, trans);
                break;
        case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
                ret = dsa_slave_vlan_filtering(dev, attr, trans);
@@ -468,7 +465,8 @@ static void dsa_slave_bridge_port_leave(struct net_device *dev)
        /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
         * so allow it to be in BR_STATE_FORWARDING to be kept functional
         */
-       dsa_slave_stp_update(dev, BR_STATE_FORWARDING);
+       if (ds->drv->port_stp_state_set)
+               ds->drv->port_stp_state_set(ds, p->port, BR_STATE_FORWARDING);
 }
 
 static int dsa_slave_port_attr_get(struct net_device *dev,