From aeddd42532529a3701dc9f9a4f78005c075bc0d6 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Thu, 13 Aug 2009 06:37:36 +0000 Subject: 1. update timeout interval time from 10ms to 50ms 2. refine MnpDxe code. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9063 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c | 314 +++++++++++----------- MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h | 20 +- MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c | 4 +- MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c | 2 +- MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h | 4 +- 5 files changed, 180 insertions(+), 164 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c index cc027a5..838765d 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c @@ -1,7 +1,7 @@ /** @file Implementation of Managed Network Protocol private services. -Copyright (c) 2005 - 2008, Intel Corporation.
+Copyright (c) 2005 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -44,162 +44,6 @@ EFI_MANAGED_NETWORK_CONFIG_DATA mMnpDefaultConfigData = { FALSE }; -/** - Configure the Snp receive filters according to the instances' receive filter - settings. - - @param[in] MnpServiceData Pointer to the mnp service context data. - - @retval EFI_SUCCESS The receive filters is configured. - @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due - to lack of memory resource. - -**/ -EFI_STATUS -MnpConfigReceiveFilters ( - IN MNP_SERVICE_DATA *MnpServiceData - ) -{ - EFI_STATUS Status; - EFI_SIMPLE_NETWORK_PROTOCOL *Snp; - EFI_MAC_ADDRESS *MCastFilter; - UINT32 MCastFilterCnt; - UINT32 EnableFilterBits; - UINT32 DisableFilterBits; - BOOLEAN ResetMCastFilters; - LIST_ENTRY *Entry; - UINT32 Index; - MNP_GROUP_ADDRESS *GroupAddress; - - NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE); - - Snp = MnpServiceData->Snp; - - // - // Initialize the enable filter and disable filter. - // - EnableFilterBits = 0; - DisableFilterBits = Snp->Mode->ReceiveFilterMask; - - if (MnpServiceData->UnicastCount != 0) { - // - // Enable unicast if any instance wants to receive unicast. - // - EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST; - } - - if (MnpServiceData->BroadcastCount != 0) { - // - // Enable broadcast if any instance wants to receive broadcast. - // - EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST; - } - - MCastFilter = NULL; - MCastFilterCnt = 0; - ResetMCastFilters = TRUE; - - if ((MnpServiceData->MulticastCount != 0) && (MnpServiceData->GroupAddressCount != 0)) { - // - // There are instances configured to receive multicast and already some group - // addresses are joined. - // - - ResetMCastFilters = FALSE; - - if (MnpServiceData->GroupAddressCount <= Snp->Mode->MaxMCastFilterCount) { - // - // The joind group address is less than simple network's maximum count. - // Just configure the snp to do the multicast filtering. - // - - EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST; - - // - // Allocate pool for the mulicast addresses. - // - MCastFilterCnt = MnpServiceData->GroupAddressCount; - MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt); - if (MCastFilter == NULL) { - - DEBUG ((EFI_D_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n")); - return EFI_OUT_OF_RESOURCES; - } - - // - // Fill the multicast HW address buffer. - // - Index = 0; - NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) { - - GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry); - CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index))); - Index++; - - ASSERT (Index <= MCastFilterCnt); - } - } else { - // - // The maximum multicast is reached, set the filter to be promiscuous - // multicast. - // - - if ((Snp->Mode->ReceiveFilterMask & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) { - EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; - } else { - // - // Either MULTICAST or PROMISCUOUS_MULTICAST is not supported by Snp, - // set the NIC to be promiscuous although this will tremendously degrade - // the performance. - // - EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS; - } - } - } - - if (MnpServiceData->PromiscuousCount != 0) { - // - // Enable promiscuous if any instance wants to receive promiscuous. - // - EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS; - } - - // - // Set the disable filter. - // - DisableFilterBits ^= EnableFilterBits; - - // - // Configure the receive filters of SNP. - // - Status = Snp->ReceiveFilters ( - Snp, - EnableFilterBits, - DisableFilterBits, - ResetMCastFilters, - MCastFilterCnt, - MCastFilter - ); - DEBUG_CODE ( - if (EFI_ERROR (Status)) { - - DEBUG ( - (EFI_D_ERROR, - "MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n", - Status) - ); - } - ); - - if (MCastFilter != NULL) { - // - // Free the buffer used to hold the group addresses. - // - gBS->FreePool (MCastFilter); - } - - return Status; -} /** Add Count of net buffers to MnpServiceData->FreeNbufQue. The length of the net @@ -1157,6 +1001,162 @@ MnpConfigureInstance ( return Status; } +/** + Configure the Snp receive filters according to the instances' receive filter + settings. + + @param[in] MnpServiceData Pointer to the mnp service context data. + + @retval EFI_SUCCESS The receive filters is configured. + @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due + to lack of memory resource. + +**/ +EFI_STATUS +MnpConfigReceiveFilters ( + IN MNP_SERVICE_DATA *MnpServiceData + ) +{ + EFI_STATUS Status; + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + EFI_MAC_ADDRESS *MCastFilter; + UINT32 MCastFilterCnt; + UINT32 EnableFilterBits; + UINT32 DisableFilterBits; + BOOLEAN ResetMCastFilters; + LIST_ENTRY *Entry; + UINT32 Index; + MNP_GROUP_ADDRESS *GroupAddress; + + NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE); + + Snp = MnpServiceData->Snp; + + // + // Initialize the enable filter and disable filter. + // + EnableFilterBits = 0; + DisableFilterBits = Snp->Mode->ReceiveFilterMask; + + if (MnpServiceData->UnicastCount != 0) { + // + // Enable unicast if any instance wants to receive unicast. + // + EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST; + } + + if (MnpServiceData->BroadcastCount != 0) { + // + // Enable broadcast if any instance wants to receive broadcast. + // + EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST; + } + + MCastFilter = NULL; + MCastFilterCnt = 0; + ResetMCastFilters = TRUE; + + if ((MnpServiceData->MulticastCount != 0) && (MnpServiceData->GroupAddressCount != 0)) { + // + // There are instances configured to receive multicast and already some group + // addresses are joined. + // + + ResetMCastFilters = FALSE; + + if (MnpServiceData->GroupAddressCount <= Snp->Mode->MaxMCastFilterCount) { + // + // The joind group address is less than simple network's maximum count. + // Just configure the snp to do the multicast filtering. + // + + EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST; + + // + // Allocate pool for the mulicast addresses. + // + MCastFilterCnt = MnpServiceData->GroupAddressCount; + MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt); + if (MCastFilter == NULL) { + + DEBUG ((EFI_D_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n")); + return EFI_OUT_OF_RESOURCES; + } + + // + // Fill the multicast HW address buffer. + // + Index = 0; + NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) { + + GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry); + CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index))); + Index++; + + ASSERT (Index <= MCastFilterCnt); + } + } else { + // + // The maximum multicast is reached, set the filter to be promiscuous + // multicast. + // + + if ((Snp->Mode->ReceiveFilterMask & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) { + EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; + } else { + // + // Either MULTICAST or PROMISCUOUS_MULTICAST is not supported by Snp, + // set the NIC to be promiscuous although this will tremendously degrade + // the performance. + // + EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS; + } + } + } + + if (MnpServiceData->PromiscuousCount != 0) { + // + // Enable promiscuous if any instance wants to receive promiscuous. + // + EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS; + } + + // + // Set the disable filter. + // + DisableFilterBits ^= EnableFilterBits; + + // + // Configure the receive filters of SNP. + // + Status = Snp->ReceiveFilters ( + Snp, + EnableFilterBits, + DisableFilterBits, + ResetMCastFilters, + MCastFilterCnt, + MCastFilter + ); + DEBUG_CODE ( + if (EFI_ERROR (Status)) { + + DEBUG ( + (EFI_D_ERROR, + "MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n", + Status) + ); + } + ); + + if (MCastFilter != NULL) { + // + // Free the buffer used to hold the group addresses. + // + gBS->FreePool (MCastFilter); + } + + return Status; +} /** diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h b/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h index 9c6facd..b9fa4ab 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h @@ -1,7 +1,7 @@ /** @file Declaration of structures and functions of MnpDxe driver. -Copyright (c) 2005 - 2008, Intel Corporation.
+Copyright (c) 2005 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define NET_ETHER_FCS_SIZE 4 #define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds -#define MNP_TIMEOUT_CHECK_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds +#define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds #define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds #define MNP_INIT_NET_BUFFER_NUM 512 #define MNP_NET_BUFFER_INCREASEMENT 64 @@ -740,4 +740,20 @@ MnpPoll ( IN EFI_MANAGED_NETWORK_PROTOCOL *This ); +/** + Configure the Snp receive filters according to the instances' receive filter + settings. + + @param[in] MnpServiceData Pointer to the mnp service context data. + + @retval EFI_SUCCESS The receive filters is configured. + @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due + to lack of memory resource. + +**/ +EFI_STATUS +MnpConfigReceiveFilters ( + IN MNP_SERVICE_DATA *MnpServiceData + ); + #endif diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c index 0c8196a..a7b703f 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c @@ -1,7 +1,7 @@ /** @file Implementation of Managed Network Protocol I/O functions. -Copyright (c) 2005 - 2007, Intel Corporation.
+Copyright (c) 2005 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1016,7 +1016,7 @@ MnpCheckPacketTimeout ( RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry); // - // TimeoutTick unit is ms, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns. + // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns. // if (RxDataWrap->TimeoutTick >= (MNP_TIMEOUT_CHECK_INTERVAL / 10)) { diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c index 292673d..8d392ee 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c @@ -424,7 +424,7 @@ Udp4CheckTimeout ( Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP4_RXDATA_WRAP, Link); // - // TimeoutTick unit is ms, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns. + // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns. // if (Wrap->TimeoutTick <= (UDP4_TIMEOUT_INTERVAL / 10)) { // diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h index 82b21de..0823b69 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h @@ -1,7 +1,7 @@ /** @file EFI UDPv4 protocol implementation. -Copyright (c) 2006 - 2007, Intel Corporation.
+Copyright (c) 2006 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -43,7 +43,7 @@ extern UINT16 mUdp4RandomPort; #define ICMP_ERROR_PACKET_LENGTH 8 -#define UDP4_TIMEOUT_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds +#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds #define UDP4_HEADER_SIZE sizeof (EFI_UDP4_HEADER) #define UDP4_MAX_DATA_SIZE 65507 -- cgit v1.1