Lines Matching refs:ds

45 static int felix_cpu_port_for_conduit(struct dsa_switch *ds,
48 struct ocelot *ocelot = ds->priv;
101 static int felix_tag_8021q_vlan_add_rx(struct dsa_switch *ds, int port,
106 struct ocelot *ocelot = ds->priv;
150 static int felix_tag_8021q_vlan_del_rx(struct dsa_switch *ds, int port,
155 struct ocelot *ocelot = ds->priv;
172 static int felix_tag_8021q_vlan_add_tx(struct dsa_switch *ds, int port,
176 unsigned long cpu_ports = dsa_cpu_ports(ds);
177 struct ocelot *ocelot = ds->priv;
239 static int felix_tag_8021q_vlan_del_tx(struct dsa_switch *ds, int port, u16 vid)
244 struct ocelot *ocelot = ds->priv;
270 static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid,
273 struct dsa_port *dp = dsa_to_port(ds, port);
284 dsa_switch_for_each_cpu_port(cpu_dp, ds) {
285 err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid,
291 err = felix_tag_8021q_vlan_add_tx(ds, port, vid);
298 dsa_switch_for_each_cpu_port(cpu_dp, ds)
299 felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid);
304 static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid)
306 struct dsa_port *dp = dsa_to_port(ds, port);
313 dsa_switch_for_each_cpu_port(cpu_dp, ds) {
314 err = felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid);
319 err = felix_tag_8021q_vlan_del_tx(ds, port, vid);
326 dsa_switch_for_each_cpu_port(cpu_dp, ds)
327 felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid,
333 static int felix_update_tag_8021q_rx_rules(struct dsa_switch *ds, int port,
338 struct ocelot *ocelot = ds->priv;
345 dsa_switch_for_each_cpu_port(cpu_dp, ds) {
362 static int felix_trap_get_cpu_port(struct dsa_switch *ds,
372 dp = dsa_to_port(ds, first_port);
381 static int felix_update_trapping_destinations(struct dsa_switch *ds,
384 struct ocelot *ocelot = ds->priv;
413 port_mask = BIT(felix_trap_get_cpu_port(ds, trap));
484 static int felix_tag_npi_setup(struct dsa_switch *ds)
487 struct ocelot *ocelot = ds->priv;
489 dsa_switch_for_each_user_port(dp, ds) {
491 dev_err(ds->dev, "Multiple NPI ports not supported\n");
506 static void felix_tag_npi_teardown(struct dsa_switch *ds)
508 struct ocelot *ocelot = ds->priv;
513 static unsigned long felix_tag_npi_get_host_fwd_mask(struct dsa_switch *ds)
515 struct ocelot *ocelot = ds->priv;
520 static int felix_tag_npi_change_conduit(struct dsa_switch *ds, int port,
524 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
525 struct ocelot *ocelot = ds->priv;
537 dsa_switch_for_each_user_port(other_dp, ds) {
549 felix_npi_port_init(ocelot, felix_cpu_port_for_conduit(ds, conduit));
568 static int felix_tag_8021q_setup(struct dsa_switch *ds)
570 struct ocelot *ocelot = ds->priv;
574 err = dsa_tag_8021q_register(ds, htons(ETH_P_8021AD));
578 dsa_switch_for_each_cpu_port(dp, ds)
581 dsa_switch_for_each_user_port(dp, ds)
585 dsa_switch_for_each_available_port(dp, ds)
619 ds->untag_vlan_aware_bridge_pvid = true;
624 static void felix_tag_8021q_teardown(struct dsa_switch *ds)
626 struct ocelot *ocelot = ds->priv;
629 dsa_switch_for_each_available_port(dp, ds)
638 dsa_switch_for_each_user_port(dp, ds)
641 dsa_switch_for_each_cpu_port(dp, ds)
644 dsa_tag_8021q_unregister(ds);
646 ds->untag_vlan_aware_bridge_pvid = false;
649 static unsigned long felix_tag_8021q_get_host_fwd_mask(struct dsa_switch *ds)
651 return dsa_cpu_ports(ds);
654 static int felix_tag_8021q_change_conduit(struct dsa_switch *ds, int port,
658 int cpu = felix_cpu_port_for_conduit(ds, conduit);
659 struct ocelot *ocelot = ds->priv;
664 return felix_update_trapping_destinations(ds, true);
674 static void felix_set_host_flood(struct dsa_switch *ds, unsigned long mask,
677 struct ocelot *ocelot = ds->priv;
693 felix_migrate_host_flood(struct dsa_switch *ds,
697 struct ocelot *ocelot = ds->priv;
702 mask = old_proto_ops->get_host_fwd_mask(ds);
703 felix_set_host_flood(ds, mask, false, false, false);
706 mask = proto_ops->get_host_fwd_mask(ds);
707 felix_set_host_flood(ds, mask, !!felix->host_flood_uc_mask,
711 static int felix_migrate_mdbs(struct dsa_switch *ds,
715 struct ocelot *ocelot = ds->priv;
721 from = old_proto_ops->get_host_fwd_mask(ds);
722 to = proto_ops->get_host_fwd_mask(ds);
733 felix_tag_proto_setup_shared(struct dsa_switch *ds,
740 err = felix_migrate_mdbs(ds, proto_ops, old_proto_ops);
744 felix_update_trapping_destinations(ds, using_tag_8021q);
746 felix_migrate_host_flood(ds, proto_ops, old_proto_ops);
755 static int felix_change_tag_protocol(struct dsa_switch *ds,
759 struct ocelot *ocelot = ds->priv;
780 err = proto_ops->setup(ds);
784 err = felix_tag_proto_setup_shared(ds, proto_ops, old_proto_ops);
789 old_proto_ops->teardown(ds);
797 proto_ops->teardown(ds);
802 static enum dsa_tag_protocol felix_get_tag_protocol(struct dsa_switch *ds,
806 struct ocelot *ocelot = ds->priv;
812 static void felix_port_set_host_flood(struct dsa_switch *ds, int port,
815 struct ocelot *ocelot = ds->priv;
829 mask = felix->tag_proto_ops->get_host_fwd_mask(ds);
830 felix_set_host_flood(ds, mask, !!felix->host_flood_uc_mask,
834 static int felix_port_change_conduit(struct dsa_switch *ds, int port,
838 struct ocelot *ocelot = ds->priv;
841 return felix->tag_proto_ops->change_conduit(ds, port, conduit, extack);
844 static int felix_set_ageing_time(struct dsa_switch *ds,
847 struct ocelot *ocelot = ds->priv;
854 static void felix_port_fast_age(struct dsa_switch *ds, int port)
856 struct ocelot *ocelot = ds->priv;
861 dev_err(ds->dev, "Flushing MAC table on port %d returned %pe\n",
865 static int felix_fdb_dump(struct dsa_switch *ds, int port,
868 struct ocelot *ocelot = ds->priv;
873 static int felix_fdb_add(struct dsa_switch *ds, int port,
878 struct dsa_port *dp = dsa_to_port(ds, port);
879 struct ocelot *ocelot = ds->priv;
885 dsa_fdb_present_in_other_db(ds, port, addr, vid, db))
894 static int felix_fdb_del(struct dsa_switch *ds, int port,
899 struct dsa_port *dp = dsa_to_port(ds, port);
900 struct ocelot *ocelot = ds->priv;
906 dsa_fdb_present_in_other_db(ds, port, addr, vid, db))
915 static int felix_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag lag,
920 struct ocelot *ocelot = ds->priv;
928 static int felix_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag lag,
933 struct ocelot *ocelot = ds->priv;
941 static int felix_mdb_add(struct dsa_switch *ds, int port,
946 struct ocelot *ocelot = ds->priv;
951 if (dsa_is_cpu_port(ds, port) && !bridge_dev &&
952 dsa_mdb_present_in_other_db(ds, port, mdb, db))
961 static int felix_mdb_del(struct dsa_switch *ds, int port,
966 struct ocelot *ocelot = ds->priv;
971 if (dsa_is_cpu_port(ds, port) && !bridge_dev &&
972 dsa_mdb_present_in_other_db(ds, port, mdb, db))
981 static void felix_bridge_stp_state_set(struct dsa_switch *ds, int port,
984 struct ocelot *ocelot = ds->priv;
989 static int felix_pre_bridge_flags(struct dsa_switch *ds, int port,
993 struct ocelot *ocelot = ds->priv;
998 static int felix_bridge_flags(struct dsa_switch *ds, int port,
1002 struct ocelot *ocelot = ds->priv;
1012 static int felix_bridge_join(struct dsa_switch *ds, int port,
1016 struct ocelot *ocelot = ds->priv;
1022 static void felix_bridge_leave(struct dsa_switch *ds, int port,
1025 struct ocelot *ocelot = ds->priv;
1030 static int felix_lag_join(struct dsa_switch *ds, int port,
1035 struct ocelot *ocelot = ds->priv;
1043 if (!dsa_is_cpu_port(ds, port))
1046 return felix_port_change_conduit(ds, port, lag.dev, extack);
1049 static int felix_lag_leave(struct dsa_switch *ds, int port,
1052 struct ocelot *ocelot = ds->priv;
1057 if (!dsa_is_cpu_port(ds, port))
1060 return felix_port_change_conduit(ds, port, lag.dev, NULL);
1063 static int felix_lag_change(struct dsa_switch *ds, int port)
1065 struct dsa_port *dp = dsa_to_port(ds, port);
1066 struct ocelot *ocelot = ds->priv;
1073 static int felix_vlan_prepare(struct dsa_switch *ds, int port,
1077 struct ocelot *ocelot = ds->priv;
1097 static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
1100 struct ocelot *ocelot = ds->priv;
1112 err = felix_update_tag_8021q_rx_rules(ds, port, enabled);
1120 static int felix_vlan_add(struct dsa_switch *ds, int port,
1124 struct ocelot *ocelot = ds->priv;
1128 err = felix_vlan_prepare(ds, port, vlan, extack);
1137 static int felix_vlan_del(struct dsa_switch *ds, int port,
1140 struct ocelot *ocelot = ds->priv;
1145 static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
1148 struct ocelot *ocelot = ds->priv;
1163 struct ocelot *ocelot = dp->ds->priv;
1178 struct ocelot *ocelot = dp->ds->priv;
1196 struct ocelot *ocelot = dp->ds->priv;
1214 struct ocelot *ocelot = dp->ds->priv;
1228 static int felix_port_enable(struct dsa_switch *ds, int port,
1231 struct dsa_port *dp = dsa_to_port(ds, port);
1232 struct ocelot *ocelot = ds->priv;
1240 if (felix_cpu_port_for_conduit(ds, conduit) != ocelot->npi) {
1241 dev_err(ds->dev, "Multiple conduits are not allowed\n");
1270 static void felix_get_stats64(struct dsa_switch *ds, int port,
1273 struct ocelot *ocelot = ds->priv;
1278 static void felix_get_pause_stats(struct dsa_switch *ds, int port,
1281 struct ocelot *ocelot = ds->priv;
1286 static void felix_get_rmon_stats(struct dsa_switch *ds, int port,
1290 struct ocelot *ocelot = ds->priv;
1295 static void felix_get_eth_ctrl_stats(struct dsa_switch *ds, int port,
1298 struct ocelot *ocelot = ds->priv;
1303 static void felix_get_eth_mac_stats(struct dsa_switch *ds, int port,
1306 struct ocelot *ocelot = ds->priv;
1311 static void felix_get_eth_phy_stats(struct dsa_switch *ds, int port,
1314 struct ocelot *ocelot = ds->priv;
1319 static void felix_get_ts_stats(struct dsa_switch *ds, int port,
1322 struct ocelot *ocelot = ds->priv;
1327 static void felix_get_strings(struct dsa_switch *ds, int port,
1330 struct ocelot *ocelot = ds->priv;
1335 static void felix_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data)
1337 struct ocelot *ocelot = ds->priv;
1342 static int felix_get_sset_count(struct dsa_switch *ds, int port, int sset)
1344 struct ocelot *ocelot = ds->priv;
1349 static int felix_get_ts_info(struct dsa_switch *ds, int port,
1352 struct ocelot *ocelot = ds->priv;
1518 ocelot->devlink = felix->ds->devlink;
1624 struct dsa_switch *ds = xmit_work->dp->ds;
1627 struct ocelot *ocelot = ds->priv;
1657 static int felix_connect_tag_protocol(struct dsa_switch *ds,
1664 tagger_data = ocelot_8021q_tagger_data(ds);
1675 static int felix_setup(struct dsa_switch *ds)
1677 struct ocelot *ocelot = ds->priv;
1682 err = felix_init_structs(felix, ds->num_ports);
1702 dsa_switch_for_each_available_port(dp, ds) {
1731 felix_change_tag_protocol(ds, felix->tag_proto);
1733 ds->mtu_enforcement_ingress = true;
1734 ds->assisted_learning_on_cpu_port = true;
1735 ds->fdb_isolation = true;
1736 ds->max_num_bridges = ds->num_ports;
1741 dsa_switch_for_each_available_port(dp, ds)
1754 static void felix_teardown(struct dsa_switch *ds)
1756 struct ocelot *ocelot = ds->priv;
1762 felix->tag_proto_ops->teardown(ds);
1765 dsa_switch_for_each_available_port(dp, ds)
1776 static int felix_hwtstamp_get(struct dsa_switch *ds, int port,
1779 struct ocelot *ocelot = ds->priv;
1786 static int felix_hwtstamp_set(struct dsa_switch *ds, int port,
1790 struct ocelot *ocelot = ds->priv;
1801 return felix_update_trapping_destinations(ds, using_tag_8021q);
1858 static bool felix_rxtstamp(struct dsa_switch *ds, int port,
1863 struct ocelot *ocelot = ds->priv;
1905 static void felix_txtstamp(struct dsa_switch *ds, int port,
1908 struct ocelot *ocelot = ds->priv;
1915 dev_err_ratelimited(ds->dev,
1925 static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
1927 struct ocelot *ocelot = ds->priv;
1942 static int felix_get_max_mtu(struct dsa_switch *ds, int port)
1944 struct ocelot *ocelot = ds->priv;
1949 static int felix_cls_flower_add(struct dsa_switch *ds, int port,
1952 struct ocelot *ocelot = ds->priv;
1963 return felix_update_trapping_destinations(ds, using_tag_8021q);
1966 static int felix_cls_flower_del(struct dsa_switch *ds, int port,
1969 struct ocelot *ocelot = ds->priv;
1974 static int felix_cls_flower_stats(struct dsa_switch *ds, int port,
1977 struct ocelot *ocelot = ds->priv;
1982 static int felix_port_policer_add(struct dsa_switch *ds, int port,
1985 struct ocelot *ocelot = ds->priv;
1994 static void felix_port_policer_del(struct dsa_switch *ds, int port)
1996 struct ocelot *ocelot = ds->priv;
2001 static int felix_port_mirror_add(struct dsa_switch *ds, int port,
2005 struct ocelot *ocelot = ds->priv;
2011 static void felix_port_mirror_del(struct dsa_switch *ds, int port,
2014 struct ocelot *ocelot = ds->priv;
2019 static int felix_port_setup_tc(struct dsa_switch *ds, int port,
2023 struct ocelot *ocelot = ds->priv;
2027 return felix->info->port_setup_tc(ds, port, type, type_data);
2032 static int felix_sb_pool_get(struct dsa_switch *ds, unsigned int sb_index,
2036 struct ocelot *ocelot = ds->priv;
2041 static int felix_sb_pool_set(struct dsa_switch *ds, unsigned int sb_index,
2046 struct ocelot *ocelot = ds->priv;
2052 static int felix_sb_port_pool_get(struct dsa_switch *ds, int port,
2056 struct ocelot *ocelot = ds->priv;
2062 static int felix_sb_port_pool_set(struct dsa_switch *ds, int port,
2066 struct ocelot *ocelot = ds->priv;
2072 static int felix_sb_tc_pool_bind_get(struct dsa_switch *ds, int port,
2077 struct ocelot *ocelot = ds->priv;
2084 static int felix_sb_tc_pool_bind_set(struct dsa_switch *ds, int port,
2090 struct ocelot *ocelot = ds->priv;
2097 static int felix_sb_occ_snapshot(struct dsa_switch *ds,
2100 struct ocelot *ocelot = ds->priv;
2105 static int felix_sb_occ_max_clear(struct dsa_switch *ds,
2108 struct ocelot *ocelot = ds->priv;
2113 static int felix_sb_occ_port_pool_get(struct dsa_switch *ds, int port,
2117 struct ocelot *ocelot = ds->priv;
2123 static int felix_sb_occ_tc_port_bind_get(struct dsa_switch *ds, int port,
2128 struct ocelot *ocelot = ds->priv;
2134 static int felix_mrp_add(struct dsa_switch *ds, int port,
2137 struct ocelot *ocelot = ds->priv;
2142 static int felix_mrp_del(struct dsa_switch *ds, int port,
2145 struct ocelot *ocelot = ds->priv;
2151 felix_mrp_add_ring_role(struct dsa_switch *ds, int port,
2154 struct ocelot *ocelot = ds->priv;
2160 felix_mrp_del_ring_role(struct dsa_switch *ds, int port,
2163 struct ocelot *ocelot = ds->priv;
2168 static int felix_port_get_default_prio(struct dsa_switch *ds, int port)
2170 struct ocelot *ocelot = ds->priv;
2175 static int felix_port_set_default_prio(struct dsa_switch *ds, int port,
2178 struct ocelot *ocelot = ds->priv;
2183 static int felix_port_get_dscp_prio(struct dsa_switch *ds, int port, u8 dscp)
2185 struct ocelot *ocelot = ds->priv;
2190 static int felix_port_add_dscp_prio(struct dsa_switch *ds, int port, u8 dscp,
2193 struct ocelot *ocelot = ds->priv;
2198 static int felix_port_del_dscp_prio(struct dsa_switch *ds, int port, u8 dscp,
2201 struct ocelot *ocelot = ds->priv;
2206 static int felix_get_mm(struct dsa_switch *ds, int port,
2209 struct ocelot *ocelot = ds->priv;
2214 static int felix_set_mm(struct dsa_switch *ds, int port,
2218 struct ocelot *ocelot = ds->priv;
2223 static void felix_get_mm_stats(struct dsa_switch *ds, int port,
2226 struct ocelot *ocelot = ds->priv;
2325 struct dsa_switch *ds;
2334 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
2335 if (!ds)
2348 felix->ds = ds;
2351 ds->dev = dev;
2352 ds->num_ports = info->num_ports;
2353 ds->num_tx_queues = OCELOT_NUM_TC;
2354 ds->ops = &felix_switch_ops;
2355 ds->phylink_mac_ops = &felix_phylink_mac_ops;
2356 ds->priv = ocelot;
2358 err = dsa_register_switch(ds);
2369 struct dsa_switch *ds = felix->ds;
2371 if (!dsa_is_user_port(ds, port))
2374 return dsa_to_port(ds, port)->user;