1 | |
---|
2 | /* uti596.h: Contains the defines and structures used by the uti596 driver */ |
---|
3 | |
---|
4 | /* |
---|
5 | * EII: March 11: Created v. 0.0 |
---|
6 | * |
---|
7 | * $Id$ |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef UTI596_H |
---|
11 | #define UTI596_H |
---|
12 | #include <rtems/error.h> |
---|
13 | #include <rtems/rtems_bsdnet.h> |
---|
14 | |
---|
15 | #include <sys/param.h> |
---|
16 | #include <sys/mbuf.h> |
---|
17 | #include <sys/socket.h> |
---|
18 | #include <sys/sockio.h> |
---|
19 | |
---|
20 | #include <net/if.h> |
---|
21 | |
---|
22 | #include <netinet/in.h> |
---|
23 | #include <netinet/if_ether.h> |
---|
24 | |
---|
25 | /* Ethernet statistics */ |
---|
26 | |
---|
27 | struct enet_statistics{ |
---|
28 | int rx_packets; /* total packets received */ |
---|
29 | int tx_packets; /* total packets transmitted */ |
---|
30 | int rx_errors; /* bad packets received */ |
---|
31 | int tx_errors; /* packet transmit problems */ |
---|
32 | int rx_dropped; /* no space in buffers */ |
---|
33 | int tx_dropped; |
---|
34 | int tx_retries_exceeded; /* excessive retries */ |
---|
35 | int multicast; /* multicast packets received */ |
---|
36 | int collisions; |
---|
37 | |
---|
38 | /* detailed rx_errors: */ |
---|
39 | int rx_length_errors; |
---|
40 | int rx_over_errors; /* receiver ring buff overflow */ |
---|
41 | int rx_crc_errors; /* recved pkt with crc error */ |
---|
42 | int rx_frame_errors; /* recv'd frame alignment error */ |
---|
43 | int rx_fifo_errors; /* recv'r fifo overrun */ |
---|
44 | int rx_missed_errors; /* receiver missed packet */ |
---|
45 | |
---|
46 | /* detailed tx_errors */ |
---|
47 | int tx_aborted_errors; |
---|
48 | int tx_carrier_errors; |
---|
49 | int tx_fifo_errors; |
---|
50 | int tx_heartbeat_errors; |
---|
51 | int tx_window_errors; |
---|
52 | |
---|
53 | /* NIC reset errors */ |
---|
54 | int nic_reset_count; /* The number of times uti596reset() has been called. */ |
---|
55 | }; |
---|
56 | |
---|
57 | #define CMD_EOL 0x8000 /* The last command of the list, stop. */ |
---|
58 | #define CMD_SUSP 0x4000 /* Suspend after doing cmd. */ |
---|
59 | #define CMD_INTR 0x2000 /* Interrupt after doing cmd. */ |
---|
60 | |
---|
61 | #define CMD_FLEX 0x0008 /* Enable flexible memory model */ |
---|
62 | |
---|
63 | #define SCB_STAT_CX 0x8000 /* Cmd completes with 'I' bit set */ |
---|
64 | #define SCB_STAT_FR 0x4000 /* Frame Received */ |
---|
65 | #define SCB_STAT_CNA 0x2000 /* Cmd unit Not Active */ |
---|
66 | #define SCB_STAT_RNR 0x1000 /* Receiver Not Ready */ |
---|
67 | |
---|
68 | #define SCB_CUS_SUSPENDED 0x0100 |
---|
69 | #define SCB_CUS_ACTIVE 0x0200 |
---|
70 | |
---|
71 | #define STAT_C 0x8000 /* Set to 1 after execution */ |
---|
72 | #define STAT_B 0x4000 /* 1 : Cmd being executed, 0 : Cmd done. */ |
---|
73 | #define STAT_OK 0x2000 /* 1: Command executed ok 0 : Error */ |
---|
74 | #define STAT_A 0x1000 /* command has been aborted */ |
---|
75 | |
---|
76 | #define STAT_S11 0x0800 |
---|
77 | #define STAT_S10 0x0400 |
---|
78 | #define STAT_S9 0x0200 |
---|
79 | #define STAT_S8 0x0100 |
---|
80 | #define STAT_S7 0x0080 |
---|
81 | #define STAT_S6 0x0040 |
---|
82 | #define STAT_S5 0x0020 |
---|
83 | #define STAT_MAX_COLLS 0x000F |
---|
84 | |
---|
85 | #define RBD_STAT_P 0x4000 /* prefetch */ |
---|
86 | #define RBD_STAT_F 0x4000 /* used */ |
---|
87 | |
---|
88 | #define CUC_START 0x0100 |
---|
89 | #define CUC_RESUME 0x0200 |
---|
90 | #define CUC_SUSPEND 0x0300 |
---|
91 | #define CUC_ABORT 0x0400 |
---|
92 | #define RX_START 0x0010 |
---|
93 | #define RX_RESUME 0x0020 |
---|
94 | #define RX_SUSPEND 0x0030 |
---|
95 | #define RX_ABORT 0x0040 |
---|
96 | |
---|
97 | #define RU_SUSPENDED 0x0010 |
---|
98 | #define RU_NO_RESOURCES 0x0020 |
---|
99 | #define RU_READY 0x0040 |
---|
100 | |
---|
101 | #define I596_NULL ( ( void * ) 0xffffffff) |
---|
102 | #define UTI_596_END_OF_FRAME 0x8000 |
---|
103 | |
---|
104 | |
---|
105 | struct i596_tbd; /* necessary forward declaration */ |
---|
106 | |
---|
107 | enum commands { |
---|
108 | CmdNOp = 0, |
---|
109 | CmdSASetup = 1, |
---|
110 | CmdConfigure = 2, |
---|
111 | CmdMulticastList = 3, |
---|
112 | CmdTx = 4, |
---|
113 | CmdTDR = 5, |
---|
114 | CmdDump = 6, |
---|
115 | CmdDiagnose = 7 |
---|
116 | }; |
---|
117 | |
---|
118 | /* |
---|
119 | * 82596 Dump Command Result |
---|
120 | */ |
---|
121 | typedef volatile struct i596_dump_result { |
---|
122 | unsigned char bf; |
---|
123 | unsigned char config_bytes[11]; |
---|
124 | unsigned char reserved1[2]; |
---|
125 | unsigned char ia_bytes[6]; |
---|
126 | unsigned short last_tx_status; |
---|
127 | unsigned short tx_crc_byte01; |
---|
128 | unsigned short tx_crc_byte23; |
---|
129 | unsigned short rx_crc_byte01; |
---|
130 | unsigned short rx_crc_byte23; |
---|
131 | unsigned short rx_temp_mem01; |
---|
132 | unsigned short rx_temp_mem23; |
---|
133 | unsigned short rx_temp_mem45; |
---|
134 | unsigned short last_rx_status; |
---|
135 | unsigned short hash_reg01; |
---|
136 | unsigned short hash_reg23; |
---|
137 | unsigned short hash_reg45; |
---|
138 | unsigned short hash_reg67; |
---|
139 | unsigned short slot_time_counter; |
---|
140 | unsigned short wait_time_counter; |
---|
141 | unsigned short rx_frame_length; |
---|
142 | unsigned long reserved2; |
---|
143 | unsigned long cb_in3; |
---|
144 | unsigned long cb_in2; |
---|
145 | unsigned long cb_in1; |
---|
146 | unsigned long la_cb_addr; |
---|
147 | unsigned long rdb_pointer; |
---|
148 | unsigned long int_memory; |
---|
149 | unsigned long rfd_size; |
---|
150 | unsigned long tbd_pointer; |
---|
151 | unsigned long base_addr; |
---|
152 | unsigned long ru_temp_reg; |
---|
153 | unsigned long tcb_count; |
---|
154 | unsigned long next_rb_size; |
---|
155 | unsigned long next_rb_addr; |
---|
156 | unsigned long curr_rb_size; |
---|
157 | unsigned long la_rbd_addr; |
---|
158 | unsigned long next_rbd_addr; |
---|
159 | unsigned long curr_rbd_addr; |
---|
160 | unsigned long curr_rb_count; |
---|
161 | unsigned long next_fd_addr; |
---|
162 | unsigned long curr_fd_add; |
---|
163 | unsigned long temp_cu_reg; |
---|
164 | unsigned long next_tb_count; |
---|
165 | unsigned long buffer_addr; |
---|
166 | unsigned long la_tbd_addr; |
---|
167 | unsigned long next_tbd_addr; |
---|
168 | unsigned long cb_command; |
---|
169 | unsigned long next_cb_addr; |
---|
170 | unsigned long curr_cb_addr; |
---|
171 | unsigned long scb_cmd_word; |
---|
172 | unsigned long scb_pointer; |
---|
173 | unsigned long cb_stat_word; |
---|
174 | unsigned long mm_lfsr; |
---|
175 | unsigned char micro_machine_bit_array[28]; |
---|
176 | unsigned char cu_port[16]; |
---|
177 | unsigned long mm_alu; |
---|
178 | unsigned long reserved3; |
---|
179 | unsigned long mm_temp_a_rr; |
---|
180 | unsigned long mm_temp_a; |
---|
181 | unsigned long tx_dma_b_cnt; |
---|
182 | unsigned long mm_input_port_addr_reg; |
---|
183 | unsigned long tx_dma_addr; |
---|
184 | unsigned long mm_port_reg1; |
---|
185 | unsigned long rx_dma_b_cnt; |
---|
186 | unsigned long mm_port_reg2; |
---|
187 | unsigned long rx_dma_addr; |
---|
188 | unsigned long reserved4; |
---|
189 | unsigned long bus_t_timers; |
---|
190 | unsigned long diu_cntrl_reg; |
---|
191 | unsigned long reserved5; |
---|
192 | unsigned long sysbus; |
---|
193 | unsigned long biu_cntrl_reg; |
---|
194 | unsigned long mm_disp_reg; |
---|
195 | unsigned long mm_status_reg; |
---|
196 | unsigned short dump_status; |
---|
197 | } i596_dump_result; |
---|
198 | |
---|
199 | typedef volatile struct i596_selftest { |
---|
200 | unsigned long rom_signature; |
---|
201 | unsigned long results; |
---|
202 | } i596_selftest; |
---|
203 | |
---|
204 | /* |
---|
205 | * Action commands |
---|
206 | * (big endian, linear mode) |
---|
207 | */ |
---|
208 | typedef volatile struct i596_cmd { |
---|
209 | unsigned short status; |
---|
210 | unsigned short command; |
---|
211 | volatile struct i596_cmd *next; |
---|
212 | } i596_cmd; |
---|
213 | |
---|
214 | typedef volatile struct i596_nop { |
---|
215 | i596_cmd cmd; |
---|
216 | } i596_nop; |
---|
217 | |
---|
218 | typedef volatile struct i596_set_add { |
---|
219 | i596_cmd cmd; |
---|
220 | char data[8]; |
---|
221 | } i596_set_add; |
---|
222 | |
---|
223 | typedef volatile struct i596_configure { |
---|
224 | i596_cmd cmd; |
---|
225 | char data[16]; |
---|
226 | } i596_configure; |
---|
227 | |
---|
228 | typedef volatile struct i596_tx { |
---|
229 | i596_cmd cmd; |
---|
230 | volatile struct i596_tbd *pTbd; |
---|
231 | unsigned short count; |
---|
232 | unsigned short pad; |
---|
233 | char data[6]; |
---|
234 | unsigned short length; |
---|
235 | } i596_tx; |
---|
236 | |
---|
237 | typedef volatile struct i596_tdr { |
---|
238 | i596_cmd cmd; |
---|
239 | unsigned long data; |
---|
240 | } i596_tdr; |
---|
241 | |
---|
242 | typedef volatile struct i596_dump { |
---|
243 | i596_cmd cmd; |
---|
244 | char *pData; |
---|
245 | } i596_dump; |
---|
246 | |
---|
247 | /* |
---|
248 | * Transmit buffer descriptor |
---|
249 | */ |
---|
250 | typedef volatile struct i596_tbd { |
---|
251 | unsigned short size; |
---|
252 | unsigned short pad; |
---|
253 | volatile struct i596_tbd *next; |
---|
254 | char *data; |
---|
255 | } i596_tbd; |
---|
256 | |
---|
257 | /* |
---|
258 | * Receive buffer descriptor |
---|
259 | * (flexible memory structure) |
---|
260 | */ |
---|
261 | typedef volatile struct i596_rbd { |
---|
262 | unsigned short count; |
---|
263 | unsigned short offset; |
---|
264 | volatile struct i596_rbd *next; |
---|
265 | char *data; |
---|
266 | unsigned short size; |
---|
267 | unsigned short pad; |
---|
268 | } i596_rbd; |
---|
269 | |
---|
270 | /* |
---|
271 | * Receive Frame Descriptor |
---|
272 | */ |
---|
273 | typedef volatile struct i596_rfd { |
---|
274 | unsigned short stat; |
---|
275 | unsigned short cmd; |
---|
276 | volatile struct i596_rfd *next; |
---|
277 | i596_rbd *pRbd; |
---|
278 | unsigned short count; |
---|
279 | unsigned short size; |
---|
280 | char data [1532]; |
---|
281 | } i596_rfd; |
---|
282 | |
---|
283 | /* |
---|
284 | * System Control Block |
---|
285 | */ |
---|
286 | typedef volatile struct i596_scb { |
---|
287 | unsigned short status; |
---|
288 | unsigned short command; |
---|
289 | unsigned long cmd_pointer; |
---|
290 | unsigned long rfd_pointer; |
---|
291 | unsigned long crc_err; |
---|
292 | unsigned long align_err; |
---|
293 | unsigned long resource_err; |
---|
294 | unsigned long over_err; |
---|
295 | unsigned long rcvdt_err; |
---|
296 | unsigned long short_err; |
---|
297 | unsigned short t_off; |
---|
298 | unsigned short t_on; |
---|
299 | i596_cmd *pCmd; |
---|
300 | i596_rfd *pRfd; |
---|
301 | } i596_scb; |
---|
302 | |
---|
303 | /* |
---|
304 | * Intermediate System Configuration Pointer |
---|
305 | */ |
---|
306 | typedef volatile struct i596_iscp { |
---|
307 | uint8_t null1; /* Always zero */ |
---|
308 | uint8_t busy; /* Busy byte */ |
---|
309 | unsigned short scb_offset; /* Not used in linear mode */ |
---|
310 | unsigned long scb_pointer; /* Swapped pointer to scb */ |
---|
311 | i596_scb *scb; /* Real pointer to scb */ |
---|
312 | } i596_iscp; |
---|
313 | |
---|
314 | /* |
---|
315 | * System Configuration Pointer |
---|
316 | */ |
---|
317 | typedef volatile struct i596_scp { |
---|
318 | unsigned long sysbus; /* Only low 8 bits are used */ |
---|
319 | unsigned long pad; /* Must be zero */ |
---|
320 | unsigned long iscp_pointer; /* Swapped pointer to iscp */ |
---|
321 | i596_iscp *iscp; /* Real pointer to iscp */ |
---|
322 | } i596_scp; |
---|
323 | |
---|
324 | /* |
---|
325 | * Device Dependent Data Structure |
---|
326 | */ |
---|
327 | typedef volatile struct uti596_softc { |
---|
328 | struct arpcom arpcom; |
---|
329 | i596_scp *pScp; /* Block aligned on 16 byte boundary */ |
---|
330 | i596_scp *base_scp; /* Unaligned block. Need for free() */ |
---|
331 | i596_iscp iscp; |
---|
332 | i596_scb scb; |
---|
333 | i596_set_add set_add; |
---|
334 | i596_configure set_conf; |
---|
335 | i596_tdr tdr; |
---|
336 | i596_nop nop; |
---|
337 | i596_tx *pTxCmd; |
---|
338 | i596_tbd *pTbd; |
---|
339 | |
---|
340 | i596_rfd *pBeginRFA; |
---|
341 | i596_rfd *pEndRFA; |
---|
342 | i596_rfd *pLastUnkRFD; |
---|
343 | i596_rbd *pLastUnkRBD; |
---|
344 | i596_rfd *pEndSavedQueue; |
---|
345 | i596_cmd *pCmdHead; |
---|
346 | i596_cmd *pCmdTail; /* unneeded, as chaining not used, but implemented */ |
---|
347 | |
---|
348 | rtems_id rxDaemonTid; |
---|
349 | rtems_id txDaemonTid; |
---|
350 | rtems_id resetDaemonTid; |
---|
351 | |
---|
352 | struct enet_statistics stats; |
---|
353 | int started; |
---|
354 | unsigned long rxInterrupts; |
---|
355 | unsigned long txInterrupts; |
---|
356 | volatile int cmdOk; |
---|
357 | unsigned short * pCurrent_command_status; |
---|
358 | int resetDone; |
---|
359 | unsigned long txRawWait; |
---|
360 | i596_rfd *pInboundFrameQueue; |
---|
361 | short int rxBdCount; |
---|
362 | short int txBdCount; |
---|
363 | short int countRFD; |
---|
364 | short int savedCount; |
---|
365 | i596_rfd *pSavedRfdQueue; |
---|
366 | rtems_name semaphore_name; |
---|
367 | rtems_id semaphore_id; |
---|
368 | char zeroes[64]; |
---|
369 | unsigned long rawsndcnt; |
---|
370 | int nic_reset; /* flag for requesting that ISR issue a reset quest */ |
---|
371 | } uti596_softc_; |
---|
372 | |
---|
373 | #endif /* UTI596_H */ |
---|