Lines Matching refs:ds

45 static int felix_cpu_port_for_conduit(struct dsa_switch *ds,
48 struct ocelot *ocelot = ds->priv;
67 static int felix_tag_8021q_vlan_add_rx(struct dsa_switch *ds, int port,
71 struct ocelot *ocelot = ds->priv;
107 static int felix_tag_8021q_vlan_del_rx(struct dsa_switch *ds, int port,
112 struct ocelot *ocelot = ds->priv;
129 static int felix_tag_8021q_vlan_add_tx(struct dsa_switch *ds, int port,
133 unsigned long cpu_ports = dsa_cpu_ports(ds);
134 struct ocelot *ocelot = ds->priv;
196 static int felix_tag_8021q_vlan_del_tx(struct dsa_switch *ds, int port, u16 vid)
201 struct ocelot *ocelot = ds->priv;
227 static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid,
237 if (!dsa_is_user_port(ds, port))
240 dsa_switch_for_each_cpu_port(cpu_dp, ds) {
241 err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid);
246 err = felix_tag_8021q_vlan_add_tx(ds, port, vid);
253 dsa_switch_for_each_cpu_port(cpu_dp, ds)
254 felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid);
259 static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid)
264 if (!dsa_is_user_port(ds, port))
267 dsa_switch_for_each_cpu_port(cpu_dp, ds) {
268 err = felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid);
273 err = felix_tag_8021q_vlan_del_tx(ds, port, vid);
280 dsa_switch_for_each_cpu_port(cpu_dp, ds)
281 felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid);
286 static int felix_trap_get_cpu_port(struct dsa_switch *ds,
296 dp = dsa_to_port(ds, first_port);
305 static int felix_update_trapping_destinations(struct dsa_switch *ds,
308 struct ocelot *ocelot = ds->priv;
337 port_mask = BIT(felix_trap_get_cpu_port(ds, trap));
408 static int felix_tag_npi_setup(struct dsa_switch *ds)
411 struct ocelot *ocelot = ds->priv;
413 dsa_switch_for_each_user_port(dp, ds) {
415 dev_err(ds->dev, "Multiple NPI ports not supported\n");
430 static void felix_tag_npi_teardown(struct dsa_switch *ds)
432 struct ocelot *ocelot = ds->priv;
437 static unsigned long felix_tag_npi_get_host_fwd_mask(struct dsa_switch *ds)
439 struct ocelot *ocelot = ds->priv;
444 static int felix_tag_npi_change_conduit(struct dsa_switch *ds, int port,
448 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
449 struct ocelot *ocelot = ds->priv;
461 dsa_switch_for_each_user_port(other_dp, ds) {
473 felix_npi_port_init(ocelot, felix_cpu_port_for_conduit(ds, conduit));
492 static int felix_tag_8021q_setup(struct dsa_switch *ds)
494 struct ocelot *ocelot = ds->priv;
498 err = dsa_tag_8021q_register(ds, htons(ETH_P_8021AD));
502 dsa_switch_for_each_cpu_port(dp, ds)
505 dsa_switch_for_each_user_port(dp, ds)
509 dsa_switch_for_each_available_port(dp, ds)
536 static void felix_tag_8021q_teardown(struct dsa_switch *ds)
538 struct ocelot *ocelot = ds->priv;
541 dsa_switch_for_each_available_port(dp, ds)
550 dsa_switch_for_each_user_port(dp, ds)
553 dsa_switch_for_each_cpu_port(dp, ds)
556 dsa_tag_8021q_unregister(ds);
559 static unsigned long felix_tag_8021q_get_host_fwd_mask(struct dsa_switch *ds)
561 return dsa_cpu_ports(ds);
564 static int felix_tag_8021q_change_conduit(struct dsa_switch *ds, int port,
568 int cpu = felix_cpu_port_for_conduit(ds, conduit);
569 struct ocelot *ocelot = ds->priv;
574 return felix_update_trapping_destinations(ds, true);
584 static void felix_set_host_flood(struct dsa_switch *ds, unsigned long mask,
587 struct ocelot *ocelot = ds->priv;
603 felix_migrate_host_flood(struct dsa_switch *ds,
607 struct ocelot *ocelot = ds->priv;
612 mask = old_proto_ops->get_host_fwd_mask(ds);
613 felix_set_host_flood(ds, mask, false, false, false);
616 mask = proto_ops->get_host_fwd_mask(ds);
617 felix_set_host_flood(ds, mask, !!felix->host_flood_uc_mask,
621 static int felix_migrate_mdbs(struct dsa_switch *ds,
625 struct ocelot *ocelot = ds->priv;
631 from = old_proto_ops->get_host_fwd_mask(ds);
632 to = proto_ops->get_host_fwd_mask(ds);
643 felix_tag_proto_setup_shared(struct dsa_switch *ds,
650 err = felix_migrate_mdbs(ds, proto_ops, old_proto_ops);
654 felix_update_trapping_destinations(ds, using_tag_8021q);
656 felix_migrate_host_flood(ds, proto_ops, old_proto_ops);
665 static int felix_change_tag_protocol(struct dsa_switch *ds,
669 struct ocelot *ocelot = ds->priv;
690 err = proto_ops->setup(ds);
694 err = felix_tag_proto_setup_shared(ds, proto_ops, old_proto_ops);
699 old_proto_ops->teardown(ds);
707 proto_ops->teardown(ds);
712 static enum dsa_tag_protocol felix_get_tag_protocol(struct dsa_switch *ds,
716 struct ocelot *ocelot = ds->priv;
722 static void felix_port_set_host_flood(struct dsa_switch *ds, int port,
725 struct ocelot *ocelot = ds->priv;
739 mask = felix->tag_proto_ops->get_host_fwd_mask(ds);
740 felix_set_host_flood(ds, mask, !!felix->host_flood_uc_mask,
744 static int felix_port_change_conduit(struct dsa_switch *ds, int port,
748 struct ocelot *ocelot = ds->priv;
751 return felix->tag_proto_ops->change_conduit(ds, port, conduit, extack);
754 static int felix_set_ageing_time(struct dsa_switch *ds,
757 struct ocelot *ocelot = ds->priv;
764 static void felix_port_fast_age(struct dsa_switch *ds, int port)
766 struct ocelot *ocelot = ds->priv;
771 dev_err(ds->dev, "Flushing MAC table on port %d returned %pe\n",
775 static int felix_fdb_dump(struct dsa_switch *ds, int port,
778 struct ocelot *ocelot = ds->priv;
783 static int felix_fdb_add(struct dsa_switch *ds, int port,
788 struct dsa_port *dp = dsa_to_port(ds, port);
789 struct ocelot *ocelot = ds->priv;
795 dsa_fdb_present_in_other_db(ds, port, addr, vid, db))
804 static int felix_fdb_del(struct dsa_switch *ds, int port,
809 struct dsa_port *dp = dsa_to_port(ds, port);
810 struct ocelot *ocelot = ds->priv;
816 dsa_fdb_present_in_other_db(ds, port, addr, vid, db))
825 static int felix_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag lag,
830 struct ocelot *ocelot = ds->priv;
838 static int felix_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag lag,
843 struct ocelot *ocelot = ds->priv;
851 static int felix_mdb_add(struct dsa_switch *ds, int port,
856 struct ocelot *ocelot = ds->priv;
861 if (dsa_is_cpu_port(ds, port) && !bridge_dev &&
862 dsa_mdb_present_in_other_db(ds, port, mdb, db))
871 static int felix_mdb_del(struct dsa_switch *ds, int port,
876 struct ocelot *ocelot = ds->priv;
881 if (dsa_is_cpu_port(ds, port) && !bridge_dev &&
882 dsa_mdb_present_in_other_db(ds, port, mdb, db))
891 static void felix_bridge_stp_state_set(struct dsa_switch *ds, int port,
894 struct ocelot *ocelot = ds->priv;
899 static int felix_pre_bridge_flags(struct dsa_switch *ds, int port,
903 struct ocelot *ocelot = ds->priv;
908 static int felix_bridge_flags(struct dsa_switch *ds, int port,
912 struct ocelot *ocelot = ds->priv;
922 static int felix_bridge_join(struct dsa_switch *ds, int port,
926 struct ocelot *ocelot = ds->priv;
932 static void felix_bridge_leave(struct dsa_switch *ds, int port,
935 struct ocelot *ocelot = ds->priv;
940 static int felix_lag_join(struct dsa_switch *ds, int port,
945 struct ocelot *ocelot = ds->priv;
953 if (!dsa_is_cpu_port(ds, port))
956 return felix_port_change_conduit(ds, port, lag.dev, extack);
959 static int felix_lag_leave(struct dsa_switch *ds, int port,
962 struct ocelot *ocelot = ds->priv;
967 if (!dsa_is_cpu_port(ds, port))
970 return felix_port_change_conduit(ds, port, lag.dev, NULL);
973 static int felix_lag_change(struct dsa_switch *ds, int port)
975 struct dsa_port *dp = dsa_to_port(ds, port);
976 struct ocelot *ocelot = ds->priv;
983 static int felix_vlan_prepare(struct dsa_switch *ds, int port,
987 struct ocelot *ocelot = ds->priv;
1007 static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
1010 struct ocelot *ocelot = ds->priv;
1015 static int felix_vlan_add(struct dsa_switch *ds, int port,
1019 struct ocelot *ocelot = ds->priv;
1023 err = felix_vlan_prepare(ds, port, vlan, extack);
1032 static int felix_vlan_del(struct dsa_switch *ds, int port,
1035 struct ocelot *ocelot = ds->priv;
1040 static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
1043 struct ocelot *ocelot = ds->priv;
1053 static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
1057 struct ocelot *ocelot = ds->priv;
1064 static struct phylink_pcs *felix_phylink_mac_select_pcs(struct dsa_switch *ds,
1068 struct ocelot *ocelot = ds->priv;
1078 static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
1082 struct ocelot *ocelot = ds->priv;
1091 static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
1098 struct ocelot *ocelot = ds->priv;
1109 static int felix_port_enable(struct dsa_switch *ds, int port,
1112 struct dsa_port *dp = dsa_to_port(ds, port);
1113 struct ocelot *ocelot = ds->priv;
1121 if (felix_cpu_port_for_conduit(ds, conduit) != ocelot->npi) {
1122 dev_err(ds->dev, "Multiple conduits are not allowed\n");
1151 static void felix_get_stats64(struct dsa_switch *ds, int port,
1154 struct ocelot *ocelot = ds->priv;
1159 static void felix_get_pause_stats(struct dsa_switch *ds, int port,
1162 struct ocelot *ocelot = ds->priv;
1167 static void felix_get_rmon_stats(struct dsa_switch *ds, int port,
1171 struct ocelot *ocelot = ds->priv;
1176 static void felix_get_eth_ctrl_stats(struct dsa_switch *ds, int port,
1179 struct ocelot *ocelot = ds->priv;
1184 static void felix_get_eth_mac_stats(struct dsa_switch *ds, int port,
1187 struct ocelot *ocelot = ds->priv;
1192 static void felix_get_eth_phy_stats(struct dsa_switch *ds, int port,
1195 struct ocelot *ocelot = ds->priv;
1200 static void felix_get_strings(struct dsa_switch *ds, int port,
1203 struct ocelot *ocelot = ds->priv;
1208 static void felix_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data)
1210 struct ocelot *ocelot = ds->priv;
1215 static int felix_get_sset_count(struct dsa_switch *ds, int port, int sset)
1217 struct ocelot *ocelot = ds->priv;
1222 static int felix_get_ts_info(struct dsa_switch *ds, int port,
1225 struct ocelot *ocelot = ds->priv;
1394 ocelot->devlink = felix->ds->devlink;
1500 struct dsa_switch *ds = xmit_work->dp->ds;
1503 struct ocelot *ocelot = ds->priv;
1528 static int felix_connect_tag_protocol(struct dsa_switch *ds,
1535 tagger_data = ocelot_8021q_tagger_data(ds);
1546 static int felix_setup(struct dsa_switch *ds)
1548 struct ocelot *ocelot = ds->priv;
1553 err = felix_init_structs(felix, ds->num_ports);
1573 dsa_switch_for_each_available_port(dp, ds) {
1593 felix_change_tag_protocol(ds, felix->tag_proto);
1595 ds->mtu_enforcement_ingress = true;
1596 ds->assisted_learning_on_cpu_port = true;
1597 ds->fdb_isolation = true;
1598 ds->max_num_bridges = ds->num_ports;
1603 dsa_switch_for_each_available_port(dp, ds)
1616 static void felix_teardown(struct dsa_switch *ds)
1618 struct ocelot *ocelot = ds->priv;
1624 felix->tag_proto_ops->teardown(ds);
1627 dsa_switch_for_each_available_port(dp, ds)
1638 static int felix_hwtstamp_get(struct dsa_switch *ds, int port,
1641 struct ocelot *ocelot = ds->priv;
1646 static int felix_hwtstamp_set(struct dsa_switch *ds, int port,
1649 struct ocelot *ocelot = ds->priv;
1660 return felix_update_trapping_destinations(ds, using_tag_8021q);
1713 static bool felix_rxtstamp(struct dsa_switch *ds, int port,
1718 struct ocelot *ocelot = ds->priv;
1760 static void felix_txtstamp(struct dsa_switch *ds, int port,
1763 struct ocelot *ocelot = ds->priv;
1770 dev_err_ratelimited(ds->dev,
1780 static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
1782 struct ocelot *ocelot = ds->priv;
1797 static int felix_get_max_mtu(struct dsa_switch *ds, int port)
1799 struct ocelot *ocelot = ds->priv;
1804 static int felix_cls_flower_add(struct dsa_switch *ds, int port,
1807 struct ocelot *ocelot = ds->priv;
1818 return felix_update_trapping_destinations(ds, using_tag_8021q);
1821 static int felix_cls_flower_del(struct dsa_switch *ds, int port,
1824 struct ocelot *ocelot = ds->priv;
1829 static int felix_cls_flower_stats(struct dsa_switch *ds, int port,
1832 struct ocelot *ocelot = ds->priv;
1837 static int felix_port_policer_add(struct dsa_switch *ds, int port,
1840 struct ocelot *ocelot = ds->priv;
1849 static void felix_port_policer_del(struct dsa_switch *ds, int port)
1851 struct ocelot *ocelot = ds->priv;
1856 static int felix_port_mirror_add(struct dsa_switch *ds, int port,
1860 struct ocelot *ocelot = ds->priv;
1866 static void felix_port_mirror_del(struct dsa_switch *ds, int port,
1869 struct ocelot *ocelot = ds->priv;
1874 static int felix_port_setup_tc(struct dsa_switch *ds, int port,
1878 struct ocelot *ocelot = ds->priv;
1882 return felix->info->port_setup_tc(ds, port, type, type_data);
1887 static int felix_sb_pool_get(struct dsa_switch *ds, unsigned int sb_index,
1891 struct ocelot *ocelot = ds->priv;
1896 static int felix_sb_pool_set(struct dsa_switch *ds, unsigned int sb_index,
1901 struct ocelot *ocelot = ds->priv;
1907 static int felix_sb_port_pool_get(struct dsa_switch *ds, int port,
1911 struct ocelot *ocelot = ds->priv;
1917 static int felix_sb_port_pool_set(struct dsa_switch *ds, int port,
1921 struct ocelot *ocelot = ds->priv;
1927 static int felix_sb_tc_pool_bind_get(struct dsa_switch *ds, int port,
1932 struct ocelot *ocelot = ds->priv;
1939 static int felix_sb_tc_pool_bind_set(struct dsa_switch *ds, int port,
1945 struct ocelot *ocelot = ds->priv;
1952 static int felix_sb_occ_snapshot(struct dsa_switch *ds,
1955 struct ocelot *ocelot = ds->priv;
1960 static int felix_sb_occ_max_clear(struct dsa_switch *ds,
1963 struct ocelot *ocelot = ds->priv;
1968 static int felix_sb_occ_port_pool_get(struct dsa_switch *ds, int port,
1972 struct ocelot *ocelot = ds->priv;
1978 static int felix_sb_occ_tc_port_bind_get(struct dsa_switch *ds, int port,
1983 struct ocelot *ocelot = ds->priv;
1989 static int felix_mrp_add(struct dsa_switch *ds, int port,
1992 struct ocelot *ocelot = ds->priv;
1997 static int felix_mrp_del(struct dsa_switch *ds, int port,
2000 struct ocelot *ocelot = ds->priv;
2006 felix_mrp_add_ring_role(struct dsa_switch *ds, int port,
2009 struct ocelot *ocelot = ds->priv;
2015 felix_mrp_del_ring_role(struct dsa_switch *ds, int port,
2018 struct ocelot *ocelot = ds->priv;
2023 static int felix_port_get_default_prio(struct dsa_switch *ds, int port)
2025 struct ocelot *ocelot = ds->priv;
2030 static int felix_port_set_default_prio(struct dsa_switch *ds, int port,
2033 struct ocelot *ocelot = ds->priv;
2038 static int felix_port_get_dscp_prio(struct dsa_switch *ds, int port, u8 dscp)
2040 struct ocelot *ocelot = ds->priv;
2045 static int felix_port_add_dscp_prio(struct dsa_switch *ds, int port, u8 dscp,
2048 struct ocelot *ocelot = ds->priv;
2053 static int felix_port_del_dscp_prio(struct dsa_switch *ds, int port, u8 dscp,
2056 struct ocelot *ocelot = ds->priv;
2061 static int felix_get_mm(struct dsa_switch *ds, int port,
2064 struct ocelot *ocelot = ds->priv;
2069 static int felix_set_mm(struct dsa_switch *ds, int port,
2073 struct ocelot *ocelot = ds->priv;
2078 static void felix_get_mm_stats(struct dsa_switch *ds, int port,
2081 struct ocelot *ocelot = ds->priv;
2174 struct dsa_switch *ds = felix->ds;
2176 if (!dsa_is_user_port(ds, port))
2179 return dsa_to_port(ds, port)->user;