Lines Matching full:ocelot

2 /* Microsemi Ocelot Switch driver
11 #include <linux/dsa/ocelot.h>
16 #include "ocelot.h"
32 static struct ocelot *devlink_port_to_ocelot(struct devlink_port *dlp) in devlink_port_to_ocelot()
39 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in devlink_port_to_port() local
41 return dlp - ocelot->devlink_ports; in devlink_port_to_port()
48 struct ocelot *ocelot = devlink_priv(dl); in ocelot_devlink_sb_pool_get() local
50 return ocelot_sb_pool_get(ocelot, sb_index, pool_index, pool_info); in ocelot_devlink_sb_pool_get()
58 struct ocelot *ocelot = devlink_priv(dl); in ocelot_devlink_sb_pool_set() local
60 return ocelot_sb_pool_set(ocelot, sb_index, pool_index, size, in ocelot_devlink_sb_pool_set()
68 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in ocelot_devlink_sb_port_pool_get() local
71 return ocelot_sb_port_pool_get(ocelot, port, sb_index, pool_index, in ocelot_devlink_sb_port_pool_get()
80 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in ocelot_devlink_sb_port_pool_set() local
83 return ocelot_sb_port_pool_set(ocelot, port, sb_index, pool_index, in ocelot_devlink_sb_port_pool_set()
93 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in ocelot_devlink_sb_tc_pool_bind_get() local
96 return ocelot_sb_tc_pool_bind_get(ocelot, port, sb_index, tc_index, in ocelot_devlink_sb_tc_pool_bind_get()
108 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in ocelot_devlink_sb_tc_pool_bind_set() local
111 return ocelot_sb_tc_pool_bind_set(ocelot, port, sb_index, tc_index, in ocelot_devlink_sb_tc_pool_bind_set()
119 struct ocelot *ocelot = devlink_priv(dl); in ocelot_devlink_sb_occ_snapshot() local
121 return ocelot_sb_occ_snapshot(ocelot, sb_index); in ocelot_devlink_sb_occ_snapshot()
127 struct ocelot *ocelot = devlink_priv(dl); in ocelot_devlink_sb_occ_max_clear() local
129 return ocelot_sb_occ_max_clear(ocelot, sb_index); in ocelot_devlink_sb_occ_max_clear()
137 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in ocelot_devlink_sb_occ_port_pool_get() local
140 return ocelot_sb_occ_port_pool_get(ocelot, port, sb_index, pool_index, in ocelot_devlink_sb_occ_port_pool_get()
150 struct ocelot *ocelot = devlink_port_to_ocelot(dlp); in ocelot_devlink_sb_occ_tc_port_bind_get() local
153 return ocelot_sb_occ_tc_port_bind_get(ocelot, port, sb_index, in ocelot_devlink_sb_occ_tc_port_bind_get()
171 int ocelot_port_devlink_init(struct ocelot *ocelot, int port, in ocelot_port_devlink_init() argument
174 struct devlink_port *dlp = &ocelot->devlink_ports[port]; in ocelot_port_devlink_init()
175 int id_len = sizeof(ocelot->base_mac); in ocelot_port_devlink_init()
176 struct devlink *dl = ocelot->devlink; in ocelot_port_devlink_init()
180 memcpy(attrs.switch_id.id, &ocelot->base_mac, id_len); in ocelot_port_devlink_init()
190 void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port) in ocelot_port_devlink_teardown() argument
192 struct devlink_port *dlp = &ocelot->devlink_ports[port]; in ocelot_port_devlink_teardown()
201 struct ocelot *ocelot = priv->port.ocelot; in ocelot_setup_tc_cls_flower() local
209 return ocelot_cls_flower_replace(ocelot, port, f, ingress); in ocelot_setup_tc_cls_flower()
211 return ocelot_cls_flower_destroy(ocelot, port, f, ingress); in ocelot_setup_tc_cls_flower()
213 return ocelot_cls_flower_stats(ocelot, port, f, ingress); in ocelot_setup_tc_cls_flower()
225 struct ocelot *ocelot = priv->port.ocelot; in ocelot_setup_tc_cls_matchall_police() local
248 err = ocelot_port_policer_add(ocelot, port, &pol); in ocelot_setup_tc_cls_matchall_police()
266 struct ocelot *ocelot = priv->port.ocelot; in ocelot_setup_tc_cls_matchall_mirred() local
283 "Destination not an ocelot port"); in ocelot_setup_tc_cls_matchall_mirred()
289 err = ocelot_port_mirror_add(ocelot, priv->port.index, in ocelot_setup_tc_cls_matchall_mirred()
306 struct ocelot *ocelot = priv->port.ocelot; in ocelot_del_tc_cls_matchall_police() local
310 err = ocelot_port_policer_del(ocelot, port); in ocelot_del_tc_cls_matchall_police()
327 struct ocelot *ocelot = priv->port.ocelot; in ocelot_del_tc_cls_matchall_mirred() local
330 ocelot_port_mirror_del(ocelot, port, ingress); in ocelot_del_tc_cls_matchall_mirred()
497 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_vlan_vid_add() local
501 ret = ocelot_vlan_add(ocelot, port, vid, pvid, untagged); in ocelot_vlan_vid_add()
506 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, vid, in ocelot_vlan_vid_add()
515 struct ocelot *ocelot = priv->port.ocelot; in ocelot_vlan_vid_del() local
526 ret = ocelot_vlan_del(ocelot, port, vid); in ocelot_vlan_vid_del()
531 ocelot_mact_forget(ocelot, dev->dev_addr, vid); in ocelot_vlan_vid_del()
558 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_xmit() local
563 !ocelot_can_inject(ocelot, 0)) in ocelot_port_xmit()
567 if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { in ocelot_port_xmit()
570 if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) { in ocelot_port_xmit()
582 ocelot_fdma_inject_frame(ocelot, port, rew_op, skb, dev); in ocelot_port_xmit()
584 ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb); in ocelot_port_xmit()
599 struct ocelot *ocelot; member
623 struct ocelot *ocelot = w->ocelot; in ocelot_mact_work() local
627 ocelot_mact_learn(ocelot, w->learn.pgid, w->learn.addr, in ocelot_mact_work()
631 ocelot_mact_forget(ocelot, w->forget.addr, w->forget.vid); in ocelot_mact_work()
640 static int ocelot_enqueue_mact_action(struct ocelot *ocelot, in ocelot_enqueue_mact_action() argument
648 w->ocelot = ocelot; in ocelot_enqueue_mact_action()
650 queue_work(ocelot->owq, &w->work); in ocelot_enqueue_mact_action()
659 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_mc_unsync() local
666 return ocelot_enqueue_mact_action(ocelot, &w); in ocelot_mc_unsync()
673 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_mc_sync() local
682 return ocelot_enqueue_mact_action(ocelot, &w); in ocelot_mc_sync()
688 struct ocelot *ocelot = priv->port.ocelot; in ocelot_set_rx_mode() local
696 val = GENMASK(ocelot->num_phys_ports - 1, 0); in ocelot_set_rx_mode()
697 for_each_nonreserved_multicast_dest_pgid(ocelot, i) in ocelot_set_rx_mode()
698 ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i); in ocelot_set_rx_mode()
707 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_set_mac_address() local
711 ocelot_mact_learn(ocelot, PGID_CPU, addr->sa_data, in ocelot_port_set_mac_address()
714 ocelot_mact_forget(ocelot, dev->dev_addr, OCELOT_STANDALONE_PVID); in ocelot_port_set_mac_address()
724 struct ocelot *ocelot = priv->port.ocelot; in ocelot_get_stats64() local
727 return ocelot_port_get_stats64(ocelot, port, stats); in ocelot_get_stats64()
738 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_fdb_add() local
741 return ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge); in ocelot_port_fdb_add()
751 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_fdb_del() local
754 return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge); in ocelot_port_fdb_del()
807 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_fdb_dump() local
817 ret = ocelot_fdb_dump(ocelot, port, ocelot_port_fdb_do_dump, &dump); in ocelot_port_fdb_dump()
836 static void ocelot_vlan_mode(struct ocelot *ocelot, int port, in ocelot_vlan_mode() argument
842 val = ocelot_read(ocelot, ANA_VLANMASK); in ocelot_vlan_mode()
847 ocelot_write(ocelot, val, ANA_VLANMASK); in ocelot_vlan_mode()
855 struct ocelot *ocelot = priv->port.ocelot; in ocelot_set_features() local
866 ocelot_vlan_mode(ocelot, port, features); in ocelot_set_features()
874 struct ocelot *ocelot = priv->port.ocelot; in ocelot_ioctl() local
880 if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) { in ocelot_ioctl()
883 return ocelot_hwstamp_set(ocelot, port, ifr); in ocelot_ioctl()
885 return ocelot_hwstamp_get(ocelot, port, ifr); in ocelot_ioctl()
896 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_change_mtu() local
898 ocelot_port_set_maxlen(ocelot, priv->port.index, new_mtu); in ocelot_change_mtu()
922 struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port) in ocelot_port_to_netdev() argument
924 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_to_netdev()
957 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_strings() local
960 ocelot_get_strings(ocelot, port, sset, data); in ocelot_port_get_strings()
968 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_ethtool_stats() local
971 ocelot_get_ethtool_stats(ocelot, port, data); in ocelot_port_get_ethtool_stats()
977 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_sset_count() local
980 return ocelot_get_sset_count(ocelot, port, sset); in ocelot_port_get_sset_count()
987 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_ts_info() local
990 if (!ocelot->ptp) in ocelot_port_get_ts_info()
993 return ocelot_get_ts_info(ocelot, port, info); in ocelot_port_get_ts_info()
1000 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_ts_stats() local
1003 ocelot_port_get_ts_stats(ocelot, port, ts_stats); in ocelot_port_ts_stats()
1016 static void ocelot_port_attr_stp_state_set(struct ocelot *ocelot, int port, in ocelot_port_attr_stp_state_set() argument
1019 ocelot_bridge_stp_state_set(ocelot, port, state); in ocelot_port_attr_stp_state_set()
1022 static void ocelot_port_attr_ageing_set(struct ocelot *ocelot, int port, in ocelot_port_attr_ageing_set() argument
1028 ocelot_set_ageing_time(ocelot, ageing_time); in ocelot_port_attr_ageing_set()
1031 static void ocelot_port_attr_mc_set(struct ocelot *ocelot, int port, bool mc) in ocelot_port_attr_mc_set() argument
1041 ocelot_rmw_gix(ocelot, val, cpu_fwd_mcast, in ocelot_port_attr_mc_set()
1050 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_attr_set() local
1059 ocelot_port_attr_stp_state_set(ocelot, port, attr->u.stp_state); in ocelot_port_attr_set()
1062 ocelot_port_attr_ageing_set(ocelot, port, attr->u.ageing_time); in ocelot_port_attr_set()
1065 ocelot_port_vlan_filtering(ocelot, port, attr->u.vlan_filtering, in ocelot_port_attr_set()
1069 ocelot_port_attr_mc_set(ocelot, port, !attr->u.mc_disabled); in ocelot_port_attr_set()
1072 err = ocelot_port_pre_bridge_flags(ocelot, port, in ocelot_port_attr_set()
1076 ocelot_port_bridge_flags(ocelot, port, attr->u.brport_flags); in ocelot_port_attr_set()
1091 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_vlan_vid_prepare() local
1094 return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack); in ocelot_vlan_vid_prepare()
1117 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_add_mdb() local
1120 return ocelot_port_mdb_add(ocelot, port, mdb, ocelot_port->bridge); in ocelot_port_obj_add_mdb()
1128 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_del_mdb() local
1131 return ocelot_port_mdb_del(ocelot, port, mdb, ocelot_port->bridge); in ocelot_port_obj_del_mdb()
1139 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_add() local
1142 return ocelot_mrp_add(ocelot, port, mrp); in ocelot_port_obj_mrp_add()
1150 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_del() local
1153 return ocelot_mrp_del(ocelot, port, mrp); in ocelot_port_obj_mrp_del()
1162 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_add_ring_role() local
1165 return ocelot_mrp_add_ring_role(ocelot, port, mrp); in ocelot_port_obj_mrp_add_ring_role()
1174 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_del_ring_role() local
1177 return ocelot_mrp_del_ring_role(ocelot, port, mrp); in ocelot_port_obj_mrp_del_ring_role()
1244 static void ocelot_inherit_brport_flags(struct ocelot *ocelot, int port, in ocelot_inherit_brport_flags() argument
1256 ocelot_port_bridge_flags(ocelot, port, flags); in ocelot_inherit_brport_flags()
1259 static void ocelot_clear_brport_flags(struct ocelot *ocelot, int port) in ocelot_clear_brport_flags() argument
1266 ocelot_port_bridge_flags(ocelot, port, flags); in ocelot_clear_brport_flags()
1269 static int ocelot_switchdev_sync(struct ocelot *ocelot, int port, in ocelot_switchdev_sync() argument
1277 ocelot_inherit_brport_flags(ocelot, port, brport_dev); in ocelot_switchdev_sync()
1280 ocelot_bridge_stp_state_set(ocelot, port, stp_state); in ocelot_switchdev_sync()
1283 ocelot_port_attr_ageing_set(ocelot, port, ageing_time); in ocelot_switchdev_sync()
1285 return ocelot_port_vlan_filtering(ocelot, port, in ocelot_switchdev_sync()
1290 static int ocelot_switchdev_unsync(struct ocelot *ocelot, int port) in ocelot_switchdev_unsync() argument
1294 err = ocelot_port_vlan_filtering(ocelot, port, false, NULL); in ocelot_switchdev_unsync()
1298 ocelot_clear_brport_flags(ocelot, port); in ocelot_switchdev_unsync()
1300 ocelot_bridge_stp_state_set(ocelot, port, BR_STATE_FORWARDING); in ocelot_switchdev_unsync()
1305 static int ocelot_bridge_num_get(struct ocelot *ocelot, in ocelot_bridge_num_get() argument
1308 int bridge_num = ocelot_bridge_num_find(ocelot, bridge_dev); in ocelot_bridge_num_get()
1312 bridge_num = find_first_zero_bit(&ocelot->bridges, in ocelot_bridge_num_get()
1313 ocelot->num_phys_ports); in ocelot_bridge_num_get()
1315 set_bit(bridge_num, &ocelot->bridges); in ocelot_bridge_num_get()
1321 static void ocelot_bridge_num_put(struct ocelot *ocelot, in ocelot_bridge_num_put() argument
1328 if (!ocelot_bridge_num_find(ocelot, bridge_dev)) in ocelot_bridge_num_put()
1329 clear_bit(bridge_num, &ocelot->bridges); in ocelot_bridge_num_put()
1339 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_bridge_join() local
1343 bridge_num = ocelot_bridge_num_get(ocelot, bridge); in ocelot_netdevice_bridge_join()
1345 err = ocelot_port_bridge_join(ocelot, port, bridge, bridge_num, in ocelot_netdevice_bridge_join()
1357 err = ocelot_switchdev_sync(ocelot, port, brport_dev, bridge, extack); in ocelot_netdevice_bridge_join()
1368 ocelot_port_bridge_leave(ocelot, port, bridge); in ocelot_netdevice_bridge_join()
1370 ocelot_bridge_num_put(ocelot, bridge, bridge_num); in ocelot_netdevice_bridge_join()
1390 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_bridge_leave() local
1395 err = ocelot_switchdev_unsync(ocelot, port); in ocelot_netdevice_bridge_leave()
1399 ocelot_port_bridge_leave(ocelot, port, bridge); in ocelot_netdevice_bridge_leave()
1400 ocelot_bridge_num_put(ocelot, bridge, bridge_num); in ocelot_netdevice_bridge_leave()
1412 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_lag_join() local
1417 err = ocelot_port_lag_join(ocelot, port, bond, info, extack); in ocelot_netdevice_lag_join()
1433 ocelot_port_lag_leave(ocelot, port, bond); in ocelot_netdevice_lag_join()
1454 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_lag_leave() local
1458 ocelot_port_lag_leave(ocelot, port, bond); in ocelot_netdevice_lag_leave()
1569 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_changelowerstate() local
1578 ocelot_port_lag_change(ocelot, port, is_active); in ocelot_netdevice_changelowerstate()
1690 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_config() local
1693 ocelot_phylink_mac_config(ocelot, port, link_an_mode, state); in vsc7514_phylink_mac_config()
1702 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_link_down() local
1705 ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface, in vsc7514_phylink_mac_link_down()
1718 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_link_up() local
1721 ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode, in vsc7514_phylink_mac_link_up()
1732 static int ocelot_port_phylink_create(struct ocelot *ocelot, int port, in ocelot_port_phylink_create() argument
1735 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_phylink_create()
1737 struct device *dev = ocelot->dev; in ocelot_port_phylink_create()
1759 err = ocelot_port_configure_serdes(ocelot, port, portnp); in ocelot_port_phylink_create()
1795 int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target, in ocelot_probe_port() argument
1806 SET_NETDEV_DEV(dev, ocelot->dev); in ocelot_probe_port()
1810 ocelot_port->ocelot = ocelot; in ocelot_probe_port()
1813 ocelot->ports[port] = ocelot_port; in ocelot_probe_port()
1825 eth_hw_addr_gen(dev, ocelot->base_mac, port); in ocelot_probe_port()
1827 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, in ocelot_probe_port()
1830 ocelot_init_port(ocelot, port); in ocelot_probe_port()
1832 err = ocelot_port_phylink_create(ocelot, port, portnp); in ocelot_probe_port()
1836 if (ocelot->fdma) in ocelot_probe_port()
1837 ocelot_fdma_netdev_init(ocelot, dev); in ocelot_probe_port()
1839 SET_NETDEV_DEVLINK_PORT(dev, &ocelot->devlink_ports[port]); in ocelot_probe_port()
1842 dev_err(ocelot->dev, "register_netdev failed\n"); in ocelot_probe_port()
1849 if (ocelot->fdma) in ocelot_probe_port()
1850 ocelot_fdma_netdev_deinit(ocelot, dev); in ocelot_probe_port()
1852 ocelot->ports[port] = NULL; in ocelot_probe_port()
1863 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_release_port() local
1864 struct ocelot_fdma *fdma = ocelot->fdma; in ocelot_release_port()
1869 ocelot_fdma_netdev_deinit(ocelot, priv->dev); in ocelot_release_port()