if_stgereg.h revision 1.6 1 1.6 msaitoh /* $NetBSD: if_stgereg.h,v 1.6 2019/10/07 11:53:40 msaitoh Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*-
4 1.1 thorpej * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.1 thorpej * by Jason R. Thorpe.
9 1.1 thorpej *
10 1.1 thorpej * Redistribution and use in source and binary forms, with or without
11 1.1 thorpej * modification, are permitted provided that the following conditions
12 1.1 thorpej * are met:
13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.1 thorpej * notice, this list of conditions and the following disclaimer.
15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.1 thorpej * documentation and/or other materials provided with the distribution.
18 1.1 thorpej *
19 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
30 1.1 thorpej */
31 1.1 thorpej
32 1.1 thorpej #ifndef _DEV_PCI_IF_STGEREG_H_
33 1.1 thorpej #define _DEV_PCI_IF_STGEREG_H_
34 1.1 thorpej
35 1.6 msaitoh
36 1.6 msaitoh #include <net/if_ether.h>
37 1.6 msaitoh #include <sys/bus.h>
38 1.6 msaitoh
39 1.1 thorpej /*
40 1.1 thorpej * Register description for the Sundance Tech. TC9021 10/100/1000
41 1.1 thorpej * Ethernet controller.
42 1.1 thorpej *
43 1.1 thorpej * Note that while DMA addresses are all in 64-bit fields, only
44 1.1 thorpej * the lower 40 bits of a DMA address are valid.
45 1.1 thorpej */
46 1.1 thorpej
47 1.1 thorpej /*
48 1.1 thorpej * TC9021 buffer fragment descriptor.
49 1.1 thorpej */
50 1.1 thorpej struct stge_frag {
51 1.1 thorpej uint64_t frag_word0; /* address, length */
52 1.4 perry } __packed;
53 1.1 thorpej
54 1.1 thorpej #define FRAG_ADDR(x) (((uint64_t)(x)) << 0)
55 1.1 thorpej #define FRAG_ADDR_MASK FRAG_ADDR(0xfffffffffULL)
56 1.1 thorpej #define FRAG_LEN(x) (((uint64_t)(x)) << 48)
57 1.1 thorpej #define FRAG_LEN_MASK FRAG_LEN(0xffffULL)
58 1.1 thorpej
59 1.1 thorpej /*
60 1.1 thorpej * TC9021 Transmit Frame Descriptor. Note the number of fragments
61 1.2 enami * here is arbitrary, but we can't have any more than 15.
62 1.1 thorpej */
63 1.1 thorpej #define STGE_NTXFRAGS 12
64 1.1 thorpej struct stge_tfd {
65 1.1 thorpej uint64_t tfd_next; /* next TFD in list */
66 1.1 thorpej uint64_t tfd_control; /* control bits */
67 1.1 thorpej /* the buffer fragments */
68 1.1 thorpej struct stge_frag tfd_frags[STGE_NTXFRAGS];
69 1.4 perry } __packed;
70 1.1 thorpej
71 1.1 thorpej #define TFD_FrameId(x) ((x) << 0)
72 1.1 thorpej #define TFD_FrameId_MAX 0xffff
73 1.1 thorpej #define TFD_WordAlign(x) ((x) << 16)
74 1.1 thorpej #define TFD_WordAlign_dword 0 /* align to dword in TxFIFO */
75 1.1 thorpej #define TFD_WordAlign_word 2 /* align to word in TxFIFO */
76 1.1 thorpej #define TFD_WordAlign_disable 1 /* disable alignment */
77 1.1 thorpej #define TFD_TCPChecksumEnable (1ULL << 18)
78 1.1 thorpej #define TFD_UDPChecksumEnable (1ULL << 19)
79 1.1 thorpej #define TFD_IPChecksumEnable (1ULL << 20)
80 1.1 thorpej #define TFD_FcsAppendDisable (1ULL << 21)
81 1.1 thorpej #define TFD_TxIndicate (1ULL << 22)
82 1.1 thorpej #define TFD_TxDMAIndicate (1ULL << 23)
83 1.1 thorpej #define TFD_FragCount(x) ((x) << 24)
84 1.1 thorpej #define TFD_VLANTagInsert (1ULL << 28)
85 1.1 thorpej #define TFD_TFDDone (1ULL << 31)
86 1.1 thorpej #define TFD_VID(x) (((uint64_t)(x)) << 32)
87 1.1 thorpej #define TFD_CFI (1ULL << 44)
88 1.1 thorpej #define TFD_UserPriority(x) (((uint64_t)(x)) << 45)
89 1.1 thorpej
90 1.1 thorpej /*
91 1.1 thorpej * TC9021 Receive Frame Descriptor. Each RFD has a single fragment
92 1.1 thorpej * in it, and the chip tells us the beginning and end of the frame.
93 1.1 thorpej */
94 1.1 thorpej struct stge_rfd {
95 1.1 thorpej uint64_t rfd_next; /* next RFD in list */
96 1.1 thorpej uint64_t rfd_status; /* status bits */
97 1.1 thorpej struct stge_frag rfd_frag; /* the buffer */
98 1.4 perry } __packed;
99 1.1 thorpej
100 1.1 thorpej #define RFD_RxDMAFrameLen(x) ((x) & 0xffff)
101 1.1 thorpej #define RFD_RxFIFOOverrun (1ULL << 16)
102 1.1 thorpej #define RFD_RxRuntFrame (1ULL << 17)
103 1.1 thorpej #define RFD_RxAlignmentError (1ULL << 18)
104 1.1 thorpej #define RFD_RxFCSError (1ULL << 19)
105 1.1 thorpej #define RFD_RxOversizedFrame (1ULL << 20)
106 1.1 thorpej #define RFD_RxLengthError (1ULL << 21)
107 1.1 thorpej #define RFD_VLANDetected (1ULL << 22)
108 1.1 thorpej #define RFD_TCPDetected (1ULL << 23)
109 1.1 thorpej #define RFD_TCPError (1ULL << 24)
110 1.1 thorpej #define RFD_UDPDetected (1ULL << 25)
111 1.1 thorpej #define RFD_UDPError (1ULL << 26)
112 1.1 thorpej #define RFD_IPDetected (1ULL << 27)
113 1.1 thorpej #define RFD_IPError (1ULL << 28)
114 1.1 thorpej #define RFD_FrameStart (1ULL << 29)
115 1.1 thorpej #define RFD_FrameEnd (1ULL << 30)
116 1.1 thorpej #define RFD_RFDDone (1ULL << 31)
117 1.1 thorpej #define RFD_TCI(x) ((((uint64_t)(x)) >> 32) & 0xffff)
118 1.1 thorpej
119 1.1 thorpej /*
120 1.1 thorpej * PCI configuration registers used by the TC9021.
121 1.1 thorpej */
122 1.1 thorpej
123 1.1 thorpej #define STGE_PCI_IOBA (PCI_MAPREG_START + 0x00)
124 1.1 thorpej #define STGE_PCI_MMBA (PCI_MAPREG_START + 0x04)
125 1.1 thorpej
126 1.1 thorpej /*
127 1.1 thorpej * EEPROM offsets.
128 1.1 thorpej */
129 1.1 thorpej #define STGE_EEPROM_ConfigParam 0x00
130 1.1 thorpej #define STGE_EEPROM_AsicCtrl 0x01
131 1.1 thorpej #define STGE_EEPROM_SubSystemVendorId 0x02
132 1.1 thorpej #define STGE_EEPROM_SubSystemId 0x03
133 1.1 thorpej #define STGE_EEPROM_StationAddress0 0x10
134 1.1 thorpej #define STGE_EEPROM_StationAddress1 0x11
135 1.1 thorpej #define STGE_EEPROM_StationAddress2 0x12
136 1.1 thorpej
137 1.1 thorpej /*
138 1.1 thorpej * The TC9021 register space.
139 1.1 thorpej */
140 1.1 thorpej
141 1.1 thorpej #define STGE_DMACtrl 0x00
142 1.1 thorpej #define DMAC_RxDMAComplete (1U << 3)
143 1.1 thorpej #define DMAC_RxDMAPollNow (1U << 4)
144 1.1 thorpej #define DMAC_TxDMAComplete (1U << 11)
145 1.1 thorpej #define DMAC_TxDMAPollNow (1U << 12)
146 1.1 thorpej #define DMAC_TxDMAInProg (1U << 15)
147 1.1 thorpej #define DMAC_RxEarlyDisable (1U << 16)
148 1.1 thorpej #define DMAC_MWIDisable (1U << 18)
149 1.1 thorpej #define DMAC_TxWiteBackDisable (1U << 19)
150 1.1 thorpej #define DMAC_TxBurstLimit(x) ((x) << 20)
151 1.1 thorpej #define DMAC_TargetAbort (1U << 30)
152 1.1 thorpej #define DMAC_MasterAbort (1U << 31)
153 1.1 thorpej
154 1.1 thorpej #define STGE_RxDMAStatus 0x08
155 1.1 thorpej
156 1.1 thorpej #define STGE_TFDListPtrLo 0x10
157 1.1 thorpej
158 1.1 thorpej #define STGE_TFDListPtrHi 0x14
159 1.1 thorpej
160 1.1 thorpej #define STGE_TxDMABurstThresh 0x18 /* 8-bit */
161 1.1 thorpej
162 1.1 thorpej #define STGE_TxDMAUrgentThresh 0x19 /* 8-bit */
163 1.1 thorpej
164 1.1 thorpej #define STGE_TxDMAPollPeriod 0x1a /* 8-bit */
165 1.1 thorpej
166 1.1 thorpej #define STGE_RFDListPtrLo 0x1c
167 1.1 thorpej
168 1.1 thorpej #define STGE_RFDListPtrHi 0x20
169 1.1 thorpej
170 1.1 thorpej #define STGE_RxDMABurstThresh 0x24 /* 8-bit */
171 1.1 thorpej
172 1.1 thorpej #define STGE_RxDMAUrgentThresh 0x25 /* 8-bit */
173 1.1 thorpej
174 1.1 thorpej #define STGE_RxDMAPollPeriod 0x26 /* 8-bit */
175 1.1 thorpej
176 1.1 thorpej #define STGE_RxDMAIntCtrl 0x28
177 1.1 thorpej #define RDIC_RxFrameCount(x) ((x) & 0xff)
178 1.1 thorpej #define RDIC_PriorityThresh(x) ((x) << 10)
179 1.1 thorpej #define RDIC_RxDMAWaitTime(x) ((x) << 16)
180 1.1 thorpej
181 1.1 thorpej #define STGE_DebugCtrl 0x2c /* 16-bit */
182 1.1 thorpej #define DC_GPIO0Ctrl (1U << 0)
183 1.1 thorpej #define DC_GPIO1Ctrl (1U << 1)
184 1.1 thorpej #define DC_GPIO0 (1U << 2)
185 1.1 thorpej #define DC_GPIO1 (1U << 3)
186 1.1 thorpej
187 1.1 thorpej #define STGE_AsicCtrl 0x30
188 1.1 thorpej #define AC_ExpRomDisable (1U << 0)
189 1.1 thorpej #define AC_ExpRomSize (1U << 1)
190 1.1 thorpej #define AC_PhySpeed10 (1U << 4)
191 1.1 thorpej #define AC_PhySpeed100 (1U << 5)
192 1.1 thorpej #define AC_PhySpeed1000 (1U << 6)
193 1.1 thorpej #define AC_PhyMedia (1U << 7)
194 1.1 thorpej #define AC_ForcedConfig(x) ((x) << 8)
195 1.1 thorpej #define AC_ForcedConfig_MASK AC_ForcedConfig(7)
196 1.1 thorpej #define AC_D3ResetDisable (1U << 11)
197 1.1 thorpej #define AC_SpeedupMode (1U << 13)
198 1.1 thorpej #define AC_LEDMode (1U << 14)
199 1.1 thorpej #define AC_RstOutPolarity (1U << 15)
200 1.1 thorpej #define AC_GlobalReset (1U << 16)
201 1.1 thorpej #define AC_RxReset (1U << 17)
202 1.1 thorpej #define AC_TxReset (1U << 18)
203 1.1 thorpej #define AC_DMA (1U << 19)
204 1.1 thorpej #define AC_FIFO (1U << 20)
205 1.1 thorpej #define AC_Network (1U << 21)
206 1.1 thorpej #define AC_Host (1U << 22)
207 1.1 thorpej #define AC_AutoInit (1U << 23)
208 1.1 thorpej #define AC_RstOut (1U << 24)
209 1.1 thorpej #define AC_InterruptRequest (1U << 25)
210 1.1 thorpej #define AC_ResetBusy (1U << 26)
211 1.1 thorpej
212 1.1 thorpej #define STGE_FIFOCtrl 0x38 /* 16-bit */
213 1.1 thorpej #define FC_RAMTestMode (1U << 0)
214 1.1 thorpej #define FC_Transmitting (1U << 14)
215 1.1 thorpej #define FC_Receiving (1U << 15)
216 1.1 thorpej
217 1.1 thorpej #define STGE_RxEarlyThresh 0x3a /* 16-bit */
218 1.1 thorpej
219 1.1 thorpej #define STGE_FlowOffThresh 0x3c /* 16-bit */
220 1.1 thorpej
221 1.1 thorpej #define STGE_FlowOnTresh 0x3e /* 16-bit */
222 1.1 thorpej
223 1.1 thorpej #define STGE_TxStartThresh 0x44 /* 16-bit */
224 1.1 thorpej
225 1.1 thorpej #define STGE_EepromData 0x48 /* 16-bit */
226 1.1 thorpej
227 1.1 thorpej #define STGE_EepromCtrl 0x4a /* 16-bit */
228 1.1 thorpej #define EC_EepromAddress(x) ((x) & 0xff)
229 1.1 thorpej #define EC_EepromOpcode(x) ((x) << 8)
230 1.1 thorpej #define EC_OP_WE 0
231 1.1 thorpej #define EC_OP_WR 1
232 1.1 thorpej #define EC_OP_RR 2
233 1.1 thorpej #define EC_OP_ER 3
234 1.1 thorpej #define EC_EepromBusy (1U << 15)
235 1.1 thorpej
236 1.1 thorpej #define STGE_ExpRomAddr 0x4c
237 1.1 thorpej
238 1.1 thorpej #define STGE_ExpRomData 0x50 /* 8-bit */
239 1.1 thorpej
240 1.1 thorpej #define STGE_WakeEvent 0x51 /* 8-bit */
241 1.1 thorpej
242 1.1 thorpej #define STGE_Countdown 0x54
243 1.1 thorpej #define CD_Count(x) ((x) & 0xffff)
244 1.1 thorpej #define CD_CountdownSpeed (1U << 24)
245 1.1 thorpej #define CD_CountdownMode (1U << 25)
246 1.1 thorpej #define CD_CountdownIntEnabled (1U << 26)
247 1.1 thorpej
248 1.1 thorpej #define STGE_IntStatusAck 0x5a /* 16-bit */
249 1.1 thorpej
250 1.3 christos #define STGE_IntStatus 0x5e /* 16-bit */
251 1.3 christos
252 1.1 thorpej #define STGE_IntEnable 0x5c /* 16-bit */
253 1.1 thorpej
254 1.1 thorpej #define IS_InterruptStatus (1U << 0)
255 1.3 christos #define IS_HostError (1U << 1)
256 1.3 christos #define IS_TxComplete (1U << 2)
257 1.3 christos #define IS_MACControlFrame (1U << 3)
258 1.3 christos #define IS_RxComplete (1U << 4)
259 1.3 christos #define IS_RxEarly (1U << 5)
260 1.3 christos #define IS_InRequested (1U << 6)
261 1.3 christos #define IS_UpdateStats (1U << 7)
262 1.3 christos #define IS_LinkEvent (1U << 8)
263 1.3 christos #define IS_TxDMAComplete (1U << 9)
264 1.3 christos #define IS_RxDMAComplete (1U << 10)
265 1.3 christos #define IS_RFDListEnd (1U << 11)
266 1.3 christos #define IS_RxDMAPriority (1U << 12)
267 1.1 thorpej
268 1.1 thorpej #define STGE_TxStatus 0x60
269 1.1 thorpej #define TS_TxError (1U << 0)
270 1.1 thorpej #define TS_LateCollision (1U << 2)
271 1.1 thorpej #define TS_MaxCollisions (1U << 3)
272 1.1 thorpej #define TS_TxUnderrun (1U << 4)
273 1.1 thorpej #define TS_TxIndicateReqd (1U << 6)
274 1.1 thorpej #define TS_TxComplete (1U << 7)
275 1.1 thorpej #define TS_TxFrameId_get(x) ((x) >> 16)
276 1.1 thorpej
277 1.1 thorpej #define STGE_MACCtrl 0x6c
278 1.1 thorpej #define MC_IFSSelect(x) ((x) & 3)
279 1.1 thorpej #define MC_DuplexSelect (1U << 5)
280 1.1 thorpej #define MC_RcvLargeFrames (1U << 6)
281 1.1 thorpej #define MC_TxFlowControlEnable (1U << 7)
282 1.1 thorpej #define MC_RxFlowControlEnable (1U << 8)
283 1.1 thorpej #define MC_RcvFCS (1U << 9)
284 1.1 thorpej #define MC_FIFOLoopback (1U << 10)
285 1.1 thorpej #define MC_MACLoopback (1U << 11)
286 1.1 thorpej #define MC_AutoVLANtagging (1U << 12)
287 1.1 thorpej #define MC_AutoVLANuntagging (1U << 13)
288 1.1 thorpej #define MC_CollisionDetect (1U << 16)
289 1.1 thorpej #define MC_CarrierSense (1U << 17)
290 1.1 thorpej #define MC_StatisticsEnable (1U << 21)
291 1.1 thorpej #define MC_StatisticsDisable (1U << 22)
292 1.1 thorpej #define MC_StatisticsEnabled (1U << 23)
293 1.1 thorpej #define MC_TxEnable (1U << 24)
294 1.1 thorpej #define MC_TxDisable (1U << 25)
295 1.1 thorpej #define MC_TxEnabled (1U << 26)
296 1.1 thorpej #define MC_RxEnable (1U << 27)
297 1.1 thorpej #define MC_RxDisable (1U << 28)
298 1.1 thorpej #define MC_RxEnabled (1U << 29)
299 1.1 thorpej #define MC_Paused (1U << 30)
300 1.1 thorpej
301 1.1 thorpej #define STGE_VLANTag 0x70
302 1.1 thorpej
303 1.1 thorpej #define STGE_PhyCtrl 0x76 /* 8-bit */
304 1.1 thorpej #define PC_MgmtClk (1U << 0)
305 1.1 thorpej #define PC_MgmtData (1U << 1)
306 1.1 thorpej #define PC_MgmtDir (1U << 2) /* MAC->PHY */
307 1.1 thorpej #define PC_PhyDuplexPolarity (1U << 3)
308 1.1 thorpej #define PC_PhyDuplexStatus (1U << 4)
309 1.1 thorpej #define PC_PhyLnkPolarity (1U << 5)
310 1.1 thorpej #define PC_LinkSpeed(x) (((x) >> 6) & 3)
311 1.1 thorpej #define PC_LinkSpeed_Down 0
312 1.1 thorpej #define PC_LinkSpeed_10 1
313 1.1 thorpej #define PC_LinkSpeed_100 2
314 1.1 thorpej #define PC_LinkSpeed_1000 3
315 1.1 thorpej
316 1.1 thorpej #define STGE_StationAddress0 0x78 /* 16-bit */
317 1.1 thorpej
318 1.1 thorpej #define STGE_StationAddress1 0x7a /* 16-bit */
319 1.1 thorpej
320 1.1 thorpej #define STGE_StationAddress2 0x7c /* 16-bit */
321 1.1 thorpej
322 1.1 thorpej #define STGE_VLANHashTable 0x7e /* 16-bit */
323 1.1 thorpej
324 1.1 thorpej #define STGE_VLANId 0x80
325 1.1 thorpej
326 1.1 thorpej #define STGE_MaxFrameSize 0x84
327 1.1 thorpej
328 1.1 thorpej #define STGE_ReceiveMode 0x88 /* 16-bit */
329 1.1 thorpej #define RM_ReceiveUnicast (1U << 0)
330 1.1 thorpej #define RM_ReceiveMulticast (1U << 1)
331 1.1 thorpej #define RM_ReceiveBroadcast (1U << 2)
332 1.1 thorpej #define RM_ReceiveAllFrames (1U << 3)
333 1.1 thorpej #define RM_ReceiveMulticastHash (1U << 4)
334 1.1 thorpej #define RM_ReceiveIPMulticast (1U << 5)
335 1.1 thorpej #define RM_ReceiveVLANMatch (1U << 8)
336 1.1 thorpej #define RM_ReceiveVLANHash (1U << 9)
337 1.1 thorpej
338 1.1 thorpej #define STGE_HashTable0 0x8c
339 1.1 thorpej
340 1.1 thorpej #define STGE_HashTable1 0x90
341 1.1 thorpej
342 1.1 thorpej #define STGE_RMONStatisticsMask 0x98 /* set to disable */
343 1.1 thorpej
344 1.1 thorpej #define STGE_StatisticsMask 0x9c /* set to disable */
345 1.1 thorpej
346 1.1 thorpej #define STGE_RxJumboFrames 0xbc /* 16-bit */
347 1.1 thorpej
348 1.1 thorpej #define STGE_TCPCheckSumErrors 0xc0 /* 16-bit */
349 1.1 thorpej
350 1.1 thorpej #define STGE_IPCheckSumErrors 0xc2 /* 16-bit */
351 1.1 thorpej
352 1.1 thorpej #define STGE_UDPCheckSumErrors 0xc4 /* 16-bit */
353 1.1 thorpej
354 1.1 thorpej #define STGE_TxJumboFrames 0xf4 /* 16-bit */
355 1.1 thorpej
356 1.1 thorpej /*
357 1.1 thorpej * TC9021 statistics. Available memory and I/O mapped.
358 1.1 thorpej */
359 1.1 thorpej
360 1.1 thorpej #define STGE_OctetRcvOk 0xa8
361 1.1 thorpej
362 1.1 thorpej #define STGE_McstOctetRcvdOk 0xac
363 1.1 thorpej
364 1.1 thorpej #define STGE_BcstOctetRcvdOk 0xb0
365 1.1 thorpej
366 1.1 thorpej #define STGE_FramesRcvdOk 0xb4
367 1.1 thorpej
368 1.1 thorpej #define STGE_McstFramesRcvdOk 0xb8
369 1.1 thorpej
370 1.1 thorpej #define STGE_BcstFramesRcvdOk 0xbe /* 16-bit */
371 1.1 thorpej
372 1.1 thorpej #define STGE_MacControlFramesRcvd 0xc6 /* 16-bit */
373 1.1 thorpej
374 1.1 thorpej #define STGE_FrameTooLongErrors 0xc8 /* 16-bit */
375 1.1 thorpej
376 1.1 thorpej #define STGE_InRangeLengthErrors 0xca /* 16-bit */
377 1.1 thorpej
378 1.1 thorpej #define STGE_FramesCheckSeqErrors 0xcc /* 16-bit */
379 1.1 thorpej
380 1.1 thorpej #define STGE_FramesLostRxErrors 0xce /* 16-bit */
381 1.1 thorpej
382 1.1 thorpej #define STGE_OctetXmtdOk 0xd0
383 1.1 thorpej
384 1.1 thorpej #define STGE_McstOctetXmtdOk 0xd4
385 1.1 thorpej
386 1.1 thorpej #define STGE_BcstOctetXmtdOk 0xd8
387 1.1 thorpej
388 1.1 thorpej #define STGE_FramesXmtdOk 0xdc
389 1.1 thorpej
390 1.1 thorpej #define STGE_McstFramesXmtdOk 0xe0
391 1.1 thorpej
392 1.1 thorpej #define STGE_FramesWDeferredXmt 0xe4
393 1.1 thorpej
394 1.1 thorpej #define STGE_LateCollisions 0xe8
395 1.1 thorpej
396 1.1 thorpej #define STGE_MultiColFrames 0xec
397 1.1 thorpej
398 1.1 thorpej #define STGE_SingleColFrames 0xf0
399 1.1 thorpej
400 1.1 thorpej #define STGE_BcstFramesXmtdOk 0xf6 /* 16-bit */
401 1.1 thorpej
402 1.1 thorpej #define STGE_CarrierSenseErrors 0xf8 /* 16-bit */
403 1.1 thorpej
404 1.1 thorpej #define STGE_MacControlFramesXmtd 0xfa /* 16-bit */
405 1.1 thorpej
406 1.1 thorpej #define STGE_FramesAbortXSColls 0xfc /* 16-bit */
407 1.1 thorpej
408 1.1 thorpej #define STGE_FramesWEXDeferal 0xfe /* 16-bit */
409 1.1 thorpej
410 1.1 thorpej /*
411 1.1 thorpej * RMON-compatible statistics. Only accessible if memory-mapped.
412 1.1 thorpej */
413 1.1 thorpej
414 1.1 thorpej #define STGE_EtherStatsCollisions 0x100
415 1.1 thorpej
416 1.1 thorpej #define STGE_EtherStatsOctetsTransmit 0x104
417 1.1 thorpej
418 1.1 thorpej #define STGE_EtherStatsPktsTransmit 0x108
419 1.1 thorpej
420 1.1 thorpej #define STGE_EtherStatsPkts64OctetsTransmit 0x10c
421 1.1 thorpej
422 1.1 thorpej #define STGE_EtherStatsPkts64to127OctetsTransmit 0x110
423 1.1 thorpej
424 1.1 thorpej #define STGE_EtherStatsPkts128to255OctetsTransmit 0x114
425 1.1 thorpej
426 1.1 thorpej #define STGE_EtherStatsPkts256to511OctetsTransmit 0x118
427 1.1 thorpej
428 1.1 thorpej #define STGE_EtherStatsPkts512to1023OctetsTransmit 0x11c
429 1.1 thorpej
430 1.1 thorpej #define STGE_EtherStatsPkts1024to1518OctetsTransmit 0x120
431 1.1 thorpej
432 1.1 thorpej #define STGE_EtherStatsCRCAlignErrors 0x124
433 1.1 thorpej
434 1.1 thorpej #define STGE_EtherStatsUndersizePkts 0x128
435 1.1 thorpej
436 1.1 thorpej #define STGE_EtherStatsFragments 0x12c
437 1.1 thorpej
438 1.1 thorpej #define STGE_EtherStatsJabbers 0x130
439 1.1 thorpej
440 1.1 thorpej #define STGE_EtherStatsOctets 0x134
441 1.1 thorpej
442 1.1 thorpej #define STGE_EtherStatsPkts 0x138
443 1.1 thorpej
444 1.1 thorpej #define STGE_EtherStatsPkts64Octets 0x13c
445 1.1 thorpej
446 1.1 thorpej #define STGE_EtherStatsPkts65to127Octets 0x140
447 1.1 thorpej
448 1.1 thorpej #define STGE_EtherStatsPkts128to255Octets 0x144
449 1.1 thorpej
450 1.1 thorpej #define STGE_EtherStatsPkts256to511Octets 0x148
451 1.1 thorpej
452 1.1 thorpej #define STGE_EtherStatsPkts512to1023Octets 0x14c
453 1.1 thorpej
454 1.1 thorpej #define STGE_EtherStatsPkts1024to1518Octets 0x150
455 1.1 thorpej
456 1.6 msaitoh /*
457 1.6 msaitoh * Transmit descriptor list size.
458 1.6 msaitoh */
459 1.6 msaitoh #define STGE_NTXDESC 256
460 1.6 msaitoh #define STGE_NTXDESC_MASK (STGE_NTXDESC - 1)
461 1.6 msaitoh #define STGE_NEXTTX(x) (((x) + 1) & STGE_NTXDESC_MASK)
462 1.6 msaitoh
463 1.6 msaitoh /*
464 1.6 msaitoh * Receive descriptor list size.
465 1.6 msaitoh */
466 1.6 msaitoh #define STGE_NRXDESC 256
467 1.6 msaitoh #define STGE_NRXDESC_MASK (STGE_NRXDESC - 1)
468 1.6 msaitoh #define STGE_NEXTRX(x) (((x) + 1) & STGE_NRXDESC_MASK)
469 1.6 msaitoh
470 1.6 msaitoh /*
471 1.6 msaitoh * Only interrupt every N frames. Must be a power-of-two.
472 1.6 msaitoh */
473 1.6 msaitoh #define STGE_TXINTR_SPACING 16
474 1.6 msaitoh #define STGE_TXINTR_SPACING_MASK (STGE_TXINTR_SPACING - 1)
475 1.6 msaitoh
476 1.6 msaitoh /*
477 1.6 msaitoh * Control structures are DMA'd to the TC9021 chip. We allocate them in
478 1.6 msaitoh * a single clump that maps to a single DMA segment to make several things
479 1.6 msaitoh * easier.
480 1.6 msaitoh */
481 1.6 msaitoh struct stge_control_data {
482 1.6 msaitoh /*
483 1.6 msaitoh * The transmit descriptors.
484 1.6 msaitoh */
485 1.6 msaitoh struct stge_tfd scd_txdescs[STGE_NTXDESC];
486 1.6 msaitoh
487 1.6 msaitoh /*
488 1.6 msaitoh * The receive descriptors.
489 1.6 msaitoh */
490 1.6 msaitoh struct stge_rfd scd_rxdescs[STGE_NRXDESC];
491 1.6 msaitoh };
492 1.6 msaitoh
493 1.6 msaitoh /*
494 1.6 msaitoh * Software state for transmit and receive jobs.
495 1.6 msaitoh */
496 1.6 msaitoh struct stge_descsoft {
497 1.6 msaitoh struct mbuf *ds_mbuf; /* head of our mbuf chain */
498 1.6 msaitoh bus_dmamap_t ds_dmamap; /* our DMA map */
499 1.6 msaitoh };
500 1.6 msaitoh
501 1.6 msaitoh /*
502 1.6 msaitoh * Software state per device.
503 1.6 msaitoh */
504 1.6 msaitoh struct stge_softc {
505 1.6 msaitoh device_t sc_dev; /* generic device information */
506 1.6 msaitoh bus_space_tag_t sc_st; /* bus space tag */
507 1.6 msaitoh bus_space_handle_t sc_sh; /* bus space handle */
508 1.6 msaitoh bus_dma_tag_t sc_dmat; /* bus DMA tag */
509 1.6 msaitoh struct ethercom sc_ethercom; /* ethernet common data */
510 1.6 msaitoh int sc_rev; /* silicon revision */
511 1.6 msaitoh
512 1.6 msaitoh void *sc_ih; /* interrupt cookie */
513 1.6 msaitoh
514 1.6 msaitoh struct mii_data sc_mii; /* MII/media information */
515 1.6 msaitoh
516 1.6 msaitoh callout_t sc_tick_ch; /* tick callout */
517 1.6 msaitoh
518 1.6 msaitoh bus_dmamap_t sc_cddmamap; /* control data DMA map */
519 1.6 msaitoh #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr
520 1.6 msaitoh
521 1.6 msaitoh /*
522 1.6 msaitoh * Software state for transmit and receive descriptors.
523 1.6 msaitoh */
524 1.6 msaitoh struct stge_descsoft sc_txsoft[STGE_NTXDESC];
525 1.6 msaitoh struct stge_descsoft sc_rxsoft[STGE_NRXDESC];
526 1.6 msaitoh
527 1.6 msaitoh /*
528 1.6 msaitoh * Control data structures.
529 1.6 msaitoh */
530 1.6 msaitoh struct stge_control_data *sc_control_data;
531 1.6 msaitoh #define sc_txdescs sc_control_data->scd_txdescs
532 1.6 msaitoh #define sc_rxdescs sc_control_data->scd_rxdescs
533 1.6 msaitoh
534 1.6 msaitoh #ifdef STGE_EVENT_COUNTERS
535 1.6 msaitoh /*
536 1.6 msaitoh * Event counters.
537 1.6 msaitoh */
538 1.6 msaitoh struct evcnt sc_ev_txstall; /* Tx stalled */
539 1.6 msaitoh struct evcnt sc_ev_txdmaintr; /* Tx DMA interrupts */
540 1.6 msaitoh struct evcnt sc_ev_txindintr; /* Tx Indicate interrupts */
541 1.6 msaitoh struct evcnt sc_ev_rxintr; /* Rx interrupts */
542 1.6 msaitoh
543 1.6 msaitoh struct evcnt sc_ev_txseg1; /* Tx packets w/ 1 segment */
544 1.6 msaitoh struct evcnt sc_ev_txseg2; /* Tx packets w/ 2 segments */
545 1.6 msaitoh struct evcnt sc_ev_txseg3; /* Tx packets w/ 3 segments */
546 1.6 msaitoh struct evcnt sc_ev_txseg4; /* Tx packets w/ 4 segments */
547 1.6 msaitoh struct evcnt sc_ev_txseg5; /* Tx packets w/ 5 segments */
548 1.6 msaitoh struct evcnt sc_ev_txsegmore; /* Tx packets w/ more than 5 segments */
549 1.6 msaitoh struct evcnt sc_ev_txcopy; /* Tx packets that we had to copy */
550 1.6 msaitoh
551 1.6 msaitoh struct evcnt sc_ev_rxipsum; /* IP checksums checked in-bound */
552 1.6 msaitoh struct evcnt sc_ev_rxtcpsum; /* TCP checksums checked in-bound */
553 1.6 msaitoh struct evcnt sc_ev_rxudpsum; /* UDP checksums checked in-bound */
554 1.6 msaitoh
555 1.6 msaitoh struct evcnt sc_ev_txipsum; /* IP checksums comp. out-bound */
556 1.6 msaitoh struct evcnt sc_ev_txtcpsum; /* TCP checksums comp. out-bound */
557 1.6 msaitoh struct evcnt sc_ev_txudpsum; /* UDP checksums comp. out-bound */
558 1.6 msaitoh #endif /* STGE_EVENT_COUNTERS */
559 1.6 msaitoh
560 1.6 msaitoh int sc_txpending; /* number of Tx requests pending */
561 1.6 msaitoh int sc_txdirty; /* first dirty Tx descriptor */
562 1.6 msaitoh int sc_txlast; /* last used Tx descriptor */
563 1.6 msaitoh
564 1.6 msaitoh int sc_rxptr; /* next ready Rx descriptor/descsoft */
565 1.6 msaitoh int sc_rxdiscard;
566 1.6 msaitoh int sc_rxlen;
567 1.6 msaitoh struct mbuf *sc_rxhead;
568 1.6 msaitoh struct mbuf *sc_rxtail;
569 1.6 msaitoh struct mbuf **sc_rxtailp;
570 1.6 msaitoh
571 1.6 msaitoh int sc_txthresh; /* Tx threshold */
572 1.6 msaitoh uint32_t sc_usefiber:1; /* if we're fiber */
573 1.6 msaitoh uint32_t sc_stge1023:1; /* are we a 1023 */
574 1.6 msaitoh uint32_t sc_DMACtrl; /* prototype DMACtrl register */
575 1.6 msaitoh uint32_t sc_MACCtrl; /* prototype MacCtrl register */
576 1.6 msaitoh uint16_t sc_IntEnable; /* prototype IntEnable register */
577 1.6 msaitoh uint16_t sc_ReceiveMode; /* prototype ReceiveMode register */
578 1.6 msaitoh uint8_t sc_PhyCtrl; /* prototype PhyCtrl register */
579 1.6 msaitoh };
580 1.6 msaitoh
581 1.1 thorpej #endif /* _DEV_PCI_IF_STGEREG_H_ */
582