TianoCore EDK2 master
Loading...
Searching...
No Matches
PxeFunction.c
Go to the documentation of this file.
1
8#include "DriverBinding.h"
9
10// API table, defined in UEFI specification
11API_FUNC gUndiApiTable[] = {
30};
31
39VOID
40EFIAPI
42 IN EFI_EVENT Event,
43 IN VOID *Context
44 )
45{
46 NIC_DATA *Nic;
47
48 Nic = Context;
49
50 if (Nic->RateLimitingCreditCount < Nic->RateLimitingCredit) {
51 Nic->RateLimitingCreditCount++;
52 }
53}
54
62VOID
64 IN PXE_CDB *Cdb,
65 IN NIC_DATA *Nic
66 )
67{
68 EFI_STATUS Status;
69
70 if ((Cdb->OpCode != PXE_OPCODE_GET_STATE) ||
71 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
72 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
73 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
74 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
75 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED) ||
76 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
77 (Cdb->DBaddr != PXE_DBADDR_NOT_USED) ||
78 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
79 {
80 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
81 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
82 return;
83 } else {
84 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
85 Cdb->StatCode = PXE_STATCODE_SUCCESS;
86 }
87
88 Cdb->StatFlags = Cdb->StatFlags | Nic->State;
89
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;
94 }
95 }
96}
97
105VOID
107 IN PXE_CDB *Cdb,
108 IN NIC_DATA *Nic
109 )
110{
111 PXE_CPB_START_31 *Cpb;
112 EFI_STATUS Status;
113 BOOLEAN EventError;
114
115 if ((Cdb->OpCode != PXE_OPCODE_START) ||
116 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
117 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
118 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
119 (Cdb->CPBsize != sizeof (PXE_CPB_START_31)) ||
120 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
121 (Cdb->DBaddr != PXE_DBADDR_NOT_USED) ||
122 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
123 {
124 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
125 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
126 return;
127 }
128
129 if (Nic->State != PXE_STATFLAGS_GET_STATE_STOPPED) {
130 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
131 Cdb->StatCode = PXE_STATCODE_ALREADY_STARTED;
132 return;
133 }
134
135 Cpb = (PXE_CPB_START_31 *)(UINTN)Cdb->CPBaddr;
136
137 Nic->PxeStart.Delay = Cpb->Delay;
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;
144 EventError = FALSE;
145 Status = EFI_SUCCESS;
146 if (Nic->RateLimitingEnable == TRUE) {
147 Status = gBS->CreateEvent (
148 EVT_TIMER | EVT_NOTIFY_SIGNAL,
149 TPL_NOTIFY,
151 Nic,
152 &Nic->RateLimiter
153 );
154 if (!EFI_ERROR (Status)) {
155 Status = gBS->SetTimer (
156 Nic->RateLimiter,
158 Nic->RateLimitingPollTimer * 10000
159 );
160 if (EFI_ERROR (Status)) {
161 EventError = TRUE;
162 }
163 }
164 }
165
166 if ((Nic->UsbEth->UsbEthUndi.UsbEthUndiStart != NULL) && (EventError == FALSE)) {
167 Status = Nic->UsbEth->UsbEthUndi.UsbEthUndiStart (Cdb, Nic);
168 }
169
170 if (!EFI_ERROR (Status)) {
171 // Initial the state for UNDI start.
172 Nic->State = PXE_STATFLAGS_GET_STATE_STARTED;
173 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
174 Cdb->StatCode = PXE_STATCODE_SUCCESS;
175 } else {
176 if (Nic->RateLimitingEnable == TRUE) {
177 if (!EventError) {
178 gBS->SetTimer (&Nic->RateLimiter, TimerCancel, 0);
179 }
180
181 if (Nic->RateLimiter) {
182 gBS->CloseEvent (&Nic->RateLimiter);
183 Nic->RateLimiter = 0;
184 }
185 }
186
187 // Initial the state when UNDI start is fail
188 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
189 Cdb->StatCode = PXE_STATCODE_DEVICE_FAILURE;
190 }
191}
192
200VOID
202 IN PXE_CDB *Cdb,
203 IN NIC_DATA *Nic
204 )
205{
206 EFI_STATUS Status;
207
208 if ((Cdb->OpCode != PXE_OPCODE_STOP) ||
209 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
210 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
211 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
212 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
213 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED) ||
214 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
215 (Cdb->DBaddr != PXE_DBADDR_NOT_USED) ||
216 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
217 {
218 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
219 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
220 return;
221 } else {
222 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
223 Cdb->StatCode = PXE_STATCODE_SUCCESS;
224 }
225
226 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
227 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
228 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
229 return;
230 }
231
232 if (Nic->State == PXE_STATFLAGS_GET_STATE_INITIALIZED) {
233 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
234 Cdb->StatCode = PXE_STATCODE_NOT_SHUTDOWN;
235 return;
236 }
237
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;
245
246 if (Nic->RateLimitingEnable == TRUE) {
247 gBS->SetTimer (&Nic->RateLimiter, TimerCancel, 0);
248 gBS->CloseEvent (&Nic->RateLimiter);
249 }
250
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;
255 }
256 }
257}
258
267VOID
269 IN PXE_CDB *Cdb,
270 IN NIC_DATA *Nic
271 )
272{
274 EFI_STATUS Status;
275
276 if ((Cdb->OpCode != PXE_OPCODE_GET_INIT_INFO) ||
277 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
278 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
279 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
280 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
281 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED) ||
282 (Cdb->DBsize != sizeof (PXE_DB_GET_INIT_INFO)) ||
283 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
284 {
285 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
286 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
287 return;
288 } else {
289 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
290 Cdb->StatCode = PXE_STATCODE_SUCCESS;
291 }
292
293 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
294 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
295 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
296 return;
297 }
298
299 Db = (PXE_DB_GET_INIT_INFO *)(UINTN)Cdb->DBaddr;
300
301 Db->MemoryRequired = MEMORY_REQUIRE;
302 Db->FrameDataLen = PXE_MAX_TXRX_UNIT_ETHER;
303 Db->LinkSpeeds[0] = 10;
304 Db->LinkSpeeds[1] = 100;
305 Db->LinkSpeeds[2] = 1000;
306 Db->LinkSpeeds[3] = 0;
307 Db->MediaHeaderLen = PXE_MAC_HEADER_LEN_ETHER;
308 Db->HWaddrLen = PXE_HWADDR_LEN_ETHER;
309 Db->MCastFilterCnt = MAX_MCAST_ADDRESS_CNT;
310 Db->TxBufCnt = Nic->PxeInit.TxBufCnt;
311 Db->TxBufSize = Nic->PxeInit.TxBufSize;
312 Db->RxBufCnt = Nic->PxeInit.RxBufCnt;
313 Db->RxBufSize = Nic->PxeInit.RxBufSize;
315 Db->SupportedDuplexModes = PXE_DUPLEX_DEFAULT;
316 Db->SupportedLoopBackModes = LOOPBACK_NORMAL;
317
318 Cdb->StatFlags |= (PXE_STATFLAGS_CABLE_DETECT_SUPPORTED |
319 PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED);
320
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;
325 }
326 }
327}
328
337VOID
339 IN PXE_CDB *Cdb,
340 IN NIC_DATA *Nic
341 )
342{
344 EFI_STATUS Status;
345
346 if ((Cdb->OpCode != PXE_OPCODE_GET_CONFIG_INFO) ||
347 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
348 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
349 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
350 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
351 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED) ||
352 (Cdb->DBsize != sizeof (PXE_DB_GET_CONFIG_INFO)) ||
353 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
354 {
355 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
356 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
357 return;
358 } else {
359 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
360 Cdb->StatCode = PXE_STATCODE_SUCCESS;
361 }
362
363 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
364 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
365 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
366 return;
367 }
368
369 Db = (PXE_DB_GET_CONFIG_INFO *)(UINTN)Cdb->DBaddr;
370
371 Db->pci.BusType = PXE_BUSTYPE_USB;
372
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;
377 }
378 }
379}
380
389VOID
391 IN PXE_CDB *Cdb,
392 IN OUT NIC_DATA *Nic
393 )
394{
397 EFI_STATUS Status;
398
399 if ((Cdb->OpCode != PXE_OPCODE_INITIALIZE) ||
400 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
401 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
402 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
403 (Cdb->CPBsize != sizeof (PXE_CPB_INITIALIZE)))
404 {
405 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
406 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
407 return;
408 } else {
409 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
410 }
411
412 if (Nic->State == PXE_STATFLAGS_GET_STATE_STOPPED) {
413 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
414 Cdb->StatCode = PXE_STATCODE_NOT_STARTED;
415 return;
416 }
417
418 if ((Cdb->OpFlags != PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) &&
419 (Cdb->OpFlags != PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE))
420 {
421 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
422 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
423 return;
424 }
425
426 if (Nic->State == PXE_STATFLAGS_GET_STATE_INITIALIZED) {
427 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
428 Cdb->StatCode = PXE_STATCODE_ALREADY_INITIALIZED;
429 return;
430 }
431
432 Cpb = (PXE_CPB_INITIALIZE *)(UINTN)Cdb->CPBaddr;
433 Db = (PXE_DB_INITIALIZE *)(UINTN)Cdb->DBaddr;
434
435 Nic->PxeInit.LinkSpeed = Cpb->LinkSpeed;
436 Nic->PxeInit.DuplexMode = Cpb->DuplexMode;
437 Nic->PxeInit.LoopBackMode = Cpb->LoopBackMode;
438 Nic->PxeInit.MemoryAddr = Cpb->MemoryAddr;
439 Nic->PxeInit.MemoryLength = Cpb->MemoryLength;
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;
444
445 Cdb->StatCode = Initialize (Cdb, Nic);
446
447 Db->MemoryUsed = MEMORY_REQUIRE;
448 Db->TxBufCnt = Nic->PxeInit.TxBufCnt;
449 Db->TxBufSize = Nic->PxeInit.TxBufSize;
450 Db->RxBufCnt = Nic->PxeInit.RxBufCnt;
451 Db->RxBufSize = Nic->PxeInit.RxBufSize;
452
454 Nic->CanTransmit = FALSE;
455
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;
461 }
462
463 if (Nic->CableDetect == 0) {
464 Cdb->StatFlags |= PXE_STATFLAGS_INITIALIZED_NO_MEDIA;
465 }
466 }
467
468 if (Cdb->StatCode != PXE_STATCODE_SUCCESS) {
469 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
470 } else {
471 Nic->State = PXE_STATFLAGS_GET_STATE_INITIALIZED;
472 }
473
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;
478 }
479 }
480}
481
491UINT16
493 IN PXE_CDB *Cdb,
494 IN OUT NIC_DATA *Nic
495 )
496{
497 UINTN Status;
498 UINT32 Index;
499 EFI_STATUS EfiStatus;
500
501 Status = MapIt (
502 Nic,
503 Nic->PxeInit.MemoryAddr,
504 Nic->PxeInit.MemoryLength,
505 TO_AND_FROM_DEVICE,
506 (UINT64)(UINTN)&Nic->MappedAddr
507 );
508
509 if (Status != 0) {
510 return (UINT16)Status;
511 }
512
513 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
514 Nic->PermNodeAddress[Index] = Nic->MacAddr.Addr[Index];
515 }
516
517 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
518 Nic->CurrentNodeAddress[Index] = Nic->PermNodeAddress[Index];
519 }
520
521 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
522 Nic->BroadcastNodeAddress[Index] = 0xFF;
523 }
524
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;
529 }
530
531 if (Nic->UsbEth->UsbEthInitialize != NULL) {
532 EfiStatus = Nic->UsbEth->UsbEthInitialize (Cdb, Nic);
533 if (EFI_ERROR (EfiStatus)) {
534 return PXE_STATFLAGS_COMMAND_FAILED;
535 }
536 }
537
538 return (UINT16)Status;
539}
540
549VOID
551 IN PXE_CDB *Cdb,
552 IN NIC_DATA *Nic
553 )
554{
555 EFI_STATUS Status;
556
557 if ((Cdb->OpCode != PXE_OPCODE_RESET) ||
558 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
559 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
560 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
561 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
562 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED) ||
563 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
564 (Cdb->DBaddr != PXE_DBADDR_NOT_USED))
565 {
566 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
567 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
568 return;
569 } else {
570 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
571 Cdb->StatCode = PXE_STATCODE_SUCCESS;
572 }
573
574 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
575 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
576 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
577 return;
578 }
579
580 if ((Cdb->OpFlags != PXE_OPFLAGS_NOT_USED) &&
581 (Cdb->OpFlags != PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS) &&
582 (Cdb->OpFlags != PXE_OPFLAGS_RESET_DISABLE_FILTERS))
583 {
584 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
585 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
586 return;
587 }
588
589 if ((Cdb->OpFlags & PXE_OPFLAGS_RESET_DISABLE_FILTERS) == 0) {
591 }
592
593 if ((Cdb->OpFlags & PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS) != 0) {
594 Nic->InterrupOpFlag = 0;
595 }
596
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;
601 }
602 }
603}
604
613VOID
615 IN PXE_CDB *Cdb,
616 IN OUT NIC_DATA *Nic
617 )
618{
619 EFI_STATUS Status;
620
621 if ((Cdb->OpCode != PXE_OPCODE_SHUTDOWN) ||
622 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
623 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
624 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
625 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
626 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED) ||
627 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
628 (Cdb->DBaddr != PXE_DBADDR_NOT_USED) ||
629 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
630 {
631 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
632 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
633 return;
634 } else {
635 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
636 Cdb->StatCode = PXE_STATCODE_SUCCESS;
637 }
638
639 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
640 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
641 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
642 return;
643 }
644
645 Nic->CanTransmit = FALSE;
646
647 Nic->State = PXE_STATFLAGS_GET_STATE_STARTED;
648
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;
654 }
655 }
656}
657
666VOID
668 IN PXE_CDB *Cdb,
669 IN NIC_DATA *Nic
670 )
671{
672 EFI_STATUS Status;
673
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;
679 } else {
680 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
681 Cdb->StatCode = PXE_STATCODE_SUCCESS;
682 }
683 }
684}
685
694VOID
696 IN PXE_CDB *Cdb,
697 IN NIC_DATA *Nic
698 )
699{
700 UINT16 NewFilter;
702 EFI_STATUS Status;
703
704 if ((Cdb->OpCode != PXE_OPCODE_RECEIVE_FILTERS) ||
705 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
706 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
707 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)))
708 {
709 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
710 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
711 return;
712 } else {
713 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
714 Cdb->StatCode = PXE_STATCODE_SUCCESS;
715 }
716
717 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
718 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
719 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
720 return;
721 }
722
723 NewFilter = (UINT16)(Cdb->OpFlags & 0x1F);
724
725 switch (Cdb->OpFlags & PXE_OPFLAGS_RECEIVE_FILTER_OPMASK) {
726 case PXE_OPFLAGS_RECEIVE_FILTER_READ:
727 if (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) {
728 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
729 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
730 }
731
732 if ((NewFilter & PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST) == 0) {
733 if ((Cdb->DBsize != 0)) {
734 Db = (PXE_DB_RECEIVE_FILTERS *)(UINTN)Cdb->DBaddr;
735 CopyMem (Db, &Nic->McastList, Nic->McastCount);
736 }
737 }
738
739 break;
740
741 case PXE_OPFLAGS_RECEIVE_FILTER_ENABLE:
742 if (NewFilter == 0) {
743 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
744 }
745
746 if (Cdb->CPBsize != 0) {
747 if (((NewFilter & PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST) == 0) ||
748 ((NewFilter & PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST) != 0) ||
749 ((NewFilter & PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST) != 0) ||
750 ((Cdb->CPBsize % sizeof (PXE_MAC_ADDR)) != 0))
751 {
752 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
753 }
754 }
755
756 if ((Cdb->OpFlags & PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST) != 0) {
757 if (((Cdb->OpFlags & PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST) != 0) ||
758 ((Cdb->OpFlags & PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST) != 0))
759 {
760 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
761 }
762
763 if ((Cdb->CPBsize == 0)) {
764 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
765 }
766 }
767
768 Cdb->StatCode = SetFilter (Nic, NewFilter, Cdb->CPBaddr, Cdb->CPBsize);
769 break;
770
771 case PXE_OPFLAGS_RECEIVE_FILTER_DISABLE:
772 if (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) {
773 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
774 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
775 }
776
777 break;
778
779 default:
780 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
781 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
782 }
783
784 Cdb->StatFlags = (PXE_STATFLAGS)(Cdb->StatFlags | Nic->RxFilter);
785
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;
790 }
791 }
792}
793
803UINT16
805 IN NIC_DATA *Nic,
806 IN UINT16 SetFilter,
807 IN UINT64 CpbAddr,
808 IN UINT32 CpbSize
809 )
810{
811 EFI_STATUS Status;
812 UINT8 *McastList;
813 UINT8 Count;
814 UINT8 Index1;
815 UINT8 Index2;
817 USB_ETHERNET_FUN_DESCRIPTOR UsbEthFunDescriptor;
818
819 Count = 0;
820 Cpb = (PXE_CPB_RECEIVE_FILTERS *)(UINTN)CpbAddr;
821
822 // The Cpb could be NULL.(ref:PXE_CPBADDR_NOT_USED)
823 Nic->RxFilter = (UINT8)SetFilter;
824
826 if (Cpb != NULL) {
827 Nic->McastCount = (UINT8)(CpbSize / PXE_MAC_LENGTH);
828 CopyMem (&Nic->McastList, Cpb, Nic->McastCount);
829 }
830
831 Nic->UsbEth->UsbEthFunDescriptor (Nic->UsbEth, &UsbEthFunDescriptor);
832 if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
834 Nic->UsbEth->SetUsbEthPacketFilter (Nic->UsbEth, Nic->RxFilter);
835 } else {
836 Status = gBS->AllocatePool (EfiBootServicesData, Nic->McastCount * 6, (VOID **)&McastList);
837 if (EFI_ERROR (Status)) {
838 return PXE_STATCODE_INVALID_PARAMETER;
839 }
840
841 if (Cpb != NULL) {
842 for (Index1 = 0; Index1 < Nic->McastCount; Index1++) {
843 for (Index2 = 0; Index2 < 6; Index2++) {
844 McastList[Count++] = Cpb->MCastList[Index1][Index2];
845 }
846 }
847 }
848
850 if (Cpb != NULL) {
851 Nic->UsbEth->SetUsbEthMcastFilter (Nic->UsbEth, Nic->McastCount, McastList);
852 }
853
854 Nic->UsbEth->SetUsbEthPacketFilter (Nic->UsbEth, Nic->RxFilter);
855 FreePool (McastList);
856 }
857 }
858
860}
861
870VOID
872 IN PXE_CDB *Cdb,
873 IN NIC_DATA *Nic
874 )
875{
878 UINT16 Index;
879 EFI_STATUS Status;
880
881 if ((Cdb->OpCode != PXE_OPCODE_STATION_ADDRESS) ||
882 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
883 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
884 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
885 (Cdb->DBsize != sizeof (PXE_DB_STATION_ADDRESS)))
886 {
887 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
888 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
889 return;
890 } else {
891 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
892 Cdb->StatCode = PXE_STATCODE_SUCCESS;
893 }
894
895 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
896 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
897 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
898 return;
899 }
900
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];
905 }
906 }
907 }
908
909 if (Cdb->CPBaddr != 0) {
910 Cpb = (PXE_CPB_STATION_ADDRESS *)(UINTN)Cdb->CPBaddr;
911 for (Index = 0; Index < PXE_MAC_LENGTH; Index++) {
912 Nic->CurrentNodeAddress[Index] = Cpb->StationAddr[Index];
913 }
914 }
915
916 if (Cdb->DBaddr != 0) {
917 Db = (PXE_DB_STATION_ADDRESS *)(UINTN)Cdb->DBaddr;
918 for (Index = 0; Index < PXE_MAC_LENGTH; Index++) {
919 Db->StationAddr[Index] = Nic->CurrentNodeAddress[Index];
920 Db->BroadcastAddr[Index] = Nic->BroadcastNodeAddress[Index];
921 Db->PermanentAddr[Index] = Nic->PermNodeAddress[Index];
922 }
923 }
924
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;
929 }
930 }
931}
932
940VOID
942 IN PXE_CDB *Cdb,
943 IN NIC_DATA *Nic
944 )
945{
946 EFI_STATUS Status;
947
948 if ((Cdb->OpCode != PXE_OPCODE_STATISTICS) ||
949 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
950 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
951 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
952 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
953 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED))
954 {
955 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
956 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
957 return;
958 } else {
959 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
960 }
961
962 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
963 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
964 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
965 return;
966 }
967
968 if ((Cdb->OpFlags != PXE_OPFLAGS_STATISTICS_RESET) &&
969 (Cdb->OpFlags != PXE_OPFLAGS_STATISTICS_READ))
970 {
971 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
972 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
973 return;
974 }
975
976 Cdb->StatCode = Statistics (Nic, Cdb->DBaddr, Cdb->DBsize);
977
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;
982 }
983 }
984}
985
994UINT16
996 IN NIC_DATA *Nic,
997 IN UINT64 DbAddr,
998 IN UINT16 DbSize
999 )
1000{
1001 PXE_DB_STATISTICS *DbStatistic;
1002 EFI_STATUS Status;
1003
1004 DbStatistic = (PXE_DB_STATISTICS *)(UINTN)DbAddr;
1005
1006 if (DbSize == 0) {
1007 return PXE_STATCODE_SUCCESS;
1008 }
1009
1010 DbStatistic->Supported = 0x802;
1011 DbStatistic->Data[0x01] = Nic->RxFrame;
1012 DbStatistic->Data[0x0B] = Nic->TxFrame;
1013
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;
1018 }
1019 }
1020
1021 return PXE_STATCODE_SUCCESS;
1022}
1023
1031VOID
1033 IN OUT PXE_CDB *Cdb,
1034 IN NIC_DATA *Nic
1035 )
1036{
1039 UINT8 *Tmp;
1040 EFI_STATUS Status;
1041
1042 if ((Cdb->OpCode != PXE_OPCODE_MCAST_IP_TO_MAC) ||
1043 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1044 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1045 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
1046 (Cdb->CPBsize != sizeof (PXE_CPB_MCAST_IP_TO_MAC)) ||
1047 (Cdb->DBsize != sizeof (PXE_DB_MCAST_IP_TO_MAC)))
1048 {
1049 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1050 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1051 return;
1052 } else {
1053 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1054 Cdb->StatCode = PXE_STATCODE_SUCCESS;
1055 }
1056
1057 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1058 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1059 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1060 return;
1061 }
1062
1063 Cpb = (PXE_CPB_MCAST_IP_TO_MAC *)(UINTN)Cdb->CPBaddr;
1064 Db = (PXE_DB_MCAST_IP_TO_MAC *)(UINTN)Cdb->DBaddr;
1065
1066 if ((Cdb->OpFlags & PXE_OPFLAGS_MCAST_IPV6_TO_MAC) != 0) {
1067 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1068 Cdb->StatCode = PXE_STATCODE_UNSUPPORTED;
1069 return;
1070 }
1071
1072 Tmp = (UINT8 *)(&Cpb->IP.IPv4);
1073
1074 if ((Tmp[0] & 0xF0) != 0xE0) {
1075 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1076 Cdb->StatCode = PXE_STATCODE_INVALID_CPB;
1077 }
1078
1079 Db->MAC[0] = 0x01;
1080 Db->MAC[1] = 0x00;
1081 Db->MAC[2] = 0x5E;
1082 Db->MAC[3] = Tmp[1] & 0x7F;
1083 Db->MAC[4] = Tmp[2];
1084 Db->MAC[5] = Tmp[3];
1085
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;
1090 }
1091 }
1092}
1093
1102VOID
1104 IN PXE_CDB *Cdb,
1105 IN NIC_DATA *Nic
1106 )
1107{
1108 EFI_STATUS Status;
1109
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;
1115 } else {
1116 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1117 Cdb->StatCode = PXE_STATCODE_SUCCESS;
1118 }
1119 }
1120}
1121
1130VOID
1132 IN PXE_CDB *Cdb,
1133 IN NIC_DATA *Nic
1134 )
1135{
1137 PXE_DB_GET_STATUS TmpGetStatus;
1138 UINT16 NumEntries;
1139 UINTN Index;
1140 EFI_STATUS Status;
1141
1142 if ((Cdb->OpCode != PXE_OPCODE_GET_STATUS) ||
1143 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1144 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1145 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
1146 (Cdb->CPBsize != PXE_CPBSIZE_NOT_USED) ||
1147 (Cdb->CPBaddr != PXE_CPBADDR_NOT_USED))
1148 {
1149 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1150 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1151 return;
1152 } else {
1153 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1154 Cdb->StatCode = PXE_STATCODE_SUCCESS;
1155 }
1156
1157 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1158 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1159 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1160 return;
1161 }
1162
1163 TmpGetStatus.RxFrameLen = 0;
1164 TmpGetStatus.reserved = 0;
1165 Db = (PXE_DB_GET_STATUS *)(UINTN)Cdb->DBaddr;
1166
1167 if ((Cdb->DBsize > 0) && (Cdb->DBsize < sizeof (UINT32) * 2)) {
1168 CopyMem (Db, &TmpGetStatus, Cdb->DBsize);
1169 } else {
1170 CopyMem (Db, &TmpGetStatus, sizeof (UINT32) * 2);
1171 }
1172
1173 if ((Cdb->OpFlags & PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS) != 0) {
1174 if (Cdb->DBsize == 0) {
1175 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1176 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1177 return;
1178 }
1179
1180 NumEntries = Cdb->DBsize - sizeof (UINT64);
1181 Cdb->DBsize = sizeof (UINT32) * 2;
1182
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];
1187 }
1188 }
1189 }
1190
1191 if ((Cdb->OpFlags & PXE_OPFLAGS_GET_INTERRUPT_STATUS) != 0) {
1192 if (Nic->ReceiveStatus != 0) {
1193 Cdb->StatFlags |= PXE_STATFLAGS_GET_STATUS_RECEIVE;
1194 }
1195 }
1196
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;
1201 }
1202
1203 if ((Cdb->OpFlags & PXE_OPFLAGS_GET_MEDIA_STATUS) != 0) {
1204 if (Nic->CableDetect == 0) {
1205 Cdb->StatFlags |= PXE_STATFLAGS_GET_STATUS_NO_MEDIA;
1206 }
1207 }
1208
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;
1213 }
1214 }
1215}
1216
1224VOID
1226 IN PXE_CDB *Cdb,
1227 IN NIC_DATA *Nic
1228 )
1229{
1230 PXE_CPB_FILL_HEADER *CpbFillHeader;
1232 ETHERNET_HEADER *MacHeader;
1233 UINTN Index;
1234 EFI_STATUS Status;
1235
1236 if ((Cdb->OpCode != PXE_OPCODE_FILL_HEADER) ||
1237 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1238 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1239 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
1240 (Cdb->CPBsize != sizeof (PXE_CPB_FILL_HEADER_FRAGMENTED)) ||
1241 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
1242 (Cdb->DBaddr != PXE_DBADDR_NOT_USED))
1243 {
1244 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1245 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1246 return;
1247 } else {
1248 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1249 Cdb->StatCode = PXE_STATCODE_SUCCESS;
1250 }
1251
1252 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1253 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1254 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1255 return;
1256 }
1257
1258 if (Cdb->CPBsize == PXE_CPBSIZE_NOT_USED) {
1259 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1260 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1261 return;
1262 }
1263
1264 if ((Cdb->OpFlags & PXE_OPFLAGS_FILL_HEADER_FRAGMENTED) != 0) {
1265 CpbFill = (PXE_CPB_FILL_HEADER_FRAGMENTED *)(UINTN)Cdb->CPBaddr;
1266
1267 if ((CpbFill->FragCnt == 0) || (CpbFill->FragDesc[0].FragLen < PXE_MAC_HEADER_LEN_ETHER)) {
1268 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1269 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1270 return;
1271 }
1272
1273 MacHeader = (ETHERNET_HEADER *)(UINTN)CpbFill->FragDesc[0].FragAddr;
1274 MacHeader->Protocol = CpbFill->Protocol;
1275
1276 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1277 MacHeader->DestAddr[Index] = CpbFill->DestAddr[Index];
1278 MacHeader->SrcAddr[Index] = CpbFill->SrcAddr[Index];
1279 }
1280 } else {
1281 CpbFillHeader = (PXE_CPB_FILL_HEADER *)(UINTN)Cdb->CPBaddr;
1282
1283 MacHeader = (ETHERNET_HEADER *)(UINTN)CpbFillHeader->MediaHeader;
1284 MacHeader->Protocol = CpbFillHeader->Protocol;
1285
1286 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1287 MacHeader->DestAddr[Index] = CpbFillHeader->DestAddr[Index];
1288 MacHeader->SrcAddr[Index] = CpbFillHeader->SrcAddr[Index];
1289 }
1290 }
1291
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;
1296 }
1297 }
1298}
1299
1307VOID
1309 IN PXE_CDB *Cdb,
1310 IN NIC_DATA *Nic
1311 )
1312{
1313 EFI_STATUS Status;
1314
1315 if ((Cdb->OpCode != PXE_OPCODE_TRANSMIT) ||
1316 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1317 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1318 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
1319 (Cdb->CPBsize != sizeof (PXE_CPB_TRANSMIT)) ||
1320 (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
1321 (Cdb->DBaddr != PXE_DBADDR_NOT_USED))
1322 {
1323 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1324 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1325 return;
1326 } else {
1327 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1328 Cdb->StatCode = PXE_STATCODE_SUCCESS;
1329 }
1330
1331 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1332 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1333 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1334 return;
1335 }
1336
1337 if (Cdb->CPBsize == PXE_CPBSIZE_NOT_USED) {
1338 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1339 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1340 return;
1341 }
1342
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;
1347 }
1348
1349 return;
1350 }
1351
1352 Cdb->StatCode = Transmit (Cdb, Nic, Cdb->CPBaddr, Cdb->OpFlags);
1353
1354 if (Cdb->StatCode != PXE_STATCODE_SUCCESS) {
1355 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1356 }
1357}
1358
1368UINT16
1369Transmit (
1370 IN PXE_CDB *Cdb,
1371 IN OUT NIC_DATA *Nic,
1372 IN UINT64 CpbAddr,
1373 IN UINT16 OpFlags
1374 )
1375{
1376 EFI_STATUS Status;
1377 PXE_CPB_TRANSMIT *Cpb;
1378 UINT64 BulkOutData;
1379 UINTN DataLength;
1380 UINTN TransmitLength;
1381 UINTN Map;
1382 UINT32 Counter;
1383 UINT16 StatCode;
1384
1385 BulkOutData = 0;
1386 Counter = 0;
1387 Cpb = (PXE_CPB_TRANSMIT *)(UINTN)CpbAddr;
1388
1389 if (Nic->CanTransmit) {
1390 return PXE_STATCODE_BUSY;
1391 }
1392
1393 Nic->CanTransmit = TRUE;
1394
1395 if ((OpFlags & PXE_OPFLAGS_TRANSMIT_FRAGMENTED) != 0) {
1396 return PXE_STATCODE_INVALID_PARAMETER;
1397 }
1398
1399 Map = MapIt (
1400 Nic,
1401 Cpb->FrameAddr,
1402 Cpb->DataLen + (UINT32)Cpb->MediaheaderLen,
1403 TO_DEVICE,
1404 (UINT64)(UINTN)&BulkOutData
1405 );
1406
1407 if (Map != 0) {
1408 Nic->CanTransmit = FALSE;
1409 return PXE_STATCODE_INVALID_PARAMETER;
1410 }
1411
1412 if (Nic->TxBufferCount < MAX_XMIT_BUFFERS) {
1413 Nic->MediaHeader[Nic->TxBufferCount] = Cpb->FrameAddr;
1414 Nic->TxBufferCount++;
1415 }
1416
1417 DataLength = (UINTN)(Cpb->DataLen + (UINT32)Cpb->MediaheaderLen);
1418
1419 while (1) {
1420 if (Counter >= 3) {
1421 StatCode = PXE_STATCODE_BUSY;
1422 break;
1423 }
1424
1425 TransmitLength = DataLength;
1426
1427 Status = Nic->UsbEth->UsbEthTransmit (Cdb, Nic->UsbEth, (VOID *)(UINTN)BulkOutData, &TransmitLength);
1428 if (EFI_ERROR (Status)) {
1429 StatCode = PXE_STATFLAGS_COMMAND_FAILED;
1430 }
1431
1432 if (Status == EFI_INVALID_PARAMETER) {
1433 StatCode = PXE_STATCODE_INVALID_PARAMETER;
1434 break;
1435 }
1436
1437 if (Status == EFI_DEVICE_ERROR) {
1438 StatCode = PXE_STATCODE_DEVICE_FAILURE;
1439 break;
1440 }
1441
1442 if (!EFI_ERROR (Status)) {
1443 Nic->TxFrame++;
1444 StatCode = PXE_STATCODE_SUCCESS;
1445 break;
1446 }
1447
1448 Counter++;
1449 }
1450
1451 UnMapIt (
1452 Nic,
1453 Cpb->FrameAddr,
1454 Cpb->DataLen + (UINT32)Cpb->MediaheaderLen,
1455 TO_DEVICE,
1456 BulkOutData
1457 );
1458
1459 Nic->CanTransmit = FALSE;
1460
1461 return StatCode;
1462}
1463
1472VOID
1474 IN PXE_CDB *Cdb,
1475 IN NIC_DATA *Nic
1476 )
1477{
1478 EFI_STATUS Status;
1479
1480 if ((Cdb->OpCode != PXE_OPCODE_RECEIVE) ||
1481 (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
1482 (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
1483 (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
1484 (Cdb->CPBsize != sizeof (PXE_CPB_RECEIVE)) ||
1485 (Cdb->DBsize != sizeof (PXE_DB_RECEIVE)) ||
1486 (Cdb->OpFlags != PXE_OPFLAGS_NOT_USED))
1487 {
1488 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1489 Cdb->StatCode = PXE_STATCODE_INVALID_CDB;
1490 return;
1491 } else {
1492 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_COMPLETE;
1493 Cdb->StatCode = PXE_STATCODE_SUCCESS;
1494 }
1495
1496 if (Nic->State != PXE_STATFLAGS_GET_STATE_INITIALIZED) {
1497 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1498 Cdb->StatCode = PXE_STATCODE_NOT_INITIALIZED;
1499 return;
1500 }
1501
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;
1506 }
1507
1508 return;
1509 }
1510
1511 Cdb->StatCode = Receive (Cdb, Nic, Cdb->CPBaddr, Cdb->DBaddr);
1512
1513 if (Cdb->StatCode != PXE_STATCODE_SUCCESS) {
1514 Cdb->StatFlags = PXE_STATFLAGS_COMMAND_FAILED;
1515 }
1516}
1517
1527UINT16
1528Receive (
1529 IN PXE_CDB *Cdb,
1530 IN OUT NIC_DATA *Nic,
1531 IN UINT64 CpbAddr,
1532 IN OUT UINT64 DbAddr
1533 )
1534{
1535 EFI_STATUS Status;
1536 UINTN Index;
1537 PXE_FRAME_TYPE FrameType;
1538 PXE_CPB_RECEIVE *Cpb;
1539 PXE_DB_RECEIVE *Db;
1540 NIC_DEVICE *NicDevice;
1541 UINT8 *BulkInData;
1542 UINTN DataLength;
1543 ETHERNET_HEADER *Header;
1544 EFI_TPL OriginalTpl;
1545
1546 FrameType = PXE_FRAME_TYPE_NONE;
1547 NicDevice = UNDI_DEV_FROM_NIC (Nic);
1548 BulkInData = NicDevice->ReceiveBuffer;
1549 DataLength = (UINTN)Nic->MaxSegmentSize;
1550 Cpb = (PXE_CPB_RECEIVE *)(UINTN)CpbAddr;
1551 Db = (PXE_DB_RECEIVE *)(UINTN)DbAddr;
1552
1553 if (!BulkInData) {
1554 return PXE_STATCODE_INVALID_PARAMETER;
1555 }
1556
1557 if ((Nic->RateLimitingCreditCount == 0) && (Nic->RateLimitingEnable == TRUE)) {
1558 return PXE_STATCODE_NO_DATA;
1559 }
1560
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--;
1568 }
1569
1570 gBS->RestoreTPL (OriginalTpl);
1571 }
1572
1573 return PXE_STATCODE_NO_DATA;
1574 }
1575
1576 Nic->RxFrame++;
1577
1578 if (DataLength != 0) {
1579 if (DataLength > Cpb->BufferLen) {
1580 DataLength = (UINTN)Cpb->BufferLen;
1581 }
1582
1583 CopyMem ((UINT8 *)(UINTN)Cpb->BufferAddr, (UINT8 *)BulkInData, DataLength);
1584
1585 Header = (ETHERNET_HEADER *)BulkInData;
1586
1587 Db->FrameLen = (UINT32)DataLength;
1588 Db->MediaHeaderLen = PXE_MAC_HEADER_LEN_ETHER;
1589
1590 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1591 if (Header->DestAddr[Index] != Nic->CurrentNodeAddress[Index]) {
1592 break;
1593 }
1594 }
1595
1596 if (Index >= PXE_HWADDR_LEN_ETHER) {
1597 FrameType = PXE_FRAME_TYPE_UNICAST;
1598 } else {
1599 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1600 if (Header->DestAddr[Index] != Nic->BroadcastNodeAddress[Index]) {
1601 break;
1602 }
1603 }
1604
1605 if (Index >= PXE_HWADDR_LEN_ETHER) {
1606 FrameType = PXE_FRAME_TYPE_BROADCAST;
1607 } else {
1608 if ((Header->DestAddr[0] & 1) == 1) {
1609 FrameType = PXE_FRAME_TYPE_FILTERED_MULTICAST;
1610 } else {
1611 FrameType = PXE_FRAME_TYPE_PROMISCUOUS;
1612 }
1613 }
1614 }
1615
1616 Db->Type = FrameType;
1617 Db->Protocol = Header->Protocol;
1618
1619 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
1620 Db->SrcAddr[Index] = Header->SrcAddr[Index];
1621 Db->DestAddr[Index] = Header->DestAddr[Index];
1622 }
1623 }
1624
1625 if (FrameType == PXE_FRAME_TYPE_NONE) {
1626 Nic->ReceiveStatus = 0;
1627 } else {
1628 Nic->ReceiveStatus = 1;
1629 }
1630
1631 return PXE_STATCODE_SUCCESS;
1632}
1633
1640VOID
1642 OUT PXE_SW_UNDI *PxeSw
1643 )
1644{
1645 PxeSw->Signature = PXE_ROMID_SIGNATURE;
1646 PxeSw->Len = (UINT8)sizeof (PXE_SW_UNDI);
1647 PxeSw->Fudge = 0;
1648 PxeSw->IFcnt = 0;
1649 PxeSw->IFcntExt = 0;
1650 PxeSw->Rev = PXE_ROMID_REV;
1651 PxeSw->MajorVer = PXE_ROMID_MAJORVER;
1652 PxeSw->MinorVer = PXE_ROMID_MINORVER;
1653 PxeSw->reserved1 = 0;
1654
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;
1663
1664 PxeSw->EntryPoint = (UINT64)(UINTN)UndiApiEntry;
1665 PxeSw->reserved2[0] = 0;
1666 PxeSw->reserved2[1] = 0;
1667 PxeSw->reserved2[2] = 0;
1668 PxeSw->BusCnt = 1;
1669 PxeSw->BusType[0] = PXE_BUSTYPE_USB;
1670 PxeSw->Fudge = PxeSw->Fudge - CalculateSum8 ((VOID *)PxeSw, PxeSw->Len);
1671}
1672
1680VOID
1682 IN NIC_DATA *Nic,
1683 IN OUT PXE_SW_UNDI *PxeSw
1684 )
1685{
1686 UINT16 NicNum;
1687
1688 NicNum = (PxeSw->IFcnt | PxeSw->IFcntExt << 8);
1689
1690 if (Nic == NULL) {
1691 if (NicNum > 0) {
1692 NicNum--;
1693 }
1694
1695 PxeSw->IFcnt = (UINT8)(NicNum & 0xFF); // Get lower byte
1696 PxeSw->IFcntExt = (UINT8)((NicNum & 0xFF00) >> 8); // Get upper byte
1697 PxeSw->Fudge = (UINT8)(PxeSw->Fudge - CalculateSum8 ((VOID *)PxeSw, PxeSw->Len));
1698 return;
1699 }
1700
1701 NicNum++;
1702
1703 PxeSw->IFcnt = (UINT8)(NicNum & 0xFF); // Get lower byte
1704 PxeSw->IFcntExt = (UINT8)((NicNum & 0xFF00) >> 8); // Get upper byte
1705 PxeSw->Fudge = (UINT8)(PxeSw->Fudge - CalculateSum8 ((VOID *)PxeSw, PxeSw->Len));
1706}
1707
1715EFIAPI
1717 IN UINT64 Cdb
1718 )
1719{
1720 PXE_CDB *CdbPtr;
1721 NIC_DATA *Nic;
1722
1723 if (Cdb == 0) {
1724 return EFI_INVALID_PARAMETER;
1725 }
1726
1727 CdbPtr = (PXE_CDB *)(UINTN)Cdb;
1728 Nic = &(gLanDeviceList[CdbPtr->IFnum]->NicInfo);
1729 gUndiApiTable[CdbPtr->OpCode](CdbPtr, Nic);
1730 return EFI_SUCCESS;
1731}
1732
1745UINTN
1747 IN NIC_DATA *Nic,
1748 IN UINT64 MemAddr,
1749 IN UINT32 Size,
1750 IN UINT32 Direction,
1751 OUT UINT64 MappedAddr
1752 )
1753{
1754 UINT64 *PhyAddr;
1755
1756 PhyAddr = (UINT64 *)(UINTN)MappedAddr;
1757
1758 if (Nic->PxeStart.Map_Mem == 0) {
1759 *PhyAddr = MemAddr;
1760 } else {
1761 ((void (*)(UINT64, UINT64, UINT32, UINT32, UINT64))(UINTN) Nic->PxeStart.Map_Mem)(
1762 Nic->PxeStart.Unique_ID,
1763 MemAddr,
1764 Size,
1765 Direction,
1766 MappedAddr
1767 );
1768 }
1769
1770 return PXE_STATCODE_SUCCESS;
1771}
1772
1785VOID
1787 IN NIC_DATA *Nic,
1788 IN UINT64 MemAddr,
1789 IN UINT32 Size,
1790 IN UINT32 Direction,
1791 IN UINT64 MappedAddr
1792 )
1793{
1794 if (Nic->PxeStart.UnMap_Mem != 0) {
1795 ((void (*)(UINT64, UINT64, UINT32, UINT32, UINT64))(UINTN) Nic->PxeStart.UnMap_Mem)(
1796 Nic->PxeStart.Unique_ID,
1797 MemAddr,
1798 Size,
1799 Direction,
1800 MappedAddr
1801 );
1802 }
1803
1804 return;
1805}
UINT64 UINTN
UINT8 EFIAPI CalculateSum8(IN CONST UINT8 *Buffer, IN UINTN Length)
Definition: CheckSum.c:33
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)
#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
VOID UndiStatistics(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:941
VOID PxeStructInit(OUT PXE_SW_UNDI *PxeSw)
Definition: PxeFunction.c:1641
VOID UndiGetInitInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:268
EFI_STATUS EFIAPI UndiApiEntry(IN UINT64 Cdb)
Definition: PxeFunction.c:1716
VOID UndiInterruptEnable(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:667
VOID UnMapIt(IN NIC_DATA *Nic, IN UINT64 MemAddr, IN UINT32 Size, IN UINT32 Direction, IN UINT64 MappedAddr)
Definition: PxeFunction.c:1786
VOID UndiGetConfigInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:338
VOID UndiReceive(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:1473
VOID UndiShutdown(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
Definition: PxeFunction.c:614
VOID UndiTransmit(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:1308
VOID UndiStationAddress(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:871
VOID UpdateNicNum(IN NIC_DATA *Nic, IN OUT PXE_SW_UNDI *PxeSw)
Definition: PxeFunction.c:1681
VOID UndiStart(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:106
UINT16 Initialize(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
Definition: PxeFunction.c:492
UINT16 Statistics(IN NIC_DATA *Nic, IN UINT64 DbAddr, IN UINT16 DbSize)
Definition: PxeFunction.c:995
VOID UndiNvData(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:1103
VOID UndiReceiveFilter(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:695
UINT16 SetFilter(IN NIC_DATA *Nic, IN UINT16 SetFilter, IN UINT64 CpbAddr, IN UINT32 CpbSize)
Definition: PxeFunction.c:804
UINTN MapIt(IN NIC_DATA *Nic, IN UINT64 MemAddr, IN UINT32 Size, IN UINT32 Direction, OUT UINT64 MappedAddr)
Definition: PxeFunction.c:1746
VOID UndiFillHeader(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:1225
VOID UndiStop(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:201
VOID UndiInitialize(IN PXE_CDB *Cdb, IN OUT NIC_DATA *Nic)
Definition: PxeFunction.c:390
VOID UndiReset(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:550
VOID EFIAPI UndiRateLimiterCallback(IN EFI_EVENT Event, IN VOID *Context)
Definition: PxeFunction.c:41
VOID UndiGetStatus(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:1131
VOID UndiMcastIp2Mac(IN OUT PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:1032
VOID UndiGetState(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
Definition: PxeFunction.c:63
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
UINTN EFI_TPL
Definition: UefiBaseType.h:41
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ EfiBootServicesData
#define PXE_ROMID_MAJORVER
Definition: UefiPxe.h:844
#define PXE_OPCODE_TRANSMIT
Definition: UefiPxe.h:165
#define PXE_CPBSIZE_NOT_USED
zero
Definition: UefiPxe.h:57
#define PXE_OPCODE_STATISTICS
Definition: UefiPxe.h:140
PXE_UINT16 PXE_STATFLAGS
Definition: UefiPxe.h:401
#define PXE_OPCODE_STOP
Definition: UefiPxe.h:95
#define PXE_OPCODE_GET_STATUS
Definition: UefiPxe.h:155
#define PXE_STATFLAGS_GET_STATUS_RECEIVE
Definition: UefiPxe.h:542
#define PXE_OPCODE_GET_STATE
Definition: UefiPxe.h:85
#define PXE_IFTYPE_ETHERNET
Definition: UefiPxe.h:706
#define PXE_OPFLAGS_RECEIVE_FILTER_OPMASK
Definition: UefiPxe.h:269
#define PXE_OPCODE_STATION_ADDRESS
Definition: UefiPxe.h:135
#define PXE_ROMID_REV
Definition: UefiPxe.h:837
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA
Definition: UefiPxe.h:574
#define PXE_ROMID_SIGNATURE
Definition: UefiPxe.h:832
#define PXE_OPCODE_MCAST_IP_TO_MAC
Definition: UefiPxe.h:145
#define PXE_OPCODE_FILL_HEADER
Definition: UefiPxe.h:160
#define PXE_OPCODE_GET_CONFIG_INFO
Definition: UefiPxe.h:105
#define PXE_OPFLAGS_GET_INTERRUPT_STATUS
Definition: UefiPxe.h:352
#define MAX_XMIT_BUFFERS
recycling Q length for xmit_done.
Definition: UefiPxe.h:919
#define PXE_OPFLAGS_GET_MEDIA_STATUS
Definition: UefiPxe.h:367
#define PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST
Definition: UefiPxe.h:278
#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS
Definition: UefiPxe.h:362
#define PXE_DBSIZE_NOT_USED
zero
Definition: UefiPxe.h:58
#define PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS
Definition: UefiPxe.h:218
#define PXE_CPBADDR_NOT_USED
zero
Definition: UefiPxe.h:59
#define PXE_OPCODE_RESET
Definition: UefiPxe.h:115
#define PXE_DBADDR_NOT_USED
zero
Definition: UefiPxe.h:60
#define PXE_OPFLAGS_STATISTICS_READ
Definition: UefiPxe.h:320
#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST
Definition: UefiPxe.h:297
#define PXE_OPCODE_RECEIVE
Definition: UefiPxe.h:170
#define PXE_OPCODE_INITIALIZE
Definition: UefiPxe.h:110
#define PXE_OPCODE_RECEIVE_FILTERS
Definition: UefiPxe.h:130
#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST
Definition: UefiPxe.h:308
#define PXE_OPCODE_START
Definition: UefiPxe.h:90
#define PXE_OPCODE_GET_INIT_INFO
Definition: UefiPxe.h:100
#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA
Definition: UefiPxe.h:446
#define PXE_STATCODE_SUCCESS
Definition: UefiPxe.h:602
#define PXE_OPCODE_SHUTDOWN
Definition: UefiPxe.h:120
#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST
Definition: UefiPxe.h:290
@ TimerCancel
Definition: UefiSpec.h:531
@ TimerPeriodic
Definition: UefiSpec.h:535
PXE_MEDIA_PROTOCOL Protocol
Definition: UefiPxe.h:1622
struct s_pxe_cpb_fill_header_fragmented::@1060 FragDesc[MAX_XMIT_FRAGMENTS]
PXE_UINT64 MediaHeader
Definition: UefiPxe.h:1580
PXE_UINT16 Protocol
Definition: UefiPxe.h:1592
PXE_MAC_ADDR SrcAddr
Definition: UefiPxe.h:1573
PXE_UINT32 MemoryLength
Definition: UefiPxe.h:1252
PXE_UINT64 MemoryAddr
Definition: UefiPxe.h:1246
PXE_UINT8 DuplexMode
Definition: UefiPxe.h:1280
PXE_UINT32 LinkSpeed
Definition: UefiPxe.h:1259
PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT]
Definition: UefiPxe.h:1321
PXE_UINT32 BufferLen
Definition: UefiPxe.h:1735
PXE_UINT64 BufferAddr
Definition: UefiPxe.h:1728
PXE_MAC_ADDR StationAddr
Definition: UefiPxe.h:1336
PXE_UINT16 MediaheaderLen
Definition: UefiPxe.h:1677
PXE_UINT32 DataLen
Definition: UefiPxe.h:1672
PXE_UINT64 FrameAddr
Definition: UefiPxe.h:1666
PXE_UINT8 SupportedLoopBackModes
Definition: UefiPxe.h:1169
PXE_UINT32 MemoryRequired
Definition: UefiPxe.h:1100
PXE_UINT32 FrameDataLen
Definition: UefiPxe.h:1105
PXE_UINT16 HWaddrLen
Definition: UefiPxe.h:1134
PXE_UINT16 TxBufCnt
Definition: UefiPxe.h:1149
PXE_UINT16 MCastFilterCnt
Definition: UefiPxe.h:1140
PXE_UINT8 SupportedDuplexModes
Definition: UefiPxe.h:1164
PXE_UINT32 LinkSpeeds[4]
Definition: UefiPxe.h:1112
PXE_UINT16 MediaHeaderLen
Definition: UefiPxe.h:1129
PXE_UINT64 TxBuffer[MAX_XMIT_BUFFERS]
Definition: UefiPxe.h:1565
PXE_UINT32 RxFrameLen
Definition: UefiPxe.h:1555
PXE_UINT32 reserved
Definition: UefiPxe.h:1560
PXE_UINT16 TxBufCnt
Definition: UefiPxe.h:1310
PXE_UINT32 MemoryUsed
Definition: UefiPxe.h:1304
PXE_MAC_ADDR SrcAddr
Definition: UefiPxe.h:1747
PXE_UINT32 FrameLen
Definition: UefiPxe.h:1755
PXE_FRAME_TYPE Type
Definition: UefiPxe.h:1770
PXE_UINT16 MediaHeaderLen
Definition: UefiPxe.h:1765
PXE_MEDIA_PROTOCOL Protocol
Definition: UefiPxe.h:1760
PXE_UINT64 Supported
Definition: UefiPxe.h:1366
PXE_UINT64 Data[64]
Definition: UefiPxe.h:1371
PXE_MAC_ADDR PermanentAddr
Definition: UefiPxe.h:1353
PXE_MAC_ADDR StationAddr
Definition: UefiPxe.h:1343
PXE_MAC_ADDR BroadcastAddr
Definition: UefiPxe.h:1348
PXE_UINT8 IFcnt
physical connector count lower byte.
Definition: UefiPxe.h:812
PXE_UINT8 IFcntExt
physical connector count upper byte.
Definition: UefiPxe.h:815