1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Handling of a single switch chip, part of a switch fabric
5 * Copyright (c) 2017 Savoir-faire Linux Inc.
9 #include <linux/if_bridge.h>
10 #include <linux/netdevice.h>
11 #include <linux/notifier.h>
12 #include <linux/if_vlan.h>
13 #include <net/switchdev.h>
17 static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds,
18 unsigned int ageing_time)
22 dsa_switch_for_each_port(dp, ds)
23 if (dp->ageing_time && dp->ageing_time < ageing_time)
24 ageing_time = dp->ageing_time;
29 static int dsa_switch_ageing_time(struct dsa_switch *ds,
30 struct dsa_notifier_ageing_time_info *info)
32 unsigned int ageing_time = info->ageing_time;
34 if (ds->ageing_time_min && ageing_time < ds->ageing_time_min)
37 if (ds->ageing_time_max && ageing_time > ds->ageing_time_max)
40 /* Program the fastest ageing time in case of multiple bridges */
41 ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time);
43 if (ds->ops->set_ageing_time)
44 return ds->ops->set_ageing_time(ds, ageing_time);
49 static bool dsa_port_mtu_match(struct dsa_port *dp,
50 struct dsa_notifier_mtu_info *info)
52 return dp == info->dp || dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp);
55 static int dsa_switch_mtu(struct dsa_switch *ds,
56 struct dsa_notifier_mtu_info *info)
61 if (!ds->ops->port_change_mtu)
64 dsa_switch_for_each_port(dp, ds) {
65 if (dsa_port_mtu_match(dp, info)) {
66 ret = ds->ops->port_change_mtu(ds, dp->index,
76 static int dsa_switch_bridge_join(struct dsa_switch *ds,
77 struct dsa_notifier_bridge_info *info)
81 if (info->dp->ds == ds) {
82 if (!ds->ops->port_bridge_join)
85 err = ds->ops->port_bridge_join(ds, info->dp->index,
87 &info->tx_fwd_offload,
93 if (info->dp->ds != ds && ds->ops->crosschip_bridge_join) {
94 err = ds->ops->crosschip_bridge_join(ds,
95 info->dp->ds->dst->index,
107 static int dsa_switch_bridge_leave(struct dsa_switch *ds,
108 struct dsa_notifier_bridge_info *info)
110 if (info->dp->ds == ds && ds->ops->port_bridge_leave)
111 ds->ops->port_bridge_leave(ds, info->dp->index, info->bridge);
113 if (info->dp->ds != ds && ds->ops->crosschip_bridge_leave)
114 ds->ops->crosschip_bridge_leave(ds, info->dp->ds->dst->index,
122 /* Matches for all upstream-facing ports (the CPU port and all upstream-facing
123 * DSA links) that sit between the targeted port on which the notifier was
124 * emitted and its dedicated CPU port.
126 static bool dsa_port_host_address_match(struct dsa_port *dp,
127 const struct dsa_port *targeted_dp)
129 struct dsa_port *cpu_dp = targeted_dp->cpu_dp;
131 if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds))
132 return dp->index == dsa_towards_port(dp->ds, cpu_dp->ds->index,
138 static struct dsa_mac_addr *dsa_mac_addr_find(struct list_head *addr_list,
139 const unsigned char *addr, u16 vid,
142 struct dsa_mac_addr *a;
144 list_for_each_entry(a, addr_list, list)
145 if (ether_addr_equal(a->addr, addr) && a->vid == vid &&
146 dsa_db_equal(&a->db, &db))
152 static int dsa_port_do_mdb_add(struct dsa_port *dp,
153 const struct switchdev_obj_port_mdb *mdb,
156 struct dsa_switch *ds = dp->ds;
157 struct dsa_mac_addr *a;
158 int port = dp->index;
161 /* No need to bother with refcounting for user ports */
162 if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
163 return ds->ops->port_mdb_add(ds, port, mdb, db);
165 mutex_lock(&dp->addr_lists_lock);
167 a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid, db);
169 refcount_inc(&a->refcount);
173 a = kzalloc(sizeof(*a), GFP_KERNEL);
179 err = ds->ops->port_mdb_add(ds, port, mdb, db);
185 ether_addr_copy(a->addr, mdb->addr);
188 refcount_set(&a->refcount, 1);
189 list_add_tail(&a->list, &dp->mdbs);
192 mutex_unlock(&dp->addr_lists_lock);
197 static int dsa_port_do_mdb_del(struct dsa_port *dp,
198 const struct switchdev_obj_port_mdb *mdb,
201 struct dsa_switch *ds = dp->ds;
202 struct dsa_mac_addr *a;
203 int port = dp->index;
206 /* No need to bother with refcounting for user ports */
207 if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
208 return ds->ops->port_mdb_del(ds, port, mdb, db);
210 mutex_lock(&dp->addr_lists_lock);
212 a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid, db);
218 if (!refcount_dec_and_test(&a->refcount))
221 err = ds->ops->port_mdb_del(ds, port, mdb, db);
223 refcount_set(&a->refcount, 1);
231 mutex_unlock(&dp->addr_lists_lock);
236 static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr,
237 u16 vid, struct dsa_db db)
239 struct dsa_switch *ds = dp->ds;
240 struct dsa_mac_addr *a;
241 int port = dp->index;
244 /* No need to bother with refcounting for user ports */
245 if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
246 return ds->ops->port_fdb_add(ds, port, addr, vid, db);
248 mutex_lock(&dp->addr_lists_lock);
250 a = dsa_mac_addr_find(&dp->fdbs, addr, vid, db);
252 refcount_inc(&a->refcount);
256 a = kzalloc(sizeof(*a), GFP_KERNEL);
262 err = ds->ops->port_fdb_add(ds, port, addr, vid, db);
268 ether_addr_copy(a->addr, addr);
271 refcount_set(&a->refcount, 1);
272 list_add_tail(&a->list, &dp->fdbs);
275 mutex_unlock(&dp->addr_lists_lock);
280 static int dsa_port_do_fdb_del(struct dsa_port *dp, const unsigned char *addr,
281 u16 vid, struct dsa_db db)
283 struct dsa_switch *ds = dp->ds;
284 struct dsa_mac_addr *a;
285 int port = dp->index;
288 /* No need to bother with refcounting for user ports */
289 if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
290 return ds->ops->port_fdb_del(ds, port, addr, vid, db);
292 mutex_lock(&dp->addr_lists_lock);
294 a = dsa_mac_addr_find(&dp->fdbs, addr, vid, db);
300 if (!refcount_dec_and_test(&a->refcount))
303 err = ds->ops->port_fdb_del(ds, port, addr, vid, db);
305 refcount_set(&a->refcount, 1);
313 mutex_unlock(&dp->addr_lists_lock);
318 static int dsa_switch_do_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag *lag,
319 const unsigned char *addr, u16 vid,
322 struct dsa_mac_addr *a;
325 mutex_lock(&lag->fdb_lock);
327 a = dsa_mac_addr_find(&lag->fdbs, addr, vid, db);
329 refcount_inc(&a->refcount);
333 a = kzalloc(sizeof(*a), GFP_KERNEL);
339 err = ds->ops->lag_fdb_add(ds, *lag, addr, vid, db);
345 ether_addr_copy(a->addr, addr);
347 refcount_set(&a->refcount, 1);
348 list_add_tail(&a->list, &lag->fdbs);
351 mutex_unlock(&lag->fdb_lock);
356 static int dsa_switch_do_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag *lag,
357 const unsigned char *addr, u16 vid,
360 struct dsa_mac_addr *a;
363 mutex_lock(&lag->fdb_lock);
365 a = dsa_mac_addr_find(&lag->fdbs, addr, vid, db);
371 if (!refcount_dec_and_test(&a->refcount))
374 err = ds->ops->lag_fdb_del(ds, *lag, addr, vid, db);
376 refcount_set(&a->refcount, 1);
384 mutex_unlock(&lag->fdb_lock);
389 static int dsa_switch_host_fdb_add(struct dsa_switch *ds,
390 struct dsa_notifier_fdb_info *info)
395 if (!ds->ops->port_fdb_add)
398 dsa_switch_for_each_port(dp, ds) {
399 if (dsa_port_host_address_match(dp, info->dp)) {
400 err = dsa_port_do_fdb_add(dp, info->addr, info->vid,
410 static int dsa_switch_host_fdb_del(struct dsa_switch *ds,
411 struct dsa_notifier_fdb_info *info)
416 if (!ds->ops->port_fdb_del)
419 dsa_switch_for_each_port(dp, ds) {
420 if (dsa_port_host_address_match(dp, info->dp)) {
421 err = dsa_port_do_fdb_del(dp, info->addr, info->vid,
431 static int dsa_switch_fdb_add(struct dsa_switch *ds,
432 struct dsa_notifier_fdb_info *info)
434 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
435 struct dsa_port *dp = dsa_to_port(ds, port);
437 if (!ds->ops->port_fdb_add)
440 return dsa_port_do_fdb_add(dp, info->addr, info->vid, info->db);
443 static int dsa_switch_fdb_del(struct dsa_switch *ds,
444 struct dsa_notifier_fdb_info *info)
446 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
447 struct dsa_port *dp = dsa_to_port(ds, port);
449 if (!ds->ops->port_fdb_del)
452 return dsa_port_do_fdb_del(dp, info->addr, info->vid, info->db);
455 static int dsa_switch_lag_fdb_add(struct dsa_switch *ds,
456 struct dsa_notifier_lag_fdb_info *info)
460 if (!ds->ops->lag_fdb_add)
463 /* Notify switch only if it has a port in this LAG */
464 dsa_switch_for_each_port(dp, ds)
465 if (dsa_port_offloads_lag(dp, info->lag))
466 return dsa_switch_do_lag_fdb_add(ds, info->lag,
467 info->addr, info->vid,
473 static int dsa_switch_lag_fdb_del(struct dsa_switch *ds,
474 struct dsa_notifier_lag_fdb_info *info)
478 if (!ds->ops->lag_fdb_del)
481 /* Notify switch only if it has a port in this LAG */
482 dsa_switch_for_each_port(dp, ds)
483 if (dsa_port_offloads_lag(dp, info->lag))
484 return dsa_switch_do_lag_fdb_del(ds, info->lag,
485 info->addr, info->vid,
491 static int dsa_switch_lag_change(struct dsa_switch *ds,
492 struct dsa_notifier_lag_info *info)
494 if (info->dp->ds == ds && ds->ops->port_lag_change)
495 return ds->ops->port_lag_change(ds, info->dp->index);
497 if (info->dp->ds != ds && ds->ops->crosschip_lag_change)
498 return ds->ops->crosschip_lag_change(ds, info->dp->ds->index,
504 static int dsa_switch_lag_join(struct dsa_switch *ds,
505 struct dsa_notifier_lag_info *info)
507 if (info->dp->ds == ds && ds->ops->port_lag_join)
508 return ds->ops->port_lag_join(ds, info->dp->index, info->lag,
511 if (info->dp->ds != ds && ds->ops->crosschip_lag_join)
512 return ds->ops->crosschip_lag_join(ds, info->dp->ds->index,
513 info->dp->index, info->lag,
519 static int dsa_switch_lag_leave(struct dsa_switch *ds,
520 struct dsa_notifier_lag_info *info)
522 if (info->dp->ds == ds && ds->ops->port_lag_leave)
523 return ds->ops->port_lag_leave(ds, info->dp->index, info->lag);
525 if (info->dp->ds != ds && ds->ops->crosschip_lag_leave)
526 return ds->ops->crosschip_lag_leave(ds, info->dp->ds->index,
527 info->dp->index, info->lag);
532 static int dsa_switch_mdb_add(struct dsa_switch *ds,
533 struct dsa_notifier_mdb_info *info)
535 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
536 struct dsa_port *dp = dsa_to_port(ds, port);
538 if (!ds->ops->port_mdb_add)
541 return dsa_port_do_mdb_add(dp, info->mdb, info->db);
544 static int dsa_switch_mdb_del(struct dsa_switch *ds,
545 struct dsa_notifier_mdb_info *info)
547 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
548 struct dsa_port *dp = dsa_to_port(ds, port);
550 if (!ds->ops->port_mdb_del)
553 return dsa_port_do_mdb_del(dp, info->mdb, info->db);
556 static int dsa_switch_host_mdb_add(struct dsa_switch *ds,
557 struct dsa_notifier_mdb_info *info)
562 if (!ds->ops->port_mdb_add)
565 dsa_switch_for_each_port(dp, ds) {
566 if (dsa_port_host_address_match(dp, info->dp)) {
567 err = dsa_port_do_mdb_add(dp, info->mdb, info->db);
576 static int dsa_switch_host_mdb_del(struct dsa_switch *ds,
577 struct dsa_notifier_mdb_info *info)
582 if (!ds->ops->port_mdb_del)
585 dsa_switch_for_each_port(dp, ds) {
586 if (dsa_port_host_address_match(dp, info->dp)) {
587 err = dsa_port_do_mdb_del(dp, info->mdb, info->db);
596 /* Port VLANs match on the targeted port and on all DSA ports */
597 static bool dsa_port_vlan_match(struct dsa_port *dp,
598 struct dsa_notifier_vlan_info *info)
600 return dsa_port_is_dsa(dp) || dp == info->dp;
603 /* Host VLANs match on the targeted port's CPU port, and on all DSA ports
604 * (upstream and downstream) of that switch and its upstream switches.
606 static bool dsa_port_host_vlan_match(struct dsa_port *dp,
607 const struct dsa_port *targeted_dp)
609 struct dsa_port *cpu_dp = targeted_dp->cpu_dp;
611 if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds))
612 return dsa_port_is_dsa(dp) || dp == cpu_dp;
617 static struct dsa_vlan *dsa_vlan_find(struct list_head *vlan_list,
618 const struct switchdev_obj_port_vlan *vlan)
622 list_for_each_entry(v, vlan_list, list)
623 if (v->vid == vlan->vid)
629 static int dsa_port_do_vlan_add(struct dsa_port *dp,
630 const struct switchdev_obj_port_vlan *vlan,
631 struct netlink_ext_ack *extack)
633 struct dsa_switch *ds = dp->ds;
634 int port = dp->index;
638 /* No need to bother with refcounting for user ports. */
639 if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
640 return ds->ops->port_vlan_add(ds, port, vlan, extack);
642 /* No need to propagate on shared ports the existing VLANs that were
643 * re-notified after just the flags have changed. This would cause a
644 * refcount bump which we need to avoid, since it unbalances the
645 * additions with the deletions.
650 mutex_lock(&dp->vlans_lock);
652 v = dsa_vlan_find(&dp->vlans, vlan);
654 refcount_inc(&v->refcount);
658 v = kzalloc(sizeof(*v), GFP_KERNEL);
664 err = ds->ops->port_vlan_add(ds, port, vlan, extack);
671 refcount_set(&v->refcount, 1);
672 list_add_tail(&v->list, &dp->vlans);
675 mutex_unlock(&dp->vlans_lock);
680 static int dsa_port_do_vlan_del(struct dsa_port *dp,
681 const struct switchdev_obj_port_vlan *vlan)
683 struct dsa_switch *ds = dp->ds;
684 int port = dp->index;
688 /* No need to bother with refcounting for user ports */
689 if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
690 return ds->ops->port_vlan_del(ds, port, vlan);
692 mutex_lock(&dp->vlans_lock);
694 v = dsa_vlan_find(&dp->vlans, vlan);
700 if (!refcount_dec_and_test(&v->refcount))
703 err = ds->ops->port_vlan_del(ds, port, vlan);
705 refcount_set(&v->refcount, 1);
713 mutex_unlock(&dp->vlans_lock);
718 static int dsa_switch_vlan_add(struct dsa_switch *ds,
719 struct dsa_notifier_vlan_info *info)
724 if (!ds->ops->port_vlan_add)
727 dsa_switch_for_each_port(dp, ds) {
728 if (dsa_port_vlan_match(dp, info)) {
729 err = dsa_port_do_vlan_add(dp, info->vlan,
739 static int dsa_switch_vlan_del(struct dsa_switch *ds,
740 struct dsa_notifier_vlan_info *info)
745 if (!ds->ops->port_vlan_del)
748 dsa_switch_for_each_port(dp, ds) {
749 if (dsa_port_vlan_match(dp, info)) {
750 err = dsa_port_do_vlan_del(dp, info->vlan);
759 static int dsa_switch_host_vlan_add(struct dsa_switch *ds,
760 struct dsa_notifier_vlan_info *info)
765 if (!ds->ops->port_vlan_add)
768 dsa_switch_for_each_port(dp, ds) {
769 if (dsa_port_host_vlan_match(dp, info->dp)) {
770 err = dsa_port_do_vlan_add(dp, info->vlan,
780 static int dsa_switch_host_vlan_del(struct dsa_switch *ds,
781 struct dsa_notifier_vlan_info *info)
786 if (!ds->ops->port_vlan_del)
789 dsa_switch_for_each_port(dp, ds) {
790 if (dsa_port_host_vlan_match(dp, info->dp)) {
791 err = dsa_port_do_vlan_del(dp, info->vlan);
800 static int dsa_switch_change_tag_proto(struct dsa_switch *ds,
801 struct dsa_notifier_tag_proto_info *info)
803 const struct dsa_device_ops *tag_ops = info->tag_ops;
804 struct dsa_port *dp, *cpu_dp;
807 if (!ds->ops->change_tag_protocol)
812 err = ds->ops->change_tag_protocol(ds, tag_ops->proto);
816 dsa_switch_for_each_cpu_port(cpu_dp, ds)
817 dsa_port_set_tag_protocol(cpu_dp, tag_ops);
819 /* Now that changing the tag protocol can no longer fail, let's update
820 * the remaining bits which are "duplicated for faster access", and the
821 * bits that depend on the tagger, such as the MTU.
823 dsa_switch_for_each_user_port(dp, ds) {
824 struct net_device *slave = dp->slave;
826 dsa_slave_setup_tagger(slave);
828 /* rtnl_mutex is held in dsa_tree_change_tag_proto */
829 dsa_slave_change_mtu(slave, slave->mtu);
835 /* We use the same cross-chip notifiers to inform both the tagger side, as well
836 * as the switch side, of connection and disconnection events.
837 * Since ds->tagger_data is owned by the tagger, it isn't a hard error if the
838 * switch side doesn't support connecting to this tagger, and therefore, the
839 * fact that we don't disconnect the tagger side doesn't constitute a memory
840 * leak: the tagger will still operate with persistent per-switch memory, just
841 * with the switch side unconnected to it. What does constitute a hard error is
842 * when the switch side supports connecting but fails.
845 dsa_switch_connect_tag_proto(struct dsa_switch *ds,
846 struct dsa_notifier_tag_proto_info *info)
848 const struct dsa_device_ops *tag_ops = info->tag_ops;
851 /* Notify the new tagger about the connection to this switch */
852 if (tag_ops->connect) {
853 err = tag_ops->connect(ds);
858 if (!ds->ops->connect_tag_protocol)
861 /* Notify the switch about the connection to the new tagger */
862 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto);
864 /* Revert the new tagger's connection to this tree */
865 if (tag_ops->disconnect)
866 tag_ops->disconnect(ds);
874 dsa_switch_disconnect_tag_proto(struct dsa_switch *ds,
875 struct dsa_notifier_tag_proto_info *info)
877 const struct dsa_device_ops *tag_ops = info->tag_ops;
879 /* Notify the tagger about the disconnection from this switch */
880 if (tag_ops->disconnect && ds->tagger_data)
881 tag_ops->disconnect(ds);
883 /* No need to notify the switch, since it shouldn't have any
884 * resources to tear down
890 dsa_switch_master_state_change(struct dsa_switch *ds,
891 struct dsa_notifier_master_state_info *info)
893 if (!ds->ops->master_state_change)
896 ds->ops->master_state_change(ds, info->master, info->operational);
901 static int dsa_switch_event(struct notifier_block *nb,
902 unsigned long event, void *info)
904 struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb);
908 case DSA_NOTIFIER_AGEING_TIME:
909 err = dsa_switch_ageing_time(ds, info);
911 case DSA_NOTIFIER_BRIDGE_JOIN:
912 err = dsa_switch_bridge_join(ds, info);
914 case DSA_NOTIFIER_BRIDGE_LEAVE:
915 err = dsa_switch_bridge_leave(ds, info);
917 case DSA_NOTIFIER_FDB_ADD:
918 err = dsa_switch_fdb_add(ds, info);
920 case DSA_NOTIFIER_FDB_DEL:
921 err = dsa_switch_fdb_del(ds, info);
923 case DSA_NOTIFIER_HOST_FDB_ADD:
924 err = dsa_switch_host_fdb_add(ds, info);
926 case DSA_NOTIFIER_HOST_FDB_DEL:
927 err = dsa_switch_host_fdb_del(ds, info);
929 case DSA_NOTIFIER_LAG_FDB_ADD:
930 err = dsa_switch_lag_fdb_add(ds, info);
932 case DSA_NOTIFIER_LAG_FDB_DEL:
933 err = dsa_switch_lag_fdb_del(ds, info);
935 case DSA_NOTIFIER_LAG_CHANGE:
936 err = dsa_switch_lag_change(ds, info);
938 case DSA_NOTIFIER_LAG_JOIN:
939 err = dsa_switch_lag_join(ds, info);
941 case DSA_NOTIFIER_LAG_LEAVE:
942 err = dsa_switch_lag_leave(ds, info);
944 case DSA_NOTIFIER_MDB_ADD:
945 err = dsa_switch_mdb_add(ds, info);
947 case DSA_NOTIFIER_MDB_DEL:
948 err = dsa_switch_mdb_del(ds, info);
950 case DSA_NOTIFIER_HOST_MDB_ADD:
951 err = dsa_switch_host_mdb_add(ds, info);
953 case DSA_NOTIFIER_HOST_MDB_DEL:
954 err = dsa_switch_host_mdb_del(ds, info);
956 case DSA_NOTIFIER_VLAN_ADD:
957 err = dsa_switch_vlan_add(ds, info);
959 case DSA_NOTIFIER_VLAN_DEL:
960 err = dsa_switch_vlan_del(ds, info);
962 case DSA_NOTIFIER_HOST_VLAN_ADD:
963 err = dsa_switch_host_vlan_add(ds, info);
965 case DSA_NOTIFIER_HOST_VLAN_DEL:
966 err = dsa_switch_host_vlan_del(ds, info);
968 case DSA_NOTIFIER_MTU:
969 err = dsa_switch_mtu(ds, info);
971 case DSA_NOTIFIER_TAG_PROTO:
972 err = dsa_switch_change_tag_proto(ds, info);
974 case DSA_NOTIFIER_TAG_PROTO_CONNECT:
975 err = dsa_switch_connect_tag_proto(ds, info);
977 case DSA_NOTIFIER_TAG_PROTO_DISCONNECT:
978 err = dsa_switch_disconnect_tag_proto(ds, info);
980 case DSA_NOTIFIER_TAG_8021Q_VLAN_ADD:
981 err = dsa_switch_tag_8021q_vlan_add(ds, info);
983 case DSA_NOTIFIER_TAG_8021Q_VLAN_DEL:
984 err = dsa_switch_tag_8021q_vlan_del(ds, info);
986 case DSA_NOTIFIER_MASTER_STATE_CHANGE:
987 err = dsa_switch_master_state_change(ds, info);
995 dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n",
998 return notifier_from_errno(err);
1001 int dsa_switch_register_notifier(struct dsa_switch *ds)
1003 ds->nb.notifier_call = dsa_switch_event;
1005 return raw_notifier_chain_register(&ds->dst->nh, &ds->nb);
1008 void dsa_switch_unregister_notifier(struct dsa_switch *ds)
1012 err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb);
1014 dev_err(ds->dev, "failed to unregister notifier (%d)\n", err);