Lines Matching full:ds
80 * driver by setting ds->num_lag_ids. It is perfectly legal to leave
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()
404 if (dp->ds != cpu_dp->ds) in dsa_tree_setup_cpu_ports()
432 struct dsa_switch *ds = dp->ds; in dsa_port_setup() local
442 if (ds->ops->port_setup) { in dsa_port_setup()
443 err = ds->ops->port_setup(ds, dp->index); in dsa_port_setup()
491 if (ds->ops->port_teardown) in dsa_port_setup()
492 ds->ops->port_teardown(ds, dp->index); in dsa_port_setup()
504 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_port_devlink_setup()
506 struct devlink *dl = dp->ds->devlink; in dsa_port_devlink_setup()
546 struct dsa_switch *ds = dp->ds; in dsa_port_teardown() local
552 if (ds->ops->port_teardown) in dsa_port_teardown()
553 ds->ops->port_teardown(ds, dp->index); in dsa_port_teardown()
599 * flavour. At this point, any call to ds->ops->port_setup has been already
600 * balanced out by a call to ds->ops->port_teardown, so we know that any
602 * ds->ops->port_setup again, in order for the driver to re-create them on the
607 struct dsa_switch *ds = dp->ds; in dsa_port_reinit_as_unused() local
616 if (ds->ops->port_setup) { in dsa_port_reinit_as_unused()
620 err = ds->ops->port_setup(ds, dp->index); in dsa_port_reinit_as_unused()
632 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_info_get() local
634 if (ds->ops->devlink_info_get) in dsa_devlink_info_get()
635 return ds->ops->devlink_info_get(ds, req, extack); in dsa_devlink_info_get()
644 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_get() local
646 if (!ds->ops->devlink_sb_pool_get) in dsa_devlink_sb_pool_get()
649 return ds->ops->devlink_sb_pool_get(ds, sb_index, pool_index, in dsa_devlink_sb_pool_get()
658 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_pool_set() local
660 if (!ds->ops->devlink_sb_pool_set) in dsa_devlink_sb_pool_set()
663 return ds->ops->devlink_sb_pool_set(ds, sb_index, pool_index, size, in dsa_devlink_sb_pool_set()
671 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_get() local
674 if (!ds->ops->devlink_sb_port_pool_get) in dsa_devlink_sb_port_pool_get()
677 return ds->ops->devlink_sb_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_port_pool_get()
686 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_port_pool_set() local
689 if (!ds->ops->devlink_sb_port_pool_set) in dsa_devlink_sb_port_pool_set()
692 return ds->ops->devlink_sb_port_pool_set(ds, port, sb_index, in dsa_devlink_sb_port_pool_set()
702 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_get() local
705 if (!ds->ops->devlink_sb_tc_pool_bind_get) in dsa_devlink_sb_tc_pool_bind_get()
708 return ds->ops->devlink_sb_tc_pool_bind_get(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_get()
720 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_tc_pool_bind_set() local
723 if (!ds->ops->devlink_sb_tc_pool_bind_set) in dsa_devlink_sb_tc_pool_bind_set()
726 return ds->ops->devlink_sb_tc_pool_bind_set(ds, port, sb_index, in dsa_devlink_sb_tc_pool_bind_set()
735 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_snapshot() local
737 if (!ds->ops->devlink_sb_occ_snapshot) in dsa_devlink_sb_occ_snapshot()
740 return ds->ops->devlink_sb_occ_snapshot(ds, sb_index); in dsa_devlink_sb_occ_snapshot()
746 struct dsa_switch *ds = dsa_devlink_to_ds(dl); in dsa_devlink_sb_occ_max_clear() local
748 if (!ds->ops->devlink_sb_occ_max_clear) in dsa_devlink_sb_occ_max_clear()
751 return ds->ops->devlink_sb_occ_max_clear(ds, sb_index); in dsa_devlink_sb_occ_max_clear()
759 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_port_pool_get() local
762 if (!ds->ops->devlink_sb_occ_port_pool_get) in dsa_devlink_sb_occ_port_pool_get()
765 return ds->ops->devlink_sb_occ_port_pool_get(ds, port, sb_index, in dsa_devlink_sb_occ_port_pool_get()
775 struct dsa_switch *ds = dsa_devlink_port_to_ds(dlp); in dsa_devlink_sb_occ_tc_port_bind_get() local
778 if (!ds->ops->devlink_sb_occ_tc_port_bind_get) in dsa_devlink_sb_occ_tc_port_bind_get()
781 return ds->ops->devlink_sb_occ_tc_port_bind_get(ds, port, in dsa_devlink_sb_occ_tc_port_bind_get()
801 static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds) in dsa_switch_setup_tag_protocol() argument
803 const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; in dsa_switch_setup_tag_protocol()
804 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_setup_tag_protocol()
810 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_setup_tag_protocol()
811 if (!dsa_is_cpu_port(ds, port)) in dsa_switch_setup_tag_protocol()
815 err = ds->ops->change_tag_protocol(ds, port, tag_ops->proto); in dsa_switch_setup_tag_protocol()
818 dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n", in dsa_switch_setup_tag_protocol()
827 static int dsa_switch_setup(struct dsa_switch *ds) in dsa_switch_setup() argument
833 if (ds->setup) in dsa_switch_setup()
836 /* Initialize ds->phys_mii_mask before registering the slave MDIO bus in dsa_switch_setup()
841 ds->phys_mii_mask |= dsa_user_ports(ds); in dsa_switch_setup()
846 ds->devlink = in dsa_switch_setup()
847 devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv), ds->dev); in dsa_switch_setup()
848 if (!ds->devlink) in dsa_switch_setup()
850 dl_priv = devlink_priv(ds->devlink); in dsa_switch_setup()
851 dl_priv->ds = ds; in dsa_switch_setup()
853 err = devlink_register(ds->devlink); in dsa_switch_setup()
860 list_for_each_entry(dp, &ds->dst->ports, list) { in dsa_switch_setup()
861 if (dp->ds == ds) { in dsa_switch_setup()
868 err = dsa_switch_register_notifier(ds); in dsa_switch_setup()
872 ds->configure_vlan_while_not_filtering = true; in dsa_switch_setup()
874 err = ds->ops->setup(ds); in dsa_switch_setup()
878 err = dsa_switch_setup_tag_protocol(ds); in dsa_switch_setup()
882 devlink_params_publish(ds->devlink); in dsa_switch_setup()
884 if (!ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_setup()
885 ds->slave_mii_bus = mdiobus_alloc(); in dsa_switch_setup()
886 if (!ds->slave_mii_bus) { in dsa_switch_setup()
891 dsa_slave_mii_bus_init(ds); in dsa_switch_setup()
893 err = mdiobus_register(ds->slave_mii_bus); in dsa_switch_setup()
898 ds->setup = true; in dsa_switch_setup()
903 if (ds->slave_mii_bus && ds->ops->phy_read) in dsa_switch_setup()
904 mdiobus_free(ds->slave_mii_bus); in dsa_switch_setup()
906 if (ds->ops->teardown) in dsa_switch_setup()
907 ds->ops->teardown(ds); in dsa_switch_setup()
909 dsa_switch_unregister_notifier(ds); in dsa_switch_setup()
911 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_setup()
912 if (dp->ds == ds) in dsa_switch_setup()
914 devlink_unregister(ds->devlink); in dsa_switch_setup()
916 devlink_free(ds->devlink); in dsa_switch_setup()
917 ds->devlink = NULL; in dsa_switch_setup()
922 static void dsa_switch_teardown(struct dsa_switch *ds) in dsa_switch_teardown() argument
926 if (!ds->setup) in dsa_switch_teardown()
929 if (ds->slave_mii_bus && ds->ops->phy_read) { in dsa_switch_teardown()
930 mdiobus_unregister(ds->slave_mii_bus); in dsa_switch_teardown()
931 mdiobus_free(ds->slave_mii_bus); in dsa_switch_teardown()
932 ds->slave_mii_bus = NULL; in dsa_switch_teardown()
935 dsa_switch_unregister_notifier(ds); in dsa_switch_teardown()
937 if (ds->ops->teardown) in dsa_switch_teardown()
938 ds->ops->teardown(ds); in dsa_switch_teardown()
940 if (ds->devlink) { in dsa_switch_teardown()
941 list_for_each_entry(dp, &ds->dst->ports, list) in dsa_switch_teardown()
942 if (dp->ds == ds) in dsa_switch_teardown()
944 devlink_unregister(ds->devlink); in dsa_switch_teardown()
945 devlink_free(ds->devlink); in dsa_switch_teardown()
946 ds->devlink = NULL; in dsa_switch_teardown()
949 ds->setup = false; in dsa_switch_teardown()
976 dsa_switch_teardown(dp->ds); in dsa_tree_teardown_switches()
985 err = dsa_switch_setup(dp->ds); in dsa_tree_setup_switches()
1040 if (dp->ds->num_lag_ids > len) in dsa_tree_setup_lags()
1041 len = dp->ds->num_lag_ids; in dsa_tree_setup_lags()
1160 if (!dsa_is_user_port(dp->ds, dp->index)) in dsa_tree_change_tag_proto()
1186 static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) in dsa_port_touch() argument
1188 struct dsa_switch_tree *dst = ds->dst; in dsa_port_touch()
1192 if (dp->ds == ds && dp->index == index) in dsa_port_touch()
1199 dp->ds = ds; in dsa_port_touch()
1231 struct dsa_switch *mds, *ds = dp->ds; in dsa_get_tag_protocol() local
1241 mds = mdp->ds; in dsa_get_tag_protocol()
1250 return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); in dsa_get_tag_protocol()
1256 struct dsa_switch *ds = dp->ds; in dsa_port_parse_cpu() local
1257 struct dsa_switch_tree *dst = ds->dst; in dsa_port_parse_cpu()
1265 dev_err(ds->dev, in dsa_port_parse_cpu()
1275 if (!ds->ops->change_tag_protocol) { in dsa_port_parse_cpu()
1276 dev_err(ds->dev, "Tag protocol cannot be modified\n"); in dsa_port_parse_cpu()
1289 dev_warn(ds->dev, "No tagger for this switch\n"); in dsa_port_parse_cpu()
1295 dev_err(ds->dev, in dsa_port_parse_cpu()
1357 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, in dsa_switch_parse_ports_of() argument
1370 dev_err(ds->dev, "no ports child node found\n"); in dsa_switch_parse_ports_of()
1382 if (reg >= ds->num_ports) { in dsa_switch_parse_ports_of()
1383 dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%zu)\n", in dsa_switch_parse_ports_of()
1384 port, reg, ds->num_ports); in dsa_switch_parse_ports_of()
1390 dp = dsa_to_port(ds, reg); in dsa_switch_parse_ports_of()
1404 static int dsa_switch_parse_member_of(struct dsa_switch *ds, in dsa_switch_parse_member_of() argument
1415 ds->index = m[1]; in dsa_switch_parse_member_of()
1417 ds->dst = dsa_tree_touch(m[0]); in dsa_switch_parse_member_of()
1418 if (!ds->dst) in dsa_switch_parse_member_of()
1421 if (dsa_switch_find(ds->dst->index, ds->index)) { in dsa_switch_parse_member_of()
1422 dev_err(ds->dev, in dsa_switch_parse_member_of()
1424 ds->index, ds->dst->index); in dsa_switch_parse_member_of()
1428 if (ds->dst->last_switch < ds->index) in dsa_switch_parse_member_of()
1429 ds->dst->last_switch = ds->index; in dsa_switch_parse_member_of()
1434 static int dsa_switch_touch_ports(struct dsa_switch *ds) in dsa_switch_touch_ports() argument
1439 for (port = 0; port < ds->num_ports; port++) { in dsa_switch_touch_ports()
1440 dp = dsa_port_touch(ds, port); in dsa_switch_touch_ports()
1448 static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn) in dsa_switch_parse_of() argument
1452 err = dsa_switch_parse_member_of(ds, dn); in dsa_switch_parse_of()
1456 err = dsa_switch_touch_ports(ds); in dsa_switch_parse_of()
1460 return dsa_switch_parse_ports_of(ds, dn); in dsa_switch_parse_of()
1484 static int dsa_switch_parse_ports(struct dsa_switch *ds, in dsa_switch_parse_ports() argument
1497 dp = dsa_to_port(ds, i); in dsa_switch_parse_ports()
1515 static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) in dsa_switch_parse() argument
1519 ds->cd = cd; in dsa_switch_parse()
1524 ds->index = 0; in dsa_switch_parse()
1525 ds->dst = dsa_tree_touch(0); in dsa_switch_parse()
1526 if (!ds->dst) in dsa_switch_parse()
1529 err = dsa_switch_touch_ports(ds); in dsa_switch_parse()
1533 return dsa_switch_parse_ports(ds, cd); in dsa_switch_parse()
1536 static void dsa_switch_release_ports(struct dsa_switch *ds) in dsa_switch_release_ports() argument
1538 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_release_ports()
1542 if (dp->ds != ds) in dsa_switch_release_ports()
1549 static int dsa_switch_probe(struct dsa_switch *ds) in dsa_switch_probe() argument
1556 if (!ds->dev) in dsa_switch_probe()
1559 pdata = ds->dev->platform_data; in dsa_switch_probe()
1560 np = ds->dev->of_node; in dsa_switch_probe()
1562 if (!ds->num_ports) in dsa_switch_probe()
1566 err = dsa_switch_parse_of(ds, np); in dsa_switch_probe()
1568 dsa_switch_release_ports(ds); in dsa_switch_probe()
1570 err = dsa_switch_parse(ds, pdata); in dsa_switch_probe()
1572 dsa_switch_release_ports(ds); in dsa_switch_probe()
1580 dst = ds->dst; in dsa_switch_probe()
1584 dsa_switch_release_ports(ds); in dsa_switch_probe()
1591 int dsa_register_switch(struct dsa_switch *ds) in dsa_register_switch() argument
1596 err = dsa_switch_probe(ds); in dsa_register_switch()
1597 dsa_tree_put(ds->dst); in dsa_register_switch()
1604 static void dsa_switch_remove(struct dsa_switch *ds) in dsa_switch_remove() argument
1606 struct dsa_switch_tree *dst = ds->dst; in dsa_switch_remove()
1609 dsa_switch_release_ports(ds); in dsa_switch_remove()
1613 void dsa_unregister_switch(struct dsa_switch *ds) in dsa_unregister_switch() argument
1616 dsa_switch_remove(ds); in dsa_unregister_switch()
1626 void dsa_switch_shutdown(struct dsa_switch *ds) in dsa_switch_shutdown() argument
1635 list_for_each_entry(dp, &ds->dst->ports, list) { in dsa_switch_shutdown()
1636 if (dp->ds != ds) in dsa_switch_shutdown()