62312ee3fa2fc243ca27a283a4937299756bf118
[reactos.git] / reactos / drivers / network / dd / pcnet / pcnet.h
1 /*
2 * ReactOS AMD PCNet Driver
3 *
4 * Copyright (C) 2003 Vizzini <vizzini@plasmic.com>
5 * Copyright (C) 2004 Filip Navara <navaraf@reactos.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * REVISIONS:
22 * 01-Sep-2003 vizzini - Created
23 * NOTES:
24 * - this assumes a 32-bit machine, where sizeof(PVOID) = 32 and sizeof(USHORT) = 16
25 * - this assumes 32-bit physical addresses
26 */
27
28 #ifndef _PCNET_H_
29 #define _PCNET_H_
30
31 /* statistics struct */
32 typedef struct _ADAPTER_STATS
33 {
34 ULONG XmtGoodFrames;
35 ULONG XmtRetryErrors;
36 ULONG XmtLossesOfCarrier;
37 ULONG XmtCollisions;
38 ULONG XmtLateCollisions;
39 ULONG XmtExcessiveDefferals;
40 ULONG XmtBufferUnderflows;
41 ULONG XmtBufferErrors;
42 ULONG XmtOneRetry;
43 ULONG XmtMoreThanOneRetry;
44 ULONG RcvGoodFrames;
45 ULONG RcvBufferErrors;
46 ULONG RcvCrcErrors;
47 ULONG RcvOverflowErrors;
48 ULONG RcvFramingErrors;
49 } ADAPTER_STATS, *PADAPTER_STATS;
50
51 /* adapter struct */
52 typedef struct _ADAPTER
53 {
54 NDIS_SPIN_LOCK Lock;
55
56 NDIS_HANDLE MiniportAdapterHandle;
57 ULONG Flags;
58 ULONG InterruptVector;
59 ULONG IoBaseAddress;
60 ULONG_PTR PortOffset;
61 NDIS_MINIPORT_INTERRUPT InterruptObject;
62 NDIS_MEDIA_STATE MediaState;
63 UINT MediaSpeed;
64 BOOLEAN FullDuplex;
65 NDIS_MINIPORT_TIMER MediaDetectionTimer;
66 ULONG CurrentReceiveDescriptorIndex;
67 ULONG CurrentPacketFilter;
68 ULONG CurrentLookaheadSize;
69
70 /* circular indexes to transmit descriptors */
71 ULONG CurrentTransmitStartIndex;
72 ULONG CurrentTransmitEndIndex;
73
74 /* initialization block */
75 ULONG InitializationBlockLength;
76 PINITIALIZATION_BLOCK InitializationBlockVirt;
77 PINITIALIZATION_BLOCK InitializationBlockPhys;
78
79 /* transmit descriptor ring */
80 ULONG TransmitDescriptorRingLength;
81 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt;
82 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingPhys;
83
84 /* transmit buffers */
85 ULONG TransmitBufferLength;
86 PCHAR TransmitBufferPtrVirt;
87 PCHAR TransmitBufferPtrPhys;
88
89 /* receive descriptor ring */
90 ULONG ReceiveDescriptorRingLength;
91 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt;
92 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingPhys;
93
94 /* receive buffers */
95 ULONG ReceiveBufferLength;
96 PCHAR ReceiveBufferPtrVirt;
97 PCHAR ReceiveBufferPtrPhys;
98
99 ADAPTER_STATS Statistics;
100 } ADAPTER, *PADAPTER;
101
102 /* forward declarations */
103 NDIS_STATUS
104 NTAPI
105 MiniportQueryInformation(
106 IN NDIS_HANDLE MiniportAdapterContext,
107 IN NDIS_OID Oid,
108 IN PVOID InformationBuffer,
109 IN ULONG InformationBufferLength,
110 OUT PULONG BytesWritten,
111 OUT PULONG BytesNeeded);
112
113 NDIS_STATUS
114 NTAPI
115 MiniportSetInformation(
116 IN NDIS_HANDLE MiniportAdapterContext,
117 IN NDIS_OID Oid,
118 IN PVOID InformationBuffer,
119 IN ULONG InformationBufferLength,
120 OUT PULONG BytesRead,
121 OUT PULONG BytesNeeded);
122
123 NDIS_STATUS
124 NTAPI
125 MiSetMulticast(
126 PADAPTER Adapter,
127 UCHAR *Addresses,
128 UINT AddressCount);
129
130 NDIS_MEDIA_STATE
131 NTAPI
132 MiGetMediaState(PADAPTER Adapter);
133
134 UINT
135 NTAPI
136 MiGetMediaSpeed(PADAPTER Adapter);
137
138 BOOLEAN
139 NTAPI
140 MiGetMediaDuplex(PADAPTER Adapter);
141
142 /* operational constants */
143 #define NUMBER_OF_BUFFERS 0x20
144 #define LOG_NUMBER_OF_BUFFERS 5 /* log2(NUMBER_OF_BUFFERS) */
145 #define BUFFER_SIZE 0x600
146 #define MAX_MULTICAST_ADDRESSES 32
147 #define MEDIA_DETECTION_INTERVAL 5000
148
149 /* flags */
150 #define RESET_IN_PROGRESS 0x1
151
152 #if DBG
153 #define BREAKPOINT DbgBreakPoint();
154 #else
155 #define BREAKPOINT
156 #endif
157
158 /* memory pool tag */
159 #define PCNET_TAG 'tNcP'
160
161 #endif // _PCNET_H_
162