.. | .. |
---|
18 | 18 | |
---|
19 | 19 | #include "ethsw.h" |
---|
20 | 20 | |
---|
21 | | -static struct workqueue_struct *ethsw_owq; |
---|
22 | | - |
---|
23 | 21 | /* Minimal supported DPSW version */ |
---|
24 | 22 | #define DPSW_MIN_VER_MAJOR 8 |
---|
25 | | -#define DPSW_MIN_VER_MINOR 0 |
---|
| 23 | +#define DPSW_MIN_VER_MINOR 1 |
---|
26 | 24 | |
---|
27 | 25 | #define DEFAULT_VLAN_ID 1 |
---|
28 | 26 | |
---|
29 | | -static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid) |
---|
| 27 | +static int dpaa2_switch_add_vlan(struct ethsw_core *ethsw, u16 vid) |
---|
30 | 28 | { |
---|
31 | 29 | int err; |
---|
32 | 30 | |
---|
33 | 31 | struct dpsw_vlan_cfg vcfg = { |
---|
34 | 32 | .fdb_id = 0, |
---|
35 | 33 | }; |
---|
36 | | - |
---|
37 | | - if (ethsw->vlans[vid]) { |
---|
38 | | - dev_err(ethsw->dev, "VLAN already configured\n"); |
---|
39 | | - return -EEXIST; |
---|
40 | | - } |
---|
41 | 34 | |
---|
42 | 35 | err = dpsw_vlan_add(ethsw->mc_io, 0, |
---|
43 | 36 | ethsw->dpsw_handle, vid, &vcfg); |
---|
.. | .. |
---|
50 | 43 | return 0; |
---|
51 | 44 | } |
---|
52 | 45 | |
---|
53 | | -static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) |
---|
| 46 | +static bool dpaa2_switch_port_is_up(struct ethsw_port_priv *port_priv) |
---|
| 47 | +{ |
---|
| 48 | + struct net_device *netdev = port_priv->netdev; |
---|
| 49 | + struct dpsw_link_state state; |
---|
| 50 | + int err; |
---|
| 51 | + |
---|
| 52 | + err = dpsw_if_get_link_state(port_priv->ethsw_data->mc_io, 0, |
---|
| 53 | + port_priv->ethsw_data->dpsw_handle, |
---|
| 54 | + port_priv->idx, &state); |
---|
| 55 | + if (err) { |
---|
| 56 | + netdev_err(netdev, "dpsw_if_get_link_state() err %d\n", err); |
---|
| 57 | + return true; |
---|
| 58 | + } |
---|
| 59 | + |
---|
| 60 | + WARN_ONCE(state.up > 1, "Garbage read into link_state"); |
---|
| 61 | + |
---|
| 62 | + return state.up ? true : false; |
---|
| 63 | +} |
---|
| 64 | + |
---|
| 65 | +static int dpaa2_switch_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) |
---|
54 | 66 | { |
---|
55 | 67 | struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
56 | 68 | struct net_device *netdev = port_priv->netdev; |
---|
57 | 69 | struct dpsw_tci_cfg tci_cfg = { 0 }; |
---|
58 | | - bool is_oper; |
---|
| 70 | + bool up; |
---|
59 | 71 | int err, ret; |
---|
60 | 72 | |
---|
61 | 73 | err = dpsw_if_get_tci(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
.. | .. |
---|
68 | 80 | tci_cfg.vlan_id = pvid; |
---|
69 | 81 | |
---|
70 | 82 | /* Interface needs to be down to change PVID */ |
---|
71 | | - is_oper = netif_oper_up(netdev); |
---|
72 | | - if (is_oper) { |
---|
| 83 | + up = dpaa2_switch_port_is_up(port_priv); |
---|
| 84 | + if (up) { |
---|
73 | 85 | err = dpsw_if_disable(ethsw->mc_io, 0, |
---|
74 | 86 | ethsw->dpsw_handle, |
---|
75 | 87 | port_priv->idx); |
---|
.. | .. |
---|
92 | 104 | port_priv->pvid = pvid; |
---|
93 | 105 | |
---|
94 | 106 | set_tci_error: |
---|
95 | | - if (is_oper) { |
---|
| 107 | + if (up) { |
---|
96 | 108 | ret = dpsw_if_enable(ethsw->mc_io, 0, |
---|
97 | 109 | ethsw->dpsw_handle, |
---|
98 | 110 | port_priv->idx); |
---|
.. | .. |
---|
105 | 117 | return err; |
---|
106 | 118 | } |
---|
107 | 119 | |
---|
108 | | -static int ethsw_port_add_vlan(struct ethsw_port_priv *port_priv, |
---|
109 | | - u16 vid, u16 flags) |
---|
| 120 | +static int dpaa2_switch_port_add_vlan(struct ethsw_port_priv *port_priv, |
---|
| 121 | + u16 vid, u16 flags) |
---|
110 | 122 | { |
---|
111 | 123 | struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
112 | 124 | struct net_device *netdev = port_priv->netdev; |
---|
.. | .. |
---|
141 | 153 | } |
---|
142 | 154 | |
---|
143 | 155 | if (flags & BRIDGE_VLAN_INFO_PVID) { |
---|
144 | | - err = ethsw_port_set_pvid(port_priv, vid); |
---|
| 156 | + err = dpaa2_switch_port_set_pvid(port_priv, vid); |
---|
145 | 157 | if (err) |
---|
146 | 158 | return err; |
---|
147 | 159 | } |
---|
.. | .. |
---|
149 | 161 | return 0; |
---|
150 | 162 | } |
---|
151 | 163 | |
---|
152 | | -static int ethsw_set_learning(struct ethsw_core *ethsw, u8 flag) |
---|
| 164 | +static int dpaa2_switch_set_learning(struct ethsw_core *ethsw, bool enable) |
---|
153 | 165 | { |
---|
154 | 166 | enum dpsw_fdb_learning_mode learn_mode; |
---|
155 | 167 | int err; |
---|
156 | 168 | |
---|
157 | | - if (flag) |
---|
| 169 | + if (enable) |
---|
158 | 170 | learn_mode = DPSW_FDB_LEARNING_MODE_HW; |
---|
159 | 171 | else |
---|
160 | 172 | learn_mode = DPSW_FDB_LEARNING_MODE_DIS; |
---|
.. | .. |
---|
165 | 177 | dev_err(ethsw->dev, "dpsw_fdb_set_learning_mode err %d\n", err); |
---|
166 | 178 | return err; |
---|
167 | 179 | } |
---|
168 | | - ethsw->learning = !!flag; |
---|
| 180 | + ethsw->learning = enable; |
---|
169 | 181 | |
---|
170 | 182 | return 0; |
---|
171 | 183 | } |
---|
172 | 184 | |
---|
173 | | -static int ethsw_port_set_flood(struct ethsw_port_priv *port_priv, u8 flag) |
---|
| 185 | +static int dpaa2_switch_port_set_flood(struct ethsw_port_priv *port_priv, bool enable) |
---|
174 | 186 | { |
---|
175 | 187 | int err; |
---|
176 | 188 | |
---|
177 | 189 | err = dpsw_if_set_flooding(port_priv->ethsw_data->mc_io, 0, |
---|
178 | 190 | port_priv->ethsw_data->dpsw_handle, |
---|
179 | | - port_priv->idx, flag); |
---|
| 191 | + port_priv->idx, enable); |
---|
180 | 192 | if (err) { |
---|
181 | 193 | netdev_err(port_priv->netdev, |
---|
182 | 194 | "dpsw_if_set_flooding err %d\n", err); |
---|
183 | 195 | return err; |
---|
184 | 196 | } |
---|
185 | | - port_priv->flood = !!flag; |
---|
| 197 | + port_priv->flood = enable; |
---|
186 | 198 | |
---|
187 | 199 | return 0; |
---|
188 | 200 | } |
---|
189 | 201 | |
---|
190 | | -static int ethsw_port_set_stp_state(struct ethsw_port_priv *port_priv, u8 state) |
---|
| 202 | +static int dpaa2_switch_port_set_stp_state(struct ethsw_port_priv *port_priv, u8 state) |
---|
191 | 203 | { |
---|
192 | 204 | struct dpsw_stp_cfg stp_cfg = { |
---|
193 | | - .vlan_id = DEFAULT_VLAN_ID, |
---|
194 | 205 | .state = state, |
---|
195 | 206 | }; |
---|
196 | 207 | int err; |
---|
| 208 | + u16 vid; |
---|
197 | 209 | |
---|
198 | | - if (!netif_oper_up(port_priv->netdev) || state == port_priv->stp_state) |
---|
| 210 | + if (!netif_running(port_priv->netdev) || state == port_priv->stp_state) |
---|
199 | 211 | return 0; /* Nothing to do */ |
---|
200 | 212 | |
---|
201 | | - err = dpsw_if_set_stp(port_priv->ethsw_data->mc_io, 0, |
---|
202 | | - port_priv->ethsw_data->dpsw_handle, |
---|
203 | | - port_priv->idx, &stp_cfg); |
---|
204 | | - if (err) { |
---|
205 | | - netdev_err(port_priv->netdev, |
---|
206 | | - "dpsw_if_set_stp err %d\n", err); |
---|
207 | | - return err; |
---|
| 213 | + for (vid = 0; vid <= VLAN_VID_MASK; vid++) { |
---|
| 214 | + if (port_priv->vlans[vid] & ETHSW_VLAN_MEMBER) { |
---|
| 215 | + stp_cfg.vlan_id = vid; |
---|
| 216 | + err = dpsw_if_set_stp(port_priv->ethsw_data->mc_io, 0, |
---|
| 217 | + port_priv->ethsw_data->dpsw_handle, |
---|
| 218 | + port_priv->idx, &stp_cfg); |
---|
| 219 | + if (err) { |
---|
| 220 | + netdev_err(port_priv->netdev, |
---|
| 221 | + "dpsw_if_set_stp err %d\n", err); |
---|
| 222 | + return err; |
---|
| 223 | + } |
---|
| 224 | + } |
---|
208 | 225 | } |
---|
209 | 226 | |
---|
210 | 227 | port_priv->stp_state = state; |
---|
.. | .. |
---|
212 | 229 | return 0; |
---|
213 | 230 | } |
---|
214 | 231 | |
---|
215 | | -static int ethsw_dellink_switch(struct ethsw_core *ethsw, u16 vid) |
---|
| 232 | +static int dpaa2_switch_dellink(struct ethsw_core *ethsw, u16 vid) |
---|
216 | 233 | { |
---|
217 | 234 | struct ethsw_port_priv *ppriv_local = NULL; |
---|
218 | 235 | int i, err; |
---|
.. | .. |
---|
235 | 252 | return 0; |
---|
236 | 253 | } |
---|
237 | 254 | |
---|
238 | | -static int ethsw_port_fdb_add_uc(struct ethsw_port_priv *port_priv, |
---|
239 | | - const unsigned char *addr) |
---|
| 255 | +static int dpaa2_switch_port_fdb_add_uc(struct ethsw_port_priv *port_priv, |
---|
| 256 | + const unsigned char *addr) |
---|
240 | 257 | { |
---|
241 | 258 | struct dpsw_fdb_unicast_cfg entry = {0}; |
---|
242 | 259 | int err; |
---|
.. | .. |
---|
254 | 271 | return err; |
---|
255 | 272 | } |
---|
256 | 273 | |
---|
257 | | -static int ethsw_port_fdb_del_uc(struct ethsw_port_priv *port_priv, |
---|
258 | | - const unsigned char *addr) |
---|
| 274 | +static int dpaa2_switch_port_fdb_del_uc(struct ethsw_port_priv *port_priv, |
---|
| 275 | + const unsigned char *addr) |
---|
259 | 276 | { |
---|
260 | 277 | struct dpsw_fdb_unicast_cfg entry = {0}; |
---|
261 | 278 | int err; |
---|
.. | .. |
---|
274 | 291 | return err; |
---|
275 | 292 | } |
---|
276 | 293 | |
---|
277 | | -static int ethsw_port_fdb_add_mc(struct ethsw_port_priv *port_priv, |
---|
278 | | - const unsigned char *addr) |
---|
| 294 | +static int dpaa2_switch_port_fdb_add_mc(struct ethsw_port_priv *port_priv, |
---|
| 295 | + const unsigned char *addr) |
---|
279 | 296 | { |
---|
280 | 297 | struct dpsw_fdb_multicast_cfg entry = {0}; |
---|
281 | 298 | int err; |
---|
.. | .. |
---|
295 | 312 | return err; |
---|
296 | 313 | } |
---|
297 | 314 | |
---|
298 | | -static int ethsw_port_fdb_del_mc(struct ethsw_port_priv *port_priv, |
---|
299 | | - const unsigned char *addr) |
---|
| 315 | +static int dpaa2_switch_port_fdb_del_mc(struct ethsw_port_priv *port_priv, |
---|
| 316 | + const unsigned char *addr) |
---|
300 | 317 | { |
---|
301 | 318 | struct dpsw_fdb_multicast_cfg entry = {0}; |
---|
302 | 319 | int err; |
---|
.. | .. |
---|
316 | 333 | return err; |
---|
317 | 334 | } |
---|
318 | 335 | |
---|
319 | | -static void port_get_stats(struct net_device *netdev, |
---|
320 | | - struct rtnl_link_stats64 *stats) |
---|
| 336 | +static int dpaa2_switch_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], |
---|
| 337 | + struct net_device *dev, const unsigned char *addr, |
---|
| 338 | + u16 vid, u16 flags, |
---|
| 339 | + struct netlink_ext_ack *extack) |
---|
| 340 | +{ |
---|
| 341 | + if (is_unicast_ether_addr(addr)) |
---|
| 342 | + return dpaa2_switch_port_fdb_add_uc(netdev_priv(dev), |
---|
| 343 | + addr); |
---|
| 344 | + else |
---|
| 345 | + return dpaa2_switch_port_fdb_add_mc(netdev_priv(dev), |
---|
| 346 | + addr); |
---|
| 347 | +} |
---|
| 348 | + |
---|
| 349 | +static int dpaa2_switch_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], |
---|
| 350 | + struct net_device *dev, |
---|
| 351 | + const unsigned char *addr, u16 vid) |
---|
| 352 | +{ |
---|
| 353 | + if (is_unicast_ether_addr(addr)) |
---|
| 354 | + return dpaa2_switch_port_fdb_del_uc(netdev_priv(dev), |
---|
| 355 | + addr); |
---|
| 356 | + else |
---|
| 357 | + return dpaa2_switch_port_fdb_del_mc(netdev_priv(dev), |
---|
| 358 | + addr); |
---|
| 359 | +} |
---|
| 360 | + |
---|
| 361 | +static void dpaa2_switch_port_get_stats(struct net_device *netdev, |
---|
| 362 | + struct rtnl_link_stats64 *stats) |
---|
321 | 363 | { |
---|
322 | 364 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
323 | 365 | u64 tmp; |
---|
.. | .. |
---|
382 | 424 | netdev_err(netdev, "dpsw_if_get_counter err %d\n", err); |
---|
383 | 425 | } |
---|
384 | 426 | |
---|
385 | | -static bool port_has_offload_stats(const struct net_device *netdev, |
---|
386 | | - int attr_id) |
---|
| 427 | +static bool dpaa2_switch_port_has_offload_stats(const struct net_device *netdev, |
---|
| 428 | + int attr_id) |
---|
387 | 429 | { |
---|
388 | 430 | return (attr_id == IFLA_OFFLOAD_XSTATS_CPU_HIT); |
---|
389 | 431 | } |
---|
390 | 432 | |
---|
391 | | -static int port_get_offload_stats(int attr_id, |
---|
392 | | - const struct net_device *netdev, |
---|
393 | | - void *sp) |
---|
| 433 | +static int dpaa2_switch_port_get_offload_stats(int attr_id, |
---|
| 434 | + const struct net_device *netdev, |
---|
| 435 | + void *sp) |
---|
394 | 436 | { |
---|
395 | 437 | switch (attr_id) { |
---|
396 | 438 | case IFLA_OFFLOAD_XSTATS_CPU_HIT: |
---|
397 | | - port_get_stats((struct net_device *)netdev, sp); |
---|
| 439 | + dpaa2_switch_port_get_stats((struct net_device *)netdev, sp); |
---|
398 | 440 | return 0; |
---|
399 | 441 | } |
---|
400 | 442 | |
---|
401 | 443 | return -EINVAL; |
---|
402 | 444 | } |
---|
403 | 445 | |
---|
404 | | -static int port_change_mtu(struct net_device *netdev, int mtu) |
---|
| 446 | +static int dpaa2_switch_port_change_mtu(struct net_device *netdev, int mtu) |
---|
405 | 447 | { |
---|
406 | 448 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
407 | 449 | int err; |
---|
.. | .. |
---|
421 | 463 | return 0; |
---|
422 | 464 | } |
---|
423 | 465 | |
---|
424 | | -static int port_carrier_state_sync(struct net_device *netdev) |
---|
| 466 | +static int dpaa2_switch_port_carrier_state_sync(struct net_device *netdev) |
---|
425 | 467 | { |
---|
426 | 468 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
427 | 469 | struct dpsw_link_state state; |
---|
428 | 470 | int err; |
---|
| 471 | + |
---|
| 472 | + /* Interrupts are received even though no one issued an 'ifconfig up' |
---|
| 473 | + * on the switch interface. Ignore these link state update interrupts |
---|
| 474 | + */ |
---|
| 475 | + if (!netif_running(netdev)) |
---|
| 476 | + return 0; |
---|
429 | 477 | |
---|
430 | 478 | err = dpsw_if_get_link_state(port_priv->ethsw_data->mc_io, 0, |
---|
431 | 479 | port_priv->ethsw_data->dpsw_handle, |
---|
.. | .. |
---|
444 | 492 | netif_carrier_off(netdev); |
---|
445 | 493 | port_priv->link_state = state.up; |
---|
446 | 494 | } |
---|
| 495 | + |
---|
447 | 496 | return 0; |
---|
448 | 497 | } |
---|
449 | 498 | |
---|
450 | | -static int port_open(struct net_device *netdev) |
---|
| 499 | +static int dpaa2_switch_port_open(struct net_device *netdev) |
---|
451 | 500 | { |
---|
452 | 501 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
453 | 502 | int err; |
---|
454 | 503 | |
---|
455 | 504 | /* No need to allow Tx as control interface is disabled */ |
---|
456 | 505 | netif_tx_stop_all_queues(netdev); |
---|
| 506 | + |
---|
| 507 | + /* Explicitly set carrier off, otherwise |
---|
| 508 | + * netif_carrier_ok() will return true and cause 'ip link show' |
---|
| 509 | + * to report the LOWER_UP flag, even though the link |
---|
| 510 | + * notification wasn't even received. |
---|
| 511 | + */ |
---|
| 512 | + netif_carrier_off(netdev); |
---|
457 | 513 | |
---|
458 | 514 | err = dpsw_if_enable(port_priv->ethsw_data->mc_io, 0, |
---|
459 | 515 | port_priv->ethsw_data->dpsw_handle, |
---|
.. | .. |
---|
464 | 520 | } |
---|
465 | 521 | |
---|
466 | 522 | /* sync carrier state */ |
---|
467 | | - err = port_carrier_state_sync(netdev); |
---|
| 523 | + err = dpaa2_switch_port_carrier_state_sync(netdev); |
---|
468 | 524 | if (err) { |
---|
469 | 525 | netdev_err(netdev, |
---|
470 | | - "port_carrier_state_sync err %d\n", err); |
---|
| 526 | + "dpaa2_switch_port_carrier_state_sync err %d\n", err); |
---|
471 | 527 | goto err_carrier_sync; |
---|
472 | 528 | } |
---|
473 | 529 | |
---|
.. | .. |
---|
480 | 536 | return err; |
---|
481 | 537 | } |
---|
482 | 538 | |
---|
483 | | -static int port_stop(struct net_device *netdev) |
---|
| 539 | +static int dpaa2_switch_port_stop(struct net_device *netdev) |
---|
484 | 540 | { |
---|
485 | 541 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
486 | 542 | int err; |
---|
.. | .. |
---|
496 | 552 | return 0; |
---|
497 | 553 | } |
---|
498 | 554 | |
---|
499 | | -static netdev_tx_t port_dropframe(struct sk_buff *skb, |
---|
500 | | - struct net_device *netdev) |
---|
| 555 | +static netdev_tx_t dpaa2_switch_port_dropframe(struct sk_buff *skb, |
---|
| 556 | + struct net_device *netdev) |
---|
501 | 557 | { |
---|
502 | 558 | /* we don't support I/O for now, drop the frame */ |
---|
503 | 559 | dev_kfree_skb_any(skb); |
---|
.. | .. |
---|
505 | 561 | return NETDEV_TX_OK; |
---|
506 | 562 | } |
---|
507 | 563 | |
---|
508 | | -static const struct net_device_ops ethsw_port_ops = { |
---|
509 | | - .ndo_open = port_open, |
---|
510 | | - .ndo_stop = port_stop, |
---|
| 564 | +static int dpaa2_switch_port_parent_id(struct net_device *dev, |
---|
| 565 | + struct netdev_phys_item_id *ppid) |
---|
| 566 | +{ |
---|
| 567 | + struct ethsw_port_priv *port_priv = netdev_priv(dev); |
---|
511 | 568 | |
---|
512 | | - .ndo_set_mac_address = eth_mac_addr, |
---|
513 | | - .ndo_change_mtu = port_change_mtu, |
---|
514 | | - .ndo_has_offload_stats = port_has_offload_stats, |
---|
515 | | - .ndo_get_offload_stats = port_get_offload_stats, |
---|
| 569 | + ppid->id_len = 1; |
---|
| 570 | + ppid->id[0] = port_priv->ethsw_data->dev_id; |
---|
516 | 571 | |
---|
517 | | - .ndo_start_xmit = port_dropframe, |
---|
| 572 | + return 0; |
---|
| 573 | +} |
---|
| 574 | + |
---|
| 575 | +static int dpaa2_switch_port_get_phys_name(struct net_device *netdev, char *name, |
---|
| 576 | + size_t len) |
---|
| 577 | +{ |
---|
| 578 | + struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
| 579 | + int err; |
---|
| 580 | + |
---|
| 581 | + err = snprintf(name, len, "p%d", port_priv->idx); |
---|
| 582 | + if (err >= len) |
---|
| 583 | + return -EINVAL; |
---|
| 584 | + |
---|
| 585 | + return 0; |
---|
| 586 | +} |
---|
| 587 | + |
---|
| 588 | +struct ethsw_dump_ctx { |
---|
| 589 | + struct net_device *dev; |
---|
| 590 | + struct sk_buff *skb; |
---|
| 591 | + struct netlink_callback *cb; |
---|
| 592 | + int idx; |
---|
518 | 593 | }; |
---|
519 | 594 | |
---|
520 | | -static void ethsw_links_state_update(struct ethsw_core *ethsw) |
---|
| 595 | +static int dpaa2_switch_fdb_dump_nl(struct fdb_dump_entry *entry, |
---|
| 596 | + struct ethsw_dump_ctx *dump) |
---|
| 597 | +{ |
---|
| 598 | + int is_dynamic = entry->type & DPSW_FDB_ENTRY_DINAMIC; |
---|
| 599 | + u32 portid = NETLINK_CB(dump->cb->skb).portid; |
---|
| 600 | + u32 seq = dump->cb->nlh->nlmsg_seq; |
---|
| 601 | + struct nlmsghdr *nlh; |
---|
| 602 | + struct ndmsg *ndm; |
---|
| 603 | + |
---|
| 604 | + if (dump->idx < dump->cb->args[2]) |
---|
| 605 | + goto skip; |
---|
| 606 | + |
---|
| 607 | + nlh = nlmsg_put(dump->skb, portid, seq, RTM_NEWNEIGH, |
---|
| 608 | + sizeof(*ndm), NLM_F_MULTI); |
---|
| 609 | + if (!nlh) |
---|
| 610 | + return -EMSGSIZE; |
---|
| 611 | + |
---|
| 612 | + ndm = nlmsg_data(nlh); |
---|
| 613 | + ndm->ndm_family = AF_BRIDGE; |
---|
| 614 | + ndm->ndm_pad1 = 0; |
---|
| 615 | + ndm->ndm_pad2 = 0; |
---|
| 616 | + ndm->ndm_flags = NTF_SELF; |
---|
| 617 | + ndm->ndm_type = 0; |
---|
| 618 | + ndm->ndm_ifindex = dump->dev->ifindex; |
---|
| 619 | + ndm->ndm_state = is_dynamic ? NUD_REACHABLE : NUD_NOARP; |
---|
| 620 | + |
---|
| 621 | + if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, entry->mac_addr)) |
---|
| 622 | + goto nla_put_failure; |
---|
| 623 | + |
---|
| 624 | + nlmsg_end(dump->skb, nlh); |
---|
| 625 | + |
---|
| 626 | +skip: |
---|
| 627 | + dump->idx++; |
---|
| 628 | + return 0; |
---|
| 629 | + |
---|
| 630 | +nla_put_failure: |
---|
| 631 | + nlmsg_cancel(dump->skb, nlh); |
---|
| 632 | + return -EMSGSIZE; |
---|
| 633 | +} |
---|
| 634 | + |
---|
| 635 | +static int dpaa2_switch_port_fdb_valid_entry(struct fdb_dump_entry *entry, |
---|
| 636 | + struct ethsw_port_priv *port_priv) |
---|
| 637 | +{ |
---|
| 638 | + int idx = port_priv->idx; |
---|
| 639 | + int valid; |
---|
| 640 | + |
---|
| 641 | + if (entry->type & DPSW_FDB_ENTRY_TYPE_UNICAST) |
---|
| 642 | + valid = entry->if_info == port_priv->idx; |
---|
| 643 | + else |
---|
| 644 | + valid = entry->if_mask[idx / 8] & BIT(idx % 8); |
---|
| 645 | + |
---|
| 646 | + return valid; |
---|
| 647 | +} |
---|
| 648 | + |
---|
| 649 | +static int dpaa2_switch_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, |
---|
| 650 | + struct net_device *net_dev, |
---|
| 651 | + struct net_device *filter_dev, int *idx) |
---|
| 652 | +{ |
---|
| 653 | + struct ethsw_port_priv *port_priv = netdev_priv(net_dev); |
---|
| 654 | + struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
| 655 | + struct device *dev = net_dev->dev.parent; |
---|
| 656 | + struct fdb_dump_entry *fdb_entries; |
---|
| 657 | + struct fdb_dump_entry fdb_entry; |
---|
| 658 | + struct ethsw_dump_ctx dump = { |
---|
| 659 | + .dev = net_dev, |
---|
| 660 | + .skb = skb, |
---|
| 661 | + .cb = cb, |
---|
| 662 | + .idx = *idx, |
---|
| 663 | + }; |
---|
| 664 | + dma_addr_t fdb_dump_iova; |
---|
| 665 | + u16 num_fdb_entries; |
---|
| 666 | + u32 fdb_dump_size; |
---|
| 667 | + int err = 0, i; |
---|
| 668 | + u8 *dma_mem; |
---|
| 669 | + |
---|
| 670 | + fdb_dump_size = ethsw->sw_attr.max_fdb_entries * sizeof(fdb_entry); |
---|
| 671 | + dma_mem = kzalloc(fdb_dump_size, GFP_KERNEL); |
---|
| 672 | + if (!dma_mem) |
---|
| 673 | + return -ENOMEM; |
---|
| 674 | + |
---|
| 675 | + fdb_dump_iova = dma_map_single(dev, dma_mem, fdb_dump_size, |
---|
| 676 | + DMA_FROM_DEVICE); |
---|
| 677 | + if (dma_mapping_error(dev, fdb_dump_iova)) { |
---|
| 678 | + netdev_err(net_dev, "dma_map_single() failed\n"); |
---|
| 679 | + err = -ENOMEM; |
---|
| 680 | + goto err_map; |
---|
| 681 | + } |
---|
| 682 | + |
---|
| 683 | + err = dpsw_fdb_dump(ethsw->mc_io, 0, ethsw->dpsw_handle, 0, |
---|
| 684 | + fdb_dump_iova, fdb_dump_size, &num_fdb_entries); |
---|
| 685 | + if (err) { |
---|
| 686 | + netdev_err(net_dev, "dpsw_fdb_dump() = %d\n", err); |
---|
| 687 | + goto err_dump; |
---|
| 688 | + } |
---|
| 689 | + |
---|
| 690 | + dma_unmap_single(dev, fdb_dump_iova, fdb_dump_size, DMA_FROM_DEVICE); |
---|
| 691 | + |
---|
| 692 | + fdb_entries = (struct fdb_dump_entry *)dma_mem; |
---|
| 693 | + for (i = 0; i < num_fdb_entries; i++) { |
---|
| 694 | + fdb_entry = fdb_entries[i]; |
---|
| 695 | + |
---|
| 696 | + if (!dpaa2_switch_port_fdb_valid_entry(&fdb_entry, port_priv)) |
---|
| 697 | + continue; |
---|
| 698 | + |
---|
| 699 | + err = dpaa2_switch_fdb_dump_nl(&fdb_entry, &dump); |
---|
| 700 | + if (err) |
---|
| 701 | + goto end; |
---|
| 702 | + } |
---|
| 703 | + |
---|
| 704 | +end: |
---|
| 705 | + *idx = dump.idx; |
---|
| 706 | + |
---|
| 707 | + kfree(dma_mem); |
---|
| 708 | + |
---|
| 709 | + return 0; |
---|
| 710 | + |
---|
| 711 | +err_dump: |
---|
| 712 | + dma_unmap_single(dev, fdb_dump_iova, fdb_dump_size, DMA_TO_DEVICE); |
---|
| 713 | +err_map: |
---|
| 714 | + kfree(dma_mem); |
---|
| 715 | + return err; |
---|
| 716 | +} |
---|
| 717 | + |
---|
| 718 | +static int dpaa2_switch_port_set_mac_addr(struct ethsw_port_priv *port_priv) |
---|
| 719 | +{ |
---|
| 720 | + struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
| 721 | + struct net_device *net_dev = port_priv->netdev; |
---|
| 722 | + struct device *dev = net_dev->dev.parent; |
---|
| 723 | + u8 mac_addr[ETH_ALEN]; |
---|
| 724 | + int err; |
---|
| 725 | + |
---|
| 726 | + if (!(ethsw->features & ETHSW_FEATURE_MAC_ADDR)) |
---|
| 727 | + return 0; |
---|
| 728 | + |
---|
| 729 | + /* Get firmware address, if any */ |
---|
| 730 | + err = dpsw_if_get_port_mac_addr(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
| 731 | + port_priv->idx, mac_addr); |
---|
| 732 | + if (err) { |
---|
| 733 | + dev_err(dev, "dpsw_if_get_port_mac_addr() failed\n"); |
---|
| 734 | + return err; |
---|
| 735 | + } |
---|
| 736 | + |
---|
| 737 | + /* First check if firmware has any address configured by bootloader */ |
---|
| 738 | + if (!is_zero_ether_addr(mac_addr)) { |
---|
| 739 | + memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len); |
---|
| 740 | + } else { |
---|
| 741 | + /* No MAC address configured, fill in net_dev->dev_addr |
---|
| 742 | + * with a random one |
---|
| 743 | + */ |
---|
| 744 | + eth_hw_addr_random(net_dev); |
---|
| 745 | + dev_dbg_once(dev, "device(s) have all-zero hwaddr, replaced with random\n"); |
---|
| 746 | + |
---|
| 747 | + /* Override NET_ADDR_RANDOM set by eth_hw_addr_random(); for all |
---|
| 748 | + * practical purposes, this will be our "permanent" mac address, |
---|
| 749 | + * at least until the next reboot. This move will also permit |
---|
| 750 | + * register_netdevice() to properly fill up net_dev->perm_addr. |
---|
| 751 | + */ |
---|
| 752 | + net_dev->addr_assign_type = NET_ADDR_PERM; |
---|
| 753 | + } |
---|
| 754 | + |
---|
| 755 | + return 0; |
---|
| 756 | +} |
---|
| 757 | + |
---|
| 758 | +static const struct net_device_ops dpaa2_switch_port_ops = { |
---|
| 759 | + .ndo_open = dpaa2_switch_port_open, |
---|
| 760 | + .ndo_stop = dpaa2_switch_port_stop, |
---|
| 761 | + |
---|
| 762 | + .ndo_set_mac_address = eth_mac_addr, |
---|
| 763 | + .ndo_get_stats64 = dpaa2_switch_port_get_stats, |
---|
| 764 | + .ndo_change_mtu = dpaa2_switch_port_change_mtu, |
---|
| 765 | + .ndo_has_offload_stats = dpaa2_switch_port_has_offload_stats, |
---|
| 766 | + .ndo_get_offload_stats = dpaa2_switch_port_get_offload_stats, |
---|
| 767 | + .ndo_fdb_add = dpaa2_switch_port_fdb_add, |
---|
| 768 | + .ndo_fdb_del = dpaa2_switch_port_fdb_del, |
---|
| 769 | + .ndo_fdb_dump = dpaa2_switch_port_fdb_dump, |
---|
| 770 | + |
---|
| 771 | + .ndo_start_xmit = dpaa2_switch_port_dropframe, |
---|
| 772 | + .ndo_get_port_parent_id = dpaa2_switch_port_parent_id, |
---|
| 773 | + .ndo_get_phys_port_name = dpaa2_switch_port_get_phys_name, |
---|
| 774 | +}; |
---|
| 775 | + |
---|
| 776 | +static bool dpaa2_switch_port_dev_check(const struct net_device *netdev, |
---|
| 777 | + struct notifier_block *nb) |
---|
| 778 | +{ |
---|
| 779 | + struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
| 780 | + |
---|
| 781 | + if (netdev->netdev_ops == &dpaa2_switch_port_ops && |
---|
| 782 | + (!nb || &port_priv->ethsw_data->port_nb == nb || |
---|
| 783 | + &port_priv->ethsw_data->port_switchdev_nb == nb || |
---|
| 784 | + &port_priv->ethsw_data->port_switchdevb_nb == nb)) |
---|
| 785 | + return true; |
---|
| 786 | + |
---|
| 787 | + return false; |
---|
| 788 | +} |
---|
| 789 | + |
---|
| 790 | +static void dpaa2_switch_links_state_update(struct ethsw_core *ethsw) |
---|
521 | 791 | { |
---|
522 | 792 | int i; |
---|
523 | 793 | |
---|
524 | | - for (i = 0; i < ethsw->sw_attr.num_ifs; i++) |
---|
525 | | - port_carrier_state_sync(ethsw->ports[i]->netdev); |
---|
| 794 | + for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { |
---|
| 795 | + dpaa2_switch_port_carrier_state_sync(ethsw->ports[i]->netdev); |
---|
| 796 | + dpaa2_switch_port_set_mac_addr(ethsw->ports[i]); |
---|
| 797 | + } |
---|
526 | 798 | } |
---|
527 | 799 | |
---|
528 | | -static irqreturn_t ethsw_irq0_handler_thread(int irq_num, void *arg) |
---|
| 800 | +static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg) |
---|
529 | 801 | { |
---|
530 | 802 | struct device *dev = (struct device *)arg; |
---|
531 | 803 | struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
.. | .. |
---|
537 | 809 | err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
538 | 810 | DPSW_IRQ_INDEX_IF, &status); |
---|
539 | 811 | if (err) { |
---|
540 | | - dev_err(dev, "Can't get irq status (err %d)", err); |
---|
| 812 | + dev_err(dev, "Can't get irq status (err %d)\n", err); |
---|
541 | 813 | |
---|
542 | 814 | err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
543 | 815 | DPSW_IRQ_INDEX_IF, 0xFFFFFFFF); |
---|
544 | 816 | if (err) |
---|
545 | | - dev_err(dev, "Can't clear irq status (err %d)", err); |
---|
| 817 | + dev_err(dev, "Can't clear irq status (err %d)\n", err); |
---|
546 | 818 | goto out; |
---|
547 | 819 | } |
---|
548 | 820 | |
---|
549 | 821 | if (status & DPSW_IRQ_EVENT_LINK_CHANGED) |
---|
550 | | - ethsw_links_state_update(ethsw); |
---|
| 822 | + dpaa2_switch_links_state_update(ethsw); |
---|
551 | 823 | |
---|
552 | 824 | out: |
---|
553 | 825 | return IRQ_HANDLED; |
---|
554 | 826 | } |
---|
555 | 827 | |
---|
556 | | -static int ethsw_setup_irqs(struct fsl_mc_device *sw_dev) |
---|
| 828 | +static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev) |
---|
557 | 829 | { |
---|
558 | 830 | struct device *dev = &sw_dev->dev; |
---|
559 | 831 | struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
.. | .. |
---|
583 | 855 | |
---|
584 | 856 | err = devm_request_threaded_irq(dev, irq->msi_desc->irq, |
---|
585 | 857 | NULL, |
---|
586 | | - ethsw_irq0_handler_thread, |
---|
| 858 | + dpaa2_switch_irq0_handler_thread, |
---|
587 | 859 | IRQF_NO_SUSPEND | IRQF_ONESHOT, |
---|
588 | 860 | dev_name(dev), dev); |
---|
589 | 861 | if (err) { |
---|
590 | | - dev_err(dev, "devm_request_threaded_irq(): %d", err); |
---|
| 862 | + dev_err(dev, "devm_request_threaded_irq(): %d\n", err); |
---|
591 | 863 | goto free_irq; |
---|
592 | 864 | } |
---|
593 | 865 | |
---|
594 | 866 | err = dpsw_set_irq_mask(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
595 | 867 | DPSW_IRQ_INDEX_IF, mask); |
---|
596 | 868 | if (err) { |
---|
597 | | - dev_err(dev, "dpsw_set_irq_mask(): %d", err); |
---|
| 869 | + dev_err(dev, "dpsw_set_irq_mask(): %d\n", err); |
---|
598 | 870 | goto free_devm_irq; |
---|
599 | 871 | } |
---|
600 | 872 | |
---|
601 | 873 | err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
602 | 874 | DPSW_IRQ_INDEX_IF, 1); |
---|
603 | 875 | if (err) { |
---|
604 | | - dev_err(dev, "dpsw_set_irq_enable(): %d", err); |
---|
| 876 | + dev_err(dev, "dpsw_set_irq_enable(): %d\n", err); |
---|
605 | 877 | goto free_devm_irq; |
---|
606 | 878 | } |
---|
607 | 879 | |
---|
.. | .. |
---|
614 | 886 | return err; |
---|
615 | 887 | } |
---|
616 | 888 | |
---|
617 | | -static void ethsw_teardown_irqs(struct fsl_mc_device *sw_dev) |
---|
| 889 | +static void dpaa2_switch_teardown_irqs(struct fsl_mc_device *sw_dev) |
---|
618 | 890 | { |
---|
619 | 891 | struct device *dev = &sw_dev->dev; |
---|
620 | 892 | struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
.. | .. |
---|
628 | 900 | fsl_mc_free_irqs(sw_dev); |
---|
629 | 901 | } |
---|
630 | 902 | |
---|
631 | | -static int swdev_port_attr_get(struct net_device *netdev, |
---|
632 | | - struct switchdev_attr *attr) |
---|
633 | | -{ |
---|
634 | | - struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
635 | | - |
---|
636 | | - switch (attr->id) { |
---|
637 | | - case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: |
---|
638 | | - attr->u.ppid.id_len = 1; |
---|
639 | | - attr->u.ppid.id[0] = port_priv->ethsw_data->dev_id; |
---|
640 | | - break; |
---|
641 | | - case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: |
---|
642 | | - attr->u.brport_flags = |
---|
643 | | - (port_priv->ethsw_data->learning ? BR_LEARNING : 0) | |
---|
644 | | - (port_priv->flood ? BR_FLOOD : 0); |
---|
645 | | - break; |
---|
646 | | - case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT: |
---|
647 | | - attr->u.brport_flags_support = BR_LEARNING | BR_FLOOD; |
---|
648 | | - break; |
---|
649 | | - default: |
---|
650 | | - return -EOPNOTSUPP; |
---|
651 | | - } |
---|
652 | | - |
---|
653 | | - return 0; |
---|
654 | | -} |
---|
655 | | - |
---|
656 | | -static int port_attr_stp_state_set(struct net_device *netdev, |
---|
657 | | - struct switchdev_trans *trans, |
---|
658 | | - u8 state) |
---|
| 903 | +static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev, |
---|
| 904 | + struct switchdev_trans *trans, |
---|
| 905 | + u8 state) |
---|
659 | 906 | { |
---|
660 | 907 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
661 | 908 | |
---|
662 | 909 | if (switchdev_trans_ph_prepare(trans)) |
---|
663 | 910 | return 0; |
---|
664 | 911 | |
---|
665 | | - return ethsw_port_set_stp_state(port_priv, state); |
---|
| 912 | + return dpaa2_switch_port_set_stp_state(port_priv, state); |
---|
666 | 913 | } |
---|
667 | 914 | |
---|
668 | | -static int port_attr_br_flags_set(struct net_device *netdev, |
---|
669 | | - struct switchdev_trans *trans, |
---|
670 | | - unsigned long flags) |
---|
| 915 | +static int dpaa2_switch_port_attr_br_flags_pre_set(struct net_device *netdev, |
---|
| 916 | + struct switchdev_trans *trans, |
---|
| 917 | + unsigned long flags) |
---|
| 918 | +{ |
---|
| 919 | + if (flags & ~(BR_LEARNING | BR_FLOOD)) |
---|
| 920 | + return -EINVAL; |
---|
| 921 | + |
---|
| 922 | + return 0; |
---|
| 923 | +} |
---|
| 924 | + |
---|
| 925 | +static int dpaa2_switch_port_attr_br_flags_set(struct net_device *netdev, |
---|
| 926 | + struct switchdev_trans *trans, |
---|
| 927 | + unsigned long flags) |
---|
671 | 928 | { |
---|
672 | 929 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
673 | 930 | int err = 0; |
---|
.. | .. |
---|
676 | 933 | return 0; |
---|
677 | 934 | |
---|
678 | 935 | /* Learning is enabled per switch */ |
---|
679 | | - err = ethsw_set_learning(port_priv->ethsw_data, flags & BR_LEARNING); |
---|
| 936 | + err = dpaa2_switch_set_learning(port_priv->ethsw_data, |
---|
| 937 | + !!(flags & BR_LEARNING)); |
---|
680 | 938 | if (err) |
---|
681 | 939 | goto exit; |
---|
682 | 940 | |
---|
683 | | - err = ethsw_port_set_flood(port_priv, flags & BR_FLOOD); |
---|
| 941 | + err = dpaa2_switch_port_set_flood(port_priv, !!(flags & BR_FLOOD)); |
---|
684 | 942 | |
---|
685 | 943 | exit: |
---|
686 | 944 | return err; |
---|
687 | 945 | } |
---|
688 | 946 | |
---|
689 | | -static int swdev_port_attr_set(struct net_device *netdev, |
---|
690 | | - const struct switchdev_attr *attr, |
---|
691 | | - struct switchdev_trans *trans) |
---|
| 947 | +static int dpaa2_switch_port_attr_set(struct net_device *netdev, |
---|
| 948 | + const struct switchdev_attr *attr, |
---|
| 949 | + struct switchdev_trans *trans) |
---|
692 | 950 | { |
---|
693 | 951 | int err = 0; |
---|
694 | 952 | |
---|
695 | 953 | switch (attr->id) { |
---|
696 | 954 | case SWITCHDEV_ATTR_ID_PORT_STP_STATE: |
---|
697 | | - err = port_attr_stp_state_set(netdev, trans, |
---|
698 | | - attr->u.stp_state); |
---|
| 955 | + err = dpaa2_switch_port_attr_stp_state_set(netdev, trans, |
---|
| 956 | + attr->u.stp_state); |
---|
| 957 | + break; |
---|
| 958 | + case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS: |
---|
| 959 | + err = dpaa2_switch_port_attr_br_flags_pre_set(netdev, trans, |
---|
| 960 | + attr->u.brport_flags); |
---|
699 | 961 | break; |
---|
700 | 962 | case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: |
---|
701 | | - err = port_attr_br_flags_set(netdev, trans, |
---|
702 | | - attr->u.brport_flags); |
---|
| 963 | + err = dpaa2_switch_port_attr_br_flags_set(netdev, trans, |
---|
| 964 | + attr->u.brport_flags); |
---|
703 | 965 | break; |
---|
704 | 966 | case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: |
---|
705 | 967 | /* VLANs are supported by default */ |
---|
.. | .. |
---|
712 | 974 | return err; |
---|
713 | 975 | } |
---|
714 | 976 | |
---|
715 | | -static int port_vlans_add(struct net_device *netdev, |
---|
716 | | - const struct switchdev_obj_port_vlan *vlan, |
---|
717 | | - struct switchdev_trans *trans) |
---|
| 977 | +static int dpaa2_switch_port_vlans_add(struct net_device *netdev, |
---|
| 978 | + const struct switchdev_obj_port_vlan *vlan, |
---|
| 979 | + struct switchdev_trans *trans) |
---|
718 | 980 | { |
---|
719 | 981 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
720 | | - int vid, err; |
---|
| 982 | + struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
| 983 | + struct dpsw_attr *attr = ðsw->sw_attr; |
---|
| 984 | + int vid, err = 0, new_vlans = 0; |
---|
721 | 985 | |
---|
722 | | - if (netif_is_bridge_master(vlan->obj.orig_dev)) |
---|
723 | | - return -EOPNOTSUPP; |
---|
| 986 | + if (switchdev_trans_ph_prepare(trans)) { |
---|
| 987 | + for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) |
---|
| 988 | + if (!port_priv->ethsw_data->vlans[vid]) |
---|
| 989 | + new_vlans++; |
---|
724 | 990 | |
---|
725 | | - if (switchdev_trans_ph_prepare(trans)) |
---|
| 991 | + /* Check if there is space for a new VLAN */ |
---|
| 992 | + err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
| 993 | + ðsw->sw_attr); |
---|
| 994 | + if (err) { |
---|
| 995 | + netdev_err(netdev, "dpsw_get_attributes err %d\n", err); |
---|
| 996 | + return err; |
---|
| 997 | + } |
---|
| 998 | + if (attr->max_vlans - attr->num_vlans < new_vlans) |
---|
| 999 | + return -ENOSPC; |
---|
| 1000 | + |
---|
726 | 1001 | return 0; |
---|
| 1002 | + } |
---|
727 | 1003 | |
---|
728 | 1004 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { |
---|
729 | 1005 | if (!port_priv->ethsw_data->vlans[vid]) { |
---|
730 | 1006 | /* this is a new VLAN */ |
---|
731 | | - err = ethsw_add_vlan(port_priv->ethsw_data, vid); |
---|
| 1007 | + err = dpaa2_switch_add_vlan(port_priv->ethsw_data, vid); |
---|
732 | 1008 | if (err) |
---|
733 | 1009 | return err; |
---|
734 | 1010 | |
---|
735 | 1011 | port_priv->ethsw_data->vlans[vid] |= ETHSW_VLAN_GLOBAL; |
---|
736 | 1012 | } |
---|
737 | | - err = ethsw_port_add_vlan(port_priv, vid, vlan->flags); |
---|
| 1013 | + err = dpaa2_switch_port_add_vlan(port_priv, vid, vlan->flags); |
---|
738 | 1014 | if (err) |
---|
739 | 1015 | break; |
---|
740 | 1016 | } |
---|
.. | .. |
---|
742 | 1018 | return err; |
---|
743 | 1019 | } |
---|
744 | 1020 | |
---|
745 | | -static int port_lookup_address(struct net_device *netdev, int is_uc, |
---|
746 | | - const unsigned char *addr) |
---|
| 1021 | +static int dpaa2_switch_port_lookup_address(struct net_device *netdev, int is_uc, |
---|
| 1022 | + const unsigned char *addr) |
---|
747 | 1023 | { |
---|
748 | 1024 | struct netdev_hw_addr_list *list = (is_uc) ? &netdev->uc : &netdev->mc; |
---|
749 | 1025 | struct netdev_hw_addr *ha; |
---|
.. | .. |
---|
759 | 1035 | return 0; |
---|
760 | 1036 | } |
---|
761 | 1037 | |
---|
762 | | -static int port_mdb_add(struct net_device *netdev, |
---|
763 | | - const struct switchdev_obj_port_mdb *mdb, |
---|
764 | | - struct switchdev_trans *trans) |
---|
| 1038 | +static int dpaa2_switch_port_mdb_add(struct net_device *netdev, |
---|
| 1039 | + const struct switchdev_obj_port_mdb *mdb, |
---|
| 1040 | + struct switchdev_trans *trans) |
---|
765 | 1041 | { |
---|
766 | 1042 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
767 | 1043 | int err; |
---|
.. | .. |
---|
770 | 1046 | return 0; |
---|
771 | 1047 | |
---|
772 | 1048 | /* Check if address is already set on this port */ |
---|
773 | | - if (port_lookup_address(netdev, 0, mdb->addr)) |
---|
| 1049 | + if (dpaa2_switch_port_lookup_address(netdev, 0, mdb->addr)) |
---|
774 | 1050 | return -EEXIST; |
---|
775 | 1051 | |
---|
776 | | - err = ethsw_port_fdb_add_mc(port_priv, mdb->addr); |
---|
| 1052 | + err = dpaa2_switch_port_fdb_add_mc(port_priv, mdb->addr); |
---|
777 | 1053 | if (err) |
---|
778 | 1054 | return err; |
---|
779 | 1055 | |
---|
780 | 1056 | err = dev_mc_add(netdev, mdb->addr); |
---|
781 | 1057 | if (err) { |
---|
782 | 1058 | netdev_err(netdev, "dev_mc_add err %d\n", err); |
---|
783 | | - ethsw_port_fdb_del_mc(port_priv, mdb->addr); |
---|
| 1059 | + dpaa2_switch_port_fdb_del_mc(port_priv, mdb->addr); |
---|
784 | 1060 | } |
---|
785 | 1061 | |
---|
786 | 1062 | return err; |
---|
787 | 1063 | } |
---|
788 | 1064 | |
---|
789 | | -static int swdev_port_obj_add(struct net_device *netdev, |
---|
790 | | - const struct switchdev_obj *obj, |
---|
791 | | - struct switchdev_trans *trans) |
---|
| 1065 | +static int dpaa2_switch_port_obj_add(struct net_device *netdev, |
---|
| 1066 | + const struct switchdev_obj *obj, |
---|
| 1067 | + struct switchdev_trans *trans) |
---|
792 | 1068 | { |
---|
793 | 1069 | int err; |
---|
794 | 1070 | |
---|
795 | 1071 | switch (obj->id) { |
---|
796 | 1072 | case SWITCHDEV_OBJ_ID_PORT_VLAN: |
---|
797 | | - err = port_vlans_add(netdev, |
---|
798 | | - SWITCHDEV_OBJ_PORT_VLAN(obj), |
---|
799 | | - trans); |
---|
| 1073 | + err = dpaa2_switch_port_vlans_add(netdev, |
---|
| 1074 | + SWITCHDEV_OBJ_PORT_VLAN(obj), |
---|
| 1075 | + trans); |
---|
800 | 1076 | break; |
---|
801 | 1077 | case SWITCHDEV_OBJ_ID_PORT_MDB: |
---|
802 | | - err = port_mdb_add(netdev, |
---|
803 | | - SWITCHDEV_OBJ_PORT_MDB(obj), |
---|
804 | | - trans); |
---|
| 1078 | + err = dpaa2_switch_port_mdb_add(netdev, |
---|
| 1079 | + SWITCHDEV_OBJ_PORT_MDB(obj), |
---|
| 1080 | + trans); |
---|
805 | 1081 | break; |
---|
806 | 1082 | default: |
---|
807 | 1083 | err = -EOPNOTSUPP; |
---|
.. | .. |
---|
811 | 1087 | return err; |
---|
812 | 1088 | } |
---|
813 | 1089 | |
---|
814 | | -static int ethsw_port_del_vlan(struct ethsw_port_priv *port_priv, u16 vid) |
---|
| 1090 | +static int dpaa2_switch_port_del_vlan(struct ethsw_port_priv *port_priv, u16 vid) |
---|
815 | 1091 | { |
---|
816 | 1092 | struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
817 | 1093 | struct net_device *netdev = port_priv->netdev; |
---|
.. | .. |
---|
822 | 1098 | return -ENOENT; |
---|
823 | 1099 | |
---|
824 | 1100 | if (port_priv->vlans[vid] & ETHSW_VLAN_PVID) { |
---|
825 | | - err = ethsw_port_set_pvid(port_priv, 0); |
---|
| 1101 | + err = dpaa2_switch_port_set_pvid(port_priv, 0); |
---|
826 | 1102 | if (err) |
---|
827 | 1103 | return err; |
---|
828 | 1104 | } |
---|
.. | .. |
---|
860 | 1136 | |
---|
861 | 1137 | ethsw->vlans[vid] &= ~ETHSW_VLAN_GLOBAL; |
---|
862 | 1138 | |
---|
863 | | - err = ethsw_dellink_switch(ethsw, vid); |
---|
| 1139 | + err = dpaa2_switch_dellink(ethsw, vid); |
---|
864 | 1140 | if (err) |
---|
865 | 1141 | return err; |
---|
866 | 1142 | } |
---|
.. | .. |
---|
868 | 1144 | return 0; |
---|
869 | 1145 | } |
---|
870 | 1146 | |
---|
871 | | -static int port_vlans_del(struct net_device *netdev, |
---|
872 | | - const struct switchdev_obj_port_vlan *vlan) |
---|
| 1147 | +static int dpaa2_switch_port_vlans_del(struct net_device *netdev, |
---|
| 1148 | + const struct switchdev_obj_port_vlan *vlan) |
---|
873 | 1149 | { |
---|
874 | 1150 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
875 | | - int vid, err; |
---|
| 1151 | + int vid, err = 0; |
---|
876 | 1152 | |
---|
877 | 1153 | if (netif_is_bridge_master(vlan->obj.orig_dev)) |
---|
878 | 1154 | return -EOPNOTSUPP; |
---|
879 | 1155 | |
---|
880 | 1156 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { |
---|
881 | | - err = ethsw_port_del_vlan(port_priv, vid); |
---|
| 1157 | + err = dpaa2_switch_port_del_vlan(port_priv, vid); |
---|
882 | 1158 | if (err) |
---|
883 | 1159 | break; |
---|
884 | 1160 | } |
---|
.. | .. |
---|
886 | 1162 | return err; |
---|
887 | 1163 | } |
---|
888 | 1164 | |
---|
889 | | -static int port_mdb_del(struct net_device *netdev, |
---|
890 | | - const struct switchdev_obj_port_mdb *mdb) |
---|
| 1165 | +static int dpaa2_switch_port_mdb_del(struct net_device *netdev, |
---|
| 1166 | + const struct switchdev_obj_port_mdb *mdb) |
---|
891 | 1167 | { |
---|
892 | 1168 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
893 | 1169 | int err; |
---|
894 | 1170 | |
---|
895 | | - if (!port_lookup_address(netdev, 0, mdb->addr)) |
---|
| 1171 | + if (!dpaa2_switch_port_lookup_address(netdev, 0, mdb->addr)) |
---|
896 | 1172 | return -ENOENT; |
---|
897 | 1173 | |
---|
898 | | - err = ethsw_port_fdb_del_mc(port_priv, mdb->addr); |
---|
| 1174 | + err = dpaa2_switch_port_fdb_del_mc(port_priv, mdb->addr); |
---|
899 | 1175 | if (err) |
---|
900 | 1176 | return err; |
---|
901 | 1177 | |
---|
.. | .. |
---|
908 | 1184 | return err; |
---|
909 | 1185 | } |
---|
910 | 1186 | |
---|
911 | | -static int swdev_port_obj_del(struct net_device *netdev, |
---|
912 | | - const struct switchdev_obj *obj) |
---|
| 1187 | +static int dpaa2_switch_port_obj_del(struct net_device *netdev, |
---|
| 1188 | + const struct switchdev_obj *obj) |
---|
913 | 1189 | { |
---|
914 | 1190 | int err; |
---|
915 | 1191 | |
---|
916 | 1192 | switch (obj->id) { |
---|
917 | 1193 | case SWITCHDEV_OBJ_ID_PORT_VLAN: |
---|
918 | | - err = port_vlans_del(netdev, SWITCHDEV_OBJ_PORT_VLAN(obj)); |
---|
| 1194 | + err = dpaa2_switch_port_vlans_del(netdev, SWITCHDEV_OBJ_PORT_VLAN(obj)); |
---|
919 | 1195 | break; |
---|
920 | 1196 | case SWITCHDEV_OBJ_ID_PORT_MDB: |
---|
921 | | - err = port_mdb_del(netdev, SWITCHDEV_OBJ_PORT_MDB(obj)); |
---|
| 1197 | + err = dpaa2_switch_port_mdb_del(netdev, SWITCHDEV_OBJ_PORT_MDB(obj)); |
---|
922 | 1198 | break; |
---|
923 | 1199 | default: |
---|
924 | 1200 | err = -EOPNOTSUPP; |
---|
.. | .. |
---|
927 | 1203 | return err; |
---|
928 | 1204 | } |
---|
929 | 1205 | |
---|
930 | | -static const struct switchdev_ops ethsw_port_switchdev_ops = { |
---|
931 | | - .switchdev_port_attr_get = swdev_port_attr_get, |
---|
932 | | - .switchdev_port_attr_set = swdev_port_attr_set, |
---|
933 | | - .switchdev_port_obj_add = swdev_port_obj_add, |
---|
934 | | - .switchdev_port_obj_del = swdev_port_obj_del, |
---|
935 | | -}; |
---|
| 1206 | +static int dpaa2_switch_port_attr_set_event(struct net_device *netdev, |
---|
| 1207 | + struct switchdev_notifier_port_attr_info |
---|
| 1208 | + *port_attr_info) |
---|
| 1209 | +{ |
---|
| 1210 | + int err; |
---|
| 1211 | + |
---|
| 1212 | + err = dpaa2_switch_port_attr_set(netdev, port_attr_info->attr, |
---|
| 1213 | + port_attr_info->trans); |
---|
| 1214 | + |
---|
| 1215 | + port_attr_info->handled = true; |
---|
| 1216 | + return notifier_from_errno(err); |
---|
| 1217 | +} |
---|
936 | 1218 | |
---|
937 | 1219 | /* For the moment, only flood setting needs to be updated */ |
---|
938 | | -static int port_bridge_join(struct net_device *netdev, |
---|
939 | | - struct net_device *upper_dev) |
---|
| 1220 | +static int dpaa2_switch_port_bridge_join(struct net_device *netdev, |
---|
| 1221 | + struct net_device *upper_dev) |
---|
940 | 1222 | { |
---|
941 | 1223 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
942 | 1224 | struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
| 1225 | + struct ethsw_port_priv *other_port_priv; |
---|
| 1226 | + struct net_device *other_dev; |
---|
| 1227 | + struct list_head *iter; |
---|
943 | 1228 | int i, err; |
---|
944 | 1229 | |
---|
945 | 1230 | for (i = 0; i < ethsw->sw_attr.num_ifs; i++) |
---|
946 | 1231 | if (ethsw->ports[i]->bridge_dev && |
---|
947 | 1232 | (ethsw->ports[i]->bridge_dev != upper_dev)) { |
---|
948 | 1233 | netdev_err(netdev, |
---|
949 | | - "Another switch port is connected to %s\n", |
---|
950 | | - ethsw->ports[i]->bridge_dev->name); |
---|
| 1234 | + "Only one bridge supported per DPSW object!\n"); |
---|
951 | 1235 | return -EINVAL; |
---|
952 | 1236 | } |
---|
953 | 1237 | |
---|
| 1238 | + netdev_for_each_lower_dev(upper_dev, other_dev, iter) { |
---|
| 1239 | + if (!dpaa2_switch_port_dev_check(other_dev, NULL)) |
---|
| 1240 | + continue; |
---|
| 1241 | + |
---|
| 1242 | + other_port_priv = netdev_priv(other_dev); |
---|
| 1243 | + if (other_port_priv->ethsw_data != port_priv->ethsw_data) { |
---|
| 1244 | + netdev_err(netdev, |
---|
| 1245 | + "Interface from a different DPSW is in the bridge already!\n"); |
---|
| 1246 | + return -EINVAL; |
---|
| 1247 | + } |
---|
| 1248 | + } |
---|
| 1249 | + |
---|
954 | 1250 | /* Enable flooding */ |
---|
955 | | - err = ethsw_port_set_flood(port_priv, 1); |
---|
| 1251 | + err = dpaa2_switch_port_set_flood(port_priv, 1); |
---|
956 | 1252 | if (!err) |
---|
957 | 1253 | port_priv->bridge_dev = upper_dev; |
---|
958 | 1254 | |
---|
959 | 1255 | return err; |
---|
960 | 1256 | } |
---|
961 | 1257 | |
---|
962 | | -static int port_bridge_leave(struct net_device *netdev) |
---|
| 1258 | +static int dpaa2_switch_port_bridge_leave(struct net_device *netdev) |
---|
963 | 1259 | { |
---|
964 | 1260 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
---|
965 | 1261 | int err; |
---|
966 | 1262 | |
---|
967 | 1263 | /* Disable flooding */ |
---|
968 | | - err = ethsw_port_set_flood(port_priv, 0); |
---|
| 1264 | + err = dpaa2_switch_port_set_flood(port_priv, 0); |
---|
969 | 1265 | if (!err) |
---|
970 | 1266 | port_priv->bridge_dev = NULL; |
---|
971 | 1267 | |
---|
972 | 1268 | return err; |
---|
973 | 1269 | } |
---|
974 | 1270 | |
---|
975 | | -static int port_netdevice_event(struct notifier_block *unused, |
---|
976 | | - unsigned long event, void *ptr) |
---|
| 1271 | +static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb, |
---|
| 1272 | + unsigned long event, void *ptr) |
---|
977 | 1273 | { |
---|
978 | 1274 | struct net_device *netdev = netdev_notifier_info_to_dev(ptr); |
---|
979 | 1275 | struct netdev_notifier_changeupper_info *info = ptr; |
---|
980 | 1276 | struct net_device *upper_dev; |
---|
981 | 1277 | int err = 0; |
---|
982 | 1278 | |
---|
983 | | - if (netdev->netdev_ops != ðsw_port_ops) |
---|
| 1279 | + if (!dpaa2_switch_port_dev_check(netdev, nb)) |
---|
984 | 1280 | return NOTIFY_DONE; |
---|
985 | 1281 | |
---|
986 | 1282 | /* Handle just upper dev link/unlink for the moment */ |
---|
.. | .. |
---|
988 | 1284 | upper_dev = info->upper_dev; |
---|
989 | 1285 | if (netif_is_bridge_master(upper_dev)) { |
---|
990 | 1286 | if (info->linking) |
---|
991 | | - err = port_bridge_join(netdev, upper_dev); |
---|
| 1287 | + err = dpaa2_switch_port_bridge_join(netdev, upper_dev); |
---|
992 | 1288 | else |
---|
993 | | - err = port_bridge_leave(netdev); |
---|
| 1289 | + err = dpaa2_switch_port_bridge_leave(netdev); |
---|
994 | 1290 | } |
---|
995 | 1291 | } |
---|
996 | 1292 | |
---|
997 | 1293 | return notifier_from_errno(err); |
---|
998 | 1294 | } |
---|
999 | | - |
---|
1000 | | -static struct notifier_block port_nb __read_mostly = { |
---|
1001 | | - .notifier_call = port_netdevice_event, |
---|
1002 | | -}; |
---|
1003 | 1295 | |
---|
1004 | 1296 | struct ethsw_switchdev_event_work { |
---|
1005 | 1297 | struct work_struct work; |
---|
.. | .. |
---|
1008 | 1300 | unsigned long event; |
---|
1009 | 1301 | }; |
---|
1010 | 1302 | |
---|
1011 | | -static void ethsw_switchdev_event_work(struct work_struct *work) |
---|
| 1303 | +static void dpaa2_switch_event_work(struct work_struct *work) |
---|
1012 | 1304 | { |
---|
1013 | 1305 | struct ethsw_switchdev_event_work *switchdev_work = |
---|
1014 | 1306 | container_of(work, struct ethsw_switchdev_event_work, work); |
---|
1015 | 1307 | struct net_device *dev = switchdev_work->dev; |
---|
1016 | 1308 | struct switchdev_notifier_fdb_info *fdb_info; |
---|
1017 | | - struct ethsw_port_priv *port_priv; |
---|
| 1309 | + int err; |
---|
1018 | 1310 | |
---|
1019 | 1311 | rtnl_lock(); |
---|
1020 | | - port_priv = netdev_priv(dev); |
---|
1021 | 1312 | fdb_info = &switchdev_work->fdb_info; |
---|
1022 | 1313 | |
---|
1023 | 1314 | switch (switchdev_work->event) { |
---|
1024 | 1315 | case SWITCHDEV_FDB_ADD_TO_DEVICE: |
---|
| 1316 | + if (!fdb_info->added_by_user) |
---|
| 1317 | + break; |
---|
1025 | 1318 | if (is_unicast_ether_addr(fdb_info->addr)) |
---|
1026 | | - ethsw_port_fdb_add_uc(netdev_priv(dev), fdb_info->addr); |
---|
| 1319 | + err = dpaa2_switch_port_fdb_add_uc(netdev_priv(dev), |
---|
| 1320 | + fdb_info->addr); |
---|
1027 | 1321 | else |
---|
1028 | | - ethsw_port_fdb_add_mc(netdev_priv(dev), fdb_info->addr); |
---|
| 1322 | + err = dpaa2_switch_port_fdb_add_mc(netdev_priv(dev), |
---|
| 1323 | + fdb_info->addr); |
---|
| 1324 | + if (err) |
---|
| 1325 | + break; |
---|
| 1326 | + fdb_info->offloaded = true; |
---|
| 1327 | + call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, |
---|
| 1328 | + &fdb_info->info, NULL); |
---|
1029 | 1329 | break; |
---|
1030 | 1330 | case SWITCHDEV_FDB_DEL_TO_DEVICE: |
---|
| 1331 | + if (!fdb_info->added_by_user) |
---|
| 1332 | + break; |
---|
1031 | 1333 | if (is_unicast_ether_addr(fdb_info->addr)) |
---|
1032 | | - ethsw_port_fdb_del_uc(netdev_priv(dev), fdb_info->addr); |
---|
| 1334 | + dpaa2_switch_port_fdb_del_uc(netdev_priv(dev), fdb_info->addr); |
---|
1033 | 1335 | else |
---|
1034 | | - ethsw_port_fdb_del_mc(netdev_priv(dev), fdb_info->addr); |
---|
| 1336 | + dpaa2_switch_port_fdb_del_mc(netdev_priv(dev), fdb_info->addr); |
---|
1035 | 1337 | break; |
---|
1036 | 1338 | } |
---|
1037 | 1339 | |
---|
.. | .. |
---|
1042 | 1344 | } |
---|
1043 | 1345 | |
---|
1044 | 1346 | /* Called under rcu_read_lock() */ |
---|
1045 | | -static int port_switchdev_event(struct notifier_block *unused, |
---|
1046 | | - unsigned long event, void *ptr) |
---|
| 1347 | +static int dpaa2_switch_port_event(struct notifier_block *nb, |
---|
| 1348 | + unsigned long event, void *ptr) |
---|
1047 | 1349 | { |
---|
1048 | 1350 | struct net_device *dev = switchdev_notifier_info_to_dev(ptr); |
---|
| 1351 | + struct ethsw_port_priv *port_priv = netdev_priv(dev); |
---|
1049 | 1352 | struct ethsw_switchdev_event_work *switchdev_work; |
---|
1050 | 1353 | struct switchdev_notifier_fdb_info *fdb_info = ptr; |
---|
| 1354 | + struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
| 1355 | + |
---|
| 1356 | + if (!dpaa2_switch_port_dev_check(dev, nb)) |
---|
| 1357 | + return NOTIFY_DONE; |
---|
| 1358 | + |
---|
| 1359 | + if (event == SWITCHDEV_PORT_ATTR_SET) |
---|
| 1360 | + return dpaa2_switch_port_attr_set_event(dev, ptr); |
---|
1051 | 1361 | |
---|
1052 | 1362 | switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); |
---|
1053 | 1363 | if (!switchdev_work) |
---|
1054 | 1364 | return NOTIFY_BAD; |
---|
1055 | 1365 | |
---|
1056 | | - INIT_WORK(&switchdev_work->work, ethsw_switchdev_event_work); |
---|
| 1366 | + INIT_WORK(&switchdev_work->work, dpaa2_switch_event_work); |
---|
1057 | 1367 | switchdev_work->dev = dev; |
---|
1058 | 1368 | switchdev_work->event = event; |
---|
1059 | 1369 | |
---|
.. | .. |
---|
1077 | 1387 | return NOTIFY_DONE; |
---|
1078 | 1388 | } |
---|
1079 | 1389 | |
---|
1080 | | - queue_work(ethsw_owq, &switchdev_work->work); |
---|
| 1390 | + queue_work(ethsw->workqueue, &switchdev_work->work); |
---|
1081 | 1391 | |
---|
1082 | 1392 | return NOTIFY_DONE; |
---|
1083 | 1393 | |
---|
.. | .. |
---|
1086 | 1396 | return NOTIFY_BAD; |
---|
1087 | 1397 | } |
---|
1088 | 1398 | |
---|
1089 | | -static struct notifier_block port_switchdev_nb = { |
---|
1090 | | - .notifier_call = port_switchdev_event, |
---|
1091 | | -}; |
---|
1092 | | - |
---|
1093 | | -static int ethsw_register_notifier(struct device *dev) |
---|
| 1399 | +static int dpaa2_switch_port_obj_event(unsigned long event, |
---|
| 1400 | + struct net_device *netdev, |
---|
| 1401 | + struct switchdev_notifier_port_obj_info *port_obj_info) |
---|
1094 | 1402 | { |
---|
| 1403 | + int err = -EOPNOTSUPP; |
---|
| 1404 | + |
---|
| 1405 | + switch (event) { |
---|
| 1406 | + case SWITCHDEV_PORT_OBJ_ADD: |
---|
| 1407 | + err = dpaa2_switch_port_obj_add(netdev, port_obj_info->obj, |
---|
| 1408 | + port_obj_info->trans); |
---|
| 1409 | + break; |
---|
| 1410 | + case SWITCHDEV_PORT_OBJ_DEL: |
---|
| 1411 | + err = dpaa2_switch_port_obj_del(netdev, port_obj_info->obj); |
---|
| 1412 | + break; |
---|
| 1413 | + } |
---|
| 1414 | + |
---|
| 1415 | + port_obj_info->handled = true; |
---|
| 1416 | + return notifier_from_errno(err); |
---|
| 1417 | +} |
---|
| 1418 | + |
---|
| 1419 | +static int dpaa2_switch_port_blocking_event(struct notifier_block *nb, |
---|
| 1420 | + unsigned long event, void *ptr) |
---|
| 1421 | +{ |
---|
| 1422 | + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); |
---|
| 1423 | + |
---|
| 1424 | + if (!dpaa2_switch_port_dev_check(dev, nb)) |
---|
| 1425 | + return NOTIFY_DONE; |
---|
| 1426 | + |
---|
| 1427 | + switch (event) { |
---|
| 1428 | + case SWITCHDEV_PORT_OBJ_ADD: |
---|
| 1429 | + case SWITCHDEV_PORT_OBJ_DEL: |
---|
| 1430 | + return dpaa2_switch_port_obj_event(event, dev, ptr); |
---|
| 1431 | + case SWITCHDEV_PORT_ATTR_SET: |
---|
| 1432 | + return dpaa2_switch_port_attr_set_event(dev, ptr); |
---|
| 1433 | + } |
---|
| 1434 | + |
---|
| 1435 | + return NOTIFY_DONE; |
---|
| 1436 | +} |
---|
| 1437 | + |
---|
| 1438 | +static int dpaa2_switch_register_notifier(struct device *dev) |
---|
| 1439 | +{ |
---|
| 1440 | + struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
1095 | 1441 | int err; |
---|
1096 | 1442 | |
---|
1097 | | - err = register_netdevice_notifier(&port_nb); |
---|
| 1443 | + ethsw->port_nb.notifier_call = dpaa2_switch_port_netdevice_event; |
---|
| 1444 | + err = register_netdevice_notifier(ðsw->port_nb); |
---|
1098 | 1445 | if (err) { |
---|
1099 | 1446 | dev_err(dev, "Failed to register netdev notifier\n"); |
---|
1100 | 1447 | return err; |
---|
1101 | 1448 | } |
---|
1102 | 1449 | |
---|
1103 | | - err = register_switchdev_notifier(&port_switchdev_nb); |
---|
| 1450 | + ethsw->port_switchdev_nb.notifier_call = dpaa2_switch_port_event; |
---|
| 1451 | + err = register_switchdev_notifier(ðsw->port_switchdev_nb); |
---|
1104 | 1452 | if (err) { |
---|
1105 | 1453 | dev_err(dev, "Failed to register switchdev notifier\n"); |
---|
1106 | 1454 | goto err_switchdev_nb; |
---|
1107 | 1455 | } |
---|
1108 | 1456 | |
---|
| 1457 | + ethsw->port_switchdevb_nb.notifier_call = dpaa2_switch_port_blocking_event; |
---|
| 1458 | + err = register_switchdev_blocking_notifier(ðsw->port_switchdevb_nb); |
---|
| 1459 | + if (err) { |
---|
| 1460 | + dev_err(dev, "Failed to register switchdev blocking notifier\n"); |
---|
| 1461 | + goto err_switchdev_blocking_nb; |
---|
| 1462 | + } |
---|
| 1463 | + |
---|
1109 | 1464 | return 0; |
---|
1110 | 1465 | |
---|
| 1466 | +err_switchdev_blocking_nb: |
---|
| 1467 | + unregister_switchdev_notifier(ðsw->port_switchdev_nb); |
---|
1111 | 1468 | err_switchdev_nb: |
---|
1112 | | - unregister_netdevice_notifier(&port_nb); |
---|
| 1469 | + unregister_netdevice_notifier(ðsw->port_nb); |
---|
1113 | 1470 | return err; |
---|
1114 | 1471 | } |
---|
1115 | 1472 | |
---|
1116 | | -static int ethsw_open(struct ethsw_core *ethsw) |
---|
| 1473 | +static void dpaa2_switch_detect_features(struct ethsw_core *ethsw) |
---|
1117 | 1474 | { |
---|
1118 | | - struct ethsw_port_priv *port_priv = NULL; |
---|
1119 | | - int i, err; |
---|
| 1475 | + ethsw->features = 0; |
---|
1120 | 1476 | |
---|
1121 | | - err = dpsw_enable(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1122 | | - if (err) { |
---|
1123 | | - dev_err(ethsw->dev, "dpsw_enable err %d\n", err); |
---|
1124 | | - return err; |
---|
1125 | | - } |
---|
1126 | | - |
---|
1127 | | - for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { |
---|
1128 | | - port_priv = ethsw->ports[i]; |
---|
1129 | | - err = dev_open(port_priv->netdev); |
---|
1130 | | - if (err) { |
---|
1131 | | - netdev_err(port_priv->netdev, "dev_open err %d\n", err); |
---|
1132 | | - return err; |
---|
1133 | | - } |
---|
1134 | | - } |
---|
1135 | | - |
---|
1136 | | - return 0; |
---|
| 1477 | + if (ethsw->major > 8 || (ethsw->major == 8 && ethsw->minor >= 6)) |
---|
| 1478 | + ethsw->features |= ETHSW_FEATURE_MAC_ADDR; |
---|
1137 | 1479 | } |
---|
1138 | 1480 | |
---|
1139 | | -static int ethsw_stop(struct ethsw_core *ethsw) |
---|
1140 | | -{ |
---|
1141 | | - struct ethsw_port_priv *port_priv = NULL; |
---|
1142 | | - int i, err; |
---|
1143 | | - |
---|
1144 | | - for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { |
---|
1145 | | - port_priv = ethsw->ports[i]; |
---|
1146 | | - dev_close(port_priv->netdev); |
---|
1147 | | - } |
---|
1148 | | - |
---|
1149 | | - err = dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1150 | | - if (err) { |
---|
1151 | | - dev_err(ethsw->dev, "dpsw_disable err %d\n", err); |
---|
1152 | | - return err; |
---|
1153 | | - } |
---|
1154 | | - |
---|
1155 | | - return 0; |
---|
1156 | | -} |
---|
1157 | | - |
---|
1158 | | -static int ethsw_init(struct fsl_mc_device *sw_dev) |
---|
| 1481 | +static int dpaa2_switch_init(struct fsl_mc_device *sw_dev) |
---|
1159 | 1482 | { |
---|
1160 | 1483 | struct device *dev = &sw_dev->dev; |
---|
1161 | 1484 | struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
1162 | | - u16 version_major, version_minor, i; |
---|
1163 | 1485 | struct dpsw_stp_cfg stp_cfg; |
---|
1164 | 1486 | int err; |
---|
| 1487 | + u16 i; |
---|
1165 | 1488 | |
---|
1166 | 1489 | ethsw->dev_id = sw_dev->obj_desc.id; |
---|
1167 | 1490 | |
---|
.. | .. |
---|
1179 | 1502 | } |
---|
1180 | 1503 | |
---|
1181 | 1504 | err = dpsw_get_api_version(ethsw->mc_io, 0, |
---|
1182 | | - &version_major, |
---|
1183 | | - &version_minor); |
---|
| 1505 | + ðsw->major, |
---|
| 1506 | + ðsw->minor); |
---|
1184 | 1507 | if (err) { |
---|
1185 | 1508 | dev_err(dev, "dpsw_get_api_version err %d\n", err); |
---|
1186 | 1509 | goto err_close; |
---|
1187 | 1510 | } |
---|
1188 | 1511 | |
---|
1189 | 1512 | /* Minimum supported DPSW version check */ |
---|
1190 | | - if (version_major < DPSW_MIN_VER_MAJOR || |
---|
1191 | | - (version_major == DPSW_MIN_VER_MAJOR && |
---|
1192 | | - version_minor < DPSW_MIN_VER_MINOR)) { |
---|
| 1513 | + if (ethsw->major < DPSW_MIN_VER_MAJOR || |
---|
| 1514 | + (ethsw->major == DPSW_MIN_VER_MAJOR && |
---|
| 1515 | + ethsw->minor < DPSW_MIN_VER_MINOR)) { |
---|
1193 | 1516 | dev_err(dev, "DPSW version %d:%d not supported. Use %d.%d or greater.\n", |
---|
1194 | | - version_major, |
---|
1195 | | - version_minor, |
---|
| 1517 | + ethsw->major, |
---|
| 1518 | + ethsw->minor, |
---|
1196 | 1519 | DPSW_MIN_VER_MAJOR, DPSW_MIN_VER_MINOR); |
---|
1197 | 1520 | err = -ENOTSUPP; |
---|
1198 | 1521 | goto err_close; |
---|
1199 | 1522 | } |
---|
| 1523 | + |
---|
| 1524 | + dpaa2_switch_detect_features(ethsw); |
---|
1200 | 1525 | |
---|
1201 | 1526 | err = dpsw_reset(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1202 | 1527 | if (err) { |
---|
.. | .. |
---|
1233 | 1558 | } |
---|
1234 | 1559 | } |
---|
1235 | 1560 | |
---|
1236 | | - ethsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM, |
---|
1237 | | - "ethsw"); |
---|
1238 | | - if (!ethsw_owq) { |
---|
| 1561 | + ethsw->workqueue = alloc_ordered_workqueue("%s_%d_ordered", |
---|
| 1562 | + WQ_MEM_RECLAIM, "ethsw", |
---|
| 1563 | + ethsw->sw_attr.id); |
---|
| 1564 | + if (!ethsw->workqueue) { |
---|
1239 | 1565 | err = -ENOMEM; |
---|
1240 | 1566 | goto err_close; |
---|
1241 | 1567 | } |
---|
1242 | 1568 | |
---|
1243 | | - err = ethsw_register_notifier(dev); |
---|
| 1569 | + err = dpaa2_switch_register_notifier(dev); |
---|
1244 | 1570 | if (err) |
---|
1245 | 1571 | goto err_destroy_ordered_workqueue; |
---|
1246 | 1572 | |
---|
1247 | 1573 | return 0; |
---|
1248 | 1574 | |
---|
1249 | 1575 | err_destroy_ordered_workqueue: |
---|
1250 | | - destroy_workqueue(ethsw_owq); |
---|
| 1576 | + destroy_workqueue(ethsw->workqueue); |
---|
1251 | 1577 | |
---|
1252 | 1578 | err_close: |
---|
1253 | 1579 | dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1254 | 1580 | return err; |
---|
1255 | 1581 | } |
---|
1256 | 1582 | |
---|
1257 | | -static int ethsw_port_init(struct ethsw_port_priv *port_priv, u16 port) |
---|
| 1583 | +static int dpaa2_switch_port_init(struct ethsw_port_priv *port_priv, u16 port) |
---|
1258 | 1584 | { |
---|
1259 | | - const char def_mcast[ETH_ALEN] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0x01}; |
---|
1260 | 1585 | struct net_device *netdev = port_priv->netdev; |
---|
1261 | 1586 | struct ethsw_core *ethsw = port_priv->ethsw_data; |
---|
1262 | 1587 | struct dpsw_vlan_if_cfg vcfg; |
---|
.. | .. |
---|
1276 | 1601 | return err; |
---|
1277 | 1602 | } |
---|
1278 | 1603 | |
---|
1279 | | - err = ethsw_port_set_pvid(port_priv, 0); |
---|
| 1604 | + err = dpaa2_switch_port_set_pvid(port_priv, 0); |
---|
1280 | 1605 | if (err) |
---|
1281 | 1606 | return err; |
---|
1282 | 1607 | |
---|
1283 | 1608 | err = dpsw_vlan_remove_if(ethsw->mc_io, 0, ethsw->dpsw_handle, |
---|
1284 | 1609 | DEFAULT_VLAN_ID, &vcfg); |
---|
1285 | | - if (err) { |
---|
| 1610 | + if (err) |
---|
1286 | 1611 | netdev_err(netdev, "dpsw_vlan_remove_if err %d\n", err); |
---|
1287 | | - return err; |
---|
1288 | | - } |
---|
1289 | | - |
---|
1290 | | - err = ethsw_port_fdb_add_mc(port_priv, def_mcast); |
---|
1291 | 1612 | |
---|
1292 | 1613 | return err; |
---|
1293 | 1614 | } |
---|
1294 | 1615 | |
---|
1295 | | -static void ethsw_unregister_notifier(struct device *dev) |
---|
| 1616 | +static void dpaa2_switch_unregister_notifier(struct device *dev) |
---|
1296 | 1617 | { |
---|
| 1618 | + struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
| 1619 | + struct notifier_block *nb; |
---|
1297 | 1620 | int err; |
---|
1298 | 1621 | |
---|
1299 | | - err = unregister_switchdev_notifier(&port_switchdev_nb); |
---|
| 1622 | + nb = ðsw->port_switchdevb_nb; |
---|
| 1623 | + err = unregister_switchdev_blocking_notifier(nb); |
---|
| 1624 | + if (err) |
---|
| 1625 | + dev_err(dev, |
---|
| 1626 | + "Failed to unregister switchdev blocking notifier (%d)\n", |
---|
| 1627 | + err); |
---|
| 1628 | + |
---|
| 1629 | + err = unregister_switchdev_notifier(ðsw->port_switchdev_nb); |
---|
1300 | 1630 | if (err) |
---|
1301 | 1631 | dev_err(dev, |
---|
1302 | 1632 | "Failed to unregister switchdev notifier (%d)\n", err); |
---|
1303 | 1633 | |
---|
1304 | | - err = unregister_netdevice_notifier(&port_nb); |
---|
| 1634 | + err = unregister_netdevice_notifier(ðsw->port_nb); |
---|
1305 | 1635 | if (err) |
---|
1306 | 1636 | dev_err(dev, |
---|
1307 | 1637 | "Failed to unregister netdev notifier (%d)\n", err); |
---|
1308 | 1638 | } |
---|
1309 | 1639 | |
---|
1310 | | -static void ethsw_takedown(struct fsl_mc_device *sw_dev) |
---|
| 1640 | +static void dpaa2_switch_takedown(struct fsl_mc_device *sw_dev) |
---|
1311 | 1641 | { |
---|
1312 | 1642 | struct device *dev = &sw_dev->dev; |
---|
1313 | 1643 | struct ethsw_core *ethsw = dev_get_drvdata(dev); |
---|
1314 | 1644 | int err; |
---|
1315 | 1645 | |
---|
1316 | | - ethsw_unregister_notifier(dev); |
---|
| 1646 | + dpaa2_switch_unregister_notifier(dev); |
---|
1317 | 1647 | |
---|
1318 | 1648 | err = dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1319 | 1649 | if (err) |
---|
1320 | 1650 | dev_warn(dev, "dpsw_close err %d\n", err); |
---|
1321 | 1651 | } |
---|
1322 | 1652 | |
---|
1323 | | -static int ethsw_remove(struct fsl_mc_device *sw_dev) |
---|
| 1653 | +static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev) |
---|
1324 | 1654 | { |
---|
1325 | 1655 | struct ethsw_port_priv *port_priv; |
---|
1326 | 1656 | struct ethsw_core *ethsw; |
---|
.. | .. |
---|
1330 | 1660 | dev = &sw_dev->dev; |
---|
1331 | 1661 | ethsw = dev_get_drvdata(dev); |
---|
1332 | 1662 | |
---|
1333 | | - ethsw_teardown_irqs(sw_dev); |
---|
| 1663 | + dpaa2_switch_teardown_irqs(sw_dev); |
---|
1334 | 1664 | |
---|
1335 | | - destroy_workqueue(ethsw_owq); |
---|
1336 | | - |
---|
1337 | | - rtnl_lock(); |
---|
1338 | | - ethsw_stop(ethsw); |
---|
1339 | | - rtnl_unlock(); |
---|
| 1665 | + dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1340 | 1666 | |
---|
1341 | 1667 | for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { |
---|
1342 | 1668 | port_priv = ethsw->ports[i]; |
---|
.. | .. |
---|
1345 | 1671 | } |
---|
1346 | 1672 | kfree(ethsw->ports); |
---|
1347 | 1673 | |
---|
1348 | | - ethsw_takedown(sw_dev); |
---|
| 1674 | + dpaa2_switch_takedown(sw_dev); |
---|
| 1675 | + |
---|
| 1676 | + destroy_workqueue(ethsw->workqueue); |
---|
| 1677 | + |
---|
1349 | 1678 | fsl_mc_portal_free(ethsw->mc_io); |
---|
1350 | 1679 | |
---|
1351 | 1680 | kfree(ethsw); |
---|
.. | .. |
---|
1355 | 1684 | return 0; |
---|
1356 | 1685 | } |
---|
1357 | 1686 | |
---|
1358 | | -static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx) |
---|
| 1687 | +static int dpaa2_switch_probe_port(struct ethsw_core *ethsw, |
---|
| 1688 | + u16 port_idx) |
---|
1359 | 1689 | { |
---|
1360 | 1690 | struct ethsw_port_priv *port_priv; |
---|
1361 | 1691 | struct device *dev = ethsw->dev; |
---|
.. | .. |
---|
1379 | 1709 | port_priv->flood = true; |
---|
1380 | 1710 | |
---|
1381 | 1711 | SET_NETDEV_DEV(port_netdev, dev); |
---|
1382 | | - port_netdev->netdev_ops = ðsw_port_ops; |
---|
1383 | | - port_netdev->ethtool_ops = ðsw_port_ethtool_ops; |
---|
1384 | | - port_netdev->switchdev_ops = ðsw_port_switchdev_ops; |
---|
| 1712 | + port_netdev->netdev_ops = &dpaa2_switch_port_ops; |
---|
| 1713 | + port_netdev->ethtool_ops = &dpaa2_switch_port_ethtool_ops; |
---|
1385 | 1714 | |
---|
1386 | 1715 | /* Set MTU limits */ |
---|
1387 | 1716 | port_netdev->min_mtu = ETH_MIN_MTU; |
---|
1388 | 1717 | port_netdev->max_mtu = ETHSW_MAX_FRAME_LENGTH; |
---|
1389 | 1718 | |
---|
| 1719 | + err = dpaa2_switch_port_init(port_priv, port_idx); |
---|
| 1720 | + if (err) |
---|
| 1721 | + goto err_port_probe; |
---|
| 1722 | + |
---|
| 1723 | + err = dpaa2_switch_port_set_mac_addr(port_priv); |
---|
| 1724 | + if (err) |
---|
| 1725 | + goto err_port_probe; |
---|
| 1726 | + |
---|
1390 | 1727 | err = register_netdev(port_netdev); |
---|
1391 | 1728 | if (err < 0) { |
---|
1392 | 1729 | dev_err(dev, "register_netdev error %d\n", err); |
---|
1393 | | - free_netdev(port_netdev); |
---|
1394 | | - return err; |
---|
| 1730 | + goto err_port_probe; |
---|
1395 | 1731 | } |
---|
1396 | 1732 | |
---|
1397 | 1733 | ethsw->ports[port_idx] = port_priv; |
---|
1398 | 1734 | |
---|
1399 | | - return ethsw_port_init(port_priv, port_idx); |
---|
| 1735 | + return 0; |
---|
| 1736 | + |
---|
| 1737 | +err_port_probe: |
---|
| 1738 | + free_netdev(port_netdev); |
---|
| 1739 | + |
---|
| 1740 | + return err; |
---|
1400 | 1741 | } |
---|
1401 | 1742 | |
---|
1402 | | -static int ethsw_probe(struct fsl_mc_device *sw_dev) |
---|
| 1743 | +static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev) |
---|
1403 | 1744 | { |
---|
1404 | 1745 | struct device *dev = &sw_dev->dev; |
---|
1405 | 1746 | struct ethsw_core *ethsw; |
---|
.. | .. |
---|
1414 | 1755 | ethsw->dev = dev; |
---|
1415 | 1756 | dev_set_drvdata(dev, ethsw); |
---|
1416 | 1757 | |
---|
1417 | | - err = fsl_mc_portal_allocate(sw_dev, 0, ðsw->mc_io); |
---|
| 1758 | + err = fsl_mc_portal_allocate(sw_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL, |
---|
| 1759 | + ðsw->mc_io); |
---|
1418 | 1760 | if (err) { |
---|
1419 | 1761 | if (err == -ENXIO) |
---|
1420 | 1762 | err = -EPROBE_DEFER; |
---|
.. | .. |
---|
1423 | 1765 | goto err_free_drvdata; |
---|
1424 | 1766 | } |
---|
1425 | 1767 | |
---|
1426 | | - err = ethsw_init(sw_dev); |
---|
| 1768 | + err = dpaa2_switch_init(sw_dev); |
---|
1427 | 1769 | if (err) |
---|
1428 | 1770 | goto err_free_cmdport; |
---|
1429 | 1771 | |
---|
.. | .. |
---|
1441 | 1783 | } |
---|
1442 | 1784 | |
---|
1443 | 1785 | for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { |
---|
1444 | | - err = ethsw_probe_port(ethsw, i); |
---|
| 1786 | + err = dpaa2_switch_probe_port(ethsw, i); |
---|
1445 | 1787 | if (err) |
---|
1446 | 1788 | goto err_free_ports; |
---|
1447 | 1789 | } |
---|
1448 | 1790 | |
---|
1449 | | - /* Switch starts up enabled */ |
---|
1450 | | - rtnl_lock(); |
---|
1451 | | - err = ethsw_open(ethsw); |
---|
1452 | | - rtnl_unlock(); |
---|
1453 | | - if (err) |
---|
| 1791 | + err = dpsw_enable(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
| 1792 | + if (err) { |
---|
| 1793 | + dev_err(ethsw->dev, "dpsw_enable err %d\n", err); |
---|
1454 | 1794 | goto err_free_ports; |
---|
| 1795 | + } |
---|
| 1796 | + |
---|
| 1797 | + /* Make sure the switch ports are disabled at probe time */ |
---|
| 1798 | + for (i = 0; i < ethsw->sw_attr.num_ifs; i++) |
---|
| 1799 | + dpsw_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle, i); |
---|
1455 | 1800 | |
---|
1456 | 1801 | /* Setup IRQs */ |
---|
1457 | | - err = ethsw_setup_irqs(sw_dev); |
---|
| 1802 | + err = dpaa2_switch_setup_irqs(sw_dev); |
---|
1458 | 1803 | if (err) |
---|
1459 | 1804 | goto err_stop; |
---|
1460 | 1805 | |
---|
.. | .. |
---|
1462 | 1807 | return 0; |
---|
1463 | 1808 | |
---|
1464 | 1809 | err_stop: |
---|
1465 | | - rtnl_lock(); |
---|
1466 | | - ethsw_stop(ethsw); |
---|
1467 | | - rtnl_unlock(); |
---|
| 1810 | + dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); |
---|
1468 | 1811 | |
---|
1469 | 1812 | err_free_ports: |
---|
1470 | 1813 | /* Cleanup registered ports only */ |
---|
.. | .. |
---|
1475 | 1818 | kfree(ethsw->ports); |
---|
1476 | 1819 | |
---|
1477 | 1820 | err_takedown: |
---|
1478 | | - ethsw_takedown(sw_dev); |
---|
| 1821 | + dpaa2_switch_takedown(sw_dev); |
---|
1479 | 1822 | |
---|
1480 | 1823 | err_free_cmdport: |
---|
1481 | 1824 | fsl_mc_portal_free(ethsw->mc_io); |
---|
.. | .. |
---|
1487 | 1830 | return err; |
---|
1488 | 1831 | } |
---|
1489 | 1832 | |
---|
1490 | | -static const struct fsl_mc_device_id ethsw_match_id_table[] = { |
---|
| 1833 | +static const struct fsl_mc_device_id dpaa2_switch_match_id_table[] = { |
---|
1491 | 1834 | { |
---|
1492 | 1835 | .vendor = FSL_MC_VENDOR_FREESCALE, |
---|
1493 | 1836 | .obj_type = "dpsw", |
---|
1494 | 1837 | }, |
---|
1495 | 1838 | { .vendor = 0x0 } |
---|
1496 | 1839 | }; |
---|
1497 | | -MODULE_DEVICE_TABLE(fslmc, ethsw_match_id_table); |
---|
| 1840 | +MODULE_DEVICE_TABLE(fslmc, dpaa2_switch_match_id_table); |
---|
1498 | 1841 | |
---|
1499 | | -static struct fsl_mc_driver eth_sw_drv = { |
---|
| 1842 | +static struct fsl_mc_driver dpaa2_switch_drv = { |
---|
1500 | 1843 | .driver = { |
---|
1501 | 1844 | .name = KBUILD_MODNAME, |
---|
1502 | 1845 | .owner = THIS_MODULE, |
---|
1503 | 1846 | }, |
---|
1504 | | - .probe = ethsw_probe, |
---|
1505 | | - .remove = ethsw_remove, |
---|
1506 | | - .match_id_table = ethsw_match_id_table |
---|
| 1847 | + .probe = dpaa2_switch_probe, |
---|
| 1848 | + .remove = dpaa2_switch_remove, |
---|
| 1849 | + .match_id_table = dpaa2_switch_match_id_table |
---|
1507 | 1850 | }; |
---|
1508 | 1851 | |
---|
1509 | | -module_fsl_mc_driver(eth_sw_drv); |
---|
| 1852 | +module_fsl_mc_driver(dpaa2_switch_drv); |
---|
1510 | 1853 | |
---|
1511 | 1854 | MODULE_LICENSE("GPL v2"); |
---|
1512 | 1855 | MODULE_DESCRIPTION("DPAA2 Ethernet Switch Driver"); |
---|