Lines Matching +full:ocelot +full:- +full:hsio

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright 2019-2021 NXP
5 * register-compatible with Ocelot and that perform I/O to their host CPU
15 #include <soc/mscc/ocelot.h>
17 #include <linux/dsa/ocelot.h>
28 /* Translate the DSA database API into the ocelot switch library API,
41 return ERR_PTR(-EOPNOTSUPP); in felix_classify_db()
48 struct ocelot *ocelot = ds->priv; in felix_cpu_port_for_conduit() local
53 mutex_lock(&ocelot->fwd_domain_lock); in felix_cpu_port_for_conduit()
54 lag = ocelot_bond_get_id(ocelot, conduit); in felix_cpu_port_for_conduit()
55 mutex_unlock(&ocelot->fwd_domain_lock); in felix_cpu_port_for_conduit()
60 cpu_dp = conduit->dsa_ptr; in felix_cpu_port_for_conduit()
61 return cpu_dp->index; in felix_cpu_port_for_conduit()
65 * felix_update_tag_8021q_rx_rule - Update VCAP ES0 tag_8021q rule after
73 * - push_inner_tag=0: the inner tag is never pushed into the frame
79 * - push_inner_tag=1: the inner tag is always pushed. This is good when the
81 * is under a VLAN-aware bridge, and software needs to
84 * The point is that what is good for a VLAN-unaware port is not good for a
85 * VLAN-aware port, and vice versa. Thus, the RX tagging rules must be kept in
93 outer_tagging_rule->action.push_inner_tag = OCELOT_ES0_TAG; in felix_update_tag_8021q_rx_rule()
95 outer_tagging_rule->action.push_inner_tag = OCELOT_NO_ES0_TAG; in felix_update_tag_8021q_rx_rule()
106 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_add_rx() local
110 key_length = ocelot->vcap[VCAP_ES0].keys[VCAP_ES0_IGR_PORT].length; in felix_tag_8021q_vlan_add_rx()
115 return -ENOMEM; in felix_tag_8021q_vlan_add_rx()
117 cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, upstream); in felix_tag_8021q_vlan_add_rx()
119 outer_tagging_rule->key_type = OCELOT_VCAP_KEY_ANY; in felix_tag_8021q_vlan_add_rx()
120 outer_tagging_rule->prio = 1; in felix_tag_8021q_vlan_add_rx()
121 outer_tagging_rule->id.cookie = cookie; in felix_tag_8021q_vlan_add_rx()
122 outer_tagging_rule->id.tc_offload = false; in felix_tag_8021q_vlan_add_rx()
123 outer_tagging_rule->block_id = VCAP_ES0; in felix_tag_8021q_vlan_add_rx()
124 outer_tagging_rule->type = OCELOT_VCAP_FILTER_OFFLOAD; in felix_tag_8021q_vlan_add_rx()
125 outer_tagging_rule->lookup = 0; in felix_tag_8021q_vlan_add_rx()
126 outer_tagging_rule->ingress_port.value = port; in felix_tag_8021q_vlan_add_rx()
127 outer_tagging_rule->ingress_port.mask = GENMASK(key_length - 1, 0); in felix_tag_8021q_vlan_add_rx()
128 outer_tagging_rule->egress_port.value = upstream; in felix_tag_8021q_vlan_add_rx()
129 outer_tagging_rule->egress_port.mask = GENMASK(key_length - 1, 0); in felix_tag_8021q_vlan_add_rx()
130 outer_tagging_rule->action.push_outer_tag = OCELOT_ES0_TAG; in felix_tag_8021q_vlan_add_rx()
131 outer_tagging_rule->action.tag_a_tpid_sel = OCELOT_TAG_TPID_SEL_8021AD; in felix_tag_8021q_vlan_add_rx()
132 outer_tagging_rule->action.tag_a_vid_sel = 1; in felix_tag_8021q_vlan_add_rx()
133 outer_tagging_rule->action.vid_a_val = vid; in felix_tag_8021q_vlan_add_rx()
135 outer_tagging_rule->action.tag_b_tpid_sel = OCELOT_TAG_TPID_SEL_8021Q; in felix_tag_8021q_vlan_add_rx()
143 err = ocelot_vcap_filter_add(ocelot, outer_tagging_rule, NULL); in felix_tag_8021q_vlan_add_rx()
155 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_del_rx() local
158 block_vcap_es0 = &ocelot->block[VCAP_ES0]; in felix_tag_8021q_vlan_del_rx()
159 cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, upstream); in felix_tag_8021q_vlan_del_rx()
164 return -ENOENT; in felix_tag_8021q_vlan_del_rx()
166 return ocelot_vcap_filter_del(ocelot, outer_tagging_rule); in felix_tag_8021q_vlan_del_rx()
177 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_add_tx() local
183 return -ENOMEM; in felix_tag_8021q_vlan_add_tx()
188 return -ENOMEM; in felix_tag_8021q_vlan_add_tx()
191 cookie = OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port); in felix_tag_8021q_vlan_add_tx()
193 untagging_rule->key_type = OCELOT_VCAP_KEY_ANY; in felix_tag_8021q_vlan_add_tx()
194 untagging_rule->ingress_port_mask = cpu_ports; in felix_tag_8021q_vlan_add_tx()
195 untagging_rule->vlan.vid.value = vid; in felix_tag_8021q_vlan_add_tx()
196 untagging_rule->vlan.vid.mask = VLAN_VID_MASK; in felix_tag_8021q_vlan_add_tx()
197 untagging_rule->prio = 1; in felix_tag_8021q_vlan_add_tx()
198 untagging_rule->id.cookie = cookie; in felix_tag_8021q_vlan_add_tx()
199 untagging_rule->id.tc_offload = false; in felix_tag_8021q_vlan_add_tx()
200 untagging_rule->block_id = VCAP_IS1; in felix_tag_8021q_vlan_add_tx()
201 untagging_rule->type = OCELOT_VCAP_FILTER_OFFLOAD; in felix_tag_8021q_vlan_add_tx()
202 untagging_rule->lookup = 0; in felix_tag_8021q_vlan_add_tx()
203 untagging_rule->action.vlan_pop_cnt_ena = true; in felix_tag_8021q_vlan_add_tx()
204 untagging_rule->action.vlan_pop_cnt = 1; in felix_tag_8021q_vlan_add_tx()
205 untagging_rule->action.pag_override_mask = 0xff; in felix_tag_8021q_vlan_add_tx()
206 untagging_rule->action.pag_val = port; in felix_tag_8021q_vlan_add_tx()
208 err = ocelot_vcap_filter_add(ocelot, untagging_rule, NULL); in felix_tag_8021q_vlan_add_tx()
215 cookie = OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port); in felix_tag_8021q_vlan_add_tx()
217 redirect_rule->key_type = OCELOT_VCAP_KEY_ANY; in felix_tag_8021q_vlan_add_tx()
218 redirect_rule->ingress_port_mask = cpu_ports; in felix_tag_8021q_vlan_add_tx()
219 redirect_rule->pag = port; in felix_tag_8021q_vlan_add_tx()
220 redirect_rule->prio = 1; in felix_tag_8021q_vlan_add_tx()
221 redirect_rule->id.cookie = cookie; in felix_tag_8021q_vlan_add_tx()
222 redirect_rule->id.tc_offload = false; in felix_tag_8021q_vlan_add_tx()
223 redirect_rule->block_id = VCAP_IS2; in felix_tag_8021q_vlan_add_tx()
224 redirect_rule->type = OCELOT_VCAP_FILTER_OFFLOAD; in felix_tag_8021q_vlan_add_tx()
225 redirect_rule->lookup = 0; in felix_tag_8021q_vlan_add_tx()
226 redirect_rule->action.mask_mode = OCELOT_MASK_MODE_REDIRECT; in felix_tag_8021q_vlan_add_tx()
227 redirect_rule->action.port_mask = BIT(port); in felix_tag_8021q_vlan_add_tx()
229 err = ocelot_vcap_filter_add(ocelot, redirect_rule, NULL); in felix_tag_8021q_vlan_add_tx()
231 ocelot_vcap_filter_del(ocelot, untagging_rule); in felix_tag_8021q_vlan_add_tx()
244 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_del_tx() local
248 block_vcap_is1 = &ocelot->block[VCAP_IS1]; in felix_tag_8021q_vlan_del_tx()
249 block_vcap_is2 = &ocelot->block[VCAP_IS2]; in felix_tag_8021q_vlan_del_tx()
251 cookie = OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port); in felix_tag_8021q_vlan_del_tx()
255 return -ENOENT; in felix_tag_8021q_vlan_del_tx()
257 err = ocelot_vcap_filter_del(ocelot, untagging_rule); in felix_tag_8021q_vlan_del_tx()
261 cookie = OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port); in felix_tag_8021q_vlan_del_tx()
265 return -ENOENT; in felix_tag_8021q_vlan_del_tx()
267 return ocelot_vcap_filter_del(ocelot, redirect_rule); in felix_tag_8021q_vlan_del_tx()
285 err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid, in felix_tag_8021q_vlan_add()
299 felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid); in felix_tag_8021q_vlan_add()
314 err = felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid); in felix_tag_8021q_vlan_del()
327 felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid, in felix_tag_8021q_vlan_del()
338 struct ocelot *ocelot = ds->priv; in felix_update_tag_8021q_rx_rules() local
343 block_vcap_es0 = &ocelot->block[VCAP_ES0]; in felix_update_tag_8021q_rx_rules()
346 cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, in felix_update_tag_8021q_rx_rules()
347 cpu_dp->index); in felix_update_tag_8021q_rx_rules()
354 err = ocelot_vcap_filter_replace(ocelot, outer_tagging_rule); in felix_update_tag_8021q_rx_rules()
368 if (WARN_ON(!trap->ingress_port_mask)) in felix_trap_get_cpu_port()
369 return -1; in felix_trap_get_cpu_port()
371 first_port = __ffs(trap->ingress_port_mask); in felix_trap_get_cpu_port()
374 return dp->cpu_dp->index; in felix_trap_get_cpu_port()
379 * their arrival when using the ocelot-8021q tagging protocol.
384 struct ocelot *ocelot = ds->priv; in felix_update_trapping_destinations() local
385 struct felix *felix = ocelot_to_felix(ocelot); in felix_update_trapping_destinations()
393 if (!felix->info->quirk_no_xtr_irq) in felix_update_trapping_destinations()
399 block_vcap_is2 = &ocelot->block[VCAP_IS2]; in felix_update_trapping_destinations()
402 list_for_each_entry(trap, &block_vcap_is2->rules, list) { in felix_update_trapping_destinations()
403 if (!trap->is_trap) in felix_update_trapping_destinations()
414 cpu_copy_ena = !!trap->take_ts; in felix_update_trapping_destinations()
424 if (trap->action.mask_mode == mask_mode && in felix_update_trapping_destinations()
425 trap->action.port_mask == port_mask && in felix_update_trapping_destinations()
426 trap->action.cpu_copy_ena == cpu_copy_ena) in felix_update_trapping_destinations()
429 trap->action.mask_mode = mask_mode; in felix_update_trapping_destinations()
430 trap->action.port_mask = port_mask; in felix_update_trapping_destinations()
431 trap->action.cpu_copy_ena = cpu_copy_ena; in felix_update_trapping_destinations()
433 err = ocelot_vcap_filter_replace(ocelot, trap); in felix_update_trapping_destinations()
447 static void felix_npi_port_init(struct ocelot *ocelot, int port) in felix_npi_port_init() argument
449 ocelot->npi = port; in felix_npi_port_init()
451 ocelot_write(ocelot, QSYS_EXT_CPU_CFG_EXT_CPUQ_MSK_M | in felix_npi_port_init()
456 ocelot_fields_write(ocelot, port, SYS_PORT_MODE_INCL_XTR_HDR, in felix_npi_port_init()
457 ocelot->npi_xtr_prefix); in felix_npi_port_init()
458 ocelot_fields_write(ocelot, port, SYS_PORT_MODE_INCL_INJ_HDR, in felix_npi_port_init()
459 ocelot->npi_inj_prefix); in felix_npi_port_init()
462 ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 0); in felix_npi_port_init()
465 static void felix_npi_port_deinit(struct ocelot *ocelot, int port) in felix_npi_port_deinit() argument
468 int unused_port = ocelot->num_phys_ports + 2; in felix_npi_port_deinit()
470 ocelot->npi = -1; in felix_npi_port_deinit()
472 ocelot_write(ocelot, QSYS_EXT_CPU_CFG_EXT_CPU_PORT(unused_port), in felix_npi_port_deinit()
475 ocelot_fields_write(ocelot, port, SYS_PORT_MODE_INCL_XTR_HDR, in felix_npi_port_deinit()
477 ocelot_fields_write(ocelot, port, SYS_PORT_MODE_INCL_INJ_HDR, in felix_npi_port_deinit()
481 ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 1); in felix_npi_port_deinit()
487 struct ocelot *ocelot = ds->priv; in felix_tag_npi_setup() local
490 if (first_cpu_dp && dp->cpu_dp != first_cpu_dp) { in felix_tag_npi_setup()
491 dev_err(ds->dev, "Multiple NPI ports not supported\n"); in felix_tag_npi_setup()
492 return -EINVAL; in felix_tag_npi_setup()
495 first_cpu_dp = dp->cpu_dp; in felix_tag_npi_setup()
499 return -EINVAL; in felix_tag_npi_setup()
501 felix_npi_port_init(ocelot, first_cpu_dp->index); in felix_tag_npi_setup()
508 struct ocelot *ocelot = ds->priv; in felix_tag_npi_teardown() local
510 felix_npi_port_deinit(ocelot, ocelot->npi); in felix_tag_npi_teardown()
515 struct ocelot *ocelot = ds->priv; in felix_tag_npi_get_host_fwd_mask() local
517 return BIT(ocelot->num_phys_ports); in felix_tag_npi_get_host_fwd_mask()
525 struct ocelot *ocelot = ds->priv; in felix_tag_npi_change_conduit() local
529 "LAG DSA conduit only supported using ocelot-8021q"); in felix_tag_npi_change_conduit()
530 return -EOPNOTSUPP; in felix_tag_npi_change_conduit()
538 struct net_device *user = other_dp->user; in felix_tag_npi_change_conduit()
540 if (other_dp != dp && (user->flags & IFF_UP) && in felix_tag_npi_change_conduit()
544 return -EOPNOTSUPP; in felix_tag_npi_change_conduit()
548 felix_npi_port_deinit(ocelot, ocelot->npi); in felix_tag_npi_change_conduit()
549 felix_npi_port_init(ocelot, felix_cpu_port_for_conduit(ds, conduit)); in felix_tag_npi_change_conduit()
556 * use the software-defined tag_8021q frame format. As far as the hardware is
557 * concerned, it thinks it is a "dumb switch" - the queues of the CPU port
559 * register-based MMIO.
570 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_setup() local
579 ocelot_port_setup_dsa_8021q_cpu(ocelot, dp->index); in felix_tag_8021q_setup()
582 ocelot_port_assign_dsa_8021q_cpu(ocelot, dp->index, in felix_tag_8021q_setup()
583 dp->cpu_dp->index); in felix_tag_8021q_setup()
589 * - When these packets are injected from the tag_8021q in felix_tag_8021q_setup()
592 * - STP traffic ingressing on a user port should go to in felix_tag_8021q_setup()
596 ocelot_write_gix(ocelot, in felix_tag_8021q_setup()
598 ANA_PORT_CPU_FWD_BPDU_CFG, dp->index); in felix_tag_8021q_setup()
601 * transferred to the tag_8021q tagger from the NPI-based tagger. in felix_tag_8021q_setup()
603 * other hand, the MMIO-based matching of PTP frames is very brittle, in felix_tag_8021q_setup()
607 ocelot_lock_xtr_grp_bh(ocelot, 0); in felix_tag_8021q_setup()
608 ocelot_drain_cpu_queue(ocelot, 0); in felix_tag_8021q_setup()
609 ocelot_unlock_xtr_grp_bh(ocelot, 0); in felix_tag_8021q_setup()
612 * about whether the received packets were VLAN-tagged on the wire, in felix_tag_8021q_setup()
615 * Since using push_inner_tag=1 is unavoidable for VLAN-aware bridges, in felix_tag_8021q_setup()
619 ds->untag_vlan_aware_bridge_pvid = true; in felix_tag_8021q_setup()
626 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_teardown() local
633 ocelot_write_gix(ocelot, in felix_tag_8021q_teardown()
636 dp->index); in felix_tag_8021q_teardown()
639 ocelot_port_unassign_dsa_8021q_cpu(ocelot, dp->index); in felix_tag_8021q_teardown()
642 ocelot_port_teardown_dsa_8021q_cpu(ocelot, dp->index); in felix_tag_8021q_teardown()
646 ds->untag_vlan_aware_bridge_pvid = false; in felix_tag_8021q_teardown()
659 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_change_conduit() local
661 ocelot_port_unassign_dsa_8021q_cpu(ocelot, port); in felix_tag_8021q_change_conduit()
662 ocelot_port_assign_dsa_8021q_cpu(ocelot, port, cpu); in felix_tag_8021q_change_conduit()
677 struct ocelot *ocelot = ds->priv; in felix_set_host_flood() local
681 ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_UC); in felix_set_host_flood()
684 ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_MC); in felix_set_host_flood()
685 ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_MCIPV4); in felix_set_host_flood()
686 ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_MCIPV6); in felix_set_host_flood()
689 ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_BC); in felix_set_host_flood()
697 struct ocelot *ocelot = ds->priv; in felix_migrate_host_flood() local
698 struct felix *felix = ocelot_to_felix(ocelot); in felix_migrate_host_flood()
702 mask = old_proto_ops->get_host_fwd_mask(ds); in felix_migrate_host_flood()
706 mask = proto_ops->get_host_fwd_mask(ds); in felix_migrate_host_flood()
707 felix_set_host_flood(ds, mask, !!felix->host_flood_uc_mask, in felix_migrate_host_flood()
708 !!felix->host_flood_mc_mask, true); in felix_migrate_host_flood()
715 struct ocelot *ocelot = ds->priv; in felix_migrate_mdbs() local
721 from = old_proto_ops->get_host_fwd_mask(ds); in felix_migrate_mdbs()
722 to = proto_ops->get_host_fwd_mask(ds); in felix_migrate_mdbs()
724 return ocelot_migrate_mdbs(ocelot, from, to); in felix_migrate_mdbs()
759 struct ocelot *ocelot = ds->priv; in felix_change_tag_protocol() local
760 struct felix *felix = ocelot_to_felix(ocelot); in felix_change_tag_protocol()
772 return -EPROTONOSUPPORT; in felix_change_tag_protocol()
775 old_proto_ops = felix->tag_proto_ops; in felix_change_tag_protocol()
780 err = proto_ops->setup(ds); in felix_change_tag_protocol()
789 old_proto_ops->teardown(ds); in felix_change_tag_protocol()
791 felix->tag_proto_ops = proto_ops; in felix_change_tag_protocol()
792 felix->tag_proto = proto; in felix_change_tag_protocol()
797 proto_ops->teardown(ds); in felix_change_tag_protocol()
806 struct ocelot *ocelot = ds->priv; in felix_get_tag_protocol() local
807 struct felix *felix = ocelot_to_felix(ocelot); in felix_get_tag_protocol()
809 return felix->tag_proto; in felix_get_tag_protocol()
815 struct ocelot *ocelot = ds->priv; in felix_port_set_host_flood() local
816 struct felix *felix = ocelot_to_felix(ocelot); in felix_port_set_host_flood()
820 felix->host_flood_uc_mask |= BIT(port); in felix_port_set_host_flood()
822 felix->host_flood_uc_mask &= ~BIT(port); in felix_port_set_host_flood()
825 felix->host_flood_mc_mask |= BIT(port); in felix_port_set_host_flood()
827 felix->host_flood_mc_mask &= ~BIT(port); in felix_port_set_host_flood()
829 mask = felix->tag_proto_ops->get_host_fwd_mask(ds); in felix_port_set_host_flood()
830 felix_set_host_flood(ds, mask, !!felix->host_flood_uc_mask, in felix_port_set_host_flood()
831 !!felix->host_flood_mc_mask, true); in felix_port_set_host_flood()
838 struct ocelot *ocelot = ds->priv; in felix_port_change_conduit() local
839 struct felix *felix = ocelot_to_felix(ocelot); in felix_port_change_conduit()
841 return felix->tag_proto_ops->change_conduit(ds, port, conduit, extack); in felix_port_change_conduit()
847 struct ocelot *ocelot = ds->priv; in felix_set_ageing_time() local
849 ocelot_set_ageing_time(ocelot, ageing_time); in felix_set_ageing_time()
856 struct ocelot *ocelot = ds->priv; in felix_port_fast_age() local
859 err = ocelot_mact_flush(ocelot, port); in felix_port_fast_age()
861 dev_err(ds->dev, "Flushing MAC table on port %d returned %pe\n", in felix_port_fast_age()
868 struct ocelot *ocelot = ds->priv; in felix_fdb_dump() local
870 return ocelot_fdb_dump(ocelot, port, cb, data); in felix_fdb_dump()
879 struct ocelot *ocelot = ds->priv; in felix_fdb_add() local
891 return ocelot_fdb_add(ocelot, port, addr, vid, bridge_dev); in felix_fdb_add()
900 struct ocelot *ocelot = ds->priv; in felix_fdb_del() local
912 return ocelot_fdb_del(ocelot, port, addr, vid, bridge_dev); in felix_fdb_del()
920 struct ocelot *ocelot = ds->priv; in felix_lag_fdb_add() local
925 return ocelot_lag_fdb_add(ocelot, lag.dev, addr, vid, bridge_dev); in felix_lag_fdb_add()
933 struct ocelot *ocelot = ds->priv; in felix_lag_fdb_del() local
938 return ocelot_lag_fdb_del(ocelot, lag.dev, addr, vid, bridge_dev); in felix_lag_fdb_del()
946 struct ocelot *ocelot = ds->priv; in felix_mdb_add() local
955 if (port == ocelot->npi) in felix_mdb_add()
956 port = ocelot->num_phys_ports; in felix_mdb_add()
958 return ocelot_port_mdb_add(ocelot, port, mdb, bridge_dev); in felix_mdb_add()
966 struct ocelot *ocelot = ds->priv; in felix_mdb_del() local
975 if (port == ocelot->npi) in felix_mdb_del()
976 port = ocelot->num_phys_ports; in felix_mdb_del()
978 return ocelot_port_mdb_del(ocelot, port, mdb, bridge_dev); in felix_mdb_del()
984 struct ocelot *ocelot = ds->priv; in felix_bridge_stp_state_set() local
986 return ocelot_bridge_stp_state_set(ocelot, port, state); in felix_bridge_stp_state_set()
993 struct ocelot *ocelot = ds->priv; in felix_pre_bridge_flags() local
995 return ocelot_port_pre_bridge_flags(ocelot, port, val); in felix_pre_bridge_flags()
1002 struct ocelot *ocelot = ds->priv; in felix_bridge_flags() local
1004 if (port == ocelot->npi) in felix_bridge_flags()
1005 port = ocelot->num_phys_ports; in felix_bridge_flags()
1007 ocelot_port_bridge_flags(ocelot, port, val); in felix_bridge_flags()
1016 struct ocelot *ocelot = ds->priv; in felix_bridge_join() local
1018 return ocelot_port_bridge_join(ocelot, port, bridge.dev, bridge.num, in felix_bridge_join()
1025 struct ocelot *ocelot = ds->priv; in felix_bridge_leave() local
1027 ocelot_port_bridge_leave(ocelot, port, bridge.dev); in felix_bridge_leave()
1035 struct ocelot *ocelot = ds->priv; in felix_lag_join() local
1038 err = ocelot_port_lag_join(ocelot, port, lag.dev, info, extack); in felix_lag_join()
1052 struct ocelot *ocelot = ds->priv; in felix_lag_leave() local
1054 ocelot_port_lag_leave(ocelot, port, lag.dev); in felix_lag_leave()
1066 struct ocelot *ocelot = ds->priv; in felix_lag_change() local
1068 ocelot_port_lag_change(ocelot, port, dp->lag_tx_enabled); in felix_lag_change()
1077 struct ocelot *ocelot = ds->priv; in felix_vlan_prepare() local
1078 u16 flags = vlan->flags; in felix_vlan_prepare()
1080 /* Ocelot switches copy frames as-is to the CPU, so the flags: in felix_vlan_prepare()
1081 * egress-untagged or not, pvid or not, make no difference. This in felix_vlan_prepare()
1084 * Just accept any configuration, and don't let ocelot deny installing in felix_vlan_prepare()
1088 if (port == ocelot->npi) in felix_vlan_prepare()
1091 return ocelot_vlan_prepare(ocelot, port, vlan->vid, in felix_vlan_prepare()
1100 struct ocelot *ocelot = ds->priv; in felix_vlan_filtering() local
1105 err = ocelot_port_vlan_filtering(ocelot, port, enabled, extack); in felix_vlan_filtering()
1109 felix = ocelot_to_felix(ocelot); in felix_vlan_filtering()
1110 using_tag_8021q = felix->tag_proto == DSA_TAG_PROTO_OCELOT_8021Q; in felix_vlan_filtering()
1124 struct ocelot *ocelot = ds->priv; in felix_vlan_add() local
1125 u16 flags = vlan->flags; in felix_vlan_add()
1132 return ocelot_vlan_add(ocelot, port, vlan->vid, in felix_vlan_add()
1140 struct ocelot *ocelot = ds->priv; in felix_vlan_del() local
1142 return ocelot_vlan_del(ocelot, port, vlan->vid); in felix_vlan_del()
1148 struct ocelot *ocelot = ds->priv; in felix_phylink_get_caps() local
1150 config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in felix_phylink_get_caps()
1154 __set_bit(ocelot->ports[port]->phy_mode, in felix_phylink_get_caps()
1155 config->supported_interfaces); in felix_phylink_get_caps()
1163 struct ocelot *ocelot = dp->ds->priv; in felix_phylink_mac_config() local
1164 int port = dp->index; in felix_phylink_mac_config()
1167 felix = ocelot_to_felix(ocelot); in felix_phylink_mac_config()
1169 if (felix->info->phylink_mac_config) in felix_phylink_mac_config()
1170 felix->info->phylink_mac_config(ocelot, port, mode, state); in felix_phylink_mac_config()
1178 struct ocelot *ocelot = dp->ds->priv; in felix_phylink_mac_select_pcs() local
1180 int port = dp->index; in felix_phylink_mac_select_pcs()
1183 felix = ocelot_to_felix(ocelot); in felix_phylink_mac_select_pcs()
1185 if (felix->pcs && felix->pcs[port]) in felix_phylink_mac_select_pcs()
1186 pcs = felix->pcs[port]; in felix_phylink_mac_select_pcs()
1196 struct ocelot *ocelot = dp->ds->priv; in felix_phylink_mac_link_down() local
1197 int port = dp->index; in felix_phylink_mac_link_down()
1200 felix = ocelot_to_felix(ocelot); in felix_phylink_mac_link_down()
1202 ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface, in felix_phylink_mac_link_down()
1203 felix->info->quirks); in felix_phylink_mac_link_down()
1214 struct ocelot *ocelot = dp->ds->priv; in felix_phylink_mac_link_up() local
1215 int port = dp->index; in felix_phylink_mac_link_up()
1218 felix = ocelot_to_felix(ocelot); in felix_phylink_mac_link_up()
1220 ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode, in felix_phylink_mac_link_up()
1222 felix->info->quirks); in felix_phylink_mac_link_up()
1224 if (felix->info->port_sched_speed_set) in felix_phylink_mac_link_up()
1225 felix->info->port_sched_speed_set(ocelot, port, speed); in felix_phylink_mac_link_up()
1232 struct ocelot *ocelot = ds->priv; in felix_port_enable() local
1237 if (ocelot->npi >= 0) { in felix_port_enable()
1240 if (felix_cpu_port_for_conduit(ds, conduit) != ocelot->npi) { in felix_port_enable()
1241 dev_err(ds->dev, "Multiple conduits are not allowed\n"); in felix_port_enable()
1242 return -EINVAL; in felix_port_enable()
1249 static void felix_port_qos_map_init(struct ocelot *ocelot, int port) in felix_port_qos_map_init() argument
1253 ocelot_rmw_gix(ocelot, in felix_port_qos_map_init()
1260 ocelot_rmw_ix(ocelot, in felix_port_qos_map_init()
1273 struct ocelot *ocelot = ds->priv; in felix_get_stats64() local
1275 ocelot_port_get_stats64(ocelot, port, stats); in felix_get_stats64()
1281 struct ocelot *ocelot = ds->priv; in felix_get_pause_stats() local
1283 ocelot_port_get_pause_stats(ocelot, port, pause_stats); in felix_get_pause_stats()
1290 struct ocelot *ocelot = ds->priv; in felix_get_rmon_stats() local
1292 ocelot_port_get_rmon_stats(ocelot, port, rmon_stats, ranges); in felix_get_rmon_stats()
1298 struct ocelot *ocelot = ds->priv; in felix_get_eth_ctrl_stats() local
1300 ocelot_port_get_eth_ctrl_stats(ocelot, port, ctrl_stats); in felix_get_eth_ctrl_stats()
1306 struct ocelot *ocelot = ds->priv; in felix_get_eth_mac_stats() local
1308 ocelot_port_get_eth_mac_stats(ocelot, port, mac_stats); in felix_get_eth_mac_stats()
1314 struct ocelot *ocelot = ds->priv; in felix_get_eth_phy_stats() local
1316 ocelot_port_get_eth_phy_stats(ocelot, port, phy_stats); in felix_get_eth_phy_stats()
1322 struct ocelot *ocelot = ds->priv; in felix_get_strings() local
1324 return ocelot_get_strings(ocelot, port, stringset, data); in felix_get_strings()
1329 struct ocelot *ocelot = ds->priv; in felix_get_ethtool_stats() local
1331 ocelot_get_ethtool_stats(ocelot, port, data); in felix_get_ethtool_stats()
1336 struct ocelot *ocelot = ds->priv; in felix_get_sset_count() local
1338 return ocelot_get_sset_count(ocelot, port, sset); in felix_get_sset_count()
1344 struct ocelot *ocelot = ds->priv; in felix_get_ts_info() local
1346 return ocelot_get_ts_info(ocelot, port, info); in felix_get_ts_info()
1361 u32 modes = felix->info->port_modes[port]; in felix_validate_phy_mode()
1365 return -EOPNOTSUPP; in felix_validate_phy_mode()
1372 struct device *dev = felix->ocelot.dev; in felix_parse_ports_node()
1383 return -ENODEV; in felix_parse_ports_node()
1389 dev_err(dev, "Failed to read phy-mode or " in felix_parse_ports_node()
1390 "phy-interface-type property for port %d\n", in felix_parse_ports_node()
1392 return -ENODEV; in felix_parse_ports_node()
1402 * best-effort to bring up as many ports as possible. in felix_parse_ports_node()
1415 struct device *dev = felix->ocelot.dev; in felix_parse_dt()
1420 switch_node = dev->of_node; in felix_parse_dt()
1424 ports_node = of_get_child_by_name(switch_node, "ethernet-ports"); in felix_parse_dt()
1426 dev_err(dev, "Incorrect bindings: absent \"ports\" or \"ethernet-ports\" node\n"); in felix_parse_dt()
1427 return -ENODEV; in felix_parse_dt()
1439 struct ocelot *ocelot = &felix->ocelot; in felix_request_regmap_by_name() local
1447 if (!felix->info->resources) in felix_request_regmap_by_name()
1448 return dev_get_regmap(ocelot->dev->parent, resource_name); in felix_request_regmap_by_name()
1450 for (i = 0; i < felix->info->num_resources; i++) { in felix_request_regmap_by_name()
1451 if (strcmp(resource_name, felix->info->resources[i].name)) in felix_request_regmap_by_name()
1454 memcpy(&res, &felix->info->resources[i], sizeof(res)); in felix_request_regmap_by_name()
1455 res.start += felix->switch_base; in felix_request_regmap_by_name()
1456 res.end += felix->switch_base; in felix_request_regmap_by_name()
1458 return ocelot_regmap_init(ocelot, &res); in felix_request_regmap_by_name()
1461 return ERR_PTR(-ENOENT); in felix_request_regmap_by_name()
1467 const char *resource_name = felix->info->resource_names[target]; in felix_request_regmap()
1489 struct ocelot *ocelot = &felix->ocelot; in felix_init_structs() local
1494 ocelot->num_phys_ports = num_phys_ports; in felix_init_structs()
1495 ocelot->ports = devm_kcalloc(ocelot->dev, num_phys_ports, in felix_init_structs()
1497 if (!ocelot->ports) in felix_init_structs()
1498 return -ENOMEM; in felix_init_structs()
1500 ocelot->map = felix->info->map; in felix_init_structs()
1501 ocelot->num_mact_rows = felix->info->num_mact_rows; in felix_init_structs()
1502 ocelot->vcap = felix->info->vcap; in felix_init_structs()
1503 ocelot->vcap_pol.base = felix->info->vcap_pol_base; in felix_init_structs()
1504 ocelot->vcap_pol.max = felix->info->vcap_pol_max; in felix_init_structs()
1505 ocelot->vcap_pol.base2 = felix->info->vcap_pol_base2; in felix_init_structs()
1506 ocelot->vcap_pol.max2 = felix->info->vcap_pol_max2; in felix_init_structs()
1507 ocelot->ops = felix->info->ops; in felix_init_structs()
1508 ocelot->npi_inj_prefix = OCELOT_TAG_PREFIX_SHORT; in felix_init_structs()
1509 ocelot->npi_xtr_prefix = OCELOT_TAG_PREFIX_SHORT; in felix_init_structs()
1510 ocelot->devlink = felix->ds->devlink; in felix_init_structs()
1515 return -ENOMEM; in felix_init_structs()
1526 dev_err(ocelot->dev, in felix_init_structs()
1533 ocelot->targets[i] = target; in felix_init_structs()
1536 err = ocelot_regfields_init(ocelot, felix->info->regfields); in felix_init_structs()
1538 dev_err(ocelot->dev, "failed to init reg fields map\n"); in felix_init_structs()
1546 ocelot_port = devm_kzalloc(ocelot->dev, in felix_init_structs()
1550 dev_err(ocelot->dev, in felix_init_structs()
1553 return -ENOMEM; in felix_init_structs()
1558 dev_err(ocelot->dev, in felix_init_structs()
1565 ocelot_port->phy_mode = port_phy_modes[port]; in felix_init_structs()
1566 ocelot_port->ocelot = ocelot; in felix_init_structs()
1567 ocelot_port->target = target; in felix_init_structs()
1568 ocelot_port->index = port; in felix_init_structs()
1569 ocelot->ports[port] = ocelot_port; in felix_init_structs()
1574 if (felix->info->mdio_bus_alloc) { in felix_init_structs()
1575 err = felix->info->mdio_bus_alloc(ocelot); in felix_init_structs()
1583 static void ocelot_port_purge_txtstamp_skb(struct ocelot *ocelot, int port, in ocelot_port_purge_txtstamp_skb() argument
1586 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_purge_txtstamp_skb()
1587 struct sk_buff *clone = OCELOT_SKB_CB(skb)->clone; in ocelot_port_purge_txtstamp_skb()
1594 spin_lock_irqsave(&ocelot_port->tx_skbs.lock, flags); in ocelot_port_purge_txtstamp_skb()
1596 skb_queue_walk_safe(&ocelot_port->tx_skbs, skb, skb_tmp) { in ocelot_port_purge_txtstamp_skb()
1599 __skb_unlink(skb, &ocelot_port->tx_skbs); in ocelot_port_purge_txtstamp_skb()
1604 spin_unlock_irqrestore(&ocelot_port->tx_skbs.lock, flags); in ocelot_port_purge_txtstamp_skb()
1616 struct dsa_switch *ds = xmit_work->dp->ds; in felix_port_deferred_xmit()
1617 struct sk_buff *skb = xmit_work->skb; in felix_port_deferred_xmit()
1619 struct ocelot *ocelot = ds->priv; in felix_port_deferred_xmit() local
1620 int port = xmit_work->dp->index; in felix_port_deferred_xmit()
1623 ocelot_lock_inj_grp(ocelot, 0); in felix_port_deferred_xmit()
1626 if (ocelot_can_inject(ocelot, 0)) in felix_port_deferred_xmit()
1630 } while (--retries); in felix_port_deferred_xmit()
1633 ocelot_unlock_inj_grp(ocelot, 0); in felix_port_deferred_xmit()
1634 dev_err(ocelot->dev, "port %d failed to inject skb\n", in felix_port_deferred_xmit()
1636 ocelot_port_purge_txtstamp_skb(ocelot, port, skb); in felix_port_deferred_xmit()
1641 ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb); in felix_port_deferred_xmit()
1643 ocelot_unlock_inj_grp(ocelot, 0); in felix_port_deferred_xmit()
1657 tagger_data->xmit_work_fn = felix_port_deferred_xmit; in felix_connect_tag_protocol()
1663 return -EPROTONOSUPPORT; in felix_connect_tag_protocol()
1669 struct ocelot *ocelot = ds->priv; in felix_setup() local
1670 struct felix *felix = ocelot_to_felix(ocelot); in felix_setup()
1674 err = felix_init_structs(felix, ds->num_ports); in felix_setup()
1678 if (ocelot->targets[HSIO]) in felix_setup()
1679 ocelot_pll5_init(ocelot); in felix_setup()
1681 err = ocelot_init(ocelot); in felix_setup()
1685 if (ocelot->ptp) { in felix_setup()
1686 err = ocelot_init_timestamp(ocelot, felix->info->ptp_caps); in felix_setup()
1688 dev_err(ocelot->dev, in felix_setup()
1690 ocelot->ptp = 0; in felix_setup()
1695 ocelot_init_port(ocelot, dp->index); in felix_setup()
1697 if (felix->info->configure_serdes) in felix_setup()
1698 felix->info->configure_serdes(ocelot, dp->index, in felix_setup()
1699 dp->dn); in felix_setup()
1704 felix_port_qos_map_init(ocelot, dp->index); in felix_setup()
1707 if (felix->info->request_irq) { in felix_setup()
1708 err = felix->info->request_irq(ocelot); in felix_setup()
1710 dev_err(ocelot->dev, "Failed to request IRQ: %pe\n", in felix_setup()
1716 err = ocelot_devlink_sb_register(ocelot); in felix_setup()
1723 felix_change_tag_protocol(ds, felix->tag_proto); in felix_setup()
1725 ds->mtu_enforcement_ingress = true; in felix_setup()
1726 ds->assisted_learning_on_cpu_port = true; in felix_setup()
1727 ds->fdb_isolation = true; in felix_setup()
1728 ds->max_num_bridges = ds->num_ports; in felix_setup()
1734 ocelot_deinit_port(ocelot, dp->index); in felix_setup()
1736 ocelot_deinit_timestamp(ocelot); in felix_setup()
1737 ocelot_deinit(ocelot); in felix_setup()
1740 if (felix->info->mdio_bus_free) in felix_setup()
1741 felix->info->mdio_bus_free(ocelot); in felix_setup()
1748 struct ocelot *ocelot = ds->priv; in felix_teardown() local
1749 struct felix *felix = ocelot_to_felix(ocelot); in felix_teardown()
1753 if (felix->tag_proto_ops) in felix_teardown()
1754 felix->tag_proto_ops->teardown(ds); in felix_teardown()
1758 ocelot_deinit_port(ocelot, dp->index); in felix_teardown()
1760 ocelot_devlink_sb_unregister(ocelot); in felix_teardown()
1761 ocelot_deinit_timestamp(ocelot); in felix_teardown()
1762 ocelot_deinit(ocelot); in felix_teardown()
1764 if (felix->info->mdio_bus_free) in felix_teardown()
1765 felix->info->mdio_bus_free(ocelot); in felix_teardown()
1771 struct ocelot *ocelot = ds->priv; in felix_hwtstamp_get() local
1773 return ocelot_hwstamp_get(ocelot, port, ifr); in felix_hwtstamp_get()
1779 struct ocelot *ocelot = ds->priv; in felix_hwtstamp_set() local
1780 struct felix *felix = ocelot_to_felix(ocelot); in felix_hwtstamp_set()
1784 err = ocelot_hwstamp_set(ocelot, port, ifr); in felix_hwtstamp_set()
1788 using_tag_8021q = felix->tag_proto == DSA_TAG_PROTO_OCELOT_8021Q; in felix_hwtstamp_set()
1793 static bool felix_check_xtr_pkt(struct ocelot *ocelot) in felix_check_xtr_pkt() argument
1795 struct felix *felix = ocelot_to_felix(ocelot); in felix_check_xtr_pkt()
1798 if (felix->tag_proto != DSA_TAG_PROTO_OCELOT_8021Q) in felix_check_xtr_pkt()
1801 if (!felix->info->quirk_no_xtr_irq) in felix_check_xtr_pkt()
1804 ocelot_lock_xtr_grp(ocelot, grp); in felix_check_xtr_pkt()
1806 while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) { in felix_check_xtr_pkt()
1810 err = ocelot_xtr_poll_frame(ocelot, grp, &skb); in felix_check_xtr_pkt()
1836 dev_err_ratelimited(ocelot->dev, in felix_check_xtr_pkt()
1839 ocelot_drain_cpu_queue(ocelot, 0); in felix_check_xtr_pkt()
1842 ocelot_unlock_xtr_grp(ocelot, grp); in felix_check_xtr_pkt()
1850 u32 tstamp_lo = OCELOT_SKB_CB(skb)->tstamp_lo; in felix_rxtstamp()
1852 struct ocelot *ocelot = ds->priv; in felix_rxtstamp() local
1859 if (!(ocelot->ports[port]->trap_proto & OCELOT_PROTO_PTP_L2)) in felix_rxtstamp()
1864 if (!(ocelot->ports[port]->trap_proto & OCELOT_PROTO_PTP_L4)) in felix_rxtstamp()
1874 if (felix_check_xtr_pkt(ocelot)) { in felix_rxtstamp()
1879 ocelot_ptp_gettime64(&ocelot->ptp_info, &ts); in felix_rxtstamp()
1884 tstamp_hi--; in felix_rxtstamp()
1890 shhwtstamps->hwtstamp = tstamp; in felix_rxtstamp()
1897 struct ocelot *ocelot = ds->priv; in felix_txtstamp() local
1900 if (!ocelot->ptp) in felix_txtstamp()
1903 if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) { in felix_txtstamp()
1904 dev_err_ratelimited(ds->dev, in felix_txtstamp()
1911 OCELOT_SKB_CB(skb)->clone = clone; in felix_txtstamp()
1916 struct ocelot *ocelot = ds->priv; in felix_change_mtu() local
1917 struct ocelot_port *ocelot_port = ocelot->ports[port]; in felix_change_mtu()
1919 ocelot_port_set_maxlen(ocelot, port, new_mtu); in felix_change_mtu()
1921 mutex_lock(&ocelot->fwd_domain_lock); in felix_change_mtu()
1923 if (ocelot_port->taprio && ocelot->ops->tas_guard_bands_update) in felix_change_mtu()
1924 ocelot->ops->tas_guard_bands_update(ocelot, port); in felix_change_mtu()
1926 mutex_unlock(&ocelot->fwd_domain_lock); in felix_change_mtu()
1933 struct ocelot *ocelot = ds->priv; in felix_get_max_mtu() local
1935 return ocelot_get_max_mtu(ocelot, port); in felix_get_max_mtu()
1941 struct ocelot *ocelot = ds->priv; in felix_cls_flower_add() local
1942 struct felix *felix = ocelot_to_felix(ocelot); in felix_cls_flower_add()
1946 err = ocelot_cls_flower_replace(ocelot, port, cls, ingress); in felix_cls_flower_add()
1950 using_tag_8021q = felix->tag_proto == DSA_TAG_PROTO_OCELOT_8021Q; in felix_cls_flower_add()
1958 struct ocelot *ocelot = ds->priv; in felix_cls_flower_del() local
1960 return ocelot_cls_flower_destroy(ocelot, port, cls, ingress); in felix_cls_flower_del()
1966 struct ocelot *ocelot = ds->priv; in felix_cls_flower_stats() local
1968 return ocelot_cls_flower_stats(ocelot, port, cls, ingress); in felix_cls_flower_stats()
1974 struct ocelot *ocelot = ds->priv; in felix_port_policer_add() local
1976 .rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8, in felix_port_policer_add()
1977 .burst = policer->burst, in felix_port_policer_add()
1980 return ocelot_port_policer_add(ocelot, port, &pol); in felix_port_policer_add()
1985 struct ocelot *ocelot = ds->priv; in felix_port_policer_del() local
1987 ocelot_port_policer_del(ocelot, port); in felix_port_policer_del()
1994 struct ocelot *ocelot = ds->priv; in felix_port_mirror_add() local
1996 return ocelot_port_mirror_add(ocelot, port, mirror->to_local_port, in felix_port_mirror_add()
2003 struct ocelot *ocelot = ds->priv; in felix_port_mirror_del() local
2005 ocelot_port_mirror_del(ocelot, port, mirror->ingress); in felix_port_mirror_del()
2012 struct ocelot *ocelot = ds->priv; in felix_port_setup_tc() local
2013 struct felix *felix = ocelot_to_felix(ocelot); in felix_port_setup_tc()
2015 if (felix->info->port_setup_tc) in felix_port_setup_tc()
2016 return felix->info->port_setup_tc(ds, port, type, type_data); in felix_port_setup_tc()
2018 return -EOPNOTSUPP; in felix_port_setup_tc()
2025 struct ocelot *ocelot = ds->priv; in felix_sb_pool_get() local
2027 return ocelot_sb_pool_get(ocelot, sb_index, pool_index, pool_info); in felix_sb_pool_get()
2035 struct ocelot *ocelot = ds->priv; in felix_sb_pool_set() local
2037 return ocelot_sb_pool_set(ocelot, sb_index, pool_index, size, in felix_sb_pool_set()
2045 struct ocelot *ocelot = ds->priv; in felix_sb_port_pool_get() local
2047 return ocelot_sb_port_pool_get(ocelot, port, sb_index, pool_index, in felix_sb_port_pool_get()
2055 struct ocelot *ocelot = ds->priv; in felix_sb_port_pool_set() local
2057 return ocelot_sb_port_pool_set(ocelot, port, sb_index, pool_index, in felix_sb_port_pool_set()
2066 struct ocelot *ocelot = ds->priv; in felix_sb_tc_pool_bind_get() local
2068 return ocelot_sb_tc_pool_bind_get(ocelot, port, sb_index, tc_index, in felix_sb_tc_pool_bind_get()
2079 struct ocelot *ocelot = ds->priv; in felix_sb_tc_pool_bind_set() local
2081 return ocelot_sb_tc_pool_bind_set(ocelot, port, sb_index, tc_index, in felix_sb_tc_pool_bind_set()
2089 struct ocelot *ocelot = ds->priv; in felix_sb_occ_snapshot() local
2091 return ocelot_sb_occ_snapshot(ocelot, sb_index); in felix_sb_occ_snapshot()
2097 struct ocelot *ocelot = ds->priv; in felix_sb_occ_max_clear() local
2099 return ocelot_sb_occ_max_clear(ocelot, sb_index); in felix_sb_occ_max_clear()
2106 struct ocelot *ocelot = ds->priv; in felix_sb_occ_port_pool_get() local
2108 return ocelot_sb_occ_port_pool_get(ocelot, port, sb_index, pool_index, in felix_sb_occ_port_pool_get()
2117 struct ocelot *ocelot = ds->priv; in felix_sb_occ_tc_port_bind_get() local
2119 return ocelot_sb_occ_tc_port_bind_get(ocelot, port, sb_index, tc_index, in felix_sb_occ_tc_port_bind_get()
2126 struct ocelot *ocelot = ds->priv; in felix_mrp_add() local
2128 return ocelot_mrp_add(ocelot, port, mrp); in felix_mrp_add()
2134 struct ocelot *ocelot = ds->priv; in felix_mrp_del() local
2136 return ocelot_mrp_add(ocelot, port, mrp); in felix_mrp_del()
2143 struct ocelot *ocelot = ds->priv; in felix_mrp_add_ring_role() local
2145 return ocelot_mrp_add_ring_role(ocelot, port, mrp); in felix_mrp_add_ring_role()
2152 struct ocelot *ocelot = ds->priv; in felix_mrp_del_ring_role() local
2154 return ocelot_mrp_del_ring_role(ocelot, port, mrp); in felix_mrp_del_ring_role()
2159 struct ocelot *ocelot = ds->priv; in felix_port_get_default_prio() local
2161 return ocelot_port_get_default_prio(ocelot, port); in felix_port_get_default_prio()
2167 struct ocelot *ocelot = ds->priv; in felix_port_set_default_prio() local
2169 return ocelot_port_set_default_prio(ocelot, port, prio); in felix_port_set_default_prio()
2174 struct ocelot *ocelot = ds->priv; in felix_port_get_dscp_prio() local
2176 return ocelot_port_get_dscp_prio(ocelot, port, dscp); in felix_port_get_dscp_prio()
2182 struct ocelot *ocelot = ds->priv; in felix_port_add_dscp_prio() local
2184 return ocelot_port_add_dscp_prio(ocelot, port, dscp, prio); in felix_port_add_dscp_prio()
2190 struct ocelot *ocelot = ds->priv; in felix_port_del_dscp_prio() local
2192 return ocelot_port_del_dscp_prio(ocelot, port, dscp, prio); in felix_port_del_dscp_prio()
2198 struct ocelot *ocelot = ds->priv; in felix_get_mm() local
2200 return ocelot_port_get_mm(ocelot, port, state); in felix_get_mm()
2207 struct ocelot *ocelot = ds->priv; in felix_set_mm() local
2209 return ocelot_port_set_mm(ocelot, port, cfg, extack); in felix_set_mm()
2215 struct ocelot *ocelot = ds->priv; in felix_get_mm_stats() local
2217 ocelot_port_get_mm_stats(ocelot, port, stats); in felix_get_mm_stats()
2314 struct ocelot *ocelot; in felix_register_switch() local
2320 return -ENOMEM; in felix_register_switch()
2324 return -ENOMEM; in felix_register_switch()
2328 ocelot = &felix->ocelot; in felix_register_switch()
2329 ocelot->dev = dev; in felix_register_switch()
2330 ocelot->num_flooding_pgids = num_flooding_pgids; in felix_register_switch()
2331 ocelot->ptp = ptp; in felix_register_switch()
2332 ocelot->mm_supported = mm_supported; in felix_register_switch()
2334 felix->info = info; in felix_register_switch()
2335 felix->switch_base = switch_base; in felix_register_switch()
2336 felix->ds = ds; in felix_register_switch()
2337 felix->tag_proto = init_tag_proto; in felix_register_switch()
2339 ds->dev = dev; in felix_register_switch()
2340 ds->num_ports = info->num_ports; in felix_register_switch()
2341 ds->num_tx_queues = OCELOT_NUM_TC; in felix_register_switch()
2342 ds->ops = &felix_switch_ops; in felix_register_switch()
2343 ds->phylink_mac_ops = &felix_phylink_mac_ops; in felix_register_switch()
2344 ds->priv = ocelot; in felix_register_switch()
2354 struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port) in felix_port_to_netdev() argument
2356 struct felix *felix = ocelot_to_felix(ocelot); in felix_port_to_netdev()
2357 struct dsa_switch *ds = felix->ds; in felix_port_to_netdev()
2362 return dsa_to_port(ds, port)->user; in felix_port_to_netdev()
2372 return -EINVAL; in felix_netdev_to_port()
2374 return dp->index; in felix_netdev_to_port()