Lines Matching refs:dst

29 	struct dsa_switch_tree *dst;  in dsa_tree_find()  local
31 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
32 if (dst->index == index) in dsa_tree_find()
33 return dst; in dsa_tree_find()
40 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
42 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
43 if (!dst) in dsa_tree_alloc()
46 dst->index = index; in dsa_tree_alloc()
48 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
49 list_add_tail(&dst->list, &dsa_tree_list); in dsa_tree_alloc()
51 kref_init(&dst->refcount); in dsa_tree_alloc()
53 return dst; in dsa_tree_alloc()
56 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
58 list_del(&dst->list); in dsa_tree_free()
59 kfree(dst); in dsa_tree_free()
62 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
64 if (dst) in dsa_tree_get()
65 kref_get(&dst->refcount); in dsa_tree_get()
67 return dst; in dsa_tree_get()
72 struct dsa_switch_tree *dst; in dsa_tree_touch() local
74 dst = dsa_tree_find(index); in dsa_tree_touch()
75 if (dst) in dsa_tree_touch()
76 return dsa_tree_get(dst); in dsa_tree_touch()
83 struct dsa_switch_tree *dst; in dsa_tree_release() local
85 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
87 dsa_tree_free(dst); in dsa_tree_release()
90 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
92 if (dst) in dsa_tree_put()
93 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
111 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
119 ds = dst->ds[device]; in dsa_tree_find_port_by_node()
137 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
144 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
178 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
185 ds = dst->ds[device]; in dsa_tree_setup_routing_table()
197 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
204 ds = dst->ds[device]; in dsa_tree_find_first_cpu()
219 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
226 dst->cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
227 if (!dst->cpu_dp) { in dsa_tree_setup_default_cpu()
234 ds = dst->ds[device]; in dsa_tree_setup_default_cpu()
242 dp->cpu_dp = dst->cpu_dp; in dsa_tree_setup_default_cpu()
249 static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_teardown_default_cpu() argument
252 dst->cpu_dp = NULL; in dsa_tree_teardown_default_cpu()
258 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup() local
259 const unsigned char *id = (const unsigned char *)&dst->index; in dsa_port_setup()
260 const unsigned char len = sizeof(dst->index); in dsa_port_setup()
443 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
451 ds = dst->ds[device]; in dsa_tree_setup_switches()
478 ds = dst->ds[i]; in dsa_tree_setup_switches()
494 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
501 ds = dst->ds[device]; in dsa_tree_teardown_switches()
515 static int dsa_tree_setup_master(struct dsa_switch_tree *dst) in dsa_tree_setup_master() argument
517 struct dsa_port *cpu_dp = dst->cpu_dp; in dsa_tree_setup_master()
524 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) in dsa_tree_teardown_master() argument
526 struct dsa_port *cpu_dp = dst->cpu_dp; in dsa_tree_teardown_master()
532 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
537 if (dst->setup) { in dsa_tree_setup()
539 dst->index); in dsa_tree_setup()
543 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
547 err = dsa_tree_setup_default_cpu(dst); in dsa_tree_setup()
551 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
555 err = dsa_tree_setup_master(dst); in dsa_tree_setup()
559 dst->setup = true; in dsa_tree_setup()
561 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
566 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
568 dsa_tree_teardown_default_cpu(dst); in dsa_tree_setup()
573 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
575 if (!dst->setup) in dsa_tree_teardown()
578 dsa_tree_teardown_master(dst); in dsa_tree_teardown()
580 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
582 dsa_tree_teardown_default_cpu(dst); in dsa_tree_teardown()
584 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
586 dst->setup = false; in dsa_tree_teardown()
589 static void dsa_tree_remove_switch(struct dsa_switch_tree *dst, in dsa_tree_remove_switch() argument
592 dsa_tree_teardown(dst); in dsa_tree_remove_switch()
594 dst->ds[index] = NULL; in dsa_tree_remove_switch()
595 dsa_tree_put(dst); in dsa_tree_remove_switch()
598 static int dsa_tree_add_switch(struct dsa_switch_tree *dst, in dsa_tree_add_switch() argument
604 if (dst->ds[index]) in dsa_tree_add_switch()
607 dsa_tree_get(dst); in dsa_tree_add_switch()
608 dst->ds[index] = ds; in dsa_tree_add_switch()
610 err = dsa_tree_setup(dst); in dsa_tree_add_switch()
612 dst->ds[index] = NULL; in dsa_tree_add_switch()
613 dsa_tree_put(dst); in dsa_tree_add_switch()
640 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
658 dp->dst = dst; in dsa_port_parse_cpu()
738 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
739 if (!ds->dst) in dsa_switch_parse_member_of()
816 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
817 if (!ds->dst) in dsa_switch_parse()
825 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_add() local
827 return dsa_tree_add_switch(dst, ds); in dsa_switch_add()
876 dsa_tree_put(ds->dst); in dsa_register_switch()
885 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
888 dsa_tree_remove_switch(dst, index); in dsa_switch_remove()