Lines Matching +full:ocelot +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0
5 * register-compatible with Ocelot and that perform I/O to their host CPU
15 #include <soc/mscc/ocelot.h>
22 #include <linux/pcs-lynx.h>
37 struct ocelot *ocelot = ds->priv; in felix_set_ageing_time() local
39 ocelot_set_ageing_time(ocelot, ageing_time); in felix_set_ageing_time()
47 struct ocelot *ocelot = ds->priv; in felix_fdb_dump() local
49 return ocelot_fdb_dump(ocelot, port, cb, data); in felix_fdb_dump()
55 struct ocelot *ocelot = ds->priv; in felix_fdb_add() local
57 return ocelot_fdb_add(ocelot, port, addr, vid); in felix_fdb_add()
63 struct ocelot *ocelot = ds->priv; in felix_fdb_del() local
65 return ocelot_fdb_del(ocelot, port, addr, vid); in felix_fdb_del()
78 struct ocelot *ocelot = ds->priv; in felix_mdb_add() local
80 ocelot_port_mdb_add(ocelot, port, mdb); in felix_mdb_add()
86 struct ocelot *ocelot = ds->priv; in felix_mdb_del() local
88 return ocelot_port_mdb_del(ocelot, port, mdb); in felix_mdb_del()
94 struct ocelot *ocelot = ds->priv; in felix_bridge_stp_state_set() local
96 return ocelot_bridge_stp_state_set(ocelot, port, state); in felix_bridge_stp_state_set()
102 struct ocelot *ocelot = ds->priv; in felix_bridge_join() local
104 return ocelot_port_bridge_join(ocelot, port, br); in felix_bridge_join()
110 struct ocelot *ocelot = ds->priv; in felix_bridge_leave() local
112 ocelot_port_bridge_leave(ocelot, port, br); in felix_bridge_leave()
125 struct ocelot *ocelot = ds->priv; in felix_vlan_filtering() local
127 return ocelot_port_vlan_filtering(ocelot, port, enabled, trans); in felix_vlan_filtering()
133 struct ocelot *ocelot = ds->priv; in felix_vlan_add() local
134 u16 flags = vlan->flags; in felix_vlan_add()
141 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { in felix_vlan_add()
142 err = ocelot_vlan_add(ocelot, port, vid, in felix_vlan_add()
146 dev_err(ds->dev, "Failed to add VLAN %d to port %d: %d\n", in felix_vlan_add()
156 struct ocelot *ocelot = ds->priv; in felix_vlan_del() local
160 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { in felix_vlan_del()
161 err = ocelot_vlan_del(ocelot, port, vid); in felix_vlan_del()
163 dev_err(ds->dev, "Failed to remove VLAN %d from port %d: %d\n", in felix_vlan_del()
174 struct ocelot *ocelot = ds->priv; in felix_port_enable() local
176 ocelot_port_enable(ocelot, port, phy); in felix_port_enable()
183 struct ocelot *ocelot = ds->priv; in felix_port_disable() local
185 return ocelot_port_disable(ocelot, port); in felix_port_disable()
192 struct ocelot *ocelot = ds->priv; in felix_phylink_validate() local
193 struct felix *felix = ocelot_to_felix(ocelot); in felix_phylink_validate()
195 if (felix->info->phylink_validate) in felix_phylink_validate()
196 felix->info->phylink_validate(ocelot, port, supported, state); in felix_phylink_validate()
203 struct ocelot *ocelot = ds->priv; in felix_phylink_mac_config() local
204 struct felix *felix = ocelot_to_felix(ocelot); in felix_phylink_mac_config()
207 if (felix->pcs[port]) in felix_phylink_mac_config()
208 phylink_set_pcs(dp->pl, &felix->pcs[port]->pcs); in felix_phylink_mac_config()
215 struct ocelot *ocelot = ds->priv; in felix_phylink_mac_link_down() local
216 struct ocelot_port *ocelot_port = ocelot->ports[port]; in felix_phylink_mac_link_down()
222 ocelot_fields_write(ocelot, port, QSYS_SWITCH_PORT_MODE_PORT_ENA, 0); in felix_phylink_mac_link_down()
224 err = ocelot_port_flush(ocelot, port); in felix_phylink_mac_link_down()
226 dev_err(ocelot->dev, "failed to flush port %d: %d\n", in felix_phylink_mac_link_down()
244 struct ocelot *ocelot = ds->priv; in felix_phylink_mac_link_up() local
245 struct ocelot_port *ocelot_port = ocelot->ports[port]; in felix_phylink_mac_link_up()
246 struct felix *felix = ocelot_to_felix(ocelot); in felix_phylink_mac_link_up()
269 mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(1); in felix_phylink_mac_link_up()
272 dev_err(ocelot->dev, "Unsupported speed on port %d: %d\n", in felix_phylink_mac_link_up()
277 /* handle Rx pause in all cases, with 2500base-X this is used for rate in felix_phylink_mac_link_up()
291 ocelot_write_rix(ocelot, mac_fc_cfg, SYS_MAC_FC_CFG, port); in felix_phylink_mac_link_up()
293 ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port); in felix_phylink_mac_link_up()
301 /* Enable receiving frames on the port, and activate auto-learning of in felix_phylink_mac_link_up()
304 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_LEARNAUTO | in felix_phylink_mac_link_up()
310 ocelot_fields_write(ocelot, port, in felix_phylink_mac_link_up()
311 QSYS_SWITCH_PORT_MODE_PORT_ENA, 1); in felix_phylink_mac_link_up()
313 if (felix->info->port_sched_speed_set) in felix_phylink_mac_link_up()
314 felix->info->port_sched_speed_set(ocelot, port, speed); in felix_phylink_mac_link_up()
317 static void felix_port_qos_map_init(struct ocelot *ocelot, int port) in felix_port_qos_map_init() argument
321 ocelot_rmw_gix(ocelot, in felix_port_qos_map_init()
328 ocelot_rmw_ix(ocelot, in felix_port_qos_map_init()
341 struct ocelot *ocelot = ds->priv; in felix_get_strings() local
343 return ocelot_get_strings(ocelot, port, stringset, data); in felix_get_strings()
348 struct ocelot *ocelot = ds->priv; in felix_get_ethtool_stats() local
350 ocelot_get_ethtool_stats(ocelot, port, data); in felix_get_ethtool_stats()
355 struct ocelot *ocelot = ds->priv; in felix_get_sset_count() local
357 return ocelot_get_sset_count(ocelot, port, sset); in felix_get_sset_count()
363 struct ocelot *ocelot = ds->priv; in felix_get_ts_info() local
365 return ocelot_get_ts_info(ocelot, port, info); in felix_get_ts_info()
372 struct ocelot *ocelot = &felix->ocelot; in felix_parse_ports_node() local
373 struct device *dev = felix->ocelot.dev; in felix_parse_ports_node()
386 return -ENODEV; in felix_parse_ports_node()
392 dev_err(dev, "Failed to read phy-mode or " in felix_parse_ports_node()
393 "phy-interface-type property for port %d\n", in felix_parse_ports_node()
396 return -ENODEV; in felix_parse_ports_node()
399 err = felix->info->prevalidate_phy_mode(ocelot, port, phy_mode); in felix_parse_ports_node()
415 struct device *dev = felix->ocelot.dev; in felix_parse_dt()
420 switch_node = dev->of_node; in felix_parse_dt()
425 return -ENODEV; in felix_parse_dt()
436 struct ocelot *ocelot = &felix->ocelot; in felix_init_structs() local
441 ocelot->num_phys_ports = num_phys_ports; in felix_init_structs()
442 ocelot->ports = devm_kcalloc(ocelot->dev, num_phys_ports, in felix_init_structs()
444 if (!ocelot->ports) in felix_init_structs()
445 return -ENOMEM; in felix_init_structs()
447 ocelot->map = felix->info->map; in felix_init_structs()
448 ocelot->stats_layout = felix->info->stats_layout; in felix_init_structs()
449 ocelot->num_stats = felix->info->num_stats; in felix_init_structs()
450 ocelot->shared_queue_sz = felix->info->shared_queue_sz; in felix_init_structs()
451 ocelot->num_mact_rows = felix->info->num_mact_rows; in felix_init_structs()
452 ocelot->vcap = felix->info->vcap; in felix_init_structs()
453 ocelot->ops = felix->info->ops; in felix_init_structs()
454 ocelot->inj_prefix = OCELOT_TAG_PREFIX_SHORT; in felix_init_structs()
455 ocelot->xtr_prefix = OCELOT_TAG_PREFIX_SHORT; in felix_init_structs()
460 return -ENOMEM; in felix_init_structs()
471 if (!felix->info->target_io_res[i].name) in felix_init_structs()
474 memcpy(&res, &felix->info->target_io_res[i], sizeof(res)); in felix_init_structs()
476 res.start += felix->switch_base; in felix_init_structs()
477 res.end += felix->switch_base; in felix_init_structs()
479 target = ocelot_regmap_init(ocelot, &res); in felix_init_structs()
481 dev_err(ocelot->dev, in felix_init_structs()
487 ocelot->targets[i] = target; in felix_init_structs()
490 err = ocelot_regfields_init(ocelot, felix->info->regfields); in felix_init_structs()
492 dev_err(ocelot->dev, "failed to init reg fields map\n"); in felix_init_structs()
502 ocelot_port = devm_kzalloc(ocelot->dev, in felix_init_structs()
506 dev_err(ocelot->dev, in felix_init_structs()
509 return -ENOMEM; in felix_init_structs()
512 memcpy(&res, &felix->info->port_io_res[port], sizeof(res)); in felix_init_structs()
514 res.start += felix->switch_base; in felix_init_structs()
515 res.end += felix->switch_base; in felix_init_structs()
517 target = ocelot_regmap_init(ocelot, &res); in felix_init_structs()
519 dev_err(ocelot->dev, in felix_init_structs()
526 template = devm_kzalloc(ocelot->dev, OCELOT_TOTAL_TAG_LEN, in felix_init_structs()
529 dev_err(ocelot->dev, in felix_init_structs()
532 return -ENOMEM; in felix_init_structs()
535 ocelot_port->phy_mode = port_phy_modes[port]; in felix_init_structs()
536 ocelot_port->ocelot = ocelot; in felix_init_structs()
537 ocelot_port->target = target; in felix_init_structs()
538 ocelot_port->xmit_template = template; in felix_init_structs()
539 ocelot->ports[port] = ocelot_port; in felix_init_structs()
541 felix->info->xmit_template_populate(ocelot, port); in felix_init_structs()
546 if (felix->info->mdio_bus_alloc) { in felix_init_structs()
547 err = felix->info->mdio_bus_alloc(ocelot); in felix_init_structs()
559 static void felix_npi_port_init(struct ocelot *ocelot, int port) in felix_npi_port_init() argument
561 ocelot->npi = port; in felix_npi_port_init()
563 ocelot_write(ocelot, QSYS_EXT_CPU_CFG_EXT_CPUQ_MSK_M | in felix_npi_port_init()
568 ocelot_fields_write(ocelot, port, SYS_PORT_MODE_INCL_XTR_HDR, in felix_npi_port_init()
569 ocelot->xtr_prefix); in felix_npi_port_init()
570 ocelot_fields_write(ocelot, port, SYS_PORT_MODE_INCL_INJ_HDR, in felix_npi_port_init()
571 ocelot->inj_prefix); in felix_npi_port_init()
574 ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 0); in felix_npi_port_init()
578 * devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing
584 struct ocelot *ocelot = ds->priv; in felix_setup() local
585 struct felix *felix = ocelot_to_felix(ocelot); in felix_setup()
588 err = felix_init_structs(felix, ds->num_ports); in felix_setup()
592 err = ocelot_init(ocelot); in felix_setup()
596 if (ocelot->ptp) { in felix_setup()
597 err = ocelot_init_timestamp(ocelot, felix->info->ptp_caps); in felix_setup()
599 dev_err(ocelot->dev, in felix_setup()
601 ocelot->ptp = 0; in felix_setup()
605 for (port = 0; port < ds->num_ports; port++) { in felix_setup()
606 ocelot_init_port(ocelot, port); in felix_setup()
609 felix_npi_port_init(ocelot, port); in felix_setup()
614 felix_port_qos_map_init(ocelot, port); in felix_setup()
618 * unicast - the hardware default value for ANA_FLOODING_FLD_UNICAST in felix_setup()
619 * excludes BIT(ocelot->num_phys_ports), and so does ocelot_init, since in felix_setup()
620 * Ocelot relies on whitelisting MAC addresses towards PGID_CPU. in felix_setup()
622 ocelot_write_rix(ocelot, in felix_setup()
623 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)), in felix_setup()
626 ds->mtu_enforcement_ingress = true; in felix_setup()
627 ds->configure_vlan_while_not_filtering = true; in felix_setup()
634 struct ocelot *ocelot = ds->priv; in felix_teardown() local
635 struct felix *felix = ocelot_to_felix(ocelot); in felix_teardown()
638 ocelot_deinit_timestamp(ocelot); in felix_teardown()
639 ocelot_deinit(ocelot); in felix_teardown()
641 for (port = 0; port < ocelot->num_phys_ports; port++) { in felix_teardown()
645 ocelot_deinit_port(ocelot, port); in felix_teardown()
648 if (felix->info->mdio_bus_free) in felix_teardown()
649 felix->info->mdio_bus_free(ocelot); in felix_teardown()
655 struct ocelot *ocelot = ds->priv; in felix_hwtstamp_get() local
657 return ocelot_hwstamp_get(ocelot, port, ifr); in felix_hwtstamp_get()
663 struct ocelot *ocelot = ds->priv; in felix_hwtstamp_set() local
665 return ocelot_hwstamp_set(ocelot, port, ifr); in felix_hwtstamp_set()
672 struct ocelot *ocelot = ds->priv; in felix_rxtstamp() local
673 u8 *extraction = skb->data - ETH_HLEN - OCELOT_TAG_LEN; in felix_rxtstamp()
678 ocelot_ptp_gettime64(&ocelot->ptp_info, &ts); in felix_rxtstamp()
686 tstamp_hi--; in felix_rxtstamp()
692 shhwtstamps->hwtstamp = tstamp; in felix_rxtstamp()
699 struct ocelot *ocelot = ds->priv; in felix_txtstamp() local
700 struct ocelot_port *ocelot_port = ocelot->ports[port]; in felix_txtstamp()
702 if (ocelot->ptp && (skb_shinfo(clone)->tx_flags & SKBTX_HW_TSTAMP) && in felix_txtstamp()
703 ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { in felix_txtstamp()
704 ocelot_port_add_txtstamp_skb(ocelot, port, clone); in felix_txtstamp()
713 struct ocelot *ocelot = ds->priv; in felix_change_mtu() local
715 ocelot_port_set_maxlen(ocelot, port, new_mtu); in felix_change_mtu()
722 struct ocelot *ocelot = ds->priv; in felix_get_max_mtu() local
724 return ocelot_get_max_mtu(ocelot, port); in felix_get_max_mtu()
730 struct ocelot *ocelot = ds->priv; in felix_cls_flower_add() local
732 return ocelot_cls_flower_replace(ocelot, port, cls, ingress); in felix_cls_flower_add()
738 struct ocelot *ocelot = ds->priv; in felix_cls_flower_del() local
740 return ocelot_cls_flower_destroy(ocelot, port, cls, ingress); in felix_cls_flower_del()
746 struct ocelot *ocelot = ds->priv; in felix_cls_flower_stats() local
748 return ocelot_cls_flower_stats(ocelot, port, cls, ingress); in felix_cls_flower_stats()
754 struct ocelot *ocelot = ds->priv; in felix_port_policer_add() local
756 .rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8, in felix_port_policer_add()
757 .burst = policer->burst, in felix_port_policer_add()
760 return ocelot_port_policer_add(ocelot, port, &pol); in felix_port_policer_add()
765 struct ocelot *ocelot = ds->priv; in felix_port_policer_del() local
767 ocelot_port_policer_del(ocelot, port); in felix_port_policer_del()
774 struct ocelot *ocelot = ds->priv; in felix_port_setup_tc() local
775 struct felix *felix = ocelot_to_felix(ocelot); in felix_port_setup_tc()
777 if (felix->info->port_setup_tc) in felix_port_setup_tc()
778 return felix->info->port_setup_tc(ds, port, type, type_data); in felix_port_setup_tc()
780 return -EOPNOTSUPP; in felix_port_setup_tc()
825 struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port) in felix_port_to_netdev() argument
827 struct felix *felix = ocelot_to_felix(ocelot); in felix_port_to_netdev()
828 struct dsa_switch *ds = felix->ds; in felix_port_to_netdev()
833 return dsa_to_port(ds, port)->slave; in felix_port_to_netdev()
842 return -EINVAL; in felix_netdev_to_port()
844 return dp->index; in felix_netdev_to_port()