diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-06-15 16:14:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-16 15:21:14 -0400 |
commit | a1a6b7ea7f2de270a51360cc48e7c49f7a283dda (patch) | |
tree | 973f9656be62d80eccb274d6074ddd2438ae9433 /net/dsa/switch.c | |
parent | 6a2fb0e99f9cab349dce0a36862b0cd370036452 (diff) |
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>
Diffstat (limited to 'net/dsa/switch.c')
-rw-r--r-- | net/dsa/switch.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/net/dsa/switch.c b/net/dsa/switch.c index f1029a8d0e20..97e2e9c8cf3f 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c | |||
@@ -122,19 +122,30 @@ static int dsa_switch_mdb_add(struct dsa_switch *ds, | |||
122 | { | 122 | { |
123 | const struct switchdev_obj_port_mdb *mdb = info->mdb; | 123 | const struct switchdev_obj_port_mdb *mdb = info->mdb; |
124 | struct switchdev_trans *trans = info->trans; | 124 | struct switchdev_trans *trans = info->trans; |
125 | DECLARE_BITMAP(group, ds->num_ports); | ||
126 | int port, err; | ||
125 | 127 | ||
126 | /* Do not care yet about other switch chips of the fabric */ | 128 | /* Build a mask of Multicast group members */ |
127 | if (ds->index != info->sw_index) | 129 | bitmap_zero(group, ds->num_ports); |
128 | return 0; | 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); | ||
129 | 135 | ||
130 | if (switchdev_trans_ph_prepare(trans)) { | 136 | if (switchdev_trans_ph_prepare(trans)) { |
131 | if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add) | 137 | if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add) |
132 | return -EOPNOTSUPP; | 138 | return -EOPNOTSUPP; |
133 | 139 | ||
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 | } | ||
135 | } | 145 | } |
136 | 146 | ||
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); | ||
138 | 149 | ||
139 | return 0; | 150 | return 0; |
140 | } | 151 | } |
@@ -144,14 +155,13 @@ static int dsa_switch_mdb_del(struct dsa_switch *ds, | |||
144 | { | 155 | { |
145 | const struct switchdev_obj_port_mdb *mdb = info->mdb; | 156 | const struct switchdev_obj_port_mdb *mdb = info->mdb; |
146 | 157 | ||
147 | /* Do not care yet about other switch chips of the fabric */ | ||
148 | if (ds->index != info->sw_index) | ||
149 | return 0; | ||
150 | |||
151 | if (!ds->ops->port_mdb_del) | 158 | if (!ds->ops->port_mdb_del) |
152 | return -EOPNOTSUPP; | 159 | return -EOPNOTSUPP; |
153 | 160 | ||
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; | ||
155 | } | 165 | } |
156 | 166 | ||
157 | static int dsa_switch_vlan_add(struct dsa_switch *ds, | 167 | static int dsa_switch_vlan_add(struct dsa_switch *ds, |