Lines Matching refs:ds

59  * driver by setting ds->num_lag_ids. It is perfectly legal to leave
189 if (dp->ds->index != sw_index)
192 return dp->ds;
290 struct dsa_switch *ds = dp->ds;
294 dst = ds->dst;
315 struct dsa_switch *ds = dp->ds;
316 struct dsa_switch_tree *dst = ds->dst;
406 dsa_switch_preferred_default_local_cpu_port(struct dsa_switch *ds)
410 if (!ds->ops->preferred_default_local_cpu_port)
413 cpu_dp = ds->ops->preferred_default_local_cpu_port(ds);
417 if (WARN_ON(!dsa_port_is_cpu(cpu_dp) || cpu_dp->ds != ds))
436 preferred_cpu_dp = dsa_switch_preferred_default_local_cpu_port(cpu_dp->ds);
441 dsa_switch_for_each_port(dp, cpu_dp->ds) {
466 struct dsa_switch *ds = dp->ds;
488 dev_warn(ds->dev,
506 dev_warn(ds->dev,
574 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds)
576 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops;
577 struct dsa_switch_tree *dst = ds->dst;
584 err = ds->ops->change_tag_protocol(ds, tag_ops->proto);
587 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n",
594 err = tag_ops->connect(ds);
599 if (ds->ops->connect_tag_protocol) {
600 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto);
602 dev_err(ds->dev,
613 tag_ops->disconnect(ds);
618 static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds)
620 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops;
623 tag_ops->disconnect(ds);
626 static int dsa_switch_setup(struct dsa_switch *ds)
630 if (ds->setup)
633 /* Initialize ds->phys_mii_mask before registering the user MDIO bus
638 ds->phys_mii_mask |= dsa_user_ports(ds);
640 err = dsa_switch_devlink_alloc(ds);
644 err = dsa_switch_register_notifier(ds);
648 ds->configure_vlan_while_not_filtering = true;
650 err = ds->ops->setup(ds);
654 err = dsa_switch_setup_tag_protocol(ds);
658 if (!ds->user_mii_bus && ds->ops->phy_read) {
659 ds->user_mii_bus = mdiobus_alloc();
660 if (!ds->user_mii_bus) {
665 dsa_user_mii_bus_init(ds);
667 err = mdiobus_register(ds->user_mii_bus);
672 dsa_switch_devlink_register(ds);
674 ds->setup = true;
678 if (ds->user_mii_bus && ds->ops->phy_read)
679 mdiobus_free(ds->user_mii_bus);
681 if (ds->ops->teardown)
682 ds->ops->teardown(ds);
684 dsa_switch_unregister_notifier(ds);
686 dsa_switch_devlink_free(ds);
690 static void dsa_switch_teardown(struct dsa_switch *ds)
692 if (!ds->setup)
695 dsa_switch_devlink_unregister(ds);
697 if (ds->user_mii_bus && ds->ops->phy_read) {
698 mdiobus_unregister(ds->user_mii_bus);
699 mdiobus_free(ds->user_mii_bus);
700 ds->user_mii_bus = NULL;
703 dsa_switch_teardown_tag_protocol(ds);
705 if (ds->ops->teardown)
706 ds->ops->teardown(ds);
708 dsa_switch_unregister_notifier(ds);
710 dsa_switch_devlink_free(ds);
712 ds->setup = false;
739 dsa_switch_teardown(dp->ds);
781 err = dsa_switch_setup(dp->ds);
845 if (dp->ds->num_lag_ids > len)
846 len = dp->ds->num_lag_ids;
1091 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)
1093 struct dsa_switch_tree *dst = ds->dst;
1096 dsa_switch_for_each_port(dp, ds)
1104 dp->ds = ds;
1137 struct dsa_switch *mds, *ds = dp->ds;
1147 mds = mdp->ds;
1156 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol);
1163 struct dsa_switch *ds = dp->ds;
1164 struct dsa_switch_tree *dst = ds->dst;
1171 dev_err(ds->dev,
1181 if (!ds->ops->change_tag_protocol) {
1182 dev_err(ds->dev, "Tag protocol cannot be modified\n");
1188 dev_warn(ds->dev,
1202 dev_warn(ds->dev, "No tagger for this switch\n");
1208 dev_err(ds->dev,
1271 static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
1284 dev_err(ds->dev, "no ports child node found\n");
1296 if (reg >= ds->num_ports) {
1297 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n",
1298 port, reg, ds->num_ports);
1304 dp = dsa_to_port(ds, reg);
1318 static int dsa_switch_parse_member_of(struct dsa_switch *ds,
1329 ds->index = m[1];
1331 ds->dst = dsa_tree_touch(m[0]);
1332 if (!ds->dst)
1335 if (dsa_switch_find(ds->dst->index, ds->index)) {
1336 dev_err(ds->dev,
1338 ds->index, ds->dst->index);
1342 if (ds->dst->last_switch < ds->index)
1343 ds->dst->last_switch = ds->index;
1348 static int dsa_switch_touch_ports(struct dsa_switch *ds)
1353 for (port = 0; port < ds->num_ports; port++) {
1354 dp = dsa_port_touch(ds, port);
1362 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn)
1366 err = dsa_switch_parse_member_of(ds, dn);
1370 err = dsa_switch_touch_ports(ds);
1374 return dsa_switch_parse_ports_of(ds, dn);
1434 static int dsa_switch_parse_ports(struct dsa_switch *ds,
1447 dp = dsa_to_port(ds, i);
1465 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd)
1469 ds->cd = cd;
1474 ds->index = 0;
1475 ds->dst = dsa_tree_touch(0);
1476 if (!ds->dst)
1479 err = dsa_switch_touch_ports(ds);
1483 return dsa_switch_parse_ports(ds, cd);
1486 static void dsa_switch_release_ports(struct dsa_switch *ds)
1492 dsa_switch_for_each_port_safe(dp, next, ds) {
1499 dev_info(ds->dev,
1507 dev_info(ds->dev,
1519 dev_info(ds->dev,
1531 static int dsa_switch_probe(struct dsa_switch *ds)
1538 if (!ds->dev)
1541 pdata = ds->dev->platform_data;
1542 np = ds->dev->of_node;
1544 if (!ds->num_ports)
1548 err = dsa_switch_parse_of(ds, np);
1550 dsa_switch_release_ports(ds);
1552 err = dsa_switch_parse(ds, pdata);
1554 dsa_switch_release_ports(ds);
1562 dst = ds->dst;
1566 dsa_switch_release_ports(ds);
1573 int dsa_register_switch(struct dsa_switch *ds)
1578 err = dsa_switch_probe(ds);
1579 dsa_tree_put(ds->dst);
1586 static void dsa_switch_remove(struct dsa_switch *ds)
1588 struct dsa_switch_tree *dst = ds->dst;
1591 dsa_switch_release_ports(ds);
1595 void dsa_unregister_switch(struct dsa_switch *ds)
1598 dsa_switch_remove(ds);
1608 void dsa_switch_shutdown(struct dsa_switch *ds)
1616 if (!ds->setup)
1621 dsa_switch_for_each_cpu_port(dp, ds)
1626 dsa_switch_for_each_user_port(dp, ds) {
1637 dsa_switch_for_each_cpu_port(dp, ds)
1652 int dsa_switch_suspend(struct dsa_switch *ds)
1658 dsa_switch_for_each_port(dp, ds) {
1667 if (ds->ops->suspend)
1668 ret = ds->ops->suspend(ds);
1674 int dsa_switch_resume(struct dsa_switch *ds)
1679 if (ds->ops->resume)
1680 ret = ds->ops->resume(ds);
1686 dsa_switch_for_each_port(dp, ds) {
1727 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port,
1731 struct dsa_port *dp = dsa_to_port(ds, port);
1748 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port,
1752 struct dsa_port *dp = dsa_to_port(ds, port);