1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved.
3 * Copyright(c) 2018 Synopsys, Inc. All rights reserved.
6 #ifndef __AXGBE_COMMON_H__
7 #define __AXGBE_COMMON_H__
9 #include "axgbe_logs.h"
13 #include <sys/queue.h>
24 #include <rte_byteorder.h>
25 #include <rte_memory.h>
26 #include <rte_malloc.h>
27 #include <rte_hexdump.h>
29 #include <rte_debug.h>
30 #include <rte_branch_prediction.h>
32 #include <rte_memzone.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
36 #include <rte_errno.h>
37 #include <rte_ethdev_pci.h>
38 #include <rte_common.h>
39 #include <rte_cycles.h>
42 #define BIT(nr) (1 << (nr))
44 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
49 /* DMA register offsets */
51 #define DMA_SBMR 0x3004
52 #define DMA_ISR 0x3008
53 #define DMA_AXIARCR 0x3010
54 #define DMA_AXIAWCR 0x3018
55 #define DMA_AXIAWRCR 0x301c
56 #define DMA_DSR0 0x3020
57 #define DMA_DSR1 0x3024
58 #define EDMA_TX_CONTROL 0x3040
59 #define EDMA_RX_CONTROL 0x3044
61 /* DMA register entry bit positions and sizes */
62 #define DMA_AXIARCR_DRC_INDEX 0
63 #define DMA_AXIARCR_DRC_WIDTH 4
64 #define DMA_AXIARCR_DRD_INDEX 4
65 #define DMA_AXIARCR_DRD_WIDTH 2
66 #define DMA_AXIARCR_TEC_INDEX 8
67 #define DMA_AXIARCR_TEC_WIDTH 4
68 #define DMA_AXIARCR_TED_INDEX 12
69 #define DMA_AXIARCR_TED_WIDTH 2
70 #define DMA_AXIARCR_THC_INDEX 16
71 #define DMA_AXIARCR_THC_WIDTH 4
72 #define DMA_AXIARCR_THD_INDEX 20
73 #define DMA_AXIARCR_THD_WIDTH 2
74 #define DMA_AXIAWCR_DWC_INDEX 0
75 #define DMA_AXIAWCR_DWC_WIDTH 4
76 #define DMA_AXIAWCR_DWD_INDEX 4
77 #define DMA_AXIAWCR_DWD_WIDTH 2
78 #define DMA_AXIAWCR_RPC_INDEX 8
79 #define DMA_AXIAWCR_RPC_WIDTH 4
80 #define DMA_AXIAWCR_RPD_INDEX 12
81 #define DMA_AXIAWCR_RPD_WIDTH 2
82 #define DMA_AXIAWCR_RHC_INDEX 16
83 #define DMA_AXIAWCR_RHC_WIDTH 4
84 #define DMA_AXIAWCR_RHD_INDEX 20
85 #define DMA_AXIAWCR_RHD_WIDTH 2
86 #define DMA_AXIAWCR_RDC_INDEX 24
87 #define DMA_AXIAWCR_RDC_WIDTH 4
88 #define DMA_AXIAWCR_RDD_INDEX 28
89 #define DMA_AXIAWCR_RDD_WIDTH 2
90 #define DMA_AXIAWRCR_TDWC_INDEX 0
91 #define DMA_AXIAWRCR_TDWC_WIDTH 4
92 #define DMA_AXIAWRCR_TDWD_INDEX 4
93 #define DMA_AXIAWRCR_TDWD_WIDTH 4
94 #define DMA_AXIAWRCR_RDRC_INDEX 8
95 #define DMA_AXIAWRCR_RDRC_WIDTH 4
96 #define DMA_ISR_MACIS_INDEX 17
97 #define DMA_ISR_MACIS_WIDTH 1
98 #define DMA_ISR_MTLIS_INDEX 16
99 #define DMA_ISR_MTLIS_WIDTH 1
100 #define DMA_MR_INTM_INDEX 12
101 #define DMA_MR_INTM_WIDTH 2
102 #define DMA_MR_SWR_INDEX 0
103 #define DMA_MR_SWR_WIDTH 1
104 #define DMA_SBMR_WR_OSR_INDEX 24
105 #define DMA_SBMR_WR_OSR_WIDTH 6
106 #define DMA_SBMR_RD_OSR_INDEX 16
107 #define DMA_SBMR_RD_OSR_WIDTH 6
108 #define DMA_SBMR_AAL_INDEX 12
109 #define DMA_SBMR_AAL_WIDTH 1
110 #define DMA_SBMR_EAME_INDEX 11
111 #define DMA_SBMR_EAME_WIDTH 1
112 #define DMA_SBMR_BLEN_256_INDEX 7
113 #define DMA_SBMR_BLEN_256_WIDTH 1
114 #define DMA_SBMR_BLEN_32_INDEX 4
115 #define DMA_SBMR_BLEN_32_WIDTH 1
116 #define DMA_SBMR_UNDEF_INDEX 0
117 #define DMA_SBMR_UNDEF_WIDTH 1
119 /* DMA register values */
120 #define DMA_DSR_RPS_WIDTH 4
121 #define DMA_DSR_TPS_WIDTH 4
122 #define DMA_DSR_Q_WIDTH (DMA_DSR_RPS_WIDTH + DMA_DSR_TPS_WIDTH)
123 #define DMA_DSR0_RPS_START 8
124 #define DMA_DSR0_TPS_START 12
125 #define DMA_DSRX_FIRST_QUEUE 3
126 #define DMA_DSRX_INC 4
127 #define DMA_DSRX_QPR 4
128 #define DMA_DSRX_RPS_START 0
129 #define DMA_DSRX_TPS_START 4
130 #define DMA_TPS_STOPPED 0x00
131 #define DMA_TPS_SUSPENDED 0x06
133 /* DMA channel register offsets
134 * Multiple channels can be active. The first channel has registers
135 * that begin at 0x3100. Each subsequent channel has registers that
136 * are accessed using an offset of 0x80 from the previous channel.
138 #define DMA_CH_BASE 0x3100
139 #define DMA_CH_INC 0x80
141 #define DMA_CH_CR 0x00
142 #define DMA_CH_TCR 0x04
143 #define DMA_CH_RCR 0x08
144 #define DMA_CH_TDLR_HI 0x10
145 #define DMA_CH_TDLR_LO 0x14
146 #define DMA_CH_RDLR_HI 0x18
147 #define DMA_CH_RDLR_LO 0x1c
148 #define DMA_CH_TDTR_LO 0x24
149 #define DMA_CH_RDTR_LO 0x2c
150 #define DMA_CH_TDRLR 0x30
151 #define DMA_CH_RDRLR 0x34
152 #define DMA_CH_IER 0x38
153 #define DMA_CH_RIWT 0x3c
154 #define DMA_CH_CATDR_LO 0x44
155 #define DMA_CH_CARDR_LO 0x4c
156 #define DMA_CH_CATBR_HI 0x50
157 #define DMA_CH_CATBR_LO 0x54
158 #define DMA_CH_CARBR_HI 0x58
159 #define DMA_CH_CARBR_LO 0x5c
160 #define DMA_CH_SR 0x60
162 /* DMA channel register entry bit positions and sizes */
163 #define DMA_CH_CR_PBLX8_INDEX 16
164 #define DMA_CH_CR_PBLX8_WIDTH 1
165 #define DMA_CH_CR_SPH_INDEX 24
166 #define DMA_CH_CR_SPH_WIDTH 1
167 #define DMA_CH_IER_AIE_INDEX 14
168 #define DMA_CH_IER_AIE_WIDTH 1
169 #define DMA_CH_IER_FBEE_INDEX 12
170 #define DMA_CH_IER_FBEE_WIDTH 1
171 #define DMA_CH_IER_NIE_INDEX 15
172 #define DMA_CH_IER_NIE_WIDTH 1
173 #define DMA_CH_IER_RBUE_INDEX 7
174 #define DMA_CH_IER_RBUE_WIDTH 1
175 #define DMA_CH_IER_RIE_INDEX 6
176 #define DMA_CH_IER_RIE_WIDTH 1
177 #define DMA_CH_IER_RSE_INDEX 8
178 #define DMA_CH_IER_RSE_WIDTH 1
179 #define DMA_CH_IER_TBUE_INDEX 2
180 #define DMA_CH_IER_TBUE_WIDTH 1
181 #define DMA_CH_IER_TIE_INDEX 0
182 #define DMA_CH_IER_TIE_WIDTH 1
183 #define DMA_CH_IER_TXSE_INDEX 1
184 #define DMA_CH_IER_TXSE_WIDTH 1
185 #define DMA_CH_RCR_PBL_INDEX 16
186 #define DMA_CH_RCR_PBL_WIDTH 6
187 #define DMA_CH_RCR_RBSZ_INDEX 1
188 #define DMA_CH_RCR_RBSZ_WIDTH 14
189 #define DMA_CH_RCR_SR_INDEX 0
190 #define DMA_CH_RCR_SR_WIDTH 1
191 #define DMA_CH_RIWT_RWT_INDEX 0
192 #define DMA_CH_RIWT_RWT_WIDTH 8
193 #define DMA_CH_SR_FBE_INDEX 12
194 #define DMA_CH_SR_FBE_WIDTH 1
195 #define DMA_CH_SR_RBU_INDEX 7
196 #define DMA_CH_SR_RBU_WIDTH 1
197 #define DMA_CH_SR_RI_INDEX 6
198 #define DMA_CH_SR_RI_WIDTH 1
199 #define DMA_CH_SR_RPS_INDEX 8
200 #define DMA_CH_SR_RPS_WIDTH 1
201 #define DMA_CH_SR_TBU_INDEX 2
202 #define DMA_CH_SR_TBU_WIDTH 1
203 #define DMA_CH_SR_TI_INDEX 0
204 #define DMA_CH_SR_TI_WIDTH 1
205 #define DMA_CH_SR_TPS_INDEX 1
206 #define DMA_CH_SR_TPS_WIDTH 1
207 #define DMA_CH_TCR_OSP_INDEX 4
208 #define DMA_CH_TCR_OSP_WIDTH 1
209 #define DMA_CH_TCR_PBL_INDEX 16
210 #define DMA_CH_TCR_PBL_WIDTH 6
211 #define DMA_CH_TCR_ST_INDEX 0
212 #define DMA_CH_TCR_ST_WIDTH 1
213 #define DMA_CH_TCR_TSE_INDEX 12
214 #define DMA_CH_TCR_TSE_WIDTH 1
216 /* DMA channel register values */
217 #define DMA_OSP_DISABLE 0x00
218 #define DMA_OSP_ENABLE 0x01
223 #define DMA_PBL_16 16
224 #define DMA_PBL_32 32
225 #define DMA_PBL_64 64 /* 8 x 8 */
226 #define DMA_PBL_128 128 /* 8 x 16 */
227 #define DMA_PBL_256 256 /* 8 x 32 */
228 #define DMA_PBL_X8_DISABLE 0x00
229 #define DMA_PBL_X8_ENABLE 0x01
231 /* MAC register offsets */
232 #define MAC_TCR 0x0000
233 #define MAC_RCR 0x0004
234 #define MAC_PFR 0x0008
235 #define MAC_WTR 0x000c
236 #define MAC_HTR0 0x0010
237 #define MAC_VLANTR 0x0050
238 #define MAC_VLANHTR 0x0058
239 #define MAC_VLANIR 0x0060
240 #define MAC_IVLANIR 0x0064
241 #define MAC_RETMR 0x006c
242 #define MAC_Q0TFCR 0x0070
243 #define MAC_RFCR 0x0090
244 #define MAC_RQC0R 0x00a0
245 #define MAC_RQC1R 0x00a4
246 #define MAC_RQC2R 0x00a8
247 #define MAC_RQC3R 0x00ac
248 #define MAC_ISR 0x00b0
249 #define MAC_IER 0x00b4
250 #define MAC_RTSR 0x00b8
251 #define MAC_PMTCSR 0x00c0
252 #define MAC_RWKPFR 0x00c4
253 #define MAC_LPICSR 0x00d0
254 #define MAC_LPITCR 0x00d4
255 #define MAC_VR 0x0110
256 #define MAC_DR 0x0114
257 #define MAC_HWF0R 0x011c
258 #define MAC_HWF1R 0x0120
259 #define MAC_HWF2R 0x0124
260 #define MAC_MDIOSCAR 0x0200
261 #define MAC_MDIOSCCDR 0x0204
262 #define MAC_MDIOISR 0x0214
263 #define MAC_MDIOIER 0x0218
264 #define MAC_MDIOCL22R 0x0220
265 #define MAC_GPIOCR 0x0278
266 #define MAC_GPIOSR 0x027c
267 #define MAC_MACA0HR 0x0300
268 #define MAC_MACA0LR 0x0304
269 #define MAC_MACA1HR 0x0308
270 #define MAC_MACA1LR 0x030c
271 #define MAC_RSSCR 0x0c80
272 #define MAC_RSSAR 0x0c88
273 #define MAC_RSSDR 0x0c8c
274 #define MAC_TSCR 0x0d00
275 #define MAC_SSIR 0x0d04
276 #define MAC_STSR 0x0d08
277 #define MAC_STNR 0x0d0c
278 #define MAC_STSUR 0x0d10
279 #define MAC_STNUR 0x0d14
280 #define MAC_TSAR 0x0d18
281 #define MAC_TSSR 0x0d20
282 #define MAC_TXSNR 0x0d30
283 #define MAC_TXSSR 0x0d34
285 #define MAC_QTFCR_INC 4
286 #define MAC_MACA_INC 4
287 #define MAC_HTR_INC 4
289 #define MAC_RQC2_INC 4
290 #define MAC_RQC2_Q_PER_REG 4
292 /* MAC register entry bit positions and sizes */
293 #define MAC_HWF0R_ADDMACADRSEL_INDEX 18
294 #define MAC_HWF0R_ADDMACADRSEL_WIDTH 5
295 #define MAC_HWF0R_ARPOFFSEL_INDEX 9
296 #define MAC_HWF0R_ARPOFFSEL_WIDTH 1
297 #define MAC_HWF0R_EEESEL_INDEX 13
298 #define MAC_HWF0R_EEESEL_WIDTH 1
299 #define MAC_HWF0R_GMIISEL_INDEX 1
300 #define MAC_HWF0R_GMIISEL_WIDTH 1
301 #define MAC_HWF0R_MGKSEL_INDEX 7
302 #define MAC_HWF0R_MGKSEL_WIDTH 1
303 #define MAC_HWF0R_MMCSEL_INDEX 8
304 #define MAC_HWF0R_MMCSEL_WIDTH 1
305 #define MAC_HWF0R_RWKSEL_INDEX 6
306 #define MAC_HWF0R_RWKSEL_WIDTH 1
307 #define MAC_HWF0R_RXCOESEL_INDEX 16
308 #define MAC_HWF0R_RXCOESEL_WIDTH 1
309 #define MAC_HWF0R_SAVLANINS_INDEX 27
310 #define MAC_HWF0R_SAVLANINS_WIDTH 1
311 #define MAC_HWF0R_SMASEL_INDEX 5
312 #define MAC_HWF0R_SMASEL_WIDTH 1
313 #define MAC_HWF0R_TSSEL_INDEX 12
314 #define MAC_HWF0R_TSSEL_WIDTH 1
315 #define MAC_HWF0R_TSSTSSEL_INDEX 25
316 #define MAC_HWF0R_TSSTSSEL_WIDTH 2
317 #define MAC_HWF0R_TXCOESEL_INDEX 14
318 #define MAC_HWF0R_TXCOESEL_WIDTH 1
319 #define MAC_HWF0R_VLHASH_INDEX 4
320 #define MAC_HWF0R_VLHASH_WIDTH 1
321 #define MAC_HWF1R_ADDR64_INDEX 14
322 #define MAC_HWF1R_ADDR64_WIDTH 2
323 #define MAC_HWF1R_ADVTHWORD_INDEX 13
324 #define MAC_HWF1R_ADVTHWORD_WIDTH 1
325 #define MAC_HWF1R_DBGMEMA_INDEX 19
326 #define MAC_HWF1R_DBGMEMA_WIDTH 1
327 #define MAC_HWF1R_DCBEN_INDEX 16
328 #define MAC_HWF1R_DCBEN_WIDTH 1
329 #define MAC_HWF1R_HASHTBLSZ_INDEX 24
330 #define MAC_HWF1R_HASHTBLSZ_WIDTH 3
331 #define MAC_HWF1R_L3L4FNUM_INDEX 27
332 #define MAC_HWF1R_L3L4FNUM_WIDTH 4
333 #define MAC_HWF1R_NUMTC_INDEX 21
334 #define MAC_HWF1R_NUMTC_WIDTH 3
335 #define MAC_HWF1R_RSSEN_INDEX 20
336 #define MAC_HWF1R_RSSEN_WIDTH 1
337 #define MAC_HWF1R_RXFIFOSIZE_INDEX 0
338 #define MAC_HWF1R_RXFIFOSIZE_WIDTH 5
339 #define MAC_HWF1R_SPHEN_INDEX 17
340 #define MAC_HWF1R_SPHEN_WIDTH 1
341 #define MAC_HWF1R_TSOEN_INDEX 18
342 #define MAC_HWF1R_TSOEN_WIDTH 1
343 #define MAC_HWF1R_TXFIFOSIZE_INDEX 6
344 #define MAC_HWF1R_TXFIFOSIZE_WIDTH 5
345 #define MAC_HWF2R_AUXSNAPNUM_INDEX 28
346 #define MAC_HWF2R_AUXSNAPNUM_WIDTH 3
347 #define MAC_HWF2R_PPSOUTNUM_INDEX 24
348 #define MAC_HWF2R_PPSOUTNUM_WIDTH 3
349 #define MAC_HWF2R_RXCHCNT_INDEX 12
350 #define MAC_HWF2R_RXCHCNT_WIDTH 4
351 #define MAC_HWF2R_RXQCNT_INDEX 0
352 #define MAC_HWF2R_RXQCNT_WIDTH 4
353 #define MAC_HWF2R_TXCHCNT_INDEX 18
354 #define MAC_HWF2R_TXCHCNT_WIDTH 4
355 #define MAC_HWF2R_TXQCNT_INDEX 6
356 #define MAC_HWF2R_TXQCNT_WIDTH 4
357 #define MAC_IER_TSIE_INDEX 12
358 #define MAC_IER_TSIE_WIDTH 1
359 #define MAC_ISR_MMCRXIS_INDEX 9
360 #define MAC_ISR_MMCRXIS_WIDTH 1
361 #define MAC_ISR_MMCTXIS_INDEX 10
362 #define MAC_ISR_MMCTXIS_WIDTH 1
363 #define MAC_ISR_PMTIS_INDEX 4
364 #define MAC_ISR_PMTIS_WIDTH 1
365 #define MAC_ISR_SMI_INDEX 1
366 #define MAC_ISR_SMI_WIDTH 1
367 #define MAC_ISR_LSI_INDEX 0
368 #define MAC_ISR_LSI_WIDTH 1
369 #define MAC_ISR_LS_INDEX 24
370 #define MAC_ISR_LS_WIDTH 2
371 #define MAC_ISR_TSIS_INDEX 12
372 #define MAC_ISR_TSIS_WIDTH 1
373 #define MAC_MACA1HR_AE_INDEX 31
374 #define MAC_MACA1HR_AE_WIDTH 1
375 #define MAC_MDIOIER_SNGLCOMPIE_INDEX 12
376 #define MAC_MDIOIER_SNGLCOMPIE_WIDTH 1
377 #define MAC_MDIOISR_SNGLCOMPINT_INDEX 12
378 #define MAC_MDIOISR_SNGLCOMPINT_WIDTH 1
379 #define MAC_MDIOSCAR_DA_INDEX 21
380 #define MAC_MDIOSCAR_DA_WIDTH 5
381 #define MAC_MDIOSCAR_PA_INDEX 16
382 #define MAC_MDIOSCAR_PA_WIDTH 5
383 #define MAC_MDIOSCAR_RA_INDEX 0
384 #define MAC_MDIOSCAR_RA_WIDTH 16
385 #define MAC_MDIOSCAR_REG_INDEX 0
386 #define MAC_MDIOSCAR_REG_WIDTH 21
387 #define MAC_MDIOSCCDR_BUSY_INDEX 22
388 #define MAC_MDIOSCCDR_BUSY_WIDTH 1
389 #define MAC_MDIOSCCDR_CMD_INDEX 16
390 #define MAC_MDIOSCCDR_CMD_WIDTH 2
391 #define MAC_MDIOSCCDR_CR_INDEX 19
392 #define MAC_MDIOSCCDR_CR_WIDTH 3
393 #define MAC_MDIOSCCDR_DATA_INDEX 0
394 #define MAC_MDIOSCCDR_DATA_WIDTH 16
395 #define MAC_MDIOSCCDR_SADDR_INDEX 18
396 #define MAC_MDIOSCCDR_SADDR_WIDTH 1
397 #define MAC_PFR_HMC_INDEX 2
398 #define MAC_PFR_HMC_WIDTH 1
399 #define MAC_PFR_HPF_INDEX 10
400 #define MAC_PFR_HPF_WIDTH 1
401 #define MAC_PFR_HUC_INDEX 1
402 #define MAC_PFR_HUC_WIDTH 1
403 #define MAC_PFR_PM_INDEX 4
404 #define MAC_PFR_PM_WIDTH 1
405 #define MAC_PFR_PR_INDEX 0
406 #define MAC_PFR_PR_WIDTH 1
407 #define MAC_PFR_VTFE_INDEX 16
408 #define MAC_PFR_VTFE_WIDTH 1
409 #define MAC_PMTCSR_MGKPKTEN_INDEX 1
410 #define MAC_PMTCSR_MGKPKTEN_WIDTH 1
411 #define MAC_PMTCSR_PWRDWN_INDEX 0
412 #define MAC_PMTCSR_PWRDWN_WIDTH 1
413 #define MAC_PMTCSR_RWKFILTRST_INDEX 31
414 #define MAC_PMTCSR_RWKFILTRST_WIDTH 1
415 #define MAC_PMTCSR_RWKPKTEN_INDEX 2
416 #define MAC_PMTCSR_RWKPKTEN_WIDTH 1
417 #define MAC_Q0TFCR_PT_INDEX 16
418 #define MAC_Q0TFCR_PT_WIDTH 16
419 #define MAC_Q0TFCR_TFE_INDEX 1
420 #define MAC_Q0TFCR_TFE_WIDTH 1
421 #define MAC_RCR_ACS_INDEX 1
422 #define MAC_RCR_ACS_WIDTH 1
423 #define MAC_RCR_CST_INDEX 2
424 #define MAC_RCR_CST_WIDTH 1
425 #define MAC_RCR_DCRCC_INDEX 3
426 #define MAC_RCR_DCRCC_WIDTH 1
427 #define MAC_RCR_HDSMS_INDEX 12
428 #define MAC_RCR_HDSMS_WIDTH 3
429 #define MAC_RCR_IPC_INDEX 9
430 #define MAC_RCR_IPC_WIDTH 1
431 #define MAC_RCR_JE_INDEX 8
432 #define MAC_RCR_JE_WIDTH 1
433 #define MAC_RCR_LM_INDEX 10
434 #define MAC_RCR_LM_WIDTH 1
435 #define MAC_RCR_RE_INDEX 0
436 #define MAC_RCR_RE_WIDTH 1
437 #define MAC_RFCR_PFCE_INDEX 8
438 #define MAC_RFCR_PFCE_WIDTH 1
439 #define MAC_RFCR_RFE_INDEX 0
440 #define MAC_RFCR_RFE_WIDTH 1
441 #define MAC_RFCR_UP_INDEX 1
442 #define MAC_RFCR_UP_WIDTH 1
443 #define MAC_RQC0R_RXQ0EN_INDEX 0
444 #define MAC_RQC0R_RXQ0EN_WIDTH 2
445 #define MAC_RSSAR_ADDRT_INDEX 2
446 #define MAC_RSSAR_ADDRT_WIDTH 1
447 #define MAC_RSSAR_CT_INDEX 1
448 #define MAC_RSSAR_CT_WIDTH 1
449 #define MAC_RSSAR_OB_INDEX 0
450 #define MAC_RSSAR_OB_WIDTH 1
451 #define MAC_RSSAR_RSSIA_INDEX 8
452 #define MAC_RSSAR_RSSIA_WIDTH 8
453 #define MAC_RSSCR_IP2TE_INDEX 1
454 #define MAC_RSSCR_IP2TE_WIDTH 1
455 #define MAC_RSSCR_RSSE_INDEX 0
456 #define MAC_RSSCR_RSSE_WIDTH 1
457 #define MAC_RSSCR_TCP4TE_INDEX 2
458 #define MAC_RSSCR_TCP4TE_WIDTH 1
459 #define MAC_RSSCR_UDP4TE_INDEX 3
460 #define MAC_RSSCR_UDP4TE_WIDTH 1
461 #define MAC_RSSDR_DMCH_INDEX 0
462 #define MAC_RSSDR_DMCH_WIDTH 4
463 #define MAC_SSIR_SNSINC_INDEX 8
464 #define MAC_SSIR_SNSINC_WIDTH 8
465 #define MAC_SSIR_SSINC_INDEX 16
466 #define MAC_SSIR_SSINC_WIDTH 8
467 #define MAC_TCR_SS_INDEX 29
468 #define MAC_TCR_SS_WIDTH 2
469 #define MAC_TCR_TE_INDEX 0
470 #define MAC_TCR_TE_WIDTH 1
471 #define MAC_TSCR_AV8021ASMEN_INDEX 28
472 #define MAC_TSCR_AV8021ASMEN_WIDTH 1
473 #define MAC_TSCR_SNAPTYPSEL_INDEX 16
474 #define MAC_TSCR_SNAPTYPSEL_WIDTH 2
475 #define MAC_TSCR_TSADDREG_INDEX 5
476 #define MAC_TSCR_TSADDREG_WIDTH 1
477 #define MAC_TSCR_TSCFUPDT_INDEX 1
478 #define MAC_TSCR_TSCFUPDT_WIDTH 1
479 #define MAC_TSCR_TSCTRLSSR_INDEX 9
480 #define MAC_TSCR_TSCTRLSSR_WIDTH 1
481 #define MAC_TSCR_TSENA_INDEX 0
482 #define MAC_TSCR_TSENA_WIDTH 1
483 #define MAC_TSCR_TSENALL_INDEX 8
484 #define MAC_TSCR_TSENALL_WIDTH 1
485 #define MAC_TSCR_TSEVNTENA_INDEX 14
486 #define MAC_TSCR_TSEVNTENA_WIDTH 1
487 #define MAC_TSCR_TSINIT_INDEX 2
488 #define MAC_TSCR_TSINIT_WIDTH 1
489 #define MAC_TSCR_TSIPENA_INDEX 11
490 #define MAC_TSCR_TSIPENA_WIDTH 1
491 #define MAC_TSCR_TSIPV4ENA_INDEX 13
492 #define MAC_TSCR_TSIPV4ENA_WIDTH 1
493 #define MAC_TSCR_TSIPV6ENA_INDEX 12
494 #define MAC_TSCR_TSIPV6ENA_WIDTH 1
495 #define MAC_TSCR_TSMSTRENA_INDEX 15
496 #define MAC_TSCR_TSMSTRENA_WIDTH 1
497 #define MAC_TSCR_TSVER2ENA_INDEX 10
498 #define MAC_TSCR_TSVER2ENA_WIDTH 1
499 #define MAC_TSCR_TXTSSTSM_INDEX 24
500 #define MAC_TSCR_TXTSSTSM_WIDTH 1
501 #define MAC_TSSR_TXTSC_INDEX 15
502 #define MAC_TSSR_TXTSC_WIDTH 1
503 #define MAC_TXSNR_TXTSSTSMIS_INDEX 31
504 #define MAC_TXSNR_TXTSSTSMIS_WIDTH 1
505 #define MAC_VLANHTR_VLHT_INDEX 0
506 #define MAC_VLANHTR_VLHT_WIDTH 16
507 #define MAC_VLANIR_VLTI_INDEX 20
508 #define MAC_VLANIR_VLTI_WIDTH 1
509 #define MAC_VLANIR_CSVL_INDEX 19
510 #define MAC_VLANIR_CSVL_WIDTH 1
511 #define MAC_VLANTR_DOVLTC_INDEX 20
512 #define MAC_VLANTR_DOVLTC_WIDTH 1
513 #define MAC_VLANTR_ERSVLM_INDEX 19
514 #define MAC_VLANTR_ERSVLM_WIDTH 1
515 #define MAC_VLANTR_ESVL_INDEX 18
516 #define MAC_VLANTR_ESVL_WIDTH 1
517 #define MAC_VLANTR_ETV_INDEX 16
518 #define MAC_VLANTR_ETV_WIDTH 1
519 #define MAC_VLANTR_EVLS_INDEX 21
520 #define MAC_VLANTR_EVLS_WIDTH 2
521 #define MAC_VLANTR_EVLRXS_INDEX 24
522 #define MAC_VLANTR_EVLRXS_WIDTH 1
523 #define MAC_VLANTR_VL_INDEX 0
524 #define MAC_VLANTR_VL_WIDTH 16
525 #define MAC_VLANTR_VTHM_INDEX 25
526 #define MAC_VLANTR_VTHM_WIDTH 1
527 #define MAC_VLANTR_VTIM_INDEX 17
528 #define MAC_VLANTR_VTIM_WIDTH 1
529 #define MAC_VR_DEVID_INDEX 8
530 #define MAC_VR_DEVID_WIDTH 8
531 #define MAC_VR_SNPSVER_INDEX 0
532 #define MAC_VR_SNPSVER_WIDTH 8
533 #define MAC_VR_USERVER_INDEX 16
534 #define MAC_VR_USERVER_WIDTH 8
536 /* MMC register offsets */
537 #define MMC_CR 0x0800
538 #define MMC_RISR 0x0804
539 #define MMC_TISR 0x0808
540 #define MMC_RIER 0x080c
541 #define MMC_TIER 0x0810
542 #define MMC_TXOCTETCOUNT_GB_LO 0x0814
543 #define MMC_TXOCTETCOUNT_GB_HI 0x0818
544 #define MMC_TXFRAMECOUNT_GB_LO 0x081c
545 #define MMC_TXFRAMECOUNT_GB_HI 0x0820
546 #define MMC_TXBROADCASTFRAMES_G_LO 0x0824
547 #define MMC_TXBROADCASTFRAMES_G_HI 0x0828
548 #define MMC_TXMULTICASTFRAMES_G_LO 0x082c
549 #define MMC_TXMULTICASTFRAMES_G_HI 0x0830
550 #define MMC_TX64OCTETS_GB_LO 0x0834
551 #define MMC_TX64OCTETS_GB_HI 0x0838
552 #define MMC_TX65TO127OCTETS_GB_LO 0x083c
553 #define MMC_TX65TO127OCTETS_GB_HI 0x0840
554 #define MMC_TX128TO255OCTETS_GB_LO 0x0844
555 #define MMC_TX128TO255OCTETS_GB_HI 0x0848
556 #define MMC_TX256TO511OCTETS_GB_LO 0x084c
557 #define MMC_TX256TO511OCTETS_GB_HI 0x0850
558 #define MMC_TX512TO1023OCTETS_GB_LO 0x0854
559 #define MMC_TX512TO1023OCTETS_GB_HI 0x0858
560 #define MMC_TX1024TOMAXOCTETS_GB_LO 0x085c
561 #define MMC_TX1024TOMAXOCTETS_GB_HI 0x0860
562 #define MMC_TXUNICASTFRAMES_GB_LO 0x0864
563 #define MMC_TXUNICASTFRAMES_GB_HI 0x0868
564 #define MMC_TXMULTICASTFRAMES_GB_LO 0x086c
565 #define MMC_TXMULTICASTFRAMES_GB_HI 0x0870
566 #define MMC_TXBROADCASTFRAMES_GB_LO 0x0874
567 #define MMC_TXBROADCASTFRAMES_GB_HI 0x0878
568 #define MMC_TXUNDERFLOWERROR_LO 0x087c
569 #define MMC_TXUNDERFLOWERROR_HI 0x0880
570 #define MMC_TXOCTETCOUNT_G_LO 0x0884
571 #define MMC_TXOCTETCOUNT_G_HI 0x0888
572 #define MMC_TXFRAMECOUNT_G_LO 0x088c
573 #define MMC_TXFRAMECOUNT_G_HI 0x0890
574 #define MMC_TXPAUSEFRAMES_LO 0x0894
575 #define MMC_TXPAUSEFRAMES_HI 0x0898
576 #define MMC_TXVLANFRAMES_G_LO 0x089c
577 #define MMC_TXVLANFRAMES_G_HI 0x08a0
578 #define MMC_RXFRAMECOUNT_GB_LO 0x0900
579 #define MMC_RXFRAMECOUNT_GB_HI 0x0904
580 #define MMC_RXOCTETCOUNT_GB_LO 0x0908
581 #define MMC_RXOCTETCOUNT_GB_HI 0x090c
582 #define MMC_RXOCTETCOUNT_G_LO 0x0910
583 #define MMC_RXOCTETCOUNT_G_HI 0x0914
584 #define MMC_RXBROADCASTFRAMES_G_LO 0x0918
585 #define MMC_RXBROADCASTFRAMES_G_HI 0x091c
586 #define MMC_RXMULTICASTFRAMES_G_LO 0x0920
587 #define MMC_RXMULTICASTFRAMES_G_HI 0x0924
588 #define MMC_RXCRCERROR_LO 0x0928
589 #define MMC_RXCRCERROR_HI 0x092c
590 #define MMC_RXRUNTERROR 0x0930
591 #define MMC_RXJABBERERROR 0x0934
592 #define MMC_RXUNDERSIZE_G 0x0938
593 #define MMC_RXOVERSIZE_G 0x093c
594 #define MMC_RX64OCTETS_GB_LO 0x0940
595 #define MMC_RX64OCTETS_GB_HI 0x0944
596 #define MMC_RX65TO127OCTETS_GB_LO 0x0948
597 #define MMC_RX65TO127OCTETS_GB_HI 0x094c
598 #define MMC_RX128TO255OCTETS_GB_LO 0x0950
599 #define MMC_RX128TO255OCTETS_GB_HI 0x0954
600 #define MMC_RX256TO511OCTETS_GB_LO 0x0958
601 #define MMC_RX256TO511OCTETS_GB_HI 0x095c
602 #define MMC_RX512TO1023OCTETS_GB_LO 0x0960
603 #define MMC_RX512TO1023OCTETS_GB_HI 0x0964
604 #define MMC_RX1024TOMAXOCTETS_GB_LO 0x0968
605 #define MMC_RX1024TOMAXOCTETS_GB_HI 0x096c
606 #define MMC_RXUNICASTFRAMES_G_LO 0x0970
607 #define MMC_RXUNICASTFRAMES_G_HI 0x0974
608 #define MMC_RXLENGTHERROR_LO 0x0978
609 #define MMC_RXLENGTHERROR_HI 0x097c
610 #define MMC_RXOUTOFRANGETYPE_LO 0x0980
611 #define MMC_RXOUTOFRANGETYPE_HI 0x0984
612 #define MMC_RXPAUSEFRAMES_LO 0x0988
613 #define MMC_RXPAUSEFRAMES_HI 0x098c
614 #define MMC_RXFIFOOVERFLOW_LO 0x0990
615 #define MMC_RXFIFOOVERFLOW_HI 0x0994
616 #define MMC_RXVLANFRAMES_GB_LO 0x0998
617 #define MMC_RXVLANFRAMES_GB_HI 0x099c
618 #define MMC_RXWATCHDOGERROR 0x09a0
620 /* MMC register entry bit positions and sizes */
621 #define MMC_CR_CR_INDEX 0
622 #define MMC_CR_CR_WIDTH 1
623 #define MMC_CR_CSR_INDEX 1
624 #define MMC_CR_CSR_WIDTH 1
625 #define MMC_CR_ROR_INDEX 2
626 #define MMC_CR_ROR_WIDTH 1
627 #define MMC_CR_MCF_INDEX 3
628 #define MMC_CR_MCF_WIDTH 1
629 #define MMC_CR_MCT_INDEX 4
630 #define MMC_CR_MCT_WIDTH 2
631 #define MMC_RIER_ALL_INTERRUPTS_INDEX 0
632 #define MMC_RIER_ALL_INTERRUPTS_WIDTH 23
633 #define MMC_RISR_RXFRAMECOUNT_GB_INDEX 0
634 #define MMC_RISR_RXFRAMECOUNT_GB_WIDTH 1
635 #define MMC_RISR_RXOCTETCOUNT_GB_INDEX 1
636 #define MMC_RISR_RXOCTETCOUNT_GB_WIDTH 1
637 #define MMC_RISR_RXOCTETCOUNT_G_INDEX 2
638 #define MMC_RISR_RXOCTETCOUNT_G_WIDTH 1
639 #define MMC_RISR_RXBROADCASTFRAMES_G_INDEX 3
640 #define MMC_RISR_RXBROADCASTFRAMES_G_WIDTH 1
641 #define MMC_RISR_RXMULTICASTFRAMES_G_INDEX 4
642 #define MMC_RISR_RXMULTICASTFRAMES_G_WIDTH 1
643 #define MMC_RISR_RXCRCERROR_INDEX 5
644 #define MMC_RISR_RXCRCERROR_WIDTH 1
645 #define MMC_RISR_RXRUNTERROR_INDEX 6
646 #define MMC_RISR_RXRUNTERROR_WIDTH 1
647 #define MMC_RISR_RXJABBERERROR_INDEX 7
648 #define MMC_RISR_RXJABBERERROR_WIDTH 1
649 #define MMC_RISR_RXUNDERSIZE_G_INDEX 8
650 #define MMC_RISR_RXUNDERSIZE_G_WIDTH 1
651 #define MMC_RISR_RXOVERSIZE_G_INDEX 9
652 #define MMC_RISR_RXOVERSIZE_G_WIDTH 1
653 #define MMC_RISR_RX64OCTETS_GB_INDEX 10
654 #define MMC_RISR_RX64OCTETS_GB_WIDTH 1
655 #define MMC_RISR_RX65TO127OCTETS_GB_INDEX 11
656 #define MMC_RISR_RX65TO127OCTETS_GB_WIDTH 1
657 #define MMC_RISR_RX128TO255OCTETS_GB_INDEX 12
658 #define MMC_RISR_RX128TO255OCTETS_GB_WIDTH 1
659 #define MMC_RISR_RX256TO511OCTETS_GB_INDEX 13
660 #define MMC_RISR_RX256TO511OCTETS_GB_WIDTH 1
661 #define MMC_RISR_RX512TO1023OCTETS_GB_INDEX 14
662 #define MMC_RISR_RX512TO1023OCTETS_GB_WIDTH 1
663 #define MMC_RISR_RX1024TOMAXOCTETS_GB_INDEX 15
664 #define MMC_RISR_RX1024TOMAXOCTETS_GB_WIDTH 1
665 #define MMC_RISR_RXUNICASTFRAMES_G_INDEX 16
666 #define MMC_RISR_RXUNICASTFRAMES_G_WIDTH 1
667 #define MMC_RISR_RXLENGTHERROR_INDEX 17
668 #define MMC_RISR_RXLENGTHERROR_WIDTH 1
669 #define MMC_RISR_RXOUTOFRANGETYPE_INDEX 18
670 #define MMC_RISR_RXOUTOFRANGETYPE_WIDTH 1
671 #define MMC_RISR_RXPAUSEFRAMES_INDEX 19
672 #define MMC_RISR_RXPAUSEFRAMES_WIDTH 1
673 #define MMC_RISR_RXFIFOOVERFLOW_INDEX 20
674 #define MMC_RISR_RXFIFOOVERFLOW_WIDTH 1
675 #define MMC_RISR_RXVLANFRAMES_GB_INDEX 21
676 #define MMC_RISR_RXVLANFRAMES_GB_WIDTH 1
677 #define MMC_RISR_RXWATCHDOGERROR_INDEX 22
678 #define MMC_RISR_RXWATCHDOGERROR_WIDTH 1
679 #define MMC_TIER_ALL_INTERRUPTS_INDEX 0
680 #define MMC_TIER_ALL_INTERRUPTS_WIDTH 18
681 #define MMC_TISR_TXOCTETCOUNT_GB_INDEX 0
682 #define MMC_TISR_TXOCTETCOUNT_GB_WIDTH 1
683 #define MMC_TISR_TXFRAMECOUNT_GB_INDEX 1
684 #define MMC_TISR_TXFRAMECOUNT_GB_WIDTH 1
685 #define MMC_TISR_TXBROADCASTFRAMES_G_INDEX 2
686 #define MMC_TISR_TXBROADCASTFRAMES_G_WIDTH 1
687 #define MMC_TISR_TXMULTICASTFRAMES_G_INDEX 3
688 #define MMC_TISR_TXMULTICASTFRAMES_G_WIDTH 1
689 #define MMC_TISR_TX64OCTETS_GB_INDEX 4
690 #define MMC_TISR_TX64OCTETS_GB_WIDTH 1
691 #define MMC_TISR_TX65TO127OCTETS_GB_INDEX 5
692 #define MMC_TISR_TX65TO127OCTETS_GB_WIDTH 1
693 #define MMC_TISR_TX128TO255OCTETS_GB_INDEX 6
694 #define MMC_TISR_TX128TO255OCTETS_GB_WIDTH 1
695 #define MMC_TISR_TX256TO511OCTETS_GB_INDEX 7
696 #define MMC_TISR_TX256TO511OCTETS_GB_WIDTH 1
697 #define MMC_TISR_TX512TO1023OCTETS_GB_INDEX 8
698 #define MMC_TISR_TX512TO1023OCTETS_GB_WIDTH 1
699 #define MMC_TISR_TX1024TOMAXOCTETS_GB_INDEX 9
700 #define MMC_TISR_TX1024TOMAXOCTETS_GB_WIDTH 1
701 #define MMC_TISR_TXUNICASTFRAMES_GB_INDEX 10
702 #define MMC_TISR_TXUNICASTFRAMES_GB_WIDTH 1
703 #define MMC_TISR_TXMULTICASTFRAMES_GB_INDEX 11
704 #define MMC_TISR_TXMULTICASTFRAMES_GB_WIDTH 1
705 #define MMC_TISR_TXBROADCASTFRAMES_GB_INDEX 12
706 #define MMC_TISR_TXBROADCASTFRAMES_GB_WIDTH 1
707 #define MMC_TISR_TXUNDERFLOWERROR_INDEX 13
708 #define MMC_TISR_TXUNDERFLOWERROR_WIDTH 1
709 #define MMC_TISR_TXOCTETCOUNT_G_INDEX 14
710 #define MMC_TISR_TXOCTETCOUNT_G_WIDTH 1
711 #define MMC_TISR_TXFRAMECOUNT_G_INDEX 15
712 #define MMC_TISR_TXFRAMECOUNT_G_WIDTH 1
713 #define MMC_TISR_TXPAUSEFRAMES_INDEX 16
714 #define MMC_TISR_TXPAUSEFRAMES_WIDTH 1
715 #define MMC_TISR_TXVLANFRAMES_G_INDEX 17
716 #define MMC_TISR_TXVLANFRAMES_G_WIDTH 1
718 /* MTL register offsets */
719 #define MTL_OMR 0x1000
720 #define MTL_FDCR 0x1008
721 #define MTL_FDSR 0x100c
722 #define MTL_FDDR 0x1010
723 #define MTL_ISR 0x1020
724 #define MTL_RQDCM0R 0x1030
725 #define MTL_TCPM0R 0x1040
726 #define MTL_TCPM1R 0x1044
728 #define MTL_RQDCM_INC 4
729 #define MTL_RQDCM_Q_PER_REG 4
730 #define MTL_TCPM_INC 4
731 #define MTL_TCPM_TC_PER_REG 4
733 /* MTL register entry bit positions and sizes */
734 #define MTL_OMR_ETSALG_INDEX 5
735 #define MTL_OMR_ETSALG_WIDTH 2
736 #define MTL_OMR_RAA_INDEX 2
737 #define MTL_OMR_RAA_WIDTH 1
739 /* MTL queue register offsets
740 * Multiple queues can be active. The first queue has registers
741 * that begin at 0x1100. Each subsequent queue has registers that
742 * are accessed using an offset of 0x80 from the previous queue.
744 #define MTL_Q_BASE 0x1100
745 #define MTL_Q_INC 0x80
747 #define MTL_Q_TQOMR 0x00
748 #define MTL_Q_TQUR 0x04
749 #define MTL_Q_TQDR 0x08
750 #define MTL_Q_RQOMR 0x40
751 #define MTL_Q_RQMPOCR 0x44
752 #define MTL_Q_RQDR 0x48
753 #define MTL_Q_RQFCR 0x50
754 #define MTL_Q_IER 0x70
755 #define MTL_Q_ISR 0x74
757 /* MTL queue register entry bit positions and sizes */
758 #define MTL_Q_RQDR_PRXQ_INDEX 16
759 #define MTL_Q_RQDR_PRXQ_WIDTH 14
760 #define MTL_Q_RQDR_RXQSTS_INDEX 4
761 #define MTL_Q_RQDR_RXQSTS_WIDTH 2
762 #define MTL_Q_RQFCR_RFA_INDEX 1
763 #define MTL_Q_RQFCR_RFA_WIDTH 6
764 #define MTL_Q_RQFCR_RFD_INDEX 17
765 #define MTL_Q_RQFCR_RFD_WIDTH 6
766 #define MTL_Q_RQOMR_EHFC_INDEX 7
767 #define MTL_Q_RQOMR_EHFC_WIDTH 1
768 #define MTL_Q_RQOMR_RQS_INDEX 16
769 #define MTL_Q_RQOMR_RQS_WIDTH 9
770 #define MTL_Q_RQOMR_RSF_INDEX 5
771 #define MTL_Q_RQOMR_RSF_WIDTH 1
772 #define MTL_Q_RQOMR_RTC_INDEX 0
773 #define MTL_Q_RQOMR_RTC_WIDTH 2
774 #define MTL_Q_TQDR_TRCSTS_INDEX 1
775 #define MTL_Q_TQDR_TRCSTS_WIDTH 2
776 #define MTL_Q_TQDR_TXQSTS_INDEX 4
777 #define MTL_Q_TQDR_TXQSTS_WIDTH 1
778 #define MTL_Q_TQOMR_FTQ_INDEX 0
779 #define MTL_Q_TQOMR_FTQ_WIDTH 1
780 #define MTL_Q_TQOMR_Q2TCMAP_INDEX 8
781 #define MTL_Q_TQOMR_Q2TCMAP_WIDTH 3
782 #define MTL_Q_TQOMR_TQS_INDEX 16
783 #define MTL_Q_TQOMR_TQS_WIDTH 10
784 #define MTL_Q_TQOMR_TSF_INDEX 1
785 #define MTL_Q_TQOMR_TSF_WIDTH 1
786 #define MTL_Q_TQOMR_TTC_INDEX 4
787 #define MTL_Q_TQOMR_TTC_WIDTH 3
788 #define MTL_Q_TQOMR_TXQEN_INDEX 2
789 #define MTL_Q_TQOMR_TXQEN_WIDTH 2
791 /* MTL queue register value */
792 #define MTL_RSF_DISABLE 0x00
793 #define MTL_RSF_ENABLE 0x01
794 #define MTL_TSF_DISABLE 0x00
795 #define MTL_TSF_ENABLE 0x01
797 #define MTL_RX_THRESHOLD_64 0x00
798 #define MTL_RX_THRESHOLD_96 0x02
799 #define MTL_RX_THRESHOLD_128 0x03
800 #define MTL_TX_THRESHOLD_32 0x01
801 #define MTL_TX_THRESHOLD_64 0x00
802 #define MTL_TX_THRESHOLD_96 0x02
803 #define MTL_TX_THRESHOLD_128 0x03
804 #define MTL_TX_THRESHOLD_192 0x04
805 #define MTL_TX_THRESHOLD_256 0x05
806 #define MTL_TX_THRESHOLD_384 0x06
807 #define MTL_TX_THRESHOLD_512 0x07
809 #define MTL_ETSALG_WRR 0x00
810 #define MTL_ETSALG_WFQ 0x01
811 #define MTL_ETSALG_DWRR 0x02
812 #define MTL_RAA_SP 0x00
813 #define MTL_RAA_WSP 0x01
815 #define MTL_Q_DISABLED 0x00
816 #define MTL_Q_ENABLED 0x02
818 /* MTL traffic class register offsets
819 * Multiple traffic classes can be active. The first class has registers
820 * that begin at 0x1100. Each subsequent queue has registers that
821 * are accessed using an offset of 0x80 from the previous queue.
823 #define MTL_TC_BASE MTL_Q_BASE
824 #define MTL_TC_INC MTL_Q_INC
826 #define MTL_TC_ETSCR 0x10
827 #define MTL_TC_ETSSR 0x14
828 #define MTL_TC_QWR 0x18
830 /* MTL traffic class register entry bit positions and sizes */
831 #define MTL_TC_ETSCR_TSA_INDEX 0
832 #define MTL_TC_ETSCR_TSA_WIDTH 2
833 #define MTL_TC_QWR_QW_INDEX 0
834 #define MTL_TC_QWR_QW_WIDTH 21
836 /* MTL traffic class register value */
837 #define MTL_TSA_SP 0x00
838 #define MTL_TSA_ETS 0x02
840 /* PCS register offsets */
841 #define PCS_V1_WINDOW_SELECT 0x03fc
842 #define PCS_V2_WINDOW_DEF 0x9060
843 #define PCS_V2_WINDOW_SELECT 0x9064
845 /* PCS register entry bit positions and sizes */
846 #define PCS_V2_WINDOW_DEF_OFFSET_INDEX 6
847 #define PCS_V2_WINDOW_DEF_OFFSET_WIDTH 14
848 #define PCS_V2_WINDOW_DEF_SIZE_INDEX 2
849 #define PCS_V2_WINDOW_DEF_SIZE_WIDTH 4
851 /* SerDes integration register offsets */
852 #define SIR0_KR_RT_1 0x002c
853 #define SIR0_STATUS 0x0040
854 #define SIR1_SPEED 0x0000
856 /* SerDes integration register entry bit positions and sizes */
857 #define SIR0_KR_RT_1_RESET_INDEX 11
858 #define SIR0_KR_RT_1_RESET_WIDTH 1
859 #define SIR0_STATUS_RX_READY_INDEX 0
860 #define SIR0_STATUS_RX_READY_WIDTH 1
861 #define SIR0_STATUS_TX_READY_INDEX 8
862 #define SIR0_STATUS_TX_READY_WIDTH 1
863 #define SIR1_SPEED_CDR_RATE_INDEX 12
864 #define SIR1_SPEED_CDR_RATE_WIDTH 4
865 #define SIR1_SPEED_DATARATE_INDEX 4
866 #define SIR1_SPEED_DATARATE_WIDTH 2
867 #define SIR1_SPEED_PLLSEL_INDEX 3
868 #define SIR1_SPEED_PLLSEL_WIDTH 1
869 #define SIR1_SPEED_RATECHANGE_INDEX 6
870 #define SIR1_SPEED_RATECHANGE_WIDTH 1
871 #define SIR1_SPEED_TXAMP_INDEX 8
872 #define SIR1_SPEED_TXAMP_WIDTH 4
873 #define SIR1_SPEED_WORDMODE_INDEX 0
874 #define SIR1_SPEED_WORDMODE_WIDTH 3
876 /* SerDes RxTx register offsets */
877 #define RXTX_REG6 0x0018
878 #define RXTX_REG20 0x0050
879 #define RXTX_REG22 0x0058
880 #define RXTX_REG114 0x01c8
881 #define RXTX_REG129 0x0204
883 /* SerDes RxTx register entry bit positions and sizes */
884 #define RXTX_REG6_RESETB_RXD_INDEX 8
885 #define RXTX_REG6_RESETB_RXD_WIDTH 1
886 #define RXTX_REG20_BLWC_ENA_INDEX 2
887 #define RXTX_REG20_BLWC_ENA_WIDTH 1
888 #define RXTX_REG114_PQ_REG_INDEX 9
889 #define RXTX_REG114_PQ_REG_WIDTH 7
890 #define RXTX_REG129_RXDFE_CONFIG_INDEX 14
891 #define RXTX_REG129_RXDFE_CONFIG_WIDTH 2
893 /* MAC Control register offsets */
894 #define XP_PROP_0 0x0000
895 #define XP_PROP_1 0x0004
896 #define XP_PROP_2 0x0008
897 #define XP_PROP_3 0x000c
898 #define XP_PROP_4 0x0010
899 #define XP_PROP_5 0x0014
900 #define XP_MAC_ADDR_LO 0x0020
901 #define XP_MAC_ADDR_HI 0x0024
902 #define XP_ECC_ISR 0x0030
903 #define XP_ECC_IER 0x0034
904 #define XP_ECC_CNT0 0x003c
905 #define XP_ECC_CNT1 0x0040
906 #define XP_DRIVER_INT_REQ 0x0060
907 #define XP_DRIVER_INT_RO 0x0064
908 #define XP_DRIVER_SCRATCH_0 0x0068
909 #define XP_DRIVER_SCRATCH_1 0x006c
910 #define XP_INT_EN 0x0078
911 #define XP_I2C_MUTEX 0x0080
912 #define XP_MDIO_MUTEX 0x0084
914 /* MAC Control register entry bit positions and sizes */
915 #define XP_DRIVER_INT_REQ_REQUEST_INDEX 0
916 #define XP_DRIVER_INT_REQ_REQUEST_WIDTH 1
917 #define XP_DRIVER_INT_RO_STATUS_INDEX 0
918 #define XP_DRIVER_INT_RO_STATUS_WIDTH 1
919 #define XP_DRIVER_SCRATCH_0_COMMAND_INDEX 0
920 #define XP_DRIVER_SCRATCH_0_COMMAND_WIDTH 8
921 #define XP_DRIVER_SCRATCH_0_SUB_COMMAND_INDEX 8
922 #define XP_DRIVER_SCRATCH_0_SUB_COMMAND_WIDTH 8
923 #define XP_ECC_CNT0_RX_DED_INDEX 24
924 #define XP_ECC_CNT0_RX_DED_WIDTH 8
925 #define XP_ECC_CNT0_RX_SEC_INDEX 16
926 #define XP_ECC_CNT0_RX_SEC_WIDTH 8
927 #define XP_ECC_CNT0_TX_DED_INDEX 8
928 #define XP_ECC_CNT0_TX_DED_WIDTH 8
929 #define XP_ECC_CNT0_TX_SEC_INDEX 0
930 #define XP_ECC_CNT0_TX_SEC_WIDTH 8
931 #define XP_ECC_CNT1_DESC_DED_INDEX 8
932 #define XP_ECC_CNT1_DESC_DED_WIDTH 8
933 #define XP_ECC_CNT1_DESC_SEC_INDEX 0
934 #define XP_ECC_CNT1_DESC_SEC_WIDTH 8
935 #define XP_ECC_IER_DESC_DED_INDEX 0
936 #define XP_ECC_IER_DESC_DED_WIDTH 1
937 #define XP_ECC_IER_DESC_SEC_INDEX 1
938 #define XP_ECC_IER_DESC_SEC_WIDTH 1
939 #define XP_ECC_IER_RX_DED_INDEX 2
940 #define XP_ECC_IER_RX_DED_WIDTH 1
941 #define XP_ECC_IER_RX_SEC_INDEX 3
942 #define XP_ECC_IER_RX_SEC_WIDTH 1
943 #define XP_ECC_IER_TX_DED_INDEX 4
944 #define XP_ECC_IER_TX_DED_WIDTH 1
945 #define XP_ECC_IER_TX_SEC_INDEX 5
946 #define XP_ECC_IER_TX_SEC_WIDTH 1
947 #define XP_ECC_ISR_DESC_DED_INDEX 0
948 #define XP_ECC_ISR_DESC_DED_WIDTH 1
949 #define XP_ECC_ISR_DESC_SEC_INDEX 1
950 #define XP_ECC_ISR_DESC_SEC_WIDTH 1
951 #define XP_ECC_ISR_RX_DED_INDEX 2
952 #define XP_ECC_ISR_RX_DED_WIDTH 1
953 #define XP_ECC_ISR_RX_SEC_INDEX 3
954 #define XP_ECC_ISR_RX_SEC_WIDTH 1
955 #define XP_ECC_ISR_TX_DED_INDEX 4
956 #define XP_ECC_ISR_TX_DED_WIDTH 1
957 #define XP_ECC_ISR_TX_SEC_INDEX 5
958 #define XP_ECC_ISR_TX_SEC_WIDTH 1
959 #define XP_I2C_MUTEX_BUSY_INDEX 31
960 #define XP_I2C_MUTEX_BUSY_WIDTH 1
961 #define XP_I2C_MUTEX_ID_INDEX 29
962 #define XP_I2C_MUTEX_ID_WIDTH 2
963 #define XP_I2C_MUTEX_ACTIVE_INDEX 0
964 #define XP_I2C_MUTEX_ACTIVE_WIDTH 1
965 #define XP_MAC_ADDR_HI_VALID_INDEX 31
966 #define XP_MAC_ADDR_HI_VALID_WIDTH 1
967 #define XP_PROP_0_CONN_TYPE_INDEX 28
968 #define XP_PROP_0_CONN_TYPE_WIDTH 3
969 #define XP_PROP_0_MDIO_ADDR_INDEX 16
970 #define XP_PROP_0_MDIO_ADDR_WIDTH 5
971 #define XP_PROP_0_PORT_ID_INDEX 0
972 #define XP_PROP_0_PORT_ID_WIDTH 8
973 #define XP_PROP_0_PORT_MODE_INDEX 8
974 #define XP_PROP_0_PORT_MODE_WIDTH 4
975 #define XP_PROP_0_PORT_SPEEDS_INDEX 23
976 #define XP_PROP_0_PORT_SPEEDS_WIDTH 4
977 #define XP_PROP_1_MAX_RX_DMA_INDEX 24
978 #define XP_PROP_1_MAX_RX_DMA_WIDTH 5
979 #define XP_PROP_1_MAX_RX_QUEUES_INDEX 8
980 #define XP_PROP_1_MAX_RX_QUEUES_WIDTH 5
981 #define XP_PROP_1_MAX_TX_DMA_INDEX 16
982 #define XP_PROP_1_MAX_TX_DMA_WIDTH 5
983 #define XP_PROP_1_MAX_TX_QUEUES_INDEX 0
984 #define XP_PROP_1_MAX_TX_QUEUES_WIDTH 5
985 #define XP_PROP_2_RX_FIFO_SIZE_INDEX 16
986 #define XP_PROP_2_RX_FIFO_SIZE_WIDTH 16
987 #define XP_PROP_2_TX_FIFO_SIZE_INDEX 0
988 #define XP_PROP_2_TX_FIFO_SIZE_WIDTH 16
989 #define XP_PROP_3_GPIO_MASK_INDEX 28
990 #define XP_PROP_3_GPIO_MASK_WIDTH 4
991 #define XP_PROP_3_GPIO_MOD_ABS_INDEX 20
992 #define XP_PROP_3_GPIO_MOD_ABS_WIDTH 4
993 #define XP_PROP_3_GPIO_RATE_SELECT_INDEX 16
994 #define XP_PROP_3_GPIO_RATE_SELECT_WIDTH 4
995 #define XP_PROP_3_GPIO_RX_LOS_INDEX 24
996 #define XP_PROP_3_GPIO_RX_LOS_WIDTH 4
997 #define XP_PROP_3_GPIO_TX_FAULT_INDEX 12
998 #define XP_PROP_3_GPIO_TX_FAULT_WIDTH 4
999 #define XP_PROP_3_GPIO_ADDR_INDEX 8
1000 #define XP_PROP_3_GPIO_ADDR_WIDTH 3
1001 #define XP_PROP_3_MDIO_RESET_INDEX 0
1002 #define XP_PROP_3_MDIO_RESET_WIDTH 2
1003 #define XP_PROP_3_MDIO_RESET_I2C_ADDR_INDEX 8
1004 #define XP_PROP_3_MDIO_RESET_I2C_ADDR_WIDTH 3
1005 #define XP_PROP_3_MDIO_RESET_I2C_GPIO_INDEX 12
1006 #define XP_PROP_3_MDIO_RESET_I2C_GPIO_WIDTH 4
1007 #define XP_PROP_3_MDIO_RESET_INT_GPIO_INDEX 4
1008 #define XP_PROP_3_MDIO_RESET_INT_GPIO_WIDTH 2
1009 #define XP_PROP_4_MUX_ADDR_HI_INDEX 8
1010 #define XP_PROP_4_MUX_ADDR_HI_WIDTH 5
1011 #define XP_PROP_4_MUX_ADDR_LO_INDEX 0
1012 #define XP_PROP_4_MUX_ADDR_LO_WIDTH 3
1013 #define XP_PROP_4_MUX_CHAN_INDEX 4
1014 #define XP_PROP_4_MUX_CHAN_WIDTH 3
1015 #define XP_PROP_4_REDRV_ADDR_INDEX 16
1016 #define XP_PROP_4_REDRV_ADDR_WIDTH 7
1017 #define XP_PROP_4_REDRV_IF_INDEX 23
1018 #define XP_PROP_4_REDRV_IF_WIDTH 1
1019 #define XP_PROP_4_REDRV_LANE_INDEX 24
1020 #define XP_PROP_4_REDRV_LANE_WIDTH 3
1021 #define XP_PROP_4_REDRV_MODEL_INDEX 28
1022 #define XP_PROP_4_REDRV_MODEL_WIDTH 3
1023 #define XP_PROP_4_REDRV_PRESENT_INDEX 31
1024 #define XP_PROP_4_REDRV_PRESENT_WIDTH 1
1026 /* I2C Control register offsets */
1027 #define IC_CON 0x0000
1028 #define IC_TAR 0x0004
1029 #define IC_DATA_CMD 0x0010
1030 #define IC_INTR_STAT 0x002c
1031 #define IC_INTR_MASK 0x0030
1032 #define IC_RAW_INTR_STAT 0x0034
1033 #define IC_CLR_INTR 0x0040
1034 #define IC_CLR_TX_ABRT 0x0054
1035 #define IC_CLR_STOP_DET 0x0060
1036 #define IC_ENABLE 0x006c
1037 #define IC_TXFLR 0x0074
1038 #define IC_RXFLR 0x0078
1039 #define IC_TX_ABRT_SOURCE 0x0080
1040 #define IC_ENABLE_STATUS 0x009c
1041 #define IC_COMP_PARAM_1 0x00f4
1043 /* I2C Control register entry bit positions and sizes */
1044 #define IC_COMP_PARAM_1_MAX_SPEED_MODE_INDEX 2
1045 #define IC_COMP_PARAM_1_MAX_SPEED_MODE_WIDTH 2
1046 #define IC_COMP_PARAM_1_RX_BUFFER_DEPTH_INDEX 8
1047 #define IC_COMP_PARAM_1_RX_BUFFER_DEPTH_WIDTH 8
1048 #define IC_COMP_PARAM_1_TX_BUFFER_DEPTH_INDEX 16
1049 #define IC_COMP_PARAM_1_TX_BUFFER_DEPTH_WIDTH 8
1050 #define IC_CON_MASTER_MODE_INDEX 0
1051 #define IC_CON_MASTER_MODE_WIDTH 1
1052 #define IC_CON_RESTART_EN_INDEX 5
1053 #define IC_CON_RESTART_EN_WIDTH 1
1054 #define IC_CON_RX_FIFO_FULL_HOLD_INDEX 9
1055 #define IC_CON_RX_FIFO_FULL_HOLD_WIDTH 1
1056 #define IC_CON_SLAVE_DISABLE_INDEX 6
1057 #define IC_CON_SLAVE_DISABLE_WIDTH 1
1058 #define IC_CON_SPEED_INDEX 1
1059 #define IC_CON_SPEED_WIDTH 2
1060 #define IC_DATA_CMD_CMD_INDEX 8
1061 #define IC_DATA_CMD_CMD_WIDTH 1
1062 #define IC_DATA_CMD_STOP_INDEX 9
1063 #define IC_DATA_CMD_STOP_WIDTH 1
1064 #define IC_ENABLE_ABORT_INDEX 1
1065 #define IC_ENABLE_ABORT_WIDTH 1
1066 #define IC_ENABLE_EN_INDEX 0
1067 #define IC_ENABLE_EN_WIDTH 1
1068 #define IC_ENABLE_STATUS_EN_INDEX 0
1069 #define IC_ENABLE_STATUS_EN_WIDTH 1
1070 #define IC_INTR_MASK_TX_EMPTY_INDEX 4
1071 #define IC_INTR_MASK_TX_EMPTY_WIDTH 1
1072 #define IC_RAW_INTR_STAT_RX_FULL_INDEX 2
1073 #define IC_RAW_INTR_STAT_RX_FULL_WIDTH 1
1074 #define IC_RAW_INTR_STAT_STOP_DET_INDEX 9
1075 #define IC_RAW_INTR_STAT_STOP_DET_WIDTH 1
1076 #define IC_RAW_INTR_STAT_TX_ABRT_INDEX 6
1077 #define IC_RAW_INTR_STAT_TX_ABRT_WIDTH 1
1078 #define IC_RAW_INTR_STAT_TX_EMPTY_INDEX 4
1079 #define IC_RAW_INTR_STAT_TX_EMPTY_WIDTH 1
1081 /* I2C Control register value */
1082 #define IC_TX_ABRT_7B_ADDR_NOACK 0x0001
1083 #define IC_TX_ABRT_ARB_LOST 0x1000
1085 /* Descriptor/Packet entry bit positions and sizes */
1086 #define RX_PACKET_ERRORS_CRC_INDEX 2
1087 #define RX_PACKET_ERRORS_CRC_WIDTH 1
1088 #define RX_PACKET_ERRORS_FRAME_INDEX 3
1089 #define RX_PACKET_ERRORS_FRAME_WIDTH 1
1090 #define RX_PACKET_ERRORS_LENGTH_INDEX 0
1091 #define RX_PACKET_ERRORS_LENGTH_WIDTH 1
1092 #define RX_PACKET_ERRORS_OVERRUN_INDEX 1
1093 #define RX_PACKET_ERRORS_OVERRUN_WIDTH 1
1095 #define RX_PACKET_ATTRIBUTES_CSUM_DONE_INDEX 0
1096 #define RX_PACKET_ATTRIBUTES_CSUM_DONE_WIDTH 1
1097 #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_INDEX 1
1098 #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_WIDTH 1
1099 #define RX_PACKET_ATTRIBUTES_INCOMPLETE_INDEX 2
1100 #define RX_PACKET_ATTRIBUTES_INCOMPLETE_WIDTH 1
1101 #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_INDEX 3
1102 #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_WIDTH 1
1103 #define RX_PACKET_ATTRIBUTES_CONTEXT_INDEX 4
1104 #define RX_PACKET_ATTRIBUTES_CONTEXT_WIDTH 1
1105 #define RX_PACKET_ATTRIBUTES_RX_TSTAMP_INDEX 5
1106 #define RX_PACKET_ATTRIBUTES_RX_TSTAMP_WIDTH 1
1107 #define RX_PACKET_ATTRIBUTES_RSS_HASH_INDEX 6
1108 #define RX_PACKET_ATTRIBUTES_RSS_HASH_WIDTH 1
1110 #define RX_NORMAL_DESC0_OVT_INDEX 0
1111 #define RX_NORMAL_DESC0_OVT_WIDTH 16
1112 #define RX_NORMAL_DESC2_HL_INDEX 0
1113 #define RX_NORMAL_DESC2_HL_WIDTH 10
1114 #define RX_NORMAL_DESC3_CDA_INDEX 27
1115 #define RX_NORMAL_DESC3_CDA_WIDTH 1
1116 #define RX_NORMAL_DESC3_CTXT_INDEX 30
1117 #define RX_NORMAL_DESC3_CTXT_WIDTH 1
1118 #define RX_NORMAL_DESC3_ES_INDEX 15
1119 #define RX_NORMAL_DESC3_ES_WIDTH 1
1120 #define RX_NORMAL_DESC3_ETLT_INDEX 16
1121 #define RX_NORMAL_DESC3_ETLT_WIDTH 4
1122 #define RX_NORMAL_DESC3_FD_INDEX 29
1123 #define RX_NORMAL_DESC3_FD_WIDTH 1
1124 #define RX_NORMAL_DESC3_INTE_INDEX 30
1125 #define RX_NORMAL_DESC3_INTE_WIDTH 1
1126 #define RX_NORMAL_DESC3_L34T_INDEX 20
1127 #define RX_NORMAL_DESC3_L34T_WIDTH 4
1128 #define RX_NORMAL_DESC3_LD_INDEX 28
1129 #define RX_NORMAL_DESC3_LD_WIDTH 1
1130 #define RX_NORMAL_DESC3_OWN_INDEX 31
1131 #define RX_NORMAL_DESC3_OWN_WIDTH 1
1132 #define RX_NORMAL_DESC3_PL_INDEX 0
1133 #define RX_NORMAL_DESC3_PL_WIDTH 14
1134 #define RX_NORMAL_DESC3_RSV_INDEX 26
1135 #define RX_NORMAL_DESC3_RSV_WIDTH 1
1137 #define RX_DESC3_L34T_IPV4_TCP 1
1138 #define RX_DESC3_L34T_IPV4_UDP 2
1139 #define RX_DESC3_L34T_IPV4_ICMP 3
1140 #define RX_DESC3_L34T_IPV6_TCP 9
1141 #define RX_DESC3_L34T_IPV6_UDP 10
1142 #define RX_DESC3_L34T_IPV6_ICMP 11
1144 #define RX_CONTEXT_DESC3_TSA_INDEX 4
1145 #define RX_CONTEXT_DESC3_TSA_WIDTH 1
1146 #define RX_CONTEXT_DESC3_TSD_INDEX 6
1147 #define RX_CONTEXT_DESC3_TSD_WIDTH 1
1149 #define TX_PACKET_ATTRIBUTES_CSUM_ENABLE_INDEX 0
1150 #define TX_PACKET_ATTRIBUTES_CSUM_ENABLE_WIDTH 1
1151 #define TX_PACKET_ATTRIBUTES_TSO_ENABLE_INDEX 1
1152 #define TX_PACKET_ATTRIBUTES_TSO_ENABLE_WIDTH 1
1153 #define TX_PACKET_ATTRIBUTES_VLAN_CTAG_INDEX 2
1154 #define TX_PACKET_ATTRIBUTES_VLAN_CTAG_WIDTH 1
1155 #define TX_PACKET_ATTRIBUTES_PTP_INDEX 3
1156 #define TX_PACKET_ATTRIBUTES_PTP_WIDTH 1
1158 #define TX_CONTEXT_DESC2_MSS_INDEX 0
1159 #define TX_CONTEXT_DESC2_MSS_WIDTH 15
1160 #define TX_CONTEXT_DESC3_CTXT_INDEX 30
1161 #define TX_CONTEXT_DESC3_CTXT_WIDTH 1
1162 #define TX_CONTEXT_DESC3_TCMSSV_INDEX 26
1163 #define TX_CONTEXT_DESC3_TCMSSV_WIDTH 1
1164 #define TX_CONTEXT_DESC3_VLTV_INDEX 16
1165 #define TX_CONTEXT_DESC3_VLTV_WIDTH 1
1166 #define TX_CONTEXT_DESC3_VT_INDEX 0
1167 #define TX_CONTEXT_DESC3_VT_WIDTH 16
1169 #define TX_NORMAL_DESC2_HL_B1L_INDEX 0
1170 #define TX_NORMAL_DESC2_HL_B1L_WIDTH 14
1171 #define TX_NORMAL_DESC2_IC_INDEX 31
1172 #define TX_NORMAL_DESC2_IC_WIDTH 1
1173 #define TX_NORMAL_DESC2_TTSE_INDEX 30
1174 #define TX_NORMAL_DESC2_TTSE_WIDTH 1
1175 #define TX_NORMAL_DESC2_VTIR_INDEX 14
1176 #define TX_NORMAL_DESC2_VTIR_WIDTH 2
1177 #define TX_NORMAL_DESC3_CIC_INDEX 16
1178 #define TX_NORMAL_DESC3_CIC_WIDTH 2
1179 #define TX_NORMAL_DESC3_CPC_INDEX 26
1180 #define TX_NORMAL_DESC3_CPC_WIDTH 2
1181 #define TX_NORMAL_DESC3_CTXT_INDEX 30
1182 #define TX_NORMAL_DESC3_CTXT_WIDTH 1
1183 #define TX_NORMAL_DESC3_FD_INDEX 29
1184 #define TX_NORMAL_DESC3_FD_WIDTH 1
1185 #define TX_NORMAL_DESC3_FL_INDEX 0
1186 #define TX_NORMAL_DESC3_FL_WIDTH 15
1187 #define TX_NORMAL_DESC3_LD_INDEX 28
1188 #define TX_NORMAL_DESC3_LD_WIDTH 1
1189 #define TX_NORMAL_DESC3_OWN_INDEX 31
1190 #define TX_NORMAL_DESC3_OWN_WIDTH 1
1191 #define TX_NORMAL_DESC3_TCPHDRLEN_INDEX 19
1192 #define TX_NORMAL_DESC3_TCPHDRLEN_WIDTH 4
1193 #define TX_NORMAL_DESC3_TCPPL_INDEX 0
1194 #define TX_NORMAL_DESC3_TCPPL_WIDTH 18
1195 #define TX_NORMAL_DESC3_TSE_INDEX 18
1196 #define TX_NORMAL_DESC3_TSE_WIDTH 1
1198 #define TX_NORMAL_DESC2_VLAN_INSERT 0x2
1200 /* MDIO undefined or vendor specific registers */
1201 #ifndef MDIO_PMA_10GBR_PMD_CTRL
1202 #define MDIO_PMA_10GBR_PMD_CTRL 0x0096
1205 #ifndef MDIO_PMA_10GBR_FECCTRL
1206 #define MDIO_PMA_10GBR_FECCTRL 0x00ab
1209 #ifndef MDIO_PCS_DIG_CTRL
1210 #define MDIO_PCS_DIG_CTRL 0x8000
1214 #define MDIO_AN_XNP 0x0016
1218 #define MDIO_AN_LPX 0x0019
1221 #ifndef MDIO_AN_COMP_STAT
1222 #define MDIO_AN_COMP_STAT 0x0030
1225 #ifndef MDIO_AN_INTMASK
1226 #define MDIO_AN_INTMASK 0x8001
1230 #define MDIO_AN_INT 0x8002
1233 #ifndef MDIO_VEND2_AN_ADVERTISE
1234 #define MDIO_VEND2_AN_ADVERTISE 0x0004
1237 #ifndef MDIO_VEND2_AN_LP_ABILITY
1238 #define MDIO_VEND2_AN_LP_ABILITY 0x0005
1241 #ifndef MDIO_VEND2_AN_CTRL
1242 #define MDIO_VEND2_AN_CTRL 0x8001
1245 #ifndef MDIO_VEND2_AN_STAT
1246 #define MDIO_VEND2_AN_STAT 0x8002
1249 #ifndef MDIO_VEND2_PMA_CDR_CONTROL
1250 #define MDIO_VEND2_PMA_CDR_CONTROL 0x8056
1253 #ifndef MDIO_CTRL1_SPEED1G
1254 #define MDIO_CTRL1_SPEED1G (MDIO_CTRL1_SPEED10G & ~BMCR_SPEED100)
1257 #ifndef MDIO_VEND2_CTRL1_AN_ENABLE
1258 #define MDIO_VEND2_CTRL1_AN_ENABLE BIT(12)
1261 #ifndef MDIO_VEND2_CTRL1_AN_RESTART
1262 #define MDIO_VEND2_CTRL1_AN_RESTART BIT(9)
1265 #ifndef MDIO_VEND2_CTRL1_SS6
1266 #define MDIO_VEND2_CTRL1_SS6 BIT(6)
1269 #ifndef MDIO_VEND2_CTRL1_SS13
1270 #define MDIO_VEND2_CTRL1_SS13 BIT(13)
1273 /* MDIO mask values */
1274 #define AXGBE_AN_CL73_INT_CMPLT BIT(0)
1275 #define AXGBE_AN_CL73_INC_LINK BIT(1)
1276 #define AXGBE_AN_CL73_PG_RCV BIT(2)
1277 #define AXGBE_AN_CL73_INT_MASK 0x07
1279 #define AXGBE_XNP_MCF_NULL_MESSAGE 0x001
1280 #define AXGBE_XNP_ACK_PROCESSED BIT(12)
1281 #define AXGBE_XNP_MP_FORMATTED BIT(13)
1282 #define AXGBE_XNP_NP_EXCHANGE BIT(15)
1284 #define AXGBE_KR_TRAINING_START BIT(0)
1285 #define AXGBE_KR_TRAINING_ENABLE BIT(1)
1287 #define AXGBE_PCS_CL37_BP BIT(12)
1289 #define AXGBE_AN_CL37_INT_CMPLT BIT(0)
1290 #define AXGBE_AN_CL37_INT_MASK 0x01
1292 #define AXGBE_AN_CL37_HD_MASK 0x40
1293 #define AXGBE_AN_CL37_FD_MASK 0x20
1295 #define AXGBE_AN_CL37_PCS_MODE_MASK 0x06
1296 #define AXGBE_AN_CL37_PCS_MODE_BASEX 0x00
1297 #define AXGBE_AN_CL37_PCS_MODE_SGMII 0x04
1298 #define AXGBE_AN_CL37_TX_CONFIG_MASK 0x08
1300 #define AXGBE_PMA_CDR_TRACK_EN_MASK 0x01
1301 #define AXGBE_PMA_CDR_TRACK_EN_OFF 0x00
1302 #define AXGBE_PMA_CDR_TRACK_EN_ON 0x01
1307 #define rmb() rte_rmb() /* dpdk rte provided rmb */
1308 #define wmb() rte_wmb() /* dpdk rte provided wmb */
1314 typedef unsigned char u8;
1315 typedef unsigned short u16;
1316 typedef unsigned int u32;
1317 typedef unsigned long long u64;
1318 typedef unsigned long long dma_addr_t;
1320 static inline uint32_t low32_value(uint64_t addr)
1322 return (addr) & 0x0ffffffff;
1325 static inline uint32_t high32_value(uint64_t addr)
1327 return (addr >> 32) & 0x0ffffffff;
1332 /* Bit setting and getting macros
1333 * The get macro will extract the current bit field value from within
1336 * The set macro will clear the current bit field value within the
1337 * variable and then set the bit field of the variable to the
1340 #define GET_BITS(_var, _index, _width) \
1341 (((_var) >> (_index)) & ((0x1 << (_width)) - 1))
1343 #define SET_BITS(_var, _index, _width, _val) \
1345 (_var) &= ~(((0x1 << (_width)) - 1) << (_index)); \
1346 (_var) |= (((_val) & ((0x1 << (_width)) - 1)) << (_index)); \
1349 #define GET_BITS_LE(_var, _index, _width) \
1350 ((rte_le_to_cpu_32((_var)) >> (_index)) & ((0x1 << (_width)) - 1))
1352 #define SET_BITS_LE(_var, _index, _width, _val) \
1354 (_var) &= rte_cpu_to_le_32(~(((0x1 << (_width)) - 1) << (_index)));\
1355 (_var) |= rte_cpu_to_le_32((((_val) & \
1356 ((0x1 << (_width)) - 1)) << (_index))); \
1359 /* Bit setting and getting macros based on register fields
1360 * The get macro uses the bit field definitions formed using the input
1361 * names to extract the current bit field value from within the
1364 * The set macro uses the bit field definitions formed using the input
1365 * names to set the bit field of the variable to the specified value
1367 #define AXGMAC_GET_BITS(_var, _prefix, _field) \
1369 _prefix##_##_field##_INDEX, \
1370 _prefix##_##_field##_WIDTH)
1372 #define AXGMAC_SET_BITS(_var, _prefix, _field, _val) \
1374 _prefix##_##_field##_INDEX, \
1375 _prefix##_##_field##_WIDTH, (_val))
1377 #define AXGMAC_GET_BITS_LE(_var, _prefix, _field) \
1378 GET_BITS_LE((_var), \
1379 _prefix##_##_field##_INDEX, \
1380 _prefix##_##_field##_WIDTH)
1382 #define AXGMAC_SET_BITS_LE(_var, _prefix, _field, _val) \
1383 SET_BITS_LE((_var), \
1384 _prefix##_##_field##_INDEX, \
1385 _prefix##_##_field##_WIDTH, (_val))
1387 /* Macros for reading or writing registers
1388 * The ioread macros will get bit fields or full values using the
1389 * register definitions formed using the input names
1391 * The iowrite macros will set bit fields or full values using the
1392 * register definitions formed using the input names
1394 #define AXGMAC_IOREAD(_pdata, _reg) \
1395 rte_read32((uint8_t *)((_pdata)->xgmac_regs) + (_reg))
1397 #define AXGMAC_IOREAD_BITS(_pdata, _reg, _field) \
1398 GET_BITS(AXGMAC_IOREAD((_pdata), _reg), \
1399 _reg##_##_field##_INDEX, \
1400 _reg##_##_field##_WIDTH)
1402 #define AXGMAC_IOWRITE(_pdata, _reg, _val) \
1403 rte_write32((_val), \
1404 (uint8_t *)((_pdata)->xgmac_regs) + (_reg))
1406 #define AXGMAC_IOWRITE_BITS(_pdata, _reg, _field, _val) \
1408 u32 reg_val = AXGMAC_IOREAD((_pdata), _reg); \
1410 _reg##_##_field##_INDEX, \
1411 _reg##_##_field##_WIDTH, (_val)); \
1412 AXGMAC_IOWRITE((_pdata), _reg, reg_val); \
1415 /* Macros for reading or writing MTL queue or traffic class registers
1416 * Similar to the standard read and write macros except that the
1417 * base register value is calculated by the queue or traffic class number
1419 #define AXGMAC_MTL_IOREAD(_pdata, _n, _reg) \
1420 rte_read32((uint8_t *)((_pdata)->xgmac_regs) + \
1421 MTL_Q_BASE + ((_n) * MTL_Q_INC) + (_reg))
1423 #define AXGMAC_MTL_IOREAD_BITS(_pdata, _n, _reg, _field) \
1424 GET_BITS(AXGMAC_MTL_IOREAD((_pdata), (_n), (_reg)), \
1425 _reg##_##_field##_INDEX, \
1426 _reg##_##_field##_WIDTH)
1428 #define AXGMAC_MTL_IOWRITE(_pdata, _n, _reg, _val) \
1429 rte_write32((_val), (uint8_t *)((_pdata)->xgmac_regs) +\
1430 MTL_Q_BASE + ((_n) * MTL_Q_INC) + (_reg))
1432 #define AXGMAC_MTL_IOWRITE_BITS(_pdata, _n, _reg, _field, _val) \
1434 u32 reg_val = AXGMAC_MTL_IOREAD((_pdata), (_n), _reg); \
1436 _reg##_##_field##_INDEX, \
1437 _reg##_##_field##_WIDTH, (_val)); \
1438 AXGMAC_MTL_IOWRITE((_pdata), (_n), _reg, reg_val); \
1441 /* Macros for reading or writing DMA channel registers
1442 * Similar to the standard read and write macros except that the
1443 * base register value is obtained from the ring
1445 #define AXGMAC_DMA_IOREAD(_channel, _reg) \
1446 rte_read32((uint8_t *)((_channel)->dma_regs) + (_reg))
1448 #define AXGMAC_DMA_IOREAD_BITS(_channel, _reg, _field) \
1449 GET_BITS(AXGMAC_DMA_IOREAD((_channel), _reg), \
1450 _reg##_##_field##_INDEX, \
1451 _reg##_##_field##_WIDTH)
1453 #define AXGMAC_DMA_IOWRITE(_channel, _reg, _val) \
1454 rte_write32((_val), \
1455 (uint8_t *)((_channel)->dma_regs) + (_reg))
1457 #define AXGMAC_DMA_IOWRITE_BITS(_channel, _reg, _field, _val) \
1459 u32 reg_val = AXGMAC_DMA_IOREAD((_channel), _reg); \
1461 _reg##_##_field##_INDEX, \
1462 _reg##_##_field##_WIDTH, (_val)); \
1463 AXGMAC_DMA_IOWRITE((_channel), _reg, reg_val); \
1466 /* Macros for building, reading or writing register values or bits
1467 * within the register values of XPCS registers.
1469 #define XPCS_GET_BITS(_var, _prefix, _field) \
1471 _prefix##_##_field##_INDEX, \
1472 _prefix##_##_field##_WIDTH)
1474 #define XPCS_SET_BITS(_var, _prefix, _field, _val) \
1476 _prefix##_##_field##_INDEX, \
1477 _prefix##_##_field##_WIDTH, (_val))
1479 #define XPCS32_IOWRITE(_pdata, _off, _val) \
1481 (uint8_t *)((_pdata)->xpcs_regs) + (_off))
1483 #define XPCS32_IOREAD(_pdata, _off) \
1484 rte_read32((uint8_t *)((_pdata)->xpcs_regs) + (_off))
1486 #define XPCS16_IOWRITE(_pdata, _off, _val) \
1488 (uint8_t *)((_pdata)->xpcs_regs) + (_off))
1490 #define XPCS16_IOREAD(_pdata, _off) \
1491 rte_read16((uint8_t *)((_pdata)->xpcs_regs) + (_off))
1493 /* Macros for building, reading or writing register values or bits
1494 * within the register values of SerDes integration registers.
1496 #define XSIR_GET_BITS(_var, _prefix, _field) \
1498 _prefix##_##_field##_INDEX, \
1499 _prefix##_##_field##_WIDTH)
1501 #define XSIR_SET_BITS(_var, _prefix, _field, _val) \
1503 _prefix##_##_field##_INDEX, \
1504 _prefix##_##_field##_WIDTH, (_val))
1506 #define XSIR0_IOREAD(_pdata, _reg) \
1507 rte_read16((uint8_t *)((_pdata)->sir0_regs) + (_reg))
1509 #define XSIR0_IOREAD_BITS(_pdata, _reg, _field) \
1510 GET_BITS(XSIR0_IOREAD((_pdata), _reg), \
1511 _reg##_##_field##_INDEX, \
1512 _reg##_##_field##_WIDTH)
1514 #define XSIR0_IOWRITE(_pdata, _reg, _val) \
1515 rte_write16((_val), \
1516 (uint8_t *)((_pdata)->sir0_regs) + (_reg))
1518 #define XSIR0_IOWRITE_BITS(_pdata, _reg, _field, _val) \
1520 u16 reg_val = XSIR0_IOREAD((_pdata), _reg); \
1522 _reg##_##_field##_INDEX, \
1523 _reg##_##_field##_WIDTH, (_val)); \
1524 XSIR0_IOWRITE((_pdata), _reg, reg_val); \
1527 #define XSIR1_IOREAD(_pdata, _reg) \
1528 rte_read16((uint8_t *)((_pdata)->sir1_regs) + _reg)
1530 #define XSIR1_IOREAD_BITS(_pdata, _reg, _field) \
1531 GET_BITS(XSIR1_IOREAD((_pdata), _reg), \
1532 _reg##_##_field##_INDEX, \
1533 _reg##_##_field##_WIDTH)
1535 #define XSIR1_IOWRITE(_pdata, _reg, _val) \
1536 rte_write16((_val), \
1537 (uint8_t *)((_pdata)->sir1_regs) + (_reg))
1539 #define XSIR1_IOWRITE_BITS(_pdata, _reg, _field, _val) \
1541 u16 reg_val = XSIR1_IOREAD((_pdata), _reg); \
1543 _reg##_##_field##_INDEX, \
1544 _reg##_##_field##_WIDTH, (_val)); \
1545 XSIR1_IOWRITE((_pdata), _reg, reg_val); \
1548 /* Macros for building, reading or writing register values or bits
1549 * within the register values of SerDes RxTx registers.
1551 #define XRXTX_IOREAD(_pdata, _reg) \
1552 rte_read16((uint8_t *)((_pdata)->rxtx_regs) + (_reg))
1554 #define XRXTX_IOREAD_BITS(_pdata, _reg, _field) \
1555 GET_BITS(XRXTX_IOREAD((_pdata), _reg), \
1556 _reg##_##_field##_INDEX, \
1557 _reg##_##_field##_WIDTH)
1559 #define XRXTX_IOWRITE(_pdata, _reg, _val) \
1560 rte_write16((_val), \
1561 (uint8_t *)((_pdata)->rxtx_regs) + (_reg))
1563 #define XRXTX_IOWRITE_BITS(_pdata, _reg, _field, _val) \
1565 u16 reg_val = XRXTX_IOREAD((_pdata), _reg); \
1567 _reg##_##_field##_INDEX, \
1568 _reg##_##_field##_WIDTH, (_val)); \
1569 XRXTX_IOWRITE((_pdata), _reg, reg_val); \
1572 /* Macros for building, reading or writing register values or bits
1573 * within the register values of MAC Control registers.
1575 #define XP_GET_BITS(_var, _prefix, _field) \
1577 _prefix##_##_field##_INDEX, \
1578 _prefix##_##_field##_WIDTH)
1580 #define XP_SET_BITS(_var, _prefix, _field, _val) \
1582 _prefix##_##_field##_INDEX, \
1583 _prefix##_##_field##_WIDTH, (_val))
1585 #define XP_IOREAD(_pdata, _reg) \
1586 rte_read32((uint8_t *)((_pdata)->xprop_regs) + (_reg))
1588 #define XP_IOREAD_BITS(_pdata, _reg, _field) \
1589 GET_BITS(XP_IOREAD((_pdata), (_reg)), \
1590 _reg##_##_field##_INDEX, \
1591 _reg##_##_field##_WIDTH)
1593 #define XP_IOWRITE(_pdata, _reg, _val) \
1594 rte_write32((_val), \
1595 (uint8_t *)((_pdata)->xprop_regs) + (_reg))
1597 #define XP_IOWRITE_BITS(_pdata, _reg, _field, _val) \
1599 u32 reg_val = XP_IOREAD((_pdata), (_reg)); \
1601 _reg##_##_field##_INDEX, \
1602 _reg##_##_field##_WIDTH, (_val)); \
1603 XP_IOWRITE((_pdata), (_reg), reg_val); \
1606 /* Macros for building, reading or writing register values or bits
1607 * within the register values of I2C Control registers.
1609 #define XI2C_GET_BITS(_var, _prefix, _field) \
1611 _prefix##_##_field##_INDEX, \
1612 _prefix##_##_field##_WIDTH)
1614 #define XI2C_SET_BITS(_var, _prefix, _field, _val) \
1616 _prefix##_##_field##_INDEX, \
1617 _prefix##_##_field##_WIDTH, (_val))
1619 #define XI2C_IOREAD(_pdata, _reg) \
1620 rte_read32((uint8_t *)((_pdata)->xi2c_regs) + (_reg))
1622 #define XI2C_IOREAD_BITS(_pdata, _reg, _field) \
1623 GET_BITS(XI2C_IOREAD((_pdata), (_reg)), \
1624 _reg##_##_field##_INDEX, \
1625 _reg##_##_field##_WIDTH)
1627 #define XI2C_IOWRITE(_pdata, _reg, _val) \
1628 rte_write32((_val), \
1629 (uint8_t *)((_pdata)->xi2c_regs) + (_reg))
1631 #define XI2C_IOWRITE_BITS(_pdata, _reg, _field, _val) \
1633 u32 reg_val = XI2C_IOREAD((_pdata), (_reg)); \
1635 _reg##_##_field##_INDEX, \
1636 _reg##_##_field##_WIDTH, (_val)); \
1637 XI2C_IOWRITE((_pdata), (_reg), reg_val); \
1640 /* Macros for building, reading or writing register values or bits
1641 * using MDIO. Different from above because of the use of standardized
1642 * Linux include values. No shifting is performed with the bit
1643 * operations, everything works on mask values.
1645 #define XMDIO_READ(_pdata, _mmd, _reg) \
1646 ((_pdata)->hw_if.read_mmd_regs((_pdata), 0, \
1647 MII_ADDR_C45 | ((_mmd) << 16) | ((_reg) & 0xffff)))
1649 #define XMDIO_READ_BITS(_pdata, _mmd, _reg, _mask) \
1650 (XMDIO_READ((_pdata), _mmd, _reg) & _mask)
1652 #define XMDIO_WRITE(_pdata, _mmd, _reg, _val) \
1653 ((_pdata)->hw_if.write_mmd_regs((_pdata), 0, \
1654 MII_ADDR_C45 | ((_mmd) << 16) | ((_reg) & 0xffff), (_val)))
1656 #define XMDIO_WRITE_BITS(_pdata, _mmd, _reg, _mask, _val) \
1658 u32 mmd_val = XMDIO_READ((_pdata), (_mmd), (_reg)); \
1659 mmd_val &= ~(_mask); \
1660 mmd_val |= (_val); \
1661 XMDIO_WRITE((_pdata), (_mmd), (_reg), (mmd_val)); \
1665 * time_after(a,b) returns true if the time a is after time b.
1667 * Do this with "<0" and ">=0" to only test the sign of the result. A
1668 * good compiler would generate better code (and a really good compiler
1669 * wouldn't care). Gcc is currently neither.
1671 #define time_after(a, b) ((long)((b) - (a)) < 0)
1672 #define time_before(a, b) time_after(b, a)
1674 #define time_after_eq(a, b) ((long)((a) - (b)) >= 0)
1675 #define time_before_eq(a, b) time_after_eq(b, a)
1677 /*---bitmap support apis---*/
1678 static inline int axgbe_test_bit(int nr, volatile unsigned long *addr)
1683 res = ((*addr) & (1UL << nr)) != 0;
1688 static inline void axgbe_set_bit(unsigned int nr, volatile unsigned long *addr)
1690 __sync_fetch_and_or(addr, (1UL << nr));
1693 static inline void axgbe_clear_bit(int nr, volatile unsigned long *addr)
1695 __sync_fetch_and_and(addr, ~(1UL << nr));
1698 static inline int axgbe_test_and_clear_bit(int nr, volatile unsigned long *addr)
1700 unsigned long mask = (1UL << nr);
1702 return __sync_fetch_and_and(addr, ~mask) & mask;
1705 static inline unsigned long msecs_to_timer_cycles(unsigned int m)
1707 return rte_get_timer_hz() * (m / 1000);
1710 #endif /* __AXGBE_COMMON_H__ */