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()
806 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_fdb_dump() local
816 ret = ocelot_fdb_dump(ocelot, port, ocelot_port_fdb_do_dump, &dump); in ocelot_port_fdb_dump()
835 static void ocelot_vlan_mode(struct ocelot *ocelot, int port, in ocelot_vlan_mode() argument
841 val = ocelot_read(ocelot, ANA_VLANMASK); in ocelot_vlan_mode()
846 ocelot_write(ocelot, val, ANA_VLANMASK); in ocelot_vlan_mode()
854 struct ocelot *ocelot = priv->port.ocelot; in ocelot_set_features() local
865 ocelot_vlan_mode(ocelot, port, features); in ocelot_set_features()
873 struct ocelot *ocelot = priv->port.ocelot; in ocelot_ioctl() local
879 if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) { in ocelot_ioctl()
882 return ocelot_hwstamp_set(ocelot, port, ifr); in ocelot_ioctl()
884 return ocelot_hwstamp_get(ocelot, port, ifr); in ocelot_ioctl()
895 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_change_mtu() local
897 ocelot_port_set_maxlen(ocelot, priv->port.index, new_mtu); in ocelot_change_mtu()
921 struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port) in ocelot_port_to_netdev() argument
923 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_to_netdev()
956 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_strings() local
959 ocelot_get_strings(ocelot, port, sset, data); in ocelot_port_get_strings()
967 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_ethtool_stats() local
970 ocelot_get_ethtool_stats(ocelot, port, data); in ocelot_port_get_ethtool_stats()
976 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_sset_count() local
979 return ocelot_get_sset_count(ocelot, port, sset); in ocelot_port_get_sset_count()
986 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_ts_info() local
989 if (!ocelot->ptp) in ocelot_port_get_ts_info()
992 return ocelot_get_ts_info(ocelot, port, info); in ocelot_port_get_ts_info()
1004 static void ocelot_port_attr_stp_state_set(struct ocelot *ocelot, int port, in ocelot_port_attr_stp_state_set() argument
1007 ocelot_bridge_stp_state_set(ocelot, port, state); in ocelot_port_attr_stp_state_set()
1010 static void ocelot_port_attr_ageing_set(struct ocelot *ocelot, int port, in ocelot_port_attr_ageing_set() argument
1016 ocelot_set_ageing_time(ocelot, ageing_time); in ocelot_port_attr_ageing_set()
1019 static void ocelot_port_attr_mc_set(struct ocelot *ocelot, int port, bool mc) in ocelot_port_attr_mc_set() argument
1029 ocelot_rmw_gix(ocelot, val, cpu_fwd_mcast, in ocelot_port_attr_mc_set()
1038 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_attr_set() local
1047 ocelot_port_attr_stp_state_set(ocelot, port, attr->u.stp_state); in ocelot_port_attr_set()
1050 ocelot_port_attr_ageing_set(ocelot, port, attr->u.ageing_time); in ocelot_port_attr_set()
1053 ocelot_port_vlan_filtering(ocelot, port, attr->u.vlan_filtering, in ocelot_port_attr_set()
1057 ocelot_port_attr_mc_set(ocelot, port, !attr->u.mc_disabled); in ocelot_port_attr_set()
1060 err = ocelot_port_pre_bridge_flags(ocelot, port, in ocelot_port_attr_set()
1064 ocelot_port_bridge_flags(ocelot, port, attr->u.brport_flags); in ocelot_port_attr_set()
1079 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_vlan_vid_prepare() local
1082 return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack); in ocelot_vlan_vid_prepare()
1105 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_add_mdb() local
1108 return ocelot_port_mdb_add(ocelot, port, mdb, ocelot_port->bridge); in ocelot_port_obj_add_mdb()
1116 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_del_mdb() local
1119 return ocelot_port_mdb_del(ocelot, port, mdb, ocelot_port->bridge); in ocelot_port_obj_del_mdb()
1127 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_add() local
1130 return ocelot_mrp_add(ocelot, port, mrp); in ocelot_port_obj_mrp_add()
1138 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_del() local
1141 return ocelot_mrp_del(ocelot, port, mrp); in ocelot_port_obj_mrp_del()
1150 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_add_ring_role() local
1153 return ocelot_mrp_add_ring_role(ocelot, port, mrp); in ocelot_port_obj_mrp_add_ring_role()
1162 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_del_ring_role() local
1165 return ocelot_mrp_del_ring_role(ocelot, port, mrp); in ocelot_port_obj_mrp_del_ring_role()
1232 static void ocelot_inherit_brport_flags(struct ocelot *ocelot, int port, in ocelot_inherit_brport_flags() argument
1244 ocelot_port_bridge_flags(ocelot, port, flags); in ocelot_inherit_brport_flags()
1247 static void ocelot_clear_brport_flags(struct ocelot *ocelot, int port) in ocelot_clear_brport_flags() argument
1254 ocelot_port_bridge_flags(ocelot, port, flags); in ocelot_clear_brport_flags()
1257 static int ocelot_switchdev_sync(struct ocelot *ocelot, int port, in ocelot_switchdev_sync() argument
1265 ocelot_inherit_brport_flags(ocelot, port, brport_dev); in ocelot_switchdev_sync()
1268 ocelot_bridge_stp_state_set(ocelot, port, stp_state); in ocelot_switchdev_sync()
1271 ocelot_port_attr_ageing_set(ocelot, port, ageing_time); in ocelot_switchdev_sync()
1273 return ocelot_port_vlan_filtering(ocelot, port, in ocelot_switchdev_sync()
1278 static int ocelot_switchdev_unsync(struct ocelot *ocelot, int port) in ocelot_switchdev_unsync() argument
1282 err = ocelot_port_vlan_filtering(ocelot, port, false, NULL); in ocelot_switchdev_unsync()
1286 ocelot_clear_brport_flags(ocelot, port); in ocelot_switchdev_unsync()
1288 ocelot_bridge_stp_state_set(ocelot, port, BR_STATE_FORWARDING); in ocelot_switchdev_unsync()
1293 static int ocelot_bridge_num_get(struct ocelot *ocelot, in ocelot_bridge_num_get() argument
1296 int bridge_num = ocelot_bridge_num_find(ocelot, bridge_dev); in ocelot_bridge_num_get()
1300 bridge_num = find_first_zero_bit(&ocelot->bridges, in ocelot_bridge_num_get()
1301 ocelot->num_phys_ports); in ocelot_bridge_num_get()
1303 set_bit(bridge_num, &ocelot->bridges); in ocelot_bridge_num_get()
1309 static void ocelot_bridge_num_put(struct ocelot *ocelot, in ocelot_bridge_num_put() argument
1316 if (!ocelot_bridge_num_find(ocelot, bridge_dev)) in ocelot_bridge_num_put()
1317 clear_bit(bridge_num, &ocelot->bridges); in ocelot_bridge_num_put()
1327 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_bridge_join() local
1331 bridge_num = ocelot_bridge_num_get(ocelot, bridge); in ocelot_netdevice_bridge_join()
1333 err = ocelot_port_bridge_join(ocelot, port, bridge, bridge_num, in ocelot_netdevice_bridge_join()
1345 err = ocelot_switchdev_sync(ocelot, port, brport_dev, bridge, extack); in ocelot_netdevice_bridge_join()
1356 ocelot_port_bridge_leave(ocelot, port, bridge); in ocelot_netdevice_bridge_join()
1358 ocelot_bridge_num_put(ocelot, bridge, bridge_num); in ocelot_netdevice_bridge_join()
1378 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_bridge_leave() local
1383 err = ocelot_switchdev_unsync(ocelot, port); in ocelot_netdevice_bridge_leave()
1387 ocelot_port_bridge_leave(ocelot, port, bridge); in ocelot_netdevice_bridge_leave()
1388 ocelot_bridge_num_put(ocelot, bridge, bridge_num); in ocelot_netdevice_bridge_leave()
1400 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_lag_join() local
1405 err = ocelot_port_lag_join(ocelot, port, bond, info, extack); in ocelot_netdevice_lag_join()
1421 ocelot_port_lag_leave(ocelot, port, bond); in ocelot_netdevice_lag_join()
1442 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_lag_leave() local
1446 ocelot_port_lag_leave(ocelot, port, bond); in ocelot_netdevice_lag_leave()
1557 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_changelowerstate() local
1566 ocelot_port_lag_change(ocelot, port, is_active); in ocelot_netdevice_changelowerstate()
1678 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_config() local
1681 ocelot_phylink_mac_config(ocelot, port, link_an_mode, state); in vsc7514_phylink_mac_config()
1690 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_link_down() local
1693 ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface, in vsc7514_phylink_mac_link_down()
1706 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_link_up() local
1709 ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode, in vsc7514_phylink_mac_link_up()
1720 static int ocelot_port_phylink_create(struct ocelot *ocelot, int port, in ocelot_port_phylink_create() argument
1723 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_phylink_create()
1725 struct device *dev = ocelot->dev; in ocelot_port_phylink_create()
1747 err = ocelot_port_configure_serdes(ocelot, port, portnp); in ocelot_port_phylink_create()
1783 int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target, in ocelot_probe_port() argument
1794 SET_NETDEV_DEV(dev, ocelot->dev); in ocelot_probe_port()
1798 ocelot_port->ocelot = ocelot; in ocelot_probe_port()
1801 ocelot->ports[port] = ocelot_port; in ocelot_probe_port()
1813 eth_hw_addr_gen(dev, ocelot->base_mac, port); in ocelot_probe_port()
1815 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, in ocelot_probe_port()
1818 ocelot_init_port(ocelot, port); in ocelot_probe_port()
1820 err = ocelot_port_phylink_create(ocelot, port, portnp); in ocelot_probe_port()
1824 if (ocelot->fdma) in ocelot_probe_port()
1825 ocelot_fdma_netdev_init(ocelot, dev); in ocelot_probe_port()
1827 SET_NETDEV_DEVLINK_PORT(dev, &ocelot->devlink_ports[port]); in ocelot_probe_port()
1830 dev_err(ocelot->dev, "register_netdev failed\n"); in ocelot_probe_port()
1837 if (ocelot->fdma) in ocelot_probe_port()
1838 ocelot_fdma_netdev_deinit(ocelot, dev); in ocelot_probe_port()
1840 ocelot->ports[port] = NULL; in ocelot_probe_port()
1851 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_release_port() local
1852 struct ocelot_fdma *fdma = ocelot->fdma; in ocelot_release_port()
1857 ocelot_fdma_netdev_deinit(ocelot, priv->dev); in ocelot_release_port()