Lines Matching full:ds
60 * driver by setting ds->num_lag_ids. It is perfectly legal to leave
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()
401 dsa_switch_preferred_default_local_cpu_port(struct dsa_switch *ds) in dsa_switch_preferred_default_local_cpu_port() argument
405 if (!ds->ops->preferred_default_local_cpu_port) in dsa_switch_preferred_default_local_cpu_port()
408 cpu_dp = ds->ops->preferred_default_local_cpu_port(ds); in dsa_switch_preferred_default_local_cpu_port()
412 if (WARN_ON(!dsa_port_is_cpu(cpu_dp) || cpu_dp->ds != ds)) in dsa_switch_preferred_default_local_cpu_port()
431 preferred_cpu_dp = dsa_switch_preferred_default_local_cpu_port(cpu_dp->ds); in dsa_tree_setup_cpu_ports()
436 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
461 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
483 dev_warn(ds->dev, in dsa_port_setup()
501 dev_warn(ds->dev, in dsa_port_setup()
569 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
571 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
572 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
579 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
582 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
589 err = tag_ops->connect(ds); in dsa_switch_setup_tag_protocol()
594 if (ds->ops->connect_tag_protocol) { in dsa_switch_setup_tag_protocol()
595 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
597 dev_err(ds->dev, in dsa_switch_setup_tag_protocol()
608 tag_ops->disconnect(ds); in dsa_switch_setup_tag_protocol()
613 static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds) in dsa_switch_teardown_tag_protocol() argument
615 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
618 tag_ops->disconnect(ds); in dsa_switch_teardown_tag_protocol()
621 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
625 if (ds->setup) in dsa_switch_setup()
628 /* Initialize ds->phys_mii_mask before registering the user MDIO bus in dsa_switch_setup()
633 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
635 err = dsa_switch_devlink_alloc(ds); in dsa_switch_setup()
639 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
643 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
645 err = ds->ops->setup(ds); in dsa_switch_setup()
649 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
653 if (!ds->user_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
654 ds->user_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
655 if (!ds->user_mii_bus) { in dsa_switch_setup()
660 dsa_user_mii_bus_init(ds); in dsa_switch_setup()
662 err = mdiobus_register(ds->user_mii_bus); in dsa_switch_setup()
667 dsa_switch_devlink_register(ds); in dsa_switch_setup()
669 ds->setup = true; in dsa_switch_setup()
673 if (ds->user_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
674 mdiobus_free(ds->user_mii_bus); in dsa_switch_setup()
676 if (ds->ops->teardown) in dsa_switch_setup()
677 ds->ops->teardown(ds); in dsa_switch_setup()
679 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
681 dsa_switch_devlink_free(ds); in dsa_switch_setup()
685 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
687 if (!ds->setup) in dsa_switch_teardown()
690 dsa_switch_devlink_unregister(ds); in dsa_switch_teardown()
692 if (ds->user_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
693 mdiobus_unregister(ds->user_mii_bus); in dsa_switch_teardown()
694 mdiobus_free(ds->user_mii_bus); in dsa_switch_teardown()
695 ds->user_mii_bus = NULL; in dsa_switch_teardown()
698 dsa_switch_teardown_tag_protocol(ds); in dsa_switch_teardown()
700 if (ds->ops->teardown) in dsa_switch_teardown()
701 ds->ops->teardown(ds); in dsa_switch_teardown()
703 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
705 dsa_switch_devlink_free(ds); in dsa_switch_teardown()
707 ds->setup = false; in dsa_switch_teardown()
734 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
776 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
840 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
841 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1086 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1088 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1091 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1099 dp->ds = ds; in dsa_port_touch()
1132 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1142 mds = mdp->ds; in dsa_get_tag_protocol()
1151 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1158 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1159 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1166 dev_err(ds->dev, in dsa_port_parse_cpu()
1176 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1177 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1183 dev_warn(ds->dev, in dsa_port_parse_cpu()
1197 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1203 dev_err(ds->dev, in dsa_port_parse_cpu()
1277 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1290 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1302 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1303 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1304 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1310 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1324 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1335 ds->index = m[1]; in dsa_switch_parse_member_of()
1337 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1338 if (!ds->dst) in dsa_switch_parse_member_of()
1341 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1342 dev_err(ds->dev, in dsa_switch_parse_member_of()
1344 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1348 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1349 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1354 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1359 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1360 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1368 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1372 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1376 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1380 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1433 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1446 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1464 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1468 ds->cd = cd; in dsa_switch_parse()
1473 ds->index = 0; in dsa_switch_parse()
1474 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1475 if (!ds->dst) in dsa_switch_parse()
1478 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1482 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1485 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1491 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1501 dev_info(ds->dev, in dsa_switch_release_ports()
1509 dev_info(ds->dev, in dsa_switch_release_ports()
1521 dev_info(ds->dev, in dsa_switch_release_ports()
1533 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1540 if (!ds->dev) in dsa_switch_probe()
1543 pdata = ds->dev->platform_data; in dsa_switch_probe()
1544 np = ds->dev->of_node; in dsa_switch_probe()
1546 if (!ds->num_ports) in dsa_switch_probe()
1550 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1552 dsa_switch_release_ports(ds); in dsa_switch_probe()
1554 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1556 dsa_switch_release_ports(ds); in dsa_switch_probe()
1564 dst = ds->dst; in dsa_switch_probe()
1568 dsa_switch_release_ports(ds); in dsa_switch_probe()
1575 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1580 err = dsa_switch_probe(ds); in dsa_register_switch()
1581 dsa_tree_put(ds->dst); in dsa_register_switch()
1588 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1590 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1593 dsa_switch_release_ports(ds); in dsa_switch_remove()
1597 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1600 dsa_switch_remove(ds); in dsa_unregister_switch()
1610 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1618 if (!ds->setup) in dsa_switch_shutdown()
1623 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1628 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1639 dsa_switch_for_each_cpu_port(dp, ds) { in dsa_switch_shutdown()
1656 int dsa_switch_suspend(struct dsa_switch *ds) in dsa_switch_suspend() argument
1662 dsa_switch_for_each_port(dp, ds) { in dsa_switch_suspend()
1671 if (ds->ops->suspend) in dsa_switch_suspend()
1672 ret = ds->ops->suspend(ds); in dsa_switch_suspend()
1678 int dsa_switch_resume(struct dsa_switch *ds) in dsa_switch_resume() argument
1683 if (ds->ops->resume) in dsa_switch_resume()
1684 ret = ds->ops->resume(ds); in dsa_switch_resume()
1690 dsa_switch_for_each_port(dp, ds) { in dsa_switch_resume()
1731 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_fdb_present_in_other_db() argument
1735 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_fdb_present_in_other_db()
1752 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_mdb_present_in_other_db() argument
1756 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_mdb_present_in_other_db()
1776 int dsa_port_simple_hsr_validate(struct dsa_switch *ds, int port, in dsa_port_simple_hsr_validate() argument
1783 err = hsr_get_port_type(hsr, dsa_to_port(ds, port)->user, &type); in dsa_port_simple_hsr_validate()
1797 int dsa_port_simple_hsr_join(struct dsa_switch *ds, int port, in dsa_port_simple_hsr_join() argument
1801 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp; in dsa_port_simple_hsr_join()
1804 err = dsa_port_simple_hsr_validate(ds, port, hsr, extack); in dsa_port_simple_hsr_join()
1808 dsa_hsr_foreach_port(other_dp, ds, hsr) { in dsa_port_simple_hsr_join()
1820 int dsa_port_simple_hsr_leave(struct dsa_switch *ds, int port, in dsa_port_simple_hsr_leave() argument
1823 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp; in dsa_port_simple_hsr_leave()
1825 dsa_hsr_foreach_port(other_dp, ds, hsr) { in dsa_port_simple_hsr_leave()