Lines Matching refs:ds

288 	dev_dbg(dev->ds->dev, "VID: %d, members: 0x%04x, untag: 0x%04x\n",  in b53_set_vlan_entry()
540 void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port) in b53_imp_vlan_setup() argument
542 struct b53_device *dev = ds->priv; in b53_imp_vlan_setup()
654 static void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable) in b53_eee_enable_set() argument
656 struct b53_device *dev = ds->priv; in b53_eee_enable_set()
667 int b53_setup_port(struct dsa_switch *ds, int port) in b53_setup_port() argument
669 struct b53_device *dev = ds->priv; in b53_setup_port()
680 if (dsa_is_user_port(ds, port)) in b53_setup_port()
689 if (dsa_is_unused_port(ds, port)) in b53_setup_port()
700 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) in b53_enable_port() argument
702 struct b53_device *dev = ds->priv; in b53_enable_port()
707 if (!dsa_is_user_port(ds, port)) in b53_enable_port()
710 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_enable_port()
733 b53_imp_vlan_setup(ds, cpu_port); in b53_enable_port()
737 b53_eee_enable_set(ds, port, true); in b53_enable_port()
743 void b53_disable_port(struct dsa_switch *ds, int port) in b53_disable_port() argument
745 struct b53_device *dev = ds->priv; in b53_disable_port()
761 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port) in b53_brcm_hdr_setup() argument
763 struct b53_device *dev = ds->priv; in b53_brcm_hdr_setup()
852 b53_brcm_hdr_setup(dev->ds, port); in b53_enable_cpu_port()
878 static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port) in b53_vlan_port_needs_forced_tagged() argument
880 struct b53_device *dev = ds->priv; in b53_vlan_port_needs_forced_tagged()
882 return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port); in b53_vlan_port_needs_forced_tagged()
885 static bool b53_vlan_port_may_join_untagged(struct dsa_switch *ds, int port) in b53_vlan_port_may_join_untagged() argument
887 struct b53_device *dev = ds->priv; in b53_vlan_port_may_join_untagged()
893 dp = dsa_to_port(ds, port); in b53_vlan_port_may_join_untagged()
901 int b53_configure_vlan(struct dsa_switch *ds) in b53_configure_vlan() argument
903 struct b53_device *dev = ds->priv; in b53_configure_vlan()
929 if (!b53_vlan_port_may_join_untagged(ds, i)) in b53_configure_vlan()
933 if (!b53_vlan_port_needs_forced_tagged(ds, i)) in b53_configure_vlan()
955 if (!dsa_is_cpu_port(ds, i)) in b53_configure_vlan()
1043 static int b53_phy_read16(struct dsa_switch *ds, int addr, int reg) in b53_phy_read16() argument
1045 struct b53_device *priv = ds->priv; in b53_phy_read16()
1058 static int b53_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) in b53_phy_write16() argument
1060 struct b53_device *priv = ds->priv; in b53_phy_write16()
1084 b53_configure_vlan(priv->ds); in b53_apply_config()
1128 static struct phy_device *b53_get_phy_device(struct dsa_switch *ds, int port) in b53_get_phy_device() argument
1138 return mdiobus_get_phy(ds->user_mii_bus, port); in b53_get_phy_device()
1141 void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset, in b53_get_strings() argument
1144 struct b53_device *dev = ds->priv; in b53_get_strings()
1154 phydev = b53_get_phy_device(ds, port); in b53_get_strings()
1163 void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data) in b53_get_ethtool_stats() argument
1165 struct b53_device *dev = ds->priv; in b53_get_ethtool_stats()
1196 void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data) in b53_get_ethtool_phy_stats() argument
1200 phydev = b53_get_phy_device(ds, port); in b53_get_ethtool_phy_stats()
1208 int b53_get_sset_count(struct dsa_switch *ds, int port, int sset) in b53_get_sset_count() argument
1210 struct b53_device *dev = ds->priv; in b53_get_sset_count()
1216 phydev = b53_get_phy_device(ds, port); in b53_get_sset_count()
1247 int b53_setup_devlink_resources(struct dsa_switch *ds) in b53_setup_devlink_resources() argument
1250 struct b53_device *dev = ds->priv; in b53_setup_devlink_resources()
1257 err = dsa_devlink_resource_register(ds, "VLAN", dev->num_vlans, in b53_setup_devlink_resources()
1264 dsa_devlink_resource_occ_get_register(ds, in b53_setup_devlink_resources()
1270 dsa_devlink_resources_unregister(ds); in b53_setup_devlink_resources()
1275 static int b53_setup(struct dsa_switch *ds) in b53_setup() argument
1277 struct b53_device *dev = ds->priv; in b53_setup()
1286 ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE; in b53_setup()
1291 ds->untag_vlan_aware_bridge_pvid = true; in b53_setup()
1295 ds->ageing_time_min = 1 * 500; in b53_setup()
1296 ds->ageing_time_max = AGE_TIME_MAX * 500; in b53_setup()
1299 ds->ageing_time_min = 1 * 1000; in b53_setup()
1300 ds->ageing_time_max = AGE_TIME_MAX * 1000; in b53_setup()
1305 dev_err(ds->dev, "failed to reset switch\n"); in b53_setup()
1314 if (!b53_vlan_port_needs_forced_tagged(ds, port)) in b53_setup()
1322 dev_err(ds->dev, "failed to apply configuration\n"); in b53_setup()
1330 if (dsa_is_cpu_port(ds, port)) in b53_setup()
1333 b53_disable_port(ds, port); in b53_setup()
1336 return b53_setup_devlink_resources(ds); in b53_setup()
1339 static void b53_teardown(struct dsa_switch *ds) in b53_teardown() argument
1341 dsa_devlink_resources_unregister(ds); in b53_teardown()
1436 static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port, in b53_adjust_63xx_rgmii() argument
1439 struct b53_device *dev = ds->priv; in b53_adjust_63xx_rgmii()
1452 dev_dbg(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_63xx_rgmii()
1456 static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port, in b53_adjust_531x5_rgmii() argument
1459 struct b53_device *dev = ds->priv; in b53_adjust_531x5_rgmii()
1497 dev_info(ds->dev, "Configured port %d for %s\n", port, in b53_adjust_531x5_rgmii()
1501 static void b53_adjust_5325_mii(struct dsa_switch *ds, int port) in b53_adjust_5325_mii() argument
1503 struct b53_device *dev = ds->priv; in b53_adjust_5325_mii()
1517 dev_err(ds->dev, in b53_adjust_5325_mii()
1524 void b53_port_event(struct dsa_switch *ds, int port) in b53_port_event() argument
1526 struct b53_device *dev = ds->priv; in b53_port_event()
1532 dsa_port_phylink_mac_change(ds, port, link); in b53_port_event()
1536 static void b53_phylink_get_caps(struct dsa_switch *ds, int port, in b53_phylink_get_caps() argument
1539 struct b53_device *dev = ds->priv; in b53_phylink_get_caps()
1583 struct b53_device *dev = dp->ds->priv; in b53_phylink_mac_select_pcs()
1597 struct dsa_switch *ds = dp->ds; in b53_phylink_mac_config() local
1598 struct b53_device *dev = ds->priv; in b53_phylink_mac_config()
1602 b53_adjust_63xx_rgmii(ds, port, interface); in b53_phylink_mac_config()
1606 b53_adjust_531x5_rgmii(ds, port, interface); in b53_phylink_mac_config()
1610 b53_adjust_5325_mii(ds, port); in b53_phylink_mac_config()
1619 struct b53_device *dev = dp->ds->priv; in b53_phylink_mac_link_down()
1646 struct dsa_switch *ds = dp->ds; in b53_phylink_mac_link_up() local
1647 struct b53_device *dev = ds->priv; in b53_phylink_mac_link_up()
1653 p->eee_enabled = b53_eee_init(ds, port, phydev); in b53_phylink_mac_link_up()
1666 if (is5301x(dev) && dsa_is_cpu_port(ds, port)) in b53_phylink_mac_link_up()
1680 int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, in b53_vlan_filtering() argument
1683 struct b53_device *dev = ds->priv; in b53_vlan_filtering()
1694 static int b53_vlan_prepare(struct dsa_switch *ds, int port, in b53_vlan_prepare() argument
1697 struct b53_device *dev = ds->priv; in b53_vlan_prepare()
1715 int b53_vlan_add(struct dsa_switch *ds, int port, in b53_vlan_add() argument
1719 struct b53_device *dev = ds->priv; in b53_vlan_add()
1726 err = b53_vlan_prepare(ds, port, vlan); in b53_vlan_add()
1744 if (dsa_is_cpu_port(ds, port)) in b53_vlan_add()
1748 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) in b53_vlan_add()
1759 if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) { in b53_vlan_add()
1769 int b53_vlan_del(struct dsa_switch *ds, int port, in b53_vlan_del() argument
1772 struct b53_device *dev = ds->priv; in b53_vlan_del()
1790 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) in b53_vlan_del()
2028 int b53_fdb_add(struct dsa_switch *ds, int port, in b53_fdb_add() argument
2032 struct b53_device *priv = ds->priv; in b53_fdb_add()
2043 int b53_fdb_del(struct dsa_switch *ds, int port, in b53_fdb_del() argument
2047 struct b53_device *priv = ds->priv; in b53_fdb_del()
2181 int b53_fdb_dump(struct dsa_switch *ds, int port, in b53_fdb_dump() argument
2185 struct b53_device *priv = ds->priv; in b53_fdb_dump()
2225 int b53_mdb_add(struct dsa_switch *ds, int port, in b53_mdb_add() argument
2229 struct b53_device *priv = ds->priv; in b53_mdb_add()
2246 int b53_mdb_del(struct dsa_switch *ds, int port, in b53_mdb_del() argument
2250 struct b53_device *priv = ds->priv; in b53_mdb_del()
2257 dev_err(ds->dev, "failed to delete MDB entry\n"); in b53_mdb_del()
2263 int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, in b53_br_join() argument
2266 struct b53_device *dev = ds->priv; in b53_br_join()
2268 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_join()
2303 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) in b53_br_join()
2330 void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge) in b53_br_leave() argument
2332 struct b53_device *dev = ds->priv; in b53_br_leave()
2334 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; in b53_br_leave()
2342 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) in b53_br_leave()
2381 void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state) in b53_br_set_stp_state() argument
2383 struct b53_device *dev = ds->priv; in b53_br_set_stp_state()
2404 dev_err(ds->dev, "invalid STP state: %d\n", state); in b53_br_set_stp_state()
2415 void b53_br_fast_age(struct dsa_switch *ds, int port) in b53_br_fast_age() argument
2417 struct b53_device *dev = ds->priv; in b53_br_fast_age()
2420 dev_err(ds->dev, "fast ageing failed\n"); in b53_br_fast_age()
2424 int b53_br_flags_pre(struct dsa_switch *ds, int port, in b53_br_flags_pre() argument
2428 struct b53_device *dev = ds->priv; in b53_br_flags_pre()
2441 int b53_br_flags(struct dsa_switch *ds, int port, in b53_br_flags() argument
2446 b53_port_set_ucast_flood(ds->priv, port, in b53_br_flags()
2449 b53_port_set_mcast_flood(ds->priv, port, in b53_br_flags()
2452 b53_port_set_learning(ds->priv, port, in b53_br_flags()
2455 b53_port_set_isolated(ds->priv, port, in b53_br_flags()
2462 static bool b53_possible_cpu_port(struct dsa_switch *ds, int port) in b53_possible_cpu_port() argument
2477 static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port, in b53_can_enable_brcm_tags() argument
2480 bool ret = b53_possible_cpu_port(ds, port); in b53_can_enable_brcm_tags()
2483 dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", in b53_can_enable_brcm_tags()
2491 dev_warn(ds->dev, in b53_can_enable_brcm_tags()
2503 enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, in b53_get_tag_protocol() argument
2506 struct b53_device *dev = ds->priv; in b53_get_tag_protocol()
2508 if (!b53_can_enable_brcm_tags(ds, port, mprot)) { in b53_get_tag_protocol()
2536 int b53_mirror_add(struct dsa_switch *ds, int port, in b53_mirror_add() argument
2540 struct b53_device *dev = ds->priv; in b53_mirror_add()
2562 void b53_mirror_del(struct dsa_switch *ds, int port, in b53_mirror_del() argument
2565 struct b53_device *dev = ds->priv; in b53_mirror_del()
2603 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy) in b53_eee_init() argument
2607 if (!b53_support_eee(ds, port)) in b53_eee_init()
2614 b53_eee_enable_set(ds, port, true); in b53_eee_init()
2620 bool b53_support_eee(struct dsa_switch *ds, int port) in b53_support_eee() argument
2622 struct b53_device *dev = ds->priv; in b53_support_eee()
2628 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e) in b53_set_mac_eee() argument
2630 struct b53_device *dev = ds->priv; in b53_set_mac_eee()
2634 b53_eee_enable_set(ds, port, e->eee_enabled); in b53_set_mac_eee()
2640 static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu) in b53_change_mtu() argument
2642 struct b53_device *dev = ds->priv; in b53_change_mtu()
2649 if (!dsa_is_cpu_port(ds, port)) in b53_change_mtu()
2658 static int b53_get_max_mtu(struct dsa_switch *ds, int port) in b53_get_max_mtu() argument
2660 struct b53_device *dev = ds->priv; in b53_get_max_mtu()
2668 int b53_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) in b53_set_ageing_time() argument
2670 struct b53_device *dev = ds->priv; in b53_set_ageing_time()
3152 dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS); in b53_switch_init()
3157 if (!(dev->ds->phys_mii_mask & BIT(i)) && in b53_switch_init()
3158 !b53_possible_cpu_port(dev->ds, i)) in b53_switch_init()
3159 dev->ds->phys_mii_mask |= BIT(i); in b53_switch_init()
3190 struct dsa_switch *ds; in b53_switch_alloc() local
3193 ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL); in b53_switch_alloc()
3194 if (!ds) in b53_switch_alloc()
3197 ds->dev = base; in b53_switch_alloc()
3203 ds->priv = dev; in b53_switch_alloc()
3206 dev->ds = ds; in b53_switch_alloc()
3209 ds->ops = &b53_switch_ops; in b53_switch_alloc()
3210 ds->phylink_mac_ops = &b53_phylink_mac_ops; in b53_switch_alloc()
3218 ds->vlan_filtering_is_global = true; in b53_switch_alloc()
3257 val = b53_phy_read16(dev->ds, 0, MII_PHYSID1); in b53_switch_detect()
3259 val = b53_phy_read16(dev->ds, 0, MII_PHYSID2); in b53_switch_detect()
3330 return dsa_register_switch(dev->ds); in b53_switch_register()