xref: /reactos/drivers/network/dd/rtl8139/nic.h (revision 3e1f4074)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS Realtek 8139 driver
4  * FILE:        rtl8139.h
5  * PURPOSE:     RTL8139 driver definitions
6  */
7 
8 #ifndef _RTL8139_PCH_
9 #define _RTL8139_PCH_
10 
11 #include <ndis.h>
12 
13 #include "rtlhw.h"
14 
15 #define ADAPTER_TAG 'Altr'
16 #define RESOURCE_LIST_TAG 'Rltr'
17 
18 #define MAX_RESET_ATTEMPTS 25
19 #define RECEIVE_BUFFER_SIZE      (32768)
20 // The full receive window requires 16 bytes of padding
21 // plus 2048 for receive overflows (because of WRAP)
22 #define FULL_RECEIVE_BUFFER_SIZE (32768 + 16 + 2048)
23 #define RECV_CRC_LENGTH 4
24 
25 #define MINIMUM_FRAME_SIZE 60
26 #define MAXIMUM_FRAME_SIZE 1514
27 
28 #define DRIVER_VERSION 1
29 
30 // 1/2 packet early RX, 512 byte FIFO threshold, 32K RX buffer, unlimited DMA bursts, WRAP
31 #define RC_VAL (0x800B780)
32 
33 // 2048 byte DMA bursts
34 #define TC_VAL (0x700)
35 
36 typedef struct _RTL_ADAPTER {
37     NDIS_HANDLE MiniportAdapterHandle;
38     NDIS_SPIN_LOCK Lock;
39 
40     ULONG IoRangeStart;
41     ULONG IoRangeLength;
42 
43     ULONG InterruptVector;
44     ULONG InterruptLevel;
45     BOOLEAN InterruptShared;
46     ULONG InterruptFlags;
47 
48     PUCHAR IoBase;
49     NDIS_MINIPORT_INTERRUPT Interrupt;
50     BOOLEAN InterruptRegistered;
51 
52     UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH];
53     UCHAR CurrentMacAddress[IEEE_802_ADDR_LENGTH];
54     struct {
55         UCHAR MacAddress[IEEE_802_ADDR_LENGTH];
56     } MulticastList[MAXIMUM_MULTICAST_ADDRESSES];
57 
58     ULONG ReceiveBufferLength;
59     PUCHAR ReceiveBuffer;
60     NDIS_PHYSICAL_ADDRESS ReceiveBufferPa;
61     USHORT ReceiveOffset;
62 
63     ULONG LinkSpeedMbps;
64     ULONG MediaState;
65     BOOLEAN LinkChange;
66 
67     ULONG PacketFilter;
68 
69     USHORT InterruptMask;
70     USHORT InterruptPending;
71 
72     UCHAR DirtyTxDesc;
73     UCHAR CurrentTxDesc;
74     BOOLEAN TxFull;
75     PUCHAR RuntTxBuffers;
76     NDIS_PHYSICAL_ADDRESS RuntTxBuffersPa;
77 
78     ULONG ReceiveOk;
79     ULONG TransmitOk;
80     ULONG ReceiveError;
81     ULONG TransmitError;
82     ULONG ReceiveNoBufferSpace;
83     ULONG ReceiveCrcError;
84     ULONG ReceiveAlignmentError;
85     ULONG TransmitOneCollision;
86     ULONG TransmitMoreCollisions;
87 
88 } RTL_ADAPTER, *PRTL_ADAPTER;
89 
90 NDIS_STATUS
91 NTAPI
92 NICPowerOn (
93     IN PRTL_ADAPTER Adapter
94     );
95 
96 NDIS_STATUS
97 NTAPI
98 NICSoftReset (
99     IN PRTL_ADAPTER Adapter
100     );
101 
102 NDIS_STATUS
103 NTAPI
104 NICRegisterReceiveBuffer (
105     IN PRTL_ADAPTER Adapter
106     );
107 
108 NDIS_STATUS
109 NTAPI
110 NICRemoveReceiveBuffer (
111     IN PRTL_ADAPTER Adapter
112     );
113 
114 NDIS_STATUS
115 NTAPI
116 NICEnableTxRx (
117     IN PRTL_ADAPTER Adapter
118     );
119 
120 NDIS_STATUS
121 NTAPI
122 NICGetPermanentMacAddress (
123     IN PRTL_ADAPTER Adapter,
124     OUT PUCHAR MacAddress
125     );
126 
127 NDIS_STATUS
128 NTAPI
129 NICApplyPacketFilter (
130     IN PRTL_ADAPTER Adapter
131     );
132 
133 NDIS_STATUS
134 NTAPI
135 NICApplyInterruptMask (
136     IN PRTL_ADAPTER Adapter
137     );
138 
139 NDIS_STATUS
140 NTAPI
141 NICDisableInterrupts (
142     IN PRTL_ADAPTER Adapter
143     );
144 
145 USHORT
146 NTAPI
147 NICInterruptRecognized (
148     IN PRTL_ADAPTER Adapter,
149     OUT PBOOLEAN InterruptRecognized
150     );
151 
152 VOID
153 NTAPI
154 NICAcknowledgeInterrupts (
155     IN PRTL_ADAPTER Adapter
156     );
157 
158 VOID
159 NTAPI
160 NICUpdateLinkStatus (
161     IN PRTL_ADAPTER Adapter
162     );
163 
164 NDIS_STATUS
165 NTAPI
166 NICTransmitPacket (
167     IN PRTL_ADAPTER Adapter,
168     IN UCHAR TxDesc,
169     IN ULONG PhysicalAddress,
170     IN ULONG Length
171     );
172 
173 NDIS_STATUS
174 NTAPI
175 MiniportSetInformation (
176     IN NDIS_HANDLE MiniportAdapterContext,
177     IN NDIS_OID Oid,
178     IN PVOID InformationBuffer,
179     IN ULONG InformationBufferLength,
180     OUT PULONG BytesRead,
181     OUT PULONG BytesNeeded
182     );
183 
184 NDIS_STATUS
185 NTAPI
186 MiniportQueryInformation (
187     IN NDIS_HANDLE MiniportAdapterContext,
188     IN NDIS_OID Oid,
189     IN PVOID InformationBuffer,
190     IN ULONG InformationBufferLength,
191     OUT PULONG BytesWritten,
192     OUT PULONG BytesNeeded
193     );
194 
195 VOID
196 NTAPI
197 MiniportISR (
198     OUT PBOOLEAN InterruptRecognized,
199     OUT PBOOLEAN QueueMiniportHandleInterrupt,
200     IN NDIS_HANDLE MiniportAdapterContext
201     );
202 
203 VOID
204 NTAPI
205 MiniportHandleInterrupt (
206     IN NDIS_HANDLE MiniportAdapterContext
207     );
208 
209 #endif /* _RTL8139_PCH_ */
210