summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Network/Udp4Dxe
diff options
context:
space:
mode:
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2012-12-13 06:47:06 +0000
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2012-12-13 06:47:06 +0000
commit216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8 (patch)
tree847cafec4185c79f082ccb9a5e895062a06980c1 /MdeModulePkg/Universal/Network/Udp4Dxe
parent906e1cb7f7f178f5cb2a3bebbac59f6aa8c273a4 (diff)
downloadedk2-platforms-216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8.tar.xz
1. Add EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName() support.
2. Fix the driver binding Stop() hang issue in the network stack. 3. Add Ip4 raw data support. 4. Add iSCSI Dhcp option 60 support. Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Ouyang Qian <qian.ouyang@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13995 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network/Udp4Dxe')
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c126
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c111
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c4
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h12
4 files changed, 227 insertions, 26 deletions
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c b/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c
index acb8f167e1..cf311055e2 100644
--- a/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c
+++ b/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
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
@@ -174,6 +174,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdpDriverNameTable[] = {
}
};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable = NULL;
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -231,6 +233,75 @@ UdpComponentNameGetDriverName (
}
/**
+ Update the component name for the Udp4 child handle.
+
+ @param Udp4[in] A pointer to the EFI_UDP4_PROTOCOL.
+
+
+ @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
+ @retval EFI_INVALID_PARAMETER The input parameter is invalid.
+
+**/
+EFI_STATUS
+UpdateName (
+ EFI_UDP4_PROTOCOL *Udp4
+ )
+{
+ EFI_STATUS Status;
+ CHAR16 HandleName[64];
+ EFI_UDP4_CONFIG_DATA Udp4ConfigData;
+
+ if (Udp4 == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Format the child name into the string buffer as:
+ // UDPv4 (SrcPort=59, DestPort=60)
+ //
+ Status = Udp4->GetModeData (Udp4, &Udp4ConfigData, NULL, NULL, NULL);
+ if (!EFI_ERROR (Status)) {
+ UnicodeSPrint (HandleName, sizeof (HandleName),
+ L"UDPv4 (SrcPort=%d, DestPort=%d)",
+ Udp4ConfigData.StationPort,
+ Udp4ConfigData.RemotePort
+ );
+ } else if (Status == EFI_NOT_STARTED) {
+ UnicodeSPrint (
+ HandleName,
+ sizeof (HandleName),
+ L"UDPv4 (Not started)"
+ );
+ } else {
+ return Status;
+ }
+
+ if (gUdpControllerNameTable != NULL) {
+ FreeUnicodeStringTable (gUdpControllerNameTable);
+ gUdpControllerNameTable = NULL;
+ }
+
+ Status = AddUnicodeString2 (
+ "eng",
+ gUdp4ComponentName.SupportedLanguages,
+ &gUdpControllerNameTable,
+ HandleName,
+ TRUE
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return AddUnicodeString2 (
+ "en",
+ gUdp4ComponentName2.SupportedLanguages,
+ &gUdpControllerNameTable,
+ HandleName,
+ FALSE
+ );
+}
+
+/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -308,6 +379,57 @@ UdpComponentNameGetControllerName (
OUT CHAR16 **ControllerName
)
{
- return EFI_UNSUPPORTED;
+ EFI_STATUS Status;
+ EFI_UDP4_PROTOCOL *Udp4;
+
+ //
+ // Only provide names for child handles.
+ //
+ if (ChildHandle == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Make sure this driver produced ChildHandle
+ //
+ Status = EfiTestChildHandle (
+ ControllerHandle,
+ ChildHandle,
+ &gEfiIp4ProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Retrieve an instance of a produced protocol from ChildHandle
+ //
+ Status = gBS->OpenProtocol (
+ ChildHandle,
+ &gEfiUdp4ProtocolGuid,
+ (VOID **)&Udp4,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Update the component name for this child handle.
+ //
+ Status = UpdateName (Udp4);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ gUdpControllerNameTable,
+ ControllerName,
+ (BOOLEAN)(This == &gUdp4ComponentName)
+ );
}
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
index 5afb3aa58e..96b08d14e9 100644
--- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
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
@@ -28,6 +28,43 @@ EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = {
Udp4ServiceBindingDestroyChild
};
+/**
+ Callback function which provided by user to remove one node in NetDestroyLinkList process.
+
+ @param[in] Entry The entry to be removed.
+ @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
+
+ @retval EFI_SUCCESS The entry has been removed successfully.
+ @retval Others Fail to remove the entry.
+
+**/
+EFI_STATUS
+Udp4DestroyChildEntryInHandleBuffer (
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
+)
+{
+ UDP4_INSTANCE_DATA *Instance;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ UINTN NumberOfChildren;
+ EFI_HANDLE *ChildHandleBuffer;
+
+ if (Entry == NULL || Context == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE);
+ ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
+ NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
+ ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+
+ if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
+ return EFI_SUCCESS;
+ }
+
+ return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
+}
+
/**
Test to see if this driver supports ControllerHandle. This service
@@ -178,18 +215,19 @@ Udp4DriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- EFI_HANDLE NicHandle;
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- UDP4_SERVICE_DATA *Udp4Service;
- UDP4_INSTANCE_DATA *Instance;
+ EFI_STATUS Status;
+ EFI_HANDLE NicHandle;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ UDP4_SERVICE_DATA *Udp4Service;
+ UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
+ LIST_ENTRY *List;
//
// Find the NicHandle where UDP4 ServiceBinding Protocol is installed.
//
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);
if (NicHandle == NULL) {
- return EFI_DEVICE_ERROR;
+ return EFI_SUCCESS;
}
//
@@ -208,9 +246,21 @@ Udp4DriverBindingStop (
}
Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (ServiceBinding);
-
- if (NumberOfChildren == 0) {
-
+ if (NumberOfChildren != 0) {
+ //
+ // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.
+ //
+ List = &Udp4Service->ChildrenList;
+ Context.ServiceBinding = ServiceBinding;
+ Context.NumberOfChildren = NumberOfChildren;
+ Context.ChildHandleBuffer = ChildHandleBuffer;
+ Status = NetDestroyLinkList (
+ List,
+ Udp4DestroyChildEntryInHandleBuffer,
+ &Context,
+ NULL
+ );
+ } else {
gBS->UninstallMultipleProtocolInterfaces (
NicHandle,
&gEfiUdp4ServiceBindingProtocolGuid,
@@ -222,14 +272,11 @@ Udp4DriverBindingStop (
Udp4CleanService (Udp4Service);
- FreePool (Udp4Service);
- } else {
-
- while (!IsListEmpty (&Udp4Service->ChildrenList)) {
- Instance = NET_LIST_HEAD (&Udp4Service->ChildrenList, UDP4_INSTANCE_DATA, Link);
-
- ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
+ if (gUdpControllerNameTable != NULL) {
+ FreeUnicodeStringTable (gUdpControllerNameTable);
+ gUdpControllerNameTable = NULL;
}
+ FreePool (Udp4Service);
}
return Status;
@@ -323,6 +370,21 @@ Udp4ServiceBindingCreateChild (
goto ON_ERROR;
}
+ //
+ // Open this instance's Ip4 protocol in the IpInfo BY_CHILD.
+ //
+ Status = gBS->OpenProtocol (
+ Instance->IpInfo->ChildHandle,
+ &gEfiIp4ProtocolGuid,
+ (VOID **) &Ip4,
+ gUdp4DriverBinding.DriverBindingHandle,
+ Instance->ChildHandle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_ERROR;
+ }
+
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
@@ -412,14 +474,14 @@ Udp4ServiceBindingDestroyChild (
Instance = UDP4_INSTANCE_DATA_FROM_THIS (Udp4Proto);
- if (Instance->Destroyed) {
+ if (Instance->InDestroy) {
return EFI_SUCCESS;
}
//
// Use the Destroyed flag to avoid the re-entering of the following code.
//
- Instance->Destroyed = TRUE;
+ Instance->InDestroy = TRUE;
//
// Close the Ip4 protocol.
@@ -430,6 +492,15 @@ Udp4ServiceBindingDestroyChild (
gUdp4DriverBinding.DriverBindingHandle,
Instance->ChildHandle
);
+ //
+ // Close the Ip4 protocol on this instance's IpInfo.
+ //
+ gBS->CloseProtocol (
+ Instance->IpInfo->ChildHandle,
+ &gEfiIp4ProtocolGuid,
+ gUdp4DriverBinding.DriverBindingHandle,
+ Instance->ChildHandle
+ );
//
// Uninstall the Udp4Protocol previously installed on the ChildHandle.
@@ -441,7 +512,7 @@ Udp4ServiceBindingDestroyChild (
NULL
);
if (EFI_ERROR (Status)) {
- Instance->Destroyed = FALSE;
+ Instance->InDestroy = FALSE;
return Status;
}
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
index 9326f3d344..8bba3572a2 100644
--- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
@@ -1,7 +1,7 @@
/** @file
The implementation of the Udp4 protocol.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
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
@@ -484,7 +484,7 @@ Udp4InitInstance (
Instance->IcmpError = EFI_SUCCESS;
Instance->Configured = FALSE;
Instance->IsNoMapping = FALSE;
- Instance->Destroyed = FALSE;
+ Instance->InDestroy = FALSE;
}
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h
index f8a39ebcf7..8142a4640f 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 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
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
@@ -31,12 +31,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h>
#include <Library/TimerLib.h>
#include <Library/DpcLib.h>
+#include <Library/PrintLib.h>
#include "Udp4Driver.h"
extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2;
+extern EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable;
extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding;
extern EFI_UDP4_PROTOCOL mUdp4Protocol;
extern UINT16 mUdp4RandomPort;
@@ -109,7 +111,7 @@ typedef struct _UDP4_INSTANCE_DATA_ {
IP_IO_IP_INFO *IpInfo;
- BOOLEAN Destroyed;
+ BOOLEAN InDestroy;
} UDP4_INSTANCE_DATA;
typedef struct _UDP4_RXDATA_WRAP_ {
@@ -119,6 +121,12 @@ typedef struct _UDP4_RXDATA_WRAP_ {
EFI_UDP4_RECEIVE_DATA RxData;
} UDP4_RXDATA_WRAP;
+typedef struct {
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ UINTN NumberOfChildren;
+ EFI_HANDLE *ChildHandleBuffer;
+} UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
+
/**
Reads the current operational settings.