Lines Matching refs:dst
32 struct dsa_switch_tree *dst; in dsa_tree_find() local
34 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
35 if (dst->index == index) in dsa_tree_find()
36 return dst; in dsa_tree_find()
43 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
45 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
46 if (!dst) in dsa_tree_alloc()
49 dst->index = index; in dsa_tree_alloc()
51 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
52 list_add_tail(&dsa_tree_list, &dst->list); in dsa_tree_alloc()
54 kref_init(&dst->refcount); in dsa_tree_alloc()
56 return dst; in dsa_tree_alloc()
59 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
61 list_del(&dst->list); in dsa_tree_free()
62 kfree(dst); in dsa_tree_free()
65 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
67 if (dst) in dsa_tree_get()
68 kref_get(&dst->refcount); in dsa_tree_get()
70 return dst; in dsa_tree_get()
75 struct dsa_switch_tree *dst; in dsa_tree_touch() local
77 dst = dsa_tree_find(index); in dsa_tree_touch()
78 if (dst) in dsa_tree_touch()
79 return dsa_tree_get(dst); in dsa_tree_touch()
86 struct dsa_switch_tree *dst; in dsa_tree_release() local
88 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
90 dsa_tree_free(dst); in dsa_tree_release()
93 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
95 if (dst) in dsa_tree_put()
96 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
114 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
122 ds = dst->ds[device]; in dsa_tree_find_port_by_node()
140 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
147 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
181 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
188 ds = dst->ds[device]; in dsa_tree_setup_routing_table()
200 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
207 ds = dst->ds[device]; in dsa_tree_find_first_cpu()
222 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
229 dst->cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
230 if (!dst->cpu_dp) { in dsa_tree_setup_default_cpu()
237 ds = dst->ds[device]; in dsa_tree_setup_default_cpu()
245 dp->cpu_dp = dst->cpu_dp; in dsa_tree_setup_default_cpu()
252 static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_teardown_default_cpu() argument
255 dst->cpu_dp = NULL; in dsa_tree_teardown_default_cpu()
401 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
409 ds = dst->ds[device]; in dsa_tree_setup_switches()
429 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
436 ds = dst->ds[device]; in dsa_tree_teardown_switches()
450 static int dsa_tree_setup_master(struct dsa_switch_tree *dst) in dsa_tree_setup_master() argument
452 struct dsa_port *cpu_dp = dst->cpu_dp; in dsa_tree_setup_master()
459 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) in dsa_tree_teardown_master() argument
461 struct dsa_port *cpu_dp = dst->cpu_dp; in dsa_tree_teardown_master()
467 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
472 if (dst->setup) { in dsa_tree_setup()
474 dst->index); in dsa_tree_setup()
478 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
482 err = dsa_tree_setup_default_cpu(dst); in dsa_tree_setup()
486 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
490 err = dsa_tree_setup_master(dst); in dsa_tree_setup()
494 dst->setup = true; in dsa_tree_setup()
496 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
501 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
503 if (!dst->setup) in dsa_tree_teardown()
506 dsa_tree_teardown_master(dst); in dsa_tree_teardown()
508 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
510 dsa_tree_teardown_default_cpu(dst); in dsa_tree_teardown()
512 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
514 dst->setup = false; in dsa_tree_teardown()
517 static void dsa_tree_remove_switch(struct dsa_switch_tree *dst, in dsa_tree_remove_switch() argument
520 dsa_tree_teardown(dst); in dsa_tree_remove_switch()
522 dst->ds[index] = NULL; in dsa_tree_remove_switch()
523 dsa_tree_put(dst); in dsa_tree_remove_switch()
526 static int dsa_tree_add_switch(struct dsa_switch_tree *dst, in dsa_tree_add_switch() argument
532 if (dst->ds[index]) in dsa_tree_add_switch()
535 dsa_tree_get(dst); in dsa_tree_add_switch()
536 dst->ds[index] = ds; in dsa_tree_add_switch()
538 err = dsa_tree_setup(dst); in dsa_tree_add_switch()
540 dsa_tree_remove_switch(dst, index); in dsa_tree_add_switch()
566 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
581 dp->dst = dst; in dsa_port_parse_cpu()
657 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
658 if (!ds->dst) in dsa_switch_parse_member_of()
735 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
736 if (!ds->dst) in dsa_switch_parse()
744 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_add() local
746 return dsa_tree_add_switch(dst, ds); in dsa_switch_add()
810 dsa_tree_put(ds->dst); in dsa_register_switch()
819 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
822 dsa_tree_remove_switch(dst, index); in dsa_switch_remove()