Lines Matching full:ds
88 static int sja1105_drop_untagged(struct dsa_switch *ds, int port, bool drop) in sja1105_drop_untagged() argument
90 struct sja1105_private *priv = ds->priv; in sja1105_drop_untagged()
119 static int sja1105_commit_pvid(struct dsa_switch *ds, int port) in sja1105_commit_pvid() argument
121 struct dsa_port *dp = dsa_to_port(ds, port); in sja1105_commit_pvid()
123 struct sja1105_private *priv = ds->priv; in sja1105_commit_pvid()
154 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_commit_pvid()
157 return sja1105_drop_untagged(ds, port, drop_untagged); in sja1105_commit_pvid()
202 struct dsa_switch *ds = priv->ds; in sja1105_init_mac_settings() local
223 list_for_each_entry(dp, &ds->dst->ports, list) { in sja1105_init_mac_settings()
224 if (dp->ds != ds) in sja1105_init_mac_settings()
253 struct dsa_switch *ds = priv->ds; in sja1105_init_mii_settings() local
275 for (i = 0; i < ds->num_ports; i++) { in sja1105_init_mii_settings()
278 if (dsa_is_unused_port(priv->ds, i)) in sja1105_init_mii_settings()
379 for (port = 0; port < priv->ds->num_ports; port++) in sja1105_init_static_fdb()
380 if (!dsa_is_unused_port(priv->ds, port)) in sja1105_init_static_fdb()
416 struct dsa_switch *ds = priv->ds; in sja1105_init_l2_lookup_params() local
421 for (port = 0; port < ds->num_ports; port++) in sja1105_init_l2_lookup_params()
422 if (!dsa_is_unused_port(ds, port)) in sja1105_init_l2_lookup_params()
427 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_lookup_params()
428 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_lookup_params()
474 struct dsa_switch *ds = priv->ds; in sja1105_init_static_vlan() local
491 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_static_vlan()
492 if (dsa_is_unused_port(ds, port)) in sja1105_init_static_vlan()
499 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { in sja1105_init_static_vlan()
512 struct dsa_switch *ds = priv->ds; in sja1105_init_l2_forwarding() local
539 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_forwarding()
540 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_forwarding()
550 for (from = 0; from < ds->num_ports; from++) { in sja1105_init_l2_forwarding()
551 if (!dsa_is_user_port(ds, from)) in sja1105_init_l2_forwarding()
554 for (to = 0; to < ds->num_ports; to++) { in sja1105_init_l2_forwarding()
555 if (!dsa_is_cpu_port(ds, to) && in sja1105_init_l2_forwarding()
556 !dsa_is_dsa_port(ds, to)) in sja1105_init_l2_forwarding()
570 for (from = 0; from < ds->num_ports; from++) { in sja1105_init_l2_forwarding()
571 if (!dsa_is_cpu_port(ds, from) && !dsa_is_dsa_port(ds, from)) in sja1105_init_l2_forwarding()
574 for (to = 0; to < ds->num_ports; to++) { in sja1105_init_l2_forwarding()
575 if (dsa_is_unused_port(ds, to)) in sja1105_init_l2_forwarding()
596 dst = ds->dst; in sja1105_init_l2_forwarding()
599 if (dl->dp->ds != ds || dl->link_dp->cpu_dp == dl->dp->cpu_dp) in sja1105_init_l2_forwarding()
603 to = dsa_upstream_port(ds, from); in sja1105_init_l2_forwarding()
605 dev_warn(ds->dev, in sja1105_init_l2_forwarding()
618 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_forwarding()
619 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_forwarding()
630 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_forwarding()
631 if (dsa_is_unused_port(ds, port)) in sja1105_init_l2_forwarding()
634 l2fwd[ds->num_ports + tc].vlan_pmap[port] = tc; in sja1105_init_l2_forwarding()
637 l2fwd[ds->num_ports + tc].type_egrpcp2outputq = true; in sja1105_init_l2_forwarding()
646 struct dsa_switch *ds = priv->ds; in sja1110_init_pcp_remapping() local
671 for (port = 0; port < ds->num_ports; port++) { in sja1110_init_pcp_remapping()
672 if (dsa_is_unused_port(ds, port)) in sja1110_init_pcp_remapping()
795 struct dsa_switch *ds = priv->ds; in sja1105_init_topology() local
802 general_params->host_port = ds->num_ports; in sja1105_init_topology()
815 general_params->casc_port = ds->num_ports; in sja1105_init_topology()
817 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_topology()
818 bool is_upstream = dsa_is_upstream_port(ds, port); in sja1105_init_topology()
819 bool is_dsa_link = dsa_is_dsa_port(ds, port); in sja1105_init_topology()
825 if (general_params->host_port == ds->num_ports) { in sja1105_init_topology()
828 dev_err(ds->dev, in sja1105_init_topology()
839 } else if (general_params->casc_port == ds->num_ports) { in sja1105_init_topology()
842 dev_err(ds->dev, in sja1105_init_topology()
850 if (general_params->host_port == ds->num_ports) { in sja1105_init_topology()
851 dev_err(ds->dev, "No host port configured\n"); in sja1105_init_topology()
863 .switchid = priv->ds->index, in sja1105_init_general_params()
877 .mirr_port = priv->ds->num_ports, in sja1105_init_general_params()
1011 struct dsa_switch *ds = priv->ds; in sja1105_init_l2_policing() local
1033 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_policing()
1034 int mcast = (ds->num_ports * (SJA1105_NUM_TC + 1)) + port; in sja1105_init_l2_policing()
1035 int bcast = (ds->num_ports * SJA1105_NUM_TC) + port; in sja1105_init_l2_policing()
1047 for (port = 0; port < ds->num_ports; port++) { in sja1105_init_l2_policing()
1050 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_init_l2_policing()
1280 struct device *dev = priv->ds->dev; in sja1105_adjust_port_config()
1358 struct sja1105_private *priv = dp->ds->priv; in sja1105_mac_select_pcs()
1379 sja1105_inhibit_tx(dp->ds->priv, BIT(dp->index), true); in sja1105_mac_link_down()
1390 struct sja1105_private *priv = dp->ds->priv; in sja1105_mac_link_up()
1398 static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, in sja1105_phylink_get_caps() argument
1401 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()
1824 rc = priv->info->fdb_add_cmd(ds, port, addr, vid); in sja1105_fdb_add()
1830 static int __sja1105_fdb_del(struct dsa_switch *ds, int port, in __sja1105_fdb_del() argument
1834 struct sja1105_private *priv = ds->priv; in __sja1105_fdb_del()
1849 return priv->info->fdb_del_cmd(ds, port, addr, vid); in __sja1105_fdb_del()
1852 static int sja1105_fdb_del(struct dsa_switch *ds, int port, in sja1105_fdb_del() argument
1856 struct sja1105_private *priv = ds->priv; in sja1105_fdb_del()
1860 rc = __sja1105_fdb_del(ds, port, addr, vid, db); in sja1105_fdb_del()
1866 static int sja1105_fdb_dump(struct dsa_switch *ds, int port, in sja1105_fdb_dump() argument
1869 struct sja1105_private *priv = ds->priv; in sja1105_fdb_dump()
1870 struct device *dev = ds->dev; in sja1105_fdb_dump()
1915 static void sja1105_fast_age(struct dsa_switch *ds, int port) in sja1105_fast_age() argument
1917 struct dsa_port *dp = dsa_to_port(ds, port); in sja1105_fast_age()
1918 struct sja1105_private *priv = ds->priv; in sja1105_fast_age()
1941 dev_err(ds->dev, "Failed to read FDB: %pe\n", in sja1105_fast_age()
1955 rc = __sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, db); in sja1105_fast_age()
1957 dev_err(ds->dev, in sja1105_fast_age()
1967 static int sja1105_mdb_add(struct dsa_switch *ds, int port, in sja1105_mdb_add() argument
1971 return sja1105_fdb_add(ds, port, mdb->addr, mdb->vid, db); in sja1105_mdb_add()
1974 static int sja1105_mdb_del(struct dsa_switch *ds, int port, in sja1105_mdb_del() argument
1978 return sja1105_fdb_del(ds, port, mdb->addr, mdb->vid, db); in sja1105_mdb_del()
1990 struct dsa_switch *ds = priv->ds; in sja1105_manage_flood_domains() local
1995 for (from = 0; from < ds->num_ports; from++) { in sja1105_manage_flood_domains()
1998 for (to = 0; to < priv->ds->num_ports; to++) { in sja1105_manage_flood_domains()
2025 static int sja1105_bridge_member(struct dsa_switch *ds, int port, in sja1105_bridge_member() argument
2029 struct sja1105_private *priv = ds->priv; in sja1105_bridge_member()
2034 for (i = 0; i < ds->num_ports; i++) { in sja1105_bridge_member()
2038 if (!dsa_is_user_port(ds, i)) in sja1105_bridge_member()
2051 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) in sja1105_bridge_member()
2067 rc = sja1105_commit_pvid(ds, port); in sja1105_bridge_member()
2074 static void sja1105_bridge_stp_state_set(struct dsa_switch *ds, int port, in sja1105_bridge_stp_state_set() argument
2077 struct dsa_port *dp = dsa_to_port(ds, port); in sja1105_bridge_stp_state_set()
2078 struct sja1105_private *priv = ds->priv; in sja1105_bridge_stp_state_set()
2111 dev_err(ds->dev, "invalid STP state: %d\n", state); in sja1105_bridge_stp_state_set()
2119 static int sja1105_bridge_join(struct dsa_switch *ds, int port, in sja1105_bridge_join() argument
2126 rc = sja1105_bridge_member(ds, port, bridge, true); in sja1105_bridge_join()
2130 rc = dsa_tag_8021q_bridge_join(ds, port, bridge, tx_fwd_offload, in sja1105_bridge_join()
2133 sja1105_bridge_member(ds, port, bridge, false); in sja1105_bridge_join()
2140 static void sja1105_bridge_leave(struct dsa_switch *ds, int port, in sja1105_bridge_leave() argument
2143 dsa_tag_8021q_bridge_leave(ds, port, bridge); in sja1105_bridge_leave()
2144 sja1105_bridge_member(ds, port, bridge, false); in sja1105_bridge_leave()
2202 static int sja1105_setup_tc_cbs(struct dsa_switch *ds, int port, in sja1105_setup_tc_cbs() argument
2205 struct sja1105_private *priv = ds->priv; in sja1105_setup_tc_cbs()
2299 struct dsa_switch *ds = priv->ds; in sja1105_static_config_reload() local
2315 for (i = 0; i < ds->num_ports; i++) { in sja1105_static_config_reload()
2328 rc = __sja1105_ptp_gettimex(ds, &now, &ptp_sts_before); in sja1105_static_config_reload()
2341 rc = __sja1105_ptp_settime(ds, 0, &ptp_sts_after); in sja1105_static_config_reload()
2358 __sja1105_ptp_adjtime(ds, now); in sja1105_static_config_reload()
2362 dev_info(priv->ds->dev, in sja1105_static_config_reload()
2376 for (i = 0; i < ds->num_ports; i++) { in sja1105_static_config_reload()
2424 sja1105_get_tag_protocol(struct dsa_switch *ds, int port, in sja1105_get_tag_protocol() argument
2427 struct sja1105_private *priv = ds->priv; in sja1105_get_tag_protocol()
2436 int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, in sja1105_vlan_filtering() argument
2440 struct sja1105_private *priv = ds->priv; in sja1105_vlan_filtering()
2471 for (port = 0; port < ds->num_ports; port++) { in sja1105_vlan_filtering()
2472 if (dsa_is_unused_port(ds, port)) in sja1105_vlan_filtering()
2475 rc = sja1105_commit_pvid(ds, port); in sja1105_vlan_filtering()
2567 static int sja1105_bridge_vlan_add(struct dsa_switch *ds, int port, in sja1105_bridge_vlan_add() argument
2571 struct sja1105_private *priv = ds->priv; in sja1105_bridge_vlan_add()
2584 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_bridge_vlan_add()
2594 return sja1105_commit_pvid(ds, port); in sja1105_bridge_vlan_add()
2597 static int sja1105_bridge_vlan_del(struct dsa_switch *ds, int port, in sja1105_bridge_vlan_del() argument
2600 struct sja1105_private *priv = ds->priv; in sja1105_bridge_vlan_del()
2610 return sja1105_commit_pvid(ds, port); in sja1105_bridge_vlan_del()
2613 static int sja1105_dsa_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, in sja1105_dsa_8021q_vlan_add() argument
2616 struct sja1105_private *priv = ds->priv; in sja1105_dsa_8021q_vlan_add()
2623 if (dsa_is_user_port(ds, port)) in sja1105_dsa_8021q_vlan_add()
2633 return sja1105_commit_pvid(ds, port); in sja1105_dsa_8021q_vlan_add()
2636 static int sja1105_dsa_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) in sja1105_dsa_8021q_vlan_del() argument
2638 struct sja1105_private *priv = ds->priv; in sja1105_dsa_8021q_vlan_del()
2643 static int sja1105_prechangeupper(struct dsa_switch *ds, int port, in sja1105_prechangeupper() argument
2648 struct dsa_switch_tree *dst = ds->dst; in sja1105_prechangeupper()
2671 static int sja1105_mgmt_xmit(struct dsa_switch *ds, int port, int slot, in sja1105_mgmt_xmit() argument
2675 struct sja1105_private *priv = ds->priv; in sja1105_mgmt_xmit()
2696 dsa_enqueue_skb(skb, dsa_to_port(ds, port)->user); in sja1105_mgmt_xmit()
2703 dev_err_ratelimited(priv->ds->dev, in sja1105_mgmt_xmit()
2723 dev_err_ratelimited(priv->ds->dev, "xmit timed out\n"); in sja1105_mgmt_xmit()
2740 struct dsa_switch *ds = xmit_work->dp->ds; in sja1105_port_deferred_xmit() local
2741 struct sja1105_private *priv = ds->priv; in sja1105_port_deferred_xmit()
2748 sja1105_mgmt_xmit(ds, port, 0, skb, !!clone); in sja1105_port_deferred_xmit()
2752 sja1105_ptp_txtstamp_skb(ds, port, clone); in sja1105_port_deferred_xmit()
2759 static int sja1105_connect_tag_protocol(struct dsa_switch *ds, in sja1105_connect_tag_protocol() argument
2762 struct sja1105_private *priv = ds->priv; in sja1105_connect_tag_protocol()
2768 tagger_data = sja1105_tagger_data(ds); in sja1105_connect_tag_protocol()
2778 static int sja1105_set_ageing_time(struct dsa_switch *ds, in sja1105_set_ageing_time() argument
2782 struct sja1105_private *priv = ds->priv; in sja1105_set_ageing_time()
2799 static int sja1105_change_mtu(struct dsa_switch *ds, int port, int new_mtu) in sja1105_change_mtu() argument
2802 struct sja1105_private *priv = ds->priv; in sja1105_change_mtu()
2806 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) in sja1105_change_mtu()
2819 static int sja1105_get_max_mtu(struct dsa_switch *ds, int port) in sja1105_get_max_mtu() argument
2824 static int sja1105_port_setup_tc(struct dsa_switch *ds, int port, in sja1105_port_setup_tc() argument
2830 return sja1105_setup_tc_taprio(ds, port, type_data); in sja1105_port_setup_tc()
2832 return sja1105_setup_tc_cbs(ds, port, type_data); in sja1105_port_setup_tc()
2849 struct dsa_switch *ds = priv->ds; in sja1105_mirror_apply() local
2860 already_enabled = (general_params->mirr_port != ds->num_ports); in sja1105_mirror_apply()
2862 dev_err(priv->ds->dev, in sja1105_mirror_apply()
2874 for (port = 0; port < ds->num_ports; port++) { in sja1105_mirror_apply()
2882 new_mirr_port = ds->num_ports; in sja1105_mirror_apply()
2902 static int sja1105_mirror_add(struct dsa_switch *ds, int port, in sja1105_mirror_add() argument
2906 return sja1105_mirror_apply(ds->priv, port, mirror->to_local_port, in sja1105_mirror_add()
2910 static void sja1105_mirror_del(struct dsa_switch *ds, int port, in sja1105_mirror_del() argument
2913 sja1105_mirror_apply(ds->priv, port, mirror->to_local_port, in sja1105_mirror_del()
2917 static int sja1105_port_policer_add(struct dsa_switch *ds, int port, in sja1105_port_policer_add() argument
2921 struct sja1105_private *priv = ds->priv; in sja1105_port_policer_add()
2936 static void sja1105_port_policer_del(struct dsa_switch *ds, int port) in sja1105_port_policer_del() argument
2939 struct sja1105_private *priv = ds->priv; in sja1105_port_policer_del()
3021 static int sja1105_port_pre_bridge_flags(struct dsa_switch *ds, int port, in sja1105_port_pre_bridge_flags() argument
3025 struct sja1105_private *priv = ds->priv; in sja1105_port_pre_bridge_flags()
3046 static int sja1105_port_bridge_flags(struct dsa_switch *ds, int port, in sja1105_port_bridge_flags() argument
3050 struct sja1105_private *priv = ds->priv; in sja1105_port_bridge_flags()
3093 static int sja1105_setup(struct dsa_switch *ds) in sja1105_setup() argument
3095 struct sja1105_private *priv = ds->priv; in sja1105_setup()
3101 dev_err(ds->dev, in sja1105_setup()
3111 dev_err(ds->dev, "Failed to load static config: %d\n", rc); in sja1105_setup()
3119 dev_err(ds->dev, in sja1105_setup()
3126 sja1105_tas_setup(ds); in sja1105_setup()
3127 sja1105_flower_setup(ds); in sja1105_setup()
3129 rc = sja1105_ptp_clock_register(ds); in sja1105_setup()
3131 dev_err(ds->dev, "Failed to register PTP clock: %d\n", rc); in sja1105_setup()
3135 rc = sja1105_mdiobus_register(ds); in sja1105_setup()
3137 dev_err(ds->dev, "Failed to register MDIO bus: %pe\n", in sja1105_setup()
3142 rc = sja1105_devlink_setup(ds); in sja1105_setup()
3147 rc = dsa_tag_8021q_register(ds, htons(ETH_P_8021Q)); in sja1105_setup()
3160 ds->vlan_filtering_is_global = true; in sja1105_setup()
3161 ds->fdb_isolation = true; in sja1105_setup()
3162 ds->max_num_bridges = DSA_TAG_8021Q_MAX_NUM_BRIDGES; in sja1105_setup()
3165 ds->num_tx_queues = SJA1105_NUM_TC; in sja1105_setup()
3167 ds->mtu_enforcement_ingress = true; in sja1105_setup()
3168 ds->assisted_learning_on_cpu_port = true; in sja1105_setup()
3173 sja1105_devlink_teardown(ds); in sja1105_setup()
3175 sja1105_mdiobus_unregister(ds); in sja1105_setup()
3177 sja1105_ptp_clock_unregister(ds); in sja1105_setup()
3179 sja1105_flower_teardown(ds); in sja1105_setup()
3180 sja1105_tas_teardown(ds); in sja1105_setup()
3187 static void sja1105_teardown(struct dsa_switch *ds) in sja1105_teardown() argument
3189 struct sja1105_private *priv = ds->priv; in sja1105_teardown()
3192 dsa_tag_8021q_unregister(ds); in sja1105_teardown()
3195 sja1105_devlink_teardown(ds); in sja1105_teardown()
3196 sja1105_mdiobus_unregister(ds); in sja1105_teardown()
3197 sja1105_ptp_clock_unregister(ds); in sja1105_teardown()
3198 sja1105_flower_teardown(ds); in sja1105_teardown()
3199 sja1105_tas_teardown(ds); in sja1105_teardown()
3309 struct dsa_switch *ds; in sja1105_probe() local
3377 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); in sja1105_probe()
3378 if (!ds) in sja1105_probe()
3381 ds->dev = dev; in sja1105_probe()
3382 ds->num_ports = priv->info->num_ports; in sja1105_probe()
3383 ds->ops = &sja1105_switch_ops; in sja1105_probe()
3384 ds->phylink_mac_ops = &sja1105_phylink_mac_ops; in sja1105_probe()
3385 ds->priv = priv; in sja1105_probe()
3386 priv->ds = ds; in sja1105_probe()
3396 dev_err(ds->dev, "Failed to parse DT: %d\n", rc); in sja1105_probe()
3408 return dsa_register_switch(priv->ds); in sja1105_probe()
3418 dsa_unregister_switch(priv->ds); in sja1105_remove()
3428 dsa_switch_shutdown(priv->ds); in sja1105_shutdown()