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

Commit 1b6dd556 authored by Arkadi Sharshevsky's avatar Arkadi Sharshevsky Committed by David S. Miller
Browse files

net: dsa: Remove prepare phase for FDB



The prepare phase for FDB add is unneeded because most of DSA devices
can have failures during bus transactions (SPI, I2C, etc.), thus, the
prepare phase cannot guarantee success of the commit stage.

The support for learning FDB through notification chain, which will be
introduced in the following patches, will provide the ability to notify
back the bridge about successful offload.

Signed-off-by: default avatarArkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-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 6c2c1dcb
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -1213,7 +1213,7 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
	return b53_arl_rw_op(dev, 0);
}

int b53_fdb_prepare(struct dsa_switch *ds, int port,
int b53_fdb_add(struct dsa_switch *ds, int port,
		const unsigned char *addr, u16 vid)
{
	struct b53_device *priv = ds->priv;
@@ -1224,17 +1224,7 @@ int b53_fdb_prepare(struct dsa_switch *ds, int port,
	if (is5325(priv) || is5365(priv))
		return -EOPNOTSUPP;

	return 0;
}
EXPORT_SYMBOL(b53_fdb_prepare);

void b53_fdb_add(struct dsa_switch *ds, int port,
		 const unsigned char *addr, u16 vid)
{
	struct b53_device *priv = ds->priv;

	if (b53_arl_op(priv, 0, port, addr, vid, true))
		pr_err("%s: failed to add MAC address\n", __func__);
	return b53_arl_op(priv, 0, port, addr, vid, true);
}
EXPORT_SYMBOL(b53_fdb_add);

@@ -1563,7 +1553,6 @@ static const struct dsa_switch_ops b53_switch_ops = {
	.port_vlan_add		= b53_vlan_add,
	.port_vlan_del		= b53_vlan_del,
	.port_vlan_dump		= b53_vlan_dump,
	.port_fdb_prepare	= b53_fdb_prepare,
	.port_fdb_dump		= b53_fdb_dump,
	.port_fdb_add		= b53_fdb_add,
	.port_fdb_del		= b53_fdb_del,
+2 −4
Original line number Diff line number Diff line
@@ -396,9 +396,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
int b53_vlan_dump(struct dsa_switch *ds, int port,
		  struct switchdev_obj_port_vlan *vlan,
		  switchdev_obj_dump_cb_t *cb);
int b53_fdb_prepare(struct dsa_switch *ds, int port,
		    const unsigned char *addr, u16 vid);
void b53_fdb_add(struct dsa_switch *ds, int port,
int b53_fdb_add(struct dsa_switch *ds, int port,
		const unsigned char *addr, u16 vid);
int b53_fdb_del(struct dsa_switch *ds, int port,
		const unsigned char *addr, u16 vid);
+0 −1
Original line number Diff line number Diff line
@@ -1022,7 +1022,6 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
	.port_vlan_add		= b53_vlan_add,
	.port_vlan_del		= b53_vlan_del,
	.port_vlan_dump		= b53_vlan_dump,
	.port_fdb_prepare	= b53_fdb_prepare,
	.port_fdb_dump		= b53_fdb_dump,
	.port_fdb_add		= b53_fdb_add,
	.port_fdb_del		= b53_fdb_del,
+10 −14
Original line number Diff line number Diff line
@@ -678,14 +678,6 @@ static int ksz_port_vlan_dump(struct dsa_switch *ds, int port,
	return err;
}

static int ksz_port_fdb_prepare(struct dsa_switch *ds, int port,
				const unsigned char *addr, u16 vid)
{
	/* nothing needed */

	return 0;
}

struct alu_struct {
	/* entry 1 */
	u8	is_static:1;
@@ -705,12 +697,13 @@ struct alu_struct {
	u8	mac[ETH_ALEN];
};

static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
static int ksz_port_fdb_add(struct dsa_switch *ds, int port,
			    const unsigned char *addr, u16 vid)
{
	struct ksz_device *dev = ds->priv;
	u32 alu_table[4];
	u32 data;
	int ret = 0;

	mutex_lock(&dev->alu_mutex);

@@ -727,7 +720,8 @@ static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
	ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);

	/* wait to be finished */
	if (wait_alu_ready(dev, ALU_START, 1000) < 0) {
	ret = wait_alu_ready(dev, ALU_START, 1000);
	if (ret < 0) {
		dev_dbg(dev->dev, "Failed to read ALU\n");
		goto exit;
	}
@@ -750,11 +744,14 @@ static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
	ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);

	/* wait to be finished */
	if (wait_alu_ready(dev, ALU_START, 1000) < 0)
		dev_dbg(dev->dev, "Failed to read ALU\n");
	ret = wait_alu_ready(dev, ALU_START, 1000);
	if (ret < 0)
		dev_dbg(dev->dev, "Failed to write ALU\n");

exit:
	mutex_unlock(&dev->alu_mutex);

	return ret;
}

static int ksz_port_fdb_del(struct dsa_switch *ds, int port,
@@ -1128,7 +1125,6 @@ static const struct dsa_switch_ops ksz_switch_ops = {
	.port_vlan_add		= ksz_port_vlan_add,
	.port_vlan_del		= ksz_port_vlan_del,
	.port_vlan_dump		= ksz_port_vlan_dump,
	.port_fdb_prepare	= ksz_port_fdb_prepare,
	.port_fdb_dump		= ksz_port_fdb_dump,
	.port_fdb_add		= ksz_port_fdb_add,
	.port_fdb_del		= ksz_port_fdb_del,
+4 −21
Original line number Diff line number Diff line
@@ -801,37 +801,21 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
}

static int
mt7530_port_fdb_prepare(struct dsa_switch *ds, int port,
mt7530_port_fdb_add(struct dsa_switch *ds, int port,
		    const unsigned char *addr, u16 vid)
{
	struct mt7530_priv *priv = ds->priv;
	int ret;
	u8 port_mask = BIT(port);

	/* Because auto-learned entrie shares the same FDB table.
	 * an entry is reserved with no port_mask to make sure fdb_add
	 * is called while the entry is still available.
	 */
	mutex_lock(&priv->reg_mutex);
	mt7530_fdb_write(priv, vid, 0, addr, -1, STATIC_ENT);
	mt7530_fdb_write(priv, vid, port_mask, addr, -1, STATIC_ENT);
	ret = mt7530_fdb_cmd(priv, MT7530_FDB_WRITE, 0);
	mutex_unlock(&priv->reg_mutex);

	return ret;
}

static void
mt7530_port_fdb_add(struct dsa_switch *ds, int port,
		    const unsigned char *addr, u16 vid)
{
	struct mt7530_priv *priv = ds->priv;
	u8 port_mask = BIT(port);

	mutex_lock(&priv->reg_mutex);
	mt7530_fdb_write(priv, vid, port_mask, addr, -1, STATIC_ENT);
	mt7530_fdb_cmd(priv, MT7530_FDB_WRITE, 0);
	mutex_unlock(&priv->reg_mutex);
}

static int
mt7530_port_fdb_del(struct dsa_switch *ds, int port,
		    const unsigned char *addr, u16 vid)
@@ -1013,7 +997,6 @@ static struct dsa_switch_ops mt7530_switch_ops = {
	.port_stp_state_set	= mt7530_stp_state_set,
	.port_bridge_join	= mt7530_port_bridge_join,
	.port_bridge_leave	= mt7530_port_bridge_leave,
	.port_fdb_prepare	= mt7530_port_fdb_prepare,
	.port_fdb_add		= mt7530_port_fdb_add,
	.port_fdb_del		= mt7530_port_fdb_del,
	.port_fdb_dump		= mt7530_port_fdb_dump,
Loading