Lines Matching refs:ds

34 			if (dp->ds->index != sw_index)  in dsa_switch_find()
37 return dp->ds; in dsa_switch_find()
148 struct dsa_switch *ds = dp->ds; in dsa_link_touch() local
152 dst = ds->dst; in dsa_link_touch()
173 struct dsa_switch *ds = dp->ds; in dsa_port_setup_routing_table() local
174 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table()
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()
395 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_info_get() local
397 if (ds->ops->devlink_info_get) in dsa_devlink_info_get()
398 return ds->ops->devlink_info_get(ds, req, extack); in dsa_devlink_info_get()
407 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
413 if (ds->setup) in dsa_switch_setup()
421 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
426 ds->devlink = devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv)); in dsa_switch_setup()
427 if (!ds->devlink) in dsa_switch_setup()
429 dl_priv = devlink_priv(ds->devlink); in dsa_switch_setup()
430 dl_priv->ds = ds; in dsa_switch_setup()
432 err = devlink_register(ds->devlink, ds->dev); in dsa_switch_setup()
439 list_for_each_entry(dp, &ds->dst->ports, list) { in dsa_switch_setup()
440 if (dp->ds == ds) { in dsa_switch_setup()
447 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
451 err = ds->ops->setup(ds); in dsa_switch_setup()
455 devlink_params_publish(ds->devlink); in dsa_switch_setup()
457 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
458 ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev); in dsa_switch_setup()
459 if (!ds->slave_mii_bus) { in dsa_switch_setup()
464 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
466 err = mdiobus_register(ds->slave_mii_bus); in dsa_switch_setup()
471 ds->setup = true; in dsa_switch_setup()
476 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
478 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_setup()
479 if (dp->ds == ds) in dsa_switch_setup()
481 devlink_unregister(ds->devlink); in dsa_switch_setup()
483 devlink_free(ds->devlink); in dsa_switch_setup()
484 ds->devlink = NULL; in dsa_switch_setup()
489 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
493 if (!ds->setup) in dsa_switch_teardown()
496 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_teardown()
497 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
499 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
501 if (ds->ops->teardown) in dsa_switch_teardown()
502 ds->ops->teardown(ds); in dsa_switch_teardown()
504 if (ds->devlink) { in dsa_switch_teardown()
505 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_teardown()
506 if (dp->ds == ds) in dsa_switch_teardown()
508 devlink_unregister(ds->devlink); in dsa_switch_teardown()
509 devlink_free(ds->devlink); in dsa_switch_teardown()
510 ds->devlink = NULL; in dsa_switch_teardown()
513 ds->setup = false; in dsa_switch_teardown()
522 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
540 dsa_switch_teardown(dp->ds); in dsa_tree_setup_switches()
553 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
645 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
647 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
651 if (dp->ds == ds && dp->index == index) in dsa_port_touch()
658 dp->ds = ds; in dsa_port_touch()
689 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
699 mds = mdp->ds; in dsa_get_tag_protocol()
708 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
713 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
714 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
723 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
762 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
775 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
785 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
790 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
802 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
813 ds->index = m[1]; in dsa_switch_parse_member_of()
815 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
816 if (!ds->dst) in dsa_switch_parse_member_of()
822 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
827 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
828 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
836 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
840 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
844 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
848 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
872 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
885 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
903 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
907 ds->cd = cd; in dsa_switch_parse()
912 ds->index = 0; in dsa_switch_parse()
913 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
914 if (!ds->dst) in dsa_switch_parse()
917 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
921 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
924 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
926 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_release_ports()
930 if (dp->ds != ds) in dsa_switch_release_ports()
937 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
944 if (!ds->dev) in dsa_switch_probe()
947 pdata = ds->dev->platform_data; in dsa_switch_probe()
948 np = ds->dev->of_node; in dsa_switch_probe()
950 if (!ds->num_ports) in dsa_switch_probe()
954 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
956 dsa_switch_release_ports(ds); in dsa_switch_probe()
958 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
960 dsa_switch_release_ports(ds); in dsa_switch_probe()
968 dst = ds->dst; in dsa_switch_probe()
972 dsa_switch_release_ports(ds); in dsa_switch_probe()
979 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
984 err = dsa_switch_probe(ds); in dsa_register_switch()
985 dsa_tree_put(ds->dst); in dsa_register_switch()
992 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
994 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
997 dsa_switch_release_ports(ds); in dsa_switch_remove()
1001 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1004 dsa_switch_remove(ds); in dsa_unregister_switch()