Lines Matching full:ds
59 * driver by setting ds->num_lag_ids. It is perfectly legal to leave
189 if (dp->ds->index != sw_index) in dsa_switch_find()
192 return dp->ds; in dsa_switch_find()
290 struct dsa_switch *ds = dp->ds; in dsa_link_touch() local
294 dst = ds->dst; in dsa_link_touch()
315 struct dsa_switch *ds = dp->ds; in dsa_port_setup_routing_table() local
316 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table()
406 dsa_switch_preferred_default_local_cpu_port(struct dsa_switch *ds) in dsa_switch_preferred_default_local_cpu_port() argument
410 if (!ds->ops->preferred_default_local_cpu_port) in dsa_switch_preferred_default_local_cpu_port()
413 cpu_dp = ds->ops->preferred_default_local_cpu_port(ds); in dsa_switch_preferred_default_local_cpu_port()
417 if (WARN_ON(!dsa_port_is_cpu(cpu_dp) || cpu_dp->ds != ds)) in dsa_switch_preferred_default_local_cpu_port()
436 preferred_cpu_dp = dsa_switch_preferred_default_local_cpu_port(cpu_dp->ds); in dsa_tree_setup_cpu_ports()
441 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
466 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
488 dev_warn(ds->dev, in dsa_port_setup()
506 dev_warn(ds->dev, in dsa_port_setup()
574 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
576 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
577 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
584 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
587 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
594 err = tag_ops->connect(ds); in dsa_switch_setup_tag_protocol()
599 if (ds->ops->connect_tag_protocol) { in dsa_switch_setup_tag_protocol()
600 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
602 dev_err(ds->dev, in dsa_switch_setup_tag_protocol()
613 tag_ops->disconnect(ds); in dsa_switch_setup_tag_protocol()
618 static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds) in dsa_switch_teardown_tag_protocol() argument
620 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
623 tag_ops->disconnect(ds); in dsa_switch_teardown_tag_protocol()
626 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
630 if (ds->setup) in dsa_switch_setup()
633 /* Initialize ds->phys_mii_mask before registering the user MDIO bus in dsa_switch_setup()
638 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
640 err = dsa_switch_devlink_alloc(ds); in dsa_switch_setup()
644 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
648 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
650 err = ds->ops->setup(ds); in dsa_switch_setup()
654 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
658 if (!ds->user_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
659 ds->user_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
660 if (!ds->user_mii_bus) { in dsa_switch_setup()
665 dsa_user_mii_bus_init(ds); in dsa_switch_setup()
667 err = mdiobus_register(ds->user_mii_bus); in dsa_switch_setup()
672 dsa_switch_devlink_register(ds); in dsa_switch_setup()
674 ds->setup = true; in dsa_switch_setup()
678 if (ds->user_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
679 mdiobus_free(ds->user_mii_bus); in dsa_switch_setup()
681 if (ds->ops->teardown) in dsa_switch_setup()
682 ds->ops->teardown(ds); in dsa_switch_setup()
684 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
686 dsa_switch_devlink_free(ds); in dsa_switch_setup()
690 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
692 if (!ds->setup) in dsa_switch_teardown()
695 dsa_switch_devlink_unregister(ds); in dsa_switch_teardown()
697 if (ds->user_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
698 mdiobus_unregister(ds->user_mii_bus); in dsa_switch_teardown()
699 mdiobus_free(ds->user_mii_bus); in dsa_switch_teardown()
700 ds->user_mii_bus = NULL; in dsa_switch_teardown()
703 dsa_switch_teardown_tag_protocol(ds); in dsa_switch_teardown()
705 if (ds->ops->teardown) in dsa_switch_teardown()
706 ds->ops->teardown(ds); in dsa_switch_teardown()
708 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
710 dsa_switch_devlink_free(ds); in dsa_switch_teardown()
712 ds->setup = false; in dsa_switch_teardown()
739 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
781 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
845 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
846 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1084 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1086 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1089 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1097 dp->ds = ds; in dsa_port_touch()
1130 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1140 mds = mdp->ds; in dsa_get_tag_protocol()
1149 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1156 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1157 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1164 dev_err(ds->dev, in dsa_port_parse_cpu()
1174 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1175 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1181 dev_warn(ds->dev, in dsa_port_parse_cpu()
1195 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1201 dev_err(ds->dev, in dsa_port_parse_cpu()
1264 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1277 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1289 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1290 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1291 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1297 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1311 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1322 ds->index = m[1]; in dsa_switch_parse_member_of()
1324 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1325 if (!ds->dst) in dsa_switch_parse_member_of()
1328 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1329 dev_err(ds->dev, in dsa_switch_parse_member_of()
1331 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1335 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1336 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1341 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1346 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1347 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1355 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1359 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1363 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1367 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1427 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1440 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1458 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1462 ds->cd = cd; in dsa_switch_parse()
1467 ds->index = 0; in dsa_switch_parse()
1468 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1469 if (!ds->dst) in dsa_switch_parse()
1472 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1476 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1479 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1483 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1492 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1499 if (!ds->dev) in dsa_switch_probe()
1502 pdata = ds->dev->platform_data; in dsa_switch_probe()
1503 np = ds->dev->of_node; in dsa_switch_probe()
1505 if (!ds->num_ports) in dsa_switch_probe()
1508 if (ds->phylink_mac_ops) { in dsa_switch_probe()
1509 if (ds->ops->phylink_mac_select_pcs || in dsa_switch_probe()
1510 ds->ops->phylink_mac_config || in dsa_switch_probe()
1511 ds->ops->phylink_mac_link_down || in dsa_switch_probe()
1512 ds->ops->phylink_mac_link_up) in dsa_switch_probe()
1517 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1519 dsa_switch_release_ports(ds); in dsa_switch_probe()
1521 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1523 dsa_switch_release_ports(ds); in dsa_switch_probe()
1531 dst = ds->dst; in dsa_switch_probe()
1535 dsa_switch_release_ports(ds); in dsa_switch_probe()
1542 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1547 err = dsa_switch_probe(ds); in dsa_register_switch()
1548 dsa_tree_put(ds->dst); in dsa_register_switch()
1555 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1557 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1560 dsa_switch_release_ports(ds); in dsa_switch_remove()
1564 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1567 dsa_switch_remove(ds); in dsa_unregister_switch()
1577 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1585 if (!ds->setup) in dsa_switch_shutdown()
1590 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1595 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1606 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1621 int dsa_switch_suspend(struct dsa_switch *ds) in dsa_switch_suspend() argument
1627 dsa_switch_for_each_port(dp, ds) { in dsa_switch_suspend()
1636 if (ds->ops->suspend) in dsa_switch_suspend()
1637 ret = ds->ops->suspend(ds); in dsa_switch_suspend()
1643 int dsa_switch_resume(struct dsa_switch *ds) in dsa_switch_resume() argument
1648 if (ds->ops->resume) in dsa_switch_resume()
1649 ret = ds->ops->resume(ds); in dsa_switch_resume()
1655 dsa_switch_for_each_port(dp, ds) { in dsa_switch_resume()
1696 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_fdb_present_in_other_db() argument
1700 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_fdb_present_in_other_db()
1717 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_mdb_present_in_other_db() argument
1721 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_mdb_present_in_other_db()