Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e013b778 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'dsa-voidify-ops'



Vivien Didelot says:

====================
net: dsa: voidify STP setter and FDB/VLAN add ops

Neither the DSA layer nor the bridge code (see br_set_state) really care
about eventual errors from STP state setters, so make it void.

The DSA layer separates the prepare and commit phases of switchdev in
two different functions. Logical errors must not happen in commit
routines, so make them void.

Changes v1 -> v2:
  - rename port_stp_update to port_stp_state_set
  - don't change code flow of bcm_sf2_sw_br_set_stp_state
  - prefer netdev_err over netdev_warn
====================

Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f453939c 4d5770b3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+11 −14
Original line number Diff line number Diff line
@@ -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,
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 */
@@ -728,13 +724,14 @@ static int bcm_sf2_sw_fdb_prepare(struct dsa_switch *ds, int port,
	return 0;
}

static int bcm_sf2_sw_fdb_add(struct dsa_switch *ds, int port,
static void bcm_sf2_sw_fdb_add(struct dsa_switch *ds, int port,
			       const struct switchdev_obj_port_fdb *fdb,
			       struct switchdev_trans *trans)
{
	struct bcm_sf2_priv *priv = ds_to_priv(ds);

	return bcm_sf2_arl_op(priv, 0, port, fdb->addr, fdb->vid, true);
	if (bcm_sf2_arl_op(priv, 0, port, fdb->addr, fdb->vid, true))
		pr_err("%s: failed to add MAC address\n", __func__);
}

static int bcm_sf2_sw_fdb_del(struct dsa_switch *ds, int port,
@@ -1387,7 +1384,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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
+18 −26
Original line number Diff line number Diff line
@@ -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,
@@ -1910,7 +1908,7 @@ static int _mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, u16 vid,
	return _mv88e6xxx_vtu_loadpurge(ds, &vlan);
}

int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
			     const struct switchdev_obj_port_vlan *vlan,
			     struct switchdev_trans *trans)
{
@@ -1918,23 +1916,19 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
	bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
	bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
	u16 vid;
	int err = 0;

	mutex_lock(&ps->smi_mutex);

	for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
		err = _mv88e6xxx_port_vlan_add(ds, port, vid, untagged);
		if (err)
			goto unlock;
	}
	for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
		if (_mv88e6xxx_port_vlan_add(ds, port, vid, untagged))
			netdev_err(ds->ports[port], "failed to add VLAN %d%c\n",
				   vid, untagged ? 'u' : 't');

	/* no PVID with ranges, otherwise it's a bug */
	if (pvid)
		err = _mv88e6xxx_port_pvid_set(ds, port, vlan->vid_end);
unlock:
	mutex_unlock(&ps->smi_mutex);
	if (pvid && _mv88e6xxx_port_pvid_set(ds, port, vlan->vid_end))
		netdev_err(ds->ports[port], "failed to set PVID %d\n",
			   vlan->vid_end);

	return err;
	mutex_unlock(&ps->smi_mutex);
}

static int _mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
@@ -2092,7 +2086,7 @@ int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
	return 0;
}

int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
			    const struct switchdev_obj_port_fdb *fdb,
			    struct switchdev_trans *trans)
{
@@ -2100,13 +2094,11 @@ int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
		GLOBAL_ATU_DATA_STATE_MC_STATIC :
		GLOBAL_ATU_DATA_STATE_UC_STATIC;
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret;

	mutex_lock(&ps->smi_mutex);
	ret = _mv88e6xxx_port_fdb_load(ds, port, fdb->addr, fdb->vid, state);
	if (_mv88e6xxx_port_fdb_load(ds, port, fdb->addr, fdb->vid, state))
		netdev_err(ds->ports[port], "failed to load MAC address\n");
	mutex_unlock(&ps->smi_mutex);

	return ret;
}

int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Loading