Lines Matching refs:ds

288 	dev_dbg(dev->ds->dev, "VID: %d, members: 0x%04x, untag: 0x%04x\n",
540 void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port)
542 struct b53_device *dev = ds->priv;
635 static void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable)
637 struct b53_device *dev = ds->priv;
648 int b53_setup_port(struct dsa_switch *ds, int port)
650 struct b53_device *dev = ds->priv;
660 if (dsa_is_user_port(ds, port))
669 if (dsa_is_unused_port(ds, port))
680 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
682 struct b53_device *dev = ds->priv;
687 if (!dsa_is_user_port(ds, port))
690 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
713 b53_imp_vlan_setup(ds, cpu_port);
717 b53_eee_enable_set(ds, port, true);
723 void b53_disable_port(struct dsa_switch *ds, int port)
725 struct b53_device *dev = ds->priv;
741 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
743 struct b53_device *dev = ds->priv;
832 b53_brcm_hdr_setup(dev->ds, port);
861 static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
863 struct b53_device *dev = ds->priv;
865 return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
868 static bool b53_vlan_port_may_join_untagged(struct dsa_switch *ds, int port)
870 struct b53_device *dev = ds->priv;
876 dp = dsa_to_port(ds, port);
884 int b53_configure_vlan(struct dsa_switch *ds)
886 struct b53_device *dev = ds->priv;
912 if (!b53_vlan_port_may_join_untagged(ds, i))
916 if (!b53_vlan_port_needs_forced_tagged(ds, i))
938 if (!dsa_is_cpu_port(ds, i))
1026 static int b53_phy_read16(struct dsa_switch *ds, int addr, int reg)
1028 struct b53_device *priv = ds->priv;
1041 static int b53_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
1043 struct b53_device *priv = ds->priv;
1067 b53_configure_vlan(priv->ds);
1111 static struct phy_device *b53_get_phy_device(struct dsa_switch *ds, int port)
1121 return mdiobus_get_phy(ds->user_mii_bus, port);
1124 void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset,
1127 struct b53_device *dev = ds->priv;
1137 phydev = b53_get_phy_device(ds, port);
1146 void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data)
1148 struct b53_device *dev = ds->priv;
1179 void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data)
1183 phydev = b53_get_phy_device(ds, port);
1191 int b53_get_sset_count(struct dsa_switch *ds, int port, int sset)
1193 struct b53_device *dev = ds->priv;
1199 phydev = b53_get_phy_device(ds, port);
1230 int b53_setup_devlink_resources(struct dsa_switch *ds)
1233 struct b53_device *dev = ds->priv;
1240 err = dsa_devlink_resource_register(ds, "VLAN", dev->num_vlans,
1247 dsa_devlink_resource_occ_get_register(ds,
1253 dsa_devlink_resources_unregister(ds);
1258 static int b53_setup(struct dsa_switch *ds)
1260 struct b53_device *dev = ds->priv;
1269 ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE;
1274 ds->untag_vlan_aware_bridge_pvid = true;
1277 ds->ageing_time_min = 1 * 1000;
1278 ds->ageing_time_max = AGE_TIME_MAX * 1000;
1282 dev_err(ds->dev, "failed to reset switch\n");
1291 if (!b53_vlan_port_needs_forced_tagged(ds, port))
1299 dev_err(ds->dev, "failed to apply configuration\n");
1307 if (dsa_is_cpu_port(ds, port))
1310 b53_disable_port(ds, port);
1313 return b53_setup_devlink_resources(ds);
1316 static void b53_teardown(struct dsa_switch *ds)
1318 dsa_devlink_resources_unregister(ds);
1404 static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
1407 struct b53_device *dev = ds->priv;
1420 dev_dbg(ds->dev, "Configured port %d for %s\n", port,
1424 static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port,
1427 struct b53_device *dev = ds->priv;
1465 dev_info(ds->dev, "Configured port %d for %s\n", port,
1469 static void b53_adjust_5325_mii(struct dsa_switch *ds, int port)
1471 struct b53_device *dev = ds->priv;
1485 dev_err(ds->dev,
1492 void b53_port_event(struct dsa_switch *ds, int port)
1494 struct b53_device *dev = ds->priv;
1500 dsa_port_phylink_mac_change(ds, port, link);
1504 static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
1507 struct b53_device *dev = ds->priv;
1551 struct b53_device *dev = dp->ds->priv;
1565 struct dsa_switch *ds = dp->ds;
1566 struct b53_device *dev = ds->priv;
1570 b53_adjust_63xx_rgmii(ds, port, interface);
1574 b53_adjust_531x5_rgmii(ds, port, interface);
1578 b53_adjust_5325_mii(ds, port);
1587 struct b53_device *dev = dp->ds->priv;
1611 struct dsa_switch *ds = dp->ds;
1612 struct b53_device *dev = ds->priv;
1618 p->eee_enabled = b53_eee_init(ds, port, phydev);
1624 if (is5301x(dev) && dsa_is_cpu_port(ds, port))
1638 int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
1641 struct b53_device *dev = ds->priv;
1652 static int b53_vlan_prepare(struct dsa_switch *ds, int port,
1655 struct b53_device *dev = ds->priv;
1676 int b53_vlan_add(struct dsa_switch *ds, int port,
1680 struct b53_device *dev = ds->priv;
1687 err = b53_vlan_prepare(ds, port, vlan);
1705 if (dsa_is_cpu_port(ds, port))
1709 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
1720 if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) {
1730 int b53_vlan_del(struct dsa_switch *ds, int port,
1733 struct b53_device *dev = ds->priv;
1751 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port))
1972 int b53_fdb_add(struct dsa_switch *ds, int port,
1976 struct b53_device *priv = ds->priv;
1987 int b53_fdb_del(struct dsa_switch *ds, int port,
1991 struct b53_device *priv = ds->priv;
2062 int b53_fdb_dump(struct dsa_switch *ds, int port,
2065 struct b53_device *priv = ds->priv;
2111 int b53_mdb_add(struct dsa_switch *ds, int port,
2115 struct b53_device *priv = ds->priv;
2132 int b53_mdb_del(struct dsa_switch *ds, int port,
2136 struct b53_device *priv = ds->priv;
2143 dev_err(ds->dev, "failed to delete MDB entry\n");
2149 int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge,
2152 struct b53_device *dev = ds->priv;
2154 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
2189 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
2216 void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge)
2218 struct b53_device *dev = ds->priv;
2220 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
2228 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
2267 void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state)
2269 struct b53_device *dev = ds->priv;
2290 dev_err(ds->dev, "invalid STP state: %d\n", state);
2301 void b53_br_fast_age(struct dsa_switch *ds, int port)
2303 struct b53_device *dev = ds->priv;
2306 dev_err(ds->dev, "fast ageing failed\n");
2310 int b53_br_flags_pre(struct dsa_switch *ds, int port,
2314 struct b53_device *dev = ds->priv;
2327 int b53_br_flags(struct dsa_switch *ds, int port,
2332 b53_port_set_ucast_flood(ds->priv, port,
2335 b53_port_set_mcast_flood(ds->priv, port,
2338 b53_port_set_learning(ds->priv, port,
2345 static bool b53_possible_cpu_port(struct dsa_switch *ds, int port)
2360 static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port,
2363 bool ret = b53_possible_cpu_port(ds, port);
2366 dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n",
2374 dev_warn(ds->dev,
2386 enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port,
2389 struct b53_device *dev = ds->priv;
2391 if (!b53_can_enable_brcm_tags(ds, port, mprot)) {
2419 int b53_mirror_add(struct dsa_switch *ds, int port,
2423 struct b53_device *dev = ds->priv;
2445 void b53_mirror_del(struct dsa_switch *ds, int port,
2448 struct b53_device *dev = ds->priv;
2486 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy)
2490 if (!b53_support_eee(ds, port))
2497 b53_eee_enable_set(ds, port, true);
2503 bool b53_support_eee(struct dsa_switch *ds, int port)
2505 struct b53_device *dev = ds->priv;
2511 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
2513 struct b53_device *dev = ds->priv;
2517 b53_eee_enable_set(ds, port, e->eee_enabled);
2523 static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
2525 struct b53_device *dev = ds->priv;
2532 if (!dsa_is_cpu_port(ds, port))
2541 static int b53_get_max_mtu(struct dsa_switch *ds, int port)
2543 struct b53_device *dev = ds->priv;
2551 int b53_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
2553 struct b53_device *dev = ds->priv;
2984 dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS);
2989 if (!(dev->ds->phys_mii_mask & BIT(i)) &&
2990 !b53_possible_cpu_port(dev->ds, i))
2991 dev->ds->phys_mii_mask |= BIT(i);
3022 struct dsa_switch *ds;
3025 ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL);
3026 if (!ds)
3029 ds->dev = base;
3035 ds->priv = dev;
3038 dev->ds = ds;
3041 ds->ops = &b53_switch_ops;
3042 ds->phylink_mac_ops = &b53_phylink_mac_ops;
3050 ds->vlan_filtering_is_global = true;
3089 val = b53_phy_read16(dev->ds, 0, MII_PHYSID1);
3091 val = b53_phy_read16(dev->ds, 0, MII_PHYSID2);
3162 return dsa_register_switch(dev->ds);