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
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for UDP6 driver.
|
||||
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 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
|
||||
@@ -174,6 +174,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdp6DriverNameTable[] =
|
||||
}
|
||||
};
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gUdp6ControllerNameTable = NULL;
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the driver.
|
||||
|
||||
@@ -230,6 +232,70 @@ Udp6ComponentNameGetDriverName (
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Update the component name for the Udp6 child handle.
|
||||
|
||||
@param Udp6[in] A pointer to the EFI_UDP6_PROTOCOL.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
|
||||
@retval EFI_INVALID_PARAMETER The input parameter is invalid.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UpdateName (
|
||||
IN EFI_UDP6_PROTOCOL *Udp6
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR16 HandleName[64];
|
||||
EFI_UDP6_CONFIG_DATA Udp6ConfigData;
|
||||
|
||||
if (Udp6 == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Format the child name into the string buffer.
|
||||
//
|
||||
Status = Udp6->GetModeData (Udp6, &Udp6ConfigData, NULL, NULL, NULL);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName),
|
||||
L"UDPv6 (SrcPort=%d, DestPort=%d)",
|
||||
Udp6ConfigData.StationPort,
|
||||
Udp6ConfigData.RemotePort
|
||||
);
|
||||
} else if (Status == EFI_NOT_STARTED) {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName), L"UDPv6 (Not started)");
|
||||
} else {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName), L"UDPv6 (%r)", Status);
|
||||
}
|
||||
|
||||
if (gUdp6ControllerNameTable != NULL) {
|
||||
FreeUnicodeStringTable (gUdp6ControllerNameTable);
|
||||
gUdp6ControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
Status = AddUnicodeString2 (
|
||||
"eng",
|
||||
gUdp6ComponentName.SupportedLanguages,
|
||||
&gUdp6ControllerNameTable,
|
||||
HandleName,
|
||||
TRUE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return AddUnicodeString2 (
|
||||
"en",
|
||||
gUdp6ComponentName2.SupportedLanguages,
|
||||
&gUdp6ControllerNameTable,
|
||||
HandleName,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@@ -308,6 +374,56 @@ Udp6ComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
EFI_STATUS Status;
|
||||
EFI_UDP6_PROTOCOL *Udp6;
|
||||
|
||||
//
|
||||
// Only provide names for child handles.
|
||||
//
|
||||
if (ChildHandle == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure this driver produced ChildHandle
|
||||
//
|
||||
Status = EfiTestChildHandle (
|
||||
ControllerHandle,
|
||||
ChildHandle,
|
||||
&gEfiIp6ProtocolGuid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve an instance of a produced protocol from ChildHandle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
(VOID **)&Udp6,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Update the component name for this child handle.
|
||||
//
|
||||
Status = UpdateName (Udp6);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
gUdp6ControllerNameTable,
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gUdp6ComponentName)
|
||||
);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Driver Binding functions and Service Binding functions for the Network driver module.
|
||||
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 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
|
||||
@@ -178,6 +178,43 @@ EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
Udp6DestroyChildEntryInHandleBuffer (
|
||||
IN LIST_ENTRY *Entry,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UDP6_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, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);
|
||||
ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
|
||||
NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
|
||||
|
||||
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@@ -211,14 +248,15 @@ Udp6DriverBindingStop (
|
||||
EFI_HANDLE NicHandle;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
UDP6_SERVICE_DATA *Udp6Service;
|
||||
UDP6_INSTANCE_DATA *Instance;
|
||||
LIST_ENTRY *List;
|
||||
UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
|
||||
|
||||
//
|
||||
// Find the NicHandle where UDP6 ServiceBinding Protocol is installed.
|
||||
//
|
||||
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);
|
||||
if (NicHandle == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -238,8 +276,21 @@ Udp6DriverBindingStop (
|
||||
|
||||
Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (ServiceBinding);
|
||||
|
||||
if (NumberOfChildren == 0) {
|
||||
|
||||
if (NumberOfChildren != 0) {
|
||||
//
|
||||
// NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.
|
||||
//
|
||||
List = &Udp6Service->ChildrenList;
|
||||
Context.ServiceBinding = ServiceBinding;
|
||||
Context.NumberOfChildren = NumberOfChildren;
|
||||
Context.ChildHandleBuffer = ChildHandleBuffer;
|
||||
Status = NetDestroyLinkList (
|
||||
List,
|
||||
Udp6DestroyChildEntryInHandleBuffer,
|
||||
&Context,
|
||||
NULL
|
||||
);
|
||||
} else if (IsListEmpty (&Udp6Service->ChildrenList)) {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
NicHandle,
|
||||
&gEfiUdp6ServiceBindingProtocolGuid,
|
||||
@@ -252,13 +303,8 @@ Udp6DriverBindingStop (
|
||||
Udp6CleanService (Udp6Service);
|
||||
|
||||
FreePool (Udp6Service);
|
||||
} else {
|
||||
|
||||
while (!IsListEmpty (&Udp6Service->ChildrenList)) {
|
||||
Instance = NET_LIST_HEAD (&Udp6Service->ChildrenList, UDP6_INSTANCE_DATA, Link);
|
||||
|
||||
Status = ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
|
||||
}
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
@@ -351,6 +397,21 @@ Udp6ServiceBindingCreateChild (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Open this instance's Ip6 protocol in the IpInfo BY_CHILD.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Instance->IpInfo->ChildHandle,
|
||||
&gEfiIp6ProtocolGuid,
|
||||
(VOID **) &Ip6,
|
||||
gUdp6DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
//
|
||||
@@ -440,17 +501,17 @@ Udp6ServiceBindingDestroyChild (
|
||||
|
||||
Instance = UDP6_INSTANCE_DATA_FROM_THIS (Udp6Proto);
|
||||
|
||||
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 Ip6 protocol.
|
||||
// Close the Ip6 protocol on the default IpIo.
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Udp6Service->IpIo->ChildHandle,
|
||||
@@ -458,6 +519,15 @@ Udp6ServiceBindingDestroyChild (
|
||||
gUdp6DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle
|
||||
);
|
||||
//
|
||||
// Close the Ip6 protocol on this instance's IpInfo.
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Instance->IpInfo->ChildHandle,
|
||||
&gEfiIp6ProtocolGuid,
|
||||
gUdp6DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle
|
||||
);
|
||||
|
||||
//
|
||||
// Uninstall the Udp6Protocol previously installed on the ChildHandle.
|
||||
@@ -469,7 +539,7 @@ Udp6ServiceBindingDestroyChild (
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Instance->Destroyed = FALSE;
|
||||
Instance->InDestroy = FALSE;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Udp6 driver's whole implementation.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 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
|
||||
@@ -363,7 +363,8 @@ ON_ERROR:
|
||||
}
|
||||
|
||||
IpIoDestroy (Udp6Service->IpIo);
|
||||
|
||||
Udp6Service->IpIo = NULL;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -388,6 +389,9 @@ Udp6CleanService (
|
||||
// Destroy the IpIo.
|
||||
//
|
||||
IpIoDestroy (Udp6Service->IpIo);
|
||||
Udp6Service->IpIo = NULL;
|
||||
|
||||
ZeroMem (Udp6Service, sizeof (UDP6_SERVICE_DATA));
|
||||
}
|
||||
|
||||
|
||||
@@ -491,7 +495,7 @@ Udp6InitInstance (
|
||||
Instance->IcmpError = EFI_SUCCESS;
|
||||
Instance->Configured = FALSE;
|
||||
Instance->IsNoMapping = FALSE;
|
||||
Instance->Destroyed = FALSE;
|
||||
Instance->InDestroy = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Udp6 driver's whole implementation and internal data structures.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 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
|
||||
@@ -30,11 +30,13 @@
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DpcLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include "Udp6Driver.h"
|
||||
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gUdp6ComponentName2;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gUdp6ComponentName;
|
||||
extern EFI_UNICODE_STRING_TABLE *gUdp6ControllerNameTable;
|
||||
extern EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding;
|
||||
extern EFI_UDP6_PROTOCOL mUdp6Protocol;
|
||||
extern UINT16 mUdp6RandomPort;
|
||||
@@ -97,7 +99,7 @@ typedef struct _UDP6_INSTANCE_DATA {
|
||||
UINT16 HeadSum;
|
||||
EFI_STATUS IcmpError;
|
||||
IP_IO_IP_INFO *IpInfo;
|
||||
BOOLEAN Destroyed;
|
||||
BOOLEAN InDestroy;
|
||||
} UDP6_INSTANCE_DATA;
|
||||
|
||||
typedef struct _UDP6_RXDATA_WRAP {
|
||||
@@ -107,6 +109,12 @@ typedef struct _UDP6_RXDATA_WRAP {
|
||||
EFI_UDP6_RECEIVE_DATA RxData;
|
||||
} UDP6_RXDATA_WRAP;
|
||||
|
||||
typedef struct {
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
} UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
|
||||
|
||||
/**
|
||||
Clean the Udp service context data.
|
||||
|
||||
|
Reference in New Issue
Block a user