Lines Matching full:ds

82  * driver by setting ds->num_lag_ids. It is perfectly legal to leave
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()
442 dsa_switch_for_each_port(dp, cpu_dp->ds) { in dsa_tree_setup_cpu_ports()
467 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup()
469 struct devlink *dl = dp->ds->devlink; in dsa_port_devlink_setup()
470 struct dsa_switch *ds = dp->ds; in dsa_port_devlink_setup() local
478 if (ds->ops->port_setup) { in dsa_port_devlink_setup()
479 err = ds->ops->port_setup(ds, dp->index); in dsa_port_devlink_setup()
509 if (ds->ops->port_teardown) in dsa_port_devlink_setup()
510 ds->ops->port_teardown(ds, dp->index); in dsa_port_devlink_setup()
520 struct dsa_switch *ds = dp->ds; in dsa_port_devlink_teardown() local
524 if (ds->ops->port_teardown) in dsa_port_devlink_teardown()
525 ds->ops->port_teardown(ds, dp->index); in dsa_port_devlink_teardown()
534 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
556 dev_warn(ds->dev, in dsa_port_setup()
574 dev_warn(ds->dev, in dsa_port_setup()
654 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_info_get() local
656 if (ds->ops->devlink_info_get) in dsa_devlink_info_get()
657 return ds->ops->devlink_info_get(ds, req, extack); in dsa_devlink_info_get()
666 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_get() local
668 if (!ds->ops->devlink_sb_pool_get) in dsa_devlink_sb_pool_get()
671 return ds->ops->devlink_sb_pool_get(ds, sb_index, pool_index, in dsa_devlink_sb_pool_get()
680 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_set() local
682 if (!ds->ops->devlink_sb_pool_set) in dsa_devlink_sb_pool_set()
685 return ds->ops->devlink_sb_pool_set(ds, sb_index, pool_index, size, in dsa_devlink_sb_pool_set()
693 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_get() local
696 if (!ds->ops->devlink_sb_port_pool_get) in dsa_devlink_sb_port_pool_get()
699 return ds->ops->devlink_sb_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_port_pool_get()
708 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_set() local
711 if (!ds->ops->devlink_sb_port_pool_set) in dsa_devlink_sb_port_pool_set()
714 return ds->ops->devlink_sb_port_pool_set(ds, port, sb_index, in dsa_devlink_sb_port_pool_set()
724 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_get() local
727 if (!ds->ops->devlink_sb_tc_pool_bind_get) in dsa_devlink_sb_tc_pool_bind_get()
730 return ds->ops->devlink_sb_tc_pool_bind_get(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_get()
742 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_set() local
745 if (!ds->ops->devlink_sb_tc_pool_bind_set) in dsa_devlink_sb_tc_pool_bind_set()
748 return ds->ops->devlink_sb_tc_pool_bind_set(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_set()
757 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_snapshot() local
759 if (!ds->ops->devlink_sb_occ_snapshot) in dsa_devlink_sb_occ_snapshot()
762 return ds->ops->devlink_sb_occ_snapshot(ds, sb_index); in dsa_devlink_sb_occ_snapshot()
768 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_max_clear() local
770 if (!ds->ops->devlink_sb_occ_max_clear) in dsa_devlink_sb_occ_max_clear()
773 return ds->ops->devlink_sb_occ_max_clear(ds, sb_index); in dsa_devlink_sb_occ_max_clear()
781 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_port_pool_get() local
784 if (!ds->ops->devlink_sb_occ_port_pool_get) in dsa_devlink_sb_occ_port_pool_get()
787 return ds->ops->devlink_sb_occ_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_occ_port_pool_get()
797 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_tc_port_bind_get() local
800 if (!ds->ops->devlink_sb_occ_tc_port_bind_get) in dsa_devlink_sb_occ_tc_port_bind_get()
803 return ds->ops->devlink_sb_occ_tc_port_bind_get(ds, port, in dsa_devlink_sb_occ_tc_port_bind_get()
823 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
825 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
826 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
833 err = ds->ops->change_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
836 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
843 err = tag_ops->connect(ds); in dsa_switch_setup_tag_protocol()
848 if (ds->ops->connect_tag_protocol) { in dsa_switch_setup_tag_protocol()
849 err = ds->ops->connect_tag_protocol(ds, tag_ops->proto); in dsa_switch_setup_tag_protocol()
851 dev_err(ds->dev, in dsa_switch_setup_tag_protocol()
862 tag_ops->disconnect(ds); in dsa_switch_setup_tag_protocol()
867 static void dsa_switch_teardown_tag_protocol(struct dsa_switch *ds) in dsa_switch_teardown_tag_protocol() argument
869 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_teardown_tag_protocol()
872 tag_ops->disconnect(ds); in dsa_switch_teardown_tag_protocol()
875 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
881 if (ds->setup) in dsa_switch_setup()
884 /* Initialize ds->phys_mii_mask before registering the slave MDIO bus in dsa_switch_setup()
889 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
894 ds->devlink = in dsa_switch_setup()
895 devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv), ds->dev); in dsa_switch_setup()
896 if (!ds->devlink) in dsa_switch_setup()
898 dl_priv = devlink_priv(ds->devlink); in dsa_switch_setup()
899 dl_priv->ds = ds; in dsa_switch_setup()
901 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
905 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
907 err = ds->ops->setup(ds); in dsa_switch_setup()
911 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
915 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
916 ds->slave_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
917 if (!ds->slave_mii_bus) { in dsa_switch_setup()
922 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
924 dn = of_get_child_by_name(ds->dev->of_node, "mdio"); in dsa_switch_setup()
926 err = of_mdiobus_register(ds->slave_mii_bus, dn); in dsa_switch_setup()
932 ds->setup = true; in dsa_switch_setup()
933 devlink_register(ds->devlink); in dsa_switch_setup()
937 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
938 mdiobus_free(ds->slave_mii_bus); in dsa_switch_setup()
940 if (ds->ops->teardown) in dsa_switch_setup()
941 ds->ops->teardown(ds); in dsa_switch_setup()
943 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
945 devlink_free(ds->devlink); in dsa_switch_setup()
946 ds->devlink = NULL; in dsa_switch_setup()
950 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
952 if (!ds->setup) in dsa_switch_teardown()
955 if (ds->devlink) in dsa_switch_teardown()
956 devlink_unregister(ds->devlink); in dsa_switch_teardown()
958 if (ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
959 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
960 mdiobus_free(ds->slave_mii_bus); in dsa_switch_teardown()
961 ds->slave_mii_bus = NULL; in dsa_switch_teardown()
964 dsa_switch_teardown_tag_protocol(ds); in dsa_switch_teardown()
966 if (ds->ops->teardown) in dsa_switch_teardown()
967 ds->ops->teardown(ds); in dsa_switch_teardown()
969 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
971 if (ds->devlink) { in dsa_switch_teardown()
972 devlink_free(ds->devlink); in dsa_switch_teardown()
973 ds->devlink = NULL; in dsa_switch_teardown()
976 ds->setup = false; in dsa_switch_teardown()
1003 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
1045 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
1109 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
1110 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1348 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1350 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1353 dsa_switch_for_each_port(dp, ds) in dsa_port_touch()
1361 dp->ds = ds; in dsa_port_touch()
1397 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1407 mds = mdp->ds; in dsa_get_tag_protocol()
1416 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1423 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1424 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1431 dev_err(ds->dev, in dsa_port_parse_cpu()
1441 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1442 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1448 dev_warn(ds->dev, in dsa_port_parse_cpu()
1462 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1468 dev_err(ds->dev, in dsa_port_parse_cpu()
1531 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1544 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1556 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1557 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", in dsa_switch_parse_ports_of()
1558 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1564 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1578 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1589 ds->index = m[1]; in dsa_switch_parse_member_of()
1591 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1592 if (!ds->dst) in dsa_switch_parse_member_of()
1595 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1596 dev_err(ds->dev, in dsa_switch_parse_member_of()
1598 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1602 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1603 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1608 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1613 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1614 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1622 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1626 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1630 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1634 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1658 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1671 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1689 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1693 ds->cd = cd; in dsa_switch_parse()
1698 ds->index = 0; in dsa_switch_parse()
1699 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1700 if (!ds->dst) in dsa_switch_parse()
1703 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1707 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1710 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1714 dsa_switch_for_each_port_safe(dp, next, ds) { in dsa_switch_release_ports()
1723 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1730 if (!ds->dev) in dsa_switch_probe()
1733 pdata = ds->dev->platform_data; in dsa_switch_probe()
1734 np = ds->dev->of_node; in dsa_switch_probe()
1736 if (!ds->num_ports) in dsa_switch_probe()
1740 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1742 dsa_switch_release_ports(ds); in dsa_switch_probe()
1744 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1746 dsa_switch_release_ports(ds); in dsa_switch_probe()
1754 dst = ds->dst; in dsa_switch_probe()
1758 dsa_switch_release_ports(ds); in dsa_switch_probe()
1765 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1770 err = dsa_switch_probe(ds); in dsa_register_switch()
1771 dsa_tree_put(ds->dst); in dsa_register_switch()
1778 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1780 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1783 dsa_switch_release_ports(ds); in dsa_switch_remove()
1787 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1790 dsa_switch_remove(ds); in dsa_unregister_switch()
1800 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1807 if (!ds->setup) in dsa_switch_shutdown()
1812 dsa_switch_for_each_user_port(dp, ds) { in dsa_switch_shutdown()
1822 dsa_switch_for_each_cpu_port(dp, ds) in dsa_switch_shutdown()