Lines Matching refs:dst

39 int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v)  in dsa_tree_notify()  argument
41 struct raw_notifier_head *nh = &dst->nh; in dsa_tree_notify()
63 struct dsa_switch_tree *dst; in dsa_broadcast() local
66 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_broadcast()
67 err = dsa_tree_notify(dst, e, v); in dsa_broadcast()
86 void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag) in dsa_lag_map() argument
90 for (id = 1; id <= dst->lags_len; id++) { in dsa_lag_map()
91 if (!dsa_lag_by_id(dst, id)) { in dsa_lag_map()
92 dst->lags[id - 1] = lag; in dsa_lag_map()
114 void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag) in dsa_lag_unmap() argument
118 dsa_lags_foreach_id(id, dst) { in dsa_lag_unmap()
119 if (dsa_lag_by_id(dst, id) == lag) { in dsa_lag_unmap()
120 dst->lags[id - 1] = NULL; in dsa_lag_unmap()
127 struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst, in dsa_tree_lag_find() argument
132 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_lag_find()
139 struct dsa_bridge *dsa_tree_bridge_find(struct dsa_switch_tree *dst, in dsa_tree_bridge_find() argument
144 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_bridge_find()
153 struct dsa_switch_tree *dst; in dsa_bridge_num_find() local
155 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_bridge_num_find()
158 bridge = dsa_tree_bridge_find(dst, bridge_dev); in dsa_bridge_num_find()
204 struct dsa_switch_tree *dst; in dsa_switch_find() local
207 list_for_each_entry(dst, &dsa_tree_list, list) { in dsa_switch_find()
208 if (dst->index != tree_index) in dsa_switch_find()
211 list_for_each_entry(dp, &dst->ports, list) { in dsa_switch_find()
225 struct dsa_switch_tree *dst; in dsa_tree_find() local
227 list_for_each_entry(dst, &dsa_tree_list, list) in dsa_tree_find()
228 if (dst->index == index) in dsa_tree_find()
229 return dst; in dsa_tree_find()
236 struct dsa_switch_tree *dst; in dsa_tree_alloc() local
238 dst = kzalloc(sizeof(*dst), GFP_KERNEL); in dsa_tree_alloc()
239 if (!dst) in dsa_tree_alloc()
242 dst->index = index; in dsa_tree_alloc()
244 INIT_LIST_HEAD(&dst->rtable); in dsa_tree_alloc()
246 INIT_LIST_HEAD(&dst->ports); in dsa_tree_alloc()
248 INIT_LIST_HEAD(&dst->list); in dsa_tree_alloc()
249 list_add_tail(&dst->list, &dsa_tree_list); in dsa_tree_alloc()
251 kref_init(&dst->refcount); in dsa_tree_alloc()
253 return dst; in dsa_tree_alloc()
256 static void dsa_tree_free(struct dsa_switch_tree *dst) in dsa_tree_free() argument
258 if (dst->tag_ops) in dsa_tree_free()
259 dsa_tag_driver_put(dst->tag_ops); in dsa_tree_free()
260 list_del(&dst->list); in dsa_tree_free()
261 kfree(dst); in dsa_tree_free()
264 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst) in dsa_tree_get() argument
266 if (dst) in dsa_tree_get()
267 kref_get(&dst->refcount); in dsa_tree_get()
269 return dst; in dsa_tree_get()
274 struct dsa_switch_tree *dst; in dsa_tree_touch() local
276 dst = dsa_tree_find(index); in dsa_tree_touch()
277 if (dst) in dsa_tree_touch()
278 return dsa_tree_get(dst); in dsa_tree_touch()
285 struct dsa_switch_tree *dst; in dsa_tree_release() local
287 dst = container_of(ref, struct dsa_switch_tree, refcount); in dsa_tree_release()
289 dsa_tree_free(dst); in dsa_tree_release()
292 static void dsa_tree_put(struct dsa_switch_tree *dst) in dsa_tree_put() argument
294 if (dst) in dsa_tree_put()
295 kref_put(&dst->refcount, dsa_tree_release); in dsa_tree_put()
298 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, in dsa_tree_find_port_by_node() argument
303 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_port_by_node()
314 struct dsa_switch_tree *dst; in dsa_link_touch() local
317 dst = ds->dst; in dsa_link_touch()
319 list_for_each_entry(dl, &dst->rtable, list) in dsa_link_touch()
331 list_add_tail(&dl->list, &dst->rtable); in dsa_link_touch()
339 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table() local
347 link_dp = dsa_tree_find_port_by_node(dst, it.node); in dsa_port_setup_routing_table()
363 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst) in dsa_tree_setup_routing_table() argument
368 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_routing_table()
379 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) in dsa_tree_find_first_cpu() argument
383 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_first_cpu()
390 struct net_device *dsa_tree_find_first_master(struct dsa_switch_tree *dst) in dsa_tree_find_first_master() argument
396 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_find_first_master()
407 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) in dsa_tree_setup_default_cpu() argument
411 cpu_dp = dsa_tree_find_first_cpu(dst); in dsa_tree_setup_default_cpu()
413 pr_err("DSA: tree %d has no CPU port\n", dst->index); in dsa_tree_setup_default_cpu()
417 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_default_cpu()
433 static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_cpu_ports() argument
437 list_for_each_entry(cpu_dp, &dst->ports, list) { in dsa_tree_setup_cpu_ports()
452 return dsa_tree_setup_default_cpu(dst); in dsa_tree_setup_cpu_ports()
455 static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_cpu_ports() argument
459 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_cpu_ports()
467 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup() local
484 id = (const unsigned char *)&dst->index; in dsa_port_devlink_setup()
485 len = sizeof(dst->index); in dsa_port_devlink_setup()
825 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
826 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol() local
829 if (tag_ops->proto == dst->default_proto) in dsa_switch_setup_tag_protocol()
869 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
983 static void dsa_tree_teardown_ports(struct dsa_switch_tree *dst) in dsa_tree_teardown_ports() argument
987 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
993 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_ports()
998 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) in dsa_tree_teardown_switches() argument
1002 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
1007 static int dsa_tree_setup_ports(struct dsa_switch_tree *dst) in dsa_tree_setup_ports() argument
1012 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_ports()
1020 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_ports()
1034 dsa_tree_teardown_ports(dst); in dsa_tree_setup_ports()
1039 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) in dsa_tree_setup_switches() argument
1044 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
1047 dsa_tree_teardown_switches(dst); in dsa_tree_setup_switches()
1055 static int dsa_tree_setup_master(struct dsa_switch_tree *dst) in dsa_tree_setup_master() argument
1062 dsa_tree_for_each_cpu_port(cpu_dp, dst) { in dsa_tree_setup_master()
1072 dsa_tree_master_admin_state_change(dst, master, admin_up); in dsa_tree_setup_master()
1073 dsa_tree_master_oper_state_change(dst, master, in dsa_tree_setup_master()
1082 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) in dsa_tree_teardown_master() argument
1088 dsa_tree_for_each_cpu_port(cpu_dp, dst) { in dsa_tree_teardown_master()
1095 dsa_tree_master_admin_state_change(dst, master, false); in dsa_tree_teardown_master()
1103 static int dsa_tree_setup_lags(struct dsa_switch_tree *dst) in dsa_tree_setup_lags() argument
1108 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_lags()
1116 dst->lags = kcalloc(len, sizeof(*dst->lags), GFP_KERNEL); in dsa_tree_setup_lags()
1117 if (!dst->lags) in dsa_tree_setup_lags()
1120 dst->lags_len = len; in dsa_tree_setup_lags()
1124 static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst) in dsa_tree_teardown_lags() argument
1126 kfree(dst->lags); in dsa_tree_teardown_lags()
1129 static int dsa_tree_setup(struct dsa_switch_tree *dst) in dsa_tree_setup() argument
1134 if (dst->setup) { in dsa_tree_setup()
1136 dst->index); in dsa_tree_setup()
1140 complete = dsa_tree_setup_routing_table(dst); in dsa_tree_setup()
1144 err = dsa_tree_setup_cpu_ports(dst); in dsa_tree_setup()
1148 err = dsa_tree_setup_switches(dst); in dsa_tree_setup()
1152 err = dsa_tree_setup_ports(dst); in dsa_tree_setup()
1156 err = dsa_tree_setup_master(dst); in dsa_tree_setup()
1160 err = dsa_tree_setup_lags(dst); in dsa_tree_setup()
1164 dst->setup = true; in dsa_tree_setup()
1166 pr_info("DSA: tree %d setup\n", dst->index); in dsa_tree_setup()
1171 dsa_tree_teardown_master(dst); in dsa_tree_setup()
1173 dsa_tree_teardown_ports(dst); in dsa_tree_setup()
1175 dsa_tree_teardown_switches(dst); in dsa_tree_setup()
1177 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_setup()
1182 static void dsa_tree_teardown(struct dsa_switch_tree *dst) in dsa_tree_teardown() argument
1186 if (!dst->setup) in dsa_tree_teardown()
1189 dsa_tree_teardown_lags(dst); in dsa_tree_teardown()
1191 dsa_tree_teardown_master(dst); in dsa_tree_teardown()
1193 dsa_tree_teardown_ports(dst); in dsa_tree_teardown()
1195 dsa_tree_teardown_switches(dst); in dsa_tree_teardown()
1197 dsa_tree_teardown_cpu_ports(dst); in dsa_tree_teardown()
1199 list_for_each_entry_safe(dl, next, &dst->rtable, list) { in dsa_tree_teardown()
1204 pr_info("DSA: tree %d torn down\n", dst->index); in dsa_tree_teardown()
1206 dst->setup = false; in dsa_tree_teardown()
1209 static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_bind_tag_proto() argument
1212 const struct dsa_device_ops *old_tag_ops = dst->tag_ops; in dsa_tree_bind_tag_proto()
1216 dst->tag_ops = tag_ops; in dsa_tree_bind_tag_proto()
1222 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_CONNECT, &info); in dsa_tree_bind_tag_proto()
1228 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
1234 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info); in dsa_tree_bind_tag_proto()
1235 dst->tag_ops = old_tag_ops; in dsa_tree_bind_tag_proto()
1244 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, in dsa_tree_change_tag_proto() argument
1260 dsa_tree_for_each_user_port(dp, dst) { in dsa_tree_change_tag_proto()
1270 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1274 err = dsa_tree_bind_tag_proto(dst, tag_ops); in dsa_tree_change_tag_proto()
1284 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info); in dsa_tree_change_tag_proto()
1290 static void dsa_tree_master_state_change(struct dsa_switch_tree *dst, in dsa_tree_master_state_change() argument
1299 dsa_tree_notify(dst, DSA_NOTIFIER_MASTER_STATE_CHANGE, &info); in dsa_tree_master_state_change()
1302 void dsa_tree_master_admin_state_change(struct dsa_switch_tree *dst, in dsa_tree_master_admin_state_change() argument
1322 dsa_tree_master_state_change(dst, master); in dsa_tree_master_admin_state_change()
1325 void dsa_tree_master_oper_state_change(struct dsa_switch_tree *dst, in dsa_tree_master_oper_state_change() argument
1345 dsa_tree_master_state_change(dst, master); in dsa_tree_master_oper_state_change()
1350 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch() local
1370 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
1424 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu() local
1429 if (dst->default_proto) { in dsa_port_parse_cpu()
1430 if (dst->default_proto != default_proto) { in dsa_port_parse_cpu()
1436 dst->default_proto = default_proto; in dsa_port_parse_cpu()
1466 if (dst->tag_ops) { in dsa_port_parse_cpu()
1467 if (dst->tag_ops != tag_ops) { in dsa_port_parse_cpu()
1480 dst->tag_ops = tag_ops; in dsa_port_parse_cpu()
1485 dsa_port_set_tag_protocol(dp, dst->tag_ops); in dsa_port_parse_cpu()
1486 dp->dst = dst; in dsa_port_parse_cpu()
1591 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1592 if (!ds->dst) in dsa_switch_parse_member_of()
1595 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1598 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1602 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1603 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1699 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1700 if (!ds->dst) in dsa_switch_parse()
1725 struct dsa_switch_tree *dst; in dsa_switch_probe() local
1754 dst = ds->dst; in dsa_switch_probe()
1755 dsa_tree_get(dst); in dsa_switch_probe()
1756 err = dsa_tree_setup(dst); in dsa_switch_probe()
1759 dsa_tree_put(dst); in dsa_switch_probe()
1771 dsa_tree_put(ds->dst); in dsa_register_switch()
1780 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove() local
1782 dsa_tree_teardown(dst); in dsa_switch_remove()
1784 dsa_tree_put(dst); in dsa_switch_remove()