/** @file\r
Implementation of Managed Network Protocol private services.\r
\r
-Copyright (c) 2005 - 2008, Intel Corporation. <BR> \r
+Copyright (c) 2005 - 2009, Intel Corporation. <BR> \r
All rights reserved. This program and the accompanying materials are licensed \r
and made available under the terms and conditions of the BSD License which \r
accompanies this distribution. The full text of the license may be found at \r
FALSE\r
};\r
\r
-/**\r
- Configure the Snp receive filters according to the instances' receive filter\r
- settings.\r
-\r
- @param[in] MnpServiceData Pointer to the mnp service context data.\r
-\r
- @retval EFI_SUCCESS The receive filters is configured.\r
- @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due \r
- to lack of memory resource.\r
-\r
-**/\r
-EFI_STATUS\r
-MnpConfigReceiveFilters (\r
- IN MNP_SERVICE_DATA *MnpServiceData\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
- EFI_MAC_ADDRESS *MCastFilter;\r
- UINT32 MCastFilterCnt;\r
- UINT32 EnableFilterBits;\r
- UINT32 DisableFilterBits;\r
- BOOLEAN ResetMCastFilters;\r
- LIST_ENTRY *Entry;\r
- UINT32 Index;\r
- MNP_GROUP_ADDRESS *GroupAddress;\r
-\r
- NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r
-\r
- Snp = MnpServiceData->Snp;\r
-\r
- //\r
- // Initialize the enable filter and disable filter.\r
- //\r
- EnableFilterBits = 0;\r
- DisableFilterBits = Snp->Mode->ReceiveFilterMask;\r
-\r
- if (MnpServiceData->UnicastCount != 0) {\r
- //\r
- // Enable unicast if any instance wants to receive unicast.\r
- //\r
- EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r
- }\r
-\r
- if (MnpServiceData->BroadcastCount != 0) {\r
- //\r
- // Enable broadcast if any instance wants to receive broadcast.\r
- //\r
- EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r
- }\r
-\r
- MCastFilter = NULL;\r
- MCastFilterCnt = 0;\r
- ResetMCastFilters = TRUE;\r
-\r
- if ((MnpServiceData->MulticastCount != 0) && (MnpServiceData->GroupAddressCount != 0)) {\r
- //\r
- // There are instances configured to receive multicast and already some group\r
- // addresses are joined.\r
- //\r
-\r
- ResetMCastFilters = FALSE;\r
-\r
- if (MnpServiceData->GroupAddressCount <= Snp->Mode->MaxMCastFilterCount) {\r
- //\r
- // The joind group address is less than simple network's maximum count.\r
- // Just configure the snp to do the multicast filtering.\r
- //\r
-\r
- EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r
-\r
- //\r
- // Allocate pool for the mulicast addresses.\r
- //\r
- MCastFilterCnt = MnpServiceData->GroupAddressCount;\r
- MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);\r
- if (MCastFilter == NULL) {\r
-\r
- DEBUG ((EFI_D_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n"));\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Fill the multicast HW address buffer.\r
- //\r
- Index = 0;\r
- NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) {\r
-\r
- GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);\r
- CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index)));\r
- Index++;\r
-\r
- ASSERT (Index <= MCastFilterCnt);\r
- }\r
- } else {\r
- //\r
- // The maximum multicast is reached, set the filter to be promiscuous\r
- // multicast.\r
- //\r
-\r
- if ((Snp->Mode->ReceiveFilterMask & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r
- EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
- } else {\r
- //\r
- // Either MULTICAST or PROMISCUOUS_MULTICAST is not supported by Snp,\r
- // set the NIC to be promiscuous although this will tremendously degrade\r
- // the performance.\r
- //\r
- EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
- }\r
- }\r
- }\r
-\r
- if (MnpServiceData->PromiscuousCount != 0) {\r
- //\r
- // Enable promiscuous if any instance wants to receive promiscuous.\r
- //\r
- EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
- }\r
-\r
- //\r
- // Set the disable filter.\r
- //\r
- DisableFilterBits ^= EnableFilterBits;\r
-\r
- //\r
- // Configure the receive filters of SNP.\r
- //\r
- Status = Snp->ReceiveFilters (\r
- Snp,\r
- EnableFilterBits,\r
- DisableFilterBits,\r
- ResetMCastFilters,\r
- MCastFilterCnt,\r
- MCastFilter\r
- );\r
- DEBUG_CODE (\r
- if (EFI_ERROR (Status)) {\r
-\r
- DEBUG (\r
- (EFI_D_ERROR,\r
- "MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n",\r
- Status)\r
- );\r
- }\r
- );\r
-\r
- if (MCastFilter != NULL) {\r
- //\r
- // Free the buffer used to hold the group addresses.\r
- //\r
- gBS->FreePool (MCastFilter);\r
- }\r
-\r
- return Status;\r
-}\r
\r
/**\r
Add Count of net buffers to MnpServiceData->FreeNbufQue. The length of the net\r
return Status;\r
}\r
\r
+/**\r
+ Configure the Snp receive filters according to the instances' receive filter\r
+ settings.\r
+\r
+ @param[in] MnpServiceData Pointer to the mnp service context data.\r
+\r
+ @retval EFI_SUCCESS The receive filters is configured.\r
+ @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due \r
+ to lack of memory resource.\r
+\r
+**/\r
+EFI_STATUS\r
+MnpConfigReceiveFilters (\r
+ IN MNP_SERVICE_DATA *MnpServiceData\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+ EFI_MAC_ADDRESS *MCastFilter;\r
+ UINT32 MCastFilterCnt;\r
+ UINT32 EnableFilterBits;\r
+ UINT32 DisableFilterBits;\r
+ BOOLEAN ResetMCastFilters;\r
+ LIST_ENTRY *Entry;\r
+ UINT32 Index;\r
+ MNP_GROUP_ADDRESS *GroupAddress;\r
+\r
+ NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r
+\r
+ Snp = MnpServiceData->Snp;\r
+\r
+ //\r
+ // Initialize the enable filter and disable filter.\r
+ //\r
+ EnableFilterBits = 0;\r
+ DisableFilterBits = Snp->Mode->ReceiveFilterMask;\r
+\r
+ if (MnpServiceData->UnicastCount != 0) {\r
+ //\r
+ // Enable unicast if any instance wants to receive unicast.\r
+ //\r
+ EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r
+ }\r
+\r
+ if (MnpServiceData->BroadcastCount != 0) {\r
+ //\r
+ // Enable broadcast if any instance wants to receive broadcast.\r
+ //\r
+ EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r
+ }\r
+\r
+ MCastFilter = NULL;\r
+ MCastFilterCnt = 0;\r
+ ResetMCastFilters = TRUE;\r
+\r
+ if ((MnpServiceData->MulticastCount != 0) && (MnpServiceData->GroupAddressCount != 0)) {\r
+ //\r
+ // There are instances configured to receive multicast and already some group\r
+ // addresses are joined.\r
+ //\r
+\r
+ ResetMCastFilters = FALSE;\r
+\r
+ if (MnpServiceData->GroupAddressCount <= Snp->Mode->MaxMCastFilterCount) {\r
+ //\r
+ // The joind group address is less than simple network's maximum count.\r
+ // Just configure the snp to do the multicast filtering.\r
+ //\r
+\r
+ EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r
+\r
+ //\r
+ // Allocate pool for the mulicast addresses.\r
+ //\r
+ MCastFilterCnt = MnpServiceData->GroupAddressCount;\r
+ MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);\r
+ if (MCastFilter == NULL) {\r
+\r
+ DEBUG ((EFI_D_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n"));\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ //\r
+ // Fill the multicast HW address buffer.\r
+ //\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) {\r
+\r
+ GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);\r
+ CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index)));\r
+ Index++;\r
+\r
+ ASSERT (Index <= MCastFilterCnt);\r
+ }\r
+ } else {\r
+ //\r
+ // The maximum multicast is reached, set the filter to be promiscuous\r
+ // multicast.\r
+ //\r
+\r
+ if ((Snp->Mode->ReceiveFilterMask & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r
+ EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
+ } else {\r
+ //\r
+ // Either MULTICAST or PROMISCUOUS_MULTICAST is not supported by Snp,\r
+ // set the NIC to be promiscuous although this will tremendously degrade\r
+ // the performance.\r
+ //\r
+ EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (MnpServiceData->PromiscuousCount != 0) {\r
+ //\r
+ // Enable promiscuous if any instance wants to receive promiscuous.\r
+ //\r
+ EnableFilterBits |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
+ }\r
+\r
+ //\r
+ // Set the disable filter.\r
+ //\r
+ DisableFilterBits ^= EnableFilterBits;\r
+\r
+ //\r
+ // Configure the receive filters of SNP.\r
+ //\r
+ Status = Snp->ReceiveFilters (\r
+ Snp,\r
+ EnableFilterBits,\r
+ DisableFilterBits,\r
+ ResetMCastFilters,\r
+ MCastFilterCnt,\r
+ MCastFilter\r
+ );\r
+ DEBUG_CODE (\r
+ if (EFI_ERROR (Status)) {\r
+\r
+ DEBUG (\r
+ (EFI_D_ERROR,\r
+ "MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n",\r
+ Status)\r
+ );\r
+ }\r
+ );\r
+\r
+ if (MCastFilter != NULL) {\r
+ //\r
+ // Free the buffer used to hold the group addresses.\r
+ //\r
+ gBS->FreePool (MCastFilter);\r
+ }\r
+\r
+ return Status;\r
+}\r
\r
\r
/**\r