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()
1091 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1093 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1096 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1104 dp->ds = ds; in dsa_port_touch()
1137 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1147 mds = mdp->ds; in dsa_get_tag_protocol()
1156 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1163 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1164 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1171 dev_err(ds->dev, in dsa_port_parse_cpu()
1181 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1182 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1188 dev_warn(ds->dev, in dsa_port_parse_cpu()
1202 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1208 dev_err(ds->dev, in dsa_port_parse_cpu()
1271 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1284 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1296 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1297 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1298 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1304 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1318 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1329 ds->index = m[1]; in dsa_switch_parse_member_of()
1331 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1332 if (!ds->dst) in dsa_switch_parse_member_of()
1335 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1336 dev_err(ds->dev, in dsa_switch_parse_member_of()
1338 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1342 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1343 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1348 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1353 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1354 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1362 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1366 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1370 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1374 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1434 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1447 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1465 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1469 ds->cd = cd; in dsa_switch_parse()
1474 ds->index = 0; in dsa_switch_parse()
1475 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1476 if (!ds->dst) in dsa_switch_parse()
1479 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1483 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1486 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1492 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1499 dev_info(ds->dev, in dsa_switch_release_ports()
1507 dev_info(ds->dev, in dsa_switch_release_ports()
1519 dev_info(ds->dev, in dsa_switch_release_ports()
1531 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1538 if (!ds->dev) in dsa_switch_probe()
1541 pdata = ds->dev->platform_data; in dsa_switch_probe()
1542 np = ds->dev->of_node; in dsa_switch_probe()
1544 if (!ds->num_ports) in dsa_switch_probe()
1548 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1550 dsa_switch_release_ports(ds); in dsa_switch_probe()
1552 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1554 dsa_switch_release_ports(ds); in dsa_switch_probe()
1562 dst = ds->dst; in dsa_switch_probe()
1566 dsa_switch_release_ports(ds); in dsa_switch_probe()
1573 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1578 err = dsa_switch_probe(ds); in dsa_register_switch()
1579 dsa_tree_put(ds->dst); in dsa_register_switch()
1586 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1588 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1591 dsa_switch_release_ports(ds); in dsa_switch_remove()
1595 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1598 dsa_switch_remove(ds); in dsa_unregister_switch()
1608 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1616 if (!ds->setup) in dsa_switch_shutdown()
1621 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1626 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1637 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1652 int dsa_switch_suspend(struct dsa_switch *ds) in dsa_switch_suspend() argument
1658 dsa_switch_for_each_port(dp, ds) { in dsa_switch_suspend()
1667 if (ds->ops->suspend) in dsa_switch_suspend()
1668 ret = ds->ops->suspend(ds); in dsa_switch_suspend()
1674 int dsa_switch_resume(struct dsa_switch *ds) in dsa_switch_resume() argument
1679 if (ds->ops->resume) in dsa_switch_resume()
1680 ret = ds->ops->resume(ds); in dsa_switch_resume()
1686 dsa_switch_for_each_port(dp, ds) { in dsa_switch_resume()
1727 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_fdb_present_in_other_db() argument
1731 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_fdb_present_in_other_db()
1748 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_mdb_present_in_other_db() argument
1752 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_mdb_present_in_other_db()