11API_FUNC gUndiApiTable[] = {
50 if (Nic->RateLimitingCreditCount < Nic->RateLimitingCredit) {
51 Nic->RateLimitingCreditCount++;
71 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
72 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
78 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
80 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
81 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
84 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
88 Cdb->StatFlags = Cdb->StatFlags | Nic->State;
90 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiGetState !=
NULL) {
91 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiGetState (Cdb, Nic);
92 if (EFI_ERROR (Status)) {
93 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
116 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
117 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
122 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
124 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
125 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
129 if (Nic->State != PXE_STATFLAGS_GET_STATE_STOPPED) {
130 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
131 Cdb->StatCode = PXE_STATCODE_ALREADY_STARTED;
138 Nic->PxeStart.Virt2Phys = Cpb->
Virt2Phys;
139 Nic->PxeStart.Block = Cpb->
Block;
140 Nic->PxeStart.Map_Mem = 0;
141 Nic->PxeStart.UnMap_Mem = 0;
142 Nic->PxeStart.Sync_Mem = Cpb->
Sync_Mem;
143 Nic->PxeStart.Unique_ID = Cpb->
Unique_ID;
146 if (Nic->RateLimitingEnable ==
TRUE) {
147 Status =
gBS->CreateEvent (
148 EVT_TIMER | EVT_NOTIFY_SIGNAL,
154 if (!EFI_ERROR (Status)) {
155 Status =
gBS->SetTimer (
158 Nic->RateLimitingPollTimer * 10000
160 if (EFI_ERROR (Status)) {
166 if ((Nic->UsbEth->UsbEthUndi.UsbEthUndiStart !=
NULL) && (EventError ==
FALSE)) {
167 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiStart (Cdb, Nic);
170 if (!EFI_ERROR (Status)) {
172 Nic->State = PXE_STATFLAGS_GET_STATE_STARTED;
173 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
176 if (Nic->RateLimitingEnable ==
TRUE) {
181 if (Nic->RateLimiter) {
182 gBS->CloseEvent (&Nic->RateLimiter);
183 Nic->RateLimiter = 0;
188 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
189 Cdb->StatCode = PXE_STATCODE_DEVICE_FAILURE;
209 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
210 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
216 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
218 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
219 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
222 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
226 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
227 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
228 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
232 if (Nic->State == PXE_STATFLAGS_GET_STATE_INITIALIZED) {
233 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
234 Cdb->StatCode = PXE_STATCODE_NOT_SHUTDOWN;
238 Nic->PxeStart.Delay = 0;
239 Nic->PxeStart.Virt2Phys = 0;
240 Nic->PxeStart.Block = 0;
241 Nic->PxeStart.Map_Mem = 0;
242 Nic->PxeStart.UnMap_Mem = 0;
243 Nic->PxeStart.Sync_Mem = 0;
244 Nic->State = PXE_STATFLAGS_GET_STATE_STOPPED;
246 if (Nic->RateLimitingEnable ==
TRUE) {
248 gBS->CloseEvent (&Nic->RateLimiter);
251 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiStop !=
NULL) {
252 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiStop (Cdb, Nic);
253 if (EFI_ERROR (Status)) {
254 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
277 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
278 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
283 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
285 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
286 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
289 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
293 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
294 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
295 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
310 Db->
TxBufCnt = Nic->PxeInit.TxBufCnt;
311 Db->TxBufSize = Nic->PxeInit.TxBufSize;
312 Db->RxBufCnt = Nic->PxeInit.RxBufCnt;
313 Db->RxBufSize = Nic->PxeInit.RxBufSize;
318 Cdb->StatFlags |= (PXE_STATFLAGS_CABLE_DETECT_SUPPORTED |
319 PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED);
321 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiGetInitInfo !=
NULL) {
322 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiGetInitInfo (Cdb, Nic);
323 if (EFI_ERROR (Status)) {
324 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
347 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
348 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
353 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
355 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
356 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
359 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
363 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
364 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
365 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
371 Db->pci.
BusType = PXE_BUSTYPE_USB;
373 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiGetConfigInfo !=
NULL) {
374 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiGetConfigInfo (Cdb, Nic);
375 if (EFI_ERROR (Status)) {
376 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
400 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
401 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
405 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
406 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
409 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
412 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
413 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
414 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
418 if ((Cdb->OpFlags != PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) &&
419 (Cdb->OpFlags != PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE))
421 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
422 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
426 if (Nic->State == PXE_STATFLAGS_GET_STATE_INITIALIZED) {
427 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
428 Cdb->StatCode = PXE_STATCODE_ALREADY_INITIALIZED;
437 Nic->PxeInit.LoopBackMode = Cpb->LoopBackMode;
440 Nic->PxeInit.TxBufCnt = TX_BUFFER_COUNT;
441 Nic->PxeInit.TxBufSize = Nic->MaxSegmentSize;
442 Nic->PxeInit.RxBufCnt = RX_BUFFER_COUNT;
443 Nic->PxeInit.RxBufSize = Nic->MaxSegmentSize;
448 Db->
TxBufCnt = Nic->PxeInit.TxBufCnt;
449 Db->TxBufSize = Nic->PxeInit.TxBufSize;
450 Db->RxBufCnt = Nic->PxeInit.RxBufCnt;
451 Db->RxBufSize = Nic->PxeInit.RxBufSize;
454 Nic->CanTransmit =
FALSE;
456 if (Cdb->OpFlags == PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) {
457 if ((Nic->Request.Request == USB_CDC_NETWORK_CONNECTION) && (Nic->Request.Value == NETWORK_DISCONNECT)) {
458 Nic->CableDetect = 0;
459 }
else if ((Nic->Request.Request == USB_CDC_NETWORK_CONNECTION) && (Nic->Request.Value == NETWORK_CONNECTED)) {
460 Nic->CableDetect = 1;
463 if (Nic->CableDetect == 0) {
469 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
471 Nic->State = PXE_STATFLAGS_GET_STATE_INITIALIZED;
474 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiInitialize !=
NULL) {
475 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiInitialize (Cdb, Nic);
476 if (EFI_ERROR (Status)) {
477 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
503 Nic->PxeInit.MemoryAddr,
504 Nic->PxeInit.MemoryLength,
506 (UINT64)(
UINTN)&Nic->MappedAddr
510 return (UINT16)Status;
513 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
514 Nic->PermNodeAddress[Index] = Nic->MacAddr.Addr[Index];
517 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
518 Nic->CurrentNodeAddress[Index] = Nic->PermNodeAddress[Index];
521 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
522 Nic->BroadcastNodeAddress[Index] = 0xFF;
525 for (Index = PXE_HWADDR_LEN_ETHER; Index < PXE_MAC_LENGTH; Index++) {
526 Nic->CurrentNodeAddress[Index] = 0;
527 Nic->PermNodeAddress[Index] = 0;
528 Nic->BroadcastNodeAddress[Index] = 0;
531 if (Nic->UsbEth->UsbEthInitialize !=
NULL) {
532 EfiStatus = Nic->UsbEth->UsbEthInitialize (Cdb, Nic);
533 if (EFI_ERROR (EfiStatus)) {
534 return PXE_STATFLAGS_COMMAND_FAILED;
538 return (UINT16)Status;
558 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
559 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
566 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
567 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
570 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
574 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
575 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
576 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
580 if ((Cdb->OpFlags != PXE_OPFLAGS_NOT_USED) &&
582 (Cdb->OpFlags != PXE_OPFLAGS_RESET_DISABLE_FILTERS))
584 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
585 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
589 if ((Cdb->OpFlags & PXE_OPFLAGS_RESET_DISABLE_FILTERS) == 0) {
594 Nic->InterrupOpFlag = 0;
597 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiReset !=
NULL) {
598 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiReset (Cdb, Nic);
599 if (EFI_ERROR (Status)) {
600 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
622 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
623 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
629 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
631 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
632 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
635 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
639 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
640 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
641 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
645 Nic->CanTransmit =
FALSE;
647 Nic->State = PXE_STATFLAGS_GET_STATE_STARTED;
649 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiShutdown !=
NULL) {
650 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiShutdown (Cdb, Nic);
651 if (EFI_ERROR (Status)) {
652 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
653 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
674 Cdb->StatCode = PXE_STATCODE_UNSUPPORTED;
675 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiInterruptEnable !=
NULL) {
676 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiInterruptEnable (Cdb, Nic);
677 if (EFI_ERROR (Status)) {
678 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
680 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
705 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
706 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
709 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
710 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
713 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
717 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
718 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
719 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
723 NewFilter = (UINT16)(Cdb->OpFlags & 0x1F);
726 case PXE_OPFLAGS_RECEIVE_FILTER_READ:
728 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
729 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
733 if ((Cdb->DBsize != 0)) {
735 CopyMem (Db, &Nic->McastList, Nic->McastCount);
741 case PXE_OPFLAGS_RECEIVE_FILTER_ENABLE:
742 if (NewFilter == 0) {
743 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
746 if (Cdb->CPBsize != 0) {
750 ((Cdb->CPBsize % sizeof (PXE_MAC_ADDR)) != 0))
752 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
760 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
763 if ((Cdb->CPBsize == 0)) {
764 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
768 Cdb->StatCode =
SetFilter (Nic, NewFilter, Cdb->CPBaddr, Cdb->CPBsize);
771 case PXE_OPFLAGS_RECEIVE_FILTER_DISABLE:
773 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
774 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
780 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
781 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
784 Cdb->StatFlags = (
PXE_STATFLAGS)(Cdb->StatFlags | Nic->RxFilter);
786 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiReceiveFilter !=
NULL) {
787 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiReceiveFilter (Cdb, Nic);
788 if (EFI_ERROR (Status)) {
789 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
827 Nic->McastCount = (UINT8)(CpbSize / PXE_MAC_LENGTH);
828 CopyMem (&Nic->McastList, Cpb, Nic->McastCount);
831 Nic->UsbEth->UsbEthFunDescriptor (Nic->UsbEth, &UsbEthFunDescriptor);
832 if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
834 Nic->UsbEth->SetUsbEthPacketFilter (Nic->UsbEth, Nic->RxFilter);
837 if (EFI_ERROR (Status)) {
838 return PXE_STATCODE_INVALID_PARAMETER;
842 for (Index1 = 0; Index1 < Nic->McastCount; Index1++) {
843 for (Index2 = 0; Index2 < 6; Index2++) {
844 McastList[Count++] = Cpb->
MCastList[Index1][Index2];
851 Nic->UsbEth->SetUsbEthMcastFilter (Nic->UsbEth, Nic->McastCount, McastList);
854 Nic->UsbEth->SetUsbEthPacketFilter (Nic->UsbEth, Nic->RxFilter);
882 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
883 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
887 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
888 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
891 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
895 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
896 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
897 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
901 if (Cdb->OpFlags == PXE_OPFLAGS_STATION_ADDRESS_RESET) {
902 if (
CompareMem (&Nic->CurrentNodeAddress[0], &Nic->PermNodeAddress[0], PXE_MAC_LENGTH) != 0) {
903 for (Index = 0; Index < PXE_MAC_LENGTH; Index++) {
904 Nic->CurrentNodeAddress[Index] = Nic->PermNodeAddress[Index];
909 if (Cdb->CPBaddr != 0) {
911 for (Index = 0; Index < PXE_MAC_LENGTH; Index++) {
912 Nic->CurrentNodeAddress[Index] = Cpb->
StationAddr[Index];
916 if (Cdb->DBaddr != 0) {
918 for (Index = 0; Index < PXE_MAC_LENGTH; Index++) {
919 Db->
StationAddr[Index] = Nic->CurrentNodeAddress[Index];
925 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiStationAddress !=
NULL) {
926 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiStationAddress (Cdb, Nic);
927 if (EFI_ERROR (Status)) {
928 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
949 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
950 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
955 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
956 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
959 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
962 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
963 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
964 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
968 if ((Cdb->OpFlags != PXE_OPFLAGS_STATISTICS_RESET) &&
971 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
972 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
976 Cdb->StatCode =
Statistics (Nic, Cdb->DBaddr, Cdb->DBsize);
978 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiStatistics !=
NULL) {
979 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiStatistics (Cdb, Nic);
980 if (EFI_ERROR (Status)) {
981 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1011 DbStatistic->
Data[0x01] = Nic->RxFrame;
1012 DbStatistic->
Data[0x0B] = Nic->TxFrame;
1014 if (Nic->UsbEth->UsbEthStatistics !=
NULL) {
1015 Status = Nic->UsbEth->UsbEthStatistics (Nic, DbAddr, DbSize);
1016 if (EFI_ERROR (Status)) {
1017 return PXE_STATFLAGS_COMMAND_FAILED;
1043 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1044 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1049 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1050 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1053 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1057 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1058 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1059 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1066 if ((Cdb->OpFlags & PXE_OPFLAGS_MCAST_IPV6_TO_MAC) != 0) {
1067 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1068 Cdb->StatCode = PXE_STATCODE_UNSUPPORTED;
1072 Tmp = (UINT8 *)(&Cpb->
IP.IPv4);
1074 if ((Tmp[0] & 0xF0) != 0xE0) {
1075 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1076 Cdb->StatCode = PXE_STATCODE_INVALID_CPB;
1082 Db->
MAC[3] = Tmp[1] & 0x7F;
1083 Db->
MAC[4] = Tmp[2];
1084 Db->
MAC[5] = Tmp[3];
1086 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiMcastIp2Mac !=
NULL) {
1087 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiMcastIp2Mac (Cdb, Nic);
1088 if (EFI_ERROR (Status)) {
1089 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1110 Cdb->StatCode = PXE_STATCODE_UNSUPPORTED;
1111 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiNvData !=
NULL) {
1112 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiNvData (Cdb, Nic);
1113 if (EFI_ERROR (Status)) {
1114 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1116 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1143 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1144 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1149 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1150 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1153 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1157 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1158 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1159 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1167 if ((Cdb->DBsize > 0) && (Cdb->DBsize <
sizeof (UINT32) * 2)) {
1168 CopyMem (Db, &TmpGetStatus, Cdb->DBsize);
1170 CopyMem (Db, &TmpGetStatus,
sizeof (UINT32) * 2);
1174 if (Cdb->DBsize == 0) {
1175 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1176 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1180 NumEntries = Cdb->DBsize -
sizeof (UINT64);
1181 Cdb->DBsize =
sizeof (UINT32) * 2;
1183 for (Index = 0; NumEntries >=
sizeof (UINT64); Index++, NumEntries -=
sizeof (UINT64)) {
1184 if (Nic->TxBufferCount > 0) {
1185 Nic->TxBufferCount--;
1186 Db->
TxBuffer[Index] = Nic->MediaHeader[Nic->TxBufferCount];
1192 if (Nic->ReceiveStatus != 0) {
1197 if ((Nic->Request.Request == USB_CDC_NETWORK_CONNECTION) && (Nic->Request.Value == NETWORK_DISCONNECT)) {
1198 Nic->CableDetect = 0;
1199 }
else if ((Nic->Request.Request == USB_CDC_NETWORK_CONNECTION) && (Nic->Request.Value == NETWORK_CONNECTED)) {
1200 Nic->CableDetect = 1;
1204 if (Nic->CableDetect == 0) {
1209 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiGetStatus !=
NULL) {
1210 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiGetStatus (Cdb, Nic);
1211 if (EFI_ERROR (Status)) {
1212 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1237 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1238 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1244 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1245 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1248 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1252 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1253 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1254 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1259 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1260 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1264 if ((Cdb->OpFlags & PXE_OPFLAGS_FILL_HEADER_FRAGMENTED) != 0) {
1268 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1269 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1274 MacHeader->Protocol = CpbFill->
Protocol;
1276 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1277 MacHeader->DestAddr[Index] = CpbFill->DestAddr[Index];
1278 MacHeader->SrcAddr[Index] = CpbFill->
SrcAddr[Index];
1284 MacHeader->Protocol = CpbFillHeader->
Protocol;
1286 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1287 MacHeader->DestAddr[Index] = CpbFillHeader->DestAddr[Index];
1288 MacHeader->SrcAddr[Index] = CpbFillHeader->
SrcAddr[Index];
1292 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiFillHeader !=
NULL) {
1293 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiFillHeader (Cdb, Nic);
1294 if (EFI_ERROR (Status)) {
1295 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1316 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1317 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1323 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1324 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1327 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1331 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1332 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1333 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1338 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1339 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1343 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiTransmit !=
NULL) {
1344 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiTransmit (Cdb, Nic);
1345 if (EFI_ERROR (Status)) {
1346 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1352 Cdb->StatCode = Transmit (Cdb, Nic, Cdb->CPBaddr, Cdb->OpFlags);
1355 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1380 UINTN TransmitLength;
1389 if (Nic->CanTransmit) {
1390 return PXE_STATCODE_BUSY;
1393 Nic->CanTransmit =
TRUE;
1395 if ((OpFlags & PXE_OPFLAGS_TRANSMIT_FRAGMENTED) != 0) {
1396 return PXE_STATCODE_INVALID_PARAMETER;
1404 (UINT64)(
UINTN)&BulkOutData
1408 Nic->CanTransmit =
FALSE;
1409 return PXE_STATCODE_INVALID_PARAMETER;
1413 Nic->MediaHeader[Nic->TxBufferCount] = Cpb->
FrameAddr;
1414 Nic->TxBufferCount++;
1421 StatCode = PXE_STATCODE_BUSY;
1425 TransmitLength = DataLength;
1427 Status = Nic->UsbEth->UsbEthTransmit (Cdb, Nic->UsbEth, (VOID *)(
UINTN)BulkOutData, &TransmitLength);
1428 if (EFI_ERROR (Status)) {
1429 StatCode = PXE_STATFLAGS_COMMAND_FAILED;
1432 if (Status == EFI_INVALID_PARAMETER) {
1433 StatCode = PXE_STATCODE_INVALID_PARAMETER;
1437 if (Status == EFI_DEVICE_ERROR) {
1438 StatCode = PXE_STATCODE_DEVICE_FAILURE;
1442 if (!EFI_ERROR (Status)) {
1459 Nic->CanTransmit =
FALSE;
1481 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1482 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1486 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
1488 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1489 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1492 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1496 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1497 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1498 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1502 if (Nic->UsbEth->UsbEthUndi.UsbEthUndiReceive !=
NULL) {
1503 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiReceive (Cdb, Nic);
1504 if (EFI_ERROR (Status)) {
1505 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1511 Cdb->StatCode = Receive (Cdb, Nic, Cdb->CPBaddr, Cdb->DBaddr);
1514 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1532 IN OUT UINT64 DbAddr
1537 PXE_FRAME_TYPE FrameType;
1546 FrameType = PXE_FRAME_TYPE_NONE;
1547 NicDevice = UNDI_DEV_FROM_NIC (Nic);
1548 BulkInData = NicDevice->ReceiveBuffer;
1549 DataLength = (
UINTN)Nic->MaxSegmentSize;
1554 return PXE_STATCODE_INVALID_PARAMETER;
1557 if ((Nic->RateLimitingCreditCount == 0) && (Nic->RateLimitingEnable ==
TRUE)) {
1558 return PXE_STATCODE_NO_DATA;
1561 Status = Nic->UsbEth->UsbEthReceive (Cdb, Nic->UsbEth, (VOID *)BulkInData, &DataLength);
1562 if (EFI_ERROR (Status)) {
1563 Nic->ReceiveStatus = 0;
1564 if (Nic->RateLimitingEnable ==
TRUE) {
1565 OriginalTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1566 if (Nic->RateLimitingCreditCount != 0) {
1567 Nic->RateLimitingCreditCount--;
1570 gBS->RestoreTPL (OriginalTpl);
1573 return PXE_STATCODE_NO_DATA;
1578 if (DataLength != 0) {
1590 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1591 if (Header->DestAddr[Index] != Nic->CurrentNodeAddress[Index]) {
1596 if (Index >= PXE_HWADDR_LEN_ETHER) {
1597 FrameType = PXE_FRAME_TYPE_UNICAST;
1599 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1600 if (Header->DestAddr[Index] != Nic->BroadcastNodeAddress[Index]) {
1605 if (Index >= PXE_HWADDR_LEN_ETHER) {
1606 FrameType = PXE_FRAME_TYPE_BROADCAST;
1608 if ((Header->DestAddr[0] & 1) == 1) {
1609 FrameType = PXE_FRAME_TYPE_FILTERED_MULTICAST;
1611 FrameType = PXE_FRAME_TYPE_PROMISCUOUS;
1616 Db->
Type = FrameType;
1619 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1620 Db->
SrcAddr[Index] = Header->SrcAddr[Index];
1621 Db->DestAddr[Index] = Header->DestAddr[Index];
1625 if (FrameType == PXE_FRAME_TYPE_NONE) {
1626 Nic->ReceiveStatus = 0;
1628 Nic->ReceiveStatus = 1;
1649 PxeSw->IFcntExt = 0;
1652 PxeSw->MinorVer = PXE_ROMID_MINORVER;
1653 PxeSw->reserved1 = 0;
1655 PxeSw->Implementation = PXE_ROMID_IMP_SW_VIRT_ADDR |
1656 PXE_ROMID_IMP_FRAG_SUPPORTED |
1657 PXE_ROMID_IMP_CMD_LINK_SUPPORTED |
1658 PXE_ROMID_IMP_STATION_ADDR_SETTABLE |
1659 PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED |
1660 PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED |
1661 PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED |
1662 PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED;
1665 PxeSw->reserved2[0] = 0;
1666 PxeSw->reserved2[1] = 0;
1667 PxeSw->reserved2[2] = 0;
1669 PxeSw->BusType[0] = PXE_BUSTYPE_USB;
1670 PxeSw->Fudge = PxeSw->Fudge -
CalculateSum8 ((VOID *)PxeSw, PxeSw->Len);
1688 NicNum = (PxeSw->IFcnt | PxeSw->IFcntExt << 8);
1695 PxeSw->IFcnt = (UINT8)(NicNum & 0xFF);
1696 PxeSw->IFcntExt = (UINT8)((NicNum & 0xFF00) >> 8);
1697 PxeSw->Fudge = (UINT8)(PxeSw->Fudge -
CalculateSum8 ((VOID *)PxeSw, PxeSw->Len));
1703 PxeSw->IFcnt = (UINT8)(NicNum & 0xFF);
1704 PxeSw->IFcntExt = (UINT8)((NicNum & 0xFF00) >> 8);
1705 PxeSw->Fudge = (UINT8)(PxeSw->Fudge -
CalculateSum8 ((VOID *)PxeSw, PxeSw->Len));
1724 return EFI_INVALID_PARAMETER;
1728 Nic = &(gLanDeviceList[CdbPtr->IFnum]->NicInfo);
1729 gUndiApiTable[CdbPtr->OpCode](CdbPtr, Nic);
1750 IN UINT32 Direction,
1751 OUT UINT64 MappedAddr
1756 PhyAddr = (UINT64 *)(
UINTN)MappedAddr;
1758 if (Nic->PxeStart.Map_Mem == 0) {
1761 ((void (*)(UINT64, UINT64, UINT32, UINT32, UINT64))(
UINTN) Nic->PxeStart.Map_Mem)(
1762 Nic->PxeStart.Unique_ID,
1790 IN UINT32 Direction,
1791 IN UINT64 MappedAddr
1794 if (Nic->PxeStart.UnMap_Mem != 0) {
1795 ((void (*)(UINT64, UINT64, UINT32, UINT32, UINT64))(
UINTN) Nic->PxeStart.UnMap_Mem)(
1796 Nic->PxeStart.Unique_ID,
UINT8 EFIAPI CalculateSum8(IN CONST UINT8 *Buffer, IN UINTN Length)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID UndiStatistics(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID PxeStructInit(OUT PXE_SW_UNDI *PxeSw)
VOID UndiGetInitInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI UndiApiEntry(IN UINT64 Cdb)
VOID UndiInterruptEnable(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UnMapIt(IN NIC_DATA *Nic, IN UINT64 MemAddr, IN UINT32 Size, IN UINT32 Direction, IN UINT64 MappedAddr)
VOID UndiGetConfigInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiReceive(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiShutdown(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
VOID UndiTransmit(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiStationAddress(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UpdateNicNum(IN NIC_DATA *Nic, IN OUT PXE_SW_UNDI *PxeSw)
VOID UndiStart(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
UINT16 Initialize(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
UINT16 Statistics(IN NIC_DATA *Nic, IN UINT64 DbAddr, IN UINT16 DbSize)
VOID UndiNvData(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiReceiveFilter(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
UINT16 SetFilter(IN NIC_DATA *Nic, IN UINT16 SetFilter, IN UINT64 CpbAddr, IN UINT32 CpbSize)
UINTN MapIt(IN NIC_DATA *Nic, IN UINT64 MemAddr, IN UINT32 Size, IN UINT32 Direction, OUT UINT64 MappedAddr)
VOID UndiFillHeader(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiStop(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiInitialize(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
VOID UndiReset(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID EFIAPI UndiRateLimiterCallback(IN EFI_EVENT Event, IN VOID *Context)
VOID UndiGetStatus(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiMcastIp2Mac(IN OUT PXE_CDB *Cdb, IN NIC_DATA *Nic)
VOID UndiGetState(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
#define PXE_ROMID_MAJORVER
#define PXE_OPCODE_TRANSMIT
#define PXE_CPBSIZE_NOT_USED
zero
#define PXE_OPCODE_STATISTICS
#define PXE_OPCODE_GET_STATUS
#define PXE_STATFLAGS_GET_STATUS_RECEIVE
#define PXE_OPCODE_GET_STATE
#define PXE_IFTYPE_ETHERNET
#define PXE_OPFLAGS_RECEIVE_FILTER_OPMASK
#define PXE_OPCODE_STATION_ADDRESS
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA
#define PXE_ROMID_SIGNATURE
#define PXE_OPCODE_MCAST_IP_TO_MAC
#define PXE_OPCODE_FILL_HEADER
#define PXE_OPCODE_GET_CONFIG_INFO
#define PXE_OPFLAGS_GET_INTERRUPT_STATUS
#define MAX_XMIT_BUFFERS
recycling Q length for xmit_done.
#define PXE_OPFLAGS_GET_MEDIA_STATUS
#define PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST
#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS
#define PXE_DBSIZE_NOT_USED
zero
#define PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS
#define PXE_CPBADDR_NOT_USED
zero
#define PXE_DBADDR_NOT_USED
zero
#define PXE_OPFLAGS_STATISTICS_READ
#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST
#define PXE_OPCODE_RECEIVE
#define PXE_OPCODE_INITIALIZE
#define PXE_OPCODE_RECEIVE_FILTERS
#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST
#define PXE_OPCODE_GET_INIT_INFO
#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA
#define PXE_STATCODE_SUCCESS
#define PXE_OPCODE_SHUTDOWN
#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST
PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT]
PXE_UINT16 MediaheaderLen
PXE_UINT8 SupportedLoopBackModes
PXE_UINT32 MemoryRequired
PXE_UINT16 MCastFilterCnt
PXE_UINT8 SupportedDuplexModes
PXE_UINT16 MediaHeaderLen
PXE_UINT64 TxBuffer[MAX_XMIT_BUFFERS]
PXE_UINT16 MediaHeaderLen
PXE_MEDIA_PROTOCOL Protocol
PXE_MAC_ADDR PermanentAddr
PXE_MAC_ADDR BroadcastAddr
PXE_UINT8 IFcnt
physical connector count lower byte.
PXE_UINT8 IFcntExt
physical connector count upper byte.