Skip to content

Commit a1a6b7e

Browse files
viviendavem330
authored andcommitted
net: dsa: add cross-chip multicast support
Similarly to how cross-chip VLAN works, define a bitmap of multicast group members for a switch, now including its DSA ports, so that multicast traffic can be sent to all switches of the fabric. A switch may drop the frames if no user port is a member. This brings support for multicast in a multi-chip environment. As of now, all switches of the fabric must support the multicast operations in order to program a single fabric port. Reported-by: Jason Cobham <jcobham@questertangent.com> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Tested-by: Jason Cobham <jcobham@questertangent.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6a2fb0e commit a1a6b7e

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

‎net/dsa/switch.c‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,30 @@ static int dsa_switch_mdb_add(struct dsa_switch *ds,
122122
{
123123
const struct switchdev_obj_port_mdb *mdb = info->mdb;
124124
struct switchdev_trans *trans = info->trans;
125+
DECLARE_BITMAP(group, ds->num_ports);
126+
int port, err;
125127

126-
/* Do not care yet about other switch chips of the fabric */
127-
if (ds->index != info->sw_index)
128-
return 0;
128+
/* Build a mask of Multicast group members */
129+
bitmap_zero(group, ds->num_ports);
130+
if (ds->index == info->sw_index)
131+
set_bit(info->port, group);
132+
for (port = 0; port < ds->num_ports; port++)
133+
if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
134+
set_bit(port, group);
129135

130136
if (switchdev_trans_ph_prepare(trans)) {
131137
if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add)
132138
return -EOPNOTSUPP;
133139

134-
return ds->ops->port_mdb_prepare(ds, info->port, mdb, trans);
140+
for_each_set_bit(port, group, ds->num_ports) {
141+
err = ds->ops->port_mdb_prepare(ds, port, mdb, trans);
142+
if (err)
143+
return err;
144+
}
135145
}
136146

137-
ds->ops->port_mdb_add(ds, info->port, mdb, trans);
147+
for_each_set_bit(port, group, ds->num_ports)
148+
ds->ops->port_mdb_add(ds, port, mdb, trans);
138149

139150
return 0;
140151
}
@@ -144,14 +155,13 @@ static int dsa_switch_mdb_del(struct dsa_switch *ds,
144155
{
145156
const struct switchdev_obj_port_mdb *mdb = info->mdb;
146157

147-
/* Do not care yet about other switch chips of the fabric */
148-
if (ds->index != info->sw_index)
149-
return 0;
150-
151158
if (!ds->ops->port_mdb_del)
152159
return -EOPNOTSUPP;
153160

154-
return ds->ops->port_mdb_del(ds, info->port, mdb);
161+
if (ds->index == info->sw_index)
162+
return ds->ops->port_mdb_del(ds, info->port, mdb);
163+
164+
return 0;
155165
}
156166

157167
static int dsa_switch_vlan_add(struct dsa_switch *ds,

0 commit comments

Comments
 (0)