0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _GEMINI_ETHERNET_H
0010 #define _GEMINI_ETHERNET_H
0011
0012 #include <linux/bitops.h>
0013
0014
0015 #define TOE_NONTOE_QUE_HDR_BASE 0x2000
0016 #define TOE_TOE_QUE_HDR_BASE 0x3000
0017
0018
0019 #define TOE_SW_FREE_QID 0x00
0020 #define TOE_HW_FREE_QID 0x01
0021 #define TOE_GMAC0_SW_TXQ0_QID 0x02
0022 #define TOE_GMAC0_SW_TXQ1_QID 0x03
0023 #define TOE_GMAC0_SW_TXQ2_QID 0x04
0024 #define TOE_GMAC0_SW_TXQ3_QID 0x05
0025 #define TOE_GMAC0_SW_TXQ4_QID 0x06
0026 #define TOE_GMAC0_SW_TXQ5_QID 0x07
0027 #define TOE_GMAC0_HW_TXQ0_QID 0x08
0028 #define TOE_GMAC0_HW_TXQ1_QID 0x09
0029 #define TOE_GMAC0_HW_TXQ2_QID 0x0A
0030 #define TOE_GMAC0_HW_TXQ3_QID 0x0B
0031 #define TOE_GMAC1_SW_TXQ0_QID 0x12
0032 #define TOE_GMAC1_SW_TXQ1_QID 0x13
0033 #define TOE_GMAC1_SW_TXQ2_QID 0x14
0034 #define TOE_GMAC1_SW_TXQ3_QID 0x15
0035 #define TOE_GMAC1_SW_TXQ4_QID 0x16
0036 #define TOE_GMAC1_SW_TXQ5_QID 0x17
0037 #define TOE_GMAC1_HW_TXQ0_QID 0x18
0038 #define TOE_GMAC1_HW_TXQ1_QID 0x19
0039 #define TOE_GMAC1_HW_TXQ2_QID 0x1A
0040 #define TOE_GMAC1_HW_TXQ3_QID 0x1B
0041 #define TOE_GMAC0_DEFAULT_QID 0x20
0042 #define TOE_GMAC1_DEFAULT_QID 0x21
0043 #define TOE_CLASSIFICATION_QID(x) (0x22 + x)
0044 #define TOE_TOE_QID(x) (0x40 + x)
0045
0046
0047
0048
0049
0050
0051
0052
0053 #define GET_WPTR(addr) readw((addr) + 2)
0054 #define GET_RPTR(addr) readw((addr))
0055 #define SET_WPTR(addr, data) writew((data), (addr) + 2)
0056 #define SET_RPTR(addr, data) writew((data), (addr))
0057 #define __RWPTR_NEXT(x, mask) (((unsigned int)(x) + 1) & (mask))
0058 #define __RWPTR_PREV(x, mask) (((unsigned int)(x) - 1) & (mask))
0059 #define __RWPTR_DISTANCE(r, w, mask) (((unsigned int)(w) - (r)) & (mask))
0060 #define __RWPTR_MASK(order) ((1 << (order)) - 1)
0061 #define RWPTR_NEXT(x, order) __RWPTR_NEXT((x), __RWPTR_MASK((order)))
0062 #define RWPTR_PREV(x, order) __RWPTR_PREV((x), __RWPTR_MASK((order)))
0063 #define RWPTR_DISTANCE(r, w, order) __RWPTR_DISTANCE((r), (w), \
0064 __RWPTR_MASK((order)))
0065
0066
0067 #define GLOBAL_TOE_VERSION_REG 0x0000
0068 #define GLOBAL_SW_FREEQ_BASE_SIZE_REG 0x0004
0069 #define GLOBAL_HW_FREEQ_BASE_SIZE_REG 0x0008
0070 #define GLOBAL_DMA_SKB_SIZE_REG 0x0010
0071 #define GLOBAL_SWFQ_RWPTR_REG 0x0014
0072 #define GLOBAL_HWFQ_RWPTR_REG 0x0018
0073 #define GLOBAL_INTERRUPT_STATUS_0_REG 0x0020
0074 #define GLOBAL_INTERRUPT_ENABLE_0_REG 0x0024
0075 #define GLOBAL_INTERRUPT_SELECT_0_REG 0x0028
0076 #define GLOBAL_INTERRUPT_STATUS_1_REG 0x0030
0077 #define GLOBAL_INTERRUPT_ENABLE_1_REG 0x0034
0078 #define GLOBAL_INTERRUPT_SELECT_1_REG 0x0038
0079 #define GLOBAL_INTERRUPT_STATUS_2_REG 0x0040
0080 #define GLOBAL_INTERRUPT_ENABLE_2_REG 0x0044
0081 #define GLOBAL_INTERRUPT_SELECT_2_REG 0x0048
0082 #define GLOBAL_INTERRUPT_STATUS_3_REG 0x0050
0083 #define GLOBAL_INTERRUPT_ENABLE_3_REG 0x0054
0084 #define GLOBAL_INTERRUPT_SELECT_3_REG 0x0058
0085 #define GLOBAL_INTERRUPT_STATUS_4_REG 0x0060
0086 #define GLOBAL_INTERRUPT_ENABLE_4_REG 0x0064
0087 #define GLOBAL_INTERRUPT_SELECT_4_REG 0x0068
0088 #define GLOBAL_HASH_TABLE_BASE_REG 0x006C
0089 #define GLOBAL_QUEUE_THRESHOLD_REG 0x0070
0090
0091
0092 #define GMAC_DMA_CTRL_REG 0x0000
0093 #define GMAC_TX_WEIGHTING_CTRL_0_REG 0x0004
0094 #define GMAC_TX_WEIGHTING_CTRL_1_REG 0x0008
0095 #define GMAC_SW_TX_QUEUE0_PTR_REG 0x000C
0096 #define GMAC_SW_TX_QUEUE1_PTR_REG 0x0010
0097 #define GMAC_SW_TX_QUEUE2_PTR_REG 0x0014
0098 #define GMAC_SW_TX_QUEUE3_PTR_REG 0x0018
0099 #define GMAC_SW_TX_QUEUE4_PTR_REG 0x001C
0100 #define GMAC_SW_TX_QUEUE5_PTR_REG 0x0020
0101 #define GMAC_SW_TX_QUEUE_PTR_REG(i) (GMAC_SW_TX_QUEUE0_PTR_REG + 4 * (i))
0102 #define GMAC_HW_TX_QUEUE0_PTR_REG 0x0024
0103 #define GMAC_HW_TX_QUEUE1_PTR_REG 0x0028
0104 #define GMAC_HW_TX_QUEUE2_PTR_REG 0x002C
0105 #define GMAC_HW_TX_QUEUE3_PTR_REG 0x0030
0106 #define GMAC_HW_TX_QUEUE_PTR_REG(i) (GMAC_HW_TX_QUEUE0_PTR_REG + 4 * (i))
0107 #define GMAC_DMA_TX_FIRST_DESC_REG 0x0038
0108 #define GMAC_DMA_TX_CURR_DESC_REG 0x003C
0109 #define GMAC_DMA_TX_DESC_WORD0_REG 0x0040
0110 #define GMAC_DMA_TX_DESC_WORD1_REG 0x0044
0111 #define GMAC_DMA_TX_DESC_WORD2_REG 0x0048
0112 #define GMAC_DMA_TX_DESC_WORD3_REG 0x004C
0113 #define GMAC_SW_TX_QUEUE_BASE_REG 0x0050
0114 #define GMAC_HW_TX_QUEUE_BASE_REG 0x0054
0115 #define GMAC_DMA_RX_FIRST_DESC_REG 0x0058
0116 #define GMAC_DMA_RX_CURR_DESC_REG 0x005C
0117 #define GMAC_DMA_RX_DESC_WORD0_REG 0x0060
0118 #define GMAC_DMA_RX_DESC_WORD1_REG 0x0064
0119 #define GMAC_DMA_RX_DESC_WORD2_REG 0x0068
0120 #define GMAC_DMA_RX_DESC_WORD3_REG 0x006C
0121 #define GMAC_HASH_ENGINE_REG0 0x0070
0122 #define GMAC_HASH_ENGINE_REG1 0x0074
0123
0124 #define GMAC_MR0CR0 0x0078
0125 #define GMAC_MR0CR1 0x007C
0126 #define GMAC_MR0CR2 0x0080
0127 #define GMAC_MR1CR0 0x0084
0128 #define GMAC_MR1CR1 0x0088
0129 #define GMAC_MR1CR2 0x008C
0130 #define GMAC_MR2CR0 0x0090
0131 #define GMAC_MR2CR1 0x0094
0132 #define GMAC_MR2CR2 0x0098
0133 #define GMAC_MR3CR0 0x009C
0134 #define GMAC_MR3CR1 0x00A0
0135 #define GMAC_MR3CR2 0x00A4
0136
0137 #define GMAC_SPR0 0x00A8
0138 #define GMAC_SPR1 0x00AC
0139 #define GMAC_SPR2 0x00B0
0140 #define GMAC_SPR3 0x00B4
0141 #define GMAC_SPR4 0x00B8
0142 #define GMAC_SPR5 0x00BC
0143 #define GMAC_SPR6 0x00C0
0144 #define GMAC_SPR7 0x00C4
0145
0146 #define GMAC_AHB_WEIGHT_REG 0x00C8
0147
0148
0149 #define GMAC_STA_ADD0 0x0000
0150 #define GMAC_STA_ADD1 0x0004
0151 #define GMAC_STA_ADD2 0x0008
0152 #define GMAC_RX_FLTR 0x000c
0153 #define GMAC_MCAST_FIL0 0x0010
0154 #define GMAC_MCAST_FIL1 0x0014
0155 #define GMAC_CONFIG0 0x0018
0156 #define GMAC_CONFIG1 0x001c
0157 #define GMAC_CONFIG2 0x0020
0158 #define GMAC_CONFIG3 0x0024
0159 #define GMAC_RESERVED 0x0028
0160 #define GMAC_STATUS 0x002c
0161 #define GMAC_IN_DISCARDS 0x0030
0162 #define GMAC_IN_ERRORS 0x0034
0163 #define GMAC_IN_MCAST 0x0038
0164 #define GMAC_IN_BCAST 0x003c
0165 #define GMAC_IN_MAC1 0x0040
0166 #define GMAC_IN_MAC2 0x0044
0167
0168 #define RX_STATS_NUM 6
0169
0170
0171 union dma_q_base_size {
0172 unsigned int bits32;
0173 unsigned int base_size;
0174 };
0175
0176 #define DMA_Q_BASE_MASK (~0x0f)
0177
0178
0179 union dma_skb_size {
0180 unsigned int bits32;
0181 struct bit_0008 {
0182 unsigned int sw_skb_size : 16;
0183 unsigned int hw_skb_size : 16;
0184 } bits;
0185 };
0186
0187
0188 union dma_rwptr {
0189 unsigned int bits32;
0190 struct bit_000c {
0191 unsigned int rptr : 16;
0192 unsigned int wptr : 16;
0193 } bits;
0194 };
0195
0196
0197
0198
0199
0200 #define GMAC1_TXDERR_INT_BIT BIT(31)
0201 #define GMAC1_TXPERR_INT_BIT BIT(30)
0202 #define GMAC0_TXDERR_INT_BIT BIT(29)
0203 #define GMAC0_TXPERR_INT_BIT BIT(28)
0204 #define GMAC1_RXDERR_INT_BIT BIT(27)
0205 #define GMAC1_RXPERR_INT_BIT BIT(26)
0206 #define GMAC0_RXDERR_INT_BIT BIT(25)
0207 #define GMAC0_RXPERR_INT_BIT BIT(24)
0208 #define GMAC1_SWTQ15_FIN_INT_BIT BIT(23)
0209 #define GMAC1_SWTQ14_FIN_INT_BIT BIT(22)
0210 #define GMAC1_SWTQ13_FIN_INT_BIT BIT(21)
0211 #define GMAC1_SWTQ12_FIN_INT_BIT BIT(20)
0212 #define GMAC1_SWTQ11_FIN_INT_BIT BIT(19)
0213 #define GMAC1_SWTQ10_FIN_INT_BIT BIT(18)
0214 #define GMAC0_SWTQ05_FIN_INT_BIT BIT(17)
0215 #define GMAC0_SWTQ04_FIN_INT_BIT BIT(16)
0216 #define GMAC0_SWTQ03_FIN_INT_BIT BIT(15)
0217 #define GMAC0_SWTQ02_FIN_INT_BIT BIT(14)
0218 #define GMAC0_SWTQ01_FIN_INT_BIT BIT(13)
0219 #define GMAC0_SWTQ00_FIN_INT_BIT BIT(12)
0220 #define GMAC1_SWTQ15_EOF_INT_BIT BIT(11)
0221 #define GMAC1_SWTQ14_EOF_INT_BIT BIT(10)
0222 #define GMAC1_SWTQ13_EOF_INT_BIT BIT(9)
0223 #define GMAC1_SWTQ12_EOF_INT_BIT BIT(8)
0224 #define GMAC1_SWTQ11_EOF_INT_BIT BIT(7)
0225 #define GMAC1_SWTQ10_EOF_INT_BIT BIT(6)
0226 #define GMAC0_SWTQ05_EOF_INT_BIT BIT(5)
0227 #define GMAC0_SWTQ04_EOF_INT_BIT BIT(4)
0228 #define GMAC0_SWTQ03_EOF_INT_BIT BIT(3)
0229 #define GMAC0_SWTQ02_EOF_INT_BIT BIT(2)
0230 #define GMAC0_SWTQ01_EOF_INT_BIT BIT(1)
0231 #define GMAC0_SWTQ00_EOF_INT_BIT BIT(0)
0232
0233
0234
0235
0236
0237 #define TOE_IQ3_FULL_INT_BIT BIT(31)
0238 #define TOE_IQ2_FULL_INT_BIT BIT(30)
0239 #define TOE_IQ1_FULL_INT_BIT BIT(29)
0240 #define TOE_IQ0_FULL_INT_BIT BIT(28)
0241 #define TOE_IQ3_INT_BIT BIT(27)
0242 #define TOE_IQ2_INT_BIT BIT(26)
0243 #define TOE_IQ1_INT_BIT BIT(25)
0244 #define TOE_IQ0_INT_BIT BIT(24)
0245 #define GMAC1_HWTQ13_EOF_INT_BIT BIT(23)
0246 #define GMAC1_HWTQ12_EOF_INT_BIT BIT(22)
0247 #define GMAC1_HWTQ11_EOF_INT_BIT BIT(21)
0248 #define GMAC1_HWTQ10_EOF_INT_BIT BIT(20)
0249 #define GMAC0_HWTQ03_EOF_INT_BIT BIT(19)
0250 #define GMAC0_HWTQ02_EOF_INT_BIT BIT(18)
0251 #define GMAC0_HWTQ01_EOF_INT_BIT BIT(17)
0252 #define GMAC0_HWTQ00_EOF_INT_BIT BIT(16)
0253 #define CLASS_RX_INT_BIT(x) BIT((x + 2))
0254 #define DEFAULT_Q1_INT_BIT BIT(1)
0255 #define DEFAULT_Q0_INT_BIT BIT(0)
0256
0257 #define TOE_IQ_INT_BITS (TOE_IQ0_INT_BIT | TOE_IQ1_INT_BIT | \
0258 TOE_IQ2_INT_BIT | TOE_IQ3_INT_BIT)
0259 #define TOE_IQ_FULL_BITS (TOE_IQ0_FULL_INT_BIT | TOE_IQ1_FULL_INT_BIT | \
0260 TOE_IQ2_FULL_INT_BIT | TOE_IQ3_FULL_INT_BIT)
0261 #define TOE_IQ_ALL_BITS (TOE_IQ_INT_BITS | TOE_IQ_FULL_BITS)
0262 #define TOE_CLASS_RX_INT_BITS 0xfffc
0263
0264
0265
0266
0267
0268 #define TOE_QL_FULL_INT_BIT(x) BIT(x)
0269
0270
0271
0272
0273
0274 #define TOE_QH_FULL_INT_BIT(x) BIT(x - 32)
0275
0276
0277
0278
0279
0280 #define GMAC1_RESERVED_INT_BIT BIT(31)
0281 #define GMAC1_MIB_INT_BIT BIT(30)
0282 #define GMAC1_RX_PAUSE_ON_INT_BIT BIT(29)
0283 #define GMAC1_TX_PAUSE_ON_INT_BIT BIT(28)
0284 #define GMAC1_RX_PAUSE_OFF_INT_BIT BIT(27)
0285 #define GMAC1_TX_PAUSE_OFF_INT_BIT BIT(26)
0286 #define GMAC1_RX_OVERRUN_INT_BIT BIT(25)
0287 #define GMAC1_STATUS_CHANGE_INT_BIT BIT(24)
0288 #define GMAC0_RESERVED_INT_BIT BIT(23)
0289 #define GMAC0_MIB_INT_BIT BIT(22)
0290 #define GMAC0_RX_PAUSE_ON_INT_BIT BIT(21)
0291 #define GMAC0_TX_PAUSE_ON_INT_BIT BIT(20)
0292 #define GMAC0_RX_PAUSE_OFF_INT_BIT BIT(19)
0293 #define GMAC0_TX_PAUSE_OFF_INT_BIT BIT(18)
0294 #define GMAC0_RX_OVERRUN_INT_BIT BIT(17)
0295 #define GMAC0_STATUS_CHANGE_INT_BIT BIT(16)
0296 #define CLASS_RX_FULL_INT_BIT(x) BIT(x + 2)
0297 #define HWFQ_EMPTY_INT_BIT BIT(1)
0298 #define SWFQ_EMPTY_INT_BIT BIT(0)
0299
0300 #define GMAC0_INT_BITS (GMAC0_RESERVED_INT_BIT | GMAC0_MIB_INT_BIT | \
0301 GMAC0_RX_PAUSE_ON_INT_BIT | \
0302 GMAC0_TX_PAUSE_ON_INT_BIT | \
0303 GMAC0_RX_PAUSE_OFF_INT_BIT | \
0304 GMAC0_TX_PAUSE_OFF_INT_BIT | \
0305 GMAC0_RX_OVERRUN_INT_BIT | \
0306 GMAC0_STATUS_CHANGE_INT_BIT)
0307 #define GMAC1_INT_BITS (GMAC1_RESERVED_INT_BIT | GMAC1_MIB_INT_BIT | \
0308 GMAC1_RX_PAUSE_ON_INT_BIT | \
0309 GMAC1_TX_PAUSE_ON_INT_BIT | \
0310 GMAC1_RX_PAUSE_OFF_INT_BIT | \
0311 GMAC1_TX_PAUSE_OFF_INT_BIT | \
0312 GMAC1_RX_OVERRUN_INT_BIT | \
0313 GMAC1_STATUS_CHANGE_INT_BIT)
0314
0315 #define CLASS_RX_FULL_INT_BITS 0xfffc
0316
0317
0318 union queue_threshold {
0319 unsigned int bits32;
0320 struct bit_0070_2 {
0321
0322 unsigned int swfq_empty:8;
0323
0324 unsigned int hwfq_empty:8;
0325
0326 unsigned int intrq:8;
0327
0328 unsigned int toe_class:8;
0329 } bits;
0330 };
0331
0332
0333
0334
0335
0336 union gmac_dma_ctrl {
0337 unsigned int bits32;
0338 struct bit_8000 {
0339
0340 unsigned int td_bus:2;
0341
0342 unsigned int td_burst_size:2;
0343
0344 unsigned int td_prot:4;
0345
0346 unsigned int rd_bus:2;
0347
0348 unsigned int rd_burst_size:2;
0349
0350 unsigned int rd_prot:4;
0351
0352 unsigned int rd_insert_bytes:2;
0353
0354 unsigned int reserved:10;
0355
0356 unsigned int drop_small_ack:1;
0357
0358 unsigned int loopback:1;
0359
0360 unsigned int td_enable:1;
0361
0362 unsigned int rd_enable:1;
0363 } bits;
0364 };
0365
0366
0367
0368
0369
0370 union gmac_tx_wcr0 {
0371 unsigned int bits32;
0372 struct bit_8004 {
0373
0374 unsigned int hw_tq0:6;
0375
0376 unsigned int hw_tq1:6;
0377
0378 unsigned int hw_tq2:6;
0379
0380 unsigned int hw_tq3:6;
0381
0382 unsigned int reserved:8;
0383 } bits;
0384 };
0385
0386
0387
0388
0389
0390 union gmac_tx_wcr1 {
0391 unsigned int bits32;
0392 struct bit_8008 {
0393
0394 unsigned int sw_tq0:5;
0395
0396 unsigned int sw_tq1:5;
0397
0398 unsigned int sw_tq2:5;
0399
0400 unsigned int sw_tq3:5;
0401
0402 unsigned int sw_tq4:5;
0403
0404 unsigned int sw_tq5:5;
0405
0406 unsigned int reserved:2;
0407 } bits;
0408 };
0409
0410
0411
0412
0413
0414 union gmac_txdesc_0 {
0415 unsigned int bits32;
0416 struct bit_8040 {
0417
0418 unsigned int buffer_size:16;
0419
0420 unsigned int desc_count:6;
0421
0422 unsigned int status_tx_ok:1;
0423
0424 unsigned int status_rvd:6;
0425
0426 unsigned int perr:1;
0427
0428 unsigned int derr:1;
0429
0430 unsigned int reserved:1;
0431 } bits;
0432 };
0433
0434
0435
0436
0437
0438 union gmac_txdesc_1 {
0439 unsigned int bits32;
0440 struct txdesc_word1 {
0441
0442 unsigned int byte_count:16;
0443
0444 unsigned int mtu_enable:1;
0445
0446 unsigned int ip_chksum:1;
0447
0448 unsigned int ipv6_enable:1;
0449
0450 unsigned int tcp_chksum:1;
0451
0452 unsigned int udp_chksum:1;
0453
0454 unsigned int bypass_tss:1;
0455
0456 unsigned int ip_fixed_len:1;
0457
0458 unsigned int reserved:9;
0459 } bits;
0460 };
0461
0462 #define TSS_IP_FIXED_LEN_BIT BIT(22)
0463 #define TSS_BYPASS_BIT BIT(21)
0464 #define TSS_UDP_CHKSUM_BIT BIT(20)
0465 #define TSS_TCP_CHKSUM_BIT BIT(19)
0466 #define TSS_IPV6_ENABLE_BIT BIT(18)
0467 #define TSS_IP_CHKSUM_BIT BIT(17)
0468 #define TSS_MTU_ENABLE_BIT BIT(16)
0469
0470 #define TSS_CHECKUM_ENABLE \
0471 (TSS_IP_CHKSUM_BIT | TSS_IPV6_ENABLE_BIT | \
0472 TSS_TCP_CHKSUM_BIT | TSS_UDP_CHKSUM_BIT)
0473
0474
0475
0476
0477
0478 union gmac_txdesc_2 {
0479 unsigned int bits32;
0480 unsigned int buf_adr;
0481 };
0482
0483
0484
0485
0486
0487 union gmac_txdesc_3 {
0488 unsigned int bits32;
0489 struct txdesc_word3 {
0490
0491 unsigned int mtu_size:13;
0492
0493 unsigned int reserved:16;
0494
0495 unsigned int eofie:1;
0496
0497 unsigned int sof_eof:2;
0498 } bits;
0499 };
0500
0501 #define SOF_EOF_BIT_MASK 0x3fffffff
0502 #define SOF_BIT 0x80000000
0503 #define EOF_BIT 0x40000000
0504 #define EOFIE_BIT BIT(29)
0505 #define MTU_SIZE_BIT_MASK 0x1fff
0506
0507
0508 struct gmac_txdesc {
0509 union gmac_txdesc_0 word0;
0510 union gmac_txdesc_1 word1;
0511 union gmac_txdesc_2 word2;
0512 union gmac_txdesc_3 word3;
0513 };
0514
0515
0516
0517
0518
0519 union gmac_rxdesc_0 {
0520 unsigned int bits32;
0521 struct bit_8060 {
0522
0523 unsigned int buffer_size:16;
0524
0525 unsigned int desc_count:6;
0526
0527 unsigned int status:4;
0528
0529 unsigned int chksum_status:3;
0530
0531 unsigned int perr:1;
0532
0533 unsigned int derr:1;
0534
0535 unsigned int drop:1;
0536 } bits;
0537 };
0538
0539 #define GMAC_RXDESC_0_T_derr BIT(30)
0540 #define GMAC_RXDESC_0_T_perr BIT(29)
0541 #define GMAC_RXDESC_0_T_chksum_status(x) BIT(x + 26)
0542 #define GMAC_RXDESC_0_T_status(x) BIT(x + 22)
0543 #define GMAC_RXDESC_0_T_desc_count(x) BIT(x + 16)
0544
0545 #define RX_CHKSUM_IP_UDP_TCP_OK 0
0546 #define RX_CHKSUM_IP_OK_ONLY 1
0547 #define RX_CHKSUM_NONE 2
0548 #define RX_CHKSUM_IP_ERR_UNKNOWN 4
0549 #define RX_CHKSUM_IP_ERR 5
0550 #define RX_CHKSUM_TCP_UDP_ERR 6
0551 #define RX_CHKSUM_NUM 8
0552
0553 #define RX_STATUS_GOOD_FRAME 0
0554 #define RX_STATUS_TOO_LONG_GOOD_CRC 1
0555 #define RX_STATUS_RUNT_FRAME 2
0556 #define RX_STATUS_SFD_NOT_FOUND 3
0557 #define RX_STATUS_CRC_ERROR 4
0558 #define RX_STATUS_TOO_LONG_BAD_CRC 5
0559 #define RX_STATUS_ALIGNMENT_ERROR 6
0560 #define RX_STATUS_TOO_LONG_BAD_ALIGN 7
0561 #define RX_STATUS_RX_ERR 8
0562 #define RX_STATUS_DA_FILTERED 9
0563 #define RX_STATUS_BUFFER_FULL 10
0564 #define RX_STATUS_NUM 16
0565
0566 #define RX_ERROR_LENGTH(s) \
0567 ((s) == RX_STATUS_TOO_LONG_GOOD_CRC || \
0568 (s) == RX_STATUS_TOO_LONG_BAD_CRC || \
0569 (s) == RX_STATUS_TOO_LONG_BAD_ALIGN)
0570 #define RX_ERROR_OVER(s) \
0571 ((s) == RX_STATUS_BUFFER_FULL)
0572 #define RX_ERROR_CRC(s) \
0573 ((s) == RX_STATUS_CRC_ERROR || \
0574 (s) == RX_STATUS_TOO_LONG_BAD_CRC)
0575 #define RX_ERROR_FRAME(s) \
0576 ((s) == RX_STATUS_ALIGNMENT_ERROR || \
0577 (s) == RX_STATUS_TOO_LONG_BAD_ALIGN)
0578 #define RX_ERROR_FIFO(s) \
0579 (0)
0580
0581
0582
0583
0584
0585 union gmac_rxdesc_1 {
0586 unsigned int bits32;
0587 struct rxdesc_word1 {
0588
0589 unsigned int byte_count:16;
0590
0591 unsigned int sw_id:16;
0592 } bits;
0593 };
0594
0595
0596
0597
0598
0599 union gmac_rxdesc_2 {
0600 unsigned int bits32;
0601 unsigned int buf_adr;
0602 };
0603
0604 #define RX_INSERT_NONE 0
0605 #define RX_INSERT_1_BYTE 1
0606 #define RX_INSERT_2_BYTE 2
0607 #define RX_INSERT_3_BYTE 3
0608
0609
0610
0611
0612
0613 union gmac_rxdesc_3 {
0614 unsigned int bits32;
0615 struct rxdesc_word3 {
0616
0617 unsigned int l3_offset:8;
0618
0619 unsigned int l4_offset:8;
0620
0621 unsigned int l7_offset:8;
0622
0623 unsigned int dup_ack:1;
0624
0625 unsigned int abnormal:1;
0626
0627 unsigned int option:1;
0628
0629 unsigned int out_of_seq:1;
0630
0631 unsigned int ctrl_flag:1;
0632
0633 unsigned int eofie:1;
0634
0635 unsigned int sof_eof:2;
0636 } bits;
0637 };
0638
0639
0640 struct gmac_rxdesc {
0641 union gmac_rxdesc_0 word0;
0642 union gmac_rxdesc_1 word1;
0643 union gmac_rxdesc_2 word2;
0644 union gmac_rxdesc_3 word3;
0645 };
0646
0647
0648
0649
0650
0651 #define MR_L2_BIT BIT(31)
0652 #define MR_L3_BIT BIT(30)
0653 #define MR_L4_BIT BIT(29)
0654 #define MR_L7_BIT BIT(28)
0655 #define MR_PORT_BIT BIT(27)
0656 #define MR_PRIORITY_BIT BIT(26)
0657 #define MR_DA_BIT BIT(23)
0658 #define MR_SA_BIT BIT(22)
0659 #define MR_ETHER_TYPE_BIT BIT(21)
0660 #define MR_VLAN_BIT BIT(20)
0661 #define MR_PPPOE_BIT BIT(19)
0662 #define MR_IP_VER_BIT BIT(15)
0663 #define MR_IP_HDR_LEN_BIT BIT(14)
0664 #define MR_FLOW_LABLE_BIT BIT(13)
0665 #define MR_TOS_TRAFFIC_BIT BIT(12)
0666 #define MR_SPR_BIT(x) BIT(x)
0667 #define MR_SPR_BITS 0xff
0668
0669
0670
0671
0672
0673 union gmac_ahb_weight {
0674 unsigned int bits32;
0675 struct bit_80C8 {
0676
0677 unsigned int hash_weight:5;
0678
0679 unsigned int rx_weight:5;
0680
0681 unsigned int tx_weight:5;
0682
0683 unsigned int pre_req:5;
0684
0685 unsigned int tq_dv_threshold:5;
0686
0687 unsigned int reserved:7;
0688 } bits;
0689 };
0690
0691
0692
0693
0694
0695 union gmac_rx_fltr {
0696 unsigned int bits32;
0697 struct bit1_000c {
0698
0699
0700
0701 unsigned int unicast:1;
0702
0703
0704
0705 unsigned int multicast:1;
0706
0707 unsigned int broadcast:1;
0708
0709 unsigned int promiscuous:1;
0710
0711 unsigned int error:1;
0712 unsigned int reserved:27;
0713 } bits;
0714 };
0715
0716
0717
0718
0719
0720 union gmac_config0 {
0721 unsigned int bits32;
0722 struct bit1_0018 {
0723
0724 unsigned int dis_tx:1;
0725
0726 unsigned int dis_rx:1;
0727
0728 unsigned int loop_back:1;
0729
0730 unsigned int flow_ctrl:1;
0731
0732 unsigned int adj_ifg:4;
0733
0734 unsigned int max_len:3;
0735
0736 unsigned int dis_bkoff:1;
0737
0738 unsigned int dis_col:1;
0739
0740 unsigned int sim_test:1;
0741
0742 unsigned int rx_fc_en:1;
0743
0744 unsigned int tx_fc_en:1;
0745
0746 unsigned int rgmii_en:1;
0747
0748 unsigned int ipv4_rx_chksum:1;
0749
0750 unsigned int ipv6_rx_chksum:1;
0751
0752 unsigned int rx_tag_remove:1;
0753
0754 unsigned int rgmm_edge:1;
0755
0756 unsigned int rxc_inv:1;
0757
0758 unsigned int ipv6_exthdr_order:1;
0759
0760 unsigned int rx_err_detect:1;
0761
0762 unsigned int port0_chk_hwq:1;
0763
0764 unsigned int port1_chk_hwq:1;
0765
0766 unsigned int port0_chk_toeq:1;
0767
0768 unsigned int port1_chk_toeq:1;
0769
0770 unsigned int port0_chk_classq:1;
0771
0772 unsigned int port1_chk_classq:1;
0773
0774 unsigned int reserved:2;
0775 } bits;
0776 };
0777
0778 #define CONFIG0_TX_RX_DISABLE (BIT(1) | BIT(0))
0779 #define CONFIG0_RX_CHKSUM (BIT(18) | BIT(17))
0780 #define CONFIG0_FLOW_RX BIT(14)
0781 #define CONFIG0_FLOW_TX BIT(15)
0782 #define CONFIG0_FLOW_TX_RX (BIT(14) | BIT(15))
0783 #define CONFIG0_FLOW_CTL (BIT(14) | BIT(15))
0784
0785 #define CONFIG0_MAXLEN_SHIFT 8
0786 #define CONFIG0_MAXLEN_MASK (7 << CONFIG0_MAXLEN_SHIFT)
0787 #define CONFIG0_MAXLEN_1536 0
0788 #define CONFIG0_MAXLEN_1518 1
0789 #define CONFIG0_MAXLEN_1522 2
0790 #define CONFIG0_MAXLEN_1542 3
0791 #define CONFIG0_MAXLEN_9k 4
0792 #define CONFIG0_MAXLEN_10k 5
0793 #define CONFIG0_MAXLEN_1518__6 6
0794 #define CONFIG0_MAXLEN_1518__7 7
0795
0796
0797
0798
0799
0800 union gmac_config1 {
0801 unsigned int bits32;
0802 struct bit1_001c {
0803
0804 unsigned int set_threshold:8;
0805
0806 unsigned int rel_threshold:8;
0807 unsigned int reserved:16;
0808 } bits;
0809 };
0810
0811 #define GMAC_FLOWCTRL_SET_MAX 32
0812 #define GMAC_FLOWCTRL_SET_MIN 0
0813 #define GMAC_FLOWCTRL_RELEASE_MAX 32
0814 #define GMAC_FLOWCTRL_RELEASE_MIN 0
0815
0816
0817
0818
0819
0820 union gmac_config2 {
0821 unsigned int bits32;
0822 struct bit1_0020 {
0823
0824 unsigned int set_threshold:16;
0825
0826 unsigned int rel_threshold:16;
0827 } bits;
0828 };
0829
0830
0831
0832
0833
0834 union gmac_config3 {
0835 unsigned int bits32;
0836 struct bit1_0024 {
0837
0838 unsigned int set_threshold:16;
0839
0840 unsigned int rel_threshold:16;
0841 } bits;
0842 };
0843
0844
0845
0846
0847
0848 union gmac_status {
0849 unsigned int bits32;
0850 struct bit1_002c {
0851
0852 unsigned int link:1;
0853
0854 unsigned int speed:2;
0855
0856 unsigned int duplex:1;
0857 unsigned int reserved_1:1;
0858
0859 unsigned int mii_rmii:2;
0860 unsigned int reserved_2:25;
0861 } bits;
0862 };
0863
0864 #define GMAC_SPEED_10 0
0865 #define GMAC_SPEED_100 1
0866 #define GMAC_SPEED_1000 2
0867
0868 #define GMAC_PHY_MII 0
0869 #define GMAC_PHY_GMII 1
0870 #define GMAC_PHY_RGMII_100_10 2
0871 #define GMAC_PHY_RGMII_1000 3
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925 #define TOE_QUEUE_HDR_ADDR(n) (TOE_TOE_QUE_HDR_BASE + n * 32)
0926 #define TOE_Q_HDR_AREA_END (TOE_QUEUE_HDR_ADDR(TOE_TOE_QUEUE_MAX + 1))
0927 #define TOE_DEFAULT_Q_HDR_BASE(x) (TOE_NONTOE_QUE_HDR_BASE + 0x08 * (x))
0928 #define TOE_CLASS_Q_HDR_BASE (TOE_NONTOE_QUE_HDR_BASE + 0x10)
0929 #define TOE_INTR_Q_HDR_BASE (TOE_NONTOE_QUE_HDR_BASE + 0x80)
0930 #define INTERRUPT_QUEUE_HDR_ADDR(n) (TOE_INTR_Q_HDR_BASE + n * 8)
0931 #define NONTOE_Q_HDR_AREA_END (INTERRUPT_QUEUE_HDR_ADDR(TOE_INTR_QUEUE_MAX + 1))
0932
0933
0934 union nontoe_qhdr0 {
0935 unsigned int bits32;
0936 unsigned int base_size;
0937 };
0938
0939 #define NONTOE_QHDR0_BASE_MASK (~0x0f)
0940
0941
0942 union nontoe_qhdr1 {
0943 unsigned int bits32;
0944 struct bit_nonqhdr1 {
0945
0946 unsigned int rptr:16;
0947
0948 unsigned int wptr:16;
0949 } bits;
0950 };
0951
0952
0953 struct nontoe_qhdr {
0954 union nontoe_qhdr0 word0;
0955 union nontoe_qhdr1 word1;
0956 };
0957
0958 #endif