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