Lines Matching refs:ds

187 			if (dp->ds->index != sw_index)  in dsa_switch_find()
190 return dp->ds; in dsa_switch_find()
288 struct dsa_switch *ds = dp->ds; in dsa_link_touch() local
292 dst = ds->dst; in dsa_link_touch()
313 struct dsa_switch *ds = dp->ds; in dsa_port_setup_routing_table() local
314 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table()
403 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
429 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
440 if (ds->ops->port_setup) { in dsa_port_setup()
441 err = ds->ops->port_setup(ds, dp->index); in dsa_port_setup()
489 if (ds->ops->port_teardown) in dsa_port_setup()
490 ds->ops->port_teardown(ds, dp->index); in dsa_port_setup()
502 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup()
504 struct devlink *dl = dp->ds->devlink; in dsa_port_devlink_setup()
544 struct dsa_switch *ds = dp->ds; in dsa_port_teardown() local
550 if (ds->ops->port_teardown) in dsa_port_teardown()
551 ds->ops->port_teardown(ds, dp->index); in dsa_port_teardown()
605 struct dsa_switch *ds = dp->ds; in dsa_port_reinit_as_unused() local
614 if (ds->ops->port_setup) { in dsa_port_reinit_as_unused()
618 err = ds->ops->port_setup(ds, dp->index); in dsa_port_reinit_as_unused()
630 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_info_get() local
632 if (ds->ops->devlink_info_get) in dsa_devlink_info_get()
633 return ds->ops->devlink_info_get(ds, req, extack); in dsa_devlink_info_get()
642 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_get() local
644 if (!ds->ops->devlink_sb_pool_get) in dsa_devlink_sb_pool_get()
647 return ds->ops->devlink_sb_pool_get(ds, sb_index, pool_index, in dsa_devlink_sb_pool_get()
656 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_set() local
658 if (!ds->ops->devlink_sb_pool_set) in dsa_devlink_sb_pool_set()
661 return ds->ops->devlink_sb_pool_set(ds, sb_index, pool_index, size, in dsa_devlink_sb_pool_set()
669 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_get() local
672 if (!ds->ops->devlink_sb_port_pool_get) in dsa_devlink_sb_port_pool_get()
675 return ds->ops->devlink_sb_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_port_pool_get()
684 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_set() local
687 if (!ds->ops->devlink_sb_port_pool_set) in dsa_devlink_sb_port_pool_set()
690 return ds->ops->devlink_sb_port_pool_set(ds, port, sb_index, in dsa_devlink_sb_port_pool_set()
700 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_get() local
703 if (!ds->ops->devlink_sb_tc_pool_bind_get) in dsa_devlink_sb_tc_pool_bind_get()
706 return ds->ops->devlink_sb_tc_pool_bind_get(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_get()
718 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_set() local
721 if (!ds->ops->devlink_sb_tc_pool_bind_set) in dsa_devlink_sb_tc_pool_bind_set()
724 return ds->ops->devlink_sb_tc_pool_bind_set(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_set()
733 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_snapshot() local
735 if (!ds->ops->devlink_sb_occ_snapshot) in dsa_devlink_sb_occ_snapshot()
738 return ds->ops->devlink_sb_occ_snapshot(ds, sb_index); in dsa_devlink_sb_occ_snapshot()
744 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_max_clear() local
746 if (!ds->ops->devlink_sb_occ_max_clear) in dsa_devlink_sb_occ_max_clear()
749 return ds->ops->devlink_sb_occ_max_clear(ds, sb_index); in dsa_devlink_sb_occ_max_clear()
757 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_port_pool_get() local
760 if (!ds->ops->devlink_sb_occ_port_pool_get) in dsa_devlink_sb_occ_port_pool_get()
763 return ds->ops->devlink_sb_occ_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_occ_port_pool_get()
773 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_tc_port_bind_get() local
776 if (!ds->ops->devlink_sb_occ_tc_port_bind_get) in dsa_devlink_sb_occ_tc_port_bind_get()
779 return ds->ops->devlink_sb_occ_tc_port_bind_get(ds, port, in dsa_devlink_sb_occ_tc_port_bind_get()
799 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
801 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
802 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
809 dsa_switch_for_each_cpu_port(cpu_dp, ds) { in dsa_switch_setup_tag_protocol()
811 err = ds->ops->change_tag_protocol(ds, cpu_dp->index, in dsa_switch_setup_tag_protocol()
815 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
824 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
830 if (ds->setup) in dsa_switch_setup()
838 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
843 ds->devlink = in dsa_switch_setup()
844 devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv), ds->dev); in dsa_switch_setup()
845 if (!ds->devlink) in dsa_switch_setup()
847 dl_priv = devlink_priv(ds->devlink); in dsa_switch_setup()
848 dl_priv->ds = ds; in dsa_switch_setup()
853 dsa_switch_for_each_port(dp, ds) { in dsa_switch_setup()
859 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
863 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
865 err = ds->ops->setup(ds); in dsa_switch_setup()
869 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
873 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
874 ds->slave_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
875 if (!ds->slave_mii_bus) { in dsa_switch_setup()
880 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
882 err = mdiobus_register(ds->slave_mii_bus); in dsa_switch_setup()
887 ds->setup = true; in dsa_switch_setup()
888 devlink_register(ds->devlink); in dsa_switch_setup()
892 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
893 mdiobus_free(ds->slave_mii_bus); in dsa_switch_setup()
895 if (ds->ops->teardown) in dsa_switch_setup()
896 ds->ops->teardown(ds); in dsa_switch_setup()
898 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
900 dsa_switch_for_each_port(dp, ds) in dsa_switch_setup()
902 devlink_free(ds->devlink); in dsa_switch_setup()
903 ds->devlink = NULL; in dsa_switch_setup()
907 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
911 if (!ds->setup) in dsa_switch_teardown()
914 if (ds->devlink) in dsa_switch_teardown()
915 devlink_unregister(ds->devlink); in dsa_switch_teardown()
917 if (ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
918 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
919 mdiobus_free(ds->slave_mii_bus); in dsa_switch_teardown()
920 ds->slave_mii_bus = NULL; in dsa_switch_teardown()
923 if (ds->ops->teardown) in dsa_switch_teardown()
924 ds->ops->teardown(ds); in dsa_switch_teardown()
926 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
928 if (ds->devlink) { in dsa_switch_teardown()
929 dsa_switch_for_each_port(dp, ds) in dsa_switch_teardown()
931 devlink_free(ds->devlink); in dsa_switch_teardown()
932 ds->devlink = NULL; in dsa_switch_teardown()
935 ds->setup = false; in dsa_switch_teardown()
962 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
971 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
1026 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
1027 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1172 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1174 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1177 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1185 dp->ds = ds; in dsa_port_touch()
1217 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1227 mds = mdp->ds; in dsa_get_tag_protocol()
1236 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1242 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1243 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1251 dev_err(ds->dev, in dsa_port_parse_cpu()
1261 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1262 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1275 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1281 dev_err(ds->dev, in dsa_port_parse_cpu()
1343 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1356 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1368 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1369 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%zu)\n", in dsa_switch_parse_ports_of()
1370 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1376 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1390 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1401 ds->index = m[1]; in dsa_switch_parse_member_of()
1403 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1404 if (!ds->dst) in dsa_switch_parse_member_of()
1407 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1408 dev_err(ds->dev, in dsa_switch_parse_member_of()
1410 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1414 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1415 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1420 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1425 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1426 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1434 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1438 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1442 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1446 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1470 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1483 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1501 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1505 ds->cd = cd; in dsa_switch_parse()
1510 ds->index = 0; in dsa_switch_parse()
1511 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1512 if (!ds->dst) in dsa_switch_parse()
1515 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1519 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1522 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1526 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1532 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1539 if (!ds->dev) in dsa_switch_probe()
1542 pdata = ds->dev->platform_data; in dsa_switch_probe()
1543 np = ds->dev->of_node; in dsa_switch_probe()
1545 if (!ds->num_ports) in dsa_switch_probe()
1549 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1551 dsa_switch_release_ports(ds); in dsa_switch_probe()
1553 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1555 dsa_switch_release_ports(ds); in dsa_switch_probe()
1563 dst = ds->dst; in dsa_switch_probe()
1567 dsa_switch_release_ports(ds); in dsa_switch_probe()
1574 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1579 err = dsa_switch_probe(ds); in dsa_register_switch()
1580 dsa_tree_put(ds->dst); in dsa_register_switch()
1587 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1589 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1592 dsa_switch_release_ports(ds); in dsa_switch_remove()
1596 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1599 dsa_switch_remove(ds); in dsa_unregister_switch()
1609 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1618 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()