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;
1084 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)
1086 struct dsa_switch_tree *dst = ds->dst;
1089 dsa_switch_for_each_port(dp, ds)
1097 dp->ds = ds;
1130 struct dsa_switch *mds, *ds = dp->ds;
1140 mds = mdp->ds;
1149 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol);
1156 struct dsa_switch *ds = dp->ds;
1157 struct dsa_switch_tree *dst = ds->dst;
1164 dev_err(ds->dev,
1174 if (!ds->ops->change_tag_protocol) {
1175 dev_err(ds->dev, "Tag protocol cannot be modified\n");
1181 dev_warn(ds->dev,
1195 dev_warn(ds->dev, "No tagger for this switch\n");
1201 dev_err(ds->dev,
1264 static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
1277 dev_err(ds->dev, "no ports child node found\n");
1289 if (reg >= ds->num_ports) {
1290 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n",
1291 port, reg, ds->num_ports);
1297 dp = dsa_to_port(ds, reg);
1311 static int dsa_switch_parse_member_of(struct dsa_switch *ds,
1322 ds->index = m[1];
1324 ds->dst = dsa_tree_touch(m[0]);
1325 if (!ds->dst)
1328 if (dsa_switch_find(ds->dst->index, ds->index)) {
1329 dev_err(ds->dev,
1331 ds->index, ds->dst->index);
1335 if (ds->dst->last_switch < ds->index)
1336 ds->dst->last_switch = ds->index;
1341 static int dsa_switch_touch_ports(struct dsa_switch *ds)
1346 for (port = 0; port < ds->num_ports; port++) {
1347 dp = dsa_port_touch(ds, port);
1355 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn)
1359 err = dsa_switch_parse_member_of(ds, dn);
1363 err = dsa_switch_touch_ports(ds);
1367 return dsa_switch_parse_ports_of(ds, dn);
1427 static int dsa_switch_parse_ports(struct dsa_switch *ds,
1440 dp = dsa_to_port(ds, i);
1458 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd)
1462 ds->cd = cd;
1467 ds->index = 0;
1468 ds->dst = dsa_tree_touch(0);
1469 if (!ds->dst)
1472 err = dsa_switch_touch_ports(ds);
1476 return dsa_switch_parse_ports(ds, cd);
1479 static void dsa_switch_release_ports(struct dsa_switch *ds)
1483 dsa_switch_for_each_port_safe(dp, next, ds) {
1492 static int dsa_switch_probe(struct dsa_switch *ds)
1499 if (!ds->dev)
1502 pdata = ds->dev->platform_data;
1503 np = ds->dev->of_node;
1505 if (!ds->num_ports)
1508 if (ds->phylink_mac_ops) {
1509 if (ds->ops->phylink_mac_select_pcs ||
1510 ds->ops->phylink_mac_prepare ||
1511 ds->ops->phylink_mac_config ||
1512 ds->ops->phylink_mac_finish ||
1513 ds->ops->phylink_mac_link_down ||
1514 ds->ops->phylink_mac_link_up)
1519 err = dsa_switch_parse_of(ds, np);
1521 dsa_switch_release_ports(ds);
1523 err = dsa_switch_parse(ds, pdata);
1525 dsa_switch_release_ports(ds);
1533 dst = ds->dst;
1537 dsa_switch_release_ports(ds);
1544 int dsa_register_switch(struct dsa_switch *ds)
1549 err = dsa_switch_probe(ds);
1550 dsa_tree_put(ds->dst);
1557 static void dsa_switch_remove(struct dsa_switch *ds)
1559 struct dsa_switch_tree *dst = ds->dst;
1562 dsa_switch_release_ports(ds);
1566 void dsa_unregister_switch(struct dsa_switch *ds)
1569 dsa_switch_remove(ds);
1579 void dsa_switch_shutdown(struct dsa_switch *ds)
1586 if (!ds->setup)
1591 dsa_switch_for_each_user_port(dp, ds) {
1601 dsa_switch_for_each_cpu_port(dp, ds)
1616 int dsa_switch_suspend(struct dsa_switch *ds)
1622 dsa_switch_for_each_port(dp, ds) {
1631 if (ds->ops->suspend)
1632 ret = ds->ops->suspend(ds);
1638 int dsa_switch_resume(struct dsa_switch *ds)
1643 if (ds->ops->resume)
1644 ret = ds->ops->resume(ds);
1650 dsa_switch_for_each_port(dp, ds) {
1691 bool dsa_fdb_present_in_other_db(struct dsa_switch *ds, int port,
1695 struct dsa_port *dp = dsa_to_port(ds, port);
1712 bool dsa_mdb_present_in_other_db(struct dsa_switch *ds, int port,
1716 struct dsa_port *dp = dsa_to_port(ds, port);