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