mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 16:20:55 +07:00
net: dsa: add switch mdb bitmap functions
This patch brings no functional changes. It moves out the MDB code iterating on a multicast group into new dsa_switch_mdb_{prepare,add}_bitmap() functions. This gives us a better isolation of the two switchdev phases. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
9c428c593f
commit
e6db98db8a
@ -108,13 +108,42 @@ static int dsa_switch_fdb_del(struct dsa_switch *ds,
|
|||||||
info->vid);
|
info->vid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dsa_switch_mdb_prepare_bitmap(struct dsa_switch *ds,
|
||||||
|
const struct switchdev_obj_port_mdb *mdb,
|
||||||
|
const unsigned long *bitmap)
|
||||||
|
{
|
||||||
|
int port, err;
|
||||||
|
|
||||||
|
if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
for_each_set_bit(port, bitmap, ds->num_ports) {
|
||||||
|
err = ds->ops->port_mdb_prepare(ds, port, mdb);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dsa_switch_mdb_add_bitmap(struct dsa_switch *ds,
|
||||||
|
const struct switchdev_obj_port_mdb *mdb,
|
||||||
|
const unsigned long *bitmap)
|
||||||
|
{
|
||||||
|
int port;
|
||||||
|
|
||||||
|
for_each_set_bit(port, bitmap, ds->num_ports)
|
||||||
|
ds->ops->port_mdb_add(ds, port, mdb);
|
||||||
|
}
|
||||||
|
|
||||||
static int dsa_switch_mdb_add(struct dsa_switch *ds,
|
static int dsa_switch_mdb_add(struct dsa_switch *ds,
|
||||||
struct dsa_notifier_mdb_info *info)
|
struct dsa_notifier_mdb_info *info)
|
||||||
{
|
{
|
||||||
const struct switchdev_obj_port_mdb *mdb = info->mdb;
|
const struct switchdev_obj_port_mdb *mdb = info->mdb;
|
||||||
struct switchdev_trans *trans = info->trans;
|
struct switchdev_trans *trans = info->trans;
|
||||||
DECLARE_BITMAP(group, ds->num_ports);
|
DECLARE_BITMAP(group, ds->num_ports);
|
||||||
int port, err;
|
int port;
|
||||||
|
|
||||||
/* Build a mask of Multicast group members */
|
/* Build a mask of Multicast group members */
|
||||||
bitmap_zero(group, ds->num_ports);
|
bitmap_zero(group, ds->num_ports);
|
||||||
@ -124,21 +153,10 @@ static int dsa_switch_mdb_add(struct dsa_switch *ds,
|
|||||||
if (dsa_is_dsa_port(ds, port))
|
if (dsa_is_dsa_port(ds, port))
|
||||||
set_bit(port, group);
|
set_bit(port, group);
|
||||||
|
|
||||||
if (switchdev_trans_ph_prepare(trans)) {
|
if (switchdev_trans_ph_prepare(trans))
|
||||||
if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add)
|
return dsa_switch_mdb_prepare_bitmap(ds, mdb, group);
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
for_each_set_bit(port, group, ds->num_ports) {
|
dsa_switch_mdb_add_bitmap(ds, mdb, group);
|
||||||
err = ds->ops->port_mdb_prepare(ds, port, mdb);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_set_bit(port, group, ds->num_ports)
|
|
||||||
ds->ops->port_mdb_add(ds, port, mdb);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user