summaryrefslogtreecommitdiffstats
path: root/private/ntos/ndis/dc21x4/d21x4hrd.h
blob: 35fdba3fc6aa8fc948ac94756f7ece835f4b6ec9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
/*
 * file:        d21x4hrd.h
 *
 * Copyright (C) 1992-1995 by
 * Digital Equipment Corporation, Maynard, Massachusetts.
 * All rights reserved.
 *
 * This software is furnished under a license and may be used and copied
 * only  in  accordance  of  the  terms  of  such  license  and with the
 * inclusion of the above copyright notice. This software or  any  other
 * copies thereof may not be provided or otherwise made available to any
 * other person.  No title to and  ownership of the  software is  hereby
 * transferred.
 *
 * The information in this software is  subject to change without notice
 * and  should  not  be  construed  as a commitment by digital equipment
 * corporation.
 *
 * Digital assumes no responsibility for the use  or  reliability of its
 * software on equipment which is not supplied by digital.
 *
 *
 * Abstract:    This file contains the hardware related definitions for the
 *              DEC's DC21X4 NDIS 4.0 miniport driver
 *
 * Author:      Philippe Klein
 *
 * Revision History:
 *
 *      phk     28-Aug-1994     Initial entry
 *
 *
-*/










// Adapter ID & revisions

#define DC21040_CFID      0x00021011
#define DC21040_REV1      0x00
#define DC21040_REV2_0    0x20
#define DC21040_REV2_2    0x22


#define DC21041_CFID      0x00141011
#define DC21041_REV1_0    0x10
#define DC21041_REV1_1    0x11
#define DC21041_REV2_0    0x20

#define DC21140_CFID      0x00091011
#define DC21140_REV1_1    0x11
#define DC21140_REV1_2    0x12
#define DC21140_REV2_0    0x20
#define DC21140_REV2_1    0x21
#define DC21140_REV2_2    0x22

#define DC21142_CFID      0x00191011
#define DC21142_REV1      0x10
#define DC21142_REV1_0    0x10
#define DC21142_REV1_1    0x11


typedef enum _CFID_INDEX {
   DefaultCfidIndex,
   DC21040CfidIndex,
   DC21041CfidIndex,
   DC21140CfidIndex,
   MAX_CFIDS
} CFID_INDEX;


#define DE425_COMPRESSED_ID                0x5042A310  //"DEC4250"
#define DC21X4_INTERRUPT_LEVEL_SENSITIVE   0
#define DC21X4_INTERRUPT_LATCHED           1

// Media types

typedef enum _MEDIA_TYPE {
   Medium10BaseT,
   Medium10Base2,
   Medium10Base5,
   Medium100BaseTx,
   Medium10BaseTFd,
   Medium100BaseTxFd,
   Medium100BaseT4,
   Medium100BaseFx,
   Medium100BaseFxFd,
   MAX_MEDIA_TABLE
} MEDIA_TYPE;

#define Medium10Base2_5   0xff


// PHY Media

typedef enum _PHY_MEDIA_TYPE {
    MediumMii10BaseT=MAX_MEDIA_TABLE,
    MediumMii10BaseTFd,
    MediumMii10Base2,    
    MediumMii10Base5,          
    MediumMii100BaseTx,        
    MediumMii100BaseTxFd,      
    MediumMii100BaseT4,         
    MediumMii100BaseFx,         
    MediumMii100BaseFxFd,      
    MAX_PHY_MEDIA
} PHY_MEDIA_TYPE;


#define MEDIA_MASK          0x00ff
#define CONTROL_MASK        0xFF00

// Media modes

#define MEDIA_NWAY          0x0100
#define MEDIA_FULL_DUPLEX   0x0200
#define MEDIA_LINK_DISABLE  0x0400
#define MEDIA_AUTOSENSE     0x0800

#define MediaAutoSense               (MEDIA_AUTOSENSE   | MEDIA_NWAY)
#define MediaAutoSenseNoNway         (MEDIA_AUTOSENSE)

#define Medium10BaseTNway            (Medium10BaseT     | MEDIA_NWAY)
#define Medium10BaseTFullDuplex      (Medium10BaseTFd   | MEDIA_FULL_DUPLEX)
#define Medium10BaseTLinkDisable     (Medium10BaseT     | MEDIA_LINK_DISABLE)

#define Medium100BaseTxFullDuplex    (Medium100BaseTxFd | MEDIA_FULL_DUPLEX)


#define MediumMii10BaseTFullDuplex   (MediumMii10BaseTFd   | MEDIA_FULL_DUPLEX)
#define MediumMii100BaseTxFullDuplex (MediumMii100BaseTxFd | MEDIA_FULL_DUPLEX)
#define MediaMiiAutoSense            (MediumMii10BaseT     | MEDIA_AUTOSENSE)


// Media Capable mask

#define MEDIUM_10BT     (1<<Medium10BaseT)
#define MEDIUM_10B2     (1<<Medium10Base2)
#define MEDIUM_10B5     (1<<Medium10Base5)
#define MEDIUM_100BTX   (1<<Medium100BaseTx)

//Default Cache Line Size (in bytes)
#define DC21X4_DEFAULT_CACHE_LINE_SIZE 64

//DC21X4 Register index

//PCI Configuration registers

#define DC21X4_PCI_ID              0
#define DC21X4_PCI_COMMAND         1
#define DC21X4_PCI_REVISION        2
#define DC21X4_PCI_LATENCY_TIMER   3
#define DC21X4_PCI_BASE_IO_ADDRESS 4
#define DC21X4_PCI_INTERRUPT       5
#define DC21X4_PCI_DRIVER_AREA     6

#define DC21X4_MAX_CONFIGURATION   7

//Command & Status Registers

#define DC21X4_BUS_MODE            0
#define DC21X4_TXM_POLL_DEMAND     1
#define DC21X4_RCV_POLL_DEMAND     2
#define DC21X4_RCV_DESC_RING       3
#define DC21X4_TXM_DESC_RING       4
#define DC21X4_STATUS              5
#define DC21X4_OPERATION_MODE      6
#define DC21X4_INTERRUPT_MASK      7
#define DC21X4_MISSED_FRAME        8
#define DC21X4_IDPROM              9
#define DC21X4_RESERVED           10
#define DC21X4_TIMER              11
#define DC21X4_SIA_STATUS         12
#define DC21X4_GEN_PURPOSE        12
#define DC21X4_SIA_MODE_0         13
#define DC21X4_SIA_MODE_1         14
#define DC21X4_SIA_MODE_2         15
#define DC21X4_MAX_CSR            16


//EISA Mapping

#define EISA_REG0_OFFSET          0xc88
#define EISA_REG1_OFFSET          0xc89

#define EISA_CFGSCR1_OFFSET       0x8C
#define EISA_CFGSCR2_OFFSET       0x98

#define EISA_CFID_OFFSET          0x08
#define EISA_CFCS_OFFSET          0x0c
#define EISA_CFRV_OFFSET          0x18
#define EISA_CFLT_OFFSET          0x1C
#define EISA_CBIO_OFFSET          0x28

#define EISA_CSR_OFFSET           0x10

#define EISA_ID_PROM_OFFSET       0xc90

#define EISA_DC21040_REGISTER_SPACE   240
#define EISA_DC21140_REGISTER_SPACE   240

//PCI mapping

#define PCI_CFID_OFFSET           0x00
#define PCI_CFCS_OFFSET           0x04
#define PCI_CFRV_OFFSET           0x08
#define PCI_CFLT_OFFSET           0x0C
#define PCI_CBIO_OFFSET           0x10
#define PCI_CFIT_OFFSET           0x3C
#define PCI_CFDA_OFFSET           0x40

#define PCI_CSR_OFFSET            0x08

# define SLOT_NUMBER_OFFSET       12
# define IRQ_BIT_NUMBER            1


//Constants for the CONFIG_ID register

#define DC21X4_DEVICE_ID                ((ULONG)(0x0000FFFF))
#define DC21X4_VENDOR_ID                ((ULONG)(0xFFFF0000))

//Constants for the CONFIG_COMMAND register

#define DC21X4_MEMORY_SPACE_ACCESS      ((ULONG)(0x00000001))
#define DC21X4_MASTER_OPERATION         ((ULONG)(0x00000002))
#define DC21X4_PARITY_ERROR_RESPONSE    ((ULONG)(0x00000004))
#define DC21X4_DEVSEL_TIMING            ((ULONG)(0x00000008))

#define DC21X4_PCI_COMMAND_DEFAULT_VALUE 0x05   // Parity Response = 0
                                                // Master Operation = 1
                                                // Memory Space Access = 0
                                                // IO Space Access = 1

//Constants for the CONFIG_REVISION register

#define DC21X4_REVISION_ID              ((ULONG)(0x000000FF))
#define DC21X4_MAJOR_REV                ((ULONG)(0x000000F0))
#define DC21X4_MINOR_REV                ((ULONG)(0x0000000F))

//Constants for the CONFIG_LATENCY_TIMER register

#define DC21X4_LATENCY_TIMER            ((ULONG)(0x0000FF00))

#define DC21X4_PCI_LATENCY_TIMER_DEFAULT_VALUE  0xFF00

//Constants for the CONFIG_BASE_IO_ADDRESS register

#define DC21X4_IO_SPACE                 ((ULONG)(0x00000001))
#define DC21X4_BASE_IO_ADDRESS          ((ULONG)(0xFFFFFF80))

//Constants for the CONFIG_INTERRUPT register

#define DC21X4_CFIT_INTERRUPT_LINE      ((ULONG)(0x000000FF))

//Constants for the CONFIG_DRIVER_AREA register

#define DC21X4_REGISTRED                ((ULONG)(0x00000100))

#define CFDA_SNOOZE_MODE                0x40000000


//Constants for the BUS_MODE register

#define DC21X4_SW_RESET               ((ULONG)(0x00000001))
#define DC21X4_BUS_ARBITRATION        ((ULONG)(0x00000002))
#define DC21X4_SKIP_LENGTH            ((ULONG)(0x0000003C))
#define DC21X4_ENDIAN                 ((ULONG)(0x00000080))
#define DC21X4_BURST_LENGTH           ((ULONG)(0x00003F00))
#define DC21X4_CACHE_ALIGNMENT        ((ULONG)(0x0000C000))
#define DC21X4_AUTO_POLLING           ((ULONG)(0x00070000))

#define BUS_ARBITRATION_BIT_NUMBER      1
#define BURST_LENGTH_BIT_NUMBER         8
#define AUTO_POLLING_BIT_NUMBER        16

#define DC21X4_BURST_LENGTH_DEFAULT_VALUE 16

#define DC21X4_SKIP_64                ((ULONG)(0x00000030))
#define DC21X4_SKIP_128               ((ULONG)(0x00000070))

#define DC21X4_ALIGN_32               ((ULONG)(0x00004000))
#define DC21X4_ALIGN_64               ((ULONG)(0x00008000))
#define DC21X4_ALIGN_128              ((ULONG)(0x0000C000))

//Constants for the TXM_POLL_DEMAND & RCV_POLL_DEMAND

#define DC21X4_POLL_DEMAND            ((ULONG)(0x00000001))


//Constants for the STATUS register (CSR5)

#define DC21X4_TXM_INTERRUPT           ((ULONG)(0x00000001))
#define DC21X4_TXM_STOPPED             ((ULONG)(0x00000002))
#define DC21X4_TXM_BUFFER_UNAVAILABLE  ((ULONG)(0x00000004))
#define DC21X4_TXM_JABBER_TIMEOUT      ((ULONG)(0x00000008))
#define DC21X4_LINK_PASS               ((ULONG)(0x00000010))
#define DC21X4_TXM_UNDERRUN            ((ULONG)(0x00000020))
#define DC21X4_RCV_INTERRUPT           ((ULONG)(0x00000040))
#define DC21X4_RCV_BUFFER_UNAVAILABLE  ((ULONG)(0x00000080))
#define DC21X4_RCV_STOPPED             ((ULONG)(0x00000100))
#define DC21X4_RCV_WATCHDOG_TIMEOUT    ((ULONG)(0x00000200))
#define DC21X4_10B5_10BT_SWITCH        ((ULONG)(0x00000400))
#define DC21X4_FULL_DUPLEX_SHORT_FRAME ((ULONG)(0x00000800))
#define DC21X4_LINK_FAIL               ((ULONG)(0x00001000))
#define DC21X4_SYSTEM_ERROR            ((ULONG)(0x00002000))
#define DC21X4_ABNORMAL_INTERRUPT      ((ULONG)(0x00008000))
#define DC21X4_NORMAL_INTERRUPT        ((ULONG)(0x00010000))
#define DC21X4_RCV_PROCESS_STATE       ((ULONG)(0x000E0000))
#define DC21X4_TXM_PROCESS_STATE       ((ULONG)(0x00700000))
#define DC21X4_ERROR_BITS              ((ULONG)(0x03800000))
#define DC21X4_GEP_INTERRUPT           ((ULONG)(0x04000000))

#define DC21X4_TXM_PROCESS_SUSPENDED   ((ULONG)(0x00600000))

#define DC21X4_STATUS_INTERRUPTS       ((ULONG)(0x0001BFFF))

//Constants for the OPERATION_MODE register (CSR6)

#define DC21X4_RCV_HASH_FILTER_MODE    ((ULONG)(0x00000001))
#define DC21X4_RCV_START               ((ULONG)(0x00000002))
#define DC21X4_PASS_BAD_FRAMES         ((ULONG)(0x00000008))
#define DC21X4_INVERSE_FILTERING       ((ULONG)(0x00000010))
#define DC21X4_STOP_BACKOFF_COUNTER    ((ULONG)(0x00000020))
#define DC21X4_PROMISCUOUS_MODE        ((ULONG)(0x00000040))
#define DC21X4_PASS_ALL_MULTICAST      ((ULONG)(0x00000080))
#define DC21X4_FLAKY_OSC_DISABLE       ((ULONG)(0x00000100))
#define DC21X4_FULL_DUPLEX_MODE        ((ULONG)(0x00000200))
#define DC21X4_OPERATING_MODE          ((ULONG)(0x00000C00))
#define DC21X4_FORCE_COLLISION_MODE    ((ULONG)(0x00001000))
#define DC21X4_TXM_START               ((ULONG)(0x00002000))
#define DC21X4_TXM_THRESHOLD           ((ULONG)(0x0000C000))
#define DC21X4_BACK_PRESSURE           ((ULONG)(0x00010000))
#define DC21X4_CAPTURE_EFFECT          ((ULONG)(0x00020000))
#define DC21X4_PORT_SELECT             ((ULONG)(0x00040000))
#define DC21X4_HEARTBEAT_DISABLE       ((ULONG)(0x00080000))
#define DC21X4_STORE_AND_FORWARD       ((ULONG)(0x00200000))
#define DC21X4_TXM_THRESHOLD_MODE      ((ULONG)(0x00400000))
#define DC21X4_CS_MODE                 ((ULONG)(0x00800000))
#define DC21X4_SCRAMBLER               ((ULONG)(0x01000000))
#define DC21X4_LINK_HYSTERESIS         ((ULONG)(0x02000000))

#define DC21X4_INTERNAL_LOOPBACK_MODE  ((ULONG)(0x00000400))
#define DC21X4_EXTERNAL_LOOPBACK_MODE  ((ULONG)(0x00000800))

#define DC21X4_TXM10_THRESHOLD_72      ((ULONG)(0x00000000))
#define DC21X4_TXM10_THRESHOLD_96      ((ULONG)(0x00004000))
#define DC21X4_TXM10_THRESHOLD_128     ((ULONG)(0x00008000))
#define DC21X4_TXM10_THRESHOLD_160     ((ULONG)(0x0000C000))

#define DC21X4_TXM100_THRESHOLD_128    ((ULONG)(0x00000000))
#define DC21X4_TXM100_THRESHOLD_256    ((ULONG)(0x00004000))
#define DC21X4_TXM100_THRESHOLD_512    ((ULONG)(0x00008000))
#define DC21X4_TXM100_THRESHOLD_1024   ((ULONG)(0x0000C000))

#define DC21X4_DEFAULT_THRESHOLD_10MBPS  DC21X4_TXM10_THRESHOLD_96
#define DC21X4_DEFAULT_THRESHOLD_100MBPS DC21X4_TXM100_THRESHOLD_512

#define DC21X4_MODE_MASK  ((ULONG)(      \
               DC21X4_TXM_THRESHOLD_MODE \
             | DC21X4_FULL_DUPLEX_MODE   \
             | DC21X4_STORE_AND_FORWARD  \
             ))

#define DC21X4_MEDIUM_MASK  ((ULONG)(         \
               DC21X4_TXM_THRESHOLD           \
             | DC21X4_PORT_SELECT             \
             | DC21X4_HEARTBEAT_DISABLE       \
             | DC21X4_FULL_DUPLEX_MODE        \
             | DC21X4_TXM_THRESHOLD_MODE      \
             | DC21X4_CS_MODE                 \
             | DC21X4_SCRAMBLER               \
             | DC21X4_LINK_HYSTERESIS         \
             ))

//initial values

#define DC21X4_OPMODE_100BTX ((ULONG)(   \
              DC21X4_HEARTBEAT_DISABLE   \
            | DC21X4_LINK_HYSTERESIS     \
            ))

//Constants for the INTERRUPT_MASK register (CSR7)

#define DC21X4_MSK_TXM_INTERRUPT            ((ULONG)(0x00000001))
#define DC21X4_MSK_TXM_STOPPED              ((ULONG)(0x00000002))
#define DC21X4_MSK_TXM_BUFFER_UNAVAILABLE   ((ULONG)(0x00000004))
#define DC21X4_MSK_TXM_JABBER_TIMEOUT       ((ULONG)(0x00000008))
#define DC21X4_MSK_LINK_PASS                ((ULONG)(0x00000010))
#define DC21X4_MSK_TXM_UNDERRUN             ((ULONG)(0x00000020))

#define DC21X4_MSK_RCV_INTERRUPT            ((ULONG)(0x00000040))
#define DC21X4_MSK_RCV_BUFFER_UNAVAILABLE   ((ULONG)(0x00000080))
#define DC21X4_MSK_RCV_STOPPED              ((ULONG)(0x00000100))
#define DC21X4_MSK_RCV_WATCHDOG_TIMEOUT     ((ULONG)(0x00000200))
#define DC21X4_MSK_10B5_10BT_SWITCH         ((ULONG)(0x00000400))
#define DC21X4_MSK_TIMER_EXPIRED            ((ULONG)(0x00000800))
#define DC21X4_MSK_FULL_DUPLEX              ((ULONG)(0x00000800))
#define DC21X4_MSK_LINK_FAIL                ((ULONG)(0x00001000))
#define DC21X4_MSK_SYSTEM_ERROR             ((ULONG)(0x00002000))
#define DC21X4_MSK_EARLY_INTERRUPT          ((ULONG)(0x00004000))
#define DC21X4_MSK_ABNORMAL_INTERRUPT       ((ULONG)(0x00008000))
#define DC21X4_MSK_NORMAL_INTERRUPT         ((ULONG)(0x00010000))
#define DC21X4_MSK_GEP_INTERRUPT            ((ULONG)(0x04000000))


//initial value

#define DC21X4_TXM_INTERRUPTS   ((ULONG)(              \
          DC21X4_MSK_TXM_INTERRUPT           \
        | DC21X4_MSK_TXM_STOPPED             \
        | DC21X4_MSK_TXM_JABBER_TIMEOUT      \
        ))

#define DC21X4_RCV_INTERRUPTS   ((ULONG)(       \
          DC21X4_MSK_TXM_STOPPED      \
        | DC21X4_MSK_RCV_INTERRUPT    \
        ))

#define DC21X4_MSK_MSK_DEFAULT_VALUE   ((ULONG)(       \
          DC21X4_TXM_INTERRUPTS              \
        | DC21X4_RCV_INTERRUPTS              \
        | DC21X4_MSK_LINK_PASS               \
        | DC21X4_MSK_LINK_FAIL               \
        | DC21X4_MSK_TIMER_EXPIRED           \
        | DC21X4_MSK_SYSTEM_ERROR            \
        | DC21X4_MSK_ABNORMAL_INTERRUPT      \
        | DC21X4_MSK_NORMAL_INTERRUPT        \
        ))

//Constants for the MISSED_FRAME/OVERFLOW register

#define DC21X4_MISSED_FRAME_COUNTER    ((ULONG)(0x0000FFFF))

#define DC21X4_OVERFLOW_COUNTER        ((ULONG)(0x00001FFF))
#define DC21X4_OVERFLOW_COUNTER_SHIFT  16

// Constants for the SERIAL ROM register

#define DC21X4_IDPROM_DATA_UNVALID      ((ULONG)(0x80000000))
#define DC21X4_IDPROM_DATA              ((ULONG)(0x000000FF))

// Constants for the TIMER register

#define DC21X4_TIMER_CON_MODE           ((ULONG)(0x00010000))


//Constants for the DC2104 SIA_STATUS register  (CSR12)

#define DC21X4_10B5_10BT_INDICATION     ((ULONG)(0x00000001))
#define DC21X4_NETWORK_CONNECTION_ERROR ((ULONG)(0x00000002))
#define DC21X4_LINKFAIL_10              ((ULONG)(0x00000004))
#define DC21X4_AUTO_POLARITY_STATE      ((ULONG)(0x00000008))
#define DC21X4_DPLL_SELF_TEST_DONE      ((ULONG)(0x00000010))
#define DC21X4_DPLL_SELF_TEST_PASS      ((ULONG)(0x00000020))
#define DC21X4_DPLL_ALL_ZERO            ((ULONG)(0x00000040))
#define DC21X4_DPLL_ALL_ONE             ((ULONG)(0x00000080))
#define DC21X4_SELECTED_PORT_ACTIVE     ((ULONG)(0x00000100))
#define DC21X4_NON_SELECTED_PORT_ACTIVE ((ULONG)(0x00000200))
#define DC21X4_AUTO_NEGOTIATION_STATE   ((ULONG)(0x00007000))
#define DC21X4_LINK_PARTNER_NEGOTIABLE  ((ULONG)(0x00008000))

#define DC21X4_SELECTED_FIELD_MASK      ((ULONG)(0x001F0000))
#define DC21X4_SELECTED_FIELD           ((ULONG)(0x00010000))

#define DC21X4_LINK_PARTNER_10BT        ((ULONG)(0x00200000))
#define DC21X4_LINK_PARTNER_10BT_FD     ((ULONG)(0x00400000))

#define DC21X4_RESTART_AUTO_NEGOTIATION  ((ULONG)(0x00001000))

//Constants for the AutoNegotation states 

#define ANS_ACKNOWLEDGE_DETECTED         ((ULONG)(0x00003000))
#define ANS_ACKNOWLEDGE_COMPLETED        ((ULONG)(0x00004000))
#define ANS_AUTO_NEGOTIATION_COMPLETED   ((ULONG)(0x00005000))

#define DC21X4_LINK_PASS_MASK    ((ULONG)(   \
          DC21X4_LINKFAIL_10                 \
        | DC21X4_AUTO_NEGOTIATION_STATE      \
        ))

#define DC21X4_LINK_PASS_STATUS    ((ULONG)( \
          ANS_AUTO_NEGOTIATION_COMPLETED     \
        ))

//Constants for the SIA_MODE_0 registers (CSR13)

#define DC21X4_SIA_RST                   ((ULONG)(0x00000001))
#define DC21X4_10B5_10BT_SELECTION       ((ULONG)(0x00000002))
#define DC21X4_CSR_AUTO_CONFIGURATION    ((ULONG)(0x00000004))
#define DC21X4_10B5_MODE                 ((ULONG)(0x00000008))

#define DC21X4_AUTOSENSE_FLG             ((ULONG)(0x80000005))
#define DC21X4_FULL_DUPLEX_FLG           ((ULONG)(0x40000005))
#define DC21X4_LINK_DISABLE_FLG          ((ULONG)(0x10000005))
#define DC21X4_10B5_FLG                  ((ULONG)(0x0000000D))
#define DC21X4_10B2_FLG                  ((ULONG)(0x2000000D))

#define DC21X4_RESET_SIA                 ((ULONG)(0x00000000))


//Constants for the SIA_MODE_1 registers (CSR14)


#define DC21X4_AUTO_NEGOTIATION_ENABLE          ((ULONG)(0x00000080))


//Constants for the SIA_MODE_2 registers (CSR15)
#define DC21142_SIA2_MASK                ((ULONG)(0x0000FFFF))
#define DC21142_GEP_MASK                 ((ULONG)(0xFFFF0000))

#define DC21142_GEP_SHIFT                16


//DC21040:

//Constants for SIA TP mode

#define DC21040_SIA0_10BT               ((ULONG)(0x00008F01))
#define DC21040_SIA1_10BT               ((ULONG)(0x0000FFFF))
#define DC21040_SIA1_10BT_FULL_DUPLEX   ((ULONG)(0x0000FFFD))
#define DC21040_SIA1_10BT_LINK_DISABLE  ((ULONG)(0x0000CFFF))
#define DC21040_SIA2_10BT               ((ULONG)(0x00000000))

//Constants for SIA BNC Thinwire mode

#define DC21040_SIA0_10B2               ((ULONG)(0x0000EF09))
#define DC21040_SIA1_10B2               ((ULONG)(0x00000705))
#define DC21040_SIA2_10B2               ((ULONG)(0x00000006))

//Constants for SIA AUI Thickwire mode

#define DC21040_SIA0_10B5               ((ULONG)(0x00008F09))
#define DC21040_SIA1_10B5               ((ULONG)(0x00000705))
#define DC21040_SIA2_10B5               ((ULONG)(0x00000006))


//DC21041:

//Constants for SIA TP mode

#define DC21041_SIA0_10BT               ((ULONG)(0x0000EF01))
#define DC21041_SIA1_10BT               ((ULONG)(0x0000FF3F))
#define DC21041_SIA1_10BT_FULL_DUPLEX   ((ULONG)(0x00007F3D))
#define DC21041_SIA1_10BT_LINK_DISABLE  ((ULONG)(0x00004F3F))
#define DC21041_SIA2_10BT               ((ULONG)(0x00000008))

//Constants for SIA BNC

#define DC21041_SIA0_10B2               ((ULONG)(0x0000EF09))
#define DC21041_SIA1_10B2               ((ULONG)(0x00000705))
#define DC21041_SIA2_10B2               ((ULONG)(0x00000006))

//Constants for SIA AUI mode

#define DC21041_SIA0_10B5               ((ULONG)(0x0000EF09))
#define DC21041_SIA1_10B5               ((ULONG)(0x00000705))
#define DC21041_SIA2_10B5               ((ULONG)(0x0000000E))

#define DC21041_LINK_TEST_ENABLED       ((ULONG)(0x0000F038))


//DC21142:

//Constants for SIA TP mode

#define DC21142_SIA0_10BT               ((ULONG)(0x00000001))
#define DC21142_SIA1_10BT               ((ULONG)(0x00007F3F))
#define DC21142_SIA1_10BT_FULL_DUPLEX   ((ULONG)(0x00007F3D))
#define DC21142_SIA1_10BT_LINK_DISABLE  ((ULONG)(0x00004F3F))
#define DC21142_SIA2_10BT               ((ULONG)(0x00000008))   // turn off the BNC transceiver

//Constants for SIA BNC

#define DC21142_SIA0_10B2               ((ULONG)(0x00000009))
#define DC21142_SIA1_10B2               ((ULONG)(0x00000705))
#define DC21142_SIA2_10B2               ((ULONG)(0x00000006))

//Constants for SIA AUI mode

#define DC21142_SIA0_10B5               ((ULONG)(0x00000009))
#define DC21142_SIA1_10B5               ((ULONG)(0x00000705))
#define DC21142_SIA2_10B5               ((ULONG)(0x0000000E))

//Constant for MII mode

#define DC21142_SIA1_MII_HALF_DUPLEX    ((ULONG)(0x00007F3F))
#define DC21142_SIA1_MII_FULL_DUPLEX    ((ULONG)(0x00007F3D))

#define DC21142_GPR_BIT_SHIFT           16

#define DC21X4_GEP_INTERRUPT_BIT_SHIFT 29

#define DC21142_LINK_TEST_ENABLED       ((ULONG)(0x0000F038))  //while in BNC or AUI mode


#define DC21X4_NWAY_ENABLED             ((ULONG)(0x000000C0))

//Constants for the RCV descriptor RDES

#define DC21X4_RDES_OVERFLOW             ((ULONG)(0x00000001))
#define DC21X4_RDES_CRC_ERROR            ((ULONG)(0x00000002))
#define DC21X4_RDES_DRIBBLING_BIT        ((ULONG)(0x00000004))
#define DC21X4_RDES_RCV_WATCHDOG_TIMEOUT ((ULONG)(0x00000010))
#define DC21X4_RDES_FRAME_TYPE           ((ULONG)(0x00000020))
#define DC21X4_RDES_COLLISION_SEEN       ((ULONG)(0x00000040))
#define DC21X4_RDES_FRAME_TOO_LONG       ((ULONG)(0x00000080))
#define DC21X4_RDES_LAST_DESCRIPTOR      ((ULONG)(0x00000100))
#define DC21X4_RDES_FIRST_DESCRIPTOR     ((ULONG)(0x00000200))
#define DC21X4_RDES_MULTICAST_FRAME      ((ULONG)(0x00000400))
#define DC21X4_RDES_RUNT_FRAME           ((ULONG)(0x00000800))
#define DC21X4_RDES_DATA_TYPE            ((ULONG)(0x00003000))
#define DC21X4_RDES_LENGTH_ERROR         ((ULONG)(0x00004000))
#define DC21X4_RDES_ERROR_SUMMARY        ((ULONG)(0x00008000))
#define DC21X4_RDES_FRAME_LENGTH         ((ULONG)(0x7FFF0000))
#define DC21X4_RDES_OWN_BIT              ((ULONG)(0x80000000))

#define DC21X4_RDES_FIRST_BUFFER_SIZE    ((ULONG)(0x000007FF))
#define DC21X4_RDES_SECOND_BUFFER_SIZE   ((ULONG)(0x003FF800))
#define DC21X4_RDES_SECOND_ADDR_CHAINED  ((ULONG)(0x01000000))
#define DC21X4_RDES_END_OF_RING          ((ULONG)(0x02000000))

#define RDES_FRAME_LENGTH_BIT_NUMBER     16


//Constants for the TXM descriptor TDES

#define DC21X4_TDES_DEFERRED             ((ULONG)(0x00000001))
#define DC21X4_TDES_UNDERRUN_ERROR      ((ULONG)(0x00000002))
#define DC21X4_TDES_LINK_FAIL            ((ULONG)(0x00000004))
#define DC21X4_TDES_COLLISION_COUNT      ((ULONG)(0x00000078))
#define DC21X4_TDES_HEARTBEAT_FAIL       ((ULONG)(0x00000080))
#define DC21X4_TDES_EXCESSIVE_COLLISIONS ((ULONG)(0x00000100))
#define DC21X4_TDES_LATE_COLLISION       ((ULONG)(0x00000200))
#define DC21X4_TDES_NO_CARRIER           ((ULONG)(0x00000400))
#define DC21X4_TDES_LOSS_OF_CARRIER      ((ULONG)(0x00000800))
#define DC21X4_TDES_TXM_JABBER_TIMEOUT   ((ULONG)(0x00004000))
#define DC21X4_TDES_ERROR_SUMMARY        ((ULONG)(0x00008000))
#define DC21X4_TDES_OWN_BIT              ((ULONG)(0x80000000))

#define DC21X4_TDES_ERROR_MASK  ((ULONG)(   \
          DC21X4_TDES_UNDERRUN_ERROR        \
        | DC21X4_TDES_EXCESSIVE_COLLISIONS  \
        | DC21X4_TDES_LATE_COLLISION        \
        | DC21X4_TDES_NO_CARRIER            \
        | DC21X4_TDES_LOSS_OF_CARRIER       \
        | DC21X4_TDES_TXM_JABBER_TIMEOUT    \
        ))

#define DC21X4_TDES_FIRST_BUFFER_SIZE       ((ULONG)(0x000007FF))
#define DC21X4_TDES_SECOND_BUFFER_SIZE      ((ULONG)(0x003FF800))
#define DC21X4_TDES_HASH_FILTERING          ((ULONG)(0x00400000))
#define DC21X4_TDES_DISABLE_PADDING         ((ULONG)(0x00800000))
#define DC21X4_TDES_SECOND_ADDR_CHAINED     ((ULONG)(0x01000000))
#define DC21X4_TDES_END_OF_RING             ((ULONG)(0x02000000))
#define DC21X4_TDES_ADD_CRC_DISABLE         ((ULONG)(0x04000000))
#define DC21X4_TDES_SETUP_PACKET            ((ULONG)(0x08000000))
#define DC21X4_TDES_INVERSE_FILTERING       ((ULONG)(0x10000000))
#define DC21X4_TDES_FIRST_SEGMENT           ((ULONG)(0x20000000))
#define DC21X4_TDES_LAST_SEGMENT            ((ULONG)(0x40000000))
#define DC21X4_TDES_INTERRUPT_ON_COMPLETION ((ULONG)(0x80000000))

#define TDES_SECOND_BUFFER_SIZE_BIT_NUMBER  11
#define TDES_COLLISION_COUNT_BIT_NUMBER     3


//Ownership of descriptors.

#define DESC_OWNED_BY_SYSTEM   ((ULONG)(0x00000000))
#define DESC_OWNED_BY_DC21X4   ((ULONG)(0x80000000))

//Size of the Ethernet frame header

#define ETH_HEADER_SIZE  14

//Size of the frame CRC field

#define ETH_CRC_SIZE  4

//Number of buffer segments per DC21X4 descriptor

#define NUMBER_OF_SEGMENT_PER_DESC  2

//Maximum buffer size

#define DC21X4_MAX_BUFFER_SIZE 1536  // 12*128(=max cache line size)

//Maximum LookAhead is the size maximum of the frame

#define DC21X4_MAX_FRAME_SIZE 1514
#define DC21X4_MAX_LOOKAHEAD  1514

//Maximum number of physical segments DC21X4 accepts
//in a single Ndis buffer. Above this threshold, the packet
//is copied into a single physically contiguous buffer

#define DC21X4_MAX_SEGMENTS  8

//Minimal size of a Txm packet to be directly mapped
//into the Transmit Ring.Under this threshold, the packet
//is copied into a preallocated Txm buffer to avoid
//the (expensive) physical mapping translation

#define DC21X4_MIN_TXM_SIZE 256


//Number of descriptors reserved for Txm packets
//into the Txm desc ring

#define DC21X4_NUMBER_OF_TRANSMIT_DESCRIPTORS 64

//Number of descriptors reserved for setup processing
//into the Txm desc ring

#define DC21X4_NUMBER_OF_SETUP_DESCRIPTORS 2

//Size of the Transmit descriptor ring

#define TRANSMIT_RING_SIZE (DC21X4_NUMBER_OF_TRANSMIT_DESCRIPTORS+DC21X4_NUMBER_OF_SETUP_DESCRIPTORS+1)

//Number and size of allocated Txm buffers;
//Nbr of Txm buffers MUST BE A POWER OF 2

#define DC21X4_NUMBER_OF_MAX_TRANSMIT_BUFFERS  4
#define DC21X4_MAX_TRANSMIT_BUFFER_SIZE        DC21X4_MAX_BUFFER_SIZE

#define DC21X4_NUMBER_OF_MIN_TRANSMIT_BUFFERS  16
#define DC21X4_MIN_TRANSMIT_BUFFER_SIZE        DC21X4_MIN_TXM_SIZE


//Number and size of allocated setup buffers

#define DC21X4_NUMBER_OF_SETUP_BUFFERS     1
#define DC21X4_SETUP_BUFFER_SIZE           192

//Physical mapping registers allocated to the adapter

#if _ALPHA_
#define DEFAULT_MAP_REGISTERS 64
#else
#define DEFAULT_MAP_REGISTERS 32
#endif


#define DC21X4_MIN_MAP_REGISTERS  4
#define DC21X4_MAX_MAP_REGISTERS  64

//Size of the Receive descriptor ring

#define DC21X4_MIN_RECEIVE_RING_SIZE   8
#define DC21X4_MAX_RECEIVE_RING_SIZE  64

#define DC21X4_RECEIVE_RING_SIZE      16

#define DC21X4_RECEIVE_PACKETS       100

//Size of allocated receive buffers:

#define DC21X4_RECEIVE_BUFFER_SIZE     DC21X4_MAX_BUFFER_SIZE


//No_carrier & ExecessCollisions counter threshold

#define NO_CARRIER_THRESHOLD           4
#define EXCESS_COLLISIONS_THRESHOLD    4


//Transmit Underrun Threshold and Max retries

#define DC21X4_UNDERRUN_THRESHOLD   10
#define DC21X4_UNDERRUN_MAX_RETRIES  2




//Interrupt and frame thresholds for interrupt moderation

#define DC21X4_MSK_THRESHOLD_DEFAULT_VALUE    500   //interrupt/second
#define DC21X4_FRAME_THRESHOLD_DEFAULT_VALUE  400   //frames/second

//NdisStallExecution (in microseconds)

#define MILLISECOND                1000

//Timer (in milliseconds)

#define DC21X4_ANC_TIMEOUT         3000 // 3 s
#define DC21X4_SPA_TICK            2000 // 2 s
#define DC21X4_MII_TICK            5000 // 5 s
#define DC21X4_LINK_DELAY          1000 // 1 s
#define DC21X4_POLL_DELAY          100  // 100 ms
#define DC21X4_ANC_DELAY           500  // 500 ms

#define POLL_COUNT_TIMEOUT          40  // *DC21X4_POLL_DELAY = 4s

#define MAX_LINK_CHECK              10  
#define LINK_CHECK_PERIOD         1000  // 1s

#define INT_MONITOR_PERIOD          500 // 500ms

// Built_in timer for MII100 (81.9 us tick)

#define ONE_MILLISECOND_TICK         12 // 12 * 81.9 us

//Loop timeout (*10 milliseconds)

#define DC21X4_SETUP_TIMEOUT    50  // *10ms
#define DC21X4_TXM_TIMEOUT      50  // *10ms
#define DC21X4_RVC_TIMEOUT      50  // *10ms

//Line speed (* 100 bps)

#define TEN_MBPS             100000  // * 100bps
#define ONE_HUNDRED_MBPS    1000000  // * 100bps