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:
sfu5
2012-12-13 06:47:06 +00:00
parent 906e1cb7f7
commit 216f79703b
91 changed files with 3991 additions and 694 deletions

View File

@@ -2,7 +2,7 @@
Implementation of EFI_COMPONENT_NAME_PROTOCOL and
EFI_COMPONENT_NAME2_PROTOCOL protocol.
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 mIp6DriverNameTable[
}
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gIp6ControllerNameTable = NULL;
/**
Retrieves a Unicode string that is the user-readable name of the driver.
@@ -231,6 +233,88 @@ Ip6ComponentNameGetDriverName (
}
/**
Update the component name for the IP6 child handle.
@param Ip6[in] A pointer to the EFI_IP6_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_IP6_PROTOCOL *Ip6
)
{
EFI_STATUS Status;
CHAR16 HandleName[128];
EFI_IP6_MODE_DATA Ip6ModeData;
UINTN Offset;
CHAR16 Address[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
if (Ip6 == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Format the child name into the string buffer.
//
Offset = 0;
Status = Ip6->GetModeData (Ip6, &Ip6ModeData, NULL, NULL);
if (!EFI_ERROR (Status) && Ip6ModeData.IsStarted) {
Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.StationAddress, Address, sizeof(Address));
if (EFI_ERROR (Status)) {
return Status;
}
Offset += UnicodeSPrint (
HandleName,
sizeof(HandleName),
L"IPv6(StationAddress=%s, ",
Address
);
Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.DestinationAddress, Address, sizeof(Address));
if (EFI_ERROR (Status)) {
return Status;
}
UnicodeSPrint (
HandleName + Offset,
sizeof(HandleName) - Offset,
L"DestinationAddress=%s)",
Address
);
} else if (!Ip6ModeData.IsStarted) {
UnicodeSPrint (HandleName, sizeof(HandleName), L"IPv6(Not started)");
} else {
UnicodeSPrint (HandleName, sizeof(HandleName), L"IPv6(%r)", Status);
}
if (gIp6ControllerNameTable != NULL) {
FreeUnicodeStringTable (gIp6ControllerNameTable);
gIp6ControllerNameTable = NULL;
}
Status = AddUnicodeString2 (
"eng",
gIp6ComponentName.SupportedLanguages,
&gIp6ControllerNameTable,
HandleName,
TRUE
);
if (EFI_ERROR (Status)) {
return Status;
}
return AddUnicodeString2 (
"en",
gIp6ComponentName2.SupportedLanguages,
&gIp6ControllerNameTable,
HandleName,
FALSE
);
}
/**
Retrieves a Unicode string that is the user-readable name of the controller
that is being managed by a driver.
@@ -309,5 +393,56 @@ Ip6ComponentNameGetControllerName (
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
EFI_STATUS Status;
EFI_IP6_PROTOCOL *Ip6;
//
// Only provide names for child handles.
//
if (ChildHandle == NULL) {
return EFI_UNSUPPORTED;
}
//
// Make sure this driver produced ChildHandle
//
Status = EfiTestChildHandle (
ControllerHandle,
ChildHandle,
&gEfiManagedNetworkProtocolGuid
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Retrieve an instance of a produced protocol from ChildHandle
//
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiIp6ProtocolGuid,
(VOID **)&Ip6,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Update the component name for this child handle.
//
Status = UpdateName (Ip6);
if (EFI_ERROR (Status)) {
return Status;
}
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
gIp6ControllerNameTable,
ControllerName,
(BOOLEAN)(This == &gIp6ComponentName)
);
}

View File

@@ -1,7 +1,7 @@
/** @file
The implementation of common functions shared by IP6 driver.
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
@@ -328,6 +328,37 @@ Ip6AddAddr (
IpIf->AddressCount++;
}
/**
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
Ip6DestroyChildEntryByAddr (
IN LIST_ENTRY *Entry,
IN VOID *Context
)
{
IP6_PROTOCOL *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
EFI_IPv6_ADDRESS *Address;
Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
ServiceBinding = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->ServiceBinding;
Address = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->Address;
if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
return EFI_SUCCESS;
}
/**
Destroy the IP instance if its StationAddress is removed. It is the help function
for Ip6RemoveAddr().
@@ -342,35 +373,20 @@ Ip6DestroyInstanceByAddress (
IN EFI_IPv6_ADDRESS *Address
)
{
BOOLEAN OneDestroyed;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
LIST_ENTRY *Entry;
IP6_PROTOCOL *Instance;
LIST_ENTRY *List;
IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ServiceBinding = &IpSb->ServiceBinding;
//
// Upper layer IP protocol consumers may have tight relationship between several
// IP protocol instances, in other words, calling ServiceBinding->DestroyChild to
// destroy one IP child may cause other related IP children destroyed too. This
// will probably leave hole in the children list when we iterate it. So everytime
// we just destroy one child then back to the start point to iterate the list.
//
do {
OneDestroyed = FALSE;
NET_LIST_FOR_EACH (Entry, &IpSb->Children) {
Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {
ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
OneDestroyed = TRUE;
break;
}
}
} while (OneDestroyed);
List = &IpSb->Children;
Context.ServiceBinding = &IpSb->ServiceBinding;
Context.Address = Address;
NetDestroyLinkList (
List,
Ip6DestroyChildEntryByAddr,
&Context,
NULL
);
}
/**

View File

@@ -1,7 +1,7 @@
/** @file
Common definition and functions for IP6 driver.
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
@@ -60,6 +60,11 @@ typedef enum {
Ip6AnyCast
} IP6_ADDRESS_TYPE;
typedef struct {
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
EFI_IPv6_ADDRESS *Address;
} IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT;
typedef struct _IP6_INTERFACE IP6_INTERFACE;
typedef struct _IP6_PROTOCOL IP6_PROTOCOL;
typedef struct _IP6_SERVICE IP6_SERVICE;

View File

@@ -114,14 +114,16 @@ Ip6CleanService (
Ip6ConfigCleanInstance (&IpSb->Ip6ConfigInstance);
//
// Leave link-scope all-nodes multicast address (FF02::1)
//
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
if (!IpSb->LinkLocalDadFail) {
//
// Leave link-scope all-nodes multicast address (FF02::1)
//
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
Status = Ip6LeaveGroup (IpSb, &AllNodes);
if (EFI_ERROR (Status)) {
return Status;
Status = Ip6LeaveGroup (IpSb, &AllNodes);
if (EFI_ERROR (Status)) {
return Status;
}
}
if (IpSb->DefaultInterface != NULL) {
@@ -244,7 +246,6 @@ Ip6CreateService (
IpSb->ServiceBinding.CreateChild = Ip6ServiceBindingCreateChild;
IpSb->ServiceBinding.DestroyChild = Ip6ServiceBindingDestroyChild;
IpSb->State = IP6_SERVICE_UNSTARTED;
IpSb->InDestroy = FALSE;
IpSb->NumChildren = 0;
InitializeListHead (&IpSb->Children);
@@ -572,6 +573,43 @@ Ip6DriverBindingStart (
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
Ip6DestroyChildEntryInHandleBuffer (
IN LIST_ENTRY *Entry,
IN VOID *Context
)
{
IP6_PROTOCOL *IpInstance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) {
return EFI_INVALID_PARAMETER;
}
IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
ServiceBinding = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
NumberOfChildren = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
ChildHandleBuffer = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
}
return ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle);
}
/**
Stop this driver on ControllerHandle.
@@ -595,30 +633,23 @@ Ip6DriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
IP6_SERVICE *IpSb;
IP6_PROTOCOL *IpInstance;
EFI_HANDLE NicHandle;
EFI_STATUS Status;
BOOLEAN IsDhcp6;
EFI_TPL OldTpl;
INTN State;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
IP6_SERVICE *IpSb;
EFI_HANDLE NicHandle;
EFI_STATUS Status;
LIST_ENTRY *List;
INTN State;
BOOLEAN IsDhcp6;
IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
IsDhcp6 = FALSE;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
if (NicHandle != NULL) {
//
// DriverBindingStop is triggered by the uninstallation of the EFI DHCPv6
// Protocol used by Ip6Config.
//
IsDhcp6 = TRUE;
} else {
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
if (NicHandle == NULL) {
return EFI_DEVICE_ERROR;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
if (NicHandle == NULL) {
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
if (NicHandle != NULL) {
IsDhcp6 = TRUE;
} else {
return EFI_SUCCESS;
}
}
@@ -636,21 +667,25 @@ Ip6DriverBindingStop (
IpSb = IP6_SERVICE_FROM_PROTOCOL (ServiceBinding);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (IpSb->InDestroy) {
Status = EFI_SUCCESS;
goto Exit;
}
if (IsDhcp6) {
Status = Ip6ConfigDestroyDhcp6 (&IpSb->Ip6ConfigInstance);
gBS->CloseEvent (IpSb->Ip6ConfigInstance.Dhcp6Event);
IpSb->Ip6ConfigInstance.Dhcp6Event = NULL;
} else if (NumberOfChildren == 0) {
IpSb->InDestroy = TRUE;
} else if (NumberOfChildren != 0) {
//
// NumberOfChildren is not zero, destroy the IP6 children instances in ChildHandleBuffer.
//
List = &IpSb->Children;
Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
Status = NetDestroyLinkList (
List,
Ip6DestroyChildEntryInHandleBuffer,
&Context,
NULL
);
} else if (IsListEmpty (&IpSb->Children)) {
State = IpSb->State;
IpSb->State = IP6_SERVICE_DESTROY;
@@ -675,24 +710,10 @@ Ip6DriverBindingStop (
);
ASSERT_EFI_ERROR (Status);
FreePool (IpSb);
} else {
//
// NumberOfChildren is not zero, destroy all IP6 children instances.
//
while (!IsListEmpty (&IpSb->Children)) {
IpInstance = NET_LIST_HEAD (&IpSb->Children, IP6_PROTOCOL, Link);
ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle);
}
if (IpSb->NumChildren != 0) {
Status = EFI_DEVICE_ERROR;
}
Status = EFI_SUCCESS;
}
Exit:
gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -830,7 +851,6 @@ Ip6ServiceBindingDestroyChild (
IP6_PROTOCOL *IpInstance;
EFI_IP6_PROTOCOL *Ip6;
EFI_TPL OldTpl;
INTN State;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -868,13 +888,12 @@ Ip6ServiceBindingDestroyChild (
// when UDP driver is being stopped, it will destroy all
// the IP child it opens.
//
if (IpInstance->State == IP6_STATE_DESTROY) {
if (IpInstance->InDestroy) {
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
State = IpInstance->State;
IpInstance->State = IP6_STATE_DESTROY;
IpInstance->InDestroy = TRUE;
//
// Close the Managed Network protocol.
@@ -900,12 +919,13 @@ Ip6ServiceBindingDestroyChild (
// will be called back before preceeding. If any packets not recycled,
// that means there is a resource leak.
//
gBS->RestoreTPL (OldTpl);
Status = gBS->UninstallProtocolInterface (
ChildHandle,
&gEfiIp6ProtocolGuid,
&IpInstance->Ip6Proto
);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
@@ -935,7 +955,6 @@ Ip6ServiceBindingDestroyChild (
return EFI_SUCCESS;
ON_ERROR:
IpInstance->State = State;
gBS->RestoreTPL (OldTpl);
return Status;

View File

@@ -19,6 +19,13 @@
extern EFI_DRIVER_BINDING_PROTOCOL gIp6DriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2;
extern EFI_UNICODE_STRING_TABLE *gIp6ControllerNameTable;
typedef struct {
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
}IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
/**
Clean up an IP6 service binding instance. It releases all

View File

@@ -565,11 +565,7 @@ Ip6ReceiveFrame (
{
EFI_STATUS Status;
IP6_LINK_RX_TOKEN *Token;
if (IpSb->InDestroy) {
return EFI_INVALID_PARAMETER;
}
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Token = &IpSb->RecvRequest;

View File

@@ -635,7 +635,7 @@ EfiIp6Configure (
IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);
IpSb = IpInstance->Service;
if (IpSb->LinkLocalDadFail) {
if (IpSb->LinkLocalDadFail && Ip6ConfigData != NULL) {
return EFI_DEVICE_ERROR;
}
@@ -1777,10 +1777,6 @@ EfiIp6Cancel (
IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);
IpSb = IpInstance->Service;
if (IpSb->LinkLocalDadFail) {
return EFI_DEVICE_ERROR;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (IpInstance->State != IP6_STATE_CONFIGED) {

View File

@@ -1,7 +1,7 @@
/** @file
Implementation of EFI_IP6_PROTOCOL protocol interfaces and type definitions.
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
@@ -68,7 +68,6 @@
//
#define IP6_STATE_UNCONFIGED 0
#define IP6_STATE_CONFIGED 1
#define IP6_STATE_DESTROY 2
//
// The state of IP6 service. It starts from UNSTARTED. It transits
@@ -157,13 +156,13 @@ struct _IP6_PROTOCOL {
UINT32 GroupCount;
EFI_IP6_CONFIG_DATA ConfigData;
BOOLEAN InDestroy;
};
struct _IP6_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
INTN State;
BOOLEAN InDestroy;
//
// List of all the IP instances and interfaces, and default

View File

@@ -821,7 +821,8 @@ Ip6OnDADFinished (
UINT16 OptBuf[4];
EFI_DHCP6_PACKET_OPTION *Oro;
EFI_DHCP6_RETRANSMISSION InfoReqReXmit;
EFI_IPv6_ADDRESS AllNodes;
IpSb = IpIf->Service;
AddrInfo = DadEntry->AddressInfo;
@@ -922,6 +923,11 @@ Ip6OnDADFinished (
RemoveEntryList (&DadEntry->Link);
FreePool (DadEntry);
//
// Leave link-scope all-nodes multicast address (FF02::1)
//
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
Ip6LeaveGroup (IpSb, &AllNodes);
//
// Disable IP operation since link-local address is a duplicate address.
//
IpSb->LinkLocalDadFail = TRUE;