Lines Matching full:ds

87 static int sja1105_drop_untagged(struct dsa_switch *ds, int port, bool drop)  in sja1105_drop_untagged()  argument
89 struct sja1105_private *priv = ds->priv; in sja1105_drop_untagged()
118 static int sja1105_commit_pvid(struct dsa_switch *ds, int port) in sja1105_commit_pvid() argument
120 struct dsa_port *dp = dsa_to_port(ds, port); in sja1105_commit_pvid()
122 struct sja1105_private *priv = ds->priv; in sja1105_commit_pvid()
153 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_commit_pvid()
156 return sja1105_drop_untagged(ds, port, drop_untagged); in sja1105_commit_pvid()
201 struct dsa_switch *ds = priv->ds; in sja1105_init_mac_settings() local
222 list_for_each_entry(dp, &ds->dst->ports, list) { in sja1105_init_mac_settings()
223 if (dp->ds != ds) in sja1105_init_mac_settings()
252 struct dsa_switch *ds = priv->ds; in sja1105_init_mii_settings() local
274 for (i = 0; i < ds->num_ports; i++) { in sja1105_init_mii_settings()
277 if (dsa_is_unused_port(priv->ds, i)) in sja1105_init_mii_settings()
378 for (port = 0; port < priv->ds->num_ports; port++) in sja1105_init_static_fdb()
379 if (!dsa_is_unused_port(priv->ds, port)) in sja1105_init_static_fdb()
415 struct dsa_switch *ds = priv->ds; in sja1105_init_l2_lookup_params() local
420 for (port = 0; port < ds->num_ports; port++) in sja1105_init_l2_lookup_params()
421 if (!dsa_is_unused_port(ds, port)) in sja1105_init_l2_lookup_params()
426 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_lookup_params()
427 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_lookup_params()
473 struct dsa_switch *ds = priv->ds; in sja1105_init_static_vlan() local
490 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_static_vlan()
491 if (dsa_is_unused_port(ds, port)) in sja1105_init_static_vlan()
498 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { in sja1105_init_static_vlan()
511 struct dsa_switch *ds = priv->ds; in sja1105_init_l2_forwarding() local
538 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_forwarding()
539 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_forwarding()
549 for (from = 0; from < ds->num_ports; from++) { in sja1105_init_l2_forwarding()
550 if (!dsa_is_user_port(ds, from)) in sja1105_init_l2_forwarding()
553 for (to = 0; to < ds->num_ports; to++) { in sja1105_init_l2_forwarding()
554 if (!dsa_is_cpu_port(ds, to) && in sja1105_init_l2_forwarding()
555 !dsa_is_dsa_port(ds, to)) in sja1105_init_l2_forwarding()
569 for (from = 0; from < ds->num_ports; from++) { in sja1105_init_l2_forwarding()
570 if (!dsa_is_cpu_port(ds, from) && !dsa_is_dsa_port(ds, from)) in sja1105_init_l2_forwarding()
573 for (to = 0; to < ds->num_ports; to++) { in sja1105_init_l2_forwarding()
574 if (dsa_is_unused_port(ds, to)) in sja1105_init_l2_forwarding()
595 dst = ds->dst; in sja1105_init_l2_forwarding()
598 if (dl->dp->ds != ds || dl->link_dp->cpu_dp == dl->dp->cpu_dp) in sja1105_init_l2_forwarding()
602 to = dsa_upstream_port(ds, from); in sja1105_init_l2_forwarding()
604 dev_warn(ds->dev, in sja1105_init_l2_forwarding()
617 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_forwarding()
618 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_forwarding()
629 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_forwarding()
630 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_forwarding()
633 l2fwd[ds->num_ports + tc].vlan_pmap[port] = tc; in sja1105_init_l2_forwarding()
636 l2fwd[ds->num_ports + tc].type_egrpcp2outputq = true; in sja1105_init_l2_forwarding()
645 struct dsa_switch *ds = priv->ds; in sja1110_init_pcp_remapping() local
670 for (port = 0; port < ds->num_ports; port++) { in sja1110_init_pcp_remapping()
671 if (dsa_is_unused_port(ds, port)) in sja1110_init_pcp_remapping()
794 struct dsa_switch *ds = priv->ds; in sja1105_init_topology() local
801 general_params->host_port = ds->num_ports; in sja1105_init_topology()
814 general_params->casc_port = ds->num_ports; in sja1105_init_topology()
816 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_topology()
817 bool is_upstream = dsa_is_upstream_port(ds, port); in sja1105_init_topology()
818 bool is_dsa_link = dsa_is_dsa_port(ds, port); in sja1105_init_topology()
824 if (general_params->host_port == ds->num_ports) { in sja1105_init_topology()
827 dev_err(ds->dev, in sja1105_init_topology()
838 } else if (general_params->casc_port == ds->num_ports) { in sja1105_init_topology()
841 dev_err(ds->dev, in sja1105_init_topology()
849 if (general_params->host_port == ds->num_ports) { in sja1105_init_topology()
850 dev_err(ds->dev, "No host port configured\n"); in sja1105_init_topology()
862 .switchid = priv->ds->index, in sja1105_init_general_params()
876 .mirr_port = priv->ds->num_ports, in sja1105_init_general_params()
1010 struct dsa_switch *ds = priv->ds; in sja1105_init_l2_policing() local
1032 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_policing()
1033 int mcast = (ds->num_ports * (SJA1105_NUM_TC + 1)) + port; in sja1105_init_l2_policing()
1034 int bcast = (ds->num_ports * SJA1105_NUM_TC) + port; in sja1105_init_l2_policing()
1046 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_policing()
1049 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_init_l2_policing()
1285 struct device *dev = priv->ds->dev; in sja1105_adjust_port_config()
1360 sja1105_mac_select_pcs(struct dsa_switch *ds, int port, phy_interface_t iface) in sja1105_mac_select_pcs() argument
1362 struct sja1105_private *priv = ds->priv; in sja1105_mac_select_pcs()
1371 static void sja1105_mac_link_down(struct dsa_switch *ds, int port, in sja1105_mac_link_down() argument
1375 sja1105_inhibit_tx(ds->priv, BIT(port), true); in sja1105_mac_link_down()
1378 static void sja1105_mac_link_up(struct dsa_switch *ds, int port, in sja1105_mac_link_up() argument
1385 struct sja1105_private *priv = ds->priv; in sja1105_mac_link_up()
1392 static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, in sja1105_phylink_get_caps() argument
1395 struct sja1105_private *priv = ds->priv; in sja1105_phylink_get_caps()
1555 int sja1105et_fdb_add(struct dsa_switch *ds, int port, in sja1105et_fdb_add() argument
1559 struct sja1105_private *priv = ds->priv; in sja1105et_fdb_add()
1560 struct device *dev = ds->dev; in sja1105et_fdb_add()
1640 int sja1105et_fdb_del(struct dsa_switch *ds, int port, in sja1105et_fdb_del() argument
1644 struct sja1105_private *priv = ds->priv; in sja1105et_fdb_del()
1675 int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port, in sja1105pqrs_fdb_add() argument
1679 struct sja1105_private *priv = ds->priv; in sja1105pqrs_fdb_add()
1720 dev_err(ds->dev, "FDB is full, cannot add entry.\n"); in sja1105pqrs_fdb_add()
1750 dev_err(ds->dev, in sja1105pqrs_fdb_add()
1766 int sja1105pqrs_fdb_del(struct dsa_switch *ds, int port, in sja1105pqrs_fdb_del() argument
1770 struct sja1105_private *priv = ds->priv; in sja1105pqrs_fdb_del()
1803 static int sja1105_fdb_add(struct dsa_switch *ds, int port, in sja1105_fdb_add() argument
1807 struct sja1105_private *priv = ds->priv; in sja1105_fdb_add()
1822 return priv->info->fdb_add_cmd(ds, port, addr, vid); in sja1105_fdb_add()
1825 static int sja1105_fdb_del(struct dsa_switch *ds, int port, in sja1105_fdb_del() argument
1829 struct sja1105_private *priv = ds->priv; in sja1105_fdb_del()
1844 return priv->info->fdb_del_cmd(ds, port, addr, vid); in sja1105_fdb_del()
1847 static int sja1105_fdb_dump(struct dsa_switch *ds, int port, in sja1105_fdb_dump() argument
1850 struct sja1105_private *priv = ds->priv; in sja1105_fdb_dump()
1851 struct device *dev = ds->dev; in sja1105_fdb_dump()
1895 static void sja1105_fast_age(struct dsa_switch *ds, int port) in sja1105_fast_age() argument
1897 struct dsa_port *dp = dsa_to_port(ds, port); in sja1105_fast_age()
1898 struct sja1105_private *priv = ds->priv; in sja1105_fast_age()
1919 dev_err(ds->dev, "Failed to read FDB: %pe\n", in sja1105_fast_age()
1933 rc = sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, db); in sja1105_fast_age()
1935 dev_err(ds->dev, in sja1105_fast_age()
1943 static int sja1105_mdb_add(struct dsa_switch *ds, int port, in sja1105_mdb_add() argument
1947 return sja1105_fdb_add(ds, port, mdb->addr, mdb->vid, db); in sja1105_mdb_add()
1950 static int sja1105_mdb_del(struct dsa_switch *ds, int port, in sja1105_mdb_del() argument
1954 return sja1105_fdb_del(ds, port, mdb->addr, mdb->vid, db); in sja1105_mdb_del()
1966 struct dsa_switch *ds = priv->ds; in sja1105_manage_flood_domains() local
1971 for (from = 0; from < ds->num_ports; from++) { in sja1105_manage_flood_domains()
1974 for (to = 0; to < priv->ds->num_ports; to++) { in sja1105_manage_flood_domains()
2001 static int sja1105_bridge_member(struct dsa_switch *ds, int port, in sja1105_bridge_member() argument
2005 struct sja1105_private *priv = ds->priv; in sja1105_bridge_member()
2010 for (i = 0; i < ds->num_ports; i++) { in sja1105_bridge_member()
2014 if (!dsa_is_user_port(ds, i)) in sja1105_bridge_member()
2027 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) in sja1105_bridge_member()
2043 rc = sja1105_commit_pvid(ds, port); in sja1105_bridge_member()
2050 static void sja1105_bridge_stp_state_set(struct dsa_switch *ds, int port, in sja1105_bridge_stp_state_set() argument
2053 struct dsa_port *dp = dsa_to_port(ds, port); in sja1105_bridge_stp_state_set()
2054 struct sja1105_private *priv = ds->priv; in sja1105_bridge_stp_state_set()
2087 dev_err(ds->dev, "invalid STP state: %d\n", state); in sja1105_bridge_stp_state_set()
2095 static int sja1105_bridge_join(struct dsa_switch *ds, int port, in sja1105_bridge_join() argument
2102 rc = sja1105_bridge_member(ds, port, bridge, true); in sja1105_bridge_join()
2106 rc = dsa_tag_8021q_bridge_join(ds, port, bridge); in sja1105_bridge_join()
2108 sja1105_bridge_member(ds, port, bridge, false); in sja1105_bridge_join()
2117 static void sja1105_bridge_leave(struct dsa_switch *ds, int port, in sja1105_bridge_leave() argument
2120 dsa_tag_8021q_bridge_leave(ds, port, bridge); in sja1105_bridge_leave()
2121 sja1105_bridge_member(ds, port, bridge, false); in sja1105_bridge_leave()
2155 static int sja1105_setup_tc_cbs(struct dsa_switch *ds, int port, in sja1105_setup_tc_cbs() argument
2158 struct sja1105_private *priv = ds->priv; in sja1105_setup_tc_cbs()
2239 struct dsa_switch *ds = priv->ds; in sja1105_static_config_reload() local
2254 for (i = 0; i < ds->num_ports; i++) { in sja1105_static_config_reload()
2267 rc = __sja1105_ptp_gettimex(ds, &now, &ptp_sts_before); in sja1105_static_config_reload()
2280 rc = __sja1105_ptp_settime(ds, 0, &ptp_sts_after); in sja1105_static_config_reload()
2297 __sja1105_ptp_adjtime(ds, now); in sja1105_static_config_reload()
2301 dev_info(priv->ds->dev, in sja1105_static_config_reload()
2315 for (i = 0; i < ds->num_ports; i++) { in sja1105_static_config_reload()
2364 sja1105_get_tag_protocol(struct dsa_switch *ds, int port, in sja1105_get_tag_protocol() argument
2367 struct sja1105_private *priv = ds->priv; in sja1105_get_tag_protocol()
2376 int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, in sja1105_vlan_filtering() argument
2380 struct sja1105_private *priv = ds->priv; in sja1105_vlan_filtering()
2416 for (port = 0; port < ds->num_ports; port++) { in sja1105_vlan_filtering()
2417 if (dsa_is_unused_port(ds, port)) in sja1105_vlan_filtering()
2420 rc = sja1105_commit_pvid(ds, port); in sja1105_vlan_filtering()
2512 static int sja1105_bridge_vlan_add(struct dsa_switch *ds, int port, in sja1105_bridge_vlan_add() argument
2516 struct sja1105_private *priv = ds->priv; in sja1105_bridge_vlan_add()
2529 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_bridge_vlan_add()
2539 return sja1105_commit_pvid(ds, port); in sja1105_bridge_vlan_add()
2542 static int sja1105_bridge_vlan_del(struct dsa_switch *ds, int port, in sja1105_bridge_vlan_del() argument
2545 struct sja1105_private *priv = ds->priv; in sja1105_bridge_vlan_del()
2555 return sja1105_commit_pvid(ds, port); in sja1105_bridge_vlan_del()
2558 static int sja1105_dsa_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, in sja1105_dsa_8021q_vlan_add() argument
2561 struct sja1105_private *priv = ds->priv; in sja1105_dsa_8021q_vlan_add()
2568 if (dsa_is_user_port(ds, port)) in sja1105_dsa_8021q_vlan_add()
2578 return sja1105_commit_pvid(ds, port); in sja1105_dsa_8021q_vlan_add()
2581 static int sja1105_dsa_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) in sja1105_dsa_8021q_vlan_del() argument
2583 struct sja1105_private *priv = ds->priv; in sja1105_dsa_8021q_vlan_del()
2588 static int sja1105_prechangeupper(struct dsa_switch *ds, int port, in sja1105_prechangeupper() argument
2593 struct dsa_switch_tree *dst = ds->dst; in sja1105_prechangeupper()
2616 static int sja1105_mgmt_xmit(struct dsa_switch *ds, int port, int slot, in sja1105_mgmt_xmit() argument
2620 struct sja1105_private *priv = ds->priv; in sja1105_mgmt_xmit()
2641 dsa_enqueue_skb(skb, dsa_to_port(ds, port)->slave); in sja1105_mgmt_xmit()
2648 dev_err_ratelimited(priv->ds->dev, in sja1105_mgmt_xmit()
2668 dev_err_ratelimited(priv->ds->dev, "xmit timed out\n"); in sja1105_mgmt_xmit()
2685 struct dsa_switch *ds = xmit_work->dp->ds; in sja1105_port_deferred_xmit() local
2686 struct sja1105_private *priv = ds->priv; in sja1105_port_deferred_xmit()
2693 sja1105_mgmt_xmit(ds, port, 0, skb, !!clone); in sja1105_port_deferred_xmit()
2697 sja1105_ptp_txtstamp_skb(ds, port, clone); in sja1105_port_deferred_xmit()
2704 static int sja1105_connect_tag_protocol(struct dsa_switch *ds, in sja1105_connect_tag_protocol() argument
2707 struct sja1105_private *priv = ds->priv; in sja1105_connect_tag_protocol()
2713 tagger_data = sja1105_tagger_data(ds); in sja1105_connect_tag_protocol()
2723 static int sja1105_set_ageing_time(struct dsa_switch *ds, in sja1105_set_ageing_time() argument
2727 struct sja1105_private *priv = ds->priv; in sja1105_set_ageing_time()
2744 static int sja1105_change_mtu(struct dsa_switch *ds, int port, int new_mtu) in sja1105_change_mtu() argument
2747 struct sja1105_private *priv = ds->priv; in sja1105_change_mtu()
2751 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_change_mtu()
2764 static int sja1105_get_max_mtu(struct dsa_switch *ds, int port) in sja1105_get_max_mtu() argument
2769 static int sja1105_port_setup_tc(struct dsa_switch *ds, int port, in sja1105_port_setup_tc() argument
2775 return sja1105_setup_tc_taprio(ds, port, type_data); in sja1105_port_setup_tc()
2777 return sja1105_setup_tc_cbs(ds, port, type_data); in sja1105_port_setup_tc()
2794 struct dsa_switch *ds = priv->ds; in sja1105_mirror_apply() local
2805 already_enabled = (general_params->mirr_port != ds->num_ports); in sja1105_mirror_apply()
2807 dev_err(priv->ds->dev, in sja1105_mirror_apply()
2819 for (port = 0; port < ds->num_ports; port++) { in sja1105_mirror_apply()
2827 new_mirr_port = ds->num_ports; in sja1105_mirror_apply()
2847 static int sja1105_mirror_add(struct dsa_switch *ds, int port, in sja1105_mirror_add() argument
2851 return sja1105_mirror_apply(ds->priv, port, mirror->to_local_port, in sja1105_mirror_add()
2855 static void sja1105_mirror_del(struct dsa_switch *ds, int port, in sja1105_mirror_del() argument
2858 sja1105_mirror_apply(ds->priv, port, mirror->to_local_port, in sja1105_mirror_del()
2862 static int sja1105_port_policer_add(struct dsa_switch *ds, int port, in sja1105_port_policer_add() argument
2866 struct sja1105_private *priv = ds->priv; in sja1105_port_policer_add()
2881 static void sja1105_port_policer_del(struct dsa_switch *ds, int port) in sja1105_port_policer_del() argument
2884 struct sja1105_private *priv = ds->priv; in sja1105_port_policer_del()
2960 static int sja1105_port_pre_bridge_flags(struct dsa_switch *ds, int port, in sja1105_port_pre_bridge_flags() argument
2964 struct sja1105_private *priv = ds->priv; in sja1105_port_pre_bridge_flags()
2985 static int sja1105_port_bridge_flags(struct dsa_switch *ds, int port, in sja1105_port_bridge_flags() argument
2989 struct sja1105_private *priv = ds->priv; in sja1105_port_bridge_flags()
3032 static int sja1105_setup(struct dsa_switch *ds) in sja1105_setup() argument
3034 struct sja1105_private *priv = ds->priv; in sja1105_setup()
3040 dev_err(ds->dev, in sja1105_setup()
3050 dev_err(ds->dev, "Failed to load static config: %d\n", rc); in sja1105_setup()
3058 dev_err(ds->dev, in sja1105_setup()
3065 sja1105_tas_setup(ds); in sja1105_setup()
3066 sja1105_flower_setup(ds); in sja1105_setup()
3068 rc = sja1105_ptp_clock_register(ds); in sja1105_setup()
3070 dev_err(ds->dev, "Failed to register PTP clock: %d\n", rc); in sja1105_setup()
3074 rc = sja1105_mdiobus_register(ds); in sja1105_setup()
3076 dev_err(ds->dev, "Failed to register MDIO bus: %pe\n", in sja1105_setup()
3081 rc = sja1105_devlink_setup(ds); in sja1105_setup()
3086 rc = dsa_tag_8021q_register(ds, htons(ETH_P_8021Q)); in sja1105_setup()
3099 ds->vlan_filtering_is_global = true; in sja1105_setup()
3100 ds->untag_bridge_pvid = true; in sja1105_setup()
3101 ds->fdb_isolation = true; in sja1105_setup()
3103 ds->max_num_bridges = 7; in sja1105_setup()
3106 ds->num_tx_queues = SJA1105_NUM_TC; in sja1105_setup()
3108 ds->mtu_enforcement_ingress = true; in sja1105_setup()
3109 ds->assisted_learning_on_cpu_port = true; in sja1105_setup()
3114 sja1105_devlink_teardown(ds); in sja1105_setup()
3116 sja1105_mdiobus_unregister(ds); in sja1105_setup()
3118 sja1105_ptp_clock_unregister(ds); in sja1105_setup()
3120 sja1105_flower_teardown(ds); in sja1105_setup()
3121 sja1105_tas_teardown(ds); in sja1105_setup()
3128 static void sja1105_teardown(struct dsa_switch *ds) in sja1105_teardown() argument
3130 struct sja1105_private *priv = ds->priv; in sja1105_teardown()
3133 dsa_tag_8021q_unregister(ds); in sja1105_teardown()
3136 sja1105_devlink_teardown(ds); in sja1105_teardown()
3137 sja1105_mdiobus_unregister(ds); in sja1105_teardown()
3138 sja1105_ptp_clock_unregister(ds); in sja1105_teardown()
3139 sja1105_flower_teardown(ds); in sja1105_teardown()
3140 sja1105_tas_teardown(ds); in sja1105_teardown()
3246 struct dsa_switch *ds; in sja1105_probe() local
3314 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); in sja1105_probe()
3315 if (!ds) in sja1105_probe()
3318 ds->dev = dev; in sja1105_probe()
3319 ds->num_ports = priv->info->num_ports; in sja1105_probe()
3320 ds->ops = &sja1105_switch_ops; in sja1105_probe()
3321 ds->priv = priv; in sja1105_probe()
3322 priv->ds = ds; in sja1105_probe()
3331 dev_err(ds->dev, "Failed to parse DT: %d\n", rc); in sja1105_probe()
3343 return dsa_register_switch(priv->ds); in sja1105_probe()
3353 dsa_unregister_switch(priv->ds); in sja1105_remove()
3363 dsa_switch_shutdown(priv->ds); in sja1105_shutdown()