Merge branch 'master' of github.com:thepowersgang/acess2
[tpg/acess2.git] / KernelLand / Modules / Network / E1000 / e1000_hw.h
1 /*
2  * Acess2 E1000 Network Driver
3  * - By John Hodge (thePowersGang)
4  *
5  * e1000_hw.h
6  * - Hardware Definitions
7  */
8 #ifndef _E1000_HW_H_
9 #define _E1000_HW_H_
10
11 typedef struct sRXDesc  tRXDesc;
12 typedef struct sTXDesc  tTXDesc;
13
14 #define RXD_STS_PIF     (1<<7)  // Passed inexact filter (multicast, probably)
15 #define RXD_STS_IPCS    (1<<6)  // IP Checksum was calculated
16 #define RXD_STS_TCPCS   (1<<5)  // TCP Checksum was calculated
17 #define RXD_STS_RSV     (1<<4)  // reserved
18 #define RXD_STS_VP      (1<<3)  // Packet was 802.1q tagged
19 #define RXD_STS_IXSM    (1<<2)  // Ignore IPCS/TCPS
20 #define RXD_STS_EOP     (1<<1)  // Last descriptor in apcket
21 #define RXD_STS_DD      (1<<0)  // Descriptor Done, buffer data is now valid
22
23 #define RXD_ERR_RXE     (1<<7)  // RX Error
24 #define RXD_ERR_IPE     (1<<6)  // IP Checksum Error
25 #define RXD_ERR_TCPE    (1<<5)  // TCP/UDP Checksum Error
26 #define RXD_ERR_CXE     (1<<4)  // Carrier Extension Error (GMII cards [82544GC/EI] only)
27 #define RXD_ERR_SEQ     (1<<2)  // Sequence Error (aka Framing Error)
28 #define RXD_ERR_SE      (1<<1)  // Symbol error (TBI mode)
29 #define RXD_ERR_CE      (1<<0)  // CRC Error / Alignmnet Error
30
31 struct sRXDesc
32 {
33         Uint64  Buffer;
34         Uint16  Length;
35         Uint16  Checksum;
36         Uint8   Status;
37         Uint8   Errors;
38         Uint16  Special;
39 } PACKED;
40
41 #define TXD_CMD_IDE     (1<<7)  // Interrupt delay enable
42 #define TXD_CMD_VLE     (1<<6)  // VLAN Packet enable
43 #define TXD_CMD_DEXT    (1<<5)  // Use extended descriptor format (TODO)
44 #define TXD_CMD_RPS     (1<<4)  // GC/EI Report Packet Set
45 #define TXD_CMD_RS      (1<<3)  // Report Status
46 #define TXD_CMD_IC      (1<<2)  // Insert checksum at indicated offset
47 #define TXD_CMD_IFCS    (1<<1)  // Insert frame check sum
48 #define TXD_CMD_EOP     (1<<0)  // End of packet
49
50 #define TXD_STS_TU      (1<<3)  // [GC/EI] Transmit Underrun
51 #define TXD_STS_LC      (1<<2)  // Late collision
52 #define TXD_STS_EC      (1<<1)  // Excess collisions
53 #define TXD_STS_DD      (1<<0)  // Descriptor Done
54
55 struct sTXDesc
56 {
57         Uint64  Buffer;
58         Uint16  Length;
59         Uint8   CSO;    // TCP Checksum offset
60         Uint8   CMD;
61         Uint8   Status;
62         Uint8   CSS;    // TCP Checksum start
63         Uint16  Special;
64 } PACKED;
65
66 #define TXCD_CMD_IDE    (1<<(24+7))     // Interrupt Delay
67 #define TXCD_CMD_DEXT   (1<<(24+5))     // Descriptor Extension (Must be one)
68 #define TXCD_CMD_RS     (1<<(24+3))     // Report Status
69 #define TXCD_CMD_TSE    (1<<(24+2))     // TCP Segmentation Enable
70 #define TXCD_CMD_IP     (1<<(24+1))     // IP version (1=IPv4, 0=IPv6)
71 #define TXCD_CMD_TCP    (1<<(24+0))     // Packet Type (1=TCP, 0=Other)
72
73 #define TXCD_STS_DD     (1<<0)  // Descriptor Done
74
75 struct sTXCtxDesc
76 {
77         Uint8   IPCSS;  // IP Checksum Start
78         Uint8   IPCSO;  // IP Checksum Offset
79         Uint16  IPCSE;  // IP Checksum Ending (last byte)
80         Uint8   TUCSS;  // TCP/UDP Checksum Start
81         Uint8   TUCSO;  // TCP/UDP Checksum Offset
82         Uint16  TUCSE;  // TCP/UDP Checksum Ending
83         Uint32  CmdLen; // [0:19] Length, [20:23] DTYP (0), [24:31] TUCMD
84         Uint8   Status;
85         Uint8   HdrLen; // Header length
86         Uint16  MSS;    // Maximum segment size
87 } PACKED;
88
89 #define TXDD_CMD_IDE    (1<<(24+7))     // Interrupt Delay
90 #define TXDD_CMD_VLE    (1<<(24+6))     // VLAN Enable
91 #define TXDD_CMD_DEXT   (1<<(24+5))     // Descriptor Extension
92 #define TXDD_CMD_RPS    (1<<(24+4))     // [GC/EI] Report Packet Sent
93 #define TXDD_CMD_RS     (1<<(24+3))     // Report Status
94 #define TXDD_CMD_TSE    (1<<(24+2))     // TCP Segmentation Enable
95 #define TXDD_CMD_IFCS   (1<<(24+1))     // Insert FCS
96 #define TXDD_CMD_EOP    (1<<(24+0))     // End of packet
97
98 #define TXDD_STS_TU     (1<<3)  // [GC/EI] Transmit Underrun
99 #define TXDD_STS_LC     (1<<2)  // Late collision
100 #define TXDD_STS_EC     (1<<1)  // Excess collisions
101 #define TXDD_STS_DD     (1<<0)  // Descriptor Done
102
103 #define TXDD_POPTS_TXSM (1<<1)  // Insert TCP/UDP Checksum
104 #define TXDD_POPTS_IXSM (1<<0)  // Insert IP Checksum
105
106 struct sTXDataDesc
107 {
108         Uint64  Buffer;
109         Uint32  CmdLen; // [0:19] Length, [20:23] DTYP (1), [24:31] DCMD
110         Uint8   Status;
111         Uint8   POpts;  // Packet option field
112         Uint16  Special;
113 };
114
115 #define REG32(card,ofs) (((volatile Uint32*)card->MMIOBase)[ofs/4])
116 #define REG64(card,ofs) (((volatile Uint64*)card->MMIOBase)[ofs/8])
117
118 enum eRegs
119 {
120         REG_CTRL        = 0x000,
121         REG_STATUS      = 0x008,
122         REG_EECD        = 0x010,
123         REG_EERD        = 0x014,
124         REG_CTRL_EXT    = 0x018,
125         REG_FLA         = 0x01C,
126         REG_MDIC        = 0x020,
127         REG_FCAL        = 0x028,        // 64-bit value
128         REG_FCAH        = 0x02C,
129         REG_FCT         = 0x030,
130
131         REG_ICR         = 0x0C0,        // Interrupt cause read
132         REG_ITR         = 0x0C4,        // Interrupt throttling
133         REG_ICS         = 0x0C8,        // Interrupt cause set
134         REG_IMS         = 0x0D0,        // Interrupt mask set/read
135         REG_IMC         = 0x0D8,        // Interrupt mask clear
136
137         REG_TXCW        = 0x178,        // N/A for 82540EP/EM, 82541xx and 82547GI/EI
138         REG_RXCW        = 0x180,        // ^^
139         REG_LEDCTL      = 0xE00,
140         
141         REG_RCTL        = 0x100,
142         REG_RDBAL       = 0x2800,
143         REG_RDLEN       = 0x2808,
144         REG_RDH         = 0x2810,
145         REG_RDT         = 0x2818,
146         REG_RDTR        = 0x2820,
147         REG_RXDCTL      = 0x2820,       // Receive Descriptor Control
148         
149         REG_TCTL        = 0x400,
150         REG_TDBAL       = 0x3800,
151         REG_TDLEN       = 0x3808,
152         REG_TDH         = 0x3810,
153         REG_TDT         = 0x3818,
154         REG_TDIV        = 0x3820,       // Transmit Interrupt Delay Value
155         REG_TXDCTL      = 0x3828,       // Transmit Descriptor Control
156         
157         REG_MTA0        = 0x5200,       // 128 entries
158         REG_RA0         = 0x5400,       // 16 entries of ?
159         REG_VFTA0       = 0x6500,       // 128 entries
160 };
161
162 #define CTRL_FD         (1 << 0)        // Full-Duplex
163 #define CTRL_LRST       (1 << 3)        // Link Reset
164 #define CTRL_ASDE       (1 << 5)        // Auto-Speed Detection Enable
165 #define CTRL_SLU        (1 << 6)        // Set link up
166 // TODO: CTRL_*
167 #define CTRL_SDP0_DATA  (1 << 18)       // Software Programmable IO #0 (Data)
168 #define CTRL_SDP1_DATA  (1 << 19)       // Software Programmable IO #1 (Data)
169 // TODO: CTRL_*
170 #define CTRL_RST        (1 << 26)       // Software reset (cleared by hw once complete)
171 #define CTRL_RFCE       (1 << 27)       // Receive Flow Control Enable
172 #define CTRL_TFCE       (1 << 28)       // Transmit Flow Control Enable
173 #define CTRL_VME        (1 << 30)       // VLAN Mode Enable
174 #define CTRL_PHY_RST    (1 << 31)       // PHY Reset (3uS)
175
176 #define ICR_TXDW        (1 << 0)        // Transmit Descriptor Written Back
177 #define ICR_TXQE        (1 << 1)        // Transmit Queue Empty
178 #define ICR_LSC         (1 << 2)        // Link Status Change
179 #define ICR_RXSEQ       (1 << 3)        // Receive Sequence Error (Framing Error)
180 #define ICR_RXDMT0      (1 << 4)        // Receive Descriptor Minimum Threshold Reached (need more RX descs)
181 #define ICR_XRO         (1 << 6)        // Receiver overrun
182 #define ICR_RXT0        (1 << 7)        // Receiver Timer Interrupt
183 #define ICR_MDAC        (1 << 9)        // MDI/O Access Complete
184 #define ICR_RXCFG       (1 << 10)       // Receiving /C/ ordered sets
185 #define ICR_PHYINT      (1 << 12)       // PHY Interrupt
186 #define ICR_GPI_SDP6    (1 << 13)       // GP Interrupt SDP6/SDP2
187 #define ICR_GPI_SDP7    (1 << 14)       // GP Interrupt SDP7/SDP3
188 #define ICR_TXD_LOW     (1 << 15)       // Transmit Descriptor Low Threshold hit
189 #define ICR_SRPD        (1 << 16)       // Small Receive Packet Detected
190
191 #define RCTL_EN         (1 << 1)        // Receiver Enable
192 #define RCTL_SBP        (1 << 2)        // Store Bad Packets
193 #define RCTL_UPE        (1 << 3)        // Unicast Promiscuous Enabled
194 #define RCTL_MPE        (1 << 4)        // Multicast Promiscuous Enabled
195 #define RCTL_LPE        (1 << 5)        // Long Packet Reception Enable
196 #define RCTL_LBM        (3 << 6)        // Loopback mode
197 enum {
198         RCTL_LBM_NONE   = 0 << 6,       // - No Loopback
199         RCTL_LBM_UD1    = 1 << 6,       // - Undefined
200         RCTL_LBM_UD2    = 2 << 6,       // - Undefined
201         RCTL_LBM_PHY    = 3 << 6,       // - PHY or external SerDes loopback
202 };
203 #define RCTL_RDMTS      (3 << 8)        // Receive Descriptor Minimum Threshold Size
204 enum {
205         RCTL_RDMTS_1_2  = 0 << 8,       // - 1/2 RDLEN free
206         RCTL_RDMTS_1_4  = 1 << 8,       // - 1/4 RDLEN free
207         RCTL_RDMTS_1_8  = 2 << 8,       // - 1/8 RDLEN free
208         RCTL_RDMTS_RSVD = 3 << 8,       // - Reserved
209 };
210 #define RCTL_MO         (3 << 12)       // Multicast Offset
211 enum {
212         RCTL_MO_36      = 0 << 12,      // bits [47:36] of multicast address
213         RCTL_MO_35      = 1 << 12,      // bits [46:35] of multicast address
214         RCTL_MO_34      = 2 << 12,      // bits [45:34] of multicast address
215         RCTL_MO_32      = 3 << 12,      // bits [43:32] of multicast address
216 };
217 #define RCTL_BAM        (1 << 15)       // Broadcast Accept Mode
218 #define RCTL_BSIZE      (1 << 16)       // Receive Buffer Size
219 enum {
220         RCTL_BSIZE_2048 = (0 << 16),    // - 2048 bytes
221         RCTL_BSIZE_1024 = (1 << 16),    // - 1024 bytes
222         RCTL_BSIZE_512  = (2 << 16),    // - 512 bytes
223         RCTL_BSIZE_256  = (3 << 16),    // - 256 bytes
224         
225         RCTL_BSIZE_RSVD = (0 << 16)|(1 << 25),  // - Reserved
226         RCTL_BSIZE_16K  = (1 << 16)|(1 << 25),  // - 16384 bytes
227         RCTL_BSIZE_8192 = (2 << 16)|(1 << 25),  // - 8192 bytes
228         RCTL_BSIZE_4096 = (3 << 16)|(1 << 25),  // - 4096 bytes
229 };
230 #define RCTL_VFE        (1 << 18)       // VLAN Filter Enable
231 #define RCTL_CFIEN      (1 << 19)       // Canoical Form Indicator Enable
232 #define RCTL_CFI        (1 << 20)       // Value to check the CFI for [Valid if CFIEN]
233 #define RCTL_DPF        (1 << 22)       // Discard Pause Frames
234 #define RCTL_PMCF       (1 << 23)       // Pass MAC Control Frames
235 #define RCTL_BSEX       (1 << 25)       // Buffer Size Extension (multply BSIZE by 16, used in BSIZE enum)
236 #define RCTL_SECRC      (1 << 26)       // Strip Ethernet CRC
237
238 #define TCTL_EN         (1 << 1)        // Transmit Enable
239 #define TCTL_PSP        (1 << 3)        // Pad Short Packets
240 #define TCTL_CT         (255 << 4)      // Collision Threshold
241 #define TCTL_CT_ofs     4
242 #define TCTL_COLD       (1023 << 12)    // Collision Distance
243 #define TCTL_COLD_ofs   12
244 #define TCTL_SWXOFF     (1 << 22)       // Software XOFF Transmission
245 #define TCTL_RTLC       (1 << 24)       // Retransmit on Late Collision
246 #define TCTL_NRTU       (1 << 25)       // No retransmit on underrun [82544GC/EI]
247
248 #endif
249

UCC git Repository :: git.ucc.asn.au