]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - net/dsa/legacy.c
net: dsa: get master device at port parsing time
[mirror_ubuntu-bionic-kernel.git] / net / dsa / legacy.c
CommitLineData
a6a71f19
VD
1/*
2 * net/dsa/legacy.c - Hardware switch handling
3 * Copyright (c) 2008-2009 Marvell Semiconductor
4 * Copyright (c) 2013 Florian Fainelli <florian@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/device.h>
13#include <linux/list.h>
14#include <linux/platform_device.h>
15#include <linux/slab.h>
16#include <linux/module.h>
17#include <linux/of.h>
18#include <linux/of_mdio.h>
19#include <linux/of_platform.h>
20#include <linux/of_net.h>
21#include <linux/netdevice.h>
22#include <linux/sysfs.h>
23#include <linux/phy_fixed.h>
24#include <linux/etherdevice.h>
ea5dd34b 25
a6a71f19
VD
26#include "dsa_priv.h"
27
28/* switch driver registration ***********************************************/
29static DEFINE_MUTEX(dsa_switch_drivers_mutex);
30static LIST_HEAD(dsa_switch_drivers);
31
32void register_switch_driver(struct dsa_switch_driver *drv)
33{
34 mutex_lock(&dsa_switch_drivers_mutex);
35 list_add_tail(&drv->list, &dsa_switch_drivers);
36 mutex_unlock(&dsa_switch_drivers_mutex);
37}
38EXPORT_SYMBOL_GPL(register_switch_driver);
39
40void unregister_switch_driver(struct dsa_switch_driver *drv)
41{
42 mutex_lock(&dsa_switch_drivers_mutex);
43 list_del_init(&drv->list);
44 mutex_unlock(&dsa_switch_drivers_mutex);
45}
46EXPORT_SYMBOL_GPL(unregister_switch_driver);
47
48static const struct dsa_switch_ops *
49dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
50 const char **_name, void **priv)
51{
52 const struct dsa_switch_ops *ret;
53 struct list_head *list;
54 const char *name;
55
56 ret = NULL;
57 name = NULL;
58
59 mutex_lock(&dsa_switch_drivers_mutex);
60 list_for_each(list, &dsa_switch_drivers) {
61 const struct dsa_switch_ops *ops;
62 struct dsa_switch_driver *drv;
63
64 drv = list_entry(list, struct dsa_switch_driver, list);
65 ops = drv->ops;
66
67 name = ops->probe(parent, host_dev, sw_addr, priv);
68 if (name != NULL) {
69 ret = ops;
70 break;
71 }
72 }
73 mutex_unlock(&dsa_switch_drivers_mutex);
74
75 *_name = name;
76
77 return ret;
78}
79
80/* basic switch operations **************************************************/
206e41fe 81static int dsa_cpu_dsa_setups(struct dsa_switch *ds)
a6a71f19 82{
a6a71f19
VD
83 int ret, port;
84
85 for (port = 0; port < ds->num_ports; port++) {
86 if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
87 continue;
88
57ab1ca2 89 ret = dsa_port_fixed_link_register_of(&ds->ports[port]);
a6a71f19
VD
90 if (ret)
91 return ret;
92 }
93 return 0;
94}
95
206e41fe
VD
96static int dsa_switch_setup_one(struct dsa_switch *ds,
97 struct net_device *master)
a6a71f19
VD
98{
99 const struct dsa_switch_ops *ops = ds->ops;
100 struct dsa_switch_tree *dst = ds->dst;
101 struct dsa_chip_data *cd = ds->cd;
102 bool valid_name_found = false;
103 int index = ds->index;
057cad2c 104 struct dsa_port *dp;
a6a71f19
VD
105 int i, ret;
106
107 /*
108 * Validate supplied switch configuration.
109 */
110 for (i = 0; i < ds->num_ports; i++) {
111 char *name;
112
057cad2c
VD
113 dp = &ds->ports[i];
114
a6a71f19
VD
115 name = cd->port_names[i];
116 if (name == NULL)
117 continue;
118
119 if (!strcmp(name, "cpu")) {
8b0d3ea5 120 if (dst->cpu_dp) {
6d3c8c0d 121 netdev_err(master,
a6a71f19
VD
122 "multiple cpu ports?!\n");
123 return -EINVAL;
124 }
8b0d3ea5 125 dst->cpu_dp = &ds->ports[i];
f8b8b1cd 126 dst->cpu_dp->master = master;
057cad2c 127 dp->type = DSA_PORT_TYPE_CPU;
a6a71f19 128 } else if (!strcmp(name, "dsa")) {
057cad2c 129 dp->type = DSA_PORT_TYPE_DSA;
a6a71f19 130 } else {
057cad2c 131 dp->type = DSA_PORT_TYPE_USER;
a6a71f19
VD
132 }
133 valid_name_found = true;
134 }
135
136 if (!valid_name_found && i == ds->num_ports)
137 return -EINVAL;
138
139 /* Make the built-in MII bus mask match the number of ports,
140 * switch drivers can override this later
141 */
02bc6e54 142 ds->phys_mii_mask |= dsa_user_ports(ds);
a6a71f19
VD
143
144 /*
145 * If the CPU connects to this switch, set the switch tree
146 * tagging protocol to the preferred tagging format of this
147 * switch.
148 */
8b0d3ea5 149 if (dst->cpu_dp->ds == ds) {
62fc9587 150 const struct dsa_device_ops *tag_ops;
a6a71f19
VD
151 enum dsa_tag_protocol tag_protocol;
152
153 tag_protocol = ops->get_tag_protocol(ds);
62fc9587
VD
154 tag_ops = dsa_resolve_tag_protocol(tag_protocol);
155 if (IS_ERR(tag_ops))
156 return PTR_ERR(tag_ops);
a6a71f19 157
15240248 158 dst->cpu_dp->tag_ops = tag_ops;
3e41f93b
VD
159
160 /* Few copies for faster access in master receive hot path */
161 dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
3e41f93b 162 dst->cpu_dp->dst = dst;
a6a71f19
VD
163 }
164
165 memcpy(ds->rtable, cd->rtable, sizeof(ds->rtable));
166
167 /*
168 * Do basic register setup.
169 */
170 ret = ops->setup(ds);
171 if (ret < 0)
172 return ret;
173
174 ret = dsa_switch_register_notifier(ds);
175 if (ret)
176 return ret;
177
a6a71f19 178 if (!ds->slave_mii_bus && ops->phy_read) {
206e41fe 179 ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
a6a71f19
VD
180 if (!ds->slave_mii_bus)
181 return -ENOMEM;
182 dsa_slave_mii_bus_init(ds);
183
184 ret = mdiobus_register(ds->slave_mii_bus);
185 if (ret < 0)
186 return ret;
187 }
188
189 /*
190 * Create network devices for physical switch ports.
191 */
192 for (i = 0; i < ds->num_ports; i++) {
193 ds->ports[i].dn = cd->port_dn[i];
06d4d450 194 ds->ports[i].cpu_dp = dst->cpu_dp;
a6a71f19 195
4a5b85ff 196 if (dsa_is_user_port(ds, i))
a6a71f19
VD
197 continue;
198
4cfbf09c 199 ret = dsa_slave_create(&ds->ports[i], cd->port_names[i]);
a6a71f19 200 if (ret < 0)
6d3c8c0d 201 netdev_err(master, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
a6a71f19
VD
202 index, i, cd->port_names[i], ret);
203 }
204
205 /* Perform configuration of the CPU and DSA ports */
206e41fe 206 ret = dsa_cpu_dsa_setups(ds);
a6a71f19 207 if (ret < 0)
6d3c8c0d 208 netdev_err(master, "[%d] : can't configure CPU and DSA ports\n",
a6a71f19
VD
209 index);
210
a6a71f19
VD
211 return 0;
212}
213
214static struct dsa_switch *
06d4d450
FF
215dsa_switch_setup(struct dsa_switch_tree *dst, struct net_device *master,
216 int index, struct device *parent, struct device *host_dev)
a6a71f19
VD
217{
218 struct dsa_chip_data *cd = dst->pd->chip + index;
219 const struct dsa_switch_ops *ops;
220 struct dsa_switch *ds;
221 int ret;
222 const char *name;
223 void *priv;
224
225 /*
226 * Probe for switch model.
227 */
228 ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv);
229 if (!ops) {
6d3c8c0d 230 netdev_err(master, "[%d]: could not detect attached switch\n",
a6a71f19
VD
231 index);
232 return ERR_PTR(-EINVAL);
233 }
6d3c8c0d 234 netdev_info(master, "[%d]: detected a %s switch\n",
a6a71f19
VD
235 index, name);
236
237
238 /*
239 * Allocate and initialise switch state.
240 */
241 ds = dsa_switch_alloc(parent, DSA_MAX_PORTS);
242 if (!ds)
243 return ERR_PTR(-ENOMEM);
244
245 ds->dst = dst;
246 ds->index = index;
247 ds->cd = cd;
248 ds->ops = ops;
249 ds->priv = priv;
250
206e41fe 251 ret = dsa_switch_setup_one(ds, master);
a6a71f19
VD
252 if (ret)
253 return ERR_PTR(ret);
254
255 return ds;
256}
257
258static void dsa_switch_destroy(struct dsa_switch *ds)
259{
260 int port;
261
262 /* Destroy network devices for physical switch ports. */
263 for (port = 0; port < ds->num_ports; port++) {
4a5b85ff 264 if (!dsa_is_user_port(ds, port))
a6a71f19
VD
265 continue;
266
f8b8b1cd 267 if (!ds->ports[port].slave)
a6a71f19
VD
268 continue;
269
f8b8b1cd 270 dsa_slave_destroy(ds->ports[port].slave);
a6a71f19
VD
271 }
272
273 /* Disable configuration of the CPU and DSA ports */
274 for (port = 0; port < ds->num_ports; port++) {
275 if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
276 continue;
57ab1ca2 277 dsa_port_fixed_link_unregister_of(&ds->ports[port]);
a6a71f19
VD
278 }
279
280 if (ds->slave_mii_bus && ds->ops->phy_read)
281 mdiobus_unregister(ds->slave_mii_bus);
282
283 dsa_switch_unregister_notifier(ds);
284}
285
a6a71f19
VD
286/* platform driver init and cleanup *****************************************/
287static int dev_is_class(struct device *dev, void *class)
288{
289 if (dev->class != NULL && !strcmp(dev->class->name, class))
290 return 1;
291
292 return 0;
293}
294
295static struct device *dev_find_class(struct device *parent, char *class)
296{
297 if (dev_is_class(parent, class)) {
298 get_device(parent);
299 return parent;
300 }
301
302 return device_find_child(parent, class, dev_is_class);
303}
304
305struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
306{
307 struct device *d;
308
309 d = dev_find_class(dev, "mdio_bus");
310 if (d != NULL) {
311 struct mii_bus *bus;
312
313 bus = to_mii_bus(d);
314 put_device(d);
315
316 return bus;
317 }
318
319 return NULL;
320}
321EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus);
322
323#ifdef CONFIG_OF
324static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
325 struct dsa_chip_data *cd,
326 int chip_index, int port_index,
327 struct device_node *link)
328{
329 const __be32 *reg;
330 int link_sw_addr;
331 struct device_node *parent_sw;
332 int len;
333
334 parent_sw = of_get_parent(link);
335 if (!parent_sw)
336 return -EINVAL;
337
338 reg = of_get_property(parent_sw, "reg", &len);
339 if (!reg || (len != sizeof(*reg) * 2))
340 return -EINVAL;
341
342 /*
343 * Get the destination switch number from the second field of its 'reg'
344 * property, i.e. for "reg = <0x19 1>" sw_addr is '1'.
345 */
346 link_sw_addr = be32_to_cpup(reg + 1);
347
348 if (link_sw_addr >= pd->nr_chips)
349 return -EINVAL;
350
351 cd->rtable[link_sw_addr] = port_index;
352
353 return 0;
354}
355
356static int dsa_of_probe_links(struct dsa_platform_data *pd,
357 struct dsa_chip_data *cd,
358 int chip_index, int port_index,
359 struct device_node *port,
360 const char *port_name)
361{
362 struct device_node *link;
363 int link_index;
364 int ret;
365
366 for (link_index = 0;; link_index++) {
367 link = of_parse_phandle(port, "link", link_index);
368 if (!link)
369 break;
370
371 if (!strcmp(port_name, "dsa") && pd->nr_chips > 1) {
372 ret = dsa_of_setup_routing_table(pd, cd, chip_index,
373 port_index, link);
374 if (ret)
375 return ret;
376 }
377 }
378 return 0;
379}
380
381static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
382{
383 int i;
384 int port_index;
385
386 for (i = 0; i < pd->nr_chips; i++) {
387 port_index = 0;
388 while (port_index < DSA_MAX_PORTS) {
389 kfree(pd->chip[i].port_names[port_index]);
390 port_index++;
391 }
392
393 /* Drop our reference to the MDIO bus device */
394 if (pd->chip[i].host_dev)
395 put_device(pd->chip[i].host_dev);
396 }
397 kfree(pd->chip);
398}
399
400static int dsa_of_probe(struct device *dev)
401{
402 struct device_node *np = dev->of_node;
403 struct device_node *child, *mdio, *ethernet, *port;
404 struct mii_bus *mdio_bus, *mdio_bus_switch;
405 struct net_device *ethernet_dev;
406 struct dsa_platform_data *pd;
407 struct dsa_chip_data *cd;
408 const char *port_name;
409 int chip_index, port_index;
410 const unsigned int *sw_addr, *port_reg;
411 u32 eeprom_len;
412 int ret;
413
414 mdio = of_parse_phandle(np, "dsa,mii-bus", 0);
415 if (!mdio)
416 return -EINVAL;
417
418 mdio_bus = of_mdio_find_bus(mdio);
419 if (!mdio_bus)
420 return -EPROBE_DEFER;
421
422 ethernet = of_parse_phandle(np, "dsa,ethernet", 0);
423 if (!ethernet) {
424 ret = -EINVAL;
425 goto out_put_mdio;
426 }
427
428 ethernet_dev = of_find_net_device_by_node(ethernet);
429 if (!ethernet_dev) {
430 ret = -EPROBE_DEFER;
431 goto out_put_mdio;
432 }
433
434 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
435 if (!pd) {
436 ret = -ENOMEM;
437 goto out_put_ethernet;
438 }
439
440 dev->platform_data = pd;
441 pd->of_netdev = ethernet_dev;
442 pd->nr_chips = of_get_available_child_count(np);
443 if (pd->nr_chips > DSA_MAX_SWITCHES)
444 pd->nr_chips = DSA_MAX_SWITCHES;
445
446 pd->chip = kcalloc(pd->nr_chips, sizeof(struct dsa_chip_data),
447 GFP_KERNEL);
448 if (!pd->chip) {
449 ret = -ENOMEM;
450 goto out_free;
451 }
452
453 chip_index = -1;
454 for_each_available_child_of_node(np, child) {
455 int i;
456
457 chip_index++;
458 cd = &pd->chip[chip_index];
459
460 cd->of_node = child;
461
462 /* Initialize the routing table */
463 for (i = 0; i < DSA_MAX_SWITCHES; ++i)
464 cd->rtable[i] = DSA_RTABLE_NONE;
465
466 /* When assigning the host device, increment its refcount */
467 cd->host_dev = get_device(&mdio_bus->dev);
468
469 sw_addr = of_get_property(child, "reg", NULL);
470 if (!sw_addr)
471 continue;
472
473 cd->sw_addr = be32_to_cpup(sw_addr);
474 if (cd->sw_addr >= PHY_MAX_ADDR)
475 continue;
476
477 if (!of_property_read_u32(child, "eeprom-length", &eeprom_len))
478 cd->eeprom_len = eeprom_len;
479
480 mdio = of_parse_phandle(child, "mii-bus", 0);
481 if (mdio) {
482 mdio_bus_switch = of_mdio_find_bus(mdio);
483 if (!mdio_bus_switch) {
484 ret = -EPROBE_DEFER;
485 goto out_free_chip;
486 }
487
488 /* Drop the mdio_bus device ref, replacing the host
489 * device with the mdio_bus_switch device, keeping
490 * the refcount from of_mdio_find_bus() above.
491 */
492 put_device(cd->host_dev);
493 cd->host_dev = &mdio_bus_switch->dev;
494 }
495
496 for_each_available_child_of_node(child, port) {
497 port_reg = of_get_property(port, "reg", NULL);
498 if (!port_reg)
499 continue;
500
501 port_index = be32_to_cpup(port_reg);
502 if (port_index >= DSA_MAX_PORTS)
503 break;
504
505 port_name = of_get_property(port, "label", NULL);
506 if (!port_name)
507 continue;
508
509 cd->port_dn[port_index] = port;
510
511 cd->port_names[port_index] = kstrdup(port_name,
512 GFP_KERNEL);
513 if (!cd->port_names[port_index]) {
514 ret = -ENOMEM;
515 goto out_free_chip;
516 }
517
518 ret = dsa_of_probe_links(pd, cd, chip_index,
519 port_index, port, port_name);
520 if (ret)
521 goto out_free_chip;
522
523 }
524 }
525
526 /* The individual chips hold their own refcount on the mdio bus,
527 * so drop ours */
528 put_device(&mdio_bus->dev);
529
530 return 0;
531
532out_free_chip:
533 dsa_of_free_platform_data(pd);
534out_free:
535 kfree(pd);
536 dev->platform_data = NULL;
537out_put_ethernet:
538 put_device(&ethernet_dev->dev);
539out_put_mdio:
540 put_device(&mdio_bus->dev);
541 return ret;
542}
543
544static void dsa_of_remove(struct device *dev)
545{
546 struct dsa_platform_data *pd = dev->platform_data;
547
548 if (!dev->of_node)
549 return;
550
551 dsa_of_free_platform_data(pd);
552 put_device(&pd->of_netdev->dev);
553 kfree(pd);
554}
555#else
556static inline int dsa_of_probe(struct device *dev)
557{
558 return 0;
559}
560
561static inline void dsa_of_remove(struct device *dev)
562{
563}
564#endif
565
566static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
567 struct device *parent, struct dsa_platform_data *pd)
568{
569 int i;
570 unsigned configured = 0;
571
572 dst->pd = pd;
a6a71f19
VD
573
574 for (i = 0; i < pd->nr_chips; i++) {
575 struct dsa_switch *ds;
576
06d4d450 577 ds = dsa_switch_setup(dst, dev, i, parent, pd->chip[i].host_dev);
a6a71f19
VD
578 if (IS_ERR(ds)) {
579 netdev_err(dev, "[%d]: couldn't create dsa switch instance (error %ld)\n",
580 i, PTR_ERR(ds));
581 continue;
582 }
583
584 dst->ds[i] = ds;
585
586 ++configured;
587 }
588
589 /*
590 * If no switch was found, exit cleanly
591 */
592 if (!configured)
593 return -EPROBE_DEFER;
594
595 /*
596 * If we use a tagging format that doesn't have an ethertype
597 * field, make sure that all packets from this point on get
598 * sent to the tag format's receive function.
599 */
600 wmb();
2f657a60 601 dev->dsa_ptr = dst->cpu_dp;
a6a71f19 602
f8b8b1cd 603 return dsa_master_ethtool_setup(dst->cpu_dp->master);
a6a71f19
VD
604}
605
606static int dsa_probe(struct platform_device *pdev)
607{
608 struct dsa_platform_data *pd = pdev->dev.platform_data;
609 struct net_device *dev;
610 struct dsa_switch_tree *dst;
611 int ret;
612
613 if (pdev->dev.of_node) {
614 ret = dsa_of_probe(&pdev->dev);
615 if (ret)
616 return ret;
617
618 pd = pdev->dev.platform_data;
619 }
620
621 if (pd == NULL || (pd->netdev == NULL && pd->of_netdev == NULL))
622 return -EINVAL;
623
624 if (pd->of_netdev) {
625 dev = pd->of_netdev;
626 dev_hold(dev);
627 } else {
628 dev = dsa_dev_to_net_device(pd->netdev);
629 }
630 if (dev == NULL) {
631 ret = -EPROBE_DEFER;
632 goto out;
633 }
634
635 if (dev->dsa_ptr != NULL) {
636 dev_put(dev);
637 ret = -EEXIST;
638 goto out;
639 }
640
641 dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL);
642 if (dst == NULL) {
643 dev_put(dev);
644 ret = -ENOMEM;
645 goto out;
646 }
647
648 platform_set_drvdata(pdev, dst);
649
650 ret = dsa_setup_dst(dst, dev, &pdev->dev, pd);
651 if (ret) {
652 dev_put(dev);
653 goto out;
654 }
655
656 return 0;
657
658out:
659 dsa_of_remove(&pdev->dev);
660
661 return ret;
662}
663
664static void dsa_remove_dst(struct dsa_switch_tree *dst)
665{
666 int i;
667
f8b8b1cd 668 dsa_master_ethtool_restore(dst->cpu_dp->master);
1943563d 669
f8b8b1cd 670 dst->cpu_dp->master->dsa_ptr = NULL;
a6a71f19
VD
671
672 /* If we used a tagging format that doesn't have an ethertype
673 * field, make sure that all packets from this point get sent
674 * without the tag and go through the regular receive path.
675 */
676 wmb();
677
678 for (i = 0; i < dst->pd->nr_chips; i++) {
679 struct dsa_switch *ds = dst->ds[i];
680
681 if (ds)
682 dsa_switch_destroy(ds);
683 }
684
f8b8b1cd 685 dev_put(dst->cpu_dp->master);
a6a71f19
VD
686}
687
688static int dsa_remove(struct platform_device *pdev)
689{
690 struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
691
692 dsa_remove_dst(dst);
693 dsa_of_remove(&pdev->dev);
694
695 return 0;
696}
697
698static void dsa_shutdown(struct platform_device *pdev)
699{
700}
701
702#ifdef CONFIG_PM_SLEEP
703static int dsa_suspend(struct device *d)
704{
705 struct platform_device *pdev = to_platform_device(d);
706 struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
707 int i, ret = 0;
708
709 for (i = 0; i < dst->pd->nr_chips; i++) {
710 struct dsa_switch *ds = dst->ds[i];
711
712 if (ds != NULL)
713 ret = dsa_switch_suspend(ds);
714 }
715
716 return ret;
717}
718
719static int dsa_resume(struct device *d)
720{
721 struct platform_device *pdev = to_platform_device(d);
722 struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
723 int i, ret = 0;
724
725 for (i = 0; i < dst->pd->nr_chips; i++) {
726 struct dsa_switch *ds = dst->ds[i];
727
728 if (ds != NULL)
729 ret = dsa_switch_resume(ds);
730 }
731
732 return ret;
733}
734#endif
735
37b8da1a
AS
736/* legacy way, bypassing the bridge *****************************************/
737int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
738 struct net_device *dev,
739 const unsigned char *addr, u16 vid,
740 u16 flags)
741{
d945097b 742 struct dsa_port *dp = dsa_slave_to_port(dev);
37b8da1a
AS
743
744 return dsa_port_fdb_add(dp, addr, vid);
745}
746
747int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
748 struct net_device *dev,
749 const unsigned char *addr, u16 vid)
750{
d945097b 751 struct dsa_port *dp = dsa_slave_to_port(dev);
37b8da1a
AS
752
753 return dsa_port_fdb_del(dp, addr, vid);
754}
755
a6a71f19
VD
756static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume);
757
758static const struct of_device_id dsa_of_match_table[] = {
759 { .compatible = "marvell,dsa", },
760 {}
761};
762MODULE_DEVICE_TABLE(of, dsa_of_match_table);
763
764static struct platform_driver dsa_driver = {
765 .probe = dsa_probe,
766 .remove = dsa_remove,
767 .shutdown = dsa_shutdown,
768 .driver = {
769 .name = "dsa",
770 .of_match_table = dsa_of_match_table,
771 .pm = &dsa_pm_ops,
772 },
773};
774
775int dsa_legacy_register(void)
776{
777 return platform_driver_register(&dsa_driver);
778}
779
780void dsa_legacy_unregister(void)
781{
782 platform_driver_unregister(&dsa_driver);
783}