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 int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
870 if (dst->setup) { in dsa_tree_setup()
872 dst->index); in dsa_tree_setup()
876 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
880 err = dsa_tree_setup_cpu_ports(dst); in dsa_tree_setup()
884 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
888 err = dsa_tree_setup_ports(dst); in dsa_tree_setup()
892 err = dsa_tree_setup_conduit(dst); in dsa_tree_setup()
896 err = dsa_tree_setup_lags(dst); in dsa_tree_setup()
900 dst->setup = true; in dsa_tree_setup()
902 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
907 dsa_tree_teardown_conduit(dst); in dsa_tree_setup()
909 dsa_tree_teardown_ports(dst); in dsa_tree_setup()
911 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
913 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_setup()
918 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
922 if (!dst->setup) in dsa_tree_teardown()
925 dsa_tree_teardown_lags(dst); in dsa_tree_teardown()
927 dsa_tree_teardown_conduit(dst); in dsa_tree_teardown()
929 dsa_tree_teardown_ports(dst); in dsa_tree_teardown()
931 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
933 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_teardown()
935 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown()
940 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
942 dst->setup = false; in dsa_tree_teardown()
945 static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_bind_tag_proto() argument
948 const struct dsa_device_ops *old_tag_ops = dst->tag_ops; in dsa_tree_bind_tag_proto()
952 dst->tag_ops = tag_ops; in dsa_tree_bind_tag_proto()
958 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_CONNECT, &info); in dsa_tree_bind_tag_proto()
964 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
970 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
971 dst->tag_ops = old_tag_ops; in dsa_tree_bind_tag_proto()
980 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_change_tag_proto() argument
996 dsa_tree_for_each_user_port(dp, dst) { in dsa_tree_change_tag_proto()
1006 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1010 err = dsa_tree_bind_tag_proto(dst, tag_ops); in dsa_tree_change_tag_proto()
1020 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1026 static void dsa_tree_conduit_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_state_change() argument
1035 dsa_tree_notify(dst, DSA_NOTIFIER_CONDUIT_STATE_CHANGE, &info); in dsa_tree_conduit_state_change()
1038 void dsa_tree_conduit_admin_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_admin_state_change() argument
1058 dsa_tree_conduit_state_change(dst, conduit); in dsa_tree_conduit_admin_state_change()
1061 void dsa_tree_conduit_oper_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_oper_state_change() argument
1081 dsa_tree_conduit_state_change(dst, conduit); in dsa_tree_conduit_oper_state_change()
1086 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
1106 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
1157 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
1162 if (dst->default_proto) { in dsa_port_parse_cpu()
1163 if (dst->default_proto != default_proto) { in dsa_port_parse_cpu()
1169 dst->default_proto = default_proto; in dsa_port_parse_cpu()
1199 if (dst->tag_ops) { in dsa_port_parse_cpu()
1200 if (dst->tag_ops != tag_ops) { in dsa_port_parse_cpu()
1213 dst->tag_ops = tag_ops; in dsa_port_parse_cpu()
1218 dsa_port_set_tag_protocol(dp, dst->tag_ops); in dsa_port_parse_cpu()
1219 dp->dst = dst; in dsa_port_parse_cpu()
1324 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1325 if (!ds->dst) in dsa_switch_parse_member_of()
1328 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1331 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1335 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1336 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1468 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1469 if (!ds->dst) in dsa_switch_parse()
1494 struct dsa_switch_tree *dst; in dsa_switch_probe() local
1531 dst = ds->dst; in dsa_switch_probe()
1532 dsa_tree_get(dst); in dsa_switch_probe()
1533 err = dsa_tree_setup(dst); in dsa_switch_probe()
1536 dsa_tree_put(dst); in dsa_switch_probe()
1548 dsa_tree_put(ds->dst); in dsa_register_switch()
1557 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
1559 dsa_tree_teardown(dst); in dsa_switch_remove()
1561 dsa_tree_put(dst); in dsa_switch_remove()