source: freebsd-rtl-driver/if_rtlreg.h@ 388

Last change on this file since 388 was 384, checked in by Rick van der Zwet, 10 years ago

Innitial import attempt of if_rtl(4)

File size: 17.1 KB
RevLine 
[384]1/*-
2 * Copyright (c) 2010, 2011 Rick van der Zwet <info@rickvanderzwet.nl>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/*-
18 * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
19 * All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * $FreeBSD: release/10.1.0/sys/dev/usb/net/if_rtlreg.h 215335 2010-11-15 06:04:25Z kevlo $
43 */
44
45#define RTL_CONFIG_IDX 0 /* config number 1 */
46#define RTL_IFACE_IDX 0
47
48#define RTL_INTR_PKTLEN 0x8
49
50#define RTL_TIMEOUT 50
51#define RTL_MIN_FRAMELEN 60
52
53/* Registers. */
54#define RTL_IDR0 0x0120
55#define RTL_IDR1 0x0121
56#define RTL_IDR2 0x0122
57#define RTL_IDR3 0x0123
58#define RTL_IDR4 0x0124
59#define RTL_IDR5 0x0125
60
61#define RTL_MAR0 0x0126
62#define RTL_MAR1 0x0127
63#define RTL_MAR2 0x0128
64#define RTL_MAR3 0x0129
65#define RTL_MAR4 0x012A
66#define RTL_MAR5 0x012B
67#define RTL_MAR6 0x012C
68#define RTL_MAR7 0x012D
69
70#define RTL_CR 0x012E /* B, R/W */
71#define RTL_CR_SOFT_RST 0x10
72#define RTL_CR_RE 0x08
73#define RTL_CR_TE 0x04
74#define RTL_CR_EP3CLREN 0x02
75
76#define RTL_TCR 0x012F /* B, R/W */
77#define RTL_TCR_TXRR1 0x80
78#define RTL_TCR_TXRR0 0x40
79#define RTL_TCR_IFG1 0x10
80#define RTL_TCR_IFG0 0x08
81#define RTL_TCR_NOCRC 0x01
82#define RTL_TCR_CONFIG (RTL_TCR_TXRR1 | RTL_TCR_TXRR0 | \
83 RTL_TCR_IFG1 | RTL_TCR_IFG0)
84
85#define RTL_RCR 0x0130 /* W, R/W */
86#define RTL_RCR_TAIL 0x80
87#define RTL_RCR_AER 0x40
88#define RTL_RCR_AR 0x20
89#define RTL_RCR_AM 0x10
90#define RTL_RCR_AB 0x08
91#define RTL_RCR_AD 0x04
92#define RTL_RCR_AAM 0x02
93#define RTL_RCR_AAP 0x01
94#define RTL_RCR_CONFIG (RTL_RCR_TAIL | RTL_RCR_AD)
95
96#define RTL_TSR 0x0132
97#define RTL_RSR 0x0133
98#define RTL_CON0 0x0135
99#define RTL_CON1 0x0136
100#define RTL_MSR 0x0137
101#define RTL_PHYADD 0x0138
102#define RTL_PHYDAT 0x0139
103
104#define RTL_PHYCNT 0x013B /* B, R/W */
105#define RTL_PHYCNT_PHYOWN 0x40
106#define RTL_PHYCNT_RWCR 0x20
107
108#define RTL_GPPC 0x013D
109#define RTL_WAKECNT 0x013E
110
111#define RTL_BMCR 0x0140
112#define RTL_BMCR_SPD_SET 0x2000
113#define RTL_BMCR_DUPLEX 0x0100
114
115#define RTL_BMSR 0x0142
116
117#define RTL_ANAR 0x0144 /* W, R/W */
118#define RTL_ANAR_PAUSE 0x0400
119
120#define RTL_ANLP 0x0146 /* W, R/O */
121#define RTL_ANLP_PAUSE 0x0400
122
123#define RTL_AER 0x0148
124
125#define RTL_NWAYT 0x014A
126#define RTL_CSCR 0x014C
127
128#define RTL_CRC0 0x014E
129#define RTL_CRC1 0x0150
130#define RTL_CRC2 0x0152
131#define RTL_CRC3 0x0154
132#define RTL_CRC4 0x0156
133
134#define RTL_BYTEMASK0 0x0158
135#define RTL_BYTEMASK1 0x0160
136#define RTL_BYTEMASK2 0x0168
137#define RTL_BYTEMASK3 0x0170
138#define RTL_BYTEMASK4 0x0178
139
140#define RTL_PHY1 0x0180
141#define RTL_PHY2 0x0184
142
143#define RTL_TW1 0x0186
144
145#define RTL_REG_MIN 0x0120
146#define RTL_REG_MAX 0x0189
147
148/* EEPROM address declarations. */
149#define RTL_EEPROM_BASE 0x1200
150#define RTL_EEPROM_IDR0 (RTL_EEPROM_BASE + 0x02)
151#define RTL_EEPROM_IDR1 (RTL_EEPROM_BASE + 0x03)
152#define RTL_EEPROM_IDR2 (RTL_EEPROM_BASE + 0x03)
153#define RTL_EEPROM_IDR3 (RTL_EEPROM_BASE + 0x03)
154#define RTL_EEPROM_IDR4 (RTL_EEPROM_BASE + 0x03)
155#define RTL_EEPROM_IDR5 (RTL_EEPROM_BASE + 0x03)
156#define RTL_EEPROM_INTERVAL (RTL_EEPROM_BASE + 0x17)
157
158#define RTL_RXSTAT_VALID (0x01 << 12)
159#define RTL_RXSTAT_RUNT (0x02 << 12)
160#define RTL_RXSTAT_PMATCH (0x04 << 12)
161#define RTL_RXSTAT_MCAST (0x08 << 12)
162
163/* New entries (imported from r8152.c) */
164#define R8152_PHY_ID 32
165
166#define PLA_IDR 0xc000
167#define PLA_RCR 0xc010
168#define PLA_RMS 0xc016
169#define PLA_RXFIFO_CTRL0 0xc0a0
170#define PLA_RXFIFO_CTRL1 0xc0a4
171#define PLA_RXFIFO_CTRL2 0xc0a8
172#define PLA_FMC 0xc0b4
173#define PLA_CFG_WOL 0xc0b6
174#define PLA_TEREDO_CFG 0xc0bc
175#define PLA_MAR 0xcd00
176#define PLA_BACKUP 0xd000
177#define PAL_BDC_CR 0xd1a0
178#define PLA_TEREDO_TIMER 0xd2cc
179#define PLA_REALWOW_TIMER 0xd2e8
180#define PLA_LEDSEL 0xdd90
181#define PLA_LED_FEATURE 0xdd92
182#define PLA_PHYAR 0xde00
183#define PLA_BOOT_CTRL 0xe004
184#define PLA_GPHY_INTR_IMR 0xe022
185#define PLA_EEE_CR 0xe040
186#define PLA_EEEP_CR 0xe080
187#define PLA_MAC_PWR_CTRL 0xe0c0
188#define PLA_MAC_PWR_CTRL2 0xe0ca
189#define PLA_MAC_PWR_CTRL3 0xe0cc
190#define PLA_MAC_PWR_CTRL4 0xe0ce
191#define PLA_WDT6_CTRL 0xe428
192#define PLA_TCR0 0xe610
193#define PLA_TCR1 0xe612
194#define PLA_MTPS 0xe615
195#define PLA_TXFIFO_CTRL 0xe618
196#define PLA_RSTTALLY 0xe800
197#define PLA_CR 0xe813
198#define PLA_CRWECR 0xe81c
199#define PLA_CONFIG12 0xe81e /* CONFIG1, CONFIG2 */
200#define PLA_CONFIG34 0xe820 /* CONFIG3, CONFIG4 */
201#define PLA_CONFIG5 0xe822
202#define PLA_PHY_PWR 0xe84c
203#define PLA_OOB_CTRL 0xe84f
204#define PLA_CPCR 0xe854
205#define PLA_MISC_0 0xe858
206#define PLA_MISC_1 0xe85a
207#define PLA_OCP_GPHY_BASE 0xe86c
208#define PLA_TALLYCNT 0xe890
209#define PLA_SFF_STS_7 0xe8de
210#define PLA_PHYSTATUS 0xe908
211#define PLA_BP_BA 0xfc26
212#define PLA_BP_0 0xfc28
213#define PLA_BP_1 0xfc2a
214#define PLA_BP_2 0xfc2c
215#define PLA_BP_3 0xfc2e
216#define PLA_BP_4 0xfc30
217#define PLA_BP_5 0xfc32
218#define PLA_BP_6 0xfc34
219#define PLA_BP_7 0xfc36
220#define PLA_BP_EN 0xfc38
221
222#define USB_U2P3_CTRL 0xb460
223#define USB_DEV_STAT 0xb808
224#define USB_USB_CTRL 0xd406
225#define USB_PHY_CTRL 0xd408
226#define USB_TX_AGG 0xd40a
227#define USB_RX_BUF_TH 0xd40c
228#define USB_USB_TIMER 0xd428
229#define USB_RX_EARLY_AGG 0xd42c
230#define USB_PM_CTRL_STATUS 0xd432
231#define USB_TX_DMA 0xd434
232#define USB_TOLERANCE 0xd490
233#define USB_LPM_CTRL 0xd41a
234#define USB_UPS_CTRL 0xd800
235#define USB_MISC_0 0xd81a
236#define USB_POWER_CUT 0xd80a
237#define USB_AFE_CTRL2 0xd824
238#define USB_WDT11_CTRL 0xe43c
239#define USB_BP_BA 0xfc26
240#define USB_BP_0 0xfc28
241#define USB_BP_1 0xfc2a
242#define USB_BP_2 0xfc2c
243#define USB_BP_3 0xfc2e
244#define USB_BP_4 0xfc30
245#define USB_BP_5 0xfc32
246#define USB_BP_6 0xfc34
247#define USB_BP_7 0xfc36
248#define USB_BP_EN 0xfc38
249
250/* OCP Registers */
251#define OCP_ALDPS_CONFIG 0x2010
252#define OCP_EEE_CONFIG1 0x2080
253#define OCP_EEE_CONFIG2 0x2092
254#define OCP_EEE_CONFIG3 0x2094
255#define OCP_BASE_MII 0xa400
256#define OCP_EEE_AR 0xa41a
257#define OCP_EEE_DATA 0xa41c
258#define OCP_PHY_STATUS 0xa420
259#define OCP_POWER_CFG 0xa430
260#define OCP_EEE_CFG 0xa432
261#define OCP_SRAM_ADDR 0xa436
262#define OCP_SRAM_DATA 0xa438
263#define OCP_DOWN_SPEED 0xa442
264#define OCP_EEE_ABLE 0xa5c4
265#define OCP_EEE_ADV 0xa5d0
266#define OCP_EEE_LPABLE 0xa5d2
267#define OCP_ADC_CFG 0xbc06
268
269/* SRAM Register */
270#define SRAM_LPF_CFG 0x8012
271#define SRAM_10M_AMP1 0x8080
272#define SRAM_10M_AMP2 0x8082
273#define SRAM_IMPEDANCE 0x8084
274
275/* PLA_RCR */
276#define RCR_AAP 0x00000001
277#define RCR_APM 0x00000002
278#define RCR_AM 0x00000004
279#define RCR_AB 0x00000008
280#define RCR_ACPT_ALL (RCR_AAP | RCR_APM | RCR_AM | RCR_AB)
281
282/* PLA_RXFIFO_CTRL0 */
283#define RXFIFO_THR1_NORMAL 0x00080002
284#define RXFIFO_THR1_OOB 0x01800003
285
286/* PLA_RXFIFO_CTRL1 */
287#define RXFIFO_THR2_FULL 0x00000060
288#define RXFIFO_THR2_HIGH 0x00000038
289#define RXFIFO_THR2_OOB 0x0000004a
290#define RXFIFO_THR2_NORMAL 0x00a0
291
292/* PLA_RXFIFO_CTRL2 */
293#define RXFIFO_THR3_FULL 0x00000078
294#define RXFIFO_THR3_HIGH 0x00000048
295#define RXFIFO_THR3_OOB 0x0000005a
296#define RXFIFO_THR3_NORMAL 0x0110
297
298/* PLA_TXFIFO_CTRL */
299#define TXFIFO_THR_NORMAL 0x00400008
300#define TXFIFO_THR_NORMAL2 0x01000008
301
302/* PLA_FMC */
303#define FMC_FCR_MCU_EN 0x0001
304
305/* PLA_EEEP_CR */
306#define EEEP_CR_EEEP_TX 0x0002
307
308/* PLA_WDT6_CTRL */
309#define WDT6_SET_MODE 0x0010
310
311/* PLA_TCR0 */
312#define TCR0_TX_EMPTY 0x0800
313#define TCR0_AUTO_FIFO 0x0080
314
315/* PLA_TCR1 */
316#define VERSION_MASK 0x7cf0
317
318/* PLA_MTPS */
319#define MTPS_JUMBO (12 * 1024 / 64)
320#define MTPS_DEFAULT (6 * 1024 / 64)
321
322/* PLA_RSTTALLY */
323#define TALLY_RESET 0x0001
324
325/* PLA_CR */
326#define CR_RST 0x10
327#define CR_RE 0x08
328#define CR_TE 0x04
329
330/* PLA_CRWECR */
331#define CRWECR_NORAML 0x00
332#define CRWECR_CONFIG 0xc0
333
334/* PLA_OOB_CTRL */
335#define NOW_IS_OOB 0x80
336#define TXFIFO_EMPTY 0x20
337#define RXFIFO_EMPTY 0x10
338#define LINK_LIST_READY 0x02
339#define DIS_MCU_CLROOB 0x01
340#define FIFO_EMPTY (TXFIFO_EMPTY | RXFIFO_EMPTY)
341
342/* PLA_MISC_1 */
343#define RXDY_GATED_EN 0x0008
344
345/* PLA_SFF_STS_7 */
346#define RE_INIT_LL 0x8000
347#define MCU_BORW_EN 0x4000
348
349/* PLA_CPCR */
350#define CPCR_RX_VLAN 0x0040
351
352/* PLA_CFG_WOL */
353#define MAGIC_EN 0x0001
354
355/* PLA_TEREDO_CFG */
356#define TEREDO_SEL 0x8000
357#define TEREDO_WAKE_MASK 0x7f00
358#define TEREDO_RS_EVENT_MASK 0x00fe
359#define OOB_TEREDO_EN 0x0001
360
361/* PAL_BDC_CR */
362#define ALDPS_PROXY_MODE 0x0001
363
364/* PLA_CONFIG34 */
365#define LINK_ON_WAKE_EN 0x0010
366#define LINK_OFF_WAKE_EN 0x0008
367
368/* PLA_CONFIG5 */
369#define BWF_EN 0x0040
370#define MWF_EN 0x0020
371#define UWF_EN 0x0010
372#define LAN_WAKE_EN 0x0002
373
374/* PLA_LED_FEATURE */
375#define LED_MODE_MASK 0x0700
376
377/* PLA_PHY_PWR */
378#define TX_10M_IDLE_EN 0x0080
379#define PFM_PWM_SWITCH 0x0040
380
381/* PLA_MAC_PWR_CTRL */
382#define D3_CLK_GATED_EN 0x00004000
383#define MCU_CLK_RATIO 0x07010f07
384#define MCU_CLK_RATIO_MASK 0x0f0f0f0f
385#define ALDPS_SPDWN_RATIO 0x0f87
386
387/* PLA_MAC_PWR_CTRL2 */
388#define EEE_SPDWN_RATIO 0x8007
389
390/* PLA_MAC_PWR_CTRL3 */
391#define PKT_AVAIL_SPDWN_EN 0x0100
392#define SUSPEND_SPDWN_EN 0x0004
393#define U1U2_SPDWN_EN 0x0002
394#define L1_SPDWN_EN 0x0001
395
396/* PLA_MAC_PWR_CTRL4 */
397#define PWRSAVE_SPDWN_EN 0x1000
398#define RXDV_SPDWN_EN 0x0800
399#define TX10MIDLE_EN 0x0100
400#define TP100_SPDWN_EN 0x0020
401#define TP500_SPDWN_EN 0x0010
402#define TP1000_SPDWN_EN 0x0008
403#define EEE_SPDWN_EN 0x0001
404
405/* PLA_GPHY_INTR_IMR */
406#define GPHY_STS_MSK 0x0001
407#define SPEED_DOWN_MSK 0x0002
408#define SPDWN_RXDV_MSK 0x0004
409#define SPDWN_LINKCHG_MSK 0x0008
410
411/* PLA_PHYAR */
412#define PHYAR_FLAG 0x80000000
413
414/* PLA_EEE_CR */
415#define EEE_RX_EN 0x0001
416#define EEE_TX_EN 0x0002
417
418/* PLA_BOOT_CTRL */
419#define AUTOLOAD_DONE 0x0002
420
421/* USB_DEV_STAT */
422#define STAT_SPEED_MASK 0x0006
423#define STAT_SPEED_HIGH 0x0000
424#define STAT_SPEED_FULL 0x0002
425
426/* USB_TX_AGG */
427#define TX_AGG_MAX_THRESHOLD 0x03
428
429/* USB_RX_BUF_TH */
430#define RX_THR_SUPPER 0x0c350180
431#define RX_THR_HIGH 0x7a120180
432#define RX_THR_SLOW 0xffff0180
433
434/* USB_TX_DMA */
435#define TEST_MODE_DISABLE 0x00000001
436#define TX_SIZE_ADJUST1 0x00000100
437
438/* USB_UPS_CTRL */
439#define POWER_CUT 0x0100
440
441/* USB_PM_CTRL_STATUS */
442#define RESUME_INDICATE 0x0001
443
444/* USB_USB_CTRL */
445#define RX_AGG_DISABLE 0x0010
446
447/* USB_U2P3_CTRL */
448#define U2P3_ENABLE 0x0001
449
450/* USB_POWER_CUT */
451#define PWR_EN 0x0001
452#define PHASE2_EN 0x0008
453
454/* USB_MISC_0 */
455#define PCUT_STATUS 0x0001
456
457/* USB_RX_EARLY_AGG */
458#define EARLY_AGG_SUPPER 0x0e832981
459#define EARLY_AGG_HIGH 0x0e837a12
460#define EARLY_AGG_SLOW 0x0e83ffff
461
462/* USB_WDT11_CTRL */
463#define TIMER11_EN 0x0001
464
465/* USB_LPM_CTRL */
466#define LPM_TIMER_MASK 0x0c
467#define LPM_TIMER_500MS 0x04 /* 500 ms */
468#define LPM_TIMER_500US 0x0c /* 500 us */
469
470/* USB_AFE_CTRL2 */
471#define SEN_VAL_MASK 0xf800
472#define SEN_VAL_NORMAL 0xa000
473#define SEL_RXIDLE 0x0100
474
475/* OCP_ALDPS_CONFIG */
476#define ENPWRSAVE 0x8000
477#define ENPDNPS 0x0200
478#define LINKENA 0x0100
479#define DIS_SDSAVE 0x0010
480
481/* OCP_PHY_STATUS */
482#define PHY_STAT_MASK 0x0007
483#define PHY_STAT_LAN_ON 3
484#define PHY_STAT_PWRDN 5
485
486/* OCP_POWER_CFG */
487#define EEE_CLKDIV_EN 0x8000
488#define EN_ALDPS 0x0004
489#define EN_10M_PLLOFF 0x0001
490
491/* OCP_EEE_CONFIG1 */
492#define RG_TXLPI_MSK_HFDUP 0x8000
493#define RG_MATCLR_EN 0x4000
494#define EEE_10_CAP 0x2000
495#define EEE_NWAY_EN 0x1000
496#define TX_QUIET_EN 0x0200
497#define RX_QUIET_EN 0x0100
498#define sd_rise_time_mask 0x0070
499#define sd_rise_time(x) (min(x, 7) << 4) /* bit 4 ~ 6 */
500#define RG_RXLPI_MSK_HFDUP 0x0008
501#define SDFALLTIME 0x0007 /* bit 0 ~ 2 */
502
503/* OCP_EEE_CONFIG2 */
504#define RG_LPIHYS_NUM 0x7000 /* bit 12 ~ 15 */
505#define RG_DACQUIET_EN 0x0400
506#define RG_LDVQUIET_EN 0x0200
507#define RG_CKRSEL 0x0020
508#define RG_EEEPRG_EN 0x0010
509
510/* OCP_EEE_CONFIG3 */
511#define fast_snr_mask 0xff80
512#define fast_snr(x) (min(x, 0x1ff) << 7) /* bit 7 ~ 15 */
513#define RG_LFS_SEL 0x0060 /* bit 6 ~ 5 */
514#define MSK_PH 0x0006 /* bit 0 ~ 3 */
515
516/* OCP_EEE_AR */
517/* bit[15:14] function */
518#define FUN_ADDR 0x0000
519#define FUN_DATA 0x4000
520/* bit[4:0] device addr */
521
522/* OCP_EEE_CFG */
523#define CTAP_SHORT_EN 0x0040
524#define EEE10_EN 0x0010
525
526/* OCP_DOWN_SPEED */
527#define EN_10M_BGOFF 0x0080
528
529/* OCP_ADC_CFG */
530#define CKADSEL_L 0x0100
531#define ADC_EN 0x0080
532#define EN_EMI_L 0x0040
533
534/* SRAM_LPF_CFG */
535#define LPF_AUTO_TUNE 0x8000
536
537/* SRAM_10M_AMP1 */
538#define GDAC_IB_UPALL 0x0008
539
540/* SRAM_10M_AMP2 */
541#define AMP_DN 0x0200
542
543/* SRAM_IMPEDANCE */
544#define RX_DRIVING_MASK 0x6000
545
546enum rtl_register_content {
547 _1000bps = 0x10,
548 _100bps = 0x08,
549 _10bps = 0x04,
550 LINK_STATUS = 0x02,
551 FULL_DUP = 0x01,
552};
553
554#define RTL8152_MAX_TX 4
555#define RTL8152_MAX_RX 10
556#define INTBUFSIZE 2
557#define CRC_SIZE 4
558#define TX_ALIGN 4
559#define RX_ALIGN 8
560
561#define INTR_LINK 0x0004
562
563#define RTL8152_REQT_READ 0xc0
564#define RTL8152_REQT_WRITE 0x40
565#define RTL8152_REQ_GET_REGS 0x05
566#define RTL8152_REQ_SET_REGS 0x05
567
568#define BYTE_EN_DWORD 0xff
569#define BYTE_EN_WORD 0x33
570#define BYTE_EN_BYTE 0x11
571#define BYTE_EN_SIX_BYTES 0x3f
572#define BYTE_EN_START_MASK 0x0f
573#define BYTE_EN_END_MASK 0xf0
574
575#define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */
576#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header) that VLAN requires.*/
577
578#define RTL8153_MAX_PACKET 9216 /* 9K */
579#define RTL8153_MAX_MTU (RTL8153_MAX_PACKET - VLAN_ETH_HLEN - VLAN_HLEN)
580#define RTL8152_RMS (VLAN_ETH_FRAME_LEN + VLAN_HLEN)
581#define RTL8153_RMS RTL8153_MAX_PACKET
582#define RTL8152_TX_TIMEOUT (5 * HZ)
583
584#define MCU_TYPE_PLA 0x0100
585#define MCU_TYPE_USB 0x0000
586
587#define BYTE_EN_DWORD 0xff
588#define BYTE_EN_WORD 0x33
589#define BYTE_EN_BYTE 0x11
590#define BYTE_EN_SIX_BYTES 0x3f
591#define BYTE_EN_START_MASK 0x0f
592#define BYTE_EN_END_MASK 0xf0
593/* End new entries */
594
595
596#define GET_MII(sc) uether_getmii(&(sc)->sc_ue)
597
598struct rtl_intrpkt {
599 uint8_t rtl_tsr;
600 uint8_t rtl_rsr;
601 uint8_t rtl_gep_msr;
602 uint8_t rtl_waksr;
603 uint8_t rtl_txok_cnt;
604 uint8_t rtl_rxlost_cnt;
605 uint8_t rtl_crcerr_cnt;
606 uint8_t rtl_col_cnt;
607} __packed;
608
609struct rx_desc {
610 uint32_t opts1;
611#define RX_LEN_MASK 0x7fff
612
613 uint32_t opts2;
614#define RD_UDP_CS (1 << 23)
615#define RD_TCP_CS (1 << 22)
616#define RD_IPV6_CS (1 << 20)
617#define RD_IPV4_CS (1 << 19)
618
619 uint32_t opts3;
620#define IPF (1 << 23) /* IP checksum fail */
621#define UDPF (1 << 22) /* UDP checksum fail */
622#define TCPF (1 << 21) /* TCP checksum fail */
623#define RX_VLAN_TAG (1 << 16)
624
625 uint32_t opts4;
626 uint32_t opts5;
627 uint32_t opts6;
628};
629
630struct tx_desc {
631 uint32_t opts1;
632#define TX_FS (1 << 31) /* First segment of a packet */
633#define TX_LS (1 << 30) /* Final segment of a packet */
634#define GTSENDV4 (1 << 28)
635#define GTSENDV6 (1 << 27)
636#define GTTCPHO_SHIFT 18
637#define GTTCPHO_MAX 0x7fU
638#define TX_LEN_MAX 0x3ffffU
639
640 uint32_t opts2;
641#define UDP_CS (1 << 31) /* Calculate UDP/IP checksum */
642#define TCP_CS (1 << 30) /* Calculate TCP/IP checksum */
643#define IPV4_CS (1 << 29) /* Calculate IPv4 checksum */
644#define IPV6_CS (1 << 28) /* Calculate IPv6 checksum */
645#define MSS_SHIFT 17
646#define MSS_MAX 0x7ffU
647#define TCPHO_SHIFT 17
648#define TCPHO_MAX 0x7ffU
649#define TX_VLAN_TAG (1 << 16)
650};
651
652
653enum {
654 RTL_BULK_DT_RD,
655 RTL_BULK_DT_WR,
656 RTL_INTR_DT_RD,
657 RTL_N_TRANSFER,
658};
659
660enum {
661 RTL_VER_UNKNOWN,
662 RTL_VER_01,
663 RTL_VER_02,
664 RTL_VER_03,
665 RTL_VER_04,
666 RTL_VER_05,
667 RTL_VER_MAX
668};
669
670struct rtl_softc {
671 struct usb_ether sc_ue;
672 struct mtx sc_mtx;
673 struct usb_xfer *sc_xfer[RTL_N_TRANSFER];
674
675 //TODO: If this the right place for this variable?
676 uint16_t ocp_base;
677 uint16_t version;
678 uint32_t saved_wolopts;
679
680 int sc_flags;
681#define RTL_FLAG_LINK 0x0001
682};
683
684#define RTL_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
685#define RTL_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
686#define RTL_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)
Note: See TracBrowser for help on using the repository browser.