Lines Matching refs:ds
34 if (dp->ds->index != sw_index)
37 return dp->ds;
148 struct dsa_switch *ds = dp->ds;
152 dst = ds->dst;
173 struct dsa_switch *ds = dp->ds;
174 struct dsa_switch_tree *dst = ds->dst;
315 struct dsa_switch_tree *dst = dp->ds->dst;
317 struct devlink *dl = dp->ds->devlink;
399 struct dsa_switch *ds = dsa_devlink_to_ds(dl);
401 if (ds->ops->devlink_info_get)
402 return ds->ops->devlink_info_get(ds, req, extack);
411 static int dsa_switch_setup(struct dsa_switch *ds)
417 if (ds->setup)
420 /* Initialize ds->phys_mii_mask before registering the slave MDIO bus
425 ds->phys_mii_mask |= dsa_user_ports(ds);
430 ds->devlink = devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv));
431 if (!ds->devlink)
433 dl_priv = devlink_priv(ds->devlink);
434 dl_priv->ds = ds;
436 err = devlink_register(ds->devlink, ds->dev);
443 list_for_each_entry(dp, &ds->dst->ports, list) {
444 if (dp->ds == ds) {
451 err = dsa_switch_register_notifier(ds);
455 err = ds->ops->setup(ds);
459 devlink_params_publish(ds->devlink);
461 if (!ds->slave_mii_bus && ds->ops->phy_read) {
462 ds->slave_mii_bus = mdiobus_alloc();
463 if (!ds->slave_mii_bus) {
468 dsa_slave_mii_bus_init(ds);
470 err = mdiobus_register(ds->slave_mii_bus);
475 ds->setup = true;
480 if (ds->slave_mii_bus && ds->ops->phy_read)
481 mdiobus_free(ds->slave_mii_bus);
483 if (ds->ops->teardown)
484 ds->ops->teardown(ds);
486 dsa_switch_unregister_notifier(ds);
488 list_for_each_entry(dp, &ds->dst->ports, list)
489 if (dp->ds == ds)
491 devlink_unregister(ds->devlink);
493 devlink_free(ds->devlink);
494 ds->devlink = NULL;
499 static void dsa_switch_teardown(struct dsa_switch *ds)
503 if (!ds->setup)
506 if (ds->slave_mii_bus && ds->ops->phy_read) {
507 mdiobus_unregister(ds->slave_mii_bus);
508 mdiobus_free(ds->slave_mii_bus);
509 ds->slave_mii_bus = NULL;
512 dsa_switch_unregister_notifier(ds);
514 if (ds->ops->teardown)
515 ds->ops->teardown(ds);
517 if (ds->devlink) {
518 list_for_each_entry(dp, &ds->dst->ports, list)
519 if (dp->ds == ds)
521 devlink_unregister(ds->devlink);
522 devlink_free(ds->devlink);
523 ds->devlink = NULL;
526 ds->setup = false;
535 err = dsa_switch_setup(dp->ds);
559 dsa_switch_teardown(dp->ds);
572 dsa_switch_teardown(dp->ds);
664 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)
666 struct dsa_switch_tree *dst = ds->dst;
670 if (dp->ds == ds && dp->index == index)
677 dp->ds = ds;
708 struct dsa_switch *mds, *ds = dp->ds;
718 mds = mdp->ds;
727 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol);
732 struct dsa_switch *ds = dp->ds;
733 struct dsa_switch_tree *dst = ds->dst;
742 dev_warn(ds->dev, "No tagger for this switch\n");
782 static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
795 dev_err(ds->dev, "no ports child node found\n");
805 if (reg >= ds->num_ports) {
810 dp = dsa_to_port(ds, reg);
822 static int dsa_switch_parse_member_of(struct dsa_switch *ds,
833 ds->index = m[1];
835 ds->dst = dsa_tree_touch(m[0]);
836 if (!ds->dst)
842 static int dsa_switch_touch_ports(struct dsa_switch *ds)
847 for (port = 0; port < ds->num_ports; port++) {
848 dp = dsa_port_touch(ds, port);
856 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn)
860 err = dsa_switch_parse_member_of(ds, dn);
864 err = dsa_switch_touch_ports(ds);
868 return dsa_switch_parse_ports_of(ds, dn);
892 static int dsa_switch_parse_ports(struct dsa_switch *ds,
905 dp = dsa_to_port(ds, i);
923 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd)
927 ds->cd = cd;
932 ds->index = 0;
933 ds->dst = dsa_tree_touch(0);
934 if (!ds->dst)
937 err = dsa_switch_touch_ports(ds);
941 return dsa_switch_parse_ports(ds, cd);
944 static void dsa_switch_release_ports(struct dsa_switch *ds)
946 struct dsa_switch_tree *dst = ds->dst;
950 if (dp->ds != ds)
957 static int dsa_switch_probe(struct dsa_switch *ds)
964 if (!ds->dev)
967 pdata = ds->dev->platform_data;
968 np = ds->dev->of_node;
970 if (!ds->num_ports)
974 err = dsa_switch_parse_of(ds, np);
976 dsa_switch_release_ports(ds);
978 err = dsa_switch_parse(ds, pdata);
980 dsa_switch_release_ports(ds);
988 dst = ds->dst;
992 dsa_switch_release_ports(ds);
999 int dsa_register_switch(struct dsa_switch *ds)
1004 err = dsa_switch_probe(ds);
1005 dsa_tree_put(ds->dst);
1012 static void dsa_switch_remove(struct dsa_switch *ds)
1014 struct dsa_switch_tree *dst = ds->dst;
1017 dsa_switch_release_ports(ds);
1021 void dsa_unregister_switch(struct dsa_switch *ds)
1024 dsa_switch_remove(ds);