TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbNcmFunction.c
Go to the documentation of this file.
1
9#include "UsbCdcNcm.h"
10
30 )
31{
32 EFI_STATUS Status;
33 UINT32 TransStatus;
35
36 Status = UsbIo->UsbGetConfigDescriptor (UsbIo, &Tmp);
37 ASSERT_EFI_ERROR (Status);
38
39 Status = gBS->AllocatePool (EfiBootServicesData, Tmp.TotalLength, (VOID **)ConfigDesc);
40 ASSERT_EFI_ERROR (Status);
41
42 Status = UsbGetDescriptor (
43 UsbIo,
44 USB_DESC_TYPE_CONFIG << 8 | (Tmp.ConfigurationValue - 1), // zero based
45 0,
46 Tmp.TotalLength,
47 *ConfigDesc,
48 &TransStatus
49 );
50 return Status;
51}
52
64BOOLEAN
67 IN OUT UINTN *Offset
68 )
69{
70 if ((Desc == NULL) || (*Offset >= Desc->TotalLength)) {
71 return FALSE;
72 }
73
74 if (((EFI_USB_CONFIG_DESCRIPTOR *)((char *)Desc+*Offset))->Length == 0) {
75 return FALSE;
76 }
77
78 *Offset += ((EFI_USB_CONFIG_DESCRIPTOR *)((char *)Desc+*Offset))->Length;
79 if ( *Offset >= Desc->TotalLength ) {
80 return FALSE;
81 }
82
83 return TRUE;
84}
85
102 IN UINT8 FunDescriptorType,
103 OUT VOID *DataBuffer
104 )
105{
106 EFI_STATUS Status;
107 UINTN Offset;
109
110 Status = EFI_NOT_FOUND;
111
112 for (Offset = 0; NextDescriptor (Config, &Offset);) {
113 Interface = (EFI_USB_INTERFACE_DESCRIPTOR *)((UINT8 *)Config + Offset);
114 if (Interface->DescriptorType == USB_DESC_TYPE_CS_INTERFACE) {
115 if (((USB_HEADER_FUN_DESCRIPTOR *)Interface)->DescriptorSubtype == FunDescriptorType) {
116 switch (FunDescriptorType) {
117 case HEADER_FUN_DESCRIPTOR:
118 CopyMem (
119 DataBuffer,
120 (USB_HEADER_FUN_DESCRIPTOR *)Interface,
122 );
123 return EFI_SUCCESS;
124 case UNION_FUN_DESCRIPTOR:
125 CopyMem (
126 DataBuffer,
127 (USB_UNION_FUN_DESCRIPTOR *)Interface,
128 ((USB_UNION_FUN_DESCRIPTOR *)Interface)->FunctionLength
129 );
130 return EFI_SUCCESS;
131 case ETHERNET_FUN_DESCRIPTOR:
132 CopyMem (
133 DataBuffer,
134 (USB_ETHERNET_FUN_DESCRIPTOR *)Interface,
136 );
137 return EFI_SUCCESS;
138 default:
139 Status = EFI_UNSUPPORTED;
140 break;
141 }
142 }
143 }
144 }
145
146 return Status;
147}
148
156VOID
158 IN EFI_USB_IO_PROTOCOL *UsbIo,
159 IN OUT USB_ETHERNET_DRIVER *UsbEthDriver
160 )
161{
162 EFI_STATUS Status;
163 UINT8 Index;
164 UINT32 Result;
167
168 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface);
169 ASSERT_EFI_ERROR (Status);
170
171 if (Interface.NumEndpoints == 0) {
172 Status = UsbSetInterface (UsbIo, Interface.InterfaceNumber, 1, &Result);
173 ASSERT_EFI_ERROR (Status);
174
175 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface);
176 ASSERT_EFI_ERROR (Status);
177 }
178
179 for (Index = 0; Index < Interface.NumEndpoints; Index++) {
180 Status = UsbIo->UsbGetEndpointDescriptor (UsbIo, Index, &Endpoint);
181 ASSERT_EFI_ERROR (Status);
182
183 switch ((Endpoint.Attributes & (BIT0 | BIT1))) {
184 case USB_ENDPOINT_BULK:
185 if (Endpoint.EndpointAddress & BIT7) {
186 UsbEthDriver->BulkInEndpoint = Endpoint.EndpointAddress;
187 } else {
188 UsbEthDriver->BulkOutEndpoint = Endpoint.EndpointAddress;
189 }
190
191 break;
192 case USB_ENDPOINT_INTERRUPT:
193 UsbEthDriver->InterruptEndpoint = Endpoint.EndpointAddress;
194 break;
195 }
196 }
197}
198
216EFIAPI
218 IN PXE_CDB *Cdb,
220 IN OUT VOID *Packet,
221 IN OUT UINTN *PacketLength
222 )
223{
224 EFI_STATUS Status;
225 USB_ETHERNET_DRIVER *UsbEthDriver;
226 EFI_USB_IO_PROTOCOL *UsbIo;
227 UINT32 TransStatus;
228 UINT8 Index;
229 UINTN BulkDataLength;
230 UINTN TotalLength;
233 USB_NCM_DATA_GRAM *Datagram;
234
235 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
236 TotalLength = 0;
237
238 if (UsbEthDriver->TotalDatagram == UsbEthDriver->NowDatagram) {
239 Status = gBS->HandleProtocol (
240 UsbEthDriver->UsbCdcDataHandle,
241 &gEfiUsbIoProtocolGuid,
242 (VOID **)&UsbIo
243 );
244 if (EFI_ERROR (Status)) {
245 return Status;
246 }
247
248 if (UsbEthDriver->BulkInEndpoint == 0) {
249 GetEndpoint (UsbIo, UsbEthDriver);
250 }
251
252 BulkDataLength = USB_NCM_MAX_NTB_SIZE;
253 SetMem (UsbEthDriver->BulkBuffer, BulkDataLength, 0);
254 UsbEthDriver->NowDatagram = 0;
255 UsbEthDriver->TotalDatagram = 0;
256
257 Status = UsbIo->UsbBulkTransfer (
258 UsbIo,
259 UsbEthDriver->BulkInEndpoint,
260 UsbEthDriver->BulkBuffer,
261 &BulkDataLength,
262 USB_ETHERNET_BULK_TIMEOUT,
263 &TransStatus
264 );
265 if (EFI_ERROR (Status)) {
266 return Status;
267 }
268
269 Nth = (USB_NCM_TRANSFER_HEADER_16 *)UsbEthDriver->BulkBuffer;
270 Ndp = (USB_NCM_DATAGRAM_POINTER_16 *)((UINT8 *)UsbEthDriver->BulkBuffer + Nth->NdpIndex);
271 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Ndp + sizeof (USB_NCM_DATAGRAM_POINTER_16));
272 UsbEthDriver->TotalDatagram = (UINT8)((Ndp->Length - 8) / 4 - 1);
273
274 for (Index = 0; Index < UsbEthDriver->TotalDatagram; Index++) {
275 TotalLength += Datagram->DatagramLength;
276 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Datagram + sizeof (USB_NCM_DATA_GRAM));
277 }
278
279 if (TotalLength < USB_ETHERNET_FRAME_SIZE) {
280 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Ndp + sizeof (USB_NCM_DATAGRAM_POINTER_16));
281
282 TotalLength = 0;
283 for (Index = 0; Index < UsbEthDriver->TotalDatagram; Index++) {
284 CopyMem ((UINT8 *)Packet + TotalLength, (UINT8 *)UsbEthDriver->BulkBuffer + Datagram->DatagramIndex, Datagram->DatagramLength);
285 TotalLength += Datagram->DatagramLength;
286 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Datagram + sizeof (USB_NCM_DATA_GRAM));
287 }
288
289 *PacketLength = TotalLength;
290 UsbEthDriver->NowDatagram = UsbEthDriver->TotalDatagram;
291 } else {
292 UsbEthDriver->NowDatagram++;
293
294 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Ndp + sizeof (USB_NCM_DATAGRAM_POINTER_16));
295 CopyMem (Packet, (UINT8 *)UsbEthDriver->BulkBuffer + Datagram->DatagramIndex, Datagram->DatagramLength);
296 *PacketLength = Datagram->DatagramLength;
297 }
298
299 return Status;
300 } else {
301 UsbEthDriver->NowDatagram++;
302
303 Nth = (USB_NCM_TRANSFER_HEADER_16 *)UsbEthDriver->BulkBuffer;
304 Ndp = (USB_NCM_DATAGRAM_POINTER_16 *)((UINT8 *)UsbEthDriver->BulkBuffer + Nth->NdpIndex);
305 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Ndp + sizeof (USB_NCM_DATAGRAM_POINTER_16));
306 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Datagram + sizeof (USB_NCM_DATA_GRAM) * (UsbEthDriver->NowDatagram - 1));
307
308 CopyMem (Packet, (UINT8 *)UsbEthDriver->BulkBuffer + Datagram->DatagramIndex, Datagram->DatagramLength);
309 *PacketLength = Datagram->DatagramLength;
310
311 return EFI_SUCCESS;
312 }
313}
314
332EFIAPI
334 IN PXE_CDB *Cdb,
336 IN VOID *Packet,
337 IN OUT UINTN *PacketLength
338 )
339{
340 EFI_STATUS Status;
341 USB_ETHERNET_DRIVER *UsbEthDriver;
342 EFI_USB_IO_PROTOCOL *UsbIo;
343 UINT32 TransStatus;
346 USB_NCM_DATA_GRAM *Datagram;
347 UINT8 *TotalPacket;
348 UINTN TotalLength;
349
350 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
351
352 Status = gBS->HandleProtocol (
353 UsbEthDriver->UsbCdcDataHandle,
354 &gEfiUsbIoProtocolGuid,
355 (VOID **)&UsbIo
356 );
357 if (EFI_ERROR (Status)) {
358 return Status;
359 }
360
361 if (UsbEthDriver->BulkOutEndpoint == 0) {
362 GetEndpoint (UsbIo, UsbEthDriver);
363 }
364
365 TotalLength = (UINTN)(USB_NCM_NTH_LENGTH + USB_NCM_NDP_LENGTH + (*PacketLength));
366
367 Status = gBS->AllocatePool (EfiBootServicesData, TotalLength, (VOID **)&TotalPacket);
368 if (EFI_ERROR (Status)) {
369 return Status;
370 }
371
372 SetMem (TotalPacket, TotalLength, 0);
373
374 Nth = (USB_NCM_TRANSFER_HEADER_16 *)TotalPacket;
375 Nth->Signature = USB_NCM_NTH_SIGN_16;
376 Nth->HeaderLength = USB_NCM_NTH_LENGTH;
377 Nth->Sequence = UsbEthDriver->BulkOutSequence++;
378 Nth->BlockLength = (UINT16)TotalLength;
379 Nth->NdpIndex = Nth->HeaderLength;
380
381 Ndp = (USB_NCM_DATAGRAM_POINTER_16 *)((UINT8 *)TotalPacket + Nth->NdpIndex);
382 Ndp->Signature = USB_NCM_NDP_SIGN_16;
383 Ndp->Length = USB_NCM_NDP_LENGTH;
384 Ndp->NextNdpIndex = 0x00;
385
386 Datagram = (USB_NCM_DATA_GRAM *)((UINT8 *)Ndp + sizeof (USB_NCM_DATAGRAM_POINTER_16));
387 Datagram->DatagramIndex = Nth->HeaderLength + Ndp->Length;
388 Datagram->DatagramLength = (UINT16)*PacketLength;
389
390 CopyMem (TotalPacket + Datagram->DatagramIndex, Packet, *PacketLength);
391
392 *PacketLength = TotalLength;
393
394 Status = UsbIo->UsbBulkTransfer (
395 UsbIo,
396 UsbEthDriver->BulkOutEndpoint,
397 TotalPacket,
398 PacketLength,
399 USB_ETHERNET_BULK_TIMEOUT,
400 &TransStatus
401 );
402 FreePool (TotalPacket);
403 return Status;
404}
405
421EFIAPI
423 IN VOID *Data,
424 IN UINTN DataLength,
425 IN VOID *Context,
426 IN UINT32 Status
427 )
428{
429 if ((Data == NULL) || (Context == NULL)) {
430 return EFI_INVALID_PARAMETER;
431 }
432
433 if (((EFI_USB_DEVICE_REQUEST *)Data)->Request == USB_CDC_NETWORK_CONNECTION) {
434 CopyMem (
435 (EFI_USB_DEVICE_REQUEST *)Context,
438 );
439 }
440
441 return EFI_SUCCESS;
442}
443
462EFIAPI
465 IN BOOLEAN IsNewTransfer,
466 IN UINTN PollingInterval,
468 )
469{
470 EFI_STATUS Status;
471 USB_ETHERNET_DRIVER *UsbEthDriver;
472 UINTN DataLength;
473
474 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
475 DataLength = 0;
476
477 if (IsNewTransfer) {
478 DataLength = sizeof (EFI_USB_DEVICE_REQUEST) + sizeof (USB_CONNECT_SPEED_CHANGE);
479 Status = UsbEthDriver->UsbIo->UsbAsyncInterruptTransfer (
480 UsbEthDriver->UsbIo,
481 UsbEthDriver->InterruptEndpoint,
482 IsNewTransfer,
483 PollingInterval,
484 DataLength,
486 Request
487 );
488 } else {
489 Status = UsbEthDriver->UsbIo->UsbAsyncInterruptTransfer (
490 UsbEthDriver->UsbIo,
491 UsbEthDriver->InterruptEndpoint,
492 IsNewTransfer,
493 0,
494 0,
495 NULL,
496 NULL
497 );
498 }
499
500 return Status;
501}
502
515EFIAPI
518 OUT EFI_MAC_ADDRESS *MacAddress
519 )
520{
521 EFI_STATUS Status;
522 USB_ETHERNET_DRIVER *UsbEthDriver;
523 USB_ETHERNET_FUN_DESCRIPTOR UsbEthDescriptor;
524 CHAR16 *Data;
525 CHAR16 *DataPtr;
526 CHAR16 TmpStr[1];
527 UINT8 Index;
528 UINT8 Hi;
529 UINT8 Low;
530
531 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
532
533 Status = This->UsbEthFunDescriptor (This, &UsbEthDescriptor);
534 if (EFI_ERROR (Status)) {
535 DEBUG ((DEBUG_ERROR, "%a:UsbEthFunDescriptor status = %r\n", __func__, Status));
536 return Status;
537 }
538
539 Status = UsbEthDriver->UsbIo->UsbGetStringDescriptor (
540 UsbEthDriver->UsbIo,
541 0x409, // English-US Language ID
542 UsbEthDescriptor.MacAddress,
543 &Data
544 );
545 if (EFI_ERROR (Status)) {
546 DEBUG ((DEBUG_ERROR, "%a:UsbGetStringDescriptor status = %r\n", __func__, Status));
547 return Status;
548 }
549
550 DataPtr = Data;
551 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
552 CopyMem (TmpStr, DataPtr, sizeof (CHAR16));
553 DataPtr++;
554 Hi = (UINT8)StrHexToUintn (TmpStr);
555 CopyMem (TmpStr, DataPtr, sizeof (CHAR16));
556 DataPtr++;
557 Low = (UINT8)StrHexToUintn (TmpStr);
558 MacAddress->Addr[Index] = (Hi << 4) | Low;
559 }
560
561 return Status;
562}
563
574EFIAPI
577 OUT UINTN *BulkSize
578 )
579{
580 *BulkSize = USB_NCM_MAX_NTB_SIZE;
581 return EFI_SUCCESS;
582}
583
596EFIAPI
599 OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor
600 )
601{
602 EFI_STATUS Status;
603 USB_ETHERNET_DRIVER *UsbEthDriver;
604
605 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
606
607 if (UsbHeaderFunDescriptor == NULL) {
608 return EFI_INVALID_PARAMETER;
609 }
610
611 Status = GetFunctionalDescriptor (UsbEthDriver->Config, HEADER_FUN_DESCRIPTOR, UsbHeaderFunDescriptor);
612 return Status;
613}
614
627EFIAPI
630 OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor
631 )
632{
633 EFI_STATUS Status;
634 USB_ETHERNET_DRIVER *UsbEthDriver;
635
636 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
637
638 if (UsbUnionFunDescriptor == NULL) {
639 return EFI_INVALID_PARAMETER;
640 }
641
642 Status = GetFunctionalDescriptor (UsbEthDriver->Config, UNION_FUN_DESCRIPTOR, UsbUnionFunDescriptor);
643 return Status;
644}
645
662EFIAPI
665 OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor
666 )
667{
668 EFI_STATUS Status;
669 USB_ETHERNET_DRIVER *UsbEthDriver;
670
671 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
672
673 if (UsbEthFunDescriptor == NULL) {
674 return EFI_INVALID_PARAMETER;
675 }
676
677 Status = GetFunctionalDescriptor (UsbEthDriver->Config, ETHERNET_FUN_DESCRIPTOR, UsbEthFunDescriptor);
678 return Status;
679}
680
697EFIAPI
700 IN UINT16 Value,
701 IN VOID *McastAddr
702 )
703{
704 EFI_STATUS Status;
706 UINT32 TransStatus;
707 USB_ETHERNET_FUN_DESCRIPTOR UsbEthFunDescriptor;
708 USB_ETHERNET_DRIVER *UsbEthDriver;
709
710 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
711
712 Status = This->UsbEthFunDescriptor (This, &UsbEthFunDescriptor);
713 if (EFI_ERROR (Status)) {
714 return Status;
715 }
716
717 if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
718 return EFI_UNSUPPORTED;
719 }
720
721 Request.RequestType = USB_ETHERNET_SET_REQ_TYPE;
722 Request.Request = SET_ETH_MULTICAST_FILTERS_REQ;
723 Request.Value = Value;
724 Request.Index = UsbEthDriver->NumOfInterface;
725 Request.Length = Value * 6;
726
727 return UsbEthDriver->UsbIo->UsbControlTransfer (
728 UsbEthDriver->UsbIo,
729 &Request,
730 EfiUsbDataOut,
731 USB_ETHERNET_TRANSFER_TIMEOUT,
732 McastAddr,
733 Request.Length,
734 &TransStatus
735 );
736}
737
755EFIAPI
758 IN UINT16 Value,
759 IN UINT16 Length,
760 IN VOID *PatternFilter
761 )
762{
764 UINT32 TransStatus;
765 USB_ETHERNET_DRIVER *UsbEthDriver;
766
767 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
768
769 Request.RequestType = USB_ETHERNET_SET_REQ_TYPE;
770 Request.Request = SET_ETH_POWER_MANAGEMENT_PATTERN_FILTER_REQ;
771 Request.Value = Value;
772 Request.Index = UsbEthDriver->NumOfInterface;
773 Request.Length = Length;
774
775 return UsbEthDriver->UsbIo->UsbControlTransfer (
776 UsbEthDriver->UsbIo,
777 &Request,
778 EfiUsbDataOut,
779 USB_ETHERNET_TRANSFER_TIMEOUT,
780 PatternFilter,
781 Length,
782 &TransStatus
783 );
784}
785
802EFIAPI
805 IN UINT16 Value,
806 OUT BOOLEAN *PatternActive
807 )
808{
810 UINT32 TransStatus;
811 USB_ETHERNET_DRIVER *UsbEthDriver;
812
813 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
814
815 Request.RequestType = USB_ETHERNET_GET_REQ_TYPE;
816 Request.Request = GET_ETH_POWER_MANAGEMENT_PATTERN_FILTER_REQ;
817 Request.Value = Value;
818 Request.Index = UsbEthDriver->NumOfInterface;
819 Request.Length = USB_ETH_POWER_FILTER_LENGTH;
820
821 return UsbEthDriver->UsbIo->UsbControlTransfer (
822 UsbEthDriver->UsbIo,
823 &Request,
824 EfiUsbDataIn,
825 USB_ETHERNET_TRANSFER_TIMEOUT,
826 PatternActive,
827 USB_ETH_POWER_FILTER_LENGTH,
828 &TransStatus
829 );
830}
831
832BIT_MAP gTable[] = {
833 { PXE_OPFLAGS_RECEIVE_FILTER_UNICAST, USB_ETH_PACKET_TYPE_DIRECTED },
834 { PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST, USB_ETH_PACKET_TYPE_BROADCAST },
835 { PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST, USB_ETH_PACKET_TYPE_MULTICAST },
836 { PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS, USB_ETH_PACKET_TYPE_PROMISCUOUS },
837 { PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST, USB_ETH_PACKET_TYPE_ALL_MULTICAST },
838};
839
847VOID
849 IN UINT16 Value,
850 OUT UINT16 *CdcFilter
851 )
852{
853 UINT32 Index;
854 UINT32 Count;
855
856 Count = sizeof (gTable)/sizeof (gTable[0]);
857
858 for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
859 if (gTable[Index].Src & Value) {
860 *CdcFilter |= gTable[Index].Dst;
861 }
862 }
863}
864
879EFIAPI
882 IN UINT16 Value
883 )
884{
886 UINT32 TransStatus;
887 USB_ETHERNET_DRIVER *UsbEthDriver;
888 UINT16 CommandFilter;
889
890 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
891 CommandFilter = 0;
892
893 ConvertFilter (Value, &CommandFilter);
894
895 Request.RequestType = USB_ETHERNET_SET_REQ_TYPE;
896 Request.Request = SET_ETH_PACKET_FILTER_REQ;
897 Request.Value = CommandFilter;
898 Request.Index = UsbEthDriver->NumOfInterface;
899 Request.Length = USB_ETH_PACKET_FILTER_LENGTH;
900
901 return UsbEthDriver->UsbIo->UsbControlTransfer (
902 UsbEthDriver->UsbIo,
903 &Request,
904 EfiUsbNoData,
905 USB_ETHERNET_TRANSFER_TIMEOUT,
906 NULL,
907 USB_ETH_PACKET_FILTER_LENGTH,
908 &TransStatus
909 );
910}
911
927EFIAPI
930 IN UINT16 FeatureSelector,
931 OUT VOID *Statistic
932 )
933{
934 EFI_STATUS Status;
936 UINT32 TransStatus;
937 USB_ETHERNET_FUN_DESCRIPTOR UsbEthFunDescriptor;
938 USB_ETHERNET_DRIVER *UsbEthDriver;
939
940 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
941
942 Status = This->UsbEthFunDescriptor (This, &UsbEthFunDescriptor);
943 if (EFI_ERROR (Status)) {
944 return Status;
945 }
946
947 if (UsbEthFunDescriptor.EthernetStatistics == 0) {
948 return EFI_UNSUPPORTED;
949 }
950
951 Request.RequestType = USB_ETHERNET_GET_REQ_TYPE;
952 Request.Request = GET_ETH_STATISTIC_REQ;
953 Request.Value = FeatureSelector;
954 Request.Index = UsbEthDriver->NumOfInterface;
955 Request.Length = USB_ETH_STATISTIC;
956
957 return UsbEthDriver->UsbIo->UsbControlTransfer (
958 UsbEthDriver->UsbIo,
959 &Request,
960 EfiUsbDataIn,
961 USB_ETHERNET_TRANSFER_TIMEOUT,
962 Statistic,
963 USB_ETH_STATISTIC,
964 &TransStatus
965 );
966}
UINT64 UINTN
UINTN EFIAPI StrHexToUintn(IN CONST CHAR16 *String)
Definition: String.c:508
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
Definition: SetMemWrapper.c:38
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
Definition: UsbIo.h:80
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ EfiBootServicesData
#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST
Definition: UefiPxe.h:284
#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS
Definition: UefiPxe.h:302
#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST
Definition: UefiPxe.h:297
#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST
Definition: UefiPxe.h:308
#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST
Definition: UefiPxe.h:290
EFI_STATUS EFIAPI UsbSetInterface(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Interface, IN UINT16 AlternateSetting, OUT UINT32 *Status)
Definition: UsbDxeLib.c:212
EFI_STATUS EFIAPI UsbGetDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Value, IN UINT16 Index, IN UINT16 DescriptorLength, OUT VOID *Descriptor, OUT UINT32 *Status)
Definition: UsbDxeLib.c:41
EFI_STATUS EFIAPI GetUsbEthMacAddress(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT EFI_MAC_ADDRESS *MacAddress)
EFI_STATUS EFIAPI SetUsbEthPowerFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN UINT16 Length, IN VOID *PatternFilter)
EFI_STATUS EFIAPI SetUsbEthPacketFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value)
EFI_STATUS EFIAPI InterruptCallback(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
VOID GetEndpoint(IN EFI_USB_IO_PROTOCOL *UsbIo, IN OUT USB_ETHERNET_DRIVER *UsbEthDriver)
EFI_STATUS GetFunctionalDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Config, IN UINT8 FunDescriptorType, OUT VOID *DataBuffer)
EFI_STATUS EFIAPI UsbEthNcmTransmit(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS EFIAPI UsbEthNcmReceive(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS EFIAPI GetUsbEthFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor)
EFI_STATUS EFIAPI GetUsbEthPowerFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, OUT BOOLEAN *PatternActive)
EFI_STATUS LoadAllDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, OUT EFI_USB_CONFIG_DESCRIPTOR **ConfigDesc)
EFI_STATUS EFIAPI GetUsbEthStatistic(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 FeatureSelector, OUT VOID *Statistic)
EFI_STATUS EFIAPI SetUsbEthMcastFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN VOID *McastAddr)
EFI_STATUS EFIAPI GetUsbHeaderFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor)
EFI_STATUS EFIAPI UsbEthNcmBulkSize(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
EFI_STATUS EFIAPI UsbEthNcmInterrupt(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Request)
EFI_STATUS EFIAPI GetUsbUnionFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
VOID ConvertFilter(IN UINT16 Value, OUT UINT16 *CdcFilter)
BOOLEAN NextDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Desc, IN OUT UINTN *Offset)