Lines Matching +full:hsio +full:- +full:cfg
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
41 return ERR_PTR(-EOPNOTSUPP); in felix_classify_db()
48 struct ocelot *ocelot = ds->priv; in felix_cpu_port_for_conduit()
53 mutex_lock(&ocelot->fwd_domain_lock); 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()
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()
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()
155 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_del_rx()
158 block_vcap_es0 = &ocelot->block[VCAP_ES0]; in felix_tag_8021q_vlan_del_rx()
164 return -ENOENT; in felix_tag_8021q_vlan_del_rx()
177 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_add_tx()
183 return -ENOMEM; in felix_tag_8021q_vlan_add_tx()
188 return -ENOMEM; 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()
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()
244 struct ocelot *ocelot = ds->priv; in felix_tag_8021q_vlan_del_tx()
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()
255 return -ENOENT; in felix_tag_8021q_vlan_del_tx()
265 return -ENOENT; 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()
343 block_vcap_es0 = &ocelot->block[VCAP_ES0]; in felix_update_tag_8021q_rx_rules()
347 cpu_dp->index); 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()
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()
449 ocelot->npi = port; in felix_npi_port_init()
457 ocelot->npi_xtr_prefix); in felix_npi_port_init()
459 ocelot->npi_inj_prefix); in felix_npi_port_init()
468 int unused_port = ocelot->num_phys_ports + 2; in felix_npi_port_deinit()
470 ocelot->npi = -1; in felix_npi_port_deinit()
487 struct ocelot *ocelot = ds->priv; in felix_tag_npi_setup()
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()
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()
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()
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()
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()
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()
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()
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()
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()
677 struct ocelot *ocelot = ds->priv; in felix_set_host_flood()
697 struct ocelot *ocelot = ds->priv; 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()
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()
759 struct ocelot *ocelot = ds->priv; 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()
809 return felix->tag_proto; in felix_get_tag_protocol()
815 struct ocelot *ocelot = ds->priv; 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()
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()
856 struct ocelot *ocelot = ds->priv; 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()
879 struct ocelot *ocelot = ds->priv; in felix_fdb_add()
900 struct ocelot *ocelot = ds->priv; in felix_fdb_del()
920 struct ocelot *ocelot = ds->priv; in felix_lag_fdb_add()
933 struct ocelot *ocelot = ds->priv; in felix_lag_fdb_del()
946 struct ocelot *ocelot = ds->priv; in felix_mdb_add()
955 if (port == ocelot->npi) in felix_mdb_add()
956 port = ocelot->num_phys_ports; in felix_mdb_add()
966 struct ocelot *ocelot = ds->priv; in felix_mdb_del()
975 if (port == ocelot->npi) in felix_mdb_del()
976 port = ocelot->num_phys_ports; in felix_mdb_del()
984 struct ocelot *ocelot = ds->priv; in felix_bridge_stp_state_set()
993 struct ocelot *ocelot = ds->priv; in felix_pre_bridge_flags()
1002 struct ocelot *ocelot = ds->priv; in felix_bridge_flags()
1004 if (port == ocelot->npi) in felix_bridge_flags()
1005 port = ocelot->num_phys_ports; in felix_bridge_flags()
1016 struct ocelot *ocelot = ds->priv; in felix_bridge_join()
1025 struct ocelot *ocelot = ds->priv; in felix_bridge_leave()
1035 struct ocelot *ocelot = ds->priv; in felix_lag_join()
1052 struct ocelot *ocelot = ds->priv; in felix_lag_leave()
1066 struct ocelot *ocelot = ds->priv; in felix_lag_change()
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()
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()
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()
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()
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()
1142 return ocelot_vlan_del(ocelot, port, vlan->vid); in felix_vlan_del()
1148 struct ocelot *ocelot = ds->priv; in felix_phylink_get_caps()
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()
1164 int port = dp->index; 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()
1180 int port = dp->index; 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()
1197 int port = dp->index; 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()
1215 int port = dp->index; 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()
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()
1273 struct ocelot *ocelot = ds->priv; in felix_get_stats64()
1281 struct ocelot *ocelot = ds->priv; in felix_get_pause_stats()
1290 struct ocelot *ocelot = ds->priv; in felix_get_rmon_stats()
1298 struct ocelot *ocelot = ds->priv; in felix_get_eth_ctrl_stats()
1306 struct ocelot *ocelot = ds->priv; in felix_get_eth_mac_stats()
1314 struct ocelot *ocelot = ds->priv; in felix_get_eth_phy_stats()
1322 struct ocelot *ocelot = ds->priv; in felix_get_strings()
1329 struct ocelot *ocelot = ds->priv; in felix_get_ethtool_stats()
1336 struct ocelot *ocelot = ds->priv; in felix_get_sset_count()
1344 struct ocelot *ocelot = ds->priv; 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()
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()
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()
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()
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()
1620 int port = xmit_work->dp->index; in felix_port_deferred_xmit()
1630 } while (--retries); in felix_port_deferred_xmit()
1634 dev_err(ocelot->dev, "port %d failed to inject skb\n", 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()
1674 err = felix_init_structs(felix, ds->num_ports); in felix_setup()
1678 if (ocelot->targets[HSIO]) 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()
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()
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()
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()
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()
1779 struct ocelot *ocelot = ds->priv; in felix_hwtstamp_set()
1788 using_tag_8021q = felix->tag_proto == DSA_TAG_PROTO_OCELOT_8021Q; in felix_hwtstamp_set()
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()
1836 dev_err_ratelimited(ocelot->dev, 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()
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()
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()
1900 if (!ocelot->ptp) 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()
1917 struct ocelot_port *ocelot_port = ocelot->ports[port]; 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()
1941 struct ocelot *ocelot = ds->priv; 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()
1966 struct ocelot *ocelot = ds->priv; in felix_cls_flower_stats()
1974 struct ocelot *ocelot = ds->priv; in felix_port_policer_add()
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()
1985 struct ocelot *ocelot = ds->priv; in felix_port_policer_del()
1994 struct ocelot *ocelot = ds->priv; in felix_port_mirror_add()
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()
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()
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()
2035 struct ocelot *ocelot = ds->priv; in felix_sb_pool_set()
2045 struct ocelot *ocelot = ds->priv; in felix_sb_port_pool_get()
2055 struct ocelot *ocelot = ds->priv; in felix_sb_port_pool_set()
2066 struct ocelot *ocelot = ds->priv; in felix_sb_tc_pool_bind_get()
2079 struct ocelot *ocelot = ds->priv; in felix_sb_tc_pool_bind_set()
2089 struct ocelot *ocelot = ds->priv; in felix_sb_occ_snapshot()
2097 struct ocelot *ocelot = ds->priv; in felix_sb_occ_max_clear()
2106 struct ocelot *ocelot = ds->priv; in felix_sb_occ_port_pool_get()
2117 struct ocelot *ocelot = ds->priv; in felix_sb_occ_tc_port_bind_get()
2126 struct ocelot *ocelot = ds->priv; in felix_mrp_add()
2134 struct ocelot *ocelot = ds->priv; in felix_mrp_del()
2143 struct ocelot *ocelot = ds->priv; in felix_mrp_add_ring_role()
2152 struct ocelot *ocelot = ds->priv; in felix_mrp_del_ring_role()
2159 struct ocelot *ocelot = ds->priv; in felix_port_get_default_prio()
2167 struct ocelot *ocelot = ds->priv; in felix_port_set_default_prio()
2174 struct ocelot *ocelot = ds->priv; in felix_port_get_dscp_prio()
2182 struct ocelot *ocelot = ds->priv; in felix_port_add_dscp_prio()
2190 struct ocelot *ocelot = ds->priv; in felix_port_del_dscp_prio()
2198 struct ocelot *ocelot = ds->priv; in felix_get_mm()
2204 struct ethtool_mm_cfg *cfg, in felix_set_mm() argument
2207 struct ocelot *ocelot = ds->priv; in felix_set_mm()
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()
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()
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()