ReactOS 0.4.16-dev-336-gb667d82
info.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Intel PRO/1000 Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Miniport information callbacks
5 * COPYRIGHT: 2013 Cameron Gutman (cameron.gutman@reactos.org)
6 * 2018 Mark Jansen (mark.jansen@reactos.org)
7 */
8
9#include "nic.h"
10
11#include <debug.h>
12
14{
40
41 /* Statistics */
47
49};
50
51static
54 _In_ PE1000_ADAPTER Adapter,
55 _In_ NDIS_OID Oid)
56{
57 /* TODO */
58 return 0;
59}
60
61static
64 _In_ PE1000_ADAPTER Adapter,
66{
67 /* TODO */
69}
70
74 IN NDIS_HANDLE MiniportAdapterContext,
75 IN NDIS_OID Oid,
76 IN PVOID InformationBuffer,
77 IN ULONG InformationBufferLength,
79 OUT PULONG BytesNeeded)
80{
81 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
82 ULONG copyLength;
83 PVOID copySource;
85 union _GENERIC_INFORMATION
86 {
89 ULONG64 Ulong64;
90 NDIS_MEDIUM Medium;
91 NDIS_PNP_CAPABILITIES PmCapabilities;
92 } GenericInfo;
93
95 copySource = &GenericInfo;
96 copyLength = sizeof(ULONG);
97
98 switch (Oid)
99 {
101 copySource = (PVOID)&SupportedOidList;
102 copyLength = sizeof(SupportedOidList);
103 break;
104
106 GenericInfo.Ulong = Adapter->PacketFilter;
107 break;
108
111 GenericInfo.Ulong = (ULONG)NdisHardwareStatusReady; //FIXME
112 break;
113
116 {
117 GenericInfo.Medium = NdisMedium802_3;
118 copyLength = sizeof(NDIS_MEDIUM);
119 break;
120 }
121
127 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER);
128 break;
129
131 copySource = Adapter->MulticastList;
132 copyLength = Adapter->MulticastListSize * IEEE_802_ADDR_LENGTH;
133 break;
134
136 GenericInfo.Ulong = MAXIMUM_MULTICAST_ADDRESSES;
137 break;
138
140 GenericInfo.Ulong = Adapter->LinkSpeedMbps * 10000;
141 break;
142
144 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE;
145 break;
146
148 GenericInfo.Ulong = RECEIVE_BUFFER_SIZE;
149 break;
150
152 /* The 3 bytes of the MAC address is the vendor ID */
153 GenericInfo.Ulong = 0;
154 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[0] << 16);
155 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[1] << 8);
156 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[2] & 0xFF);
157 break;
158
160 {
161 static UCHAR vendorDesc[] = "ReactOS Team";
162 copySource = vendorDesc;
163 copyLength = sizeof(vendorDesc);
164 break;
165 }
166
168 GenericInfo.Ulong = DRIVER_VERSION;
169 break;
170
172 {
173 copyLength = sizeof(USHORT);
174 GenericInfo.Ushort = (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
175 break;
176 }
177
179 GenericInfo.Ulong = MAXIMUM_FRAME_SIZE;
180 break;
181
183 GenericInfo.Ulong = 1;
184 break;
185
187 GenericInfo.Ulong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
191 break;
192
194 GenericInfo.Ulong = Adapter->MediaState;
195 break;
196
198 copySource = Adapter->MulticastList[0].MacAddress;
199 copyLength = IEEE_802_ADDR_LENGTH;
200 break;
201
203 copySource = Adapter->PermanentMacAddress;
204 copyLength = IEEE_802_ADDR_LENGTH;
205 break;
206
207 case OID_GEN_XMIT_OK:
208 case OID_GEN_RCV_OK:
212 {
213 GenericInfo.Ulong64 = NICQueryStatisticCounter(Adapter, Oid);
214
215 *BytesNeeded = sizeof(ULONG64);
216 if (InformationBufferLength >= sizeof(ULONG64))
217 {
218 *BytesWritten = sizeof(ULONG64);
219 NdisMoveMemory(InformationBuffer, copySource, sizeof(ULONG64));
220 }
221 else if (InformationBufferLength >= sizeof(ULONG))
222 {
223 *BytesWritten = sizeof(ULONG);
224 NdisMoveMemory(InformationBuffer, copySource, sizeof(ULONG));
225 }
226 else
227 {
228 *BytesWritten = 0;
230 }
231 return NDIS_STATUS_SUCCESS;
232 }
233
235 {
236 copyLength = sizeof(NDIS_PNP_CAPABILITIES);
237
238 status = NICFillPowerManagementCapabilities(Adapter, &GenericInfo.PmCapabilities);
239 break;
240 }
241
242 default:
243 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
245 break;
246 }
247
249 {
250 if (copyLength > InformationBufferLength)
251 {
252 *BytesNeeded = copyLength;
253 *BytesWritten = 0;
255 }
256 else
257 {
258 NdisMoveMemory(InformationBuffer, copySource, copyLength);
259 *BytesWritten = copyLength;
260 *BytesNeeded = copyLength;
261 }
262 }
263 else
264 {
265 *BytesWritten = 0;
266 *BytesNeeded = 0;
267 }
268
269 NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x(%s): Completed with status 0x%x (%d, %d)\n",
270 Oid, Oid2Str(Oid), status, *BytesWritten, *BytesNeeded));
271 return status;
272}
273
275NTAPI
277 IN NDIS_HANDLE MiniportAdapterContext,
278 IN NDIS_OID Oid,
279 IN PVOID InformationBuffer,
280 IN ULONG InformationBufferLength,
282 OUT PULONG BytesNeeded)
283{
284 PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
285 ULONG genericUlong;
287
289
290 switch (Oid)
291 {
293 if (InformationBufferLength < sizeof(ULONG))
294 {
295 *BytesRead = 0;
296 *BytesNeeded = sizeof(ULONG);
298 break;
299 }
300
301 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
302
303 if (genericUlong &
310 {
311 *BytesRead = sizeof(ULONG);
312 *BytesNeeded = sizeof(ULONG);
314 break;
315 }
316
317 if (Adapter->PacketFilter == genericUlong)
318 {
319 break;
320 }
321
322 Adapter->PacketFilter = genericUlong;
323
324 status = NICApplyPacketFilter(Adapter);
326 {
327 NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter (0x%x)\n", status));
328 break;
329 }
330
331 break;
332
334 if (InformationBufferLength < sizeof(ULONG))
335 {
336 *BytesRead = 0;
337 *BytesNeeded = sizeof(ULONG);
339 break;
340 }
341
342 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
343
344 if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
345 {
347 }
348 else
349 {
350 // Ignore this...
351 }
352
353 break;
354
356 if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
357 {
358 *BytesRead = 0;
359 *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
361 break;
362 }
363
364 if (InformationBufferLength > sizeof(Adapter->MulticastList))
365 {
366 *BytesNeeded = sizeof(Adapter->MulticastList);
367 *BytesRead = 0;
369 break;
370 }
371
372 NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
373
374 Adapter->MulticastListSize = InformationBufferLength / IEEE_802_ADDR_LENGTH;
375
376 NICUpdateMulticastList(Adapter);
377 break;
378
379 default:
380 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
382 *BytesRead = 0;
383 *BytesNeeded = 0;
384 break;
385 }
386
388 {
389 *BytesRead = InformationBufferLength;
390 *BytesNeeded = 0;
391 }
392
393 return status;
394}
395
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:724
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:693
static NDIS_OID SupportedOidList[]
Definition: info.c:13
NDIS_STATUS NTAPI MiniportSetInformation(IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesRead, OUT PULONG BytesNeeded)
Definition: info.c:276
static ULONG64 NICQueryStatisticCounter(_In_ PE1000_ADAPTER Adapter, _In_ NDIS_OID Oid)
Definition: info.c:53
NDIS_STATUS NTAPI MiniportQueryInformation(IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
Definition: info.c:73
static NDIS_STATUS NICFillPowerManagementCapabilities(_In_ PE1000_ADAPTER Adapter, _Out_ PNDIS_PNP_CAPABILITIES Capabilities)
Definition: info.c:63
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
struct _E1000_ADAPTER * PE1000_ADAPTER
#define RECEIVE_BUFFER_SIZE
Definition: nic.h:20
#define DRIVER_VERSION
Definition: nic.h:22
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
unsigned __int64 ULONG64
Definition: imports.h:198
#define NDIS_PACKET_TYPE_PROMISCUOUS
Definition: ndis.h:668
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NDIS_STATUS_BUFFER_TOO_SHORT
Definition: ndis.h:487
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
#define NDIS_PACKET_TYPE_ALL_MULTICAST
Definition: ndis.h:665
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
#define NDIS_STATUS_MULTICAST_FULL
Definition: ndis.h:473
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:267
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:244
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
struct _NDIS_PNP_CAPABILITIES NDIS_PNP_CAPABILITIES
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
@ NdisMedium802_3
Definition: ntddndis.h:188
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_RCV_OK
Definition: ntddndis.h:268
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
int NDIS_STATUS
Definition: ntddndis.h:475
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#define OID_PNP_CAPABILITIES
Definition: ntddndis.h:360
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:245
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:233
ULONG NDIS_OID
Definition: ntddndis.h:230
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
unsigned short USHORT
Definition: pedump.c:61
Definition: lan.h:33
ULONG LinkSpeedMbps
Definition: nic.h:49
ULONG PacketFilter
Definition: nic.h:51
ULONG MediaState
Definition: nic.h:50
ULONG MulticastListSize
Definition: nic.h:47
struct _E1000_ADAPTER::@1001 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:42
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
unsigned short Ushort
Definition: utypes.h:44
unsigned long Ulong
Definition: utypes.h:42
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
unsigned char UCHAR
Definition: xmlstorage.h:181