Lines Matching refs:dst

64 void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag)  in dsa_lag_map()  argument
68 for (id = 1; id <= dst->lags_len; id++) { in dsa_lag_map()
69 if (!dsa_lag_by_id(dst, id)) { in dsa_lag_map()
70 dst->lags[id - 1] = lag; in dsa_lag_map()
92 void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag) in dsa_lag_unmap() argument
96 dsa_lags_foreach_id(id, dst) { in dsa_lag_unmap()
97 if (dsa_lag_by_id(dst, id) == lag) { in dsa_lag_unmap()
98 dst->lags[id - 1] = NULL; in dsa_lag_unmap()
105 struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst, in dsa_tree_lag_find() argument
110 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_lag_find()
117 struct dsa_bridge *dsa_tree_bridge_find(struct dsa_switch_tree *dst, in dsa_tree_bridge_find() argument
122 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_bridge_find()
131 struct dsa_switch_tree *dst; in dsa_bridge_num_find() local
133 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_bridge_num_find()
136 bridge = dsa_tree_bridge_find(dst, bridge_dev); in dsa_bridge_num_find()
182 struct dsa_switch_tree *dst; in dsa_switch_find() local
185 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_switch_find()
186 if (dst->index != tree_index) in dsa_switch_find()
189 list_for_each_entry(dp, &dst->ports, list) { in dsa_switch_find()
203 struct dsa_switch_tree *dst; in dsa_tree_find() local
205 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
206 if (dst->index == index) in dsa_tree_find()
207 return dst; in dsa_tree_find()
214 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
216 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
217 if (!dst) in dsa_tree_alloc()
220 dst->index = index; in dsa_tree_alloc()
222 INIT_LIST_HEAD(&dst->rtable); in dsa_tree_alloc()
224 INIT_LIST_HEAD(&dst->ports); in dsa_tree_alloc()
226 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
227 list_add_tail(&dst->list, &dsa_tree_list); in dsa_tree_alloc()
229 kref_init(&dst->refcount); in dsa_tree_alloc()
231 return dst; in dsa_tree_alloc()
234 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
236 if (dst->tag_ops) in dsa_tree_free()
237 dsa_tag_driver_put(dst->tag_ops); in dsa_tree_free()
238 list_del(&dst->list); in dsa_tree_free()
239 kfree(dst); in dsa_tree_free()
242 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
244 if (dst) in dsa_tree_get()
245 kref_get(&dst->refcount); in dsa_tree_get()
247 return dst; in dsa_tree_get()
252 struct dsa_switch_tree *dst; in dsa_tree_touch() local
254 dst = dsa_tree_find(index); in dsa_tree_touch()
255 if (dst) in dsa_tree_touch()
256 return dsa_tree_get(dst); in dsa_tree_touch()
263 struct dsa_switch_tree *dst; in dsa_tree_release() local
265 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
267 dsa_tree_free(dst); in dsa_tree_release()
270 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
272 if (dst) in dsa_tree_put()
273 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
276 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
281 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_port_by_node()
292 struct dsa_switch_tree *dst; in dsa_link_touch() local
295 dst = ds->dst; in dsa_link_touch()
297 list_for_each_entry(dl, &dst->rtable, list) in dsa_link_touch()
309 list_add_tail(&dl->list, &dst->rtable); in dsa_link_touch()
317 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
325 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
341 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
346 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_routing_table()
357 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
361 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_first_cpu()
368 struct net_device *dsa_tree_find_first_conduit(struct dsa_switch_tree *dst) in dsa_tree_find_first_conduit() argument
372 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_find_first_conduit()
379 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
383 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
385 pr_err("DSA: tree %d has no CPU port\n", dst->index); in dsa_tree_setup_default_cpu()
389 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_default_cpu()
423 static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_cpu_ports() argument
427 list_for_each_entry(cpu_dp, &dst->ports, list) { in dsa_tree_setup_cpu_ports()
446 return dsa_tree_setup_default_cpu(dst); in dsa_tree_setup_cpu_ports()
449 static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_cpu_ports() argument
453 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_cpu_ports()
571 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
572 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol() local
575 if (tag_ops->proto == dst->default_proto) in dsa_switch_setup_tag_protocol()
615 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
714 static void dsa_tree_teardown_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_ports() argument
718 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
724 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
729 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
733 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
738 static int dsa_tree_setup_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_ports() argument
743 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_ports()
751 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_ports()
765 dsa_tree_teardown_ports(dst); in dsa_tree_setup_ports()
770 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
775 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
778 dsa_tree_teardown_switches(dst); in dsa_tree_setup_switches()
786 static int dsa_tree_setup_conduit(struct dsa_switch_tree *dst) in dsa_tree_setup_conduit() argument
793 dsa_tree_for_each_cpu_port(cpu_dp, dst) { in dsa_tree_setup_conduit()
803 dsa_tree_conduit_admin_state_change(dst, conduit, admin_up); in dsa_tree_setup_conduit()
804 dsa_tree_conduit_oper_state_change(dst, conduit, in dsa_tree_setup_conduit()
813 static void dsa_tree_teardown_conduit(struct dsa_switch_tree *dst) in dsa_tree_teardown_conduit() argument
819 dsa_tree_for_each_cpu_port(cpu_dp, dst) { in dsa_tree_teardown_conduit()
826 dsa_tree_conduit_admin_state_change(dst, conduit, false); in dsa_tree_teardown_conduit()
834 static int dsa_tree_setup_lags(struct dsa_switch_tree *dst) in dsa_tree_setup_lags() argument
839 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_lags()
847 dst->lags = kcalloc(len, sizeof(*dst->lags), GFP_KERNEL); in dsa_tree_setup_lags()
848 if (!dst->lags) in dsa_tree_setup_lags()
851 dst->lags_len = len; in dsa_tree_setup_lags()
855 static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst) in dsa_tree_teardown_lags() argument
857 kfree(dst->lags); in dsa_tree_teardown_lags()
860 static void dsa_tree_teardown_routing_table(struct dsa_switch_tree *dst) in dsa_tree_teardown_routing_table() argument
864 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown_routing_table()
870 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
875 if (dst->setup) { in dsa_tree_setup()
877 dst->index); in dsa_tree_setup()
881 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
885 err = dsa_tree_setup_cpu_ports(dst); in dsa_tree_setup()
889 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
893 err = dsa_tree_setup_ports(dst); in dsa_tree_setup()
897 err = dsa_tree_setup_conduit(dst); in dsa_tree_setup()
901 err = dsa_tree_setup_lags(dst); in dsa_tree_setup()
905 dst->setup = true; in dsa_tree_setup()
907 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
912 dsa_tree_teardown_conduit(dst); in dsa_tree_setup()
914 dsa_tree_teardown_ports(dst); in dsa_tree_setup()
916 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
918 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_setup()
920 dsa_tree_teardown_routing_table(dst); in dsa_tree_setup()
925 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
927 if (!dst->setup) in dsa_tree_teardown()
930 dsa_tree_teardown_lags(dst); in dsa_tree_teardown()
932 dsa_tree_teardown_conduit(dst); in dsa_tree_teardown()
934 dsa_tree_teardown_ports(dst); in dsa_tree_teardown()
936 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
938 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_teardown()
940 dsa_tree_teardown_routing_table(dst); in dsa_tree_teardown()
942 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
944 dst->setup = false; in dsa_tree_teardown()
947 static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_bind_tag_proto() argument
950 const struct dsa_device_ops *old_tag_ops = dst->tag_ops; in dsa_tree_bind_tag_proto()
954 dst->tag_ops = tag_ops; in dsa_tree_bind_tag_proto()
960 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_CONNECT, &info); in dsa_tree_bind_tag_proto()
966 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
972 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
973 dst->tag_ops = old_tag_ops; in dsa_tree_bind_tag_proto()
982 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_change_tag_proto() argument
998 dsa_tree_for_each_user_port(dp, dst) { in dsa_tree_change_tag_proto()
1008 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1012 err = dsa_tree_bind_tag_proto(dst, tag_ops); in dsa_tree_change_tag_proto()
1022 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1028 static void dsa_tree_conduit_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_state_change() argument
1037 dsa_tree_notify(dst, DSA_NOTIFIER_CONDUIT_STATE_CHANGE, &info); in dsa_tree_conduit_state_change()
1040 void dsa_tree_conduit_admin_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_admin_state_change() argument
1060 dsa_tree_conduit_state_change(dst, conduit); in dsa_tree_conduit_admin_state_change()
1063 void dsa_tree_conduit_oper_state_change(struct dsa_switch_tree *dst, in dsa_tree_conduit_oper_state_change() argument
1083 dsa_tree_conduit_state_change(dst, conduit); in dsa_tree_conduit_oper_state_change()
1088 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
1108 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
1159 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
1164 if (dst->default_proto) { in dsa_port_parse_cpu()
1165 if (dst->default_proto != default_proto) { in dsa_port_parse_cpu()
1171 dst->default_proto = default_proto; in dsa_port_parse_cpu()
1201 if (dst->tag_ops) { in dsa_port_parse_cpu()
1202 if (dst->tag_ops != tag_ops) { in dsa_port_parse_cpu()
1215 dst->tag_ops = tag_ops; in dsa_port_parse_cpu()
1220 dsa_port_set_tag_protocol(dp, dst->tag_ops); in dsa_port_parse_cpu()
1221 dp->dst = dst; in dsa_port_parse_cpu()
1337 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1338 if (!ds->dst) in dsa_switch_parse_member_of()
1341 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1344 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1348 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1349 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1474 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1475 if (!ds->dst) in dsa_switch_parse()
1535 struct dsa_switch_tree *dst; in dsa_switch_probe() local
1564 dst = ds->dst; in dsa_switch_probe()
1565 dsa_tree_get(dst); in dsa_switch_probe()
1566 err = dsa_tree_setup(dst); in dsa_switch_probe()
1569 dsa_tree_put(dst); in dsa_switch_probe()
1581 dsa_tree_put(ds->dst); in dsa_register_switch()
1590 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
1592 dsa_tree_teardown(dst); in dsa_switch_remove()
1594 dsa_tree_put(dst); in dsa_switch_remove()