Lines Matching refs:ds

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()
419 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
444 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
466 dev_warn(ds->dev, in dsa_port_setup()
484 dev_warn(ds->dev, in dsa_port_setup()
552 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
554 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
555 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
562 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
565 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
572 err = tag_ops->connect(ds); in dsa_switch_setup_tag_protocol()
577 if (ds->ops->connect_tag_protocol) { in dsa_switch_setup_tag_protocol()
578 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
580 dev_err(ds->dev, in dsa_switch_setup_tag_protocol()
591 tag_ops->disconnect(ds); in dsa_switch_setup_tag_protocol()
596 static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds) in dsa_switch_teardown_tag_protocol() argument
598 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
601 tag_ops->disconnect(ds); in dsa_switch_teardown_tag_protocol()
604 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
609 if (ds->setup) in dsa_switch_setup()
617 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
619 err = dsa_switch_devlink_alloc(ds); in dsa_switch_setup()
623 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
627 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
629 err = ds->ops->setup(ds); in dsa_switch_setup()
633 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
637 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
638 ds->slave_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
639 if (!ds->slave_mii_bus) { in dsa_switch_setup()
644 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
646 dn = of_get_child_by_name(ds->dev->of_node, "mdio"); in dsa_switch_setup()
648 err = of_mdiobus_register(ds->slave_mii_bus, dn); in dsa_switch_setup()
654 dsa_switch_devlink_register(ds); in dsa_switch_setup()
656 ds->setup = true; in dsa_switch_setup()
660 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
661 mdiobus_free(ds->slave_mii_bus); in dsa_switch_setup()
663 if (ds->ops->teardown) in dsa_switch_setup()
664 ds->ops->teardown(ds); in dsa_switch_setup()
666 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
668 dsa_switch_devlink_free(ds); in dsa_switch_setup()
672 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
674 if (!ds->setup) in dsa_switch_teardown()
677 dsa_switch_devlink_unregister(ds); in dsa_switch_teardown()
679 if (ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
680 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
681 mdiobus_free(ds->slave_mii_bus); in dsa_switch_teardown()
682 ds->slave_mii_bus = NULL; in dsa_switch_teardown()
685 dsa_switch_teardown_tag_protocol(ds); in dsa_switch_teardown()
687 if (ds->ops->teardown) in dsa_switch_teardown()
688 ds->ops->teardown(ds); in dsa_switch_teardown()
690 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
692 dsa_switch_devlink_free(ds); in dsa_switch_teardown()
694 ds->setup = false; in dsa_switch_teardown()
721 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
763 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
827 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
828 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1066 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1068 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1071 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1079 dp->ds = ds; in dsa_port_touch()
1112 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1122 mds = mdp->ds; in dsa_get_tag_protocol()
1131 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1138 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1139 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1146 dev_err(ds->dev, in dsa_port_parse_cpu()
1156 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1157 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1163 dev_warn(ds->dev, in dsa_port_parse_cpu()
1177 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1183 dev_err(ds->dev, in dsa_port_parse_cpu()
1246 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1259 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1271 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1272 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1273 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1279 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1293 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1304 ds->index = m[1]; in dsa_switch_parse_member_of()
1306 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1307 if (!ds->dst) in dsa_switch_parse_member_of()
1310 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1311 dev_err(ds->dev, in dsa_switch_parse_member_of()
1313 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1317 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1318 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1323 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1328 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1329 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1337 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1341 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1345 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1349 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1409 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1422 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1440 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1444 ds->cd = cd; in dsa_switch_parse()
1449 ds->index = 0; in dsa_switch_parse()
1450 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1451 if (!ds->dst) in dsa_switch_parse()
1454 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1458 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1461 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1465 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1474 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1481 if (!ds->dev) in dsa_switch_probe()
1484 pdata = ds->dev->platform_data; in dsa_switch_probe()
1485 np = ds->dev->of_node; in dsa_switch_probe()
1487 if (!ds->num_ports) in dsa_switch_probe()
1491 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1493 dsa_switch_release_ports(ds); in dsa_switch_probe()
1495 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1497 dsa_switch_release_ports(ds); in dsa_switch_probe()
1505 dst = ds->dst; in dsa_switch_probe()
1509 dsa_switch_release_ports(ds); in dsa_switch_probe()
1516 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1521 err = dsa_switch_probe(ds); in dsa_register_switch()
1522 dsa_tree_put(ds->dst); in dsa_register_switch()
1529 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1531 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1534 dsa_switch_release_ports(ds); in dsa_switch_remove()
1538 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1541 dsa_switch_remove(ds); in dsa_unregister_switch()
1551 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1558 if (!ds->setup) in dsa_switch_shutdown()
1563 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1573 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()
1588 int dsa_switch_suspend(struct dsa_switch *ds) in dsa_switch_suspend() argument
1594 dsa_switch_for_each_port(dp, ds) { in dsa_switch_suspend()
1603 if (ds->ops->suspend) in dsa_switch_suspend()
1604 ret = ds->ops->suspend(ds); in dsa_switch_suspend()
1610 int dsa_switch_resume(struct dsa_switch *ds) in dsa_switch_resume() argument
1615 if (ds->ops->resume) in dsa_switch_resume()
1616 ret = ds->ops->resume(ds); in dsa_switch_resume()
1622 dsa_switch_for_each_port(dp, ds) { in dsa_switch_resume()
1663 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_fdb_present_in_other_db() argument
1667 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_fdb_present_in_other_db()
1684 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port, in dsa_mdb_present_in_other_db() argument
1688 struct dsa_port *dp = dsa_to_port(ds, port); in dsa_mdb_present_in_other_db()