Vivien Didelot | f515f19 | 2017-02-03 13:20:20 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Handling of a single switch chip, part of a switch fabric |
| 3 | * |
Vivien Didelot | 4333d61 | 2017-03-28 15:10:36 -0400 | [diff] [blame] | 4 | * Copyright (c) 2017 Savoir-faire Linux Inc. |
| 5 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
Vivien Didelot | f515f19 | 2017-02-03 13:20:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
Vladimir Oltean | d371b7c | 2019-04-28 21:45:46 +0300 | [diff] [blame^] | 13 | #include <linux/if_bridge.h> |
Vivien Didelot | f515f19 | 2017-02-03 13:20:20 -0500 | [diff] [blame] | 14 | #include <linux/netdevice.h> |
| 15 | #include <linux/notifier.h> |
Florian Fainelli | 061f6a5 | 2019-02-20 14:35:39 -0800 | [diff] [blame] | 16 | #include <linux/if_vlan.h> |
Vivien Didelot | 1faabf7 | 2017-05-19 17:00:52 -0400 | [diff] [blame] | 17 | #include <net/switchdev.h> |
Vivien Didelot | ea5dd34 | 2017-05-17 15:46:03 -0400 | [diff] [blame] | 18 | |
| 19 | #include "dsa_priv.h" |
Vivien Didelot | f515f19 | 2017-02-03 13:20:20 -0500 | [diff] [blame] | 20 | |
Vivien Didelot | 1faabf7 | 2017-05-19 17:00:52 -0400 | [diff] [blame] | 21 | static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, |
| 22 | unsigned int ageing_time) |
| 23 | { |
| 24 | int i; |
| 25 | |
| 26 | for (i = 0; i < ds->num_ports; ++i) { |
| 27 | struct dsa_port *dp = &ds->ports[i]; |
| 28 | |
| 29 | if (dp->ageing_time && dp->ageing_time < ageing_time) |
| 30 | ageing_time = dp->ageing_time; |
| 31 | } |
| 32 | |
| 33 | return ageing_time; |
| 34 | } |
| 35 | |
| 36 | static int dsa_switch_ageing_time(struct dsa_switch *ds, |
| 37 | struct dsa_notifier_ageing_time_info *info) |
| 38 | { |
| 39 | unsigned int ageing_time = info->ageing_time; |
| 40 | struct switchdev_trans *trans = info->trans; |
| 41 | |
Vivien Didelot | 1faabf7 | 2017-05-19 17:00:52 -0400 | [diff] [blame] | 42 | if (switchdev_trans_ph_prepare(trans)) { |
| 43 | if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) |
| 44 | return -ERANGE; |
| 45 | if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) |
| 46 | return -ERANGE; |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | /* Program the fastest ageing time in case of multiple bridges */ |
| 51 | ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time); |
| 52 | |
| 53 | if (ds->ops->set_ageing_time) |
| 54 | return ds->ops->set_ageing_time(ds, ageing_time); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
Vivien Didelot | 04d3a4c | 2017-02-03 13:20:21 -0500 | [diff] [blame] | 59 | static int dsa_switch_bridge_join(struct dsa_switch *ds, |
| 60 | struct dsa_notifier_bridge_info *info) |
| 61 | { |
| 62 | if (ds->index == info->sw_index && ds->ops->port_bridge_join) |
| 63 | return ds->ops->port_bridge_join(ds, info->port, info->br); |
| 64 | |
Vivien Didelot | 40ef2c9 | 2017-03-30 17:37:14 -0400 | [diff] [blame] | 65 | if (ds->index != info->sw_index && ds->ops->crosschip_bridge_join) |
| 66 | return ds->ops->crosschip_bridge_join(ds, info->sw_index, |
| 67 | info->port, info->br); |
Vivien Didelot | 04d3a4c | 2017-02-03 13:20:21 -0500 | [diff] [blame] | 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | static int dsa_switch_bridge_leave(struct dsa_switch *ds, |
| 73 | struct dsa_notifier_bridge_info *info) |
| 74 | { |
Vladimir Oltean | d371b7c | 2019-04-28 21:45:46 +0300 | [diff] [blame^] | 75 | bool unset_vlan_filtering = br_vlan_enabled(info->br); |
| 76 | int err, i; |
| 77 | |
Vivien Didelot | 04d3a4c | 2017-02-03 13:20:21 -0500 | [diff] [blame] | 78 | if (ds->index == info->sw_index && ds->ops->port_bridge_leave) |
| 79 | ds->ops->port_bridge_leave(ds, info->port, info->br); |
| 80 | |
Vivien Didelot | 40ef2c9 | 2017-03-30 17:37:14 -0400 | [diff] [blame] | 81 | if (ds->index != info->sw_index && ds->ops->crosschip_bridge_leave) |
| 82 | ds->ops->crosschip_bridge_leave(ds, info->sw_index, info->port, |
| 83 | info->br); |
Vivien Didelot | 04d3a4c | 2017-02-03 13:20:21 -0500 | [diff] [blame] | 84 | |
Vladimir Oltean | d371b7c | 2019-04-28 21:45:46 +0300 | [diff] [blame^] | 85 | /* If the bridge was vlan_filtering, the bridge core doesn't trigger an |
| 86 | * event for changing vlan_filtering setting upon slave ports leaving |
| 87 | * it. That is a good thing, because that lets us handle it and also |
| 88 | * handle the case where the switch's vlan_filtering setting is global |
| 89 | * (not per port). When that happens, the correct moment to trigger the |
| 90 | * vlan_filtering callback is only when the last port left this bridge. |
| 91 | */ |
| 92 | if (unset_vlan_filtering && ds->vlan_filtering_is_global) { |
| 93 | for (i = 0; i < ds->num_ports; i++) { |
| 94 | if (i == info->port) |
| 95 | continue; |
| 96 | if (dsa_to_port(ds, i)->bridge_dev == info->br) { |
| 97 | unset_vlan_filtering = false; |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | if (unset_vlan_filtering) { |
| 103 | struct switchdev_trans trans = {0}; |
| 104 | |
| 105 | err = dsa_port_vlan_filtering(&ds->ports[info->port], |
| 106 | false, &trans); |
| 107 | if (err && err != EOPNOTSUPP) |
| 108 | return err; |
| 109 | } |
Vivien Didelot | 04d3a4c | 2017-02-03 13:20:21 -0500 | [diff] [blame] | 110 | return 0; |
| 111 | } |
| 112 | |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 113 | static int dsa_switch_fdb_add(struct dsa_switch *ds, |
| 114 | struct dsa_notifier_fdb_info *info) |
| 115 | { |
Vivien Didelot | 3169241 | 2017-11-30 12:56:43 -0500 | [diff] [blame] | 116 | int port = dsa_towards_port(ds, info->sw_index, info->port); |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 117 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 118 | if (!ds->ops->port_fdb_add) |
| 119 | return -EOPNOTSUPP; |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 120 | |
Vivien Didelot | 3169241 | 2017-11-30 12:56:43 -0500 | [diff] [blame] | 121 | return ds->ops->port_fdb_add(ds, port, info->addr, info->vid); |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | static int dsa_switch_fdb_del(struct dsa_switch *ds, |
| 125 | struct dsa_notifier_fdb_info *info) |
| 126 | { |
Vivien Didelot | 3169241 | 2017-11-30 12:56:43 -0500 | [diff] [blame] | 127 | int port = dsa_towards_port(ds, info->sw_index, info->port); |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 128 | |
| 129 | if (!ds->ops->port_fdb_del) |
| 130 | return -EOPNOTSUPP; |
| 131 | |
Vivien Didelot | 3169241 | 2017-11-30 12:56:43 -0500 | [diff] [blame] | 132 | return ds->ops->port_fdb_del(ds, port, info->addr, info->vid); |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 133 | } |
| 134 | |
Vivien Didelot | e6db98d | 2017-11-30 11:24:00 -0500 | [diff] [blame] | 135 | static int |
| 136 | dsa_switch_mdb_prepare_bitmap(struct dsa_switch *ds, |
| 137 | const struct switchdev_obj_port_mdb *mdb, |
| 138 | const unsigned long *bitmap) |
| 139 | { |
| 140 | int port, err; |
| 141 | |
| 142 | if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add) |
| 143 | return -EOPNOTSUPP; |
| 144 | |
| 145 | for_each_set_bit(port, bitmap, ds->num_ports) { |
| 146 | err = ds->ops->port_mdb_prepare(ds, port, mdb); |
| 147 | if (err) |
| 148 | return err; |
| 149 | } |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | static void dsa_switch_mdb_add_bitmap(struct dsa_switch *ds, |
| 155 | const struct switchdev_obj_port_mdb *mdb, |
| 156 | const unsigned long *bitmap) |
| 157 | { |
| 158 | int port; |
| 159 | |
| 160 | for_each_set_bit(port, bitmap, ds->num_ports) |
| 161 | ds->ops->port_mdb_add(ds, port, mdb); |
| 162 | } |
| 163 | |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 164 | static int dsa_switch_mdb_add(struct dsa_switch *ds, |
| 165 | struct dsa_notifier_mdb_info *info) |
| 166 | { |
| 167 | const struct switchdev_obj_port_mdb *mdb = info->mdb; |
| 168 | struct switchdev_trans *trans = info->trans; |
Vivien Didelot | e6db98d | 2017-11-30 11:24:00 -0500 | [diff] [blame] | 169 | int port; |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 170 | |
Vivien Didelot | a1a6b7e | 2017-06-15 16:14:48 -0400 | [diff] [blame] | 171 | /* Build a mask of Multicast group members */ |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 172 | bitmap_zero(ds->bitmap, ds->num_ports); |
Vivien Didelot | a1a6b7e | 2017-06-15 16:14:48 -0400 | [diff] [blame] | 173 | if (ds->index == info->sw_index) |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 174 | set_bit(info->port, ds->bitmap); |
Vivien Didelot | a1a6b7e | 2017-06-15 16:14:48 -0400 | [diff] [blame] | 175 | for (port = 0; port < ds->num_ports; port++) |
Andrew Lunn | ae45102 | 2017-11-09 23:11:02 +0100 | [diff] [blame] | 176 | if (dsa_is_dsa_port(ds, port)) |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 177 | set_bit(port, ds->bitmap); |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 178 | |
Vivien Didelot | e6db98d | 2017-11-30 11:24:00 -0500 | [diff] [blame] | 179 | if (switchdev_trans_ph_prepare(trans)) |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 180 | return dsa_switch_mdb_prepare_bitmap(ds, mdb, ds->bitmap); |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 181 | |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 182 | dsa_switch_mdb_add_bitmap(ds, mdb, ds->bitmap); |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 183 | |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | static int dsa_switch_mdb_del(struct dsa_switch *ds, |
| 188 | struct dsa_notifier_mdb_info *info) |
| 189 | { |
| 190 | const struct switchdev_obj_port_mdb *mdb = info->mdb; |
| 191 | |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 192 | if (!ds->ops->port_mdb_del) |
| 193 | return -EOPNOTSUPP; |
| 194 | |
Vivien Didelot | a1a6b7e | 2017-06-15 16:14:48 -0400 | [diff] [blame] | 195 | if (ds->index == info->sw_index) |
| 196 | return ds->ops->port_mdb_del(ds, info->port, mdb); |
| 197 | |
| 198 | return 0; |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 199 | } |
| 200 | |
Florian Fainelli | 061f6a5 | 2019-02-20 14:35:39 -0800 | [diff] [blame] | 201 | static int dsa_port_vlan_device_check(struct net_device *vlan_dev, |
| 202 | int vlan_dev_vid, |
| 203 | void *arg) |
| 204 | { |
| 205 | struct switchdev_obj_port_vlan *vlan = arg; |
| 206 | u16 vid; |
| 207 | |
| 208 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { |
| 209 | if (vid == vlan_dev_vid) |
| 210 | return -EBUSY; |
| 211 | } |
| 212 | |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | static int dsa_port_vlan_check(struct dsa_switch *ds, int port, |
| 217 | const struct switchdev_obj_port_vlan *vlan) |
| 218 | { |
| 219 | const struct dsa_port *dp = dsa_to_port(ds, port); |
| 220 | int err = 0; |
| 221 | |
| 222 | /* Device is not bridged, let it proceed with the VLAN device |
| 223 | * creation. |
| 224 | */ |
| 225 | if (!dp->bridge_dev) |
| 226 | return err; |
| 227 | |
Vladimir Oltean | 85478d7 | 2019-04-28 21:45:42 +0300 | [diff] [blame] | 228 | /* dsa_slave_vlan_rx_{add,kill}_vid() cannot use the prepare phase and |
Florian Fainelli | 061f6a5 | 2019-02-20 14:35:39 -0800 | [diff] [blame] | 229 | * already checks whether there is an overlapping bridge VLAN entry |
| 230 | * with the same VID, so here we only need to check that if we are |
| 231 | * adding a bridge VLAN entry there is not an overlapping VLAN device |
| 232 | * claiming that VID. |
| 233 | */ |
| 234 | return vlan_for_each(dp->slave, dsa_port_vlan_device_check, |
| 235 | (void *)vlan); |
| 236 | } |
| 237 | |
Vivien Didelot | 9c428c5 | 2017-11-30 11:23:59 -0500 | [diff] [blame] | 238 | static int |
| 239 | dsa_switch_vlan_prepare_bitmap(struct dsa_switch *ds, |
| 240 | const struct switchdev_obj_port_vlan *vlan, |
| 241 | const unsigned long *bitmap) |
| 242 | { |
| 243 | int port, err; |
| 244 | |
| 245 | if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add) |
| 246 | return -EOPNOTSUPP; |
| 247 | |
| 248 | for_each_set_bit(port, bitmap, ds->num_ports) { |
Florian Fainelli | 061f6a5 | 2019-02-20 14:35:39 -0800 | [diff] [blame] | 249 | err = dsa_port_vlan_check(ds, port, vlan); |
| 250 | if (err) |
| 251 | return err; |
| 252 | |
Vivien Didelot | 9c428c5 | 2017-11-30 11:23:59 -0500 | [diff] [blame] | 253 | err = ds->ops->port_vlan_prepare(ds, port, vlan); |
| 254 | if (err) |
| 255 | return err; |
| 256 | } |
| 257 | |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | static void |
| 262 | dsa_switch_vlan_add_bitmap(struct dsa_switch *ds, |
| 263 | const struct switchdev_obj_port_vlan *vlan, |
| 264 | const unsigned long *bitmap) |
| 265 | { |
| 266 | int port; |
| 267 | |
| 268 | for_each_set_bit(port, bitmap, ds->num_ports) |
| 269 | ds->ops->port_vlan_add(ds, port, vlan); |
| 270 | } |
| 271 | |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 272 | static int dsa_switch_vlan_add(struct dsa_switch *ds, |
| 273 | struct dsa_notifier_vlan_info *info) |
| 274 | { |
| 275 | const struct switchdev_obj_port_vlan *vlan = info->vlan; |
| 276 | struct switchdev_trans *trans = info->trans; |
Vivien Didelot | 9c428c5 | 2017-11-30 11:23:59 -0500 | [diff] [blame] | 277 | int port; |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 278 | |
Vivien Didelot | 1ca4aa9 | 2017-06-07 18:12:14 -0400 | [diff] [blame] | 279 | /* Build a mask of VLAN members */ |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 280 | bitmap_zero(ds->bitmap, ds->num_ports); |
Vivien Didelot | 1ca4aa9 | 2017-06-07 18:12:14 -0400 | [diff] [blame] | 281 | if (ds->index == info->sw_index) |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 282 | set_bit(info->port, ds->bitmap); |
Vivien Didelot | b2f81d3 | 2017-06-07 18:12:15 -0400 | [diff] [blame] | 283 | for (port = 0; port < ds->num_ports; port++) |
| 284 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 285 | set_bit(port, ds->bitmap); |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 286 | |
Vivien Didelot | 9c428c5 | 2017-11-30 11:23:59 -0500 | [diff] [blame] | 287 | if (switchdev_trans_ph_prepare(trans)) |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 288 | return dsa_switch_vlan_prepare_bitmap(ds, vlan, ds->bitmap); |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 289 | |
Salvatore Mesoraca | 0015b80 | 2018-07-16 21:10:34 -0700 | [diff] [blame] | 290 | dsa_switch_vlan_add_bitmap(ds, vlan, ds->bitmap); |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 291 | |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | static int dsa_switch_vlan_del(struct dsa_switch *ds, |
| 296 | struct dsa_notifier_vlan_info *info) |
| 297 | { |
| 298 | const struct switchdev_obj_port_vlan *vlan = info->vlan; |
| 299 | |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 300 | if (!ds->ops->port_vlan_del) |
| 301 | return -EOPNOTSUPP; |
| 302 | |
Vivien Didelot | 1ca4aa9 | 2017-06-07 18:12:14 -0400 | [diff] [blame] | 303 | if (ds->index == info->sw_index) |
| 304 | return ds->ops->port_vlan_del(ds, info->port, vlan); |
| 305 | |
| 306 | return 0; |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 307 | } |
| 308 | |
Vivien Didelot | f515f19 | 2017-02-03 13:20:20 -0500 | [diff] [blame] | 309 | static int dsa_switch_event(struct notifier_block *nb, |
| 310 | unsigned long event, void *info) |
| 311 | { |
| 312 | struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb); |
| 313 | int err; |
| 314 | |
| 315 | switch (event) { |
Vivien Didelot | 1faabf7 | 2017-05-19 17:00:52 -0400 | [diff] [blame] | 316 | case DSA_NOTIFIER_AGEING_TIME: |
| 317 | err = dsa_switch_ageing_time(ds, info); |
| 318 | break; |
Vivien Didelot | 04d3a4c | 2017-02-03 13:20:21 -0500 | [diff] [blame] | 319 | case DSA_NOTIFIER_BRIDGE_JOIN: |
| 320 | err = dsa_switch_bridge_join(ds, info); |
| 321 | break; |
| 322 | case DSA_NOTIFIER_BRIDGE_LEAVE: |
| 323 | err = dsa_switch_bridge_leave(ds, info); |
| 324 | break; |
Vivien Didelot | 685fb6a | 2017-05-19 17:00:53 -0400 | [diff] [blame] | 325 | case DSA_NOTIFIER_FDB_ADD: |
| 326 | err = dsa_switch_fdb_add(ds, info); |
| 327 | break; |
| 328 | case DSA_NOTIFIER_FDB_DEL: |
| 329 | err = dsa_switch_fdb_del(ds, info); |
| 330 | break; |
Vivien Didelot | 8ae5bcd | 2017-05-19 17:00:54 -0400 | [diff] [blame] | 331 | case DSA_NOTIFIER_MDB_ADD: |
| 332 | err = dsa_switch_mdb_add(ds, info); |
| 333 | break; |
| 334 | case DSA_NOTIFIER_MDB_DEL: |
| 335 | err = dsa_switch_mdb_del(ds, info); |
| 336 | break; |
Vivien Didelot | d0c627b | 2017-05-19 17:00:55 -0400 | [diff] [blame] | 337 | case DSA_NOTIFIER_VLAN_ADD: |
| 338 | err = dsa_switch_vlan_add(ds, info); |
| 339 | break; |
| 340 | case DSA_NOTIFIER_VLAN_DEL: |
| 341 | err = dsa_switch_vlan_del(ds, info); |
| 342 | break; |
Vivien Didelot | f515f19 | 2017-02-03 13:20:20 -0500 | [diff] [blame] | 343 | default: |
| 344 | err = -EOPNOTSUPP; |
| 345 | break; |
| 346 | } |
| 347 | |
| 348 | /* Non-switchdev operations cannot be rolled back. If a DSA driver |
| 349 | * returns an error during the chained call, switch chips may be in an |
| 350 | * inconsistent state. |
| 351 | */ |
| 352 | if (err) |
| 353 | dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n", |
| 354 | event, err); |
| 355 | |
| 356 | return notifier_from_errno(err); |
| 357 | } |
| 358 | |
| 359 | int dsa_switch_register_notifier(struct dsa_switch *ds) |
| 360 | { |
| 361 | ds->nb.notifier_call = dsa_switch_event; |
| 362 | |
| 363 | return raw_notifier_chain_register(&ds->dst->nh, &ds->nb); |
| 364 | } |
| 365 | |
| 366 | void dsa_switch_unregister_notifier(struct dsa_switch *ds) |
| 367 | { |
| 368 | int err; |
| 369 | |
| 370 | err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb); |
| 371 | if (err) |
| 372 | dev_err(ds->dev, "failed to unregister notifier (%d)\n", err); |
| 373 | } |