TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbEthernetProtocol.h
Go to the documentation of this file.
1
9#ifndef USB_ETHERNET_PROTOCOL_H_
10#define USB_ETHERNET_PROTOCOL_H_
11
12#define EDKII_USB_ETHERNET_PROTOCOL_GUID \
13 {0x8d8969cc, 0xfeb0, 0x4303, {0xb2, 0x1a, 0x1f, 0x11, 0x6f, 0x38, 0x56, 0x43}}
14
16
17#define USB_CDC_CLASS 0x02
18#define USB_CDC_ACM_SUBCLASS 0x02
19#define USB_CDC_ECM_SUBCLASS 0x06
20#define USB_CDC_NCM_SUBCLASS 0x0D
21#define USB_CDC_DATA_CLASS 0x0A
22#define USB_CDC_DATA_SUBCLASS 0x00
23#define USB_NO_CLASS_PROTOCOL 0x00
24#define USB_NCM_NTB_PROTOCOL 0x01
25#define USB_VENDOR_PROTOCOL 0xFF
26
27#define USB_MISC_CLASS 0xEF
28#define USB_RNDIS_SUBCLASS 0x04
29#define USB_RNDIS_ETHERNET_PROTOCOL 0x01
30
31// Descriptor SubType in Functional Descriptors
32#define HEADER_FUN_DESCRIPTOR 0x00
33#define UNION_FUN_DESCRIPTOR 0x06
34#define ETHERNET_FUN_DESCRIPTOR 0x0F
35
36#define MAX_LAN_INTERFACE 0x10
37
38// Table 20: Class-Specific Notification Codes
39#define USB_CDC_NETWORK_CONNECTION 0x00
40
41// 6.3.1 NetworkConnection
42#define NETWORK_CONNECTED 0x01
43#define NETWORK_DISCONNECT 0x00
44
45#define MAC_FILTERS_MASK 0x7FFF
46
47// USB Header functional Descriptor
48typedef struct {
49 UINT8 FunctionLength;
50 UINT8 DescriptorType;
51 UINT8 DescriptorSubtype;
52 UINT16 BcdCdc;
54
55// USB Union Functional Descriptor
56typedef struct {
57 UINT8 FunctionLength;
58 UINT8 DescriptorType;
59 UINT8 DescriptorSubtype;
60 UINT8 MasterInterface;
61 UINT8 SlaveInterface;
63
64// USB Ethernet Functional Descriptor
65typedef struct {
66 UINT8 FunctionLength;
67 UINT8 DescriptorType;
68 UINT8 DescriptorSubtype;
69 UINT8 MacAddress;
70 UINT32 EthernetStatistics;
71 UINT16 MaxSegmentSize;
72 UINT16 NumberMcFilters;
73 UINT8 NumberPowerFilters;
75
76typedef struct {
77 UINT32 UsBitRate;
78 UINT32 DsBitRate;
80
81// Request Type Codes for USB Ethernet
82#define USB_ETHERNET_GET_REQ_TYPE 0xA1
83#define USB_ETHERNET_SET_REQ_TYPE 0x21
84
85// Class-Specific Request Codes for Ethernet subclass
86// USB ECM 1.2 specification, Section 6.2
87#define SET_ETH_MULTICAST_FILTERS_REQ 0x40
88#define SET_ETH_POWER_MANAGEMENT_PATTERN_FILTER_REQ 0x41
89#define GET_ETH_POWER_MANAGEMENT_PATTERN_FILTER_REQ 0x42
90#define SET_ETH_PACKET_FILTER_REQ 0x43
91#define GET_ETH_STATISTIC_REQ 0x44
92
93// USB ECM command request length
94#define USB_ETH_POWER_FILTER_LENGTH 2 // Section 6.2.3
95#define USB_ETH_PACKET_FILTER_LENGTH 0 // Section 6.2.4
96#define USB_ETH_STATISTIC 4 // Section 6.2.5
97
98// USB Ethernet Packet Filter Bitmap
99// USB ECM 1.2 specification, Section 6.2.4
100#define USB_ETH_PACKET_TYPE_PROMISCUOUS BIT0
101#define USB_ETH_PACKET_TYPE_ALL_MULTICAST BIT1
102#define USB_ETH_PACKET_TYPE_DIRECTED BIT2
103#define USB_ETH_PACKET_TYPE_BROADCAST BIT3
104#define USB_ETH_PACKET_TYPE_MULTICAST BIT4
105
106// USB Ethernet Statistics Feature Selector Codes
107// USB ECM 1.2 specification, Section 6.2.5
108#define USB_ETH_XMIT_OK 0x01
109#define USB_ETH_RCV_OK 0x02
110#define USB_ETH_XMIT_ERROR 0x03
111#define USB_ETH_RCV_ERROR 0x04
112#define USB_ETH_RCV_NO_BUFFER 0x05
113#define USB_ETH_DIRECTED_BYTES_XMIT 0x06
114#define USB_ETH_DIRECTED_FRAMES_XMIT 0x07
115#define USB_ETH_MULTICAST_BYTES_XMIT 0x08
116#define USB_ETH_MULTICAST_FRAMES_XMIT 0x09
117#define USB_ETH_BROADCAST_BYTES_XMIT 0x0A
118#define USB_ETH_BROADCAST_FRAMES_XMIT 0x0B
119#define USB_ETH_DIRECTED_BYTES_RCV 0x0C
120#define USB_ETH_DIRECTED_FRAMES_RCV 0x0D
121#define USB_ETH_MULTICAST_BYTES_RCV 0x0E
122#define USB_ETH_MULTICAST_FRAMES_RCV 0x0F
123#define USB_ETH_BROADCAST_BYTES_RCV 0x10
124#define USB_ETH_BROADCAST_FRAMES_RCV 0x11
125#define USB_ETH_RCV_CRC_ERROR 0x12
126#define USB_ETH_TRANSMIT_QUEUE_LENGTH 0x13
127#define USB_ETH_RCV_ERROR_ALIGNMENT 0x14
128#define USB_ETH_XMIT_ONE_COLLISION 0x15
129#define USB_ETH_XMIT_MORE_COLLISIONS 0x16
130#define USB_ETH_XMIT_DEFERRED 0x17
131#define USB_ETH_XMIT_MAX_COLLISIONS 0x18
132#define USB_ETH_RCV_OVERRUN 0x19
133#define USB_ETH_XMIT_UNDERRUN 0x1A
134#define USB_ETH_XMIT_HEARTBEAT_FAILURE 0x1B
135#define USB_ETH_XMIT_TIMES_CRS_LOST 0x1C
136#define USB_ETH_XMIT_LATE_COLLISIONS 0x1D
137
138// NIC Information
139typedef struct {
140 UINT32 Signature;
142 UINT16 InterrupOpFlag;
143 UINT64 MappedAddr;
144 PXE_MAC_ADDR McastList[MAX_MCAST_ADDRESS_CNT];
145 UINT8 McastCount;
146 UINT64 MediaHeader[MAX_XMIT_BUFFERS];
147 UINT8 TxBufferCount;
148 UINT16 State;
149 BOOLEAN CanTransmit;
150 UINT16 ReceiveStatus;
151 UINT8 RxFilter;
152 UINT32 RxFrame;
153 UINT32 TxFrame;
154 UINT16 NetworkConnect;
155 UINT8 CableDetect;
156 UINT16 MaxSegmentSize;
157 EFI_MAC_ADDRESS MacAddr;
160 UINT8 PermNodeAddress[PXE_MAC_LENGTH];
161 UINT8 CurrentNodeAddress[PXE_MAC_LENGTH];
162 UINT8 BroadcastNodeAddress[PXE_MAC_LENGTH];
164 EFI_EVENT RateLimiter;
165 UINT32 RateLimitingCredit;
166 UINT32 RateLimitingCreditCount;
167 UINT32 RateLimitingPollTimer;
168 BOOLEAN RateLimitingEnable;
169} NIC_DATA;
170
171#define NIC_DATA_SIGNATURE SIGNATURE_32('n', 'i', 'c', 'd')
172#define NIC_DATA_FROM_EDKII_USB_ETHERNET_PROTOCOL(a) CR (a, NIC_DATA, UsbEth, NIC_DATA_SIGNATURE)
173
186typedef
189 IN PXE_CDB *Cdb,
190 IN NIC_DATA *Nic
191 );
192
205typedef
208 IN PXE_CDB *Cdb,
209 IN NIC_DATA *Nic
210 );
211
224typedef
227 IN PXE_CDB *Cdb,
228 IN NIC_DATA *Nic
229 );
230
244typedef
247 IN PXE_CDB *Cdb,
248 IN NIC_DATA *Nic
249 );
250
264typedef
267 IN PXE_CDB *Cdb,
268 IN NIC_DATA *Nic
269 );
270
284typedef
287 IN PXE_CDB *Cdb,
288 IN NIC_DATA *Nic
289 );
290
304typedef
307 IN PXE_CDB *Cdb,
308 IN NIC_DATA *Nic
309 );
310
324typedef
327 IN PXE_CDB *Cdb,
328 IN NIC_DATA *Nic
329 );
330
344typedef
347 IN PXE_CDB *Cdb,
348 IN NIC_DATA *Nic
349 );
350
364typedef
367 IN PXE_CDB *Cdb,
368 IN NIC_DATA *Nic
369 );
370
384typedef
387 IN PXE_CDB *Cdb,
388 IN NIC_DATA *Nic
389 );
390
403typedef
406 IN PXE_CDB *Cdb,
407 IN NIC_DATA *Nic
408 );
409
422typedef
425 IN PXE_CDB *Cdb,
426 IN NIC_DATA *Nic
427 );
428
442typedef
445 IN PXE_CDB *Cdb,
446 IN NIC_DATA *Nic
447 );
448
462typedef
465 IN PXE_CDB *Cdb,
466 IN NIC_DATA *Nic
467 );
468
481typedef
484 IN PXE_CDB *Cdb,
485 IN NIC_DATA *Nic
486 );
487
500typedef
503 IN PXE_CDB *Cdb,
504 IN NIC_DATA *Nic
505 );
506
520typedef
523 IN PXE_CDB *Cdb,
524 IN NIC_DATA *Nic
525 );
526
540typedef
543 IN PXE_CDB *Cdb,
544 IN OUT NIC_DATA *Nic
545 );
546
560typedef
563 IN NIC_DATA *Nic,
564 IN UINT64 DbAddr,
565 IN UINT16 DbSize
566 );
567
583typedef
586 IN PXE_CDB *Cdb,
588 IN OUT VOID *Packet,
589 IN OUT UINTN *PacketLength
590 );
591
607typedef
610 IN PXE_CDB *Cdb,
612 IN OUT VOID *Packet,
613 IN OUT UINTN *PacketLength
614 );
615
633typedef
637 IN BOOLEAN IsNewTransfer,
638 IN UINTN PollingInterval,
640 );
641
652typedef
656 OUT EFI_MAC_ADDRESS *MacAddress
657 );
658
669typedef
673 OUT UINTN *BulkSize
674 );
675
686typedef
690 OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor
691 );
692
703typedef
707 OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor
708 );
709
720typedef
724 OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor
725 );
726
741typedef
745 IN UINT16 Value,
746 IN VOID *McastAddr
747 );
748
764typedef
768 IN UINT16 Value,
769 IN UINT16 Length,
770 IN VOID *PatternFilter
771 );
772
787typedef
791 IN UINT16 Value,
792 OUT BOOLEAN *PatternActive
793 );
794
807typedef
811 IN UINT16 Value
812 );
813
827typedef
831 IN UINT16 FeatureSelector,
832 OUT VOID *Statistic
833 );
834
835typedef struct {
836 EDKII_USB_ETHERNET_UNDI_GET_STATE UsbEthUndiGetState;
837 EDKII_USB_ETHERNET_UNDI_START UsbEthUndiStart;
838 EDKII_USB_ETHERNET_UNDI_STOP UsbEthUndiStop;
839 EDKII_USB_ETHERNET_UNDI_GET_INIT_INFO UsbEthUndiGetInitInfo;
840 EDKII_USB_ETHERNET_UNDI_GET_CONFIG_INFO UsbEthUndiGetConfigInfo;
841 EDKII_USB_ETHERNET_UNDI_INITIALIZE UsbEthUndiInitialize;
842 EDKII_USB_ETHERNET_UNDI_RESET UsbEthUndiReset;
843 EDKII_USB_ETHERNET_UNDI_SHUTDOWN UsbEthUndiShutdown;
844 EDKII_USB_ETHERNET_UNDI_INTERRUPT_ENABLE UsbEthUndiInterruptEnable;
845 EDKII_USB_ETHERNET_UNDI_RECEIVE_FILTER UsbEthUndiReceiveFilter;
846 EDKII_USB_ETHERNET_UNDI_STATION_ADDRESS UsbEthUndiStationAddress;
847 EDKII_USB_ETHERNET_UNDI_STATISTICS UsbEthUndiStatistics;
848 EDKII_USB_ETHERNET_UNDI_MCAST_IPTOMAC UsbEthUndiMcastIp2Mac;
849 EDKII_USB_ETHERNET_UNDI_NV_DATA UsbEthUndiNvData;
850 EDKII_USB_ETHERNET_UNDI_GET_STATUS UsbEthUndiGetStatus;
851 EDKII_USB_ETHERNET_UNDI_FILL_HEADER UsbEthUndiFillHeader;
852 EDKII_USB_ETHERNET_UNDI_TRANSMIT UsbEthUndiTransmit;
853 EDKII_USB_ETHERNET_UNDI_RECEIVE UsbEthUndiReceive;
855
856// The EDKII_USB_ETHERNET_PROTOCOL provides some basic USB Ethernet device relevant
857// descriptor and specific requests.
859 EDKII_USB_ETHERNET_UNDI UsbEthUndi;
860 // for calling the UNDI child functions
861 EDKII_USB_ETHERNET_INITIALIZE UsbEthInitialize;
862 EDKII_USB_ETHERNET_STATISTICS UsbEthStatistics;
863 EDKII_USB_ETHERNET_RECEIVE UsbEthReceive;
864 EDKII_USB_ETHERNET_TRANSMIT UsbEthTransmit;
865 EDKII_USB_ETHERNET_INTERRUPT UsbEthInterrupt;
866 EDKII_USB_GET_ETH_MAC_ADDRESS UsbEthMacAddress;
867 EDKII_USB_ETH_MAX_BULK_SIZE UsbEthMaxBulkSize;
868 EDKII_USB_HEADER_FUNCTIONAL_DESCRIPTOR UsbHeaderFunDescriptor;
869 EDKII_USB_UNION_FUNCTIONAL_DESCRIPTOR UsbUnionFunDescriptor;
874 EDKII_USB_ETHERNET_SET_ETH_PACKET_FILTER SetUsbEthPacketFilter;
875 EDKII_USB_ETHERNET_GET_ETH_STATISTIC GetUsbEthStatistic;
876};
877
878extern EFI_GUID gEdkIIUsbEthProtocolGuid;
879
880#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS PxeInit(SNP_DRIVER *Snp, UINT16 CableDetectFlag)
Definition: Initialize.c:24
EFI_STATUS PxeStart(IN SNP_DRIVER *Snp)
Definition: Start.c:21
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define MAX_XMIT_BUFFERS
recycling Q length for xmit_done.
Definition: UefiPxe.h:919
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_GET_INIT_INFO)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_RECEIVE_FILTER)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_FUNCTIONAL_DESCRIPTOR)(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_INITIALIZE)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_INTERRUPT)(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Request)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_TRANSMIT)(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS(EFIAPI * EDKII_USB_GET_ETH_MAC_ADDRESS)(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT EFI_MAC_ADDRESS *MacAddress)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_GET_ETH_POWER_MANAGE_PATTERN_FILTER)(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, OUT BOOLEAN *PatternActive)
EFI_STATUS(EFIAPI * EDKII_USB_UNION_FUNCTIONAL_DESCRIPTOR)(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_GET_STATE)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_STOP)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_RECEIVE)(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_SET_ETH_PACKET_FILTER)(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_NV_DATA)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_SET_ETH_MULTICAST_FILTERS)(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN VOID *McastAddr)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_START)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_HEADER_FUNCTIONAL_DESCRIPTOR)(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_INITIALIZE)(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETH_MAX_BULK_SIZE)(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_GET_ETH_STATISTIC)(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 FeatureSelector, OUT VOID *Statistic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_STATION_ADDRESS)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_TRANSMIT)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_RESET)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_GET_CONFIG_INFO)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_SHUTDOWN)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_SET_ETH_POWER_MANAGE_PATTERN_FILTER)(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN UINT16 Length, IN VOID *PatternFilter)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_GET_STATUS)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_MCAST_IPTOMAC)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_STATISTICS)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_INTERRUPT_ENABLE)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_STATISTICS)(IN NIC_DATA *Nic, IN UINT64 DbAddr, IN UINT16 DbSize)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_FILL_HEADER)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS(EFIAPI * EDKII_USB_ETHERNET_UNDI_RECEIVE)(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: Base.h:213