Lines Matching refs:dst

37 int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v)  in dsa_tree_notify()  argument
39 struct raw_notifier_head *nh = &dst->nh; in dsa_tree_notify()
61 struct dsa_switch_tree *dst; in dsa_broadcast() local
64 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_broadcast()
65 err = dsa_tree_notify(dst, e, v); in dsa_broadcast()
84 void dsa_lag_map(struct dsa_switch_tree *dst, struct net_device *lag) in dsa_lag_map() argument
88 if (dsa_lag_id(dst, lag) >= 0) in dsa_lag_map()
92 for (id = 0; id < dst->lags_len; id++) { in dsa_lag_map()
93 if (!dsa_lag_dev(dst, id)) { in dsa_lag_map()
94 dst->lags[id] = lag; in dsa_lag_map()
115 void dsa_lag_unmap(struct dsa_switch_tree *dst, struct net_device *lag) in dsa_lag_unmap() argument
120 dsa_lag_foreach_port(dp, dst, lag) in dsa_lag_unmap()
124 dsa_lags_foreach_id(id, dst) { in dsa_lag_unmap()
125 if (dsa_lag_dev(dst, id) == lag) { in dsa_lag_unmap()
126 dst->lags[id] = NULL; in dsa_lag_unmap()
134 struct dsa_switch_tree *dst; in dsa_bridge_num_find() local
142 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_bridge_num_find()
143 list_for_each_entry(dp, &dst->ports, list) in dsa_bridge_num_find()
179 struct dsa_switch_tree *dst; in dsa_switch_find() local
182 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_switch_find()
183 if (dst->index != tree_index) in dsa_switch_find()
186 list_for_each_entry(dp, &dst->ports, list) { in dsa_switch_find()
200 struct dsa_switch_tree *dst; in dsa_tree_find() local
202 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
203 if (dst->index == index) in dsa_tree_find()
204 return dst; in dsa_tree_find()
211 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
213 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
214 if (!dst) in dsa_tree_alloc()
217 dst->index = index; in dsa_tree_alloc()
219 INIT_LIST_HEAD(&dst->rtable); in dsa_tree_alloc()
221 INIT_LIST_HEAD(&dst->ports); in dsa_tree_alloc()
223 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
224 list_add_tail(&dst->list, &dsa_tree_list); in dsa_tree_alloc()
226 kref_init(&dst->refcount); in dsa_tree_alloc()
228 return dst; in dsa_tree_alloc()
231 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
233 if (dst->tag_ops) in dsa_tree_free()
234 dsa_tag_driver_put(dst->tag_ops); in dsa_tree_free()
235 list_del(&dst->list); in dsa_tree_free()
236 kfree(dst); in dsa_tree_free()
239 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
241 if (dst) in dsa_tree_get()
242 kref_get(&dst->refcount); in dsa_tree_get()
244 return dst; in dsa_tree_get()
249 struct dsa_switch_tree *dst; in dsa_tree_touch() local
251 dst = dsa_tree_find(index); in dsa_tree_touch()
252 if (dst) in dsa_tree_touch()
253 return dsa_tree_get(dst); in dsa_tree_touch()
260 struct dsa_switch_tree *dst; in dsa_tree_release() local
262 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
264 dsa_tree_free(dst); in dsa_tree_release()
267 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
269 if (dst) in dsa_tree_put()
270 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
273 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
278 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_port_by_node()
289 struct dsa_switch_tree *dst; in dsa_link_touch() local
292 dst = ds->dst; in dsa_link_touch()
294 list_for_each_entry(dl, &dst->rtable, list) in dsa_link_touch()
306 list_add_tail(&dl->list, &dst->rtable); in dsa_link_touch()
314 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
322 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
338 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
343 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_routing_table()
354 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
358 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_first_cpu()
368 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
372 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
374 pr_err("DSA: tree %d has no CPU port\n", dst->index); in dsa_tree_setup_default_cpu()
378 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_default_cpu()
394 static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_cpu_ports() argument
398 list_for_each_entry(cpu_dp, &dst->ports, list) { in dsa_tree_setup_cpu_ports()
413 return dsa_tree_setup_default_cpu(dst); in dsa_tree_setup_cpu_ports()
416 static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_cpu_ports() argument
420 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_cpu_ports()
502 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup() local
509 id = (const unsigned char *)&dst->index; in dsa_port_devlink_setup()
510 len = sizeof(dst->index); in dsa_port_devlink_setup()
801 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
802 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol() local
806 if (tag_ops->proto == dst->default_proto) in dsa_switch_setup_tag_protocol()
942 static void dsa_tree_teardown_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_ports() argument
946 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
952 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
957 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
961 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
965 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
970 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
976 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
988 dsa_tree_teardown_ports(dst); in dsa_tree_setup_switches()
990 dsa_tree_teardown_switches(dst); in dsa_tree_setup_switches()
995 static int dsa_tree_setup_master(struct dsa_switch_tree *dst) in dsa_tree_setup_master() argument
1000 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_master()
1011 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) in dsa_tree_teardown_master() argument
1015 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_master()
1020 static int dsa_tree_setup_lags(struct dsa_switch_tree *dst) in dsa_tree_setup_lags() argument
1025 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_lags()
1033 dst->lags = kcalloc(len, sizeof(*dst->lags), GFP_KERNEL); in dsa_tree_setup_lags()
1034 if (!dst->lags) in dsa_tree_setup_lags()
1037 dst->lags_len = len; in dsa_tree_setup_lags()
1041 static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst) in dsa_tree_teardown_lags() argument
1043 kfree(dst->lags); in dsa_tree_teardown_lags()
1046 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
1051 if (dst->setup) { in dsa_tree_setup()
1053 dst->index); in dsa_tree_setup()
1057 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
1061 err = dsa_tree_setup_cpu_ports(dst); in dsa_tree_setup()
1065 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
1069 err = dsa_tree_setup_master(dst); in dsa_tree_setup()
1073 err = dsa_tree_setup_lags(dst); in dsa_tree_setup()
1077 dst->setup = true; in dsa_tree_setup()
1079 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
1084 dsa_tree_teardown_master(dst); in dsa_tree_setup()
1086 dsa_tree_teardown_ports(dst); in dsa_tree_setup()
1087 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
1089 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_setup()
1094 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
1098 if (!dst->setup) in dsa_tree_teardown()
1101 dsa_tree_teardown_lags(dst); in dsa_tree_teardown()
1103 dsa_tree_teardown_master(dst); in dsa_tree_teardown()
1105 dsa_tree_teardown_ports(dst); in dsa_tree_teardown()
1107 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
1109 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_teardown()
1111 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown()
1116 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
1118 dst->setup = false; in dsa_tree_teardown()
1125 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_change_tag_proto() argument
1145 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_change_tag_proto()
1154 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1158 dst->tag_ops = tag_ops; in dsa_tree_change_tag_proto()
1166 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1174 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
1190 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
1243 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
1249 if (dst->default_proto) { in dsa_port_parse_cpu()
1250 if (dst->default_proto != default_proto) { in dsa_port_parse_cpu()
1256 dst->default_proto = default_proto; in dsa_port_parse_cpu()
1279 if (dst->tag_ops) { in dsa_port_parse_cpu()
1280 if (dst->tag_ops != tag_ops) { in dsa_port_parse_cpu()
1293 dst->tag_ops = tag_ops; in dsa_port_parse_cpu()
1298 dsa_port_set_tag_protocol(dp, dst->tag_ops); in dsa_port_parse_cpu()
1299 dp->dst = dst; in dsa_port_parse_cpu()
1403 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1404 if (!ds->dst) in dsa_switch_parse_member_of()
1407 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1410 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1414 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1415 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1511 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1512 if (!ds->dst) in dsa_switch_parse()
1534 struct dsa_switch_tree *dst; in dsa_switch_probe() local
1563 dst = ds->dst; in dsa_switch_probe()
1564 dsa_tree_get(dst); in dsa_switch_probe()
1565 err = dsa_tree_setup(dst); in dsa_switch_probe()
1568 dsa_tree_put(dst); in dsa_switch_probe()
1580 dsa_tree_put(ds->dst); in dsa_register_switch()
1589 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
1591 dsa_tree_teardown(dst); in dsa_switch_remove()
1593 dsa_tree_put(dst); in dsa_switch_remove()