Lines Matching refs:ds
286 dev_dbg(dev->ds->dev, "VID: %d, members: 0x%04x, untag: 0x%04x\n", in b53_set_vlan_entry()
524 void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port) in b53_imp_vlan_setup() argument
526 struct b53_device *dev = ds->priv; in b53_imp_vlan_setup()
588 static void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable) in b53_eee_enable_set() argument
590 struct b53_device *dev = ds->priv; in b53_eee_enable_set()
601 int b53_setup_port(struct dsa_switch *ds, int port) in b53_setup_port() argument
603 struct b53_device *dev = ds->priv; in b53_setup_port()
613 if (dsa_is_user_port(ds, port)) in b53_setup_port()
620 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) in b53_enable_port() argument
622 struct b53_device *dev = ds->priv; in b53_enable_port()
627 if (!dsa_is_user_port(ds, port)) in b53_enable_port()
630 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_enable_port()
650 b53_imp_vlan_setup(ds, cpu_port); in b53_enable_port()
654 b53_eee_enable_set(ds, port, true); in b53_enable_port()
660 void b53_disable_port(struct dsa_switch *ds, int port) in b53_disable_port() argument
662 struct b53_device *dev = ds->priv; in b53_disable_port()
675 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port) in b53_brcm_hdr_setup() argument
677 struct b53_device *dev = ds->priv; in b53_brcm_hdr_setup()
761 b53_brcm_hdr_setup(dev->ds, port); in b53_enable_cpu_port()
790 static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port) in b53_vlan_port_needs_forced_tagged() argument
792 struct b53_device *dev = ds->priv; in b53_vlan_port_needs_forced_tagged()
794 return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port); in b53_vlan_port_needs_forced_tagged()
797 static bool b53_vlan_port_may_join_untagged(struct dsa_switch *ds, int port) in b53_vlan_port_may_join_untagged() argument
799 struct b53_device *dev = ds->priv; in b53_vlan_port_may_join_untagged()
805 dp = dsa_to_port(ds, port); in b53_vlan_port_may_join_untagged()
813 int b53_configure_vlan(struct dsa_switch *ds) in b53_configure_vlan() argument
815 struct b53_device *dev = ds->priv; in b53_configure_vlan()
841 if (!b53_vlan_port_may_join_untagged(ds, i)) in b53_configure_vlan()
845 if (!b53_vlan_port_needs_forced_tagged(ds, i)) in b53_configure_vlan()
867 if (!dsa_is_cpu_port(ds, i)) in b53_configure_vlan()
955 static int b53_phy_read16(struct dsa_switch *ds, int addr, int reg) in b53_phy_read16() argument
957 struct b53_device *priv = ds->priv; in b53_phy_read16()
970 static int b53_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) in b53_phy_write16() argument
972 struct b53_device *priv = ds->priv; in b53_phy_write16()
996 b53_configure_vlan(priv->ds); in b53_apply_config()
1040 static struct phy_device *b53_get_phy_device(struct dsa_switch *ds, int port) in b53_get_phy_device() argument
1050 return mdiobus_get_phy(ds->user_mii_bus, port); in b53_get_phy_device()
1053 void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset, in b53_get_strings() argument
1056 struct b53_device *dev = ds->priv; in b53_get_strings()
1066 phydev = b53_get_phy_device(ds, port); in b53_get_strings()
1075 void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data) in b53_get_ethtool_stats() argument
1077 struct b53_device *dev = ds->priv; in b53_get_ethtool_stats()
1108 void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data) in b53_get_ethtool_phy_stats() argument
1112 phydev = b53_get_phy_device(ds, port); in b53_get_ethtool_phy_stats()
1120 int b53_get_sset_count(struct dsa_switch *ds, int port, int sset) in b53_get_sset_count() argument
1122 struct b53_device *dev = ds->priv; in b53_get_sset_count()
1128 phydev = b53_get_phy_device(ds, port); in b53_get_sset_count()
1159 int b53_setup_devlink_resources(struct dsa_switch *ds) in b53_setup_devlink_resources() argument
1162 struct b53_device *dev = ds->priv; in b53_setup_devlink_resources()
1169 err = dsa_devlink_resource_register(ds, "VLAN", dev->num_vlans, in b53_setup_devlink_resources()
1176 dsa_devlink_resource_occ_get_register(ds, in b53_setup_devlink_resources()
1182 dsa_devlink_resources_unregister(ds); in b53_setup_devlink_resources()
1187 static int b53_setup(struct dsa_switch *ds) in b53_setup() argument
1189 struct b53_device *dev = ds->priv; in b53_setup()
1198 ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE; in b53_setup()
1203 ds->untag_vlan_aware_bridge_pvid = true; in b53_setup()
1207 dev_err(ds->dev, "failed to reset switch\n"); in b53_setup()
1216 if (!b53_vlan_port_needs_forced_tagged(ds, port)) in b53_setup()
1224 dev_err(ds->dev, "failed to apply configuration\n"); in b53_setup()
1232 if (dsa_is_cpu_port(ds, port)) in b53_setup()
1235 b53_disable_port(ds, port); in b53_setup()
1238 return b53_setup_devlink_resources(ds); in b53_setup()
1241 static void b53_teardown(struct dsa_switch *ds) in b53_teardown() argument
1243 dsa_devlink_resources_unregister(ds); in b53_teardown()
1316 static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port, in b53_adjust_63xx_rgmii() argument
1319 struct b53_device *dev = ds->priv; in b53_adjust_63xx_rgmii()
1356 dev_dbg(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_63xx_rgmii()
1360 static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port, in b53_adjust_531x5_rgmii() argument
1363 struct b53_device *dev = ds->priv; in b53_adjust_531x5_rgmii()
1399 dev_info(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_531x5_rgmii()
1403 static void b53_adjust_5325_mii(struct dsa_switch *ds, int port) in b53_adjust_5325_mii() argument
1405 struct b53_device *dev = ds->priv; in b53_adjust_5325_mii()
1419 dev_err(ds->dev, in b53_adjust_5325_mii()
1426 void b53_port_event(struct dsa_switch *ds, int port) in b53_port_event() argument
1428 struct b53_device *dev = ds->priv; in b53_port_event()
1434 dsa_port_phylink_mac_change(ds, port, link); in b53_port_event()
1438 static void b53_phylink_get_caps(struct dsa_switch *ds, int port, in b53_phylink_get_caps() argument
1441 struct b53_device *dev = ds->priv; in b53_phylink_get_caps()
1481 struct b53_device *dev = dp->ds->priv; in b53_phylink_mac_select_pcs()
1495 struct dsa_switch *ds = dp->ds; in b53_phylink_mac_config() local
1496 struct b53_device *dev = ds->priv; in b53_phylink_mac_config()
1500 b53_adjust_63xx_rgmii(ds, port, interface); in b53_phylink_mac_config()
1504 b53_adjust_531x5_rgmii(ds, port, interface); in b53_phylink_mac_config()
1508 b53_adjust_5325_mii(ds, port); in b53_phylink_mac_config()
1517 struct b53_device *dev = dp->ds->priv; in b53_phylink_mac_link_down()
1541 struct dsa_switch *ds = dp->ds; in b53_phylink_mac_link_up() local
1542 struct b53_device *dev = ds->priv; in b53_phylink_mac_link_up()
1548 p->eee_enabled = b53_eee_init(ds, port, phydev); in b53_phylink_mac_link_up()
1554 if (is5301x(dev) && dsa_is_cpu_port(ds, port)) in b53_phylink_mac_link_up()
1568 int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, in b53_vlan_filtering() argument
1571 struct b53_device *dev = ds->priv; in b53_vlan_filtering()
1582 static int b53_vlan_prepare(struct dsa_switch *ds, int port, in b53_vlan_prepare() argument
1585 struct b53_device *dev = ds->priv; in b53_vlan_prepare()
1606 int b53_vlan_add(struct dsa_switch *ds, int port, in b53_vlan_add() argument
1610 struct b53_device *dev = ds->priv; in b53_vlan_add()
1617 err = b53_vlan_prepare(ds, port, vlan); in b53_vlan_add()
1635 if (dsa_is_cpu_port(ds, port)) in b53_vlan_add()
1639 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) in b53_vlan_add()
1650 if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) { in b53_vlan_add()
1660 int b53_vlan_del(struct dsa_switch *ds, int port, in b53_vlan_del() argument
1663 struct b53_device *dev = ds->priv; in b53_vlan_del()
1681 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) in b53_vlan_del()
1854 int b53_fdb_add(struct dsa_switch *ds, int port, in b53_fdb_add() argument
1858 struct b53_device *priv = ds->priv; in b53_fdb_add()
1875 int b53_fdb_del(struct dsa_switch *ds, int port, in b53_fdb_del() argument
1879 struct b53_device *priv = ds->priv; in b53_fdb_del()
1934 int b53_fdb_dump(struct dsa_switch *ds, int port, in b53_fdb_dump() argument
1937 struct b53_device *priv = ds->priv; in b53_fdb_dump()
1977 int b53_mdb_add(struct dsa_switch *ds, int port, in b53_mdb_add() argument
1981 struct b53_device *priv = ds->priv; in b53_mdb_add()
1998 int b53_mdb_del(struct dsa_switch *ds, int port, in b53_mdb_del() argument
2002 struct b53_device *priv = ds->priv; in b53_mdb_del()
2009 dev_err(ds->dev, "failed to delete MDB entry\n"); in b53_mdb_del()
2015 int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, in b53_br_join() argument
2018 struct b53_device *dev = ds->priv; in b53_br_join()
2020 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_join()
2058 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) in b53_br_join()
2085 void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge) in b53_br_leave() argument
2087 struct b53_device *dev = ds->priv; in b53_br_leave()
2089 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_leave()
2097 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) in b53_br_leave()
2137 void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state) in b53_br_set_stp_state() argument
2139 struct b53_device *dev = ds->priv; in b53_br_set_stp_state()
2160 dev_err(ds->dev, "invalid STP state: %d\n", state); in b53_br_set_stp_state()
2171 void b53_br_fast_age(struct dsa_switch *ds, int port) in b53_br_fast_age() argument
2173 struct b53_device *dev = ds->priv; in b53_br_fast_age()
2176 dev_err(ds->dev, "fast ageing failed\n"); in b53_br_fast_age()
2180 int b53_br_flags_pre(struct dsa_switch *ds, int port, in b53_br_flags_pre() argument
2191 int b53_br_flags(struct dsa_switch *ds, int port, in b53_br_flags() argument
2196 b53_port_set_ucast_flood(ds->priv, port, in b53_br_flags()
2199 b53_port_set_mcast_flood(ds->priv, port, in b53_br_flags()
2202 b53_port_set_learning(ds->priv, port, in b53_br_flags()
2209 static bool b53_possible_cpu_port(struct dsa_switch *ds, int port) in b53_possible_cpu_port() argument
2224 static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port, in b53_can_enable_brcm_tags() argument
2227 bool ret = b53_possible_cpu_port(ds, port); in b53_can_enable_brcm_tags()
2230 dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", in b53_can_enable_brcm_tags()
2238 dev_warn(ds->dev, in b53_can_enable_brcm_tags()
2250 enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, in b53_get_tag_protocol() argument
2253 struct b53_device *dev = ds->priv; in b53_get_tag_protocol()
2255 if (!b53_can_enable_brcm_tags(ds, port, mprot)) { in b53_get_tag_protocol()
2280 int b53_mirror_add(struct dsa_switch *ds, int port, in b53_mirror_add() argument
2284 struct b53_device *dev = ds->priv; in b53_mirror_add()
2306 void b53_mirror_del(struct dsa_switch *ds, int port, in b53_mirror_del() argument
2309 struct b53_device *dev = ds->priv; in b53_mirror_del()
2347 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy) in b53_eee_init() argument
2355 b53_eee_enable_set(ds, port, true); in b53_eee_init()
2361 bool b53_support_eee(struct dsa_switch *ds, int port) in b53_support_eee() argument
2363 struct b53_device *dev = ds->priv; in b53_support_eee()
2369 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e) in b53_set_mac_eee() argument
2371 struct b53_device *dev = ds->priv; in b53_set_mac_eee()
2375 b53_eee_enable_set(ds, port, e->eee_enabled); in b53_set_mac_eee()
2381 static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu) in b53_change_mtu() argument
2383 struct b53_device *dev = ds->priv; in b53_change_mtu()
2390 if (!dsa_is_cpu_port(ds, port)) in b53_change_mtu()
2399 static int b53_get_max_mtu(struct dsa_switch *ds, int port) in b53_get_max_mtu() argument
2401 struct b53_device *dev = ds->priv; in b53_get_max_mtu()
2825 dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS); in b53_switch_init()
2830 if (!(dev->ds->phys_mii_mask & BIT(i)) && in b53_switch_init()
2831 !b53_possible_cpu_port(dev->ds, i)) in b53_switch_init()
2832 dev->ds->phys_mii_mask |= BIT(i); in b53_switch_init()
2863 struct dsa_switch *ds; in b53_switch_alloc() local
2866 ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL); in b53_switch_alloc()
2867 if (!ds) in b53_switch_alloc()
2870 ds->dev = base; in b53_switch_alloc()
2876 ds->priv = dev; in b53_switch_alloc()
2879 dev->ds = ds; in b53_switch_alloc()
2882 ds->ops = &b53_switch_ops; in b53_switch_alloc()
2883 ds->phylink_mac_ops = &b53_phylink_mac_ops; in b53_switch_alloc()
2891 ds->vlan_filtering_is_global = true; in b53_switch_alloc()
2989 return dsa_register_switch(dev->ds); in b53_switch_register()