]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/network/drvIntel82557/i82557HW.h
xnu-123.5.tar.gz
[apple/xnu.git] / iokit / Drivers / network / drvIntel82557 / i82557HW.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
24 *
25 * i82557HW.h - Intel 82557/82558 chip-related definitions
26 *
27 * HISTORY
28 * Jan 22, 1996 Dieter Siegmund at NeXT (dieter@next.com)
29 * Created.
30 */
31
32 #ifndef _I82557HW_H
33 #define _I82557HW_H
34
35 #include <net/etherdefs.h>
36
37 //-------------------------------------------------------------------------
38 // Misc definitions.
39 //-------------------------------------------------------------------------
40
41 #define DWORD_ALIGNMENT 4
42 #define WORD_ALIGNMENT 2
43 #define PARAGRAPH_ALIGNMENT 16
44 #define CACHE_ALIGNMENT 32
45
46 #define C_NULL (~0)
47
48 #define PCI_CFID_INTEL82557 0x12298086
49
50 typedef enum {
51 MEDIUM_TYPE_10_HD = 0,
52 MEDIUM_TYPE_10_FD,
53 MEDIUM_TYPE_TX_HD,
54 MEDIUM_TYPE_TX_FD,
55 MEDIUM_TYPE_T4,
56 MEDIUM_TYPE_AUTO,
57 MEDIUM_TYPE_INVALID,
58 } mediumType_t;
59
60 //-------------------------------------------------------------------------
61 // SCB status word.
62 // Offset 0, 16-bit, RW.
63 //-------------------------------------------------------------------------
64 typedef UInt16 scb_status_t;
65 #define SCB_STATUS_CX BIT(15) // command block with 'I' bit set.
66 #define SCB_STATUS_FR BIT(14) // RU finished receiving a frame.
67 #define SCB_STATUS_CNA BIT(13) // CU active to suspended/idle.
68 #define SCB_STATUS_RNR BIT(12) // RU no longer in ready state.
69 #define SCB_STATUS_MDI BIT(11) // MDI read/write cycle is done.
70 #define SCB_STATUS_SWI BIT(10) // software interrupt.
71 #define SCB_STATUS_ER BIT(9) // early receive interrupt.
72 #define SCB_STATUS_FCP BIT(8) // flow control pause interrupt.
73 #define SCB_STATUS_INT_MASK 0xff00 // mask for all interrupt bits.
74
75 #define SCB_STATUS_CUS_SHIFT 6
76 #define SCB_STATUS_CUS_MASK CSR_MASK(SCB_STATUS_CUS, 0x3)
77 #define SCB_CUS_IDLE 0
78 #define SCB_CUS_SUSPEND 1
79 #define SCB_CUS_ACTIVE 2
80
81 #define SCB_STATUS_RUS_SHIFT 2
82 #define SCB_STATUS_RUS_MASK CSR_MASK(SCB_STATUS_RUS, 0xf)
83 #define SCB_RUS_IDLE 0
84 #define SCB_RUS_SUSPEND 1
85 #define SCB_RUS_NO_RESOURCES 2
86 #define SCB_RUS_READY 4
87 #define SCB_RUS_SUSPEND_NO_RBDS 9
88 #define SCB_RUS_NO_RBDS 10
89 #define SCB_RUS_READY_NO_RBDS 12
90
91 //-------------------------------------------------------------------------
92 // SCB interrupt control byte.
93 // Offset 3, 8-bit, RW.
94 //-------------------------------------------------------------------------
95 typedef UInt8 scb_interrupt_t;
96 #define SCB_INTERRUPT_CX BIT(7) // interrupt masks
97 #define SCB_INTERRUPT_FR BIT(6)
98 #define SCB_INTERRUPT_CNA BIT(5)
99 #define SCB_INTERRUPT_RNR BIT(4)
100 #define SCB_INTERRUPT_ER BIT(3)
101 #define SCB_INTERRUPT_FCP BIT(2)
102 #define SCB_INTERRUPT_SI BIT(1)
103 #define SCB_INTERRUPT_M BIT(0)
104
105 //-------------------------------------------------------------------------
106 // SCB command byte.
107 // Offset 2, 8-bit, RW.
108 //-------------------------------------------------------------------------
109 typedef UInt8 scb_command_t;
110 #define SCB_COMMAND_CUC_SHIFT 4
111 #define SCB_COMMAND_CUC_MASK CSR_MASK(SCB_COMMAND_CUC, 0xf)
112 #define SCB_CUC_NOP 0
113 #define SCB_CUC_START 1
114 #define SCB_CUC_RESUME 2
115 #define SCB_CUC_LOAD_DUMP_ADDR 4
116 #define SCB_CUC_DUMP_STAT 5
117 #define SCB_CUC_LOAD_BASE 6
118 #define SCB_CUC_DUMP_RESET_STAT 7
119 #define SCB_CUC_STATIC_RESUME 10
120
121 #define SCB_COMMAND_RUC_SHIFT 0
122 #define SCB_COMMAND_RUC_MASK CSR_MASK(SCB_COMMAND_RUC, 0x7)
123 #define SCB_RUC_NOP 0
124 #define SCB_RUC_START 1
125 #define SCB_RUC_RESUME 2
126 #define SCB_RUC_DMA_REDIRECT 3
127 #define SCB_RUC_ABORT 4
128 #define SCB_RUC_LOAD_HDS 5
129 #define SCB_RUC_LOAD_BASE 6
130 #define SCB_RUC_RBD_RESUME 7
131
132 //-------------------------------------------------------------------------
133 // MDI control register.
134 // Offset 0x10, 32-bit, RW.
135 //-------------------------------------------------------------------------
136 typedef UInt32 mdi_control_t;
137 #define MDI_CONTROL_INT_ENABLE BIT(29) // interrupt enable.
138 #define MDI_CONTROL_READY BIT(28) // ready bit.
139 #define MDI_CONTROL_OPCODE_SHIFT 26
140 #define MDI_CONTROL_OPCODE_MASK CSR_MASK(MDI_CONTROL_OPCODE, 0x3)
141 #define MDI_CONTROL_OP_WRITE 1
142 #define MDI_CONTROL_OP_READ 2
143 #define MDI_CONTROL_PHYADDR_SHIFT 21
144 #define MDI_CONTROL_PHYADDR_MASK CSR_MASK(MDI_CONTROL_PHYADDR, 0x1f)
145 #define MDI_CONTROL_REGADDR_SHIFT 16
146 #define MDI_CONTROL_REGADDR_MASK CSR_MASK(MDI_CONTROL_REGADDR, 0x1f)
147 #define MDI_CONTROL_DATA_SHIFT 0
148 #define MDI_CONTROL_DATA_MASK CSR_MASK(MDI_CONTROL_DATA, 0xffff)
149
150 //-------------------------------------------------------------------------
151 // EEPROM control register.
152 // Offset 0xE, 16-bit, RW.
153 //-------------------------------------------------------------------------
154 typedef UInt16 eeprom_control_t;
155 #define EEPROM_CONTROL_EEDO BIT(3)
156 #define EEPROM_CONTROL_EEDI BIT(2)
157 #define EEPROM_CONTROL_EECS BIT(1)
158 #define EEPROM_CONTROL_EESK BIT(0)
159
160 //-------------------------------------------------------------------------
161 // Flow control threshold register.
162 // Offset 0x19, 8-bit, RW.
163 //-------------------------------------------------------------------------
164 #define FC_THRESHOLD_SHIFT 0
165 #define FC_THRESHOLD_MASK CSR_MASK(FC_THRESHOLD, 0x7)
166 #define FC_THRESHOLD_512 0
167 #define FC_THRESHOLD_1024 1
168 #define FC_THRESHOLD_1280 2
169 #define FC_THRESHOLD_1536 3
170
171 //-------------------------------------------------------------------------
172 // Flow control command register.
173 // Offset 0x20, 8-bit, RW.
174 //-------------------------------------------------------------------------
175 #define FC_XON BIT(0)
176 #define FC_XOFF BIT(1)
177 #define FC_FULL BIT(2)
178 #define FC_PAUSED BIT(3)
179 #define FC_PAUSED_LOW BIT(4)
180
181 //-------------------------------------------------------------------------
182 // Generic command block definition.
183 //-------------------------------------------------------------------------
184 #define CB_NOP 0
185 #define CB_IA_ADDRESS 1
186 #define CB_CONFIGURE 2
187 #define CB_MULTICAST 3
188 #define CB_TRANSMIT 4
189 #define CB_LOAD_MICROCODE 5
190 #define CB_DUMP 6
191 #define CB_DIAGNOSE 7
192
193 typedef UInt16 cb_status_t;
194 #define CB_STATUS_C BIT(15) // command complete.
195 #define CB_STATUS_OK BIT(13) // DMA OK.
196
197 typedef UInt16 cb_command_t;
198 #define CB_EL BIT(15) // end of list.
199 #define CB_S BIT(14) // suspend bit.
200 #define CB_I BIT(13) // interrupt bit.
201 #define CB_CMD_SHIFT 0
202 #define CB_CMD_MASK CSR_MASK(CB_CMD, 0x7)
203
204 #define CB_CMD_NOP 0x0
205 #define CB_CMD_IASETUP 0x1
206 #define CB_CMD_CONFIGURE 0x2
207 #define CB_CMD_MCSETUP 0x3
208 #define CB_CMD_TRANSMIT 0x4
209
210 static __inline__ char *
211 CUCommandString(int cmd)
212 {
213 char * s[] = {
214 "nop",
215 "iasetup",
216 "configure",
217 "mcsetup",
218 "transmit"
219 };
220 return (s[cmd]);
221 }
222
223 typedef struct {
224 volatile cb_status_t status;
225 volatile cb_command_t command;
226 IOPhysicalAddress link;
227 } cbHeader_t;
228
229 //-------------------------------------------------------------------------
230 // Configure command.
231 //-------------------------------------------------------------------------
232 #define CB_CONFIG_BYTE_COUNT 22
233
234 #define CB_CB0_BYTE_COUNT_SHIFT 0
235 #define CB_CB0_BYTE_COUNT_MASK CSR_MASK(CB_CB0_BYTE_COUNT, 0x3f)
236
237 #define CB_CB1_TX_FIFO_LIMIT_SHIFT 4
238 #define CB_CB1_TX_FIFO_LIMIT_MASK CSR_MASK(CB_CB1_TX_FIFO_LIMIT, 0xf)
239 #define CB_CB1_RX_FIFO_LIMIT_SHIFT 0
240 #define CB_CB1_RX_FIFO_LIMIT_MASK CSR_MASK(CB_CB1_RX_FIFO_LIMIT, 0xf)
241 #define CB_CB1_TX_FIFO_0 8 // 0 bytes
242 #define CB_CB1_RX_FIFO_64 8 // 64 bytes
243
244 #define CB_CB2_ADAPTIVE_IFS_SHIFT 0
245 #define CB_CB2_ADAPTIVE_IFS_MASK CSR_MASK(CB_CB2_ADAPTIVE_IFS, 0xff)
246
247 #define CB_CB3_TERM_ON_CL BIT(3)
248 #define CB_CB3_READ_AL_ENABLE BIT(2)
249 #define CB_CB3_TYPE_ENABLE BIT(1)
250 #define CB_CB3_MWI_ENABLE BIT(0)
251
252 #define CB_CB4_RX_MIN_SHIFT 0
253 #define CB_CB4_RX_MIN_MASK CSR_MASK(CB_CB4_RX_MIN, 0x7f)
254
255 #define CB_CB5_DMBC_EN BIT(7)
256 #define CB_CB5_TX_MAX_SHIFT 0
257 #define CB_CB5_TX_MAX_MASK CSR_MASK(CB_CB4_TX_MAX, 0x7f)
258
259 #define CB_CB6_SAVE_BF BIT(7)
260 #define CB_CB6_DISC_OVER BIT(6)
261 #define CB_CB6_STD_STATS BIT(5)
262 #define CB_CB6_STD_TCB BIT(4)
263 #define CB_CB6_CI_INT BIT(3)
264 #define CB_CB6_TNO_INT BIT(2)
265 #define CB_CB6_NON_DIRECT_DMA BIT(1)
266 #define CB_CB6_LATE_SCB BIT(0)
267
268 #define CB_CB7_DYNAMIC_TBD BIT(7)
269 #define CB_CB7_UNDERRUN_RETRY_SHIFT 1
270 #define CB_CB7_UNDERRUN_RETRY_MASK CSR_MASK(CB_CB7_UNDERRUN_RETRY, 0x3)
271 #define CB_CB7_UNDERRUN_RETRY_1 1
272 #define CB_CB7_UNDERRUN_RETRY_2 2
273 #define CB_CB7_UNDERRUN_RETRY_3 3
274 #define CB_CB7_DISC_SHORT_FRAMES BIT(0)
275
276 #define CB_CB8_CSMA_EN BIT(0)
277
278 #define CB_CB10_LOOPBACK_SHIFT 6
279 #define CB_CB10_LOOPBACK_MASK CSR_MASK(CB_CB10_LOOPBACK, 0x3)
280 #define CB_CB10_PREAMBLE_SHIFT 4
281 #define CB_CB10_PREAMBLE_MASK CSR_MASK(CB_CB10_PREAMBLE, 0x3)
282 #define CB_CB10_PREAMBLE_1_BYTE 0
283 #define CB_CB10_PREAMBLE_3_BYTES 1
284 #define CB_CB10_PREAMBLE_7_BYTES 2
285 #define CB_CB10_PREAMBLE_15_BYTES 3
286 #define CB_CB10_NSAI BIT(3)
287
288 #define CB_CB11_LIN_PRIORITY_SHIFT 0
289 #define CB_CB11_LIN_PRIORITY_MASK CSR_MASK(CB_CB11_PRIORITY, 0x7)
290
291 #define CB_CB12_IFS_SHIFT 4
292 #define CB_CB12_IFS_MASK CSR_MASK(CB_CB12_IFS, 0xf)
293 #define CB_CB12_IFS_96_BIT_TIMES 0x6
294 #define CB_CB12_LIN_PRIORITY BIT(0)
295
296 #define CB_CB13_FC_TYPE_LSB_SHIFT 0
297 #define CB_CB13_FC_TYPE_LSB_MASK CSR_MASK(CB_CB13_FC_TYPE_LSB, 0xff)
298 #define CB_CB13_FC_TYPE_LSB_DEF 0 // 82558 compatible
299
300 #define CB_CB14_FC_TYPE_MSB_SHIFT 0
301 #define CB_CB14_FC_TYPE_MSB_MASK CSR_MASK(CB_CB14_FC_TYPE_MSB, 0xff)
302 #define CB_CB14_FC_TYPE_MSB_DEF 0xf2 // 82558 compatible
303
304 #define CB_CB15_CRS_CDT BIT(7)
305 #define CB_CB15_BROADCAST_DISABLE BIT(1)
306 #define CB_CB15_PROMISCUOUS BIT(0)
307
308 #define CB_CB16_FC_DELAY_LSB_SHIFT 0
309 #define CB_CB16_FC_DELAY_LSB_MASK CSR_MASK(CB_CB16_FC_DELAY_LSB, 0xff)
310 #define CB_CB16_FC_DELAY_LSB_DEF 0
311
312 #define CB_CB17_FC_DELAY_MSB_SHIFT 0
313 #define CB_CB17_FC_DELAY_MSB_MASK CSR_MASK(CB_CB17_FC_DELAY_MSB, 0xff)
314 #define CB_CB17_FC_DELAY_MSB_DEF 0x40
315
316 #define CB_CB18_LONG_RX_OK BIT(3)
317 #define CB_CB18_CRC_XFER BIT(2)
318 #define CB_CB18_PADDING BIT(1)
319 #define CB_CB18_STRIPPING BIT(0)
320
321 #define CB_CB19_AUTO_FDX BIT(7)
322 #define CB_CB19_FORCE_FDX BIT(6)
323 #define CB_CB19_REJECT_FC BIT(5)
324 #define CB_CB19_RX_FC_RESTART BIT(4)
325 #define CB_CB19_RX_FC_RESTOP BIT(3)
326 #define CB_CB19_TX_FC BIT(2)
327 #define CB_CB19_MAGIC_PKT_WAKEUP BIT(1)
328 #define CB_CB19_ADDRESS_WAKEUP BIT(0)
329
330 #define CB_CB20_MULTI_IA BIT(6)
331 #define CB_CB20_FC_ADDR_LSB_SHIFT 0
332 #define CB_CB20_FC_ADDR_LSB_MASK CSR_MASK(CB_CB20_FC_ADDR_LSB, 0x1f)
333 #define CB_CB20_FC_ADDR_LSB_DEF 0x0f
334
335 #define CB_CB21_MULTICAST_ALL BIT(3)
336
337 typedef struct cb_configure {
338 cbHeader_t header;
339 UInt8 byte[24];
340 } cb_configure_t;
341
342 //-------------------------------------------------------------------------
343 // MC-Setup command.
344 //-------------------------------------------------------------------------
345 typedef struct cb_mcsetup {
346 cbHeader_t header;
347 UInt16 count;
348 IOEthernetAddress addrs[0];
349 } cb_mcsetup_t;
350
351 //-------------------------------------------------------------------------
352 // IA-Setup command.
353 //-------------------------------------------------------------------------
354 typedef struct cb_iasetup {
355 cbHeader_t header;
356 IOEthernetAddress addr;
357 } cb_iasetup_t;
358
359 //-------------------------------------------------------------------------
360 // Port Commands.
361 // Enumerated port command values.
362 //-------------------------------------------------------------------------
363 typedef enum {
364 portReset_e = 0,
365 portSelfTest_e = 1,
366 portSelectiveReset_e = 2,
367 portDump_e = 3,
368 } port_command_t;
369
370 #define PORT_ADDRESS_SHIFT 4
371 #define PORT_ADDRESS_MASK CSR_MASK(PORT_FUNCTION, 0xfffffff)
372
373 #define PORT_FUNCTION_SHIFT 0
374 #define PORT_FUNCTION_MASK CSR_MASK(PORT_FUNCTION, 0xf)
375
376 //-------------------------------------------------------------------------
377 // Port Self-Test
378 // Definition for self test area.
379 //-------------------------------------------------------------------------
380 #define PORT_SELFTEST_GENERAL BIT(12)
381 #define PORT_SELFTEST_DIAGNOSE BIT(5)
382 #define PORT_SELFTEST_REGISTER BIT(3)
383 #define PORT_SELFTEST_ROM BIT(2)
384
385 typedef struct port_selftest_t {
386 UInt32 signature;
387 UInt32 results;
388 } port_selftest_t;
389
390 /*
391 * Typedef: CSR_t
392 *
393 * Purpose: Control Status Registers block
394 * Communication to the chip occurs via this set of
395 * memory-mapped (also io-mapped, which we don't use)
396 * registers.
397 */
398 typedef struct csr {
399 volatile scb_status_t status;
400 volatile scb_command_t command;
401 volatile scb_interrupt_t interrupt;
402 volatile IOPhysicalAddress pointer;
403 volatile UInt32 port;
404 volatile UInt16 flashControl;
405 volatile eeprom_control_t eepromControl;
406 volatile mdi_control_t mdiControl;
407 volatile UInt32 rxDMAByteCount;
408 volatile UInt8 earlyRxInterrupt;
409 volatile UInt8 flowControlThreshold;
410 volatile UInt8 flowControlCommand;
411 volatile UInt8 powerManagement;
412 } CSR_t;
413
414 //-------------------------------------------------------------------------
415 // Structure containing error counters retrieved via:
416 // Dump Statistics Counters command, or
417 // Dump and Reset Statistics Counters command.
418 //
419 // NOTE: 82558 can return an extended set of statistics counters.
420 //-------------------------------------------------------------------------
421 typedef struct {
422 UInt32 tx_good_frames;
423 UInt32 tx_maxcol_errors;
424 UInt32 tx_late_collision_errors;
425 UInt32 tx_underrun_errors;
426 UInt32 tx_lost_carrier_sense_errors;
427 UInt32 tx_deferred;
428 UInt32 tx_single_collisions;
429 UInt32 tx_multiple_collisions;
430 UInt32 tx_total_collisions;
431 UInt32 rx_good_frames;
432 UInt32 rx_crc_errors;
433 UInt32 rx_alignment_errors;
434 UInt32 rx_resource_errors;
435 UInt32 rx_overrun_errors;
436 UInt32 rx_collision_detect_errors;
437 UInt32 rx_short_frame_errors;
438 UInt32 _status;
439 #define DUMP_STATUS 0x0
440 #define DUMP_COMPLETE 0xa005
441 #define DUMP_AND_RESET_COMPLETE 0xa007
442 } errorCounters_t;
443
444 //-------------------------------------------------------------------------
445 // RBD count dword.
446 // Offset 0, 32-bit, RW.
447 //-------------------------------------------------------------------------
448 typedef UInt32 rbd_count_t;
449 #define RBD_COUNT_EOF BIT(15) // end-of-frame bit.
450 #define RBD_COUNT_F BIT(14) // buffer fetch bit.
451 #define RBD_COUNT_SHIFT 0
452 #define RBD_COUNT_MASK CSR_MASK(RBD_COUNT, 0x3fff)
453
454 //-------------------------------------------------------------------------
455 // RBD size dword.
456 // Offset 0xC, 32-bit, RW.
457 //-------------------------------------------------------------------------
458 typedef UInt32 rbd_size_t;
459 #define RBD_SIZE_EL BIT(15) // EL bit.
460 #define RBD_SIZE_SHIFT 0
461 #define RBD_SIZE_MASK CSR_MASK(RBD_SIZE, 0x3fff)
462
463 //-------------------------------------------------------------------------
464 // RBD - receive buffer descriptor definition.
465 //-------------------------------------------------------------------------
466 typedef struct rbd {
467 volatile rbd_count_t count;
468 volatile IOPhysicalAddress link;
469 volatile IOPhysicalAddress buffer;
470 volatile rbd_size_t size;
471
472 /* driver private */
473
474 struct rbd * _next;
475 IOPhysicalAddress _paddr;
476 struct mbuf * _mbuf;
477 UInt32 _pad;
478 } rbd_t;
479
480 //-------------------------------------------------------------------------
481 // RFD status word.
482 // Offset 0, 16-bit, RW.
483 //-------------------------------------------------------------------------
484 typedef UInt16 rfd_status_t;
485 #define RFD_STATUS_C BIT(15) // complete bit.
486 #define RFD_STATUS_OK BIT(13) // OK bit.
487 #define RFD_STATUS_CRC_ERROR BIT(11) // CRC error bit.
488 #define RFD_STATUS_ALIGNMENT_ERROR BIT(10) // alignment error.
489 #define RFD_STATUS_NO_RESOURCES BIT(9) // no buffer space.
490 #define RFD_STATUS_DMA_OVERRUN BIT(8) // receive DMA overrun.
491 #define RFD_STATUS_FRAME_TOO_SHORT BIT(7) // frame too short.
492 #define RFD_STATUS_TYPE_FRAME BIT(5) // type/length bit.
493 #define RFD_STATUS_RX_ERROR BIT(4) // RX_ERR pin on PHY was set.
494 #define RFD_STATUS_NO_ADDR_MATCH BIT(2) // no address match.
495 #define RFD_STATUS_IA_MATCH BIT(1) // IA address match.
496 #define RFD_STATUS_COLLISION BIT(0) // receive collision.
497
498 //-------------------------------------------------------------------------
499 // RFD command word.
500 // Offset 2, 16-bit, RW.
501 //-------------------------------------------------------------------------
502 typedef UInt16 rfd_command_t;
503 #define RFD_COMMAND_EL BIT(15) // EL bit.
504 #define RFD_COMMAND_S BIT(14) // suspend bit.
505 #define RFD_COMMAND_H BIT(4) // header RFD bit.
506 #define RFD_COMMAND_SF BIT(3) // flexible mode bit.
507
508 //-------------------------------------------------------------------------
509 // RFD misc dword.
510 // Offset 0xC, 32-bit, RW.
511 //-------------------------------------------------------------------------
512 typedef UInt32 rfd_misc_t;
513 #define RFD_MISC_EOF BIT(15) // end-of-frame bit.
514 #define RFD_MISC_F BIT(14) // buffer fetch bit.
515 #define RFD_MISC_ACT_COUNT_SHIFT 0
516 #define RFD_MISC_ACT_COUNT_MASK CSR_MASK(RFD_MISC_ACT_COUNT, 0x3fff)
517 #define RFD_MISC_SIZE_SHIFT 16
518 #define RFD_MISC_SIZE_MASK CSR_MASK(RFD_MISC_SIZE, 0x3fff)
519
520 //-------------------------------------------------------------------------
521 // RFD - receive frame descriptor definition.
522 //-------------------------------------------------------------------------
523 typedef struct rfd {
524 volatile rfd_status_t status;
525 volatile rfd_command_t command;
526 volatile IOPhysicalAddress link;
527 volatile IOPhysicalAddress rbdAddr;
528 volatile rfd_misc_t misc; // 16 bytes
529
530 UInt32 _pad[2]; // pad it to 64 bytes
531
532 /* driver private */
533
534 struct rfd * _next;
535 IOPhysicalAddress _paddr;
536 rbd_t _rbd; // 32 bytes
537 } rfd_t;
538
539 //-------------------------------------------------------------------------
540 // TBD - Transmit Buffer Descriptor.
541 //-------------------------------------------------------------------------
542 typedef UInt16 tbd_size_t;
543 #define TBD_SIZE_EL BIT(15) // end of list
544 #define TBD_SIZE_SHIFT 0
545 #define TBD_SIZE_MASK CSR_MASK(TBD_SIZE, 0x3fff)
546
547 typedef struct tbd {
548 volatile IOPhysicalAddress addr;
549 volatile tbd_size_t size;
550 } tbd_t;
551
552 //-------------------------------------------------------------------------
553 // TxCB Status Word.
554 // Offset 0, 16-bit, RW.
555 //-------------------------------------------------------------------------
556 typedef UInt16 tcb_status_t;
557 #define TCB_STATUS_C BIT(15) // complete bit
558 #define TCB_STATUS_OK BIT(13) // error free completion
559 #define TCB_STATUS_U BIT(12) // underrun bit
560
561 //-------------------------------------------------------------------------
562 // TxCB Command Word.
563 // Offset 2, 16-bit, RW.
564 //-------------------------------------------------------------------------
565 typedef UInt16 tcb_command_t;
566 #define TCB_COMMAND_EL BIT(15) // end of list
567 #define TCB_COMMAND_S BIT(14) // suspend bit
568 #define TCB_COMMAND_I BIT(13) // interrupt bit
569 #define TCB_COMMAND_NC BIT(4) // CRC/Source Address control
570 #define TCB_COMMAND_SF BIT(3) // flexible mode bit
571 #define TCB_COMMAND_SHIFT 0
572 #define TCB_COMMAND_MASK CSR_MASK(TCB_COMMAND, 0x7)
573
574 //-------------------------------------------------------------------------
575 // TxCB Count Word.
576 // Offset 0xC, 16-bit, RW.
577 //-------------------------------------------------------------------------
578 typedef UInt16 tcb_count_t;
579 #define TCB_COUNT_EOF BIT(15) // whole frame in TCB
580 #define TCB_COUNT_SHIFT 0
581 #define TCB_COUNT_MASK CSR_MASK(TCB_COUNT, 0x3fff)
582
583 //-------------------------------------------------------------------------
584 // TxCB - Transmit Command Block.
585 //-------------------------------------------------------------------------
586 #define TBDS_PER_TCB 12
587 #define TCB_TX_THRESHOLD 0xe0
588
589 typedef struct tcb {
590 volatile tcb_status_t status;
591 volatile tcb_command_t command;
592 volatile IOPhysicalAddress link;
593 volatile IOPhysicalAddress tbdAddr;
594 volatile tcb_count_t count;
595 volatile UInt8 threshold;
596 volatile UInt8 number;
597
598 /* driver private */
599
600 tbd_t _tbds[TBDS_PER_TCB];
601 struct tcb * _next;
602 IOPhysicalAddress _paddr;
603 struct mbuf * _mbuf;
604 unsigned _pad;
605 } tcb_t;
606
607 #endif /* !_I82557HW_H */
608