• Home
  • Raw
  • Download

Lines Matching refs:dp

27 	struct dsa_port *dp;  in dsa_switch_find()  local
33 list_for_each_entry(dp, &dst->ports, list) { in dsa_switch_find()
34 if (dp->ds->index != sw_index) in dsa_switch_find()
37 return dp->ds; in dsa_switch_find()
128 static bool dsa_port_is_user(struct dsa_port *dp) in dsa_port_is_user() argument
130 return dp->type == DSA_PORT_TYPE_USER; in dsa_port_is_user()
136 struct dsa_port *dp; in dsa_tree_find_port_by_node() local
138 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_port_by_node()
139 if (dp->dn == dn) in dsa_tree_find_port_by_node()
140 return dp; in dsa_tree_find_port_by_node()
145 static struct dsa_link *dsa_link_touch(struct dsa_port *dp, in dsa_link_touch() argument
148 struct dsa_switch *ds = dp->ds; in dsa_link_touch()
155 if (dl->dp == dp && dl->link_dp == link_dp) in dsa_link_touch()
162 dl->dp = dp; in dsa_link_touch()
171 static bool dsa_port_setup_routing_table(struct dsa_port *dp) in dsa_port_setup_routing_table() argument
173 struct dsa_switch *ds = dp->ds; in dsa_port_setup_routing_table()
175 struct device_node *dn = dp->dn; in dsa_port_setup_routing_table()
188 dl = dsa_link_touch(dp, link_dp); in dsa_port_setup_routing_table()
201 struct dsa_port *dp; in dsa_tree_setup_routing_table() local
203 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_routing_table()
204 if (dsa_port_is_dsa(dp)) { in dsa_tree_setup_routing_table()
205 complete = dsa_port_setup_routing_table(dp); in dsa_tree_setup_routing_table()
216 struct dsa_port *dp; in dsa_tree_find_first_cpu() local
218 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_find_first_cpu()
219 if (dsa_port_is_cpu(dp)) in dsa_tree_find_first_cpu()
220 return dp; in dsa_tree_find_first_cpu()
227 struct dsa_port *cpu_dp, *dp; in dsa_tree_setup_default_cpu() local
236 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_default_cpu()
237 if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp)) in dsa_tree_setup_default_cpu()
238 dp->cpu_dp = cpu_dp; in dsa_tree_setup_default_cpu()
245 struct dsa_port *dp; in dsa_tree_teardown_default_cpu() local
247 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_default_cpu()
248 if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp)) in dsa_tree_teardown_default_cpu()
249 dp->cpu_dp = NULL; in dsa_tree_teardown_default_cpu()
252 static int dsa_port_setup(struct dsa_port *dp) in dsa_port_setup() argument
254 struct devlink_port *dlp = &dp->devlink_port; in dsa_port_setup()
259 if (dp->setup) in dsa_port_setup()
262 switch (dp->type) { in dsa_port_setup()
264 dsa_port_disable(dp); in dsa_port_setup()
267 err = dsa_port_link_register_of(dp); in dsa_port_setup()
272 err = dsa_port_enable(dp, NULL); in dsa_port_setup()
279 err = dsa_port_link_register_of(dp); in dsa_port_setup()
284 err = dsa_port_enable(dp, NULL); in dsa_port_setup()
291 dp->mac = of_get_mac_address(dp->dn); in dsa_port_setup()
292 err = dsa_slave_create(dp); in dsa_port_setup()
296 devlink_port_type_eth_set(dlp, dp->slave); in dsa_port_setup()
301 dsa_port_disable(dp); in dsa_port_setup()
303 dsa_port_link_unregister_of(dp); in dsa_port_setup()
307 dp->setup = true; in dsa_port_setup()
312 static int dsa_port_devlink_setup(struct dsa_port *dp) in dsa_port_devlink_setup() argument
314 struct devlink_port *dlp = &dp->devlink_port; in dsa_port_devlink_setup()
315 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup()
317 struct devlink *dl = dp->ds->devlink; in dsa_port_devlink_setup()
325 attrs.phys.port_number = dp->index; in dsa_port_devlink_setup()
330 switch (dp->type) { in dsa_port_devlink_setup()
346 err = devlink_port_register(dl, dlp, dp->index); in dsa_port_devlink_setup()
349 dp->devlink_port_setup = true; in dsa_port_devlink_setup()
354 static void dsa_port_teardown(struct dsa_port *dp) in dsa_port_teardown() argument
356 struct devlink_port *dlp = &dp->devlink_port; in dsa_port_teardown()
358 if (!dp->setup) in dsa_port_teardown()
363 switch (dp->type) { in dsa_port_teardown()
367 dsa_port_disable(dp); in dsa_port_teardown()
368 dsa_tag_driver_put(dp->tag_ops); in dsa_port_teardown()
369 dsa_port_link_unregister_of(dp); in dsa_port_teardown()
372 dsa_port_disable(dp); in dsa_port_teardown()
373 dsa_port_link_unregister_of(dp); in dsa_port_teardown()
376 if (dp->slave) { in dsa_port_teardown()
377 dsa_slave_destroy(dp->slave); in dsa_port_teardown()
378 dp->slave = NULL; in dsa_port_teardown()
383 dp->setup = false; in dsa_port_teardown()
386 static void dsa_port_devlink_teardown(struct dsa_port *dp) in dsa_port_devlink_teardown() argument
388 struct devlink_port *dlp = &dp->devlink_port; in dsa_port_devlink_teardown()
390 if (dp->devlink_port_setup) in dsa_port_devlink_teardown()
392 dp->devlink_port_setup = false; in dsa_port_devlink_teardown()
414 struct dsa_port *dp; in dsa_switch_setup() local
443 list_for_each_entry(dp, &ds->dst->ports, list) { in dsa_switch_setup()
444 if (dp->ds == ds) { in dsa_switch_setup()
445 err = dsa_port_devlink_setup(dp); in dsa_switch_setup()
488 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_setup()
489 if (dp->ds == ds) in dsa_switch_setup()
490 dsa_port_devlink_teardown(dp); in dsa_switch_setup()
501 struct dsa_port *dp; in dsa_switch_teardown() local
518 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_teardown()
519 if (dp->ds == ds) in dsa_switch_teardown()
520 dsa_port_devlink_teardown(dp); in dsa_switch_teardown()
531 struct dsa_port *dp; in dsa_tree_setup_switches() local
534 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
535 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
540 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_switches()
541 err = dsa_port_setup(dp); in dsa_tree_setup_switches()
543 dsa_port_devlink_teardown(dp); in dsa_tree_setup_switches()
544 dp->type = DSA_PORT_TYPE_UNUSED; in dsa_tree_setup_switches()
545 err = dsa_port_devlink_setup(dp); in dsa_tree_setup_switches()
555 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_switches()
556 dsa_port_teardown(dp); in dsa_tree_setup_switches()
558 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_setup_switches()
559 dsa_switch_teardown(dp->ds); in dsa_tree_setup_switches()
566 struct dsa_port *dp; in dsa_tree_teardown_switches() local
568 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
569 dsa_port_teardown(dp); in dsa_tree_teardown_switches()
571 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_switches()
572 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
577 struct dsa_port *dp; in dsa_tree_setup_master() local
580 list_for_each_entry(dp, &dst->ports, list) { in dsa_tree_setup_master()
581 if (dsa_port_is_cpu(dp)) { in dsa_tree_setup_master()
582 err = dsa_master_setup(dp->master, dp); in dsa_tree_setup_master()
593 struct dsa_port *dp; in dsa_tree_teardown_master() local
595 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_teardown_master()
596 if (dsa_port_is_cpu(dp)) in dsa_tree_teardown_master()
597 dsa_master_teardown(dp->master); in dsa_tree_teardown_master()
667 struct dsa_port *dp; in dsa_port_touch() local
669 list_for_each_entry(dp, &dst->ports, list) in dsa_port_touch()
670 if (dp->ds == ds && dp->index == index) in dsa_port_touch()
671 return dp; in dsa_port_touch()
673 dp = kzalloc(sizeof(*dp), GFP_KERNEL); in dsa_port_touch()
674 if (!dp) in dsa_port_touch()
677 dp->ds = ds; in dsa_port_touch()
678 dp->index = index; in dsa_port_touch()
680 INIT_LIST_HEAD(&dp->list); in dsa_port_touch()
681 list_add_tail(&dp->list, &dst->ports); in dsa_port_touch()
683 return dp; in dsa_port_touch()
686 static int dsa_port_parse_user(struct dsa_port *dp, const char *name) in dsa_port_parse_user() argument
691 dp->type = DSA_PORT_TYPE_USER; in dsa_port_parse_user()
692 dp->name = name; in dsa_port_parse_user()
697 static int dsa_port_parse_dsa(struct dsa_port *dp) in dsa_port_parse_dsa() argument
699 dp->type = DSA_PORT_TYPE_DSA; in dsa_port_parse_dsa()
704 static enum dsa_tag_protocol dsa_get_tag_protocol(struct dsa_port *dp, in dsa_get_tag_protocol() argument
708 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol()
727 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
730 static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master) in dsa_port_parse_cpu() argument
732 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu()
737 tag_protocol = dsa_get_tag_protocol(dp, master); in dsa_port_parse_cpu()
743 dp->master = NULL; in dsa_port_parse_cpu()
747 dp->master = master; in dsa_port_parse_cpu()
748 dp->type = DSA_PORT_TYPE_CPU; in dsa_port_parse_cpu()
749 dp->filter = tag_ops->filter; in dsa_port_parse_cpu()
750 dp->rcv = tag_ops->rcv; in dsa_port_parse_cpu()
751 dp->tag_ops = tag_ops; in dsa_port_parse_cpu()
752 dp->dst = dst; in dsa_port_parse_cpu()
757 static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) in dsa_port_parse_of() argument
763 dp->dn = dn; in dsa_port_parse_of()
773 return dsa_port_parse_cpu(dp, master); in dsa_port_parse_of()
777 return dsa_port_parse_dsa(dp); in dsa_port_parse_of()
779 return dsa_port_parse_user(dp, name); in dsa_port_parse_of()
786 struct dsa_port *dp; in dsa_switch_parse_ports_of() local
810 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
812 err = dsa_port_parse_of(dp, port); in dsa_switch_parse_ports_of()
844 struct dsa_port *dp; in dsa_switch_touch_ports() local
848 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
849 if (!dp) in dsa_switch_touch_ports()
871 static int dsa_port_parse(struct dsa_port *dp, const char *name, in dsa_port_parse() argument
883 return dsa_port_parse_cpu(dp, master); in dsa_port_parse()
887 return dsa_port_parse_dsa(dp); in dsa_port_parse()
889 return dsa_port_parse_user(dp, name); in dsa_port_parse()
896 struct dsa_port *dp; in dsa_switch_parse_ports() local
905 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
910 err = dsa_port_parse(dp, name, dev); in dsa_switch_parse_ports()
947 struct dsa_port *dp, *next; in dsa_switch_release_ports() local
949 list_for_each_entry_safe(dp, next, &dst->ports, list) { in dsa_switch_release_ports()
950 if (dp->ds != ds) in dsa_switch_release_ports()
952 list_del(&dp->list); in dsa_switch_release_ports()
953 kfree(dp); in dsa_switch_release_ports()