Lines Matching refs:dst

55  * @dst: Tree in which to record the mapping.
64 void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag)
68 for (id = 1; id <= dst->lags_len; id++) {
69 if (!dsa_lag_by_id(dst, id)) {
70 dst->lags[id - 1] = lag;
86 * @dst: Tree in which the mapping is recorded.
92 void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag)
96 dsa_lags_foreach_id(id, dst) {
97 if (dsa_lag_by_id(dst, id) == lag) {
98 dst->lags[id - 1] = NULL;
105 struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst,
110 list_for_each_entry(dp, &dst->ports, list)
117 struct dsa_bridge *dsa_tree_bridge_find(struct dsa_switch_tree *dst,
122 list_for_each_entry(dp, &dst->ports, list)
131 struct dsa_switch_tree *dst;
133 list_for_each_entry(dst, &dsa_tree_list, list) {
136 bridge = dsa_tree_bridge_find(dst, bridge_dev);
182 struct dsa_switch_tree *dst;
185 list_for_each_entry(dst, &dsa_tree_list, list) {
186 if (dst->index != tree_index)
189 list_for_each_entry(dp, &dst->ports, list) {
203 struct dsa_switch_tree *dst;
205 list_for_each_entry(dst, &dsa_tree_list, list)
206 if (dst->index == index)
207 return dst;
214 struct dsa_switch_tree *dst;
216 dst = kzalloc(sizeof(*dst), GFP_KERNEL);
217 if (!dst)
220 dst->index = index;
222 INIT_LIST_HEAD(&dst->rtable);
224 INIT_LIST_HEAD(&dst->ports);
226 INIT_LIST_HEAD(&dst->list);
227 list_add_tail(&dst->list, &dsa_tree_list);
229 kref_init(&dst->refcount);
231 return dst;
234 static void dsa_tree_free(struct dsa_switch_tree *dst)
236 if (dst->tag_ops)
237 dsa_tag_driver_put(dst->tag_ops);
238 list_del(&dst->list);
239 kfree(dst);
242 static struct dsa_switch_tree *dsa_tree_get(struct dsa_switch_tree *dst)
244 if (dst)
245 kref_get(&dst->refcount);
247 return dst;
252 struct dsa_switch_tree *dst;
254 dst = dsa_tree_find(index);
255 if (dst)
256 return dsa_tree_get(dst);
263 struct dsa_switch_tree *dst;
265 dst = container_of(ref, struct dsa_switch_tree, refcount);
267 dsa_tree_free(dst);
270 static void dsa_tree_put(struct dsa_switch_tree *dst)
272 if (dst)
273 kref_put(&dst->refcount, dsa_tree_release);
276 static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst,
281 list_for_each_entry(dp, &dst->ports, list)
292 struct dsa_switch_tree *dst;
295 dst = ds->dst;
297 list_for_each_entry(dl, &dst->rtable, list)
309 list_add_tail(&dl->list, &dst->rtable);
317 struct dsa_switch_tree *dst = ds->dst;
325 link_dp = dsa_tree_find_port_by_node(dst, it.node);
341 static bool dsa_tree_setup_routing_table(struct dsa_switch_tree *dst)
346 list_for_each_entry(dp, &dst->ports, list) {
357 static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst)
361 list_for_each_entry(dp, &dst->ports, list)
368 struct net_device *dsa_tree_find_first_master(struct dsa_switch_tree *dst)
374 cpu_dp = dsa_tree_find_first_cpu(dst);
385 static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst)
389 cpu_dp = dsa_tree_find_first_cpu(dst);
391 pr_err("DSA: tree %d has no CPU port\n", dst->index);
395 list_for_each_entry(dp, &dst->ports, list) {
429 static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst)
433 list_for_each_entry(cpu_dp, &dst->ports, list) {
452 return dsa_tree_setup_default_cpu(dst);
455 static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst)
459 list_for_each_entry(dp, &dst->ports, list)
577 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops;
578 struct dsa_switch_tree *dst = ds->dst;
581 if (tag_ops->proto == dst->default_proto)
621 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops;
724 static void dsa_tree_teardown_ports(struct dsa_switch_tree *dst)
728 list_for_each_entry(dp, &dst->ports, list)
734 list_for_each_entry(dp, &dst->ports, list)
739 static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst)
743 list_for_each_entry(dp, &dst->ports, list)
748 static int dsa_tree_setup_ports(struct dsa_switch_tree *dst)
753 list_for_each_entry(dp, &dst->ports, list) {
761 list_for_each_entry(dp, &dst->ports, list) {
775 dsa_tree_teardown_ports(dst);
780 static int dsa_tree_setup_switches(struct dsa_switch_tree *dst)
785 list_for_each_entry(dp, &dst->ports, list) {
788 dsa_tree_teardown_switches(dst);
796 static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
803 dsa_tree_for_each_cpu_port(cpu_dp, dst) {
813 dsa_tree_master_admin_state_change(dst, master, admin_up);
814 dsa_tree_master_oper_state_change(dst, master,
823 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
829 dsa_tree_for_each_cpu_port(cpu_dp, dst) {
836 dsa_tree_master_admin_state_change(dst, master, false);
844 static int dsa_tree_setup_lags(struct dsa_switch_tree *dst)
849 list_for_each_entry(dp, &dst->ports, list) {
857 dst->lags = kcalloc(len, sizeof(*dst->lags), GFP_KERNEL);
858 if (!dst->lags)
861 dst->lags_len = len;
865 static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst)
867 kfree(dst->lags);
870 static int dsa_tree_setup(struct dsa_switch_tree *dst)
875 if (dst->setup) {
877 dst->index);
881 complete = dsa_tree_setup_routing_table(dst);
885 err = dsa_tree_setup_cpu_ports(dst);
889 err = dsa_tree_setup_switches(dst);
893 err = dsa_tree_setup_ports(dst);
897 err = dsa_tree_setup_master(dst);
901 err = dsa_tree_setup_lags(dst);
905 dst->setup = true;
907 pr_info("DSA: tree %d setup\n", dst->index);
912 dsa_tree_teardown_master(dst);
914 dsa_tree_teardown_ports(dst);
916 dsa_tree_teardown_switches(dst);
918 dsa_tree_teardown_cpu_ports(dst);
923 static void dsa_tree_teardown(struct dsa_switch_tree *dst)
927 if (!dst->setup)
930 dsa_tree_teardown_lags(dst);
932 dsa_tree_teardown_master(dst);
934 dsa_tree_teardown_ports(dst);
936 dsa_tree_teardown_switches(dst);
938 dsa_tree_teardown_cpu_ports(dst);
940 list_for_each_entry_safe(dl, next, &dst->rtable, list) {
945 pr_info("DSA: tree %d torn down\n", dst->index);
947 dst->setup = false;
950 static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst,
953 const struct dsa_device_ops *old_tag_ops = dst->tag_ops;
957 dst->tag_ops = tag_ops;
963 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_CONNECT, &info);
969 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info);
975 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, &info);
976 dst->tag_ops = old_tag_ops;
985 int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,
1001 dsa_tree_for_each_user_port(dp, dst) {
1011 err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info);
1015 err = dsa_tree_bind_tag_proto(dst, tag_ops);
1025 dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info);
1031 static void dsa_tree_master_state_change(struct dsa_switch_tree *dst,
1040 dsa_tree_notify(dst, DSA_NOTIFIER_MASTER_STATE_CHANGE, &info);
1043 void dsa_tree_master_admin_state_change(struct dsa_switch_tree *dst,
1063 dsa_tree_master_state_change(dst, master);
1066 void dsa_tree_master_oper_state_change(struct dsa_switch_tree *dst,
1086 dsa_tree_master_state_change(dst, master);
1091 struct dsa_switch_tree *dst = ds->dst;
1111 list_add_tail(&dp->list, &dst->ports);
1162 struct dsa_switch_tree *dst = ds->dst;
1167 if (dst->default_proto) {
1168 if (dst->default_proto != default_proto) {
1174 dst->default_proto = default_proto;
1204 if (dst->tag_ops) {
1205 if (dst->tag_ops != tag_ops) {
1218 dst->tag_ops = tag_ops;
1223 dsa_port_set_tag_protocol(dp, dst->tag_ops);
1224 dp->dst = dst;
1329 ds->dst = dsa_tree_touch(m[0]);
1330 if (!ds->dst)
1333 if (dsa_switch_find(ds->dst->index, ds->index)) {
1336 ds->index, ds->dst->index);
1340 if (ds->dst->last_switch < ds->index)
1341 ds->dst->last_switch = ds->index;
1473 ds->dst = dsa_tree_touch(0);
1474 if (!ds->dst)
1499 struct dsa_switch_tree *dst;
1528 dst = ds->dst;
1529 dsa_tree_get(dst);
1530 err = dsa_tree_setup(dst);
1533 dsa_tree_put(dst);
1545 dsa_tree_put(ds->dst);
1554 struct dsa_switch_tree *dst = ds->dst;
1556 dsa_tree_teardown(dst);
1558 dsa_tree_put(dst);