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()
439 list_for_each_entry(dp, &ds->dst->ports, list) { in dsa_switch_setup()
478 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_setup()
505 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_teardown()
516 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
521 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
527 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
536 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_switches()
539 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_switches()
545 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
549 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
552 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
556 static int dsa_tree_setup_master(struct dsa_switch_tree *dst) in dsa_tree_setup_master() argument
561 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_master()
572 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) in dsa_tree_teardown_master() argument
576 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_master()
581 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
586 if (dst->setup) { in dsa_tree_setup()
588 dst->index); in dsa_tree_setup()
592 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
596 err = dsa_tree_setup_default_cpu(dst); in dsa_tree_setup()
600 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
604 err = dsa_tree_setup_master(dst); in dsa_tree_setup()
608 dst->setup = true; in dsa_tree_setup()
610 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
615 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
617 dsa_tree_teardown_default_cpu(dst); in dsa_tree_setup()
622 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
626 if (!dst->setup) in dsa_tree_teardown()
629 dsa_tree_teardown_master(dst); in dsa_tree_teardown()
631 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
633 dsa_tree_teardown_default_cpu(dst); in dsa_tree_teardown()
635 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown()
640 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
642 dst->setup = false; in dsa_tree_teardown()
647 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
650 list_for_each_entry(dp, &dst->ports, list) in dsa_port_touch()
662 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
714 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
733 dp->dst = dst; in dsa_port_parse_cpu()
815 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
816 if (!ds->dst) in dsa_switch_parse_member_of()
913 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
914 if (!ds->dst) in dsa_switch_parse()
926 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_release_ports() local
929 list_for_each_entry_safe(dp, next, &dst->ports, list) { in dsa_switch_release_ports()
939 struct dsa_switch_tree *dst; in dsa_switch_probe() local
968 dst = ds->dst; in dsa_switch_probe()
969 dsa_tree_get(dst); in dsa_switch_probe()
970 err = dsa_tree_setup(dst); in dsa_switch_probe()
973 dsa_tree_put(dst); in dsa_switch_probe()
985 dsa_tree_put(ds->dst); in dsa_register_switch()
994 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
996 dsa_tree_teardown(dst); in dsa_switch_remove()
998 dsa_tree_put(dst); in dsa_switch_remove()