xref: /openbmc/linux/include/soc/mscc/ocelot.h (revision 7c2c5726)
1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2 /* Copyright (c) 2017 Microsemi Corporation
3  */
4 
5 #ifndef _SOC_MSCC_OCELOT_H
6 #define _SOC_MSCC_OCELOT_H
7 
8 #include <linux/ptp_clock_kernel.h>
9 #include <linux/net_tstamp.h>
10 #include <linux/if_vlan.h>
11 #include <linux/regmap.h>
12 #include <net/dsa.h>
13 
14 /* Port Group IDs (PGID) are masks of destination ports.
15  *
16  * For L2 forwarding, the switch performs 3 lookups in the PGID table for each
17  * frame, and forwards the frame to the ports that are present in the logical
18  * AND of all 3 PGIDs.
19  *
20  * These PGID lookups are:
21  * - In one of PGID[0-63]: for the destination masks. There are 2 paths by
22  *   which the switch selects a destination PGID:
23  *     - The {DMAC, VID} is present in the MAC table. In that case, the
24  *       destination PGID is given by the DEST_IDX field of the MAC table entry
25  *       that matched.
26  *     - The {DMAC, VID} is not present in the MAC table (it is unknown). The
27  *       frame is disseminated as being either unicast, multicast or broadcast,
28  *       and according to that, the destination PGID is chosen as being the
29  *       value contained by ANA_FLOODING_FLD_UNICAST,
30  *       ANA_FLOODING_FLD_MULTICAST or ANA_FLOODING_FLD_BROADCAST.
31  *   The destination PGID can be an unicast set: the first PGIDs, 0 to
32  *   ocelot->num_phys_ports - 1, or a multicast set: the PGIDs from
33  *   ocelot->num_phys_ports to 63. By convention, a unicast PGID corresponds to
34  *   a physical port and has a single bit set in the destination ports mask:
35  *   that corresponding to the port number itself. In contrast, a multicast
36  *   PGID will have potentially more than one single bit set in the destination
37  *   ports mask.
38  * - In one of PGID[64-79]: for the aggregation mask. The switch classifier
39  *   dissects each frame and generates a 4-bit Link Aggregation Code which is
40  *   used for this second PGID table lookup. The goal of link aggregation is to
41  *   hash multiple flows within the same LAG on to different destination ports.
42  *   The first lookup will result in a PGID with all the LAG members present in
43  *   the destination ports mask, and the second lookup, by Link Aggregation
44  *   Code, will ensure that each flow gets forwarded only to a single port out
45  *   of that mask (there are no duplicates).
46  * - In one of PGID[80-90]: for the source mask. The third time, the PGID table
47  *   is indexed with the ingress port (plus 80). These PGIDs answer the
48  *   question "is port i allowed to forward traffic to port j?" If yes, then
49  *   BIT(j) of PGID 80+i will be found set. The third PGID lookup can be used
50  *   to enforce the L2 forwarding matrix imposed by e.g. a Linux bridge.
51  */
52 
53 /* Reserve some destination PGIDs at the end of the range:
54  * PGID_BLACKHOLE: used for not forwarding the frames
55  * PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses
56  *           of the switch port net devices, towards the CPU port module.
57  * PGID_UC: the flooding destinations for unknown unicast traffic.
58  * PGID_MC: the flooding destinations for non-IP multicast traffic.
59  * PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic.
60  * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic.
61  * PGID_BC: the flooding destinations for broadcast traffic.
62  */
63 #define PGID_BLACKHOLE			57
64 #define PGID_CPU			58
65 #define PGID_UC				59
66 #define PGID_MC				60
67 #define PGID_MCIPV4			61
68 #define PGID_MCIPV6			62
69 #define PGID_BC				63
70 
71 #define for_each_unicast_dest_pgid(ocelot, pgid)		\
72 	for ((pgid) = 0;					\
73 	     (pgid) < (ocelot)->num_phys_ports;			\
74 	     (pgid)++)
75 
76 #define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid)	\
77 	for ((pgid) = (ocelot)->num_phys_ports + 1;		\
78 	     (pgid) < PGID_BLACKHOLE;				\
79 	     (pgid)++)
80 
81 #define for_each_aggr_pgid(ocelot, pgid)			\
82 	for ((pgid) = PGID_AGGR;				\
83 	     (pgid) < PGID_SRC;					\
84 	     (pgid)++)
85 
86 /* Aggregation PGIDs, one per Link Aggregation Code */
87 #define PGID_AGGR			64
88 
89 /* Source PGIDs, one per physical port */
90 #define PGID_SRC			80
91 
92 #define OCELOT_NUM_TC			8
93 
94 #define OCELOT_SPEED_2500		0
95 #define OCELOT_SPEED_1000		1
96 #define OCELOT_SPEED_100		2
97 #define OCELOT_SPEED_10			3
98 
99 #define OCELOT_PTP_PINS_NUM		4
100 
101 #define TARGET_OFFSET			24
102 #define REG_MASK			GENMASK(TARGET_OFFSET - 1, 0)
103 #define REG(reg, offset)		[reg & REG_MASK] = offset
104 
105 #define REG_RESERVED_ADDR		0xffffffff
106 #define REG_RESERVED(reg)		REG(reg, REG_RESERVED_ADDR)
107 
108 #define for_each_stat(ocelot, stat)				\
109 	for ((stat) = (ocelot)->stats_layout;			\
110 	     ((stat)->name[0] != '\0');				\
111 	     (stat)++)
112 
113 enum ocelot_target {
114 	ANA = 1,
115 	QS,
116 	QSYS,
117 	REW,
118 	SYS,
119 	S0,
120 	S1,
121 	S2,
122 	HSIO,
123 	PTP,
124 	FDMA,
125 	GCB,
126 	DEV_GMII,
127 	TARGET_MAX,
128 };
129 
130 enum ocelot_reg {
131 	ANA_ADVLEARN = ANA << TARGET_OFFSET,
132 	ANA_VLANMASK,
133 	ANA_PORT_B_DOMAIN,
134 	ANA_ANAGEFIL,
135 	ANA_ANEVENTS,
136 	ANA_STORMLIMIT_BURST,
137 	ANA_STORMLIMIT_CFG,
138 	ANA_ISOLATED_PORTS,
139 	ANA_COMMUNITY_PORTS,
140 	ANA_AUTOAGE,
141 	ANA_MACTOPTIONS,
142 	ANA_LEARNDISC,
143 	ANA_AGENCTRL,
144 	ANA_MIRRORPORTS,
145 	ANA_EMIRRORPORTS,
146 	ANA_FLOODING,
147 	ANA_FLOODING_IPMC,
148 	ANA_SFLOW_CFG,
149 	ANA_PORT_MODE,
150 	ANA_CUT_THRU_CFG,
151 	ANA_PGID_PGID,
152 	ANA_TABLES_ANMOVED,
153 	ANA_TABLES_MACHDATA,
154 	ANA_TABLES_MACLDATA,
155 	ANA_TABLES_STREAMDATA,
156 	ANA_TABLES_MACACCESS,
157 	ANA_TABLES_MACTINDX,
158 	ANA_TABLES_VLANACCESS,
159 	ANA_TABLES_VLANTIDX,
160 	ANA_TABLES_ISDXACCESS,
161 	ANA_TABLES_ISDXTIDX,
162 	ANA_TABLES_ENTRYLIM,
163 	ANA_TABLES_PTP_ID_HIGH,
164 	ANA_TABLES_PTP_ID_LOW,
165 	ANA_TABLES_STREAMACCESS,
166 	ANA_TABLES_STREAMTIDX,
167 	ANA_TABLES_SEQ_HISTORY,
168 	ANA_TABLES_SEQ_MASK,
169 	ANA_TABLES_SFID_MASK,
170 	ANA_TABLES_SFIDACCESS,
171 	ANA_TABLES_SFIDTIDX,
172 	ANA_MSTI_STATE,
173 	ANA_OAM_UPM_LM_CNT,
174 	ANA_SG_ACCESS_CTRL,
175 	ANA_SG_CONFIG_REG_1,
176 	ANA_SG_CONFIG_REG_2,
177 	ANA_SG_CONFIG_REG_3,
178 	ANA_SG_CONFIG_REG_4,
179 	ANA_SG_CONFIG_REG_5,
180 	ANA_SG_GCL_GS_CONFIG,
181 	ANA_SG_GCL_TI_CONFIG,
182 	ANA_SG_STATUS_REG_1,
183 	ANA_SG_STATUS_REG_2,
184 	ANA_SG_STATUS_REG_3,
185 	ANA_PORT_VLAN_CFG,
186 	ANA_PORT_DROP_CFG,
187 	ANA_PORT_QOS_CFG,
188 	ANA_PORT_VCAP_CFG,
189 	ANA_PORT_VCAP_S1_KEY_CFG,
190 	ANA_PORT_VCAP_S2_CFG,
191 	ANA_PORT_PCP_DEI_MAP,
192 	ANA_PORT_CPU_FWD_CFG,
193 	ANA_PORT_CPU_FWD_BPDU_CFG,
194 	ANA_PORT_CPU_FWD_GARP_CFG,
195 	ANA_PORT_CPU_FWD_CCM_CFG,
196 	ANA_PORT_PORT_CFG,
197 	ANA_PORT_POL_CFG,
198 	ANA_PORT_PTP_CFG,
199 	ANA_PORT_PTP_DLY1_CFG,
200 	ANA_PORT_PTP_DLY2_CFG,
201 	ANA_PORT_SFID_CFG,
202 	ANA_PFC_PFC_CFG,
203 	ANA_PFC_PFC_TIMER,
204 	ANA_IPT_OAM_MEP_CFG,
205 	ANA_IPT_IPT,
206 	ANA_PPT_PPT,
207 	ANA_FID_MAP_FID_MAP,
208 	ANA_AGGR_CFG,
209 	ANA_CPUQ_CFG,
210 	ANA_CPUQ_CFG2,
211 	ANA_CPUQ_8021_CFG,
212 	ANA_DSCP_CFG,
213 	ANA_DSCP_REWR_CFG,
214 	ANA_VCAP_RNG_TYPE_CFG,
215 	ANA_VCAP_RNG_VAL_CFG,
216 	ANA_VRAP_CFG,
217 	ANA_VRAP_HDR_DATA,
218 	ANA_VRAP_HDR_MASK,
219 	ANA_DISCARD_CFG,
220 	ANA_FID_CFG,
221 	ANA_POL_PIR_CFG,
222 	ANA_POL_CIR_CFG,
223 	ANA_POL_MODE_CFG,
224 	ANA_POL_PIR_STATE,
225 	ANA_POL_CIR_STATE,
226 	ANA_POL_STATE,
227 	ANA_POL_FLOWC,
228 	ANA_POL_HYST,
229 	ANA_POL_MISC_CFG,
230 	QS_XTR_GRP_CFG = QS << TARGET_OFFSET,
231 	QS_XTR_RD,
232 	QS_XTR_FRM_PRUNING,
233 	QS_XTR_FLUSH,
234 	QS_XTR_DATA_PRESENT,
235 	QS_XTR_CFG,
236 	QS_INJ_GRP_CFG,
237 	QS_INJ_WR,
238 	QS_INJ_CTRL,
239 	QS_INJ_STATUS,
240 	QS_INJ_ERR,
241 	QS_INH_DBG,
242 	QSYS_PORT_MODE = QSYS << TARGET_OFFSET,
243 	QSYS_SWITCH_PORT_MODE,
244 	QSYS_STAT_CNT_CFG,
245 	QSYS_EEE_CFG,
246 	QSYS_EEE_THRES,
247 	QSYS_IGR_NO_SHARING,
248 	QSYS_EGR_NO_SHARING,
249 	QSYS_SW_STATUS,
250 	QSYS_EXT_CPU_CFG,
251 	QSYS_PAD_CFG,
252 	QSYS_CPU_GROUP_MAP,
253 	QSYS_QMAP,
254 	QSYS_ISDX_SGRP,
255 	QSYS_TIMED_FRAME_ENTRY,
256 	QSYS_TFRM_MISC,
257 	QSYS_TFRM_PORT_DLY,
258 	QSYS_TFRM_TIMER_CFG_1,
259 	QSYS_TFRM_TIMER_CFG_2,
260 	QSYS_TFRM_TIMER_CFG_3,
261 	QSYS_TFRM_TIMER_CFG_4,
262 	QSYS_TFRM_TIMER_CFG_5,
263 	QSYS_TFRM_TIMER_CFG_6,
264 	QSYS_TFRM_TIMER_CFG_7,
265 	QSYS_TFRM_TIMER_CFG_8,
266 	QSYS_RED_PROFILE,
267 	QSYS_RES_QOS_MODE,
268 	QSYS_RES_CFG,
269 	QSYS_RES_STAT,
270 	QSYS_EGR_DROP_MODE,
271 	QSYS_EQ_CTRL,
272 	QSYS_EVENTS_CORE,
273 	QSYS_QMAXSDU_CFG_0,
274 	QSYS_QMAXSDU_CFG_1,
275 	QSYS_QMAXSDU_CFG_2,
276 	QSYS_QMAXSDU_CFG_3,
277 	QSYS_QMAXSDU_CFG_4,
278 	QSYS_QMAXSDU_CFG_5,
279 	QSYS_QMAXSDU_CFG_6,
280 	QSYS_QMAXSDU_CFG_7,
281 	QSYS_PREEMPTION_CFG,
282 	QSYS_CIR_CFG,
283 	QSYS_EIR_CFG,
284 	QSYS_SE_CFG,
285 	QSYS_SE_DWRR_CFG,
286 	QSYS_SE_CONNECT,
287 	QSYS_SE_DLB_SENSE,
288 	QSYS_CIR_STATE,
289 	QSYS_EIR_STATE,
290 	QSYS_SE_STATE,
291 	QSYS_HSCH_MISC_CFG,
292 	QSYS_TAG_CONFIG,
293 	QSYS_TAS_PARAM_CFG_CTRL,
294 	QSYS_PORT_MAX_SDU,
295 	QSYS_PARAM_CFG_REG_1,
296 	QSYS_PARAM_CFG_REG_2,
297 	QSYS_PARAM_CFG_REG_3,
298 	QSYS_PARAM_CFG_REG_4,
299 	QSYS_PARAM_CFG_REG_5,
300 	QSYS_GCL_CFG_REG_1,
301 	QSYS_GCL_CFG_REG_2,
302 	QSYS_PARAM_STATUS_REG_1,
303 	QSYS_PARAM_STATUS_REG_2,
304 	QSYS_PARAM_STATUS_REG_3,
305 	QSYS_PARAM_STATUS_REG_4,
306 	QSYS_PARAM_STATUS_REG_5,
307 	QSYS_PARAM_STATUS_REG_6,
308 	QSYS_PARAM_STATUS_REG_7,
309 	QSYS_PARAM_STATUS_REG_8,
310 	QSYS_PARAM_STATUS_REG_9,
311 	QSYS_GCL_STATUS_REG_1,
312 	QSYS_GCL_STATUS_REG_2,
313 	REW_PORT_VLAN_CFG = REW << TARGET_OFFSET,
314 	REW_TAG_CFG,
315 	REW_PORT_CFG,
316 	REW_DSCP_CFG,
317 	REW_PCP_DEI_QOS_MAP_CFG,
318 	REW_PTP_CFG,
319 	REW_PTP_DLY1_CFG,
320 	REW_RED_TAG_CFG,
321 	REW_DSCP_REMAP_DP1_CFG,
322 	REW_DSCP_REMAP_CFG,
323 	REW_STAT_CFG,
324 	REW_REW_STICKY,
325 	REW_PPT,
326 	SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
327 	SYS_COUNT_RX_UNICAST,
328 	SYS_COUNT_RX_MULTICAST,
329 	SYS_COUNT_RX_BROADCAST,
330 	SYS_COUNT_RX_SHORTS,
331 	SYS_COUNT_RX_FRAGMENTS,
332 	SYS_COUNT_RX_JABBERS,
333 	SYS_COUNT_RX_CRC_ALIGN_ERRS,
334 	SYS_COUNT_RX_SYM_ERRS,
335 	SYS_COUNT_RX_64,
336 	SYS_COUNT_RX_65_127,
337 	SYS_COUNT_RX_128_255,
338 	SYS_COUNT_RX_256_1023,
339 	SYS_COUNT_RX_1024_1526,
340 	SYS_COUNT_RX_1527_MAX,
341 	SYS_COUNT_RX_PAUSE,
342 	SYS_COUNT_RX_CONTROL,
343 	SYS_COUNT_RX_LONGS,
344 	SYS_COUNT_RX_CLASSIFIED_DROPS,
345 	SYS_COUNT_TX_OCTETS,
346 	SYS_COUNT_TX_UNICAST,
347 	SYS_COUNT_TX_MULTICAST,
348 	SYS_COUNT_TX_BROADCAST,
349 	SYS_COUNT_TX_COLLISION,
350 	SYS_COUNT_TX_DROPS,
351 	SYS_COUNT_TX_PAUSE,
352 	SYS_COUNT_TX_64,
353 	SYS_COUNT_TX_65_127,
354 	SYS_COUNT_TX_128_511,
355 	SYS_COUNT_TX_512_1023,
356 	SYS_COUNT_TX_1024_1526,
357 	SYS_COUNT_TX_1527_MAX,
358 	SYS_COUNT_TX_AGING,
359 	SYS_RESET_CFG,
360 	SYS_SR_ETYPE_CFG,
361 	SYS_VLAN_ETYPE_CFG,
362 	SYS_PORT_MODE,
363 	SYS_FRONT_PORT_MODE,
364 	SYS_FRM_AGING,
365 	SYS_STAT_CFG,
366 	SYS_SW_STATUS,
367 	SYS_MISC_CFG,
368 	SYS_REW_MAC_HIGH_CFG,
369 	SYS_REW_MAC_LOW_CFG,
370 	SYS_TIMESTAMP_OFFSET,
371 	SYS_CMID,
372 	SYS_PAUSE_CFG,
373 	SYS_PAUSE_TOT_CFG,
374 	SYS_ATOP,
375 	SYS_ATOP_TOT_CFG,
376 	SYS_MAC_FC_CFG,
377 	SYS_MMGT,
378 	SYS_MMGT_FAST,
379 	SYS_EVENTS_DIF,
380 	SYS_EVENTS_CORE,
381 	SYS_CNT,
382 	SYS_PTP_STATUS,
383 	SYS_PTP_TXSTAMP,
384 	SYS_PTP_NXT,
385 	SYS_PTP_CFG,
386 	SYS_RAM_INIT,
387 	SYS_CM_ADDR,
388 	SYS_CM_DATA_WR,
389 	SYS_CM_DATA_RD,
390 	SYS_CM_OP,
391 	SYS_CM_DATA,
392 	PTP_PIN_CFG = PTP << TARGET_OFFSET,
393 	PTP_PIN_TOD_SEC_MSB,
394 	PTP_PIN_TOD_SEC_LSB,
395 	PTP_PIN_TOD_NSEC,
396 	PTP_PIN_WF_HIGH_PERIOD,
397 	PTP_PIN_WF_LOW_PERIOD,
398 	PTP_CFG_MISC,
399 	PTP_CLK_CFG_ADJ_CFG,
400 	PTP_CLK_CFG_ADJ_FREQ,
401 	GCB_SOFT_RST = GCB << TARGET_OFFSET,
402 	GCB_MIIM_MII_STATUS,
403 	GCB_MIIM_MII_CMD,
404 	GCB_MIIM_MII_DATA,
405 	DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET,
406 	DEV_PORT_MISC,
407 	DEV_EVENTS,
408 	DEV_EEE_CFG,
409 	DEV_RX_PATH_DELAY,
410 	DEV_TX_PATH_DELAY,
411 	DEV_PTP_PREDICT_CFG,
412 	DEV_MAC_ENA_CFG,
413 	DEV_MAC_MODE_CFG,
414 	DEV_MAC_MAXLEN_CFG,
415 	DEV_MAC_TAGS_CFG,
416 	DEV_MAC_ADV_CHK_CFG,
417 	DEV_MAC_IFG_CFG,
418 	DEV_MAC_HDX_CFG,
419 	DEV_MAC_DBG_CFG,
420 	DEV_MAC_FC_MAC_LOW_CFG,
421 	DEV_MAC_FC_MAC_HIGH_CFG,
422 	DEV_MAC_STICKY,
423 	PCS1G_CFG,
424 	PCS1G_MODE_CFG,
425 	PCS1G_SD_CFG,
426 	PCS1G_ANEG_CFG,
427 	PCS1G_ANEG_NP_CFG,
428 	PCS1G_LB_CFG,
429 	PCS1G_DBG_CFG,
430 	PCS1G_CDET_CFG,
431 	PCS1G_ANEG_STATUS,
432 	PCS1G_ANEG_NP_STATUS,
433 	PCS1G_LINK_STATUS,
434 	PCS1G_LINK_DOWN_CNT,
435 	PCS1G_STICKY,
436 	PCS1G_DEBUG_STATUS,
437 	PCS1G_LPI_CFG,
438 	PCS1G_LPI_WAKE_ERROR_CNT,
439 	PCS1G_LPI_STATUS,
440 	PCS1G_TSTPAT_MODE_CFG,
441 	PCS1G_TSTPAT_STATUS,
442 	DEV_PCS_FX100_CFG,
443 	DEV_PCS_FX100_STATUS,
444 };
445 
446 enum ocelot_regfield {
447 	ANA_ADVLEARN_VLAN_CHK,
448 	ANA_ADVLEARN_LEARN_MIRROR,
449 	ANA_ANEVENTS_FLOOD_DISCARD,
450 	ANA_ANEVENTS_MSTI_DROP,
451 	ANA_ANEVENTS_ACLKILL,
452 	ANA_ANEVENTS_ACLUSED,
453 	ANA_ANEVENTS_AUTOAGE,
454 	ANA_ANEVENTS_VS2TTL1,
455 	ANA_ANEVENTS_STORM_DROP,
456 	ANA_ANEVENTS_LEARN_DROP,
457 	ANA_ANEVENTS_AGED_ENTRY,
458 	ANA_ANEVENTS_CPU_LEARN_FAILED,
459 	ANA_ANEVENTS_AUTO_LEARN_FAILED,
460 	ANA_ANEVENTS_LEARN_REMOVE,
461 	ANA_ANEVENTS_AUTO_LEARNED,
462 	ANA_ANEVENTS_AUTO_MOVED,
463 	ANA_ANEVENTS_DROPPED,
464 	ANA_ANEVENTS_CLASSIFIED_DROP,
465 	ANA_ANEVENTS_CLASSIFIED_COPY,
466 	ANA_ANEVENTS_VLAN_DISCARD,
467 	ANA_ANEVENTS_FWD_DISCARD,
468 	ANA_ANEVENTS_MULTICAST_FLOOD,
469 	ANA_ANEVENTS_UNICAST_FLOOD,
470 	ANA_ANEVENTS_DEST_KNOWN,
471 	ANA_ANEVENTS_BUCKET3_MATCH,
472 	ANA_ANEVENTS_BUCKET2_MATCH,
473 	ANA_ANEVENTS_BUCKET1_MATCH,
474 	ANA_ANEVENTS_BUCKET0_MATCH,
475 	ANA_ANEVENTS_CPU_OPERATION,
476 	ANA_ANEVENTS_DMAC_LOOKUP,
477 	ANA_ANEVENTS_SMAC_LOOKUP,
478 	ANA_ANEVENTS_SEQ_GEN_ERR_0,
479 	ANA_ANEVENTS_SEQ_GEN_ERR_1,
480 	ANA_TABLES_MACACCESS_B_DOM,
481 	ANA_TABLES_MACTINDX_BUCKET,
482 	ANA_TABLES_MACTINDX_M_INDEX,
483 	QSYS_SWITCH_PORT_MODE_PORT_ENA,
484 	QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG,
485 	QSYS_SWITCH_PORT_MODE_YEL_RSRVD,
486 	QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE,
487 	QSYS_SWITCH_PORT_MODE_TX_PFC_ENA,
488 	QSYS_SWITCH_PORT_MODE_TX_PFC_MODE,
489 	QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
490 	QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
491 	QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
492 	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
493 	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
494 	SYS_PORT_MODE_DATA_WO_TS,
495 	SYS_PORT_MODE_INCL_INJ_HDR,
496 	SYS_PORT_MODE_INCL_XTR_HDR,
497 	SYS_PORT_MODE_INCL_HDR_ERR,
498 	SYS_RESET_CFG_CORE_ENA,
499 	SYS_RESET_CFG_MEM_ENA,
500 	SYS_RESET_CFG_MEM_INIT,
501 	GCB_SOFT_RST_SWC_RST,
502 	GCB_MIIM_MII_STATUS_PENDING,
503 	GCB_MIIM_MII_STATUS_BUSY,
504 	SYS_PAUSE_CFG_PAUSE_START,
505 	SYS_PAUSE_CFG_PAUSE_STOP,
506 	SYS_PAUSE_CFG_PAUSE_ENA,
507 	REGFIELD_MAX
508 };
509 
510 enum {
511 	/* VCAP_CORE_CFG */
512 	VCAP_CORE_UPDATE_CTRL,
513 	VCAP_CORE_MV_CFG,
514 	/* VCAP_CORE_CACHE */
515 	VCAP_CACHE_ENTRY_DAT,
516 	VCAP_CACHE_MASK_DAT,
517 	VCAP_CACHE_ACTION_DAT,
518 	VCAP_CACHE_CNT_DAT,
519 	VCAP_CACHE_TG_DAT,
520 	/* VCAP_CONST */
521 	VCAP_CONST_VCAP_VER,
522 	VCAP_CONST_ENTRY_WIDTH,
523 	VCAP_CONST_ENTRY_CNT,
524 	VCAP_CONST_ENTRY_SWCNT,
525 	VCAP_CONST_ENTRY_TG_WIDTH,
526 	VCAP_CONST_ACTION_DEF_CNT,
527 	VCAP_CONST_ACTION_WIDTH,
528 	VCAP_CONST_CNT_WIDTH,
529 	VCAP_CONST_CORE_CNT,
530 	VCAP_CONST_IF_CNT,
531 };
532 
533 enum ocelot_ptp_pins {
534 	PTP_PIN_0,
535 	PTP_PIN_1,
536 	PTP_PIN_2,
537 	PTP_PIN_3,
538 	TOD_ACC_PIN
539 };
540 
541 struct ocelot_stat_layout {
542 	u32 offset;
543 	char name[ETH_GSTRING_LEN];
544 };
545 
546 #define OCELOT_STAT_END { .name = "" }
547 
548 struct ocelot_stats_region {
549 	struct list_head node;
550 	u32 offset;
551 	int count;
552 	u32 *buf;
553 };
554 
555 enum ocelot_tag_prefix {
556 	OCELOT_TAG_PREFIX_DISABLED	= 0,
557 	OCELOT_TAG_PREFIX_NONE,
558 	OCELOT_TAG_PREFIX_SHORT,
559 	OCELOT_TAG_PREFIX_LONG,
560 };
561 
562 struct ocelot;
563 
564 struct ocelot_ops {
565 	struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
566 	int (*netdev_to_port)(struct net_device *dev);
567 	int (*reset)(struct ocelot *ocelot);
568 	u16 (*wm_enc)(u16 value);
569 	u16 (*wm_dec)(u16 value);
570 	void (*wm_stat)(u32 val, u32 *inuse, u32 *maxuse);
571 	void (*psfp_init)(struct ocelot *ocelot);
572 	int (*psfp_filter_add)(struct ocelot *ocelot, int port,
573 			       struct flow_cls_offload *f);
574 	int (*psfp_filter_del)(struct ocelot *ocelot, struct flow_cls_offload *f);
575 	int (*psfp_stats_get)(struct ocelot *ocelot, struct flow_cls_offload *f,
576 			      struct flow_stats *stats);
577 	void (*cut_through_fwd)(struct ocelot *ocelot);
578 	void (*tas_clock_adjust)(struct ocelot *ocelot);
579 };
580 
581 struct ocelot_vcap_policer {
582 	struct list_head pol_list;
583 	u16 base;
584 	u16 max;
585 	u16 base2;
586 	u16 max2;
587 };
588 
589 struct ocelot_vcap_block {
590 	struct list_head rules;
591 	int count;
592 };
593 
594 struct ocelot_bridge_vlan {
595 	u16 vid;
596 	unsigned long portmask;
597 	unsigned long untagged;
598 	struct list_head list;
599 };
600 
601 enum ocelot_port_tag_config {
602 	/* all VLANs are egress-untagged */
603 	OCELOT_PORT_TAG_DISABLED = 0,
604 	/* all VLANs except the native VLAN and VID 0 are egress-tagged */
605 	OCELOT_PORT_TAG_NATIVE = 1,
606 	/* all VLANs except VID 0 are egress-tagged */
607 	OCELOT_PORT_TAG_TRUNK_NO_VID0 = 2,
608 	/* all VLANs are egress-tagged */
609 	OCELOT_PORT_TAG_TRUNK = 3,
610 };
611 
612 struct ocelot_psfp_list {
613 	struct list_head stream_list;
614 	struct list_head sfi_list;
615 	struct list_head sgi_list;
616 };
617 
618 enum ocelot_sb {
619 	OCELOT_SB_BUF,
620 	OCELOT_SB_REF,
621 	OCELOT_SB_NUM,
622 };
623 
624 enum ocelot_sb_pool {
625 	OCELOT_SB_POOL_ING,
626 	OCELOT_SB_POOL_EGR,
627 	OCELOT_SB_POOL_NUM,
628 };
629 
630 /* MAC table entry types.
631  * ENTRYTYPE_NORMAL is subject to aging.
632  * ENTRYTYPE_LOCKED is not subject to aging.
633  * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
634  * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
635  */
636 enum macaccess_entry_type {
637 	ENTRYTYPE_NORMAL = 0,
638 	ENTRYTYPE_LOCKED,
639 	ENTRYTYPE_MACv4,
640 	ENTRYTYPE_MACv6,
641 };
642 
643 #define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION	BIT(0)
644 #define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP		BIT(1)
645 
646 struct ocelot_lag_fdb {
647 	unsigned char addr[ETH_ALEN];
648 	u16 vid;
649 	struct net_device *bond;
650 	struct list_head list;
651 };
652 
653 struct ocelot_mirror {
654 	refcount_t refcount;
655 	int to;
656 };
657 
658 struct ocelot_port;
659 
660 struct ocelot_port {
661 	struct ocelot			*ocelot;
662 
663 	struct regmap			*target;
664 
665 	struct net_device		*bond;
666 	struct net_device		*bridge;
667 
668 	struct ocelot_port		*dsa_8021q_cpu;
669 
670 	/* VLAN that untagged frames are classified to, on ingress */
671 	const struct ocelot_bridge_vlan	*pvid_vlan;
672 
673 	phy_interface_t			phy_mode;
674 
675 	unsigned int			ptp_skbs_in_flight;
676 	struct sk_buff_head		tx_skbs;
677 
678 	u16				mrp_ring_id;
679 
680 	u8				ptp_cmd;
681 	u8				ts_id;
682 
683 	u8				index;
684 
685 	u8				stp_state;
686 	bool				vlan_aware;
687 	bool				is_dsa_8021q_cpu;
688 	bool				learn_ena;
689 
690 	bool				lag_tx_active;
691 
692 	int				bridge_num;
693 
694 	int				speed;
695 
696 	/* Store the AdminBaseTime of EST fetched from userspace. */
697 	s64				base_time;
698 };
699 
700 struct ocelot {
701 	struct device			*dev;
702 	struct devlink			*devlink;
703 	struct devlink_port		*devlink_ports;
704 
705 	const struct ocelot_ops		*ops;
706 	struct regmap			*targets[TARGET_MAX];
707 	struct regmap_field		*regfields[REGFIELD_MAX];
708 	const u32 *const		*map;
709 	const struct ocelot_stat_layout	*stats_layout;
710 	struct list_head		stats_regions;
711 	unsigned int			num_stats;
712 
713 	u32				pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM];
714 	int				packet_buffer_size;
715 	int				num_frame_refs;
716 	int				num_mact_rows;
717 
718 	struct ocelot_port		**ports;
719 
720 	u8				base_mac[ETH_ALEN];
721 
722 	struct list_head		vlans;
723 	struct list_head		traps;
724 	struct list_head		lag_fdbs;
725 
726 	/* Switches like VSC9959 have flooding per traffic class */
727 	int				num_flooding_pgids;
728 
729 	/* In tables like ANA:PORT and the ANA:PGID:PGID mask,
730 	 * the CPU is located after the physical ports (at the
731 	 * num_phys_ports index).
732 	 */
733 	u8				num_phys_ports;
734 
735 	int				npi;
736 
737 	enum ocelot_tag_prefix		npi_inj_prefix;
738 	enum ocelot_tag_prefix		npi_xtr_prefix;
739 
740 	unsigned long			bridges;
741 
742 	struct list_head		multicast;
743 	struct list_head		pgids;
744 
745 	struct list_head		dummy_rules;
746 	struct ocelot_vcap_block	block[3];
747 	struct ocelot_vcap_policer	vcap_pol;
748 	struct vcap_props		*vcap;
749 	struct ocelot_mirror		*mirror;
750 
751 	struct ocelot_psfp_list		psfp;
752 
753 	/* Workqueue to check statistics for overflow with its lock */
754 	struct mutex			stats_lock;
755 	u64				*stats;
756 	struct delayed_work		stats_work;
757 	struct workqueue_struct		*stats_queue;
758 
759 	/* Lock for serializing access to the MAC table */
760 	struct mutex			mact_lock;
761 	/* Lock for serializing forwarding domain changes */
762 	struct mutex			fwd_domain_lock;
763 
764 	/* Lock for serializing Time-Aware Shaper changes */
765 	struct mutex			tas_lock;
766 
767 	struct workqueue_struct		*owq;
768 
769 	u8				ptp:1;
770 	struct ptp_clock		*ptp_clock;
771 	struct ptp_clock_info		ptp_info;
772 	struct hwtstamp_config		hwtstamp_config;
773 	unsigned int			ptp_skbs_in_flight;
774 	/* Protects the 2-step TX timestamp ID logic */
775 	spinlock_t			ts_id_lock;
776 	/* Protects the PTP interface state */
777 	struct mutex			ptp_lock;
778 	/* Protects the PTP clock */
779 	spinlock_t			ptp_clock_lock;
780 	struct ptp_pin_desc		ptp_pins[OCELOT_PTP_PINS_NUM];
781 
782 	struct ocelot_fdma		*fdma;
783 };
784 
785 struct ocelot_policer {
786 	u32 rate; /* kilobit per second */
787 	u32 burst; /* bytes */
788 };
789 
790 #define ocelot_bulk_read_rix(ocelot, reg, ri, buf, count) \
791 	__ocelot_bulk_read_ix(ocelot, reg, reg##_RSZ * (ri), buf, count)
792 
793 #define ocelot_read_ix(ocelot, reg, gi, ri) \
794 	__ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
795 #define ocelot_read_gix(ocelot, reg, gi) \
796 	__ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
797 #define ocelot_read_rix(ocelot, reg, ri) \
798 	__ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
799 #define ocelot_read(ocelot, reg) \
800 	__ocelot_read_ix(ocelot, reg, 0)
801 
802 #define ocelot_write_ix(ocelot, val, reg, gi, ri) \
803 	__ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
804 #define ocelot_write_gix(ocelot, val, reg, gi) \
805 	__ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
806 #define ocelot_write_rix(ocelot, val, reg, ri) \
807 	__ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
808 #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
809 
810 #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) \
811 	__ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
812 #define ocelot_rmw_gix(ocelot, val, m, reg, gi) \
813 	__ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
814 #define ocelot_rmw_rix(ocelot, val, m, reg, ri) \
815 	__ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
816 #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
817 
818 #define ocelot_field_write(ocelot, reg, val) \
819 	regmap_field_write((ocelot)->regfields[(reg)], (val))
820 #define ocelot_field_read(ocelot, reg, val) \
821 	regmap_field_read((ocelot)->regfields[(reg)], (val))
822 #define ocelot_fields_write(ocelot, id, reg, val) \
823 	regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
824 #define ocelot_fields_read(ocelot, id, reg, val) \
825 	regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
826 
827 #define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \
828 	__ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
829 #define ocelot_target_read_gix(ocelot, target, reg, gi) \
830 	__ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi))
831 #define ocelot_target_read_rix(ocelot, target, reg, ri) \
832 	__ocelot_target_read_ix(ocelot, target, reg, reg##_RSZ * (ri))
833 #define ocelot_target_read(ocelot, target, reg) \
834 	__ocelot_target_read_ix(ocelot, target, reg, 0)
835 
836 #define ocelot_target_write_ix(ocelot, target, val, reg, gi, ri) \
837 	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
838 #define ocelot_target_write_gix(ocelot, target, val, reg, gi) \
839 	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi))
840 #define ocelot_target_write_rix(ocelot, target, val, reg, ri) \
841 	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_RSZ * (ri))
842 #define ocelot_target_write(ocelot, target, val, reg) \
843 	__ocelot_target_write_ix(ocelot, target, val, reg, 0)
844 
845 /* I/O */
846 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
847 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
848 void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg);
849 int __ocelot_bulk_read_ix(struct ocelot *ocelot, u32 reg, u32 offset, void *buf,
850 			  int count);
851 u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
852 void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
853 void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
854 		     u32 offset);
855 u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
856 			    u32 reg, u32 offset);
857 void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
858 			      u32 val, u32 reg, u32 offset);
859 
860 /* Packet I/O */
861 bool ocelot_can_inject(struct ocelot *ocelot, int grp);
862 void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
863 			      u32 rew_op, struct sk_buff *skb);
864 void ocelot_ifh_port_set(void *ifh, int port, u32 rew_op, u32 vlan_tag);
865 int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb);
866 void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp);
867 void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb,
868 			     u64 timestamp);
869 
870 /* Hardware initialization */
871 int ocelot_regfields_init(struct ocelot *ocelot,
872 			  const struct reg_field *const regfields);
873 struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
874 int ocelot_init(struct ocelot *ocelot);
875 void ocelot_deinit(struct ocelot *ocelot);
876 void ocelot_init_port(struct ocelot *ocelot, int port);
877 void ocelot_deinit_port(struct ocelot *ocelot, int port);
878 
879 void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu);
880 void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port);
881 u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port);
882 
883 /* DSA callbacks */
884 void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
885 void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
886 int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
887 int ocelot_get_ts_info(struct ocelot *ocelot, int port,
888 		       struct ethtool_ts_info *info);
889 void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
890 int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled,
891 			       struct netlink_ext_ack *extack);
892 void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
893 u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port);
894 int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port,
895 				 struct switchdev_brport_flags val);
896 void ocelot_port_bridge_flags(struct ocelot *ocelot, int port,
897 			      struct switchdev_brport_flags val);
898 int ocelot_port_get_default_prio(struct ocelot *ocelot, int port);
899 int ocelot_port_set_default_prio(struct ocelot *ocelot, int port, u8 prio);
900 int ocelot_port_get_dscp_prio(struct ocelot *ocelot, int port, u8 dscp);
901 int ocelot_port_add_dscp_prio(struct ocelot *ocelot, int port, u8 dscp, u8 prio);
902 int ocelot_port_del_dscp_prio(struct ocelot *ocelot, int port, u8 dscp, u8 prio);
903 int ocelot_port_bridge_join(struct ocelot *ocelot, int port,
904 			    struct net_device *bridge, int bridge_num,
905 			    struct netlink_ext_ack *extack);
906 void ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
907 			      struct net_device *bridge);
908 int ocelot_mact_flush(struct ocelot *ocelot, int port);
909 int ocelot_fdb_dump(struct ocelot *ocelot, int port,
910 		    dsa_fdb_dump_cb_t *cb, void *data);
911 int ocelot_fdb_add(struct ocelot *ocelot, int port, const unsigned char *addr,
912 		   u16 vid, const struct net_device *bridge);
913 int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr,
914 		   u16 vid, const struct net_device *bridge);
915 int ocelot_lag_fdb_add(struct ocelot *ocelot, struct net_device *bond,
916 		       const unsigned char *addr, u16 vid,
917 		       const struct net_device *bridge);
918 int ocelot_lag_fdb_del(struct ocelot *ocelot, struct net_device *bond,
919 		       const unsigned char *addr, u16 vid,
920 		       const struct net_device *bridge);
921 int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
922 			bool untagged, struct netlink_ext_ack *extack);
923 int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
924 		    bool untagged);
925 int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
926 int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
927 int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
928 int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
929 				 struct sk_buff *skb,
930 				 struct sk_buff **clone);
931 void ocelot_get_txtstamp(struct ocelot *ocelot);
932 void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
933 int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
934 int ocelot_port_policer_add(struct ocelot *ocelot, int port,
935 			    struct ocelot_policer *pol);
936 int ocelot_port_policer_del(struct ocelot *ocelot, int port);
937 int ocelot_port_mirror_add(struct ocelot *ocelot, int from, int to,
938 			   bool ingress, struct netlink_ext_ack *extack);
939 void ocelot_port_mirror_del(struct ocelot *ocelot, int from, bool ingress);
940 int ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
941 			      struct flow_cls_offload *f, bool ingress);
942 int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
943 			      struct flow_cls_offload *f, bool ingress);
944 int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
945 			    struct flow_cls_offload *f, bool ingress);
946 int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
947 			const struct switchdev_obj_port_mdb *mdb,
948 			const struct net_device *bridge);
949 int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
950 			const struct switchdev_obj_port_mdb *mdb,
951 			const struct net_device *bridge);
952 int ocelot_port_lag_join(struct ocelot *ocelot, int port,
953 			 struct net_device *bond,
954 			 struct netdev_lag_upper_info *info);
955 void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
956 			   struct net_device *bond);
957 void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active);
958 
959 int ocelot_devlink_sb_register(struct ocelot *ocelot);
960 void ocelot_devlink_sb_unregister(struct ocelot *ocelot);
961 int ocelot_sb_pool_get(struct ocelot *ocelot, unsigned int sb_index,
962 		       u16 pool_index,
963 		       struct devlink_sb_pool_info *pool_info);
964 int ocelot_sb_pool_set(struct ocelot *ocelot, unsigned int sb_index,
965 		       u16 pool_index, u32 size,
966 		       enum devlink_sb_threshold_type threshold_type,
967 		       struct netlink_ext_ack *extack);
968 int ocelot_sb_port_pool_get(struct ocelot *ocelot, int port,
969 			    unsigned int sb_index, u16 pool_index,
970 			    u32 *p_threshold);
971 int ocelot_sb_port_pool_set(struct ocelot *ocelot, int port,
972 			    unsigned int sb_index, u16 pool_index,
973 			    u32 threshold, struct netlink_ext_ack *extack);
974 int ocelot_sb_tc_pool_bind_get(struct ocelot *ocelot, int port,
975 			       unsigned int sb_index, u16 tc_index,
976 			       enum devlink_sb_pool_type pool_type,
977 			       u16 *p_pool_index, u32 *p_threshold);
978 int ocelot_sb_tc_pool_bind_set(struct ocelot *ocelot, int port,
979 			       unsigned int sb_index, u16 tc_index,
980 			       enum devlink_sb_pool_type pool_type,
981 			       u16 pool_index, u32 threshold,
982 			       struct netlink_ext_ack *extack);
983 int ocelot_sb_occ_snapshot(struct ocelot *ocelot, unsigned int sb_index);
984 int ocelot_sb_occ_max_clear(struct ocelot *ocelot, unsigned int sb_index);
985 int ocelot_sb_occ_port_pool_get(struct ocelot *ocelot, int port,
986 				unsigned int sb_index, u16 pool_index,
987 				u32 *p_cur, u32 *p_max);
988 int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,
989 				   unsigned int sb_index, u16 tc_index,
990 				   enum devlink_sb_pool_type pool_type,
991 				   u32 *p_cur, u32 *p_max);
992 
993 void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
994 				  unsigned int link_an_mode,
995 				  phy_interface_t interface,
996 				  unsigned long quirks);
997 void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
998 				struct phy_device *phydev,
999 				unsigned int link_an_mode,
1000 				phy_interface_t interface,
1001 				int speed, int duplex,
1002 				bool tx_pause, bool rx_pause,
1003 				unsigned long quirks);
1004 
1005 int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx,
1006 		       const unsigned char mac[ETH_ALEN],
1007 		       unsigned int vid, enum macaccess_entry_type *type);
1008 int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx,
1009 				 const unsigned char mac[ETH_ALEN],
1010 				 unsigned int vid,
1011 				 enum macaccess_entry_type type,
1012 				 int sfid, int ssid);
1013 
1014 int ocelot_migrate_mdbs(struct ocelot *ocelot, unsigned long from_mask,
1015 			unsigned long to_mask);
1016 
1017 int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
1018 			    struct ocelot_policer *pol);
1019 int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix);
1020 
1021 #if IS_ENABLED(CONFIG_BRIDGE_MRP)
1022 int ocelot_mrp_add(struct ocelot *ocelot, int port,
1023 		   const struct switchdev_obj_mrp *mrp);
1024 int ocelot_mrp_del(struct ocelot *ocelot, int port,
1025 		   const struct switchdev_obj_mrp *mrp);
1026 int ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
1027 			     const struct switchdev_obj_ring_role_mrp *mrp);
1028 int ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
1029 			     const struct switchdev_obj_ring_role_mrp *mrp);
1030 #else
1031 static inline int ocelot_mrp_add(struct ocelot *ocelot, int port,
1032 				 const struct switchdev_obj_mrp *mrp)
1033 {
1034 	return -EOPNOTSUPP;
1035 }
1036 
1037 static inline int ocelot_mrp_del(struct ocelot *ocelot, int port,
1038 				 const struct switchdev_obj_mrp *mrp)
1039 {
1040 	return -EOPNOTSUPP;
1041 }
1042 
1043 static inline int
1044 ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
1045 			 const struct switchdev_obj_ring_role_mrp *mrp)
1046 {
1047 	return -EOPNOTSUPP;
1048 }
1049 
1050 static inline int
1051 ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
1052 			 const struct switchdev_obj_ring_role_mrp *mrp)
1053 {
1054 	return -EOPNOTSUPP;
1055 }
1056 #endif
1057 
1058 #endif
1059