Lines Matching refs:ocelot
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()
200 struct ocelot *ocelot = priv->port.ocelot; in ocelot_get_devlink_port() local
203 return &ocelot->devlink_ports[port]; in ocelot_get_devlink_port()
210 struct ocelot *ocelot = priv->port.ocelot; in ocelot_setup_tc_cls_flower() local
218 return ocelot_cls_flower_replace(ocelot, port, f, ingress); in ocelot_setup_tc_cls_flower()
220 return ocelot_cls_flower_destroy(ocelot, port, f, ingress); in ocelot_setup_tc_cls_flower()
222 return ocelot_cls_flower_stats(ocelot, port, f, ingress); in ocelot_setup_tc_cls_flower()
234 struct ocelot *ocelot = priv->port.ocelot; in ocelot_setup_tc_cls_matchall_police() local
257 err = ocelot_port_policer_add(ocelot, port, &pol); in ocelot_setup_tc_cls_matchall_police()
275 struct ocelot *ocelot = priv->port.ocelot; in ocelot_setup_tc_cls_matchall_mirred() local
298 err = ocelot_port_mirror_add(ocelot, priv->port.index, in ocelot_setup_tc_cls_matchall_mirred()
315 struct ocelot *ocelot = priv->port.ocelot; in ocelot_del_tc_cls_matchall_police() local
319 err = ocelot_port_policer_del(ocelot, port); in ocelot_del_tc_cls_matchall_police()
336 struct ocelot *ocelot = priv->port.ocelot; in ocelot_del_tc_cls_matchall_mirred() local
339 ocelot_port_mirror_del(ocelot, port, ingress); in ocelot_del_tc_cls_matchall_mirred()
506 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_vlan_vid_add() local
510 ret = ocelot_vlan_add(ocelot, port, vid, pvid, untagged); in ocelot_vlan_vid_add()
515 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, vid, in ocelot_vlan_vid_add()
524 struct ocelot *ocelot = priv->port.ocelot; in ocelot_vlan_vid_del() local
535 ret = ocelot_vlan_del(ocelot, port, vid); in ocelot_vlan_vid_del()
540 ocelot_mact_forget(ocelot, dev->dev_addr, vid); in ocelot_vlan_vid_del()
567 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_xmit() local
572 !ocelot_can_inject(ocelot, 0)) in ocelot_port_xmit()
576 if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { in ocelot_port_xmit()
579 if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) { in ocelot_port_xmit()
591 ocelot_fdma_inject_frame(ocelot, port, rew_op, skb, dev); in ocelot_port_xmit()
593 ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb); in ocelot_port_xmit()
608 struct ocelot *ocelot; member
632 struct ocelot *ocelot = w->ocelot; in ocelot_mact_work() local
636 ocelot_mact_learn(ocelot, w->learn.pgid, w->learn.addr, in ocelot_mact_work()
640 ocelot_mact_forget(ocelot, w->forget.addr, w->forget.vid); in ocelot_mact_work()
649 static int ocelot_enqueue_mact_action(struct ocelot *ocelot, in ocelot_enqueue_mact_action() argument
657 w->ocelot = ocelot; in ocelot_enqueue_mact_action()
659 queue_work(ocelot->owq, &w->work); in ocelot_enqueue_mact_action()
668 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_mc_unsync() local
675 return ocelot_enqueue_mact_action(ocelot, &w); in ocelot_mc_unsync()
682 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_mc_sync() local
691 return ocelot_enqueue_mact_action(ocelot, &w); in ocelot_mc_sync()
697 struct ocelot *ocelot = priv->port.ocelot; in ocelot_set_rx_mode() local
705 val = GENMASK(ocelot->num_phys_ports - 1, 0); in ocelot_set_rx_mode()
706 for_each_nonreserved_multicast_dest_pgid(ocelot, i) in ocelot_set_rx_mode()
707 ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i); in ocelot_set_rx_mode()
716 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_set_mac_address() local
720 ocelot_mact_learn(ocelot, PGID_CPU, addr->sa_data, in ocelot_port_set_mac_address()
723 ocelot_mact_forget(ocelot, dev->dev_addr, OCELOT_STANDALONE_PVID); in ocelot_port_set_mac_address()
733 struct ocelot *ocelot = priv->port.ocelot; in ocelot_get_stats64() local
736 return ocelot_port_get_stats64(ocelot, port, stats); in ocelot_get_stats64()
747 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_fdb_add() local
750 return ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge); in ocelot_port_fdb_add()
760 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_fdb_del() local
763 return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge); in ocelot_port_fdb_del()
815 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_fdb_dump() local
825 ret = ocelot_fdb_dump(ocelot, port, ocelot_port_fdb_do_dump, &dump); in ocelot_port_fdb_dump()
844 static void ocelot_vlan_mode(struct ocelot *ocelot, int port, in ocelot_vlan_mode() argument
850 val = ocelot_read(ocelot, ANA_VLANMASK); in ocelot_vlan_mode()
855 ocelot_write(ocelot, val, ANA_VLANMASK); in ocelot_vlan_mode()
863 struct ocelot *ocelot = priv->port.ocelot; in ocelot_set_features() local
874 ocelot_vlan_mode(ocelot, port, features); in ocelot_set_features()
882 struct ocelot *ocelot = priv->port.ocelot; in ocelot_ioctl() local
888 if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) { in ocelot_ioctl()
891 return ocelot_hwstamp_set(ocelot, port, ifr); in ocelot_ioctl()
893 return ocelot_hwstamp_get(ocelot, port, ifr); in ocelot_ioctl()
904 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_change_mtu() local
906 ocelot_port_set_maxlen(ocelot, priv->port.index, new_mtu); in ocelot_change_mtu()
931 struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port) in ocelot_port_to_netdev() argument
933 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_to_netdev()
966 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_strings() local
969 ocelot_get_strings(ocelot, port, sset, data); in ocelot_port_get_strings()
977 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_ethtool_stats() local
980 ocelot_get_ethtool_stats(ocelot, port, data); in ocelot_port_get_ethtool_stats()
986 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_sset_count() local
989 return ocelot_get_sset_count(ocelot, port, sset); in ocelot_port_get_sset_count()
996 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_get_ts_info() local
999 if (!ocelot->ptp) in ocelot_port_get_ts_info()
1002 return ocelot_get_ts_info(ocelot, port, info); in ocelot_port_get_ts_info()
1014 static void ocelot_port_attr_stp_state_set(struct ocelot *ocelot, int port, in ocelot_port_attr_stp_state_set() argument
1017 ocelot_bridge_stp_state_set(ocelot, port, state); in ocelot_port_attr_stp_state_set()
1020 static void ocelot_port_attr_ageing_set(struct ocelot *ocelot, int port, in ocelot_port_attr_ageing_set() argument
1026 ocelot_set_ageing_time(ocelot, ageing_time); in ocelot_port_attr_ageing_set()
1029 static void ocelot_port_attr_mc_set(struct ocelot *ocelot, int port, bool mc) in ocelot_port_attr_mc_set() argument
1039 ocelot_rmw_gix(ocelot, val, cpu_fwd_mcast, in ocelot_port_attr_mc_set()
1048 struct ocelot *ocelot = priv->port.ocelot; in ocelot_port_attr_set() local
1057 ocelot_port_attr_stp_state_set(ocelot, port, attr->u.stp_state); in ocelot_port_attr_set()
1060 ocelot_port_attr_ageing_set(ocelot, port, attr->u.ageing_time); in ocelot_port_attr_set()
1063 ocelot_port_vlan_filtering(ocelot, port, attr->u.vlan_filtering, in ocelot_port_attr_set()
1067 ocelot_port_attr_mc_set(ocelot, port, !attr->u.mc_disabled); in ocelot_port_attr_set()
1070 err = ocelot_port_pre_bridge_flags(ocelot, port, in ocelot_port_attr_set()
1074 ocelot_port_bridge_flags(ocelot, port, attr->u.brport_flags); in ocelot_port_attr_set()
1089 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_vlan_vid_prepare() local
1092 return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack); in ocelot_vlan_vid_prepare()
1115 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_add_mdb() local
1118 return ocelot_port_mdb_add(ocelot, port, mdb, ocelot_port->bridge); in ocelot_port_obj_add_mdb()
1126 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_del_mdb() local
1129 return ocelot_port_mdb_del(ocelot, port, mdb, ocelot_port->bridge); in ocelot_port_obj_del_mdb()
1137 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_add() local
1140 return ocelot_mrp_add(ocelot, port, mrp); in ocelot_port_obj_mrp_add()
1148 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_del() local
1151 return ocelot_mrp_del(ocelot, port, mrp); in ocelot_port_obj_mrp_del()
1160 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_add_ring_role() local
1163 return ocelot_mrp_add_ring_role(ocelot, port, mrp); in ocelot_port_obj_mrp_add_ring_role()
1172 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_obj_mrp_del_ring_role() local
1175 return ocelot_mrp_del_ring_role(ocelot, port, mrp); in ocelot_port_obj_mrp_del_ring_role()
1242 static void ocelot_inherit_brport_flags(struct ocelot *ocelot, int port, in ocelot_inherit_brport_flags() argument
1254 ocelot_port_bridge_flags(ocelot, port, flags); in ocelot_inherit_brport_flags()
1257 static void ocelot_clear_brport_flags(struct ocelot *ocelot, int port) in ocelot_clear_brport_flags() argument
1264 ocelot_port_bridge_flags(ocelot, port, flags); in ocelot_clear_brport_flags()
1267 static int ocelot_switchdev_sync(struct ocelot *ocelot, int port, in ocelot_switchdev_sync() argument
1275 ocelot_inherit_brport_flags(ocelot, port, brport_dev); in ocelot_switchdev_sync()
1278 ocelot_bridge_stp_state_set(ocelot, port, stp_state); in ocelot_switchdev_sync()
1281 ocelot_port_attr_ageing_set(ocelot, port, ageing_time); in ocelot_switchdev_sync()
1283 return ocelot_port_vlan_filtering(ocelot, port, in ocelot_switchdev_sync()
1288 static int ocelot_switchdev_unsync(struct ocelot *ocelot, int port) in ocelot_switchdev_unsync() argument
1292 err = ocelot_port_vlan_filtering(ocelot, port, false, NULL); in ocelot_switchdev_unsync()
1296 ocelot_clear_brport_flags(ocelot, port); in ocelot_switchdev_unsync()
1298 ocelot_bridge_stp_state_set(ocelot, port, BR_STATE_FORWARDING); in ocelot_switchdev_unsync()
1303 static int ocelot_bridge_num_get(struct ocelot *ocelot, in ocelot_bridge_num_get() argument
1306 int bridge_num = ocelot_bridge_num_find(ocelot, bridge_dev); in ocelot_bridge_num_get()
1310 bridge_num = find_first_zero_bit(&ocelot->bridges, in ocelot_bridge_num_get()
1311 ocelot->num_phys_ports); in ocelot_bridge_num_get()
1313 set_bit(bridge_num, &ocelot->bridges); in ocelot_bridge_num_get()
1319 static void ocelot_bridge_num_put(struct ocelot *ocelot, in ocelot_bridge_num_put() argument
1326 if (!ocelot_bridge_num_find(ocelot, bridge_dev)) in ocelot_bridge_num_put()
1327 clear_bit(bridge_num, &ocelot->bridges); in ocelot_bridge_num_put()
1337 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_bridge_join() local
1341 bridge_num = ocelot_bridge_num_get(ocelot, bridge); in ocelot_netdevice_bridge_join()
1343 err = ocelot_port_bridge_join(ocelot, port, bridge, bridge_num, in ocelot_netdevice_bridge_join()
1355 err = ocelot_switchdev_sync(ocelot, port, brport_dev, bridge, extack); in ocelot_netdevice_bridge_join()
1366 ocelot_port_bridge_leave(ocelot, port, bridge); in ocelot_netdevice_bridge_join()
1368 ocelot_bridge_num_put(ocelot, bridge, bridge_num); in ocelot_netdevice_bridge_join()
1388 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_bridge_leave() local
1393 err = ocelot_switchdev_unsync(ocelot, port); in ocelot_netdevice_bridge_leave()
1397 ocelot_port_bridge_leave(ocelot, port, bridge); in ocelot_netdevice_bridge_leave()
1398 ocelot_bridge_num_put(ocelot, bridge, bridge_num); in ocelot_netdevice_bridge_leave()
1410 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_lag_join() local
1415 err = ocelot_port_lag_join(ocelot, port, bond, info, extack); in ocelot_netdevice_lag_join()
1431 ocelot_port_lag_leave(ocelot, port, bond); in ocelot_netdevice_lag_join()
1452 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_lag_leave() local
1456 ocelot_port_lag_leave(ocelot, port, bond); in ocelot_netdevice_lag_leave()
1567 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_netdevice_changelowerstate() local
1576 ocelot_port_lag_change(ocelot, port, is_active); in ocelot_netdevice_changelowerstate()
1715 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_link_down() local
1718 ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface, in vsc7514_phylink_mac_link_down()
1731 struct ocelot *ocelot = priv->port.ocelot; in vsc7514_phylink_mac_link_up() local
1734 ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode, in vsc7514_phylink_mac_link_up()
1746 static int ocelot_port_phylink_create(struct ocelot *ocelot, int port, in ocelot_port_phylink_create() argument
1749 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_port_phylink_create()
1751 struct device *dev = ocelot->dev; in ocelot_port_phylink_create()
1832 int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target, in ocelot_probe_port() argument
1843 SET_NETDEV_DEV(dev, ocelot->dev); in ocelot_probe_port()
1847 ocelot_port->ocelot = ocelot; in ocelot_probe_port()
1850 ocelot->ports[port] = ocelot_port; in ocelot_probe_port()
1862 eth_hw_addr_gen(dev, ocelot->base_mac, port); in ocelot_probe_port()
1864 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, in ocelot_probe_port()
1867 ocelot_init_port(ocelot, port); in ocelot_probe_port()
1869 err = ocelot_port_phylink_create(ocelot, port, portnp); in ocelot_probe_port()
1873 if (ocelot->fdma) in ocelot_probe_port()
1874 ocelot_fdma_netdev_init(ocelot, dev); in ocelot_probe_port()
1878 dev_err(ocelot->dev, "register_netdev failed\n"); in ocelot_probe_port()
1885 if (ocelot->fdma) in ocelot_probe_port()
1886 ocelot_fdma_netdev_deinit(ocelot, dev); in ocelot_probe_port()
1888 ocelot->ports[port] = NULL; in ocelot_probe_port()
1899 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_release_port() local
1900 struct ocelot_fdma *fdma = ocelot->fdma; in ocelot_release_port()
1905 ocelot_fdma_netdev_deinit(ocelot, priv->dev); in ocelot_release_port()