Commit a52b2da7 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Jakub Kicinski
Browse files

net: dsa: remove the transactional logic from MDB entries



For many drivers, the .port_mdb_prepare callback was not a good opportunity
to avoid any error condition, and they would suppress errors found during
the actual commit phase.

Where a logical separation between the prepare and the commit phase
existed, the function that used to implement the .port_mdb_prepare
callback still exists, but now it is called directly from .port_mdb_add,
which was modified to return an int code.

Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek
Reviewed-by: Linus Wallei <linus.walleij@linaro.org> # RTL8366
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 77b61365
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -1741,7 +1741,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
}
EXPORT_SYMBOL(b53_fdb_dump);

int b53_mdb_prepare(struct dsa_switch *ds, int port,
int b53_mdb_add(struct dsa_switch *ds, int port,
		const struct switchdev_obj_port_mdb *mdb)
{
	struct b53_device *priv = ds->priv;
@@ -1752,19 +1752,7 @@ int b53_mdb_prepare(struct dsa_switch *ds, int port,
	if (is5325(priv) || is5365(priv))
		return -EOPNOTSUPP;

	return 0;
}
EXPORT_SYMBOL(b53_mdb_prepare);

void b53_mdb_add(struct dsa_switch *ds, int port,
		 const struct switchdev_obj_port_mdb *mdb)
{
	struct b53_device *priv = ds->priv;
	int ret;

	ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, true);
	if (ret)
		dev_err(ds->dev, "failed to add MDB entry\n");
	return b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, true);
}
EXPORT_SYMBOL(b53_mdb_add);

@@ -2205,7 +2193,6 @@ static const struct dsa_switch_ops b53_switch_ops = {
	.port_fdb_del		= b53_fdb_del,
	.port_mirror_add	= b53_mirror_add,
	.port_mirror_del	= b53_mirror_del,
	.port_mdb_prepare	= b53_mdb_prepare,
	.port_mdb_add		= b53_mdb_add,
	.port_mdb_del		= b53_mdb_del,
	.port_max_mtu		= b53_get_max_mtu,
+2 −4
Original line number Diff line number Diff line
@@ -361,9 +361,7 @@ int b53_fdb_del(struct dsa_switch *ds, int port,
		const unsigned char *addr, u16 vid);
int b53_fdb_dump(struct dsa_switch *ds, int port,
		 dsa_fdb_dump_cb_t *cb, void *data);
int b53_mdb_prepare(struct dsa_switch *ds, int port,
		    const struct switchdev_obj_port_mdb *mdb);
void b53_mdb_add(struct dsa_switch *ds, int port,
int b53_mdb_add(struct dsa_switch *ds, int port,
		const struct switchdev_obj_port_mdb *mdb);
int b53_mdb_del(struct dsa_switch *ds, int port,
		const struct switchdev_obj_port_mdb *mdb);
+0 −1
Original line number Diff line number Diff line
@@ -1126,7 +1126,6 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
	.set_rxnfc		= bcm_sf2_set_rxnfc,
	.port_mirror_add	= b53_mirror_add,
	.port_mirror_del	= b53_mirror_del,
	.port_mdb_prepare	= b53_mdb_prepare,
	.port_mdb_add		= b53_mdb_add,
	.port_mdb_del		= b53_mdb_del,
};
+8 −4
Original line number Diff line number Diff line
@@ -1232,14 +1232,19 @@ static int lan9303_port_mdb_prepare(struct dsa_switch *ds, int port,
	return 0;
}

static void lan9303_port_mdb_add(struct dsa_switch *ds, int port,
static int lan9303_port_mdb_add(struct dsa_switch *ds, int port,
				const struct switchdev_obj_port_mdb *mdb)
{
	struct lan9303 *chip = ds->priv;
	int err;

	err = lan9303_port_mdb_prepare(ds, port, mdb);
	if (err)
		return err;

	dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, mdb->addr,
		mdb->vid);
	lan9303_alr_add_port(chip, mdb->addr, port, false);
	return lan9303_alr_add_port(chip, mdb->addr, port, false);
}

static int lan9303_port_mdb_del(struct dsa_switch *ds, int port,
@@ -1274,7 +1279,6 @@ static const struct dsa_switch_ops lan9303_switch_ops = {
	.port_fdb_add           = lan9303_port_fdb_add,
	.port_fdb_del           = lan9303_port_fdb_del,
	.port_fdb_dump          = lan9303_port_fdb_dump,
	.port_mdb_prepare       = lan9303_port_mdb_prepare,
	.port_mdb_add           = lan9303_port_mdb_add,
	.port_mdb_del           = lan9303_port_mdb_del,
};
+0 −1
Original line number Diff line number Diff line
@@ -1114,7 +1114,6 @@ static const struct dsa_switch_ops ksz8795_switch_ops = {
	.port_vlan_add		= ksz8795_port_vlan_add,
	.port_vlan_del		= ksz8795_port_vlan_del,
	.port_fdb_dump		= ksz_port_fdb_dump,
	.port_mdb_prepare       = ksz_port_mdb_prepare,
	.port_mdb_add           = ksz_port_mdb_add,
	.port_mdb_del           = ksz_port_mdb_del,
	.port_mirror_add	= ksz8795_port_mirror_add,
Loading