Lines Matching refs:dst

63 void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag)  in dsa_lag_map()  argument
67 for (id = 1; id <= dst->lags_len; id++) { in dsa_lag_map()
68 if (!dsa_lag_by_id(dst, id)) { in dsa_lag_map()
69 dst->lags[id - 1] = lag; in dsa_lag_map()
91 void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag) in dsa_lag_unmap() argument
95 dsa_lags_foreach_id(id, dst) { in dsa_lag_unmap()
96 if (dsa_lag_by_id(dst, id) == lag) { in dsa_lag_unmap()
97 dst->lags[id - 1] = NULL; in dsa_lag_unmap()
104 struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst, in dsa_tree_lag_find() argument
109 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_lag_find()
116 struct dsa_bridge *dsa_tree_bridge_find(struct dsa_switch_tree *dst, in dsa_tree_bridge_find() argument
121 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_bridge_find()
130 struct dsa_switch_tree *dst; in dsa_bridge_num_find() local
132 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_bridge_num_find()
135 bridge = dsa_tree_bridge_find(dst, bridge_dev); in dsa_bridge_num_find()
181 struct dsa_switch_tree *dst; in dsa_switch_find() local
184 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_switch_find()
185 if (dst->index != tree_index) in dsa_switch_find()
188 list_for_each_entry(dp, &dst->ports, list) { in dsa_switch_find()
202 struct dsa_switch_tree *dst; in dsa_tree_find() local
204 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
205 if (dst->index == index) in dsa_tree_find()
206 return dst; in dsa_tree_find()
213 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
215 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
216 if (!dst) in dsa_tree_alloc()
219 dst->index = index; in dsa_tree_alloc()
221 INIT_LIST_HEAD(&dst->rtable); in dsa_tree_alloc()
223 INIT_LIST_HEAD(&dst->ports); in dsa_tree_alloc()
225 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
226 list_add_tail(&dst->list, &dsa_tree_list); in dsa_tree_alloc()
228 kref_init(&dst->refcount); in dsa_tree_alloc()
230 return dst; in dsa_tree_alloc()
233 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
235 if (dst->tag_ops) in dsa_tree_free()
236 dsa_tag_driver_put(dst->tag_ops); in dsa_tree_free()
237 list_del(&dst->list); in dsa_tree_free()
238 kfree(dst); in dsa_tree_free()
241 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
243 if (dst) in dsa_tree_get()
244 kref_get(&dst->refcount); in dsa_tree_get()
246 return dst; in dsa_tree_get()
251 struct dsa_switch_tree *dst; in dsa_tree_touch() local
253 dst = dsa_tree_find(index); in dsa_tree_touch()
254 if (dst) in dsa_tree_touch()
255 return dsa_tree_get(dst); in dsa_tree_touch()
262 struct dsa_switch_tree *dst; in dsa_tree_release() local
264 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
266 dsa_tree_free(dst); in dsa_tree_release()
269 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
271 if (dst) in dsa_tree_put()
272 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
275 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
280 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_port_by_node()
291 struct dsa_switch_tree *dst; in dsa_link_touch() local
294 dst = ds->dst; in dsa_link_touch()
296 list_for_each_entry(dl, &dst->rtable, list) in dsa_link_touch()
308 list_add_tail(&dl->list, &dst->rtable); in dsa_link_touch()
316 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
324 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
340 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
345 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_routing_table()
356 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
360 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_first_cpu()
367 struct net_device *dsa_tree_find_first_conduit(struct dsa_switch_tree *dst) in dsa_tree_find_first_conduit() argument
373 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_find_first_conduit()
384 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
388 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
390 pr_err("DSA: tree %d has no CPU port\n", dst->index); in dsa_tree_setup_default_cpu()
394 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_default_cpu()
428 static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_cpu_ports() argument
432 list_for_each_entry(cpu_dp, &dst->ports, list) { in dsa_tree_setup_cpu_ports()
451 return dsa_tree_setup_default_cpu(dst); in dsa_tree_setup_cpu_ports()
454 static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_cpu_ports() argument
458 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_cpu_ports()
576 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
577 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol() local
580 if (tag_ops->proto == dst->default_proto) in dsa_switch_setup_tag_protocol()
620 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
719 static void dsa_tree_teardown_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_ports() argument
723 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
729 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
734 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
738 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
743 static int dsa_tree_setup_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_ports() argument
748 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_ports()
756 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_ports()
770 dsa_tree_teardown_ports(dst); in dsa_tree_setup_ports()
775 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
780 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
783 dsa_tree_teardown_switches(dst); in dsa_tree_setup_switches()
791 static int dsa_tree_setup_conduit(struct dsa_switch_tree *dst) in dsa_tree_setup_conduit() argument
798 dsa_tree_for_each_cpu_port(cpu_dp, dst) { in dsa_tree_setup_conduit()
808 dsa_tree_conduit_admin_state_change(dst, conduit, admin_up); in dsa_tree_setup_conduit()
809 dsa_tree_conduit_oper_state_change(dst, conduit, in dsa_tree_setup_conduit()
818 static void dsa_tree_teardown_conduit(struct dsa_switch_tree *dst) in dsa_tree_teardown_conduit() argument
824 dsa_tree_for_each_cpu_port(cpu_dp, dst) { in dsa_tree_teardown_conduit()
831 dsa_tree_conduit_admin_state_change(dst, conduit, false); in dsa_tree_teardown_conduit()
839 static int dsa_tree_setup_lags(struct dsa_switch_tree *dst) in dsa_tree_setup_lags() argument
844 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_lags()
852 dst->lags = kcalloc(len, sizeof(*dst->lags), GFP_KERNEL); in dsa_tree_setup_lags()
853 if (!dst->lags) in dsa_tree_setup_lags()
856 dst->lags_len = len; in dsa_tree_setup_lags()
860 static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst) in dsa_tree_teardown_lags() argument
862 kfree(dst->lags); in dsa_tree_teardown_lags()
865 static void dsa_tree_teardown_routing_table(struct dsa_switch_tree *dst) in dsa_tree_teardown_routing_table() argument
869 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown_routing_table()
875 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
880 if (dst->setup) { in dsa_tree_setup()
882 dst->index); in dsa_tree_setup()
886 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
890 err = dsa_tree_setup_cpu_ports(dst); in dsa_tree_setup()
894 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
898 err = dsa_tree_setup_ports(dst); in dsa_tree_setup()
902 err = dsa_tree_setup_conduit(dst); in dsa_tree_setup()
906 err = dsa_tree_setup_lags(dst); in dsa_tree_setup()
910 dst->setup = true; in dsa_tree_setup()
912 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
917 dsa_tree_teardown_conduit(dst); in dsa_tree_setup()
919 dsa_tree_teardown_ports(dst); in dsa_tree_setup()
921 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
923 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_setup()
925 dsa_tree_teardown_routing_table(dst); in dsa_tree_setup()
930 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
932 if (!dst->setup) in dsa_tree_teardown()
935 dsa_tree_teardown_lags(dst); in dsa_tree_teardown()
937 dsa_tree_teardown_conduit(dst); in dsa_tree_teardown()
939 dsa_tree_teardown_ports(dst); in dsa_tree_teardown()
941 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
943 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_teardown()
945 dsa_tree_teardown_routing_table(dst); in dsa_tree_teardown()
947 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
949 dst->setup = false; in dsa_tree_teardown()
952 static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_bind_tag_proto() argument
955 const struct dsa_device_ops *old_tag_ops = dst->tag_ops; in dsa_tree_bind_tag_proto()
959 dst->tag_ops = tag_ops; in dsa_tree_bind_tag_proto()
965 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_CONNECT, &info); in dsa_tree_bind_tag_proto()
971 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
977 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
978 dst->tag_ops = old_tag_ops; in dsa_tree_bind_tag_proto()
987 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_change_tag_proto() argument
1003 dsa_tree_for_each_user_port(dp, dst) { in dsa_tree_change_tag_proto()
1013 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1017 err = dsa_tree_bind_tag_proto(dst, tag_ops); in dsa_tree_change_tag_proto()
1027 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1033 static void dsa_tree_conduit_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_state_change() argument
1042 dsa_tree_notify(dst, DSA_NOTIFIER_CONDUIT_STATE_CHANGE, &info); in dsa_tree_conduit_state_change()
1045 void dsa_tree_conduit_admin_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_admin_state_change() argument
1065 dsa_tree_conduit_state_change(dst, conduit); in dsa_tree_conduit_admin_state_change()
1068 void dsa_tree_conduit_oper_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_oper_state_change() argument
1088 dsa_tree_conduit_state_change(dst, conduit); in dsa_tree_conduit_oper_state_change()
1093 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
1113 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
1164 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
1169 if (dst->default_proto) { in dsa_port_parse_cpu()
1170 if (dst->default_proto != default_proto) { in dsa_port_parse_cpu()
1176 dst->default_proto = default_proto; in dsa_port_parse_cpu()
1206 if (dst->tag_ops) { in dsa_port_parse_cpu()
1207 if (dst->tag_ops != tag_ops) { in dsa_port_parse_cpu()
1220 dst->tag_ops = tag_ops; in dsa_port_parse_cpu()
1225 dsa_port_set_tag_protocol(dp, dst->tag_ops); in dsa_port_parse_cpu()
1226 dp->dst = dst; in dsa_port_parse_cpu()
1331 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1332 if (!ds->dst) in dsa_switch_parse_member_of()
1335 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1338 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1342 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1343 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1475 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1476 if (!ds->dst) in dsa_switch_parse()
1533 struct dsa_switch_tree *dst; in dsa_switch_probe() local
1562 dst = ds->dst; in dsa_switch_probe()
1563 dsa_tree_get(dst); in dsa_switch_probe()
1564 err = dsa_tree_setup(dst); in dsa_switch_probe()
1567 dsa_tree_put(dst); in dsa_switch_probe()
1579 dsa_tree_put(ds->dst); in dsa_register_switch()
1588 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
1590 dsa_tree_teardown(dst); in dsa_switch_remove()
1592 dsa_tree_put(dst); in dsa_switch_remove()