blob: 8b601ced6b45fb56bd157772ebfa314467c48450 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Vivien Didelotf515f192017-02-03 13:20:20 -05002/*
3 * Handling of a single switch chip, part of a switch fabric
4 *
Vivien Didelot4333d612017-03-28 15:10:36 -04005 * Copyright (c) 2017 Savoir-faire Linux Inc.
6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Vivien Didelotf515f192017-02-03 13:20:20 -05007 */
8
Vladimir Olteand371b7c2019-04-28 21:45:46 +03009#include <linux/if_bridge.h>
Vivien Didelotf515f192017-02-03 13:20:20 -050010#include <linux/netdevice.h>
11#include <linux/notifier.h>
Florian Fainelli061f6a52019-02-20 14:35:39 -080012#include <linux/if_vlan.h>
Vivien Didelot1faabf72017-05-19 17:00:52 -040013#include <net/switchdev.h>
Vivien Didelotea5dd342017-05-17 15:46:03 -040014
15#include "dsa_priv.h"
Vivien Didelotf515f192017-02-03 13:20:20 -050016
Vivien Didelot1faabf72017-05-19 17:00:52 -040017static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds,
18 unsigned int ageing_time)
19{
20 int i;
21
22 for (i = 0; i < ds->num_ports; ++i) {
Vivien Didelot68bb8ea2019-10-21 16:51:15 -040023 struct dsa_port *dp = dsa_to_port(ds, i);
Vivien Didelot1faabf72017-05-19 17:00:52 -040024
25 if (dp->ageing_time && dp->ageing_time < ageing_time)
26 ageing_time = dp->ageing_time;
27 }
28
29 return ageing_time;
30}
31
32static int dsa_switch_ageing_time(struct dsa_switch *ds,
33 struct dsa_notifier_ageing_time_info *info)
34{
35 unsigned int ageing_time = info->ageing_time;
Vivien Didelot1faabf72017-05-19 17:00:52 -040036
Vladimir Oltean77b61362021-01-09 02:01:51 +020037 if (ds->ageing_time_min && ageing_time < ds->ageing_time_min)
38 return -ERANGE;
39
40 if (ds->ageing_time_max && ageing_time > ds->ageing_time_max)
41 return -ERANGE;
Vivien Didelot1faabf72017-05-19 17:00:52 -040042
43 /* Program the fastest ageing time in case of multiple bridges */
44 ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time);
45
46 if (ds->ops->set_ageing_time)
47 return ds->ops->set_ageing_time(ds, ageing_time);
48
49 return 0;
50}
51
Vladimir Olteanbfcb8132020-03-27 21:55:42 +020052static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port,
53 struct dsa_notifier_mtu_info *info)
54{
55 if (ds->index == info->sw_index)
56 return (port == info->port) || dsa_is_dsa_port(ds, port);
57
58 if (!info->propagate_upstream)
59 return false;
60
61 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
62 return true;
63
64 return false;
65}
66
67static int dsa_switch_mtu(struct dsa_switch *ds,
68 struct dsa_notifier_mtu_info *info)
69{
70 int port, ret;
71
72 if (!ds->ops->port_change_mtu)
73 return -EOPNOTSUPP;
74
75 for (port = 0; port < ds->num_ports; port++) {
76 if (dsa_switch_mtu_match(ds, port, info)) {
77 ret = ds->ops->port_change_mtu(ds, port, info->mtu);
78 if (ret)
79 return ret;
80 }
81 }
82
83 return 0;
84}
85
Vivien Didelot04d3a4c2017-02-03 13:20:21 -050086static int dsa_switch_bridge_join(struct dsa_switch *ds,
87 struct dsa_notifier_bridge_info *info)
88{
Vladimir Olteanf66a6a62020-05-10 19:37:41 +030089 struct dsa_switch_tree *dst = ds->dst;
90
91 if (dst->index == info->tree_index && ds->index == info->sw_index &&
92 ds->ops->port_bridge_join)
Vivien Didelot04d3a4c2017-02-03 13:20:21 -050093 return ds->ops->port_bridge_join(ds, info->port, info->br);
94
Vladimir Olteanf66a6a62020-05-10 19:37:41 +030095 if ((dst->index != info->tree_index || ds->index != info->sw_index) &&
96 ds->ops->crosschip_bridge_join)
97 return ds->ops->crosschip_bridge_join(ds, info->tree_index,
98 info->sw_index,
Vivien Didelot40ef2c92017-03-30 17:37:14 -040099 info->port, info->br);
Vivien Didelot04d3a4c2017-02-03 13:20:21 -0500100
101 return 0;
102}
103
104static int dsa_switch_bridge_leave(struct dsa_switch *ds,
105 struct dsa_notifier_bridge_info *info)
106{
Vladimir Olteand371b7c2019-04-28 21:45:46 +0300107 bool unset_vlan_filtering = br_vlan_enabled(info->br);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +0300108 struct dsa_switch_tree *dst = ds->dst;
Vladimir Oltean89153ed2021-02-13 22:43:19 +0200109 struct netlink_ext_ack extack = {0};
Vladimir Oltean479dc492021-03-24 11:56:39 +0200110 int err, port;
Vladimir Olteand371b7c2019-04-28 21:45:46 +0300111
Vladimir Olteanf66a6a62020-05-10 19:37:41 +0300112 if (dst->index == info->tree_index && ds->index == info->sw_index &&
113 ds->ops->port_bridge_join)
Vivien Didelot04d3a4c2017-02-03 13:20:21 -0500114 ds->ops->port_bridge_leave(ds, info->port, info->br);
115
Vladimir Olteanf66a6a62020-05-10 19:37:41 +0300116 if ((dst->index != info->tree_index || ds->index != info->sw_index) &&
117 ds->ops->crosschip_bridge_join)
118 ds->ops->crosschip_bridge_leave(ds, info->tree_index,
119 info->sw_index, info->port,
Vivien Didelot40ef2c92017-03-30 17:37:14 -0400120 info->br);
Vivien Didelot04d3a4c2017-02-03 13:20:21 -0500121
Vladimir Olteand371b7c2019-04-28 21:45:46 +0300122 /* If the bridge was vlan_filtering, the bridge core doesn't trigger an
123 * event for changing vlan_filtering setting upon slave ports leaving
124 * it. That is a good thing, because that lets us handle it and also
125 * handle the case where the switch's vlan_filtering setting is global
126 * (not per port). When that happens, the correct moment to trigger the
Vladimir Oltean479dc492021-03-24 11:56:39 +0200127 * vlan_filtering callback is only when the last port leaves the last
128 * VLAN-aware bridge.
Vladimir Olteand371b7c2019-04-28 21:45:46 +0300129 */
130 if (unset_vlan_filtering && ds->vlan_filtering_is_global) {
Vladimir Oltean479dc492021-03-24 11:56:39 +0200131 for (port = 0; port < ds->num_ports; port++) {
132 struct net_device *bridge_dev;
133
134 bridge_dev = dsa_to_port(ds, port)->bridge_dev;
135
136 if (bridge_dev && br_vlan_enabled(bridge_dev)) {
Vladimir Olteand371b7c2019-04-28 21:45:46 +0300137 unset_vlan_filtering = false;
138 break;
139 }
140 }
141 }
142 if (unset_vlan_filtering) {
Vladimir Oltean2e554a72020-10-03 01:06:46 +0300143 err = dsa_port_vlan_filtering(dsa_to_port(ds, info->port),
Vladimir Oltean89153ed2021-02-13 22:43:19 +0200144 false, &extack);
145 if (extack._msg)
146 dev_err(ds->dev, "port %d: %s\n", info->port,
147 extack._msg);
Vladimir Olteand371b7c2019-04-28 21:45:46 +0300148 if (err && err != EOPNOTSUPP)
149 return err;
150 }
Vivien Didelot04d3a4c2017-02-03 13:20:21 -0500151 return 0;
152}
153
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400154static int dsa_switch_fdb_add(struct dsa_switch *ds,
155 struct dsa_notifier_fdb_info *info)
156{
Vivien Didelot31692412017-11-30 12:56:43 -0500157 int port = dsa_towards_port(ds, info->sw_index, info->port);
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400158
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +0300159 if (!ds->ops->port_fdb_add)
160 return -EOPNOTSUPP;
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400161
Vivien Didelot31692412017-11-30 12:56:43 -0500162 return ds->ops->port_fdb_add(ds, port, info->addr, info->vid);
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400163}
164
165static int dsa_switch_fdb_del(struct dsa_switch *ds,
166 struct dsa_notifier_fdb_info *info)
167{
Vivien Didelot31692412017-11-30 12:56:43 -0500168 int port = dsa_towards_port(ds, info->sw_index, info->port);
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400169
170 if (!ds->ops->port_fdb_del)
171 return -EOPNOTSUPP;
172
Vivien Didelot31692412017-11-30 12:56:43 -0500173 return ds->ops->port_fdb_del(ds, port, info->addr, info->vid);
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400174}
175
George McCollister18596f52021-02-09 19:02:12 -0600176static int dsa_switch_hsr_join(struct dsa_switch *ds,
177 struct dsa_notifier_hsr_info *info)
178{
179 if (ds->index == info->sw_index && ds->ops->port_hsr_join)
180 return ds->ops->port_hsr_join(ds, info->port, info->hsr);
181
182 return -EOPNOTSUPP;
183}
184
185static int dsa_switch_hsr_leave(struct dsa_switch *ds,
186 struct dsa_notifier_hsr_info *info)
187{
188 if (ds->index == info->sw_index && ds->ops->port_hsr_leave)
189 return ds->ops->port_hsr_leave(ds, info->port, info->hsr);
190
191 return -EOPNOTSUPP;
192}
193
Tobias Waldekranz058102a2021-01-13 09:42:53 +0100194static int dsa_switch_lag_change(struct dsa_switch *ds,
195 struct dsa_notifier_lag_info *info)
196{
197 if (ds->index == info->sw_index && ds->ops->port_lag_change)
198 return ds->ops->port_lag_change(ds, info->port);
199
200 if (ds->index != info->sw_index && ds->ops->crosschip_lag_change)
201 return ds->ops->crosschip_lag_change(ds, info->sw_index,
202 info->port);
203
204 return 0;
205}
206
207static int dsa_switch_lag_join(struct dsa_switch *ds,
208 struct dsa_notifier_lag_info *info)
209{
210 if (ds->index == info->sw_index && ds->ops->port_lag_join)
211 return ds->ops->port_lag_join(ds, info->port, info->lag,
212 info->info);
213
214 if (ds->index != info->sw_index && ds->ops->crosschip_lag_join)
215 return ds->ops->crosschip_lag_join(ds, info->sw_index,
216 info->port, info->lag,
217 info->info);
218
219 return 0;
220}
221
222static int dsa_switch_lag_leave(struct dsa_switch *ds,
223 struct dsa_notifier_lag_info *info)
224{
225 if (ds->index == info->sw_index && ds->ops->port_lag_leave)
226 return ds->ops->port_lag_leave(ds, info->port, info->lag);
227
228 if (ds->index != info->sw_index && ds->ops->crosschip_lag_leave)
229 return ds->ops->crosschip_lag_leave(ds, info->sw_index,
230 info->port, info->lag);
231
232 return 0;
233}
234
Vladimir Olteanffb68fc2021-01-09 02:01:48 +0200235static int dsa_switch_mdb_add(struct dsa_switch *ds,
236 struct dsa_notifier_mdb_info *info)
Vivien Didelote6db98d2017-11-30 11:24:00 -0500237{
Vladimir Olteanabd49532021-06-21 19:42:16 +0300238 int port = dsa_towards_port(ds, info->sw_index, info->port);
Vivien Didelote6db98d2017-11-30 11:24:00 -0500239
Vladimir Olteana52b2da2021-01-09 02:01:52 +0200240 if (!ds->ops->port_mdb_add)
Vivien Didelote6db98d2017-11-30 11:24:00 -0500241 return -EOPNOTSUPP;
242
Vladimir Olteanabd49532021-06-21 19:42:16 +0300243 return ds->ops->port_mdb_add(ds, port, info->mdb);
Vivien Didelot8ae5bcd2017-05-19 17:00:54 -0400244}
245
246static int dsa_switch_mdb_del(struct dsa_switch *ds,
247 struct dsa_notifier_mdb_info *info)
248{
Vivien Didelot8ae5bcd2017-05-19 17:00:54 -0400249 if (!ds->ops->port_mdb_del)
250 return -EOPNOTSUPP;
251
Vivien Didelota1a6b7e2017-06-15 16:14:48 -0400252 if (ds->index == info->sw_index)
Vivien Didelote65d45c2019-08-25 13:25:15 -0400253 return ds->ops->port_mdb_del(ds, info->port, info->mdb);
Vivien Didelota1a6b7e2017-06-15 16:14:48 -0400254
255 return 0;
Vivien Didelot8ae5bcd2017-05-19 17:00:54 -0400256}
257
Vivien Didelote65d45c2019-08-25 13:25:15 -0400258static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port,
259 struct dsa_notifier_vlan_info *info)
260{
261 if (ds->index == info->sw_index && port == info->port)
262 return true;
263
Vivien Didelot7e1741b2019-08-25 13:25:19 -0400264 if (dsa_is_dsa_port(ds, port))
Vivien Didelote65d45c2019-08-25 13:25:15 -0400265 return true;
266
267 return false;
268}
269
Vladimir Olteanffb68fc2021-01-09 02:01:48 +0200270static int dsa_switch_vlan_add(struct dsa_switch *ds,
271 struct dsa_notifier_vlan_info *info)
Vivien Didelot9c428c52017-11-30 11:23:59 -0500272{
273 int port, err;
274
Vladimir Oltean1958d582021-01-09 02:01:53 +0200275 if (!ds->ops->port_vlan_add)
Vivien Didelot9c428c52017-11-30 11:23:59 -0500276 return -EOPNOTSUPP;
277
Vivien Didelote65d45c2019-08-25 13:25:15 -0400278 for (port = 0; port < ds->num_ports; port++) {
279 if (dsa_switch_vlan_match(ds, port, info)) {
Vladimir Oltean31046a52021-02-13 22:43:18 +0200280 err = ds->ops->port_vlan_add(ds, port, info->vlan,
281 info->extack);
Vivien Didelote65d45c2019-08-25 13:25:15 -0400282 if (err)
283 return err;
284 }
Vivien Didelot9c428c52017-11-30 11:23:59 -0500285 }
286
Vivien Didelotd0c627b2017-05-19 17:00:55 -0400287 return 0;
288}
289
290static int dsa_switch_vlan_del(struct dsa_switch *ds,
291 struct dsa_notifier_vlan_info *info)
292{
Vivien Didelotd0c627b2017-05-19 17:00:55 -0400293 if (!ds->ops->port_vlan_del)
294 return -EOPNOTSUPP;
295
Vivien Didelot1ca4aa92017-06-07 18:12:14 -0400296 if (ds->index == info->sw_index)
Vivien Didelote65d45c2019-08-25 13:25:15 -0400297 return ds->ops->port_vlan_del(ds, info->port, info->vlan);
Vivien Didelot1ca4aa92017-06-07 18:12:14 -0400298
Vivien Didelot7e1741b2019-08-25 13:25:19 -0400299 /* Do not deprogram the DSA links as they may be used as conduit
300 * for other VLAN members in the fabric.
301 */
Vivien Didelot1ca4aa92017-06-07 18:12:14 -0400302 return 0;
Vivien Didelotd0c627b2017-05-19 17:00:55 -0400303}
304
Vladimir Oltean53da0eb2021-01-29 03:00:06 +0200305static int dsa_switch_change_tag_proto(struct dsa_switch *ds,
306 struct dsa_notifier_tag_proto_info *info)
307{
308 const struct dsa_device_ops *tag_ops = info->tag_ops;
309 int port, err;
310
311 if (!ds->ops->change_tag_protocol)
312 return -EOPNOTSUPP;
313
314 ASSERT_RTNL();
315
316 for (port = 0; port < ds->num_ports; port++) {
Tobias Waldekranz21e0b502021-04-20 20:53:09 +0200317 if (!dsa_is_cpu_port(ds, port))
318 continue;
Vladimir Oltean53da0eb2021-01-29 03:00:06 +0200319
Tobias Waldekranz21e0b502021-04-20 20:53:09 +0200320 err = ds->ops->change_tag_protocol(ds, port, tag_ops->proto);
321 if (err)
322 return err;
323
324 dsa_port_set_tag_protocol(dsa_to_port(ds, port), tag_ops);
Vladimir Oltean53da0eb2021-01-29 03:00:06 +0200325 }
326
327 /* Now that changing the tag protocol can no longer fail, let's update
328 * the remaining bits which are "duplicated for faster access", and the
329 * bits that depend on the tagger, such as the MTU.
330 */
331 for (port = 0; port < ds->num_ports; port++) {
332 if (dsa_is_user_port(ds, port)) {
333 struct net_device *slave;
334
335 slave = dsa_to_port(ds, port)->slave;
336 dsa_slave_setup_tagger(slave);
337
338 /* rtnl_mutex is held in dsa_tree_change_tag_proto */
339 dsa_slave_change_mtu(slave, slave->mtu);
340 }
341 }
342
343 return 0;
344}
345
Horatiu Vulturc595c432021-02-16 22:42:04 +0100346static bool dsa_switch_mrp_match(struct dsa_switch *ds, int port,
347 struct dsa_notifier_mrp_info *info)
348{
349 if (ds->index == info->sw_index && port == info->port)
350 return true;
351
352 if (dsa_is_dsa_port(ds, port))
353 return true;
354
355 return false;
356}
357
358static int dsa_switch_mrp_add(struct dsa_switch *ds,
359 struct dsa_notifier_mrp_info *info)
360{
361 int err = 0;
362 int port;
363
364 if (!ds->ops->port_mrp_add)
365 return -EOPNOTSUPP;
366
367 for (port = 0; port < ds->num_ports; port++) {
368 if (dsa_switch_mrp_match(ds, port, info)) {
369 err = ds->ops->port_mrp_add(ds, port, info->mrp);
370 if (err)
371 break;
372 }
373 }
374
375 return err;
376}
377
378static int dsa_switch_mrp_del(struct dsa_switch *ds,
379 struct dsa_notifier_mrp_info *info)
380{
381 if (!ds->ops->port_mrp_del)
382 return -EOPNOTSUPP;
383
384 if (ds->index == info->sw_index)
385 return ds->ops->port_mrp_del(ds, info->port, info->mrp);
386
387 return 0;
388}
389
390static bool
391dsa_switch_mrp_ring_role_match(struct dsa_switch *ds, int port,
392 struct dsa_notifier_mrp_ring_role_info *info)
393{
394 if (ds->index == info->sw_index && port == info->port)
395 return true;
396
397 if (dsa_is_dsa_port(ds, port))
398 return true;
399
400 return false;
401}
402
403static int
404dsa_switch_mrp_add_ring_role(struct dsa_switch *ds,
405 struct dsa_notifier_mrp_ring_role_info *info)
406{
407 int err = 0;
408 int port;
409
410 if (!ds->ops->port_mrp_add)
411 return -EOPNOTSUPP;
412
413 for (port = 0; port < ds->num_ports; port++) {
414 if (dsa_switch_mrp_ring_role_match(ds, port, info)) {
415 err = ds->ops->port_mrp_add_ring_role(ds, port,
416 info->mrp);
417 if (err)
418 break;
419 }
420 }
421
422 return err;
423}
424
425static int
426dsa_switch_mrp_del_ring_role(struct dsa_switch *ds,
427 struct dsa_notifier_mrp_ring_role_info *info)
428{
429 if (!ds->ops->port_mrp_del)
430 return -EOPNOTSUPP;
431
432 if (ds->index == info->sw_index)
433 return ds->ops->port_mrp_del_ring_role(ds, info->port,
434 info->mrp);
435
436 return 0;
437}
438
Vivien Didelotf515f192017-02-03 13:20:20 -0500439static int dsa_switch_event(struct notifier_block *nb,
440 unsigned long event, void *info)
441{
442 struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb);
443 int err;
444
445 switch (event) {
Vivien Didelot1faabf72017-05-19 17:00:52 -0400446 case DSA_NOTIFIER_AGEING_TIME:
447 err = dsa_switch_ageing_time(ds, info);
448 break;
Vivien Didelot04d3a4c2017-02-03 13:20:21 -0500449 case DSA_NOTIFIER_BRIDGE_JOIN:
450 err = dsa_switch_bridge_join(ds, info);
451 break;
452 case DSA_NOTIFIER_BRIDGE_LEAVE:
453 err = dsa_switch_bridge_leave(ds, info);
454 break;
Vivien Didelot685fb6a2017-05-19 17:00:53 -0400455 case DSA_NOTIFIER_FDB_ADD:
456 err = dsa_switch_fdb_add(ds, info);
457 break;
458 case DSA_NOTIFIER_FDB_DEL:
459 err = dsa_switch_fdb_del(ds, info);
460 break;
George McCollister18596f52021-02-09 19:02:12 -0600461 case DSA_NOTIFIER_HSR_JOIN:
462 err = dsa_switch_hsr_join(ds, info);
463 break;
464 case DSA_NOTIFIER_HSR_LEAVE:
465 err = dsa_switch_hsr_leave(ds, info);
466 break;
Tobias Waldekranz058102a2021-01-13 09:42:53 +0100467 case DSA_NOTIFIER_LAG_CHANGE:
468 err = dsa_switch_lag_change(ds, info);
469 break;
470 case DSA_NOTIFIER_LAG_JOIN:
471 err = dsa_switch_lag_join(ds, info);
472 break;
473 case DSA_NOTIFIER_LAG_LEAVE:
474 err = dsa_switch_lag_leave(ds, info);
475 break;
Vivien Didelot8ae5bcd2017-05-19 17:00:54 -0400476 case DSA_NOTIFIER_MDB_ADD:
477 err = dsa_switch_mdb_add(ds, info);
478 break;
479 case DSA_NOTIFIER_MDB_DEL:
480 err = dsa_switch_mdb_del(ds, info);
481 break;
Vivien Didelotd0c627b2017-05-19 17:00:55 -0400482 case DSA_NOTIFIER_VLAN_ADD:
483 err = dsa_switch_vlan_add(ds, info);
484 break;
485 case DSA_NOTIFIER_VLAN_DEL:
486 err = dsa_switch_vlan_del(ds, info);
487 break;
Vladimir Olteanbfcb8132020-03-27 21:55:42 +0200488 case DSA_NOTIFIER_MTU:
489 err = dsa_switch_mtu(ds, info);
490 break;
Vladimir Oltean53da0eb2021-01-29 03:00:06 +0200491 case DSA_NOTIFIER_TAG_PROTO:
492 err = dsa_switch_change_tag_proto(ds, info);
493 break;
Horatiu Vulturc595c432021-02-16 22:42:04 +0100494 case DSA_NOTIFIER_MRP_ADD:
495 err = dsa_switch_mrp_add(ds, info);
496 break;
497 case DSA_NOTIFIER_MRP_DEL:
498 err = dsa_switch_mrp_del(ds, info);
499 break;
500 case DSA_NOTIFIER_MRP_ADD_RING_ROLE:
501 err = dsa_switch_mrp_add_ring_role(ds, info);
502 break;
503 case DSA_NOTIFIER_MRP_DEL_RING_ROLE:
504 err = dsa_switch_mrp_del_ring_role(ds, info);
505 break;
Vivien Didelotf515f192017-02-03 13:20:20 -0500506 default:
507 err = -EOPNOTSUPP;
508 break;
509 }
510
Vivien Didelotf515f192017-02-03 13:20:20 -0500511 if (err)
512 dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n",
513 event, err);
514
515 return notifier_from_errno(err);
516}
517
518int dsa_switch_register_notifier(struct dsa_switch *ds)
519{
520 ds->nb.notifier_call = dsa_switch_event;
521
522 return raw_notifier_chain_register(&ds->dst->nh, &ds->nb);
523}
524
525void dsa_switch_unregister_notifier(struct dsa_switch *ds)
526{
527 int err;
528
529 err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb);
530 if (err)
531 dev_err(ds->dev, "failed to unregister notifier (%d)\n", err);
532}