Lines Matching full:ds
17 static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, in dsa_switch_fastest_ageing_time() argument
22 for (i = 0; i < ds->num_ports; ++i) { in dsa_switch_fastest_ageing_time()
23 struct dsa_port *dp = dsa_to_port(ds, i); in dsa_switch_fastest_ageing_time()
32 static int dsa_switch_ageing_time(struct dsa_switch *ds, in dsa_switch_ageing_time() argument
37 if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) in dsa_switch_ageing_time()
40 if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) in dsa_switch_ageing_time()
44 ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
46 if (ds->ops->set_ageing_time) in dsa_switch_ageing_time()
47 return ds->ops->set_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
52 static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port, in dsa_switch_mtu_match() argument
55 if (ds->index == info->sw_index && port == info->port) in dsa_switch_mtu_match()
64 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) in dsa_switch_mtu_match()
70 static int dsa_switch_mtu(struct dsa_switch *ds, in dsa_switch_mtu() argument
75 if (!ds->ops->port_change_mtu) in dsa_switch_mtu()
78 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_mtu()
79 if (dsa_switch_mtu_match(ds, port, info)) { in dsa_switch_mtu()
80 ret = ds->ops->port_change_mtu(ds, port, info->mtu); in dsa_switch_mtu()
89 static int dsa_switch_bridge_join(struct dsa_switch *ds, in dsa_switch_bridge_join() argument
92 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_bridge_join()
95 if (dst->index == info->tree_index && ds->index == info->sw_index) { in dsa_switch_bridge_join()
96 if (!ds->ops->port_bridge_join) in dsa_switch_bridge_join()
99 err = ds->ops->port_bridge_join(ds, info->port, info->br); in dsa_switch_bridge_join()
104 if ((dst->index != info->tree_index || ds->index != info->sw_index) && in dsa_switch_bridge_join()
105 ds->ops->crosschip_bridge_join) { in dsa_switch_bridge_join()
106 err = ds->ops->crosschip_bridge_join(ds, info->tree_index, in dsa_switch_bridge_join()
113 return dsa_tag_8021q_bridge_join(ds, info); in dsa_switch_bridge_join()
116 static int dsa_switch_bridge_leave(struct dsa_switch *ds, in dsa_switch_bridge_leave() argument
119 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_bridge_leave()
125 if (dst->index == info->tree_index && ds->index == info->sw_index && in dsa_switch_bridge_leave()
126 ds->ops->port_bridge_leave) in dsa_switch_bridge_leave()
127 ds->ops->port_bridge_leave(ds, info->port, info->br); in dsa_switch_bridge_leave()
129 if ((dst->index != info->tree_index || ds->index != info->sw_index) && in dsa_switch_bridge_leave()
130 ds->ops->crosschip_bridge_leave) in dsa_switch_bridge_leave()
131 ds->ops->crosschip_bridge_leave(ds, info->tree_index, in dsa_switch_bridge_leave()
135 if (ds->needs_standalone_vlan_filtering && !br_vlan_enabled(info->br)) { in dsa_switch_bridge_leave()
138 } else if (!ds->needs_standalone_vlan_filtering && in dsa_switch_bridge_leave()
152 if (change_vlan_filtering && ds->vlan_filtering_is_global) { in dsa_switch_bridge_leave()
153 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_bridge_leave()
156 bridge_dev = dsa_to_port(ds, port)->bridge_dev; in dsa_switch_bridge_leave()
166 err = dsa_port_vlan_filtering(dsa_to_port(ds, info->port), in dsa_switch_bridge_leave()
169 dev_err(ds->dev, "port %d: %s\n", info->port, in dsa_switch_bridge_leave()
175 return dsa_tag_8021q_bridge_leave(ds, info); in dsa_switch_bridge_leave()
182 static bool dsa_switch_host_address_match(struct dsa_switch *ds, int port, in dsa_switch_host_address_match() argument
188 targeted_ds = dsa_switch_find(ds->dst->index, info_sw_index); in dsa_switch_host_address_match()
192 if (dsa_switch_is_upstream_of(ds, targeted_ds)) in dsa_switch_host_address_match()
193 return port == dsa_towards_port(ds, cpu_dp->ds->index, in dsa_switch_host_address_match()
212 static int dsa_switch_do_mdb_add(struct dsa_switch *ds, int port, in dsa_switch_do_mdb_add() argument
215 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_do_mdb_add()
221 return ds->ops->port_mdb_add(ds, port, mdb); in dsa_switch_do_mdb_add()
233 err = ds->ops->port_mdb_add(ds, port, mdb); in dsa_switch_do_mdb_add()
247 static int dsa_switch_do_mdb_del(struct dsa_switch *ds, int port, in dsa_switch_do_mdb_del() argument
250 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_do_mdb_del()
256 return ds->ops->port_mdb_del(ds, port, mdb); in dsa_switch_do_mdb_del()
265 err = ds->ops->port_mdb_del(ds, port, mdb); in dsa_switch_do_mdb_del()
277 static int dsa_switch_do_fdb_add(struct dsa_switch *ds, int port, in dsa_switch_do_fdb_add() argument
280 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_do_fdb_add()
286 return ds->ops->port_fdb_add(ds, port, addr, vid); in dsa_switch_do_fdb_add()
298 err = ds->ops->port_fdb_add(ds, port, addr, vid); in dsa_switch_do_fdb_add()
312 static int dsa_switch_do_fdb_del(struct dsa_switch *ds, int port, in dsa_switch_do_fdb_del() argument
315 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_do_fdb_del()
321 return ds->ops->port_fdb_del(ds, port, addr, vid); in dsa_switch_do_fdb_del()
330 err = ds->ops->port_fdb_del(ds, port, addr, vid); in dsa_switch_do_fdb_del()
342 static int dsa_switch_host_fdb_add(struct dsa_switch *ds, in dsa_switch_host_fdb_add() argument
348 if (!ds->ops->port_fdb_add) in dsa_switch_host_fdb_add()
351 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_host_fdb_add()
352 if (dsa_switch_host_address_match(ds, port, info->sw_index, in dsa_switch_host_fdb_add()
354 err = dsa_switch_do_fdb_add(ds, port, info->addr, in dsa_switch_host_fdb_add()
364 static int dsa_switch_host_fdb_del(struct dsa_switch *ds, in dsa_switch_host_fdb_del() argument
370 if (!ds->ops->port_fdb_del) in dsa_switch_host_fdb_del()
373 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_host_fdb_del()
374 if (dsa_switch_host_address_match(ds, port, info->sw_index, in dsa_switch_host_fdb_del()
376 err = dsa_switch_do_fdb_del(ds, port, info->addr, in dsa_switch_host_fdb_del()
386 static int dsa_switch_fdb_add(struct dsa_switch *ds, in dsa_switch_fdb_add() argument
389 int port = dsa_towards_port(ds, info->sw_index, info->port); in dsa_switch_fdb_add()
391 if (!ds->ops->port_fdb_add) in dsa_switch_fdb_add()
394 return dsa_switch_do_fdb_add(ds, port, info->addr, info->vid); in dsa_switch_fdb_add()
397 static int dsa_switch_fdb_del(struct dsa_switch *ds, in dsa_switch_fdb_del() argument
400 int port = dsa_towards_port(ds, info->sw_index, info->port); in dsa_switch_fdb_del()
402 if (!ds->ops->port_fdb_del) in dsa_switch_fdb_del()
405 return dsa_switch_do_fdb_del(ds, port, info->addr, info->vid); in dsa_switch_fdb_del()
408 static int dsa_switch_hsr_join(struct dsa_switch *ds, in dsa_switch_hsr_join() argument
411 if (ds->index == info->sw_index && ds->ops->port_hsr_join) in dsa_switch_hsr_join()
412 return ds->ops->port_hsr_join(ds, info->port, info->hsr); in dsa_switch_hsr_join()
417 static int dsa_switch_hsr_leave(struct dsa_switch *ds, in dsa_switch_hsr_leave() argument
420 if (ds->index == info->sw_index && ds->ops->port_hsr_leave) in dsa_switch_hsr_leave()
421 return ds->ops->port_hsr_leave(ds, info->port, info->hsr); in dsa_switch_hsr_leave()
426 static int dsa_switch_lag_change(struct dsa_switch *ds, in dsa_switch_lag_change() argument
429 if (ds->index == info->sw_index && ds->ops->port_lag_change) in dsa_switch_lag_change()
430 return ds->ops->port_lag_change(ds, info->port); in dsa_switch_lag_change()
432 if (ds->index != info->sw_index && ds->ops->crosschip_lag_change) in dsa_switch_lag_change()
433 return ds->ops->crosschip_lag_change(ds, info->sw_index, in dsa_switch_lag_change()
439 static int dsa_switch_lag_join(struct dsa_switch *ds, in dsa_switch_lag_join() argument
442 if (ds->index == info->sw_index && ds->ops->port_lag_join) in dsa_switch_lag_join()
443 return ds->ops->port_lag_join(ds, info->port, info->lag, in dsa_switch_lag_join()
446 if (ds->index != info->sw_index && ds->ops->crosschip_lag_join) in dsa_switch_lag_join()
447 return ds->ops->crosschip_lag_join(ds, info->sw_index, in dsa_switch_lag_join()
454 static int dsa_switch_lag_leave(struct dsa_switch *ds, in dsa_switch_lag_leave() argument
457 if (ds->index == info->sw_index && ds->ops->port_lag_leave) in dsa_switch_lag_leave()
458 return ds->ops->port_lag_leave(ds, info->port, info->lag); in dsa_switch_lag_leave()
460 if (ds->index != info->sw_index && ds->ops->crosschip_lag_leave) in dsa_switch_lag_leave()
461 return ds->ops->crosschip_lag_leave(ds, info->sw_index, in dsa_switch_lag_leave()
467 static int dsa_switch_mdb_add(struct dsa_switch *ds, in dsa_switch_mdb_add() argument
470 int port = dsa_towards_port(ds, info->sw_index, info->port); in dsa_switch_mdb_add()
472 if (!ds->ops->port_mdb_add) in dsa_switch_mdb_add()
475 return dsa_switch_do_mdb_add(ds, port, info->mdb); in dsa_switch_mdb_add()
478 static int dsa_switch_mdb_del(struct dsa_switch *ds, in dsa_switch_mdb_del() argument
481 int port = dsa_towards_port(ds, info->sw_index, info->port); in dsa_switch_mdb_del()
483 if (!ds->ops->port_mdb_del) in dsa_switch_mdb_del()
486 return dsa_switch_do_mdb_del(ds, port, info->mdb); in dsa_switch_mdb_del()
489 static int dsa_switch_host_mdb_add(struct dsa_switch *ds, in dsa_switch_host_mdb_add() argument
495 if (!ds->ops->port_mdb_add) in dsa_switch_host_mdb_add()
498 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_host_mdb_add()
499 if (dsa_switch_host_address_match(ds, port, info->sw_index, in dsa_switch_host_mdb_add()
501 err = dsa_switch_do_mdb_add(ds, port, info->mdb); in dsa_switch_host_mdb_add()
510 static int dsa_switch_host_mdb_del(struct dsa_switch *ds, in dsa_switch_host_mdb_del() argument
516 if (!ds->ops->port_mdb_del) in dsa_switch_host_mdb_del()
519 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_host_mdb_del()
520 if (dsa_switch_host_address_match(ds, port, info->sw_index, in dsa_switch_host_mdb_del()
522 err = dsa_switch_do_mdb_del(ds, port, info->mdb); in dsa_switch_host_mdb_del()
531 static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port, in dsa_switch_vlan_match() argument
534 if (ds->index == info->sw_index && port == info->port) in dsa_switch_vlan_match()
537 if (dsa_is_dsa_port(ds, port)) in dsa_switch_vlan_match()
543 static int dsa_switch_vlan_add(struct dsa_switch *ds, in dsa_switch_vlan_add() argument
548 if (!ds->ops->port_vlan_add) in dsa_switch_vlan_add()
551 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_vlan_add()
552 if (dsa_switch_vlan_match(ds, port, info)) { in dsa_switch_vlan_add()
553 err = ds->ops->port_vlan_add(ds, port, info->vlan, in dsa_switch_vlan_add()
563 static int dsa_switch_vlan_del(struct dsa_switch *ds, in dsa_switch_vlan_del() argument
566 if (!ds->ops->port_vlan_del) in dsa_switch_vlan_del()
569 if (ds->index == info->sw_index) in dsa_switch_vlan_del()
570 return ds->ops->port_vlan_del(ds, info->port, info->vlan); in dsa_switch_vlan_del()
578 static int dsa_switch_change_tag_proto(struct dsa_switch *ds, in dsa_switch_change_tag_proto() argument
584 if (!ds->ops->change_tag_protocol) in dsa_switch_change_tag_proto()
589 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_change_tag_proto()
590 if (!dsa_is_cpu_port(ds, port)) in dsa_switch_change_tag_proto()
593 err = ds->ops->change_tag_protocol(ds, port, tag_ops->proto); in dsa_switch_change_tag_proto()
597 dsa_port_set_tag_protocol(dsa_to_port(ds, port), tag_ops); in dsa_switch_change_tag_proto()
604 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_change_tag_proto()
605 if (dsa_is_user_port(ds, port)) { in dsa_switch_change_tag_proto()
608 slave = dsa_to_port(ds, port)->slave; in dsa_switch_change_tag_proto()
619 static int dsa_switch_mrp_add(struct dsa_switch *ds, in dsa_switch_mrp_add() argument
622 if (!ds->ops->port_mrp_add) in dsa_switch_mrp_add()
625 if (ds->index == info->sw_index) in dsa_switch_mrp_add()
626 return ds->ops->port_mrp_add(ds, info->port, info->mrp); in dsa_switch_mrp_add()
631 static int dsa_switch_mrp_del(struct dsa_switch *ds, in dsa_switch_mrp_del() argument
634 if (!ds->ops->port_mrp_del) in dsa_switch_mrp_del()
637 if (ds->index == info->sw_index) in dsa_switch_mrp_del()
638 return ds->ops->port_mrp_del(ds, info->port, info->mrp); in dsa_switch_mrp_del()
644 dsa_switch_mrp_add_ring_role(struct dsa_switch *ds, in dsa_switch_mrp_add_ring_role() argument
647 if (!ds->ops->port_mrp_add) in dsa_switch_mrp_add_ring_role()
650 if (ds->index == info->sw_index) in dsa_switch_mrp_add_ring_role()
651 return ds->ops->port_mrp_add_ring_role(ds, info->port, in dsa_switch_mrp_add_ring_role()
658 dsa_switch_mrp_del_ring_role(struct dsa_switch *ds, in dsa_switch_mrp_del_ring_role() argument
661 if (!ds->ops->port_mrp_del) in dsa_switch_mrp_del_ring_role()
664 if (ds->index == info->sw_index) in dsa_switch_mrp_del_ring_role()
665 return ds->ops->port_mrp_del_ring_role(ds, info->port, in dsa_switch_mrp_del_ring_role()
674 struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb); in dsa_switch_event() local
679 err = dsa_switch_ageing_time(ds, info); in dsa_switch_event()
682 err = dsa_switch_bridge_join(ds, info); in dsa_switch_event()
685 err = dsa_switch_bridge_leave(ds, info); in dsa_switch_event()
688 err = dsa_switch_fdb_add(ds, info); in dsa_switch_event()
691 err = dsa_switch_fdb_del(ds, info); in dsa_switch_event()
694 err = dsa_switch_host_fdb_add(ds, info); in dsa_switch_event()
697 err = dsa_switch_host_fdb_del(ds, info); in dsa_switch_event()
700 err = dsa_switch_hsr_join(ds, info); in dsa_switch_event()
703 err = dsa_switch_hsr_leave(ds, info); in dsa_switch_event()
706 err = dsa_switch_lag_change(ds, info); in dsa_switch_event()
709 err = dsa_switch_lag_join(ds, info); in dsa_switch_event()
712 err = dsa_switch_lag_leave(ds, info); in dsa_switch_event()
715 err = dsa_switch_mdb_add(ds, info); in dsa_switch_event()
718 err = dsa_switch_mdb_del(ds, info); in dsa_switch_event()
721 err = dsa_switch_host_mdb_add(ds, info); in dsa_switch_event()
724 err = dsa_switch_host_mdb_del(ds, info); in dsa_switch_event()
727 err = dsa_switch_vlan_add(ds, info); in dsa_switch_event()
730 err = dsa_switch_vlan_del(ds, info); in dsa_switch_event()
733 err = dsa_switch_mtu(ds, info); in dsa_switch_event()
736 err = dsa_switch_change_tag_proto(ds, info); in dsa_switch_event()
739 err = dsa_switch_mrp_add(ds, info); in dsa_switch_event()
742 err = dsa_switch_mrp_del(ds, info); in dsa_switch_event()
745 err = dsa_switch_mrp_add_ring_role(ds, info); in dsa_switch_event()
748 err = dsa_switch_mrp_del_ring_role(ds, info); in dsa_switch_event()
751 err = dsa_switch_tag_8021q_vlan_add(ds, info); in dsa_switch_event()
754 err = dsa_switch_tag_8021q_vlan_del(ds, info); in dsa_switch_event()
762 dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n", in dsa_switch_event()
768 int dsa_switch_register_notifier(struct dsa_switch *ds) in dsa_switch_register_notifier() argument
770 ds->nb.notifier_call = dsa_switch_event; in dsa_switch_register_notifier()
772 return raw_notifier_chain_register(&ds->dst->nh, &ds->nb); in dsa_switch_register_notifier()
775 void dsa_switch_unregister_notifier(struct dsa_switch *ds) in dsa_switch_unregister_notifier() argument
779 err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb); in dsa_switch_unregister_notifier()
781 dev_err(ds->dev, "failed to unregister notifier (%d)\n", err); in dsa_switch_unregister_notifier()