X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FMnpDxe%2FMnpIo.c;h=d9df1d45b21eb5d05303bd92a591236c23b46571;hp=91b8d4e0b854e327c8b7413533d66b659052fb8b;hb=e48e37fce2611df7a52aff271835ff72ee396d9b;hpb=4eb65aff715faafd9040c6fc85a5d59e22343978 diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c index 91b8d4e0b8..d9df1d45b2 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c @@ -58,7 +58,7 @@ MnpIsValidTxToken ( // The token is invalid if the Event is NULL, or the TxData is NULL, or // the fragment count is zero. // - MNP_DEBUG_WARN (("MnpIsValidTxToken: Invalid Token.\n")); + DEBUG ((EFI_D_WARN, "MnpIsValidTxToken: Invalid Token.\n")); return FALSE; } @@ -67,7 +67,7 @@ MnpIsValidTxToken ( // The token is invalid if the HeaderLength isn't zero while the DestinationAddress // is NULL (The destination address is already put into the packet). // - MNP_DEBUG_WARN (("MnpIsValidTxToken: DestinationAddress isn't NULL, HeaderLength must be 0.\n")); + DEBUG ((EFI_D_WARN, "MnpIsValidTxToken: DestinationAddress isn't NULL, HeaderLength must be 0.\n")); return FALSE; } @@ -79,7 +79,7 @@ MnpIsValidTxToken ( // // The token is invalid if any FragmentLength is zero or any FragmentBuffer is NULL. // - MNP_DEBUG_WARN (("MnpIsValidTxToken: Invalid FragmentLength or FragmentBuffer.\n")); + DEBUG ((EFI_D_WARN, "MnpIsValidTxToken: Invalid FragmentLength or FragmentBuffer.\n")); return FALSE; } @@ -98,7 +98,7 @@ MnpIsValidTxToken ( // The length calculated from the fragment information doesn't equal to the // sum of the DataLength and the HeaderLength. // - MNP_DEBUG_WARN (("MnpIsValidTxData: Invalid Datalength compared with the sum of fragment length.\n")); + DEBUG ((EFI_D_WARN, "MnpIsValidTxData: Invalid Datalength compared with the sum of fragment length.\n")); return FALSE; } @@ -106,7 +106,7 @@ MnpIsValidTxToken ( // // The total length is larger than the MTU. // - MNP_DEBUG_WARN (("MnpIsValidTxData: TxData->DataLength exceeds Mtu.\n")); + DEBUG ((EFI_D_WARN, "MnpIsValidTxData: TxData->DataLength exceeds Mtu.\n")); return FALSE; } @@ -169,7 +169,7 @@ MnpBuildTxPacket ( // // Copy the data. // - NetCopyMem ( + CopyMem ( DstPos, TxData->FragmentTable[Index].FragmentBuffer, TxData->FragmentTable[Index].FragmentLength @@ -294,6 +294,11 @@ SIGNAL_TOKEN: Token->Status = Status; gBS->SignalEvent (Token->Event); + // + // Dispatch the DPC queued by the NotifyFunction of Token->Event. + // + NetLibDispatchDpc (); + return EFI_SUCCESS; } @@ -324,7 +329,7 @@ MnpInstanceDeliverPacket ( MnpServiceData = Instance->MnpServiceData; NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE); - if (NetMapIsEmpty (&Instance->RxTokenMap) || NetListIsEmpty (&Instance->RcvdPacketQueue)) { + if (NetMapIsEmpty (&Instance->RxTokenMap) || IsListEmpty (&Instance->RcvdPacketQueue)) { // // No pending received data or no available receive token, return. // @@ -341,7 +346,7 @@ MnpInstanceDeliverPacket ( // DupNbuf = MnpAllocNbuf (MnpServiceData); if (DupNbuf == NULL) { - MNP_DEBUG_WARN (("MnpDeliverPacket: Failed to allocate a free Nbuf.\n")); + DEBUG ((EFI_D_WARN, "MnpDeliverPacket: Failed to allocate a free Nbuf.\n")); return EFI_OUT_OF_RESOURCES; } @@ -374,7 +379,7 @@ MnpInstanceDeliverPacket ( // // Insert this RxDataWrap into the delivered queue. // - NetListInsertTail (&Instance->RxDeliveredPacketQueue, &RxDataWrap->WrapEntry); + InsertTailList (&Instance->RxDeliveredPacketQueue, &RxDataWrap->WrapEntry); // // Get the receive token from the RxTokenMap. @@ -406,7 +411,7 @@ MnpDeliverPacket ( IN MNP_SERVICE_DATA *MnpServiceData ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; MNP_INSTANCE_DATA *Instance; NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE); @@ -467,9 +472,9 @@ MnpRecycleRxData ( // // Remove this Wrap entry from the list. // - NetListRemoveEntry (&RxDataWrap->WrapEntry); + RemoveEntryList (&RxDataWrap->WrapEntry); - NetFreePool (RxDataWrap); + gBS->FreePool (RxDataWrap); } @@ -500,7 +505,7 @@ MnpQueueRcvdPacket ( // if (Instance->RcvdPacketQueueSize == MNP_MAX_RCVD_PACKET_QUE_SIZE) { - MNP_DEBUG_WARN (("MnpQueueRcvdPacket: Drop one packet bcz queue size limit reached.\n")); + DEBUG ((EFI_D_WARN, "MnpQueueRcvdPacket: Drop one packet bcz queue size limit reached.\n")); // // Get the oldest packet. @@ -526,7 +531,7 @@ MnpQueueRcvdPacket ( // // Insert this Wrap into the instance queue. // - NetListInsertTail (&Instance->RcvdPacketQueue, &RxDataWrap->WrapEntry); + InsertTailList (&Instance->RcvdPacketQueue, &RxDataWrap->WrapEntry); Instance->RcvdPacketQueueSize++; } @@ -555,19 +560,13 @@ MnpMatchPacket ( ) { EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData; - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk; NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE); ConfigData = &Instance->ConfigData; - if (ConfigData->EnablePromiscuousReceive) { - // - // Always match if this instance is configured to be promiscuous. - // - return TRUE; - } // // Check the protocol type. // @@ -575,6 +574,13 @@ MnpMatchPacket ( return FALSE; } + if (ConfigData->EnablePromiscuousReceive) { + // + // Always match if this instance is configured to be promiscuous. + // + return TRUE; + } + // // The protocol type is matched, check receive filter, include unicast and broadcast. // @@ -638,7 +644,7 @@ MnpAnalysePacket ( { EFI_SIMPLE_NETWORK_MODE *SnpMode; UINT8 *BufPtr; - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; SnpMode = MnpServiceData->Snp->Mode; @@ -701,7 +707,7 @@ MnpAnalysePacket ( } } - NetZeroMem (&RxData->Timestamp, sizeof (EFI_TIME)); + ZeroMem (&RxData->Timestamp, sizeof (EFI_TIME)); // // Fill the common parts of RxData. @@ -736,9 +742,9 @@ MnpWrapRxData ( // // Allocate memory. // - RxDataWrap = NetAllocatePool (sizeof (MNP_RXDATA_WRAP)); + RxDataWrap = AllocatePool (sizeof (MNP_RXDATA_WRAP)); if (RxDataWrap == NULL) { - MNP_DEBUG_ERROR (("MnpDispatchPacket: Failed to allocate a MNP_RXDATA_WRAP.\n")); + DEBUG ((EFI_D_ERROR, "MnpDispatchPacket: Failed to allocate a MNP_RXDATA_WRAP.\n")); return NULL; } @@ -747,22 +753,22 @@ MnpWrapRxData ( // // Fill the RxData in RxDataWrap, // - CopyMem (&RxDataWrap->RxData, RxData, sizeof (EFI_MANAGED_NETWORK_RECEIVE_DATA)); + CopyMem (&RxDataWrap->RxData, RxData, sizeof (RxDataWrap->RxData)); // // Create the recycle event. // Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, - NET_TPL_RECYCLE, + TPL_NOTIFY, MnpRecycleRxData, RxDataWrap, &RxDataWrap->RxData.RecycleEvent ); if (EFI_ERROR (Status)) { - MNP_DEBUG_ERROR (("MnpDispatchPacket: gBS->CreateEvent failed, %r.\n", Status)); - NetFreePool (RxDataWrap); + DEBUG ((EFI_D_ERROR, "MnpDispatchPacket: gBS->CreateEvent failed, %r.\n", Status)); + gBS->FreePool (RxDataWrap); return NULL; } @@ -788,13 +794,15 @@ MnpEnqueuePacket ( IN NET_BUF *Nbuf ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; MNP_INSTANCE_DATA *Instance; EFI_MANAGED_NETWORK_RECEIVE_DATA RxData; UINT8 PktAttr; MNP_GROUP_ADDRESS *GroupAddress; MNP_RXDATA_WRAP *RxDataWrap; + + GroupAddress = NULL; // // First, analyse the packet header. // @@ -827,7 +835,7 @@ MnpEnqueuePacket ( // // Wrap the RxData. // - CopyMem (&RxDataWrap, MnpWrapRxData (Instance, &RxData), sizeof (MNP_RXDATA_WRAP)); + RxDataWrap = MnpWrapRxData (Instance, &RxData); if (RxDataWrap == NULL) { continue; } @@ -881,7 +889,7 @@ MnpReceivePacket ( return EFI_NOT_STARTED; } - if (NetListIsEmpty (&MnpServiceData->ChildrenList)) { + if (IsListEmpty (&MnpServiceData->ChildrenList)) { // // There is no child, no need to receive packets. // @@ -921,7 +929,7 @@ MnpReceivePacket ( DEBUG_CODE ( if (Status != EFI_NOT_READY) { - MNP_DEBUG_ERROR (("MnpReceivePacket: Snp->Receive() = %r.\n", Status)); + DEBUG ((EFI_D_ERROR, "MnpReceivePacket: Snp->Receive() = %r.\n", Status)); } ); @@ -933,8 +941,9 @@ MnpReceivePacket ( // if ((HeaderSize != Snp->Mode->MediaHeaderSize) || (BufLen < HeaderSize)) { - MNP_DEBUG_WARN ( - ("MnpReceivePacket: Size error, HL:TL = %d:%d.\n", + DEBUG ( + (EFI_D_WARN, + "MnpReceivePacket: Size error, HL:TL = %d:%d.\n", HeaderSize, BufLen) ); @@ -965,7 +974,7 @@ MnpReceivePacket ( Nbuf = MnpAllocNbuf (MnpServiceData); MnpServiceData->RxNbufCache = Nbuf; if (Nbuf == NULL) { - MNP_DEBUG_ERROR (("MnpReceivePacket: Alloc packet for receiving cache failed.\n")); + DEBUG ((EFI_D_ERROR, "MnpReceivePacket: Alloc packet for receiving cache failed.\n")); return EFI_DEVICE_ERROR; } @@ -974,7 +983,10 @@ MnpReceivePacket ( // // No receiver for this packet. // - NetbufAllocSpace (Nbuf, Trimmed, NET_BUF_TAIL); + if (Trimmed > 0) { + NetbufAllocSpace (Nbuf, Trimmed, NET_BUF_TAIL); + } + goto EXIT; } // @@ -982,6 +994,11 @@ MnpReceivePacket ( // MnpDeliverPacket (MnpServiceData); + // + // Dispatch the DPC queued by the NotifyFunction of rx token's events. + // + NetLibDispatchDpc (); + EXIT: ASSERT (Nbuf->TotalSize == MnpServiceData->BufferLength); @@ -1008,9 +1025,9 @@ MnpCheckPacketTimeout ( ) { MNP_SERVICE_DATA *MnpServiceData; - NET_LIST_ENTRY *Entry; - NET_LIST_ENTRY *RxEntry; - NET_LIST_ENTRY *NextEntry; + LIST_ENTRY *Entry; + LIST_ENTRY *RxEntry; + LIST_ENTRY *NextEntry; MNP_INSTANCE_DATA *Instance; MNP_RXDATA_WRAP *RxDataWrap; EFI_TPL OldTpl; @@ -1031,7 +1048,7 @@ MnpCheckPacketTimeout ( continue; } - OldTpl = NET_RAISE_TPL (NET_TPL_RECYCLE); + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); NET_LIST_FOR_EACH_SAFE (RxEntry, NextEntry, &Instance->RcvdPacketQueue) { @@ -1044,13 +1061,13 @@ MnpCheckPacketTimeout ( // // Drop the timeout packet. // - MNP_DEBUG_WARN (("MnpCheckPacketTimeout: Received packet timeout.\n")); + DEBUG ((EFI_D_WARN, "MnpCheckPacketTimeout: Received packet timeout.\n")); MnpRecycleRxData (NULL, RxDataWrap); Instance->RcvdPacketQueueSize--; } } - NET_RESTORE_TPL (OldTpl); + gBS->RestoreTPL (OldTpl); } } @@ -1082,4 +1099,6 @@ MnpSystemPoll ( // Try to receive packets from Snp. // MnpReceivePacket (MnpServiceData); + + NetLibDispatchDpc (); }