Lines Matching refs:ds

17 static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds,  in dsa_switch_fastest_ageing_time()  argument
22 dsa_switch_for_each_port(dp, ds) in dsa_switch_fastest_ageing_time()
29 static int dsa_switch_ageing_time(struct dsa_switch *ds, in dsa_switch_ageing_time() argument
34 if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) in dsa_switch_ageing_time()
37 if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) in dsa_switch_ageing_time()
41 ageing_time = dsa_switch_fastest_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
43 if (ds->ops->set_ageing_time) in dsa_switch_ageing_time()
44 return ds->ops->set_ageing_time(ds, ageing_time); in dsa_switch_ageing_time()
55 static int dsa_switch_mtu(struct dsa_switch *ds, in dsa_switch_mtu() argument
61 if (!ds->ops->port_change_mtu) in dsa_switch_mtu()
64 dsa_switch_for_each_port(dp, ds) { in dsa_switch_mtu()
66 ret = ds->ops->port_change_mtu(ds, dp->index, in dsa_switch_mtu()
76 static int dsa_switch_bridge_join(struct dsa_switch *ds, in dsa_switch_bridge_join() argument
81 if (info->dp->ds == ds) { in dsa_switch_bridge_join()
82 if (!ds->ops->port_bridge_join) in dsa_switch_bridge_join()
85 err = ds->ops->port_bridge_join(ds, info->dp->index, in dsa_switch_bridge_join()
93 if (info->dp->ds != ds && ds->ops->crosschip_bridge_join) { in dsa_switch_bridge_join()
94 err = ds->ops->crosschip_bridge_join(ds, in dsa_switch_bridge_join()
95 info->dp->ds->dst->index, in dsa_switch_bridge_join()
96 info->dp->ds->index, in dsa_switch_bridge_join()
107 static int dsa_switch_bridge_leave(struct dsa_switch *ds, in dsa_switch_bridge_leave() argument
110 if (info->dp->ds == ds && ds->ops->port_bridge_leave) in dsa_switch_bridge_leave()
111 ds->ops->port_bridge_leave(ds, info->dp->index, info->bridge); in dsa_switch_bridge_leave()
113 if (info->dp->ds != ds && ds->ops->crosschip_bridge_leave) in dsa_switch_bridge_leave()
114 ds->ops->crosschip_bridge_leave(ds, info->dp->ds->dst->index, in dsa_switch_bridge_leave()
115 info->dp->ds->index, in dsa_switch_bridge_leave()
131 if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds)) in dsa_port_host_address_match()
132 return dp->index == dsa_towards_port(dp->ds, cpu_dp->ds->index, in dsa_port_host_address_match()
156 struct dsa_switch *ds = dp->ds; in dsa_port_do_mdb_add() local
163 return ds->ops->port_mdb_add(ds, port, mdb, db); in dsa_port_do_mdb_add()
179 err = ds->ops->port_mdb_add(ds, port, mdb, db); in dsa_port_do_mdb_add()
201 struct dsa_switch *ds = dp->ds; in dsa_port_do_mdb_del() local
208 return ds->ops->port_mdb_del(ds, port, mdb, db); in dsa_port_do_mdb_del()
221 err = ds->ops->port_mdb_del(ds, port, mdb, db); in dsa_port_do_mdb_del()
239 struct dsa_switch *ds = dp->ds; in dsa_port_do_fdb_add() local
246 return ds->ops->port_fdb_add(ds, port, addr, vid, db); in dsa_port_do_fdb_add()
262 err = ds->ops->port_fdb_add(ds, port, addr, vid, db); in dsa_port_do_fdb_add()
283 struct dsa_switch *ds = dp->ds; in dsa_port_do_fdb_del() local
290 return ds->ops->port_fdb_del(ds, port, addr, vid, db); in dsa_port_do_fdb_del()
303 err = ds->ops->port_fdb_del(ds, port, addr, vid, db); in dsa_port_do_fdb_del()
318 static int dsa_switch_do_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag *lag, in dsa_switch_do_lag_fdb_add() argument
339 err = ds->ops->lag_fdb_add(ds, *lag, addr, vid, db); in dsa_switch_do_lag_fdb_add()
357 static int dsa_switch_do_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag *lag, in dsa_switch_do_lag_fdb_del() argument
375 err = ds->ops->lag_fdb_del(ds, *lag, addr, vid, db); in dsa_switch_do_lag_fdb_del()
390 static int dsa_switch_host_fdb_add(struct dsa_switch *ds, in dsa_switch_host_fdb_add() argument
396 if (!ds->ops->port_fdb_add) in dsa_switch_host_fdb_add()
399 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_fdb_add()
402 err = dsa_switch_do_lag_fdb_add(ds, dp->lag, in dsa_switch_host_fdb_add()
418 static int dsa_switch_host_fdb_del(struct dsa_switch *ds, in dsa_switch_host_fdb_del() argument
424 if (!ds->ops->port_fdb_del) in dsa_switch_host_fdb_del()
427 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_fdb_del()
430 err = dsa_switch_do_lag_fdb_del(ds, dp->lag, in dsa_switch_host_fdb_del()
446 static int dsa_switch_fdb_add(struct dsa_switch *ds, in dsa_switch_fdb_add() argument
449 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_fdb_add()
450 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_fdb_add()
452 if (!ds->ops->port_fdb_add) in dsa_switch_fdb_add()
458 static int dsa_switch_fdb_del(struct dsa_switch *ds, in dsa_switch_fdb_del() argument
461 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_fdb_del()
462 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_fdb_del()
464 if (!ds->ops->port_fdb_del) in dsa_switch_fdb_del()
470 static int dsa_switch_lag_fdb_add(struct dsa_switch *ds, in dsa_switch_lag_fdb_add() argument
475 if (!ds->ops->lag_fdb_add) in dsa_switch_lag_fdb_add()
479 dsa_switch_for_each_port(dp, ds) in dsa_switch_lag_fdb_add()
481 return dsa_switch_do_lag_fdb_add(ds, info->lag, in dsa_switch_lag_fdb_add()
488 static int dsa_switch_lag_fdb_del(struct dsa_switch *ds, in dsa_switch_lag_fdb_del() argument
493 if (!ds->ops->lag_fdb_del) in dsa_switch_lag_fdb_del()
497 dsa_switch_for_each_port(dp, ds) in dsa_switch_lag_fdb_del()
499 return dsa_switch_do_lag_fdb_del(ds, info->lag, in dsa_switch_lag_fdb_del()
506 static int dsa_switch_lag_change(struct dsa_switch *ds, in dsa_switch_lag_change() argument
509 if (info->dp->ds == ds && ds->ops->port_lag_change) in dsa_switch_lag_change()
510 return ds->ops->port_lag_change(ds, info->dp->index); in dsa_switch_lag_change()
512 if (info->dp->ds != ds && ds->ops->crosschip_lag_change) in dsa_switch_lag_change()
513 return ds->ops->crosschip_lag_change(ds, info->dp->ds->index, in dsa_switch_lag_change()
519 static int dsa_switch_lag_join(struct dsa_switch *ds, in dsa_switch_lag_join() argument
522 if (info->dp->ds == ds && ds->ops->port_lag_join) in dsa_switch_lag_join()
523 return ds->ops->port_lag_join(ds, info->dp->index, info->lag, in dsa_switch_lag_join()
526 if (info->dp->ds != ds && ds->ops->crosschip_lag_join) in dsa_switch_lag_join()
527 return ds->ops->crosschip_lag_join(ds, info->dp->ds->index, in dsa_switch_lag_join()
534 static int dsa_switch_lag_leave(struct dsa_switch *ds, in dsa_switch_lag_leave() argument
537 if (info->dp->ds == ds && ds->ops->port_lag_leave) in dsa_switch_lag_leave()
538 return ds->ops->port_lag_leave(ds, info->dp->index, info->lag); in dsa_switch_lag_leave()
540 if (info->dp->ds != ds && ds->ops->crosschip_lag_leave) in dsa_switch_lag_leave()
541 return ds->ops->crosschip_lag_leave(ds, info->dp->ds->index, in dsa_switch_lag_leave()
547 static int dsa_switch_mdb_add(struct dsa_switch *ds, in dsa_switch_mdb_add() argument
550 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_mdb_add()
551 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_mdb_add()
553 if (!ds->ops->port_mdb_add) in dsa_switch_mdb_add()
559 static int dsa_switch_mdb_del(struct dsa_switch *ds, in dsa_switch_mdb_del() argument
562 int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index); in dsa_switch_mdb_del()
563 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_switch_mdb_del()
565 if (!ds->ops->port_mdb_del) in dsa_switch_mdb_del()
571 static int dsa_switch_host_mdb_add(struct dsa_switch *ds, in dsa_switch_host_mdb_add() argument
577 if (!ds->ops->port_mdb_add) in dsa_switch_host_mdb_add()
580 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_mdb_add()
591 static int dsa_switch_host_mdb_del(struct dsa_switch *ds, in dsa_switch_host_mdb_del() argument
597 if (!ds->ops->port_mdb_del) in dsa_switch_host_mdb_del()
600 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_mdb_del()
626 if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds)) in dsa_port_host_vlan_match()
648 struct dsa_switch *ds = dp->ds; in dsa_port_do_vlan_add() local
655 return ds->ops->port_vlan_add(ds, port, vlan, extack); in dsa_port_do_vlan_add()
679 err = ds->ops->port_vlan_add(ds, port, vlan, extack); in dsa_port_do_vlan_add()
698 struct dsa_switch *ds = dp->ds; in dsa_port_do_vlan_del() local
705 return ds->ops->port_vlan_del(ds, port, vlan); in dsa_port_do_vlan_del()
718 err = ds->ops->port_vlan_del(ds, port, vlan); in dsa_port_do_vlan_del()
733 static int dsa_switch_vlan_add(struct dsa_switch *ds, in dsa_switch_vlan_add() argument
739 if (!ds->ops->port_vlan_add) in dsa_switch_vlan_add()
742 dsa_switch_for_each_port(dp, ds) { in dsa_switch_vlan_add()
754 static int dsa_switch_vlan_del(struct dsa_switch *ds, in dsa_switch_vlan_del() argument
760 if (!ds->ops->port_vlan_del) in dsa_switch_vlan_del()
763 dsa_switch_for_each_port(dp, ds) { in dsa_switch_vlan_del()
774 static int dsa_switch_host_vlan_add(struct dsa_switch *ds, in dsa_switch_host_vlan_add() argument
780 if (!ds->ops->port_vlan_add) in dsa_switch_host_vlan_add()
783 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_vlan_add()
795 static int dsa_switch_host_vlan_del(struct dsa_switch *ds, in dsa_switch_host_vlan_del() argument
801 if (!ds->ops->port_vlan_del) in dsa_switch_host_vlan_del()
804 dsa_switch_for_each_port(dp, ds) { in dsa_switch_host_vlan_del()
815 static int dsa_switch_change_tag_proto(struct dsa_switch *ds, in dsa_switch_change_tag_proto() argument
822 if (!ds->ops->change_tag_protocol) in dsa_switch_change_tag_proto()
827 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_change_tag_proto()
831 dsa_switch_for_each_cpu_port(cpu_dp, ds) in dsa_switch_change_tag_proto()
838 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_change_tag_proto()
860 dsa_switch_connect_tag_proto(struct dsa_switch *ds, in dsa_switch_connect_tag_proto() argument
868 err = tag_ops->connect(ds); in dsa_switch_connect_tag_proto()
873 if (!ds->ops->connect_tag_protocol) in dsa_switch_connect_tag_proto()
877 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_connect_tag_proto()
881 tag_ops->disconnect(ds); in dsa_switch_connect_tag_proto()
889 dsa_switch_disconnect_tag_proto(struct dsa_switch *ds, in dsa_switch_disconnect_tag_proto() argument
895 if (tag_ops->disconnect && ds->tagger_data) in dsa_switch_disconnect_tag_proto()
896 tag_ops->disconnect(ds); in dsa_switch_disconnect_tag_proto()
905 dsa_switch_master_state_change(struct dsa_switch *ds, in dsa_switch_master_state_change() argument
908 if (!ds->ops->master_state_change) in dsa_switch_master_state_change()
911 ds->ops->master_state_change(ds, info->master, info->operational); in dsa_switch_master_state_change()
919 struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb); in dsa_switch_event() local
924 err = dsa_switch_ageing_time(ds, info); in dsa_switch_event()
927 err = dsa_switch_bridge_join(ds, info); in dsa_switch_event()
930 err = dsa_switch_bridge_leave(ds, info); in dsa_switch_event()
933 err = dsa_switch_fdb_add(ds, info); in dsa_switch_event()
936 err = dsa_switch_fdb_del(ds, info); in dsa_switch_event()
939 err = dsa_switch_host_fdb_add(ds, info); in dsa_switch_event()
942 err = dsa_switch_host_fdb_del(ds, info); in dsa_switch_event()
945 err = dsa_switch_lag_fdb_add(ds, info); in dsa_switch_event()
948 err = dsa_switch_lag_fdb_del(ds, info); in dsa_switch_event()
951 err = dsa_switch_lag_change(ds, info); in dsa_switch_event()
954 err = dsa_switch_lag_join(ds, info); in dsa_switch_event()
957 err = dsa_switch_lag_leave(ds, info); in dsa_switch_event()
960 err = dsa_switch_mdb_add(ds, info); in dsa_switch_event()
963 err = dsa_switch_mdb_del(ds, info); in dsa_switch_event()
966 err = dsa_switch_host_mdb_add(ds, info); in dsa_switch_event()
969 err = dsa_switch_host_mdb_del(ds, info); in dsa_switch_event()
972 err = dsa_switch_vlan_add(ds, info); in dsa_switch_event()
975 err = dsa_switch_vlan_del(ds, info); in dsa_switch_event()
978 err = dsa_switch_host_vlan_add(ds, info); in dsa_switch_event()
981 err = dsa_switch_host_vlan_del(ds, info); in dsa_switch_event()
984 err = dsa_switch_mtu(ds, info); in dsa_switch_event()
987 err = dsa_switch_change_tag_proto(ds, info); in dsa_switch_event()
990 err = dsa_switch_connect_tag_proto(ds, info); in dsa_switch_event()
993 err = dsa_switch_disconnect_tag_proto(ds, info); in dsa_switch_event()
996 err = dsa_switch_tag_8021q_vlan_add(ds, info); in dsa_switch_event()
999 err = dsa_switch_tag_8021q_vlan_del(ds, info); in dsa_switch_event()
1002 err = dsa_switch_master_state_change(ds, info); in dsa_switch_event()
1010 dev_dbg(ds->dev, "breaking chain for DSA event %lu (%d)\n", in dsa_switch_event()
1016 int dsa_switch_register_notifier(struct dsa_switch *ds) in dsa_switch_register_notifier() argument
1018 ds->nb.notifier_call = dsa_switch_event; in dsa_switch_register_notifier()
1020 return raw_notifier_chain_register(&ds->dst->nh, &ds->nb); in dsa_switch_register_notifier()
1023 void dsa_switch_unregister_notifier(struct dsa_switch *ds) in dsa_switch_unregister_notifier() argument
1027 err = raw_notifier_chain_unregister(&ds->dst->nh, &ds->nb); in dsa_switch_unregister_notifier()
1029 dev_err(ds->dev, "failed to unregister notifier (%d)\n", err); in dsa_switch_unregister_notifier()