Lines Matching refs:ocelot
44 static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot) in ocelot_mact_wait_for_completion() argument
53 val = ocelot_read(ocelot, ANA_TABLES_MACACCESS); in ocelot_mact_wait_for_completion()
63 static void ocelot_mact_select(struct ocelot *ocelot, in ocelot_mact_select() argument
80 ocelot_write(ocelot, macl, ANA_TABLES_MACLDATA); in ocelot_mact_select()
81 ocelot_write(ocelot, mach, ANA_TABLES_MACHDATA); in ocelot_mact_select()
85 static int ocelot_mact_learn(struct ocelot *ocelot, int port, in ocelot_mact_learn() argument
90 ocelot_mact_select(ocelot, mac, vid); in ocelot_mact_learn()
93 ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID | in ocelot_mact_learn()
99 return ocelot_mact_wait_for_completion(ocelot); in ocelot_mact_learn()
102 static int ocelot_mact_forget(struct ocelot *ocelot, in ocelot_mact_forget() argument
106 ocelot_mact_select(ocelot, mac, vid); in ocelot_mact_forget()
109 ocelot_write(ocelot, in ocelot_mact_forget()
113 return ocelot_mact_wait_for_completion(ocelot); in ocelot_mact_forget()
116 static void ocelot_mact_init(struct ocelot *ocelot) in ocelot_mact_init() argument
122 ocelot_rmw(ocelot, 0, in ocelot_mact_init()
129 ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS); in ocelot_mact_init()
132 static inline int ocelot_vlant_wait_for_completion(struct ocelot *ocelot) in ocelot_vlant_wait_for_completion() argument
141 val = ocelot_read(ocelot, ANA_TABLES_VLANACCESS); in ocelot_vlant_wait_for_completion()
151 static int ocelot_vlant_set_mask(struct ocelot *ocelot, u16 vid, u32 mask) in ocelot_vlant_set_mask() argument
154 ocelot_write(ocelot, ANA_TABLES_VLANTIDX_V_INDEX(vid), in ocelot_vlant_set_mask()
157 ocelot_write(ocelot, ANA_TABLES_VLANACCESS_VLAN_PORT_MASK(mask) | in ocelot_vlant_set_mask()
161 return ocelot_vlant_wait_for_completion(ocelot); in ocelot_vlant_set_mask()
167 struct ocelot *ocelot = port->ocelot; in ocelot_vlan_mode() local
172 val = ocelot_read(ocelot, ANA_VLANMASK); in ocelot_vlan_mode()
177 ocelot_write(ocelot, val, ANA_VLANMASK); in ocelot_vlan_mode()
180 static void ocelot_vlan_port_apply(struct ocelot *ocelot, in ocelot_vlan_port_apply() argument
192 ocelot_rmw_gix(ocelot, val, in ocelot_vlan_port_apply()
207 ocelot_write_gix(ocelot, val, ANA_PORT_DROP_CFG, port->chip_port); in ocelot_vlan_port_apply()
220 ocelot_rmw_gix(ocelot, val, in ocelot_vlan_port_apply()
228 ocelot_rmw_gix(ocelot, val, in ocelot_vlan_port_apply()
238 struct ocelot *ocelot = port->ocelot; in ocelot_vlan_vid_add() local
242 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, vid, in ocelot_vlan_vid_add()
246 ocelot->vlan_mask[vid] |= BIT(port->chip_port); in ocelot_vlan_vid_add()
247 ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); in ocelot_vlan_vid_add()
259 ocelot_vlan_port_apply(ocelot, port); in ocelot_vlan_vid_add()
267 struct ocelot *ocelot = port->ocelot; in ocelot_vlan_vid_del() local
278 ocelot_mact_forget(ocelot, dev->dev_addr, vid); in ocelot_vlan_vid_del()
281 ocelot->vlan_mask[vid] &= ~BIT(port->chip_port); in ocelot_vlan_vid_del()
282 ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); in ocelot_vlan_vid_del()
294 ocelot_vlan_port_apply(ocelot, port); in ocelot_vlan_vid_del()
299 static void ocelot_vlan_init(struct ocelot *ocelot) in ocelot_vlan_init() argument
304 ocelot_write(ocelot, ANA_TABLES_VLANACCESS_CMD_INIT, in ocelot_vlan_init()
306 ocelot_vlant_wait_for_completion(ocelot); in ocelot_vlan_init()
310 ocelot->vlan_mask[vid] = 0; in ocelot_vlan_init()
311 ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); in ocelot_vlan_init()
318 ocelot->vlan_mask[0] = GENMASK(ocelot->num_phys_ports - 1, 0); in ocelot_vlan_init()
319 ocelot_vlant_set_mask(ocelot, 0, ocelot->vlan_mask[0]); in ocelot_vlan_init()
322 ocelot_write_gix(ocelot, ANA_PORT_VLAN_CFG_VLAN_VID(0) | in ocelot_vlan_init()
325 ANA_PORT_VLAN_CFG, ocelot->num_phys_ports); in ocelot_vlan_init()
330 ocelot_write(ocelot, GENMASK(9, 0), ANA_VLANMASK); in ocelot_vlan_init()
332 for (port = 0; port < ocelot->num_phys_ports; port++) { in ocelot_vlan_init()
333 ocelot_write_gix(ocelot, 0, REW_PORT_VLAN_CFG, port); in ocelot_vlan_init()
334 ocelot_write_gix(ocelot, 0, REW_TAG_CFG, port); in ocelot_vlan_init()
353 struct ocelot *ocelot = port->ocelot; in ocelot_port_adjust_link() local
438 ocelot_write_gix(ocelot, ANA_PFC_PFC_CFG_FC_LINK_SPEED(speed), in ocelot_port_adjust_link()
445 ocelot_write_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA | in ocelot_port_adjust_link()
450 ocelot_write_rix(ocelot, QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE | in ocelot_port_adjust_link()
456 ocelot_write_rix(ocelot, SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) | in ocelot_port_adjust_link()
462 ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, p); in ocelot_port_adjust_link()
465 atop_wm = (ocelot->shared_queue_sz - 9 * VLAN_ETH_FRAME_LEN) / OCELOT_BUFFER_CELL_SZ; in ocelot_port_adjust_link()
466 ocelot_write_rix(ocelot, ocelot_wm_enc(9 * VLAN_ETH_FRAME_LEN), in ocelot_port_adjust_link()
468 ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG); in ocelot_port_adjust_link()
474 struct ocelot *ocelot = port->ocelot; in ocelot_port_open() local
480 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_LEARNAUTO | in ocelot_port_open()
508 ocelot_rmw_rix(port->ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA, in ocelot_port_stop()
536 struct ocelot *ocelot = port->ocelot; in ocelot_port_xmit() local
542 val = ocelot_read(ocelot, QS_INJ_STATUS); in ocelot_port_xmit()
547 ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) | in ocelot_port_xmit()
556 ocelot_write_rix(ocelot, (__force u32)cpu_to_be32(ifh[i]), in ocelot_port_xmit()
562 ocelot_write_rix(ocelot, ((u32 *)skb->data)[i], QS_INJ_WR, grp); in ocelot_port_xmit()
567 ocelot_write_rix(ocelot, 0, QS_INJ_WR, grp); in ocelot_port_xmit()
572 ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) | in ocelot_port_xmit()
578 ocelot_write_rix(ocelot, 0, QS_INJ_WR, grp); in ocelot_port_xmit()
590 struct ocelot *ocelot = port->ocelot; in ocelot_mact_mc_reset() local
598 ocelot_mact_forget(ocelot, ha->addr, port->pvid); in ocelot_mact_mc_reset()
607 struct ocelot *ocelot = port->ocelot; in ocelot_mact_mc_add() local
616 ocelot_mact_learn(ocelot, PGID_CPU, ha->addr, port->pvid, in ocelot_mact_mc_add()
625 struct ocelot *ocelot = port->ocelot; in ocelot_set_rx_mode() local
634 val = GENMASK(ocelot->num_phys_ports - 1, 0); in ocelot_set_rx_mode()
635 for (i = ocelot->num_phys_ports + 1; i < PGID_CPU; i++) in ocelot_set_rx_mode()
636 ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i); in ocelot_set_rx_mode()
663 struct ocelot *ocelot = port->ocelot; in ocelot_port_set_mac_address() local
667 ocelot_mact_learn(ocelot, PGID_CPU, addr->sa_data, port->pvid, in ocelot_port_set_mac_address()
670 ocelot_mact_forget(ocelot, dev->dev_addr, port->pvid); in ocelot_port_set_mac_address()
680 struct ocelot *ocelot = port->ocelot; in ocelot_get_stats64() local
683 ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port->chip_port), in ocelot_get_stats64()
687 stats->rx_bytes = ocelot_read(ocelot, SYS_COUNT_RX_OCTETS); in ocelot_get_stats64()
688 stats->rx_packets = ocelot_read(ocelot, SYS_COUNT_RX_SHORTS) + in ocelot_get_stats64()
689 ocelot_read(ocelot, SYS_COUNT_RX_FRAGMENTS) + in ocelot_get_stats64()
690 ocelot_read(ocelot, SYS_COUNT_RX_JABBERS) + in ocelot_get_stats64()
691 ocelot_read(ocelot, SYS_COUNT_RX_LONGS) + in ocelot_get_stats64()
692 ocelot_read(ocelot, SYS_COUNT_RX_64) + in ocelot_get_stats64()
693 ocelot_read(ocelot, SYS_COUNT_RX_65_127) + in ocelot_get_stats64()
694 ocelot_read(ocelot, SYS_COUNT_RX_128_255) + in ocelot_get_stats64()
695 ocelot_read(ocelot, SYS_COUNT_RX_256_1023) + in ocelot_get_stats64()
696 ocelot_read(ocelot, SYS_COUNT_RX_1024_1526) + in ocelot_get_stats64()
697 ocelot_read(ocelot, SYS_COUNT_RX_1527_MAX); in ocelot_get_stats64()
698 stats->multicast = ocelot_read(ocelot, SYS_COUNT_RX_MULTICAST); in ocelot_get_stats64()
702 stats->tx_bytes = ocelot_read(ocelot, SYS_COUNT_TX_OCTETS); in ocelot_get_stats64()
703 stats->tx_packets = ocelot_read(ocelot, SYS_COUNT_TX_64) + in ocelot_get_stats64()
704 ocelot_read(ocelot, SYS_COUNT_TX_65_127) + in ocelot_get_stats64()
705 ocelot_read(ocelot, SYS_COUNT_TX_128_511) + in ocelot_get_stats64()
706 ocelot_read(ocelot, SYS_COUNT_TX_512_1023) + in ocelot_get_stats64()
707 ocelot_read(ocelot, SYS_COUNT_TX_1024_1526) + in ocelot_get_stats64()
708 ocelot_read(ocelot, SYS_COUNT_TX_1527_MAX); in ocelot_get_stats64()
709 stats->tx_dropped = ocelot_read(ocelot, SYS_COUNT_TX_DROPS) + in ocelot_get_stats64()
710 ocelot_read(ocelot, SYS_COUNT_TX_AGING); in ocelot_get_stats64()
711 stats->collisions = ocelot_read(ocelot, SYS_COUNT_TX_COLLISION); in ocelot_get_stats64()
719 struct ocelot *ocelot = port->ocelot; in ocelot_fdb_add() local
735 return ocelot_mact_learn(ocelot, port->chip_port, addr, vid, in ocelot_fdb_add()
744 struct ocelot *ocelot = port->ocelot; in ocelot_fdb_del() local
746 return ocelot_mact_forget(ocelot, addr, vid); in ocelot_fdb_del()
801 struct ocelot *ocelot = port->ocelot; in ocelot_mact_read() local
806 ocelot_field_write(ocelot, ANA_TABLES_MACTINDX_M_INDEX, row); in ocelot_mact_read()
807 ocelot_field_write(ocelot, ANA_TABLES_MACTINDX_BUCKET, col); in ocelot_mact_read()
810 ocelot_write(ocelot, in ocelot_mact_read()
814 if (ocelot_mact_wait_for_completion(ocelot)) in ocelot_mact_read()
818 val = ocelot_read(ocelot, ANA_TABLES_MACACCESS); in ocelot_mact_read()
830 macl = ocelot_read(ocelot, ANA_TABLES_MACLDATA); in ocelot_mact_read()
831 mach = ocelot_read(ocelot, ANA_TABLES_MACHDATA); in ocelot_mact_read()
929 struct ocelot *ocelot = port->ocelot; in ocelot_get_strings() local
935 for (i = 0; i < ocelot->num_stats; i++) in ocelot_get_strings()
936 memcpy(data + i * ETH_GSTRING_LEN, ocelot->stats_layout[i].name, in ocelot_get_strings()
943 struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work); in ocelot_check_stats() local
946 mutex_lock(&ocelot->stats_lock); in ocelot_check_stats()
948 for (i = 0; i < ocelot->num_phys_ports; i++) { in ocelot_check_stats()
950 ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); in ocelot_check_stats()
952 for (j = 0; j < ocelot->num_stats; j++) { in ocelot_check_stats()
954 unsigned int idx = i * ocelot->num_stats + j; in ocelot_check_stats()
956 val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, in ocelot_check_stats()
957 ocelot->stats_layout[j].offset); in ocelot_check_stats()
959 if (val < (ocelot->stats[idx] & U32_MAX)) in ocelot_check_stats()
960 ocelot->stats[idx] += (u64)1 << 32; in ocelot_check_stats()
962 ocelot->stats[idx] = (ocelot->stats[idx] & in ocelot_check_stats()
967 cancel_delayed_work(&ocelot->stats_work); in ocelot_check_stats()
968 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, in ocelot_check_stats()
971 mutex_unlock(&ocelot->stats_lock); in ocelot_check_stats()
978 struct ocelot *ocelot = port->ocelot; in ocelot_get_ethtool_stats() local
982 ocelot_check_stats(&ocelot->stats_work.work); in ocelot_get_ethtool_stats()
985 for (i = 0; i < ocelot->num_stats; i++) in ocelot_get_ethtool_stats()
986 *data++ = ocelot->stats[port->chip_port * ocelot->num_stats + i]; in ocelot_get_ethtool_stats()
992 struct ocelot *ocelot = port->ocelot; in ocelot_get_sset_count() local
996 return ocelot->num_stats; in ocelot_get_sset_count()
1011 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_attr_get() local
1015 attr->u.ppid.id_len = sizeof(ocelot->base_mac); in ocelot_port_attr_get()
1016 memcpy(&attr->u.ppid.id, &ocelot->base_mac, in ocelot_port_attr_get()
1030 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_attr_stp_state_set() local
1037 if (!(BIT(ocelot_port->chip_port) & ocelot->bridge_mask)) in ocelot_port_attr_stp_state_set()
1040 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, in ocelot_port_attr_stp_state_set()
1045 ocelot->bridge_fwd_mask |= BIT(ocelot_port->chip_port); in ocelot_port_attr_stp_state_set()
1053 ocelot->bridge_fwd_mask &= ~BIT(ocelot_port->chip_port); in ocelot_port_attr_stp_state_set()
1057 ocelot_write_gix(ocelot, port_cfg, ANA_PORT_PORT_CFG, in ocelot_port_attr_stp_state_set()
1063 for (port = 0; port < ocelot->num_phys_ports; port++) { in ocelot_port_attr_stp_state_set()
1064 if (ocelot->bridge_fwd_mask & BIT(port)) { in ocelot_port_attr_stp_state_set()
1065 unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(port); in ocelot_port_attr_stp_state_set()
1067 for (i = 0; i < ocelot->num_phys_ports; i++) { in ocelot_port_attr_stp_state_set()
1068 unsigned long bond_mask = ocelot->lags[i]; in ocelot_port_attr_stp_state_set()
1079 ocelot_write_rix(ocelot, in ocelot_port_attr_stp_state_set()
1080 BIT(ocelot->num_phys_ports) | mask, in ocelot_port_attr_stp_state_set()
1086 ocelot_write_rix(ocelot, in ocelot_port_attr_stp_state_set()
1087 BIT(ocelot->num_phys_ports), in ocelot_port_attr_stp_state_set()
1098 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_attr_ageing_set() local
1102 ocelot_write(ocelot, ANA_AUTOAGE_AGE_PERIOD(ageing_time / 2), in ocelot_port_attr_ageing_set()
1108 struct ocelot *ocelot = port->ocelot; in ocelot_port_attr_mc_set() local
1109 u32 val = ocelot_read_gix(ocelot, ANA_PORT_CPU_FWD_CFG, in ocelot_port_attr_mc_set()
1121 ocelot_write_gix(ocelot, val, ANA_PORT_CPU_FWD_CFG, port->chip_port); in ocelot_port_attr_mc_set()
1141 ocelot_vlan_port_apply(ocelot_port->ocelot, ocelot_port); in ocelot_port_attr_set()
1188 static struct ocelot_multicast *ocelot_multicast_get(struct ocelot *ocelot, in ocelot_multicast_get() argument
1194 list_for_each_entry(mc, &ocelot->multicast, list) { in ocelot_multicast_get()
1207 struct ocelot *ocelot = port->ocelot; in ocelot_port_obj_add_mdb() local
1216 mc = ocelot_multicast_get(ocelot, mdb->addr, vid); in ocelot_port_obj_add_mdb()
1218 mc = devm_kzalloc(ocelot->dev, sizeof(*mc), GFP_KERNEL); in ocelot_port_obj_add_mdb()
1225 list_add_tail(&mc->list, &ocelot->multicast); in ocelot_port_obj_add_mdb()
1235 ocelot_mact_forget(ocelot, addr, vid); in ocelot_port_obj_add_mdb()
1242 return ocelot_mact_learn(ocelot, 0, addr, vid, ENTRYTYPE_MACv4); in ocelot_port_obj_add_mdb()
1249 struct ocelot *ocelot = port->ocelot; in ocelot_port_obj_del_mdb() local
1257 mc = ocelot_multicast_get(ocelot, mdb->addr, vid); in ocelot_port_obj_del_mdb()
1265 ocelot_mact_forget(ocelot, addr, vid); in ocelot_port_obj_del_mdb()
1270 devm_kfree(ocelot->dev, mc); in ocelot_port_obj_del_mdb()
1277 return ocelot_mact_learn(ocelot, 0, addr, vid, ENTRYTYPE_MACv4); in ocelot_port_obj_del_mdb()
1333 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_bridge_join() local
1335 if (!ocelot->bridge_mask) { in ocelot_port_bridge_join()
1336 ocelot->hw_bridge_dev = bridge; in ocelot_port_bridge_join()
1338 if (ocelot->hw_bridge_dev != bridge) in ocelot_port_bridge_join()
1344 ocelot->bridge_mask |= BIT(ocelot_port->chip_port); in ocelot_port_bridge_join()
1352 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_bridge_leave() local
1354 ocelot->bridge_mask &= ~BIT(ocelot_port->chip_port); in ocelot_port_bridge_leave()
1356 if (!ocelot->bridge_mask) in ocelot_port_bridge_leave()
1357 ocelot->hw_bridge_dev = NULL; in ocelot_port_bridge_leave()
1365 static void ocelot_set_aggr_pgids(struct ocelot *ocelot) in ocelot_set_aggr_pgids() argument
1370 for (port = 0; port < ocelot->num_phys_ports; port++) in ocelot_set_aggr_pgids()
1371 ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port); in ocelot_set_aggr_pgids()
1374 ocelot_write_rix(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0), in ocelot_set_aggr_pgids()
1378 for (lag = 0; lag < ocelot->num_phys_ports; lag++) { in ocelot_set_aggr_pgids()
1383 bond_mask = ocelot->lags[lag]; in ocelot_set_aggr_pgids()
1387 for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) { in ocelot_set_aggr_pgids()
1389 ocelot_write_rix(ocelot, bond_mask, in ocelot_set_aggr_pgids()
1398 ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i); in ocelot_set_aggr_pgids()
1401 ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); in ocelot_set_aggr_pgids()
1406 static void ocelot_setup_lag(struct ocelot *ocelot, int lag) in ocelot_setup_lag() argument
1408 unsigned long bond_mask = ocelot->lags[lag]; in ocelot_setup_lag()
1411 for_each_set_bit(p, &bond_mask, ocelot->num_phys_ports) { in ocelot_setup_lag()
1412 u32 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, p); in ocelot_setup_lag()
1417 ocelot_write_gix(ocelot, port_cfg | in ocelot_setup_lag()
1426 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_lag_join() local
1447 ocelot->lags[p] = bond_mask; in ocelot_port_lag_join()
1451 ocelot->lags[lp] = 0; in ocelot_port_lag_join()
1455 ocelot->lags[lp] |= BIT(p); in ocelot_port_lag_join()
1458 ocelot_setup_lag(ocelot, lag); in ocelot_port_lag_join()
1459 ocelot_set_aggr_pgids(ocelot); in ocelot_port_lag_join()
1467 struct ocelot *ocelot = ocelot_port->ocelot; in ocelot_port_lag_leave() local
1473 for (i = 0; i < ocelot->num_phys_ports; i++) in ocelot_port_lag_leave()
1474 ocelot->lags[i] &= ~BIT(ocelot_port->chip_port); in ocelot_port_lag_leave()
1479 if (ocelot->lags[p]) { in ocelot_port_lag_leave()
1480 int n = __ffs(ocelot->lags[p]); in ocelot_port_lag_leave()
1482 ocelot->lags[n] = ocelot->lags[p]; in ocelot_port_lag_leave()
1483 ocelot->lags[p] = 0; in ocelot_port_lag_leave()
1485 ocelot_setup_lag(ocelot, n); in ocelot_port_lag_leave()
1488 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, p); in ocelot_port_lag_leave()
1490 ocelot_write_gix(ocelot, port_cfg | ANA_PORT_PORT_CFG_PORTID_VAL(p), in ocelot_port_lag_leave()
1493 ocelot_set_aggr_pgids(ocelot); in ocelot_port_lag_leave()
1522 ocelot_vlan_port_apply(ocelot_port->ocelot, in ocelot_netdevice_port_event()
1584 int ocelot_probe_port(struct ocelot *ocelot, u8 port, in ocelot_probe_port() argument
1595 SET_NETDEV_DEV(dev, ocelot->dev); in ocelot_probe_port()
1598 ocelot_port->ocelot = ocelot; in ocelot_probe_port()
1603 ocelot->ports[port] = ocelot_port; in ocelot_probe_port()
1612 memcpy(dev->dev_addr, ocelot->base_mac, ETH_ALEN); in ocelot_probe_port()
1614 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, ocelot_port->pvid, in ocelot_probe_port()
1619 dev_err(ocelot->dev, "register_netdev failed\n"); in ocelot_probe_port()
1624 ocelot_vlan_port_apply(ocelot, ocelot_port); in ocelot_probe_port()
1634 int ocelot_init(struct ocelot *ocelot) in ocelot_init() argument
1637 int i, cpu = ocelot->num_phys_ports; in ocelot_init()
1640 ocelot->lags = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, in ocelot_init()
1642 if (!ocelot->lags) in ocelot_init()
1645 ocelot->stats = devm_kcalloc(ocelot->dev, in ocelot_init()
1646 ocelot->num_phys_ports * ocelot->num_stats, in ocelot_init()
1648 if (!ocelot->stats) in ocelot_init()
1651 mutex_init(&ocelot->stats_lock); in ocelot_init()
1653 dev_name(ocelot->dev)); in ocelot_init()
1654 ocelot->stats_queue = create_singlethread_workqueue(queue_name); in ocelot_init()
1655 if (!ocelot->stats_queue) in ocelot_init()
1658 ocelot_mact_init(ocelot); in ocelot_init()
1659 ocelot_vlan_init(ocelot); in ocelot_init()
1661 for (port = 0; port < ocelot->num_phys_ports; port++) { in ocelot_init()
1663 ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port) | in ocelot_init()
1669 ocelot_write(ocelot, ETH_P_8021AD, SYS_VLAN_ETYPE_CFG); in ocelot_init()
1672 ocelot_write(ocelot, ANA_AGGR_CFG_AC_SMAC_ENA | in ocelot_init()
1680 ocelot_write(ocelot, in ocelot_init()
1685 regmap_field_write(ocelot->regfields[ANA_ADVLEARN_VLAN_CHK], 1); in ocelot_init()
1688 ocelot_write(ocelot, SYS_FRM_AGING_AGE_TX_ENA | in ocelot_init()
1692 ocelot_write_rix(ocelot, ANA_FLOODING_FLD_MULTICAST(PGID_MC) | in ocelot_init()
1696 ocelot_write(ocelot, ANA_FLOODING_IPMC_FLD_MC6_DATA(PGID_MCIPV6) | in ocelot_init()
1702 for (port = 0; port < ocelot->num_phys_ports; port++) { in ocelot_init()
1704 ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port); in ocelot_init()
1706 ocelot_write_gix(ocelot, in ocelot_init()
1711 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_SRC + port); in ocelot_init()
1715 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, cpu); in ocelot_init()
1716 ocelot_write_rix(ocelot, BIT(cpu), ANA_PGID_PGID, PGID_CPU); in ocelot_init()
1717 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_RECV_ENA | in ocelot_init()
1722 for (i = ocelot->num_phys_ports + 1; i < PGID_CPU; i++) { in ocelot_init()
1723 u32 val = ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports - 1, 0)); in ocelot_init()
1725 ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i); in ocelot_init()
1727 ocelot_write_rix(ocelot, in ocelot_init()
1728 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)), in ocelot_init()
1730 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_MCIPV4); in ocelot_init()
1731 ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_MCIPV6); in ocelot_init()
1734 ocelot_write_rix(ocelot, QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE | in ocelot_init()
1738 ocelot_write_rix(ocelot, SYS_PORT_MODE_INCL_XTR_HDR(1) | in ocelot_init()
1743 ocelot_write_rix(ocelot, QS_INJ_GRP_CFG_BYTE_SWAP | in ocelot_init()
1745 ocelot_write_rix(ocelot, QS_XTR_GRP_CFG_BYTE_SWAP | in ocelot_init()
1747 ocelot_write(ocelot, ANA_CPUQ_CFG_CPUQ_MIRROR(2) | in ocelot_init()
1757 ocelot_write_rix(ocelot, ANA_CPUQ_8021_CFG_CPUQ_GARP_VAL(6) | in ocelot_init()
1761 INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats); in ocelot_init()
1762 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, in ocelot_init()
1768 void ocelot_deinit(struct ocelot *ocelot) in ocelot_deinit() argument
1770 destroy_workqueue(ocelot->stats_queue); in ocelot_deinit()
1771 mutex_destroy(&ocelot->stats_lock); in ocelot_deinit()