Lines Matching refs:dst
26 struct dsa_switch_tree *dst; in dsa_switch_find() local
29 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_switch_find()
30 if (dst->index != tree_index) in dsa_switch_find()
33 list_for_each_entry(dp, &dst->ports, list) { in dsa_switch_find()
47 struct dsa_switch_tree *dst; in dsa_tree_find() local
49 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
50 if (dst->index == index) in dsa_tree_find()
51 return dst; in dsa_tree_find()
58 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
60 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
61 if (!dst) in dsa_tree_alloc()
64 dst->index = index; in dsa_tree_alloc()
66 INIT_LIST_HEAD(&dst->rtable); in dsa_tree_alloc()
68 INIT_LIST_HEAD(&dst->ports); in dsa_tree_alloc()
70 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
71 list_add_tail(&dst->list, &dsa_tree_list); in dsa_tree_alloc()
73 kref_init(&dst->refcount); in dsa_tree_alloc()
75 return dst; in dsa_tree_alloc()
78 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
80 list_del(&dst->list); in dsa_tree_free()
81 kfree(dst); in dsa_tree_free()
84 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
86 if (dst) in dsa_tree_get()
87 kref_get(&dst->refcount); in dsa_tree_get()
89 return dst; in dsa_tree_get()
94 struct dsa_switch_tree *dst; in dsa_tree_touch() local
96 dst = dsa_tree_find(index); in dsa_tree_touch()
97 if (dst) in dsa_tree_touch()
98 return dsa_tree_get(dst); in dsa_tree_touch()
105 struct dsa_switch_tree *dst; in dsa_tree_release() local
107 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
109 dsa_tree_free(dst); in dsa_tree_release()
112 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
114 if (dst) in dsa_tree_put()
115 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
133 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
138 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_port_by_node()
149 struct dsa_switch_tree *dst; in dsa_link_touch() local
152 dst = ds->dst; in dsa_link_touch()
154 list_for_each_entry(dl, &dst->rtable, list) in dsa_link_touch()
166 list_add_tail(&dl->list, &dst->rtable); in dsa_link_touch()
174 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
182 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
198 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
203 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_routing_table()
214 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
218 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_first_cpu()
225 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
229 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
231 pr_err("DSA: tree %d has no CPU port\n", dst->index); in dsa_tree_setup_default_cpu()
236 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_default_cpu()
243 static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_teardown_default_cpu() argument
247 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_default_cpu()
315 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup() local
322 id = (const unsigned char *)&dst->index; in dsa_port_devlink_setup()
323 len = sizeof(dst->index); in dsa_port_devlink_setup()
443 list_for_each_entry(dp, &ds->dst->ports, list) { in dsa_switch_setup()
488 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_setup()
518 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_teardown()
529 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
534 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
540 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
555 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_switches()
558 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_switches()
564 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
568 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
571 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
575 static int dsa_tree_setup_master(struct dsa_switch_tree *dst) in dsa_tree_setup_master() argument
580 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_master()
591 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) in dsa_tree_teardown_master() argument
595 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_master()
600 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
605 if (dst->setup) { in dsa_tree_setup()
607 dst->index); in dsa_tree_setup()
611 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
615 err = dsa_tree_setup_default_cpu(dst); in dsa_tree_setup()
619 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
623 err = dsa_tree_setup_master(dst); in dsa_tree_setup()
627 dst->setup = true; in dsa_tree_setup()
629 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
634 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
636 dsa_tree_teardown_default_cpu(dst); in dsa_tree_setup()
641 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
645 if (!dst->setup) in dsa_tree_teardown()
648 dsa_tree_teardown_master(dst); in dsa_tree_teardown()
650 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
652 dsa_tree_teardown_default_cpu(dst); in dsa_tree_teardown()
654 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown()
659 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
661 dst->setup = false; in dsa_tree_teardown()
666 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
669 list_for_each_entry(dp, &dst->ports, list) in dsa_port_touch()
681 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
733 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
752 dp->dst = dst; in dsa_port_parse_cpu()
835 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
836 if (!ds->dst) in dsa_switch_parse_member_of()
933 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
934 if (!ds->dst) in dsa_switch_parse()
946 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_release_ports() local
949 list_for_each_entry_safe(dp, next, &dst->ports, list) { in dsa_switch_release_ports()
959 struct dsa_switch_tree *dst; in dsa_switch_probe() local
988 dst = ds->dst; in dsa_switch_probe()
989 dsa_tree_get(dst); in dsa_switch_probe()
990 err = dsa_tree_setup(dst); in dsa_switch_probe()
993 dsa_tree_put(dst); in dsa_switch_probe()
1005 dsa_tree_put(ds->dst); in dsa_register_switch()
1014 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
1016 dsa_tree_teardown(dst); in dsa_switch_remove()
1018 dsa_tree_put(dst); in dsa_switch_remove()