Lines Matching refs:ds
212 if (dp->ds->index != sw_index) in dsa_switch_find()
215 return dp->ds; in dsa_switch_find()
313 struct dsa_switch *ds = dp->ds; in dsa_link_touch() local
317 dst = ds->dst; in dsa_link_touch()
338 struct dsa_switch *ds = dp->ds; in dsa_port_setup_routing_table() local
339 struct dsa_switch_tree *dst = ds->dst; in dsa_port_setup_routing_table()
428 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
454 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
461 if (ds->ops->port_setup) { in dsa_port_setup()
462 err = ds->ops->port_setup(ds, dp->index); in dsa_port_setup()
510 if (ds->ops->port_teardown) in dsa_port_setup()
511 ds->ops->port_teardown(ds, dp->index); in dsa_port_setup()
523 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup()
525 struct devlink *dl = dp->ds->devlink; in dsa_port_devlink_setup()
565 struct dsa_switch *ds = dp->ds; in dsa_port_teardown() local
570 if (ds->ops->port_teardown) in dsa_port_teardown()
571 ds->ops->port_teardown(ds, dp->index); in dsa_port_teardown()
615 struct dsa_switch *ds = dp->ds; in dsa_port_reinit_as_unused() local
624 if (ds->ops->port_setup) { in dsa_port_reinit_as_unused()
628 err = ds->ops->port_setup(ds, dp->index); in dsa_port_reinit_as_unused()
640 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_info_get() local
642 if (ds->ops->devlink_info_get) in dsa_devlink_info_get()
643 return ds->ops->devlink_info_get(ds, req, extack); in dsa_devlink_info_get()
652 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_get() local
654 if (!ds->ops->devlink_sb_pool_get) in dsa_devlink_sb_pool_get()
657 return ds->ops->devlink_sb_pool_get(ds, sb_index, pool_index, in dsa_devlink_sb_pool_get()
666 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_set() local
668 if (!ds->ops->devlink_sb_pool_set) in dsa_devlink_sb_pool_set()
671 return ds->ops->devlink_sb_pool_set(ds, sb_index, pool_index, size, in dsa_devlink_sb_pool_set()
679 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_get() local
682 if (!ds->ops->devlink_sb_port_pool_get) in dsa_devlink_sb_port_pool_get()
685 return ds->ops->devlink_sb_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_port_pool_get()
694 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_set() local
697 if (!ds->ops->devlink_sb_port_pool_set) in dsa_devlink_sb_port_pool_set()
700 return ds->ops->devlink_sb_port_pool_set(ds, port, sb_index, in dsa_devlink_sb_port_pool_set()
710 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_get() local
713 if (!ds->ops->devlink_sb_tc_pool_bind_get) in dsa_devlink_sb_tc_pool_bind_get()
716 return ds->ops->devlink_sb_tc_pool_bind_get(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_get()
728 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_set() local
731 if (!ds->ops->devlink_sb_tc_pool_bind_set) in dsa_devlink_sb_tc_pool_bind_set()
734 return ds->ops->devlink_sb_tc_pool_bind_set(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_set()
743 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_snapshot() local
745 if (!ds->ops->devlink_sb_occ_snapshot) in dsa_devlink_sb_occ_snapshot()
748 return ds->ops->devlink_sb_occ_snapshot(ds, sb_index); in dsa_devlink_sb_occ_snapshot()
754 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_max_clear() local
756 if (!ds->ops->devlink_sb_occ_max_clear) in dsa_devlink_sb_occ_max_clear()
759 return ds->ops->devlink_sb_occ_max_clear(ds, sb_index); in dsa_devlink_sb_occ_max_clear()
767 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_port_pool_get() local
770 if (!ds->ops->devlink_sb_occ_port_pool_get) in dsa_devlink_sb_occ_port_pool_get()
773 return ds->ops->devlink_sb_occ_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_occ_port_pool_get()
783 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_tc_port_bind_get() local
786 if (!ds->ops->devlink_sb_occ_tc_port_bind_get) in dsa_devlink_sb_occ_tc_port_bind_get()
789 return ds->ops->devlink_sb_occ_tc_port_bind_get(ds, port, in dsa_devlink_sb_occ_tc_port_bind_get()
809 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
811 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
812 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
819 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
822 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
829 err = tag_ops->connect(ds); in dsa_switch_setup_tag_protocol()
834 if (ds->ops->connect_tag_protocol) { in dsa_switch_setup_tag_protocol()
835 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
837 dev_err(ds->dev, in dsa_switch_setup_tag_protocol()
848 tag_ops->disconnect(ds); in dsa_switch_setup_tag_protocol()
853 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
860 if (ds->setup) in dsa_switch_setup()
868 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
873 ds->devlink = in dsa_switch_setup()
874 devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv), ds->dev); in dsa_switch_setup()
875 if (!ds->devlink) in dsa_switch_setup()
877 dl_priv = devlink_priv(ds->devlink); in dsa_switch_setup()
878 dl_priv->ds = ds; in dsa_switch_setup()
883 dsa_switch_for_each_port(dp, ds) { in dsa_switch_setup()
889 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
893 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
895 err = ds->ops->setup(ds); in dsa_switch_setup()
899 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
903 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
904 ds->slave_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
905 if (!ds->slave_mii_bus) { in dsa_switch_setup()
910 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
912 dn = of_get_child_by_name(ds->dev->of_node, "mdio"); in dsa_switch_setup()
914 err = of_mdiobus_register(ds->slave_mii_bus, dn); in dsa_switch_setup()
920 ds->setup = true; in dsa_switch_setup()
921 devlink_register(ds->devlink); in dsa_switch_setup()
925 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
926 mdiobus_free(ds->slave_mii_bus); in dsa_switch_setup()
928 if (ds->ops->teardown) in dsa_switch_setup()
929 ds->ops->teardown(ds); in dsa_switch_setup()
931 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
933 dsa_switch_for_each_port(dp, ds) in dsa_switch_setup()
935 devlink_free(ds->devlink); in dsa_switch_setup()
936 ds->devlink = NULL; in dsa_switch_setup()
940 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
944 if (!ds->setup) in dsa_switch_teardown()
947 if (ds->devlink) in dsa_switch_teardown()
948 devlink_unregister(ds->devlink); in dsa_switch_teardown()
950 if (ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
951 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
952 mdiobus_free(ds->slave_mii_bus); in dsa_switch_teardown()
953 ds->slave_mii_bus = NULL; in dsa_switch_teardown()
956 if (ds->ops->teardown) in dsa_switch_teardown()
957 ds->ops->teardown(ds); in dsa_switch_teardown()
959 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
961 if (ds->devlink) { in dsa_switch_teardown()
962 dsa_switch_for_each_port(dp, ds) in dsa_switch_teardown()
964 devlink_free(ds->devlink); in dsa_switch_teardown()
965 ds->devlink = NULL; in dsa_switch_teardown()
968 ds->setup = false; in dsa_switch_teardown()
995 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
1037 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
1105 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
1106 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1336 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1338 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1341 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1349 dp->ds = ds; in dsa_port_touch()
1385 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1395 mds = mdp->ds; in dsa_get_tag_protocol()
1404 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1410 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1411 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1419 dev_err(ds->dev, in dsa_port_parse_cpu()
1429 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1430 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1443 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1449 dev_err(ds->dev, in dsa_port_parse_cpu()
1512 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1525 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1537 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1538 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1539 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1545 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1559 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1570 ds->index = m[1]; in dsa_switch_parse_member_of()
1572 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1573 if (!ds->dst) in dsa_switch_parse_member_of()
1576 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1577 dev_err(ds->dev, in dsa_switch_parse_member_of()
1579 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1583 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1584 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1589 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1594 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1595 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1603 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1607 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1611 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1615 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1639 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1652 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1670 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1674 ds->cd = cd; in dsa_switch_parse()
1679 ds->index = 0; in dsa_switch_parse()
1680 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1681 if (!ds->dst) in dsa_switch_parse()
1684 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1688 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1691 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1695 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1704 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1711 if (!ds->dev) in dsa_switch_probe()
1714 pdata = ds->dev->platform_data; in dsa_switch_probe()
1715 np = ds->dev->of_node; in dsa_switch_probe()
1717 if (!ds->num_ports) in dsa_switch_probe()
1721 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1723 dsa_switch_release_ports(ds); in dsa_switch_probe()
1725 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1727 dsa_switch_release_ports(ds); in dsa_switch_probe()
1735 dst = ds->dst; in dsa_switch_probe()
1739 dsa_switch_release_ports(ds); in dsa_switch_probe()
1746 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1751 err = dsa_switch_probe(ds); in dsa_register_switch()
1752 dsa_tree_put(ds->dst); in dsa_register_switch()
1759 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1761 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1764 dsa_switch_release_ports(ds); in dsa_switch_remove()
1768 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1771 dsa_switch_remove(ds); in dsa_unregister_switch()
1781 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1788 if (!ds->setup) in dsa_switch_shutdown()
1793 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1803 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()