Lines Matching full:ds
23 static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, in dsa_switch_fastest_ageing_time() argument
28 dsa_switch_for_each_port(dp, ds) in dsa_switch_fastest_ageing_time()
35 static int dsa_switch_ageing_time(struct dsa_switch *ds, in dsa_switch_ageing_time() argument
40 if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) in dsa_switch_ageing_time()
43 if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) in dsa_switch_ageing_time()
47 ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
49 if (ds->ops->set_ageing_time) in dsa_switch_ageing_time()
50 return ds->ops->set_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
61 static int dsa_switch_mtu(struct dsa_switch *ds, in dsa_switch_mtu() argument
67 if (!ds->ops->port_change_mtu) in dsa_switch_mtu()
70 dsa_switch_for_each_port(dp, ds) { in dsa_switch_mtu()
72 ret = ds->ops->port_change_mtu(ds, dp->index, in dsa_switch_mtu()
82 static int dsa_switch_bridge_join(struct dsa_switch *ds, in dsa_switch_bridge_join() argument
87 if (info->dp->ds == ds) { in dsa_switch_bridge_join()
88 if (!ds->ops->port_bridge_join) in dsa_switch_bridge_join()
91 err = ds->ops->port_bridge_join(ds, info->dp->index, in dsa_switch_bridge_join()
99 if (info->dp->ds != ds && ds->ops->crosschip_bridge_join) { in dsa_switch_bridge_join()
100 err = ds->ops->crosschip_bridge_join(ds, in dsa_switch_bridge_join()
101 info->dp->ds->dst->index, in dsa_switch_bridge_join()
102 info->dp->ds->index, in dsa_switch_bridge_join()
113 static int dsa_switch_bridge_leave(struct dsa_switch *ds, in dsa_switch_bridge_leave() argument
116 if (info->dp->ds == ds && ds->ops->port_bridge_leave) in dsa_switch_bridge_leave()
117 ds->ops->port_bridge_leave(ds, info->dp->index, info->bridge); in dsa_switch_bridge_leave()
119 if (info->dp->ds != ds && ds->ops->crosschip_bridge_leave) in dsa_switch_bridge_leave()
120 ds->ops->crosschip_bridge_leave(ds, info->dp->ds->dst->index, in dsa_switch_bridge_leave()
121 info->dp->ds->index, in dsa_switch_bridge_leave()
137 if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds)) in dsa_port_host_address_match()
138 return dp->index == dsa_towards_port(dp->ds, cpu_dp->ds->index, in dsa_port_host_address_match()
162 struct dsa_switch *ds = dp->ds; in dsa_port_do_mdb_add() local
169 err = ds->ops->port_mdb_add(ds, port, mdb, db); in dsa_port_do_mdb_add()
191 err = ds->ops->port_mdb_add(ds, port, mdb, db); in dsa_port_do_mdb_add()
214 struct dsa_switch *ds = dp->ds; in dsa_port_do_mdb_del() local
221 err = ds->ops->port_mdb_del(ds, port, mdb, db); in dsa_port_do_mdb_del()
242 err = ds->ops->port_mdb_del(ds, port, mdb, db); in dsa_port_do_mdb_del()
261 struct dsa_switch *ds = dp->ds; in dsa_port_do_fdb_add() local
268 err = ds->ops->port_fdb_add(ds, port, addr, vid, db); in dsa_port_do_fdb_add()
289 err = ds->ops->port_fdb_add(ds, port, addr, vid, db); in dsa_port_do_fdb_add()
311 struct dsa_switch *ds = dp->ds; in dsa_port_do_fdb_del() local
318 err = ds->ops->port_fdb_del(ds, port, addr, vid, db); in dsa_port_do_fdb_del()
338 err = ds->ops->port_fdb_del(ds, port, addr, vid, db); in dsa_port_do_fdb_del()
354 static int dsa_switch_do_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag *lag, in dsa_switch_do_lag_fdb_add() argument
377 err = ds->ops->lag_fdb_add(ds, *lag, addr, vid, db); in dsa_switch_do_lag_fdb_add()
396 static int dsa_switch_do_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag *lag, in dsa_switch_do_lag_fdb_del() argument
418 err = ds->ops->lag_fdb_del(ds, *lag, addr, vid, db); in dsa_switch_do_lag_fdb_del()
434 static int dsa_switch_host_fdb_add(struct dsa_switch *ds, in dsa_switch_host_fdb_add() argument
440 if (!ds->ops->port_fdb_add) in dsa_switch_host_fdb_add()
443 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_fdb_add()
446 err = dsa_switch_do_lag_fdb_add(ds, dp->lag, in dsa_switch_host_fdb_add()
462 static int dsa_switch_host_fdb_del(struct dsa_switch *ds, in dsa_switch_host_fdb_del() argument
468 if (!ds->ops->port_fdb_del) in dsa_switch_host_fdb_del()
471 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_fdb_del()
474 err = dsa_switch_do_lag_fdb_del(ds, dp->lag, in dsa_switch_host_fdb_del()
490 static int dsa_switch_fdb_add(struct dsa_switch *ds, in dsa_switch_fdb_add() argument
493 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_fdb_add()
494 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_fdb_add()
496 if (!ds->ops->port_fdb_add) in dsa_switch_fdb_add()
502 static int dsa_switch_fdb_del(struct dsa_switch *ds, in dsa_switch_fdb_del() argument
505 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_fdb_del()
506 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_fdb_del()
508 if (!ds->ops->port_fdb_del) in dsa_switch_fdb_del()
514 static int dsa_switch_lag_fdb_add(struct dsa_switch *ds, in dsa_switch_lag_fdb_add() argument
519 if (!ds->ops->lag_fdb_add) in dsa_switch_lag_fdb_add()
523 dsa_switch_for_each_port(dp, ds) in dsa_switch_lag_fdb_add()
525 return dsa_switch_do_lag_fdb_add(ds, info->lag, in dsa_switch_lag_fdb_add()
532 static int dsa_switch_lag_fdb_del(struct dsa_switch *ds, in dsa_switch_lag_fdb_del() argument
537 if (!ds->ops->lag_fdb_del) in dsa_switch_lag_fdb_del()
541 dsa_switch_for_each_port(dp, ds) in dsa_switch_lag_fdb_del()
543 return dsa_switch_do_lag_fdb_del(ds, info->lag, in dsa_switch_lag_fdb_del()
550 static int dsa_switch_lag_change(struct dsa_switch *ds, in dsa_switch_lag_change() argument
553 if (info->dp->ds == ds && ds->ops->port_lag_change) in dsa_switch_lag_change()
554 return ds->ops->port_lag_change(ds, info->dp->index); in dsa_switch_lag_change()
556 if (info->dp->ds != ds && ds->ops->crosschip_lag_change) in dsa_switch_lag_change()
557 return ds->ops->crosschip_lag_change(ds, info->dp->ds->index, in dsa_switch_lag_change()
563 static int dsa_switch_lag_join(struct dsa_switch *ds, in dsa_switch_lag_join() argument
566 if (info->dp->ds == ds && ds->ops->port_lag_join) in dsa_switch_lag_join()
567 return ds->ops->port_lag_join(ds, info->dp->index, info->lag, in dsa_switch_lag_join()
570 if (info->dp->ds != ds && ds->ops->crosschip_lag_join) in dsa_switch_lag_join()
571 return ds->ops->crosschip_lag_join(ds, info->dp->ds->index, in dsa_switch_lag_join()
578 static int dsa_switch_lag_leave(struct dsa_switch *ds, in dsa_switch_lag_leave() argument
581 if (info->dp->ds == ds && ds->ops->port_lag_leave) in dsa_switch_lag_leave()
582 return ds->ops->port_lag_leave(ds, info->dp->index, info->lag); in dsa_switch_lag_leave()
584 if (info->dp->ds != ds && ds->ops->crosschip_lag_leave) in dsa_switch_lag_leave()
585 return ds->ops->crosschip_lag_leave(ds, info->dp->ds->index, in dsa_switch_lag_leave()
591 static int dsa_switch_mdb_add(struct dsa_switch *ds, in dsa_switch_mdb_add() argument
594 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_mdb_add()
595 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_mdb_add()
597 if (!ds->ops->port_mdb_add) in dsa_switch_mdb_add()
603 static int dsa_switch_mdb_del(struct dsa_switch *ds, in dsa_switch_mdb_del() argument
606 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_mdb_del()
607 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_mdb_del()
609 if (!ds->ops->port_mdb_del) in dsa_switch_mdb_del()
615 static int dsa_switch_host_mdb_add(struct dsa_switch *ds, in dsa_switch_host_mdb_add() argument
621 if (!ds->ops->port_mdb_add) in dsa_switch_host_mdb_add()
624 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_mdb_add()
635 static int dsa_switch_host_mdb_del(struct dsa_switch *ds, in dsa_switch_host_mdb_del() argument
641 if (!ds->ops->port_mdb_del) in dsa_switch_host_mdb_del()
644 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_mdb_del()
670 if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds)) in dsa_port_host_vlan_match()
692 struct dsa_switch *ds = dp->ds; in dsa_port_do_vlan_add() local
699 err = ds->ops->port_vlan_add(ds, port, vlan, extack); in dsa_port_do_vlan_add()
728 err = ds->ops->port_vlan_add(ds, port, vlan, extack); in dsa_port_do_vlan_add()
748 struct dsa_switch *ds = dp->ds; in dsa_port_do_vlan_del() local
755 err = ds->ops->port_vlan_del(ds, port, vlan); in dsa_port_do_vlan_del()
775 err = ds->ops->port_vlan_del(ds, port, vlan); in dsa_port_do_vlan_del()
791 static int dsa_switch_vlan_add(struct dsa_switch *ds, in dsa_switch_vlan_add() argument
797 if (!ds->ops->port_vlan_add) in dsa_switch_vlan_add()
800 dsa_switch_for_each_port(dp, ds) { in dsa_switch_vlan_add()
812 static int dsa_switch_vlan_del(struct dsa_switch *ds, in dsa_switch_vlan_del() argument
818 if (!ds->ops->port_vlan_del) in dsa_switch_vlan_del()
821 dsa_switch_for_each_port(dp, ds) { in dsa_switch_vlan_del()
832 static int dsa_switch_host_vlan_add(struct dsa_switch *ds, in dsa_switch_host_vlan_add() argument
838 if (!ds->ops->port_vlan_add) in dsa_switch_host_vlan_add()
841 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_vlan_add()
853 static int dsa_switch_host_vlan_del(struct dsa_switch *ds, in dsa_switch_host_vlan_del() argument
859 if (!ds->ops->port_vlan_del) in dsa_switch_host_vlan_del()
862 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_vlan_del()
873 static int dsa_switch_change_tag_proto(struct dsa_switch *ds, in dsa_switch_change_tag_proto() argument
880 if (!ds->ops->change_tag_protocol) in dsa_switch_change_tag_proto()
885 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_change_tag_proto()
889 dsa_switch_for_each_cpu_port(cpu_dp, ds) in dsa_switch_change_tag_proto()
896 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_change_tag_proto()
910 * Since ds->tagger_data is owned by the tagger, it isn't a hard error if the
918 dsa_switch_connect_tag_proto(struct dsa_switch *ds, in dsa_switch_connect_tag_proto() argument
926 err = tag_ops->connect(ds); in dsa_switch_connect_tag_proto()
931 if (!ds->ops->connect_tag_protocol) in dsa_switch_connect_tag_proto()
935 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_connect_tag_proto()
939 tag_ops->disconnect(ds); in dsa_switch_connect_tag_proto()
947 dsa_switch_disconnect_tag_proto(struct dsa_switch *ds, in dsa_switch_disconnect_tag_proto() argument
953 if (tag_ops->disconnect && ds->tagger_data) in dsa_switch_disconnect_tag_proto()
954 tag_ops->disconnect(ds); in dsa_switch_disconnect_tag_proto()
963 dsa_switch_conduit_state_change(struct dsa_switch *ds, in dsa_switch_conduit_state_change() argument
966 if (!ds->ops->conduit_state_change) in dsa_switch_conduit_state_change()
969 ds->ops->conduit_state_change(ds, info->conduit, info->operational); in dsa_switch_conduit_state_change()
977 struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb); in dsa_switch_event() local
982 err = dsa_switch_ageing_time(ds, info); in dsa_switch_event()
985 err = dsa_switch_bridge_join(ds, info); in dsa_switch_event()
988 err = dsa_switch_bridge_leave(ds, info); in dsa_switch_event()
991 err = dsa_switch_fdb_add(ds, info); in dsa_switch_event()
994 err = dsa_switch_fdb_del(ds, info); in dsa_switch_event()
997 err = dsa_switch_host_fdb_add(ds, info); in dsa_switch_event()
1000 err = dsa_switch_host_fdb_del(ds, info); in dsa_switch_event()
1003 err = dsa_switch_lag_fdb_add(ds, info); in dsa_switch_event()
1006 err = dsa_switch_lag_fdb_del(ds, info); in dsa_switch_event()
1009 err = dsa_switch_lag_change(ds, info); in dsa_switch_event()
1012 err = dsa_switch_lag_join(ds, info); in dsa_switch_event()
1015 err = dsa_switch_lag_leave(ds, info); in dsa_switch_event()
1018 err = dsa_switch_mdb_add(ds, info); in dsa_switch_event()
1021 err = dsa_switch_mdb_del(ds, info); in dsa_switch_event()
1024 err = dsa_switch_host_mdb_add(ds, info); in dsa_switch_event()
1027 err = dsa_switch_host_mdb_del(ds, info); in dsa_switch_event()
1030 err = dsa_switch_vlan_add(ds, info); in dsa_switch_event()
1033 err = dsa_switch_vlan_del(ds, info); in dsa_switch_event()
1036 err = dsa_switch_host_vlan_add(ds, info); in dsa_switch_event()
1039 err = dsa_switch_host_vlan_del(ds, info); in dsa_switch_event()
1042 err = dsa_switch_mtu(ds, info); in dsa_switch_event()
1045 err = dsa_switch_change_tag_proto(ds, info); in dsa_switch_event()
1048 err = dsa_switch_connect_tag_proto(ds, info); in dsa_switch_event()
1051 err = dsa_switch_disconnect_tag_proto(ds, info); in dsa_switch_event()
1054 err = dsa_switch_tag_8021q_vlan_add(ds, info); in dsa_switch_event()
1057 err = dsa_switch_tag_8021q_vlan_del(ds, info); in dsa_switch_event()
1060 err = dsa_switch_conduit_state_change(ds, info); in dsa_switch_event()
1068 dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n", in dsa_switch_event()
1120 int dsa_switch_register_notifier(struct dsa_switch *ds) in dsa_switch_register_notifier() argument
1122 ds->nb.notifier_call = dsa_switch_event; in dsa_switch_register_notifier()
1124 return raw_notifier_chain_register(&ds->dst->nh, &ds->nb); in dsa_switch_register_notifier()
1127 void dsa_switch_unregister_notifier(struct dsa_switch *ds) in dsa_switch_unregister_notifier() argument
1131 err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb); in dsa_switch_unregister_notifier()
1133 dev_err(ds->dev, "failed to unregister notifier (%d)\n", err); in dsa_switch_unregister_notifier()