switch.c (e77bc7dc9af0ec53996367b2053dfafee83b7edb) switch.c (ffb68fc58e9640762be891f9aebe4f5aac615ab3)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Handling of a single switch chip, part of a switch fabric
4 *
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 */
8

--- 176 unchanged lines hidden (view full) ---

185 return true;
186
187 if (dsa_is_dsa_port(ds, port))
188 return true;
189
190 return false;
191}
192
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Handling of a single switch chip, part of a switch fabric
4 *
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
7 */
8

--- 176 unchanged lines hidden (view full) ---

185 return true;
186
187 if (dsa_is_dsa_port(ds, port))
188 return true;
189
190 return false;
191}
192
193static int dsa_switch_mdb_prepare(struct dsa_switch *ds,
194 struct dsa_notifier_mdb_info *info)
193static int dsa_switch_mdb_add(struct dsa_switch *ds,
194 struct dsa_notifier_mdb_info *info)
195{
196 int port, err;
197
198 if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add)
199 return -EOPNOTSUPP;
200
201 for (port = 0; port < ds->num_ports; port++) {
202 if (dsa_switch_mdb_match(ds, port, info)) {
203 err = ds->ops->port_mdb_prepare(ds, port, info->mdb);
204 if (err)
205 return err;
206 }
207 }
208
195{
196 int port, err;
197
198 if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add)
199 return -EOPNOTSUPP;
200
201 for (port = 0; port < ds->num_ports; port++) {
202 if (dsa_switch_mdb_match(ds, port, info)) {
203 err = ds->ops->port_mdb_prepare(ds, port, info->mdb);
204 if (err)
205 return err;
206 }
207 }
208
209 return 0;
210}
211
212static int dsa_switch_mdb_add(struct dsa_switch *ds,
213 struct dsa_notifier_mdb_info *info)
214{
215 int port;
216
217 if (switchdev_trans_ph_prepare(info->trans))
218 return dsa_switch_mdb_prepare(ds, info);
219
220 if (!ds->ops->port_mdb_add)
221 return 0;
222
223 for (port = 0; port < ds->num_ports; port++)
224 if (dsa_switch_mdb_match(ds, port, info))
225 ds->ops->port_mdb_add(ds, port, info->mdb);
226
227 return 0;
228}
229
230static int dsa_switch_mdb_del(struct dsa_switch *ds,

--- 15 unchanged lines hidden (view full) ---

246 return true;
247
248 if (dsa_is_dsa_port(ds, port))
249 return true;
250
251 return false;
252}
253
209 for (port = 0; port < ds->num_ports; port++)
210 if (dsa_switch_mdb_match(ds, port, info))
211 ds->ops->port_mdb_add(ds, port, info->mdb);
212
213 return 0;
214}
215
216static int dsa_switch_mdb_del(struct dsa_switch *ds,

--- 15 unchanged lines hidden (view full) ---

232 return true;
233
234 if (dsa_is_dsa_port(ds, port))
235 return true;
236
237 return false;
238}
239
254static int dsa_switch_vlan_prepare(struct dsa_switch *ds,
255 struct dsa_notifier_vlan_info *info)
240static int dsa_switch_vlan_add(struct dsa_switch *ds,
241 struct dsa_notifier_vlan_info *info)
256{
257 int port, err;
258
259 if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
260 return -EOPNOTSUPP;
261
262 for (port = 0; port < ds->num_ports; port++) {
263 if (dsa_switch_vlan_match(ds, port, info)) {
264 err = ds->ops->port_vlan_prepare(ds, port, info->vlan);
265 if (err)
266 return err;
267 }
268 }
269
242{
243 int port, err;
244
245 if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
246 return -EOPNOTSUPP;
247
248 for (port = 0; port < ds->num_ports; port++) {
249 if (dsa_switch_vlan_match(ds, port, info)) {
250 err = ds->ops->port_vlan_prepare(ds, port, info->vlan);
251 if (err)
252 return err;
253 }
254 }
255
270 return 0;
271}
272
273static int dsa_switch_vlan_add(struct dsa_switch *ds,
274 struct dsa_notifier_vlan_info *info)
275{
276 int port;
277
278 if (switchdev_trans_ph_prepare(info->trans))
279 return dsa_switch_vlan_prepare(ds, info);
280
281 if (!ds->ops->port_vlan_add)
282 return 0;
283
284 for (port = 0; port < ds->num_ports; port++)
285 if (dsa_switch_vlan_match(ds, port, info))
286 ds->ops->port_vlan_add(ds, port, info->vlan);
287
288 return 0;
289}
290
291static int dsa_switch_vlan_del(struct dsa_switch *ds,

--- 82 unchanged lines hidden ---
256 for (port = 0; port < ds->num_ports; port++)
257 if (dsa_switch_vlan_match(ds, port, info))
258 ds->ops->port_vlan_add(ds, port, info->vlan);
259
260 return 0;
261}
262
263static int dsa_switch_vlan_del(struct dsa_switch *ds,

--- 82 unchanged lines hidden ---