Lines Matching refs:ds
190 if (dp->ds->index != sw_index) in dsa_switch_find()
193 return dp->ds; in dsa_switch_find()
291 struct dsa_switch *ds = dp->ds; in dsa_link_touch() local
295 dst = ds->dst; in dsa_link_touch()
316 struct dsa_switch *ds = dp->ds; in dsa_port_setup_routing_table() local
317 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table()
407 dsa_switch_preferred_default_local_cpu_port(struct dsa_switch *ds) in dsa_switch_preferred_default_local_cpu_port() argument
411 if (!ds->ops->preferred_default_local_cpu_port) in dsa_switch_preferred_default_local_cpu_port()
414 cpu_dp = ds->ops->preferred_default_local_cpu_port(ds); in dsa_switch_preferred_default_local_cpu_port()
418 if (WARN_ON(!dsa_port_is_cpu(cpu_dp) || cpu_dp->ds != ds)) in dsa_switch_preferred_default_local_cpu_port()
437 preferred_cpu_dp = dsa_switch_preferred_default_local_cpu_port(cpu_dp->ds); in dsa_tree_setup_cpu_ports()
442 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
467 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
489 dev_warn(ds->dev, in dsa_port_setup()
507 dev_warn(ds->dev, in dsa_port_setup()
575 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
577 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
578 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
585 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
588 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
595 err = tag_ops->connect(ds); in dsa_switch_setup_tag_protocol()
600 if (ds->ops->connect_tag_protocol) { in dsa_switch_setup_tag_protocol()
601 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
603 dev_err(ds->dev, in dsa_switch_setup_tag_protocol()
614 tag_ops->disconnect(ds); in dsa_switch_setup_tag_protocol()
619 static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds) in dsa_switch_teardown_tag_protocol() argument
621 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
624 tag_ops->disconnect(ds); in dsa_switch_teardown_tag_protocol()
627 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
632 if (ds->setup) in dsa_switch_setup()
640 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
642 err = dsa_switch_devlink_alloc(ds); in dsa_switch_setup()
646 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
650 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
652 err = ds->ops->setup(ds); in dsa_switch_setup()
656 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
660 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
661 ds->slave_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
662 if (!ds->slave_mii_bus) { in dsa_switch_setup()
667 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
669 dn = of_get_child_by_name(ds->dev->of_node, "mdio"); in dsa_switch_setup()
671 err = of_mdiobus_register(ds->slave_mii_bus, dn); in dsa_switch_setup()
677 dsa_switch_devlink_register(ds); in dsa_switch_setup()
679 ds->setup = true; in dsa_switch_setup()
683 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
684 mdiobus_free(ds->slave_mii_bus); in dsa_switch_setup()
686 if (ds->ops->teardown) in dsa_switch_setup()
687 ds->ops->teardown(ds); in dsa_switch_setup()
689 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
691 dsa_switch_devlink_free(ds); in dsa_switch_setup()
695 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
697 if (!ds->setup) in dsa_switch_teardown()
700 dsa_switch_devlink_unregister(ds); in dsa_switch_teardown()
702 if (ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
703 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
704 mdiobus_free(ds->slave_mii_bus); in dsa_switch_teardown()
705 ds->slave_mii_bus = NULL; in dsa_switch_teardown()
708 dsa_switch_teardown_tag_protocol(ds); in dsa_switch_teardown()
710 if (ds->ops->teardown) in dsa_switch_teardown()
711 ds->ops->teardown(ds); in dsa_switch_teardown()
713 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
715 dsa_switch_devlink_free(ds); in dsa_switch_teardown()
717 ds->setup = false; in dsa_switch_teardown()
744 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
786 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
850 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
851 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1089 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1091 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1094 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1102 dp->ds = ds; in dsa_port_touch()
1135 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1145 mds = mdp->ds; in dsa_get_tag_protocol()
1154 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1161 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1162 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1169 dev_err(ds->dev, in dsa_port_parse_cpu()
1179 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1180 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1186 dev_warn(ds->dev, in dsa_port_parse_cpu()
1200 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1206 dev_err(ds->dev, in dsa_port_parse_cpu()
1269 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1282 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1294 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1295 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1296 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1302 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1316 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1327 ds->index = m[1]; in dsa_switch_parse_member_of()
1329 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1330 if (!ds->dst) in dsa_switch_parse_member_of()
1333 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1334 dev_err(ds->dev, in dsa_switch_parse_member_of()
1336 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1340 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1341 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1346 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1351 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1352 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1360 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1364 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1368 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1372 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1432 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1445 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1463 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1467 ds->cd = cd; in dsa_switch_parse()
1472 ds->index = 0; in dsa_switch_parse()
1473 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1474 if (!ds->dst) in dsa_switch_parse()
1477 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1481 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1484 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1488 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1497 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1504 if (!ds->dev) in dsa_switch_probe()
1507 pdata = ds->dev->platform_data; in dsa_switch_probe()
1508 np = ds->dev->of_node; in dsa_switch_probe()
1510 if (!ds->num_ports) in dsa_switch_probe()
1514 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1516 dsa_switch_release_ports(ds); in dsa_switch_probe()
1518 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1520 dsa_switch_release_ports(ds); in dsa_switch_probe()
1528 dst = ds->dst; in dsa_switch_probe()
1532 dsa_switch_release_ports(ds); in dsa_switch_probe()
1539 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1544 err = dsa_switch_probe(ds); in dsa_register_switch()
1545 dsa_tree_put(ds->dst); in dsa_register_switch()
1552 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1554 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1557 dsa_switch_release_ports(ds); in dsa_switch_remove()
1561 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1564 dsa_switch_remove(ds); in dsa_unregister_switch()
1574 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1581 if (!ds->setup) in dsa_switch_shutdown()
1586 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1596 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1611 int dsa_switch_suspend(struct dsa_switch *ds) in dsa_switch_suspend() argument
1617 dsa_switch_for_each_port(dp, ds) { in dsa_switch_suspend()
1626 if (ds->ops->suspend) in dsa_switch_suspend()
1627 ret = ds->ops->suspend(ds); in dsa_switch_suspend()
1633 int dsa_switch_resume(struct dsa_switch *ds) in dsa_switch_resume() argument
1638 if (ds->ops->resume) in dsa_switch_resume()
1639 ret = ds->ops->resume(ds); in dsa_switch_resume()
1645 dsa_switch_for_each_port(dp, ds) { in dsa_switch_resume()
1686 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_fdb_present_in_other_db() argument
1690 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_fdb_present_in_other_db()
1707 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_mdb_present_in_other_db() argument
1711 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_mdb_present_in_other_db()