TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbRndis.h
Go to the documentation of this file.
1
8#ifndef USB_RNDIS_H_
9#define USB_RNDIS_H_
10
13#include <Library/UefiLib.h>
15#include <Library/DebugLib.h>
18#include <Library/UefiUsbLib.h>
19#include <Protocol/UsbIo.h>
21
23
24typedef struct {
25 UINT32 Signature;
27 EFI_HANDLE UsbCdcDataHandle;
28 EFI_HANDLE UsbRndisHandle;
30 EFI_USB_IO_PROTOCOL *UsbIoCdcData;
32 UINT8 NumOfInterface;
33 UINT8 BulkInEndpoint;
34 UINT8 BulkOutEndpoint;
35 UINT8 InterrupEndpoint;
36 EFI_MAC_ADDRESS MacAddress;
37 UINT32 RequestId;
38 UINT32 Medium;
39 UINT32 MaxPacketsPerTransfer;
40 UINT32 MaxTransferSize;
41 UINT32 PacketAlignmentFactor;
42 LIST_ENTRY ReceivePacketList;
44
45#define USB_RNDIS_DRIVER_VERSION 1
46#define USB_TX_ETHERNET_BULK_TIMEOUT 3000
47#define USB_RX_ETHERNET_BULK_TIMEOUT 3
48#define USB_ETHERNET_TRANSFER_TIMEOUT 200
49
50#define LAN_BULKIN_CMD_CONTROL 1
51#define MAXIMUM_STOPBULKIN_CNT 300 // Indicating maximum counts for waiting bulk in command
52#define MINIMUM_STOPBULKIN_CNT 3 // Indicating minimum counts for waiting bulk in command
53#define BULKIN_CMD_POLLING_CNT 300 // Indicating the waiting counts for send bulk in command when system pending
54#define RNDIS_RESERVED_BYTE_LENGTH 8
55
56#define USB_RNDIS_SIGNATURE SIGNATURE_32('r', 'n', 'd', 's')
57#define USB_RNDIS_DEVICE_FROM_THIS(a) CR (a, USB_RNDIS_DEVICE, UsbEth, USB_RNDIS_SIGNATURE)
58
59extern EFI_COMPONENT_NAME2_PROTOCOL gUsbRndisComponentName2;
60
61typedef struct {
62 UINT16 Src;
63 UINT16 Dst;
64} BIT_MAP;
65
67EFIAPI
70 IN EFI_HANDLE ControllerHandle,
71 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
72 );
73
75EFIAPI
78 IN EFI_HANDLE ControllerHandle,
79 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
80 );
81
83EFIAPI
86 IN EFI_HANDLE ControllerHandle,
87 IN UINTN NumberOfChildren,
88 IN EFI_HANDLE *ChildHandleBuffer
89 );
90
95 );
96
97BOOLEAN
100 IN OUT UINTN *Offset
101 );
102
106 IN UINT8 FunDescriptorType,
107 OUT VOID *DataBuffer
108 );
109
110VOID
112 IN EFI_USB_IO_PROTOCOL *UsbIo,
113 IN OUT USB_RNDIS_DEVICE *UsbRndisDevice
114 );
115
117EFIAPI
120 IN BOOLEAN IsNewTransfer,
121 IN UINTN PollingInterval,
123 );
124
126EFIAPI
128 IN VOID *Data,
129 IN UINTN DataLength,
130 IN VOID *Context,
131 IN UINT32 Status
132 );
133
135EFIAPI
138 OUT EFI_MAC_ADDRESS *MacAddress
139 );
140
142EFIAPI
145 OUT UINTN *BulkSize
146 );
147
149EFIAPI
151 IN PXE_CDB *Cdb,
152 IN NIC_DATA *Nic
153 );
154
156EFIAPI
158 IN PXE_CDB *Cdb,
159 IN NIC_DATA *Nic
160 );
161
163EFIAPI
165 IN PXE_CDB *Cdb,
166 IN NIC_DATA *Nic
167 );
168
170EFIAPI
172 IN PXE_CDB *Cdb,
173 IN NIC_DATA *Nic
174 );
175
177EFIAPI
179 IN PXE_CDB *Cdb,
180 IN NIC_DATA *Nic
181 );
182
184EFIAPI
186 IN PXE_CDB *Cdb,
187 IN NIC_DATA *Nic
188 );
189
191EFIAPI
193 IN PXE_CDB *Cdb,
195 IN VOID *BulkOutData,
196 IN OUT UINTN *DataLength
197 );
198
200EFIAPI
202 IN PXE_CDB *Cdb,
204 IN OUT VOID *BulkInData,
205 IN OUT UINTN *DataLength
206 );
207
209EFIAPI
211 IN PXE_CDB *Cdb,
212 IN NIC_DATA *Nic
213 );
214
216EFIAPI
218 IN PXE_CDB *Cdb,
219 IN NIC_DATA *Nic
220 );
221
223EFIAPI
225 IN PXE_CDB *Cdb,
226 IN NIC_DATA *Nic
227 );
228
230EFIAPI
232 IN PXE_CDB *Cdb,
233 IN NIC_DATA *Nic
234 );
235
237EFIAPI
240 OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor
241 );
242
244EFIAPI
247 OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor
248 );
249
251EFIAPI
254 OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor
255 );
256
258EFIAPI
261 IN UINT16 Value,
262 IN VOID *McastAddr
263 );
264
266EFIAPI
269 IN UINT16 Value,
270 IN UINT16 Length,
271 IN VOID *PatternFilter
272 );
273
275EFIAPI
276GetUsbRndisPowerFilter (
278 IN UINT16 Value,
279 IN BOOLEAN *PatternActive
280 );
281
283EFIAPI
286 IN UINT16 Value
287 );
288
290EFIAPI
291GetRndisStatistic (
293 IN UINT16 Value,
294 IN VOID *Statistic
295 );
296
299 IN USB_RNDIS_DEVICE *UsbRndisDevice,
300 IN REMOTE_NDIS_MSG_HEADER *RndisMsg,
301 OUT REMOTE_NDIS_MSG_HEADER *RndisMsgResponse
302 );
303
305RndisTransmitDataMsg (
306 IN USB_RNDIS_DEVICE *UsbRndisDevice,
307 IN REMOTE_NDIS_MSG_HEADER *RndisMsg,
308 UINTN *TransferLength
309 );
310
312RndisReceiveDataMsg (
313 IN USB_RNDIS_DEVICE *UsbRndisDevice,
314 IN REMOTE_NDIS_MSG_HEADER *RndisMsg,
315 UINTN *TransferLength
316 );
317
318VOID
320 IN REMOTE_NDIS_MSG_HEADER *RndisMsg
321 );
322
323#define RNDIS_MAJOR_VERSION 0x00000001
324#define RNDIS_MINOR_VERSION 0x00000000
325#define RNDIS_MAX_TRANSFER_SIZE 0x4000
326
327#define RNDIS_PACKET_MSG 0x00000001
328#define RNDIS_INITIALIZE_MSG 0x00000002
329#define RNDIS_INITIALIZE_CMPLT 0x80000002
330#define RNDIS_HLT_MSG 0x00000003
331#define RNDIS_QUERY_MSG 0x00000004
332#define RNDIS_QUERY_CMPLT 0x80000004
333#define RNDIS_SET_MSG 0x00000005
334#define RNDIS_SET_CMPLT 0x80000005
335#define RNDIS_RESET_MSG 0x00000006
336#define RNDIS_RESET_CMPLT 0x80000006
337#define RNDIS_INDICATE_STATUS_MSG 0x00000007
338#define RNDIS_KEEPALIVE_MSG 0x00000008
339#define RNDIS_KEEPALIVE_CMPLT 0x80000008
340
341#define RNDIS_STATUS_SUCCESS 0x00000000
342#define RNDIS_STATUS_FAILURE 0xC0000001
343#define RNDIS_STATUS_INVALID_DATA 0xC0010015
344#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BB
345#define RNDIS_STATUS_MEDIA_CONNECT 0x4001000B
346#define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000C
347
348#define RNDIS_CONTROL_TIMEOUT 10000 // 10sec
349#define RNDIS_KEEPALIVE_TIMEOUT 5000 // 5sec
350
351#define SEND_ENCAPSULATED_COMMAND 0x00000000
352#define GET_ENCAPSULATED_RESPONSE 0x00000001
353
354//
355// General Objects
356//
357// Taken from NTDDNDIS.H
358#define OID_GEN_SUPPORTED_LIST 0x00010101
359#define OID_GEN_HARDWARE_STATUS 0x00010102
360#define OID_GEN_MEDIA_SUPPORTED 0x00010103
361#define OID_GEN_MEDIA_IN_USE 0x00010104
362#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
363#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
364#define OID_GEN_LINK_SPEED 0x00010107
365#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
366#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
367#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
368#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
369#define OID_GEN_VENDOR_ID 0x0001010C
370#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D
371#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
372#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
373#define OID_GEN_DRIVER_VERSION 0x00010110
374#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
375#define OID_GEN_PROTOCOL_OPTIONS 0x00010112
376#define OID_GEN_MAC_OPTIONS 0x00010113
377#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
378#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
379#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
380
381#define OID_GEN_XMIT_OK 0x00020101
382#define OID_GEN_RCV_OK 0x00020102
383#define OID_GEN_XMIT_ERROR 0x00020103
384#define OID_GEN_RCV_ERROR 0x00020104
385#define OID_GEN_RCV_NO_BUFFER 0x00020105
386
387#define OID_GEN_DIRECTED_BYTES_XMIT 0x00020201
388#define OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202
389#define OID_GEN_MULTICAST_BYTES_XMIT 0x00020203
390#define OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204
391#define OID_GEN_BROADCAST_BYTES_XMIT 0x00020205
392#define OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206
393#define OID_GEN_DIRECTED_BYTES_RCV 0x00020207
394#define OID_GEN_DIRECTED_FRAMES_RCV 0x00020208
395#define OID_GEN_MULTICAST_BYTES_RCV 0x00020209
396#define OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A
397#define OID_GEN_BROADCAST_BYTES_RCV 0x0002020B
398#define OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C
399#define OID_GEN_RCV_CRC_ERROR 0x0002020D
400#define OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E
401
402#define OID_802_3_CURRENT_ADDRESS 0x01010102
403//
404// Ndis Packet Filter Bits (OID_GEN_CURRENT_PACKET_FILTER).
405//
406#define NDIS_PACKET_TYPE_DIRECTED 0x0001
407#define NDIS_PACKET_TYPE_MULTICAST 0x0002
408#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x0004
409#define NDIS_PACKET_TYPE_BROADCAST 0x0008
410#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x0010
411#define NDIS_PACKET_TYPE_PROMISCUOUS 0x0020
412#define NDIS_PACKET_TYPE_SMT 0x0040
413#define NDIS_PACKET_TYPE_ALL_LOCAL 0x0080
414#define NDIS_PACKET_TYPE_MAC_FRAME 0x8000
415#define NDIS_PACKET_TYPE_FUNCTIONAL 0x4000
416#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x2000
417#define NDIS_PACKET_TYPE_GROUP 0x1000
418
419#pragma pack(1)
420
422 UINT32 MessageType;
423 UINT32 MessageLength;
425
426typedef struct {
427 UINT32 MessageType;
428 UINT32 MessageLength;
429 UINT32 RequestID;
430 UINT32 MajorVersion;
431 UINT32 MinorVersion;
432 UINT32 MaxTransferSize;
434
435typedef struct {
436 UINT32 MessageType;
437 UINT32 MessageLength;
438 UINT32 RequestID;
440
441typedef struct {
442 UINT32 MessageType;
443 UINT32 MessageLength;
444 UINT32 RequestID;
445 UINT32 Oid;
446 UINT32 InformationBufferLength;
447 UINT32 InformationBufferOffset;
448 UINT32 Reserved;
450
451typedef struct {
452 REMOTE_NDIS_QUERY_MSG QueryMsg;
453 UINT8 Addr[6];
455
456typedef struct {
457 REMOTE_NDIS_QUERY_MSG QueryMsg;
458 UINT32 MaxTotalSize;
460
461typedef struct {
462 UINT32 MessageType;
463 UINT32 MessageLength;
464 UINT32 RequestID;
465 UINT32 Oid;
466 UINT32 InformationBufferLength;
467 UINT32 InformationBufferOffset;
468 UINT32 Reserved;
470
471typedef struct {
472 UINT32 MessageType;
473 UINT32 MessageLength;
474 UINT32 Reserved;
476
477typedef struct {
478 UINT32 MessageType;
479 UINT32 MessageLength;
480 UINT32 Status;
481 UINT32 StatusBufferLength;
482 UINT32 StatusBufferOffset;
484
485typedef struct {
486 UINT32 DiagStatus;
487 UINT32 ErrorOffset;
489
490typedef struct {
491 UINT32 MessageType;
492 UINT32 MessageLength;
493 UINT32 RequestID;
495
496typedef struct {
497 UINT32 MessageType;
498 UINT32 MessageLength;
499 UINT32 RequestID;
500 UINT32 Status;
501 UINT32 MajorVersion;
502 UINT32 MinorVersion;
503 UINT32 DeviceFlags;
504 UINT32 Medium;
505 UINT32 MaxPacketsPerTransfer;
506 UINT32 MaxTransferSize;
507 UINT32 PacketAlignmentFactor;
508 UINT64 Reserved;
510
511typedef struct {
512 UINT32 MessageType;
513 UINT32 MessageLength;
514 UINT32 RequestID;
515 UINT32 Status;
516 UINT32 InformationBufferLength;
517 UINT32 InformationBufferOffset;
519
520typedef struct {
521 REMOTE_NDIS_QUERY_CMPLT QueryCmplt;
522 UINT8 Addr[6];
524
525typedef struct {
526 REMOTE_NDIS_QUERY_CMPLT QueryCmplt;
527 UINT32 MaxTotalSize;
529
530typedef struct {
531 UINT32 MessageType;
532 UINT32 MessageLength;
533 UINT32 RequestID;
534 UINT32 Status;
536
537typedef struct {
538 UINT32 MessageType;
539 UINT32 MessageLength;
540 UINT32 Status;
541 UINT32 AddressingReset;
543
544typedef struct {
545 UINT32 MessageType;
546 UINT32 MessageLength;
547 UINT32 RequestID;
548 UINT32 Status;
550
551typedef struct {
552 UINT32 MessageType;
553 UINT32 MessageLength;
554 UINT32 DataOffset;
555 UINT32 DataLength;
556 UINT32 OutOfBandDataOffset;
557 UINT32 OutOfBandDataLength;
558 UINT32 NumOutOfBandDataElements;
559 UINT32 PerPacketInfoOffset;
560 UINT32 PerPacketInfoLength;
561 UINT32 Reserved1;
562 UINT32 Reserved2;
564
565typedef struct {
566 UINT32 Size;
567 UINT32 Type;
568 UINT32 ClassInformationOffset;
570
571typedef struct {
572 UINT32 Size;
573 UINT32 Type;
574 UINT32 ClassInformationOffset;
576
577typedef struct {
578 LIST_ENTRY PacketList;
579 UINT8 *OrgBuffer;
580 UINTN RemainingLength;
581 UINT8 *PacketStartBuffer; // Variable size data to follow
583
584#pragma pack()
585
586#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_STATUS EFIAPI GetUsbEthMacAddress(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT EFI_MAC_ADDRESS *MacAddress)
EFI_STATUS EFIAPI InterruptCallback(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
EFI_STATUS GetFunctionalDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Config, IN UINT8 FunDescriptorType, OUT VOID *DataBuffer)
EFI_STATUS EFIAPI GetUsbRndisFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor)
EFI_STATUS EFIAPI RndisUndiShutdown(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiReceiveFilter(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI UsbRndisDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbRndis.c:470
EFI_STATUS EFIAPI RndisUndiStop(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiReceive(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *BulkInData, IN OUT UINTN *DataLength)
EFI_STATUS EFIAPI SetUsbRndisPacketFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value)
EFI_STATUS EFIAPI RndisUndiReset(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiGetConfigInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS LoadAllDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, OUT EFI_USB_CONFIG_DESCRIPTOR **ConfigDesc)
EFI_STATUS EFIAPI SetUsbRndisMcastFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN VOID *McastAddr)
EFI_STATUS EFIAPI UsbRndisDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbRndis.c:518
EFI_STATUS EFIAPI UsbRndisInterrupt(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Requst)
EFI_STATUS EFIAPI UsbEthBulkSize(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
EFI_STATUS EFIAPI RndisDummyReturn(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiGetStatus(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiInitialize(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI GetUsbHeaderFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor)
EFI_STATUS EFIAPI RndisUndiGetInitInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS RndisControlMsg(IN USB_RNDIS_DEVICE *UsbRndisDevice, IN REMOTE_NDIS_MSG_HEADER *RndisMsg, OUT REMOTE_NDIS_MSG_HEADER *RndisMsgResponse)
EFI_STATUS EFIAPI RndisUndiStart(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiTransmit(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN VOID *BulkOutData, IN OUT UINTN *DataLength)
EFI_STATUS EFIAPI SetUsbRndisPowerFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN UINT16 Length, IN VOID *PatternFilter)
VOID PrintRndisMsg(IN REMOTE_NDIS_MSG_HEADER *RndisMsg)
VOID GetEndpoint(IN EFI_USB_IO_PROTOCOL *UsbIo, IN OUT USB_RNDIS_DEVICE *UsbRndisDevice)
EFI_STATUS EFIAPI UsbRndisDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UsbRndis.c:795
EFI_STATUS EFIAPI GetUsbUnionFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
BOOLEAN NextDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Desc, IN OUT UINTN *Offset)