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 iSCSI.
|
||||
|
||||
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 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
|
||||
@@ -43,6 +43,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable
|
||||
}
|
||||
};
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gIScsiControllerNameTable = NULL;
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@@ -99,6 +101,99 @@ IScsiComponentNameGetDriverName (
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Update the component name for the iSCSI NIC handle.
|
||||
|
||||
@param[in] Controller The handle of the NIC controller.
|
||||
@param[in] Ipv6Flag TRUE if IP6 network stack is used.
|
||||
|
||||
@retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
|
||||
@retval EFI_INVALID_PARAMETER The input parameter is invalid.
|
||||
@retval EFI_UNSUPPORTED Can't get the corresponding NIC info from the Controller handle.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UpdateName (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN BOOLEAN Ipv6Flag
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MAC_ADDRESS MacAddr;
|
||||
UINTN HwAddressSize;
|
||||
UINT16 VlanId;
|
||||
ISCSI_NIC_INFO *ThisNic;
|
||||
ISCSI_NIC_INFO *NicInfo;
|
||||
LIST_ENTRY *Entry;
|
||||
CHAR16 HandleName[80];
|
||||
|
||||
//
|
||||
// Get MAC address of this network device.
|
||||
//
|
||||
Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get VLAN ID of this network device.
|
||||
//
|
||||
VlanId = NetLibGetVlanId (Controller);
|
||||
|
||||
//
|
||||
// Check whether the NIC information exists.
|
||||
//
|
||||
ThisNic = NULL;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
|
||||
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
|
||||
if (NicInfo->HwAddressSize == HwAddressSize &&
|
||||
CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&
|
||||
NicInfo->VlanId == VlanId) {
|
||||
|
||||
ThisNic = NicInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ThisNic == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
UnicodeSPrint (
|
||||
HandleName,
|
||||
sizeof (HandleName),
|
||||
L"iSCSI (%s, NicIndex=%d)",
|
||||
Ipv6Flag ? L"IPv6" : L"IPv4",
|
||||
ThisNic->NicIndex
|
||||
);
|
||||
|
||||
if (gIScsiControllerNameTable != NULL) {
|
||||
FreeUnicodeStringTable (gIScsiControllerNameTable);
|
||||
gIScsiControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
Status = AddUnicodeString2 (
|
||||
"eng",
|
||||
gIScsiComponentName.SupportedLanguages,
|
||||
&gIScsiControllerNameTable,
|
||||
HandleName,
|
||||
TRUE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return AddUnicodeString2 (
|
||||
"en",
|
||||
gIScsiComponentName2.SupportedLanguages,
|
||||
&gIScsiControllerNameTable,
|
||||
HandleName,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@@ -177,5 +272,54 @@ IScsiComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
EFI_HANDLE IScsiController;
|
||||
BOOLEAN Ipv6Flag;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *IScsiPrivateGuid;
|
||||
ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
|
||||
|
||||
//
|
||||
// Get the handle of the controller we are controling.
|
||||
//
|
||||
IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
|
||||
if (IScsiController != NULL) {
|
||||
IScsiPrivateGuid = &gIScsiV4PrivateGuid;
|
||||
Ipv6Flag = FALSE;
|
||||
} else {
|
||||
IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);
|
||||
if (IScsiController != NULL) {
|
||||
IScsiPrivateGuid = &gIScsiV6PrivateGuid;
|
||||
Ipv6Flag = TRUE;
|
||||
} else {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve an instance of a produced protocol from IScsiController
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
IScsiController,
|
||||
IScsiPrivateGuid,
|
||||
(VOID **) &IScsiIdentifier,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = UpdateName(IScsiController, Ipv6Flag);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
gIScsiControllerNameTable,
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gIScsiComponentName)
|
||||
);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
iSCSI DHCP6 related configuration routines.
|
||||
|
||||
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
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -250,6 +250,7 @@ IScsiDhcp6ParseReply (
|
||||
EFI_DHCP6_PACKET_OPTION *BootFileOpt;
|
||||
EFI_DHCP6_PACKET_OPTION **OptionList;
|
||||
ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData;
|
||||
UINT16 ParaLen;
|
||||
|
||||
OptionCount = 0;
|
||||
BootFileOpt = NULL;
|
||||
@@ -282,7 +283,7 @@ IScsiDhcp6ParseReply (
|
||||
if (OptionList[Index]->OpCode == DHCP6_OPT_DNS_SERVERS) {
|
||||
|
||||
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto Exit;
|
||||
}
|
||||
//
|
||||
@@ -302,6 +303,24 @@ IScsiDhcp6ParseReply (
|
||||
// The server sends this option to inform the client about an URL to a boot file.
|
||||
//
|
||||
BootFileOpt = OptionList[Index];
|
||||
} else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_PARA) {
|
||||
//
|
||||
// The server sends this option to inform the client about DHCP6 server address.
|
||||
//
|
||||
if (OptionList[Index]->OpLen < 18) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto Exit;
|
||||
}
|
||||
//
|
||||
// Check param-len 1, should be 16 bytes.
|
||||
//
|
||||
CopyMem (&ParaLen, &OptionList[Index]->Data[0], sizeof (UINT16));
|
||||
if (NTOHS (ParaLen) != 16) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
CopyMem (&ConfigData->DhcpServer, &OptionList[Index]->Data[2], sizeof (EFI_IPv6_ADDRESS));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +424,7 @@ IScsiDoDhcp6 (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Oro = AllocateZeroPool (sizeof (EFI_DHCP6_PACKET_OPTION) + 3);
|
||||
Oro = AllocateZeroPool (sizeof (EFI_DHCP6_PACKET_OPTION) + 5);
|
||||
if (Oro == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
@@ -416,9 +435,10 @@ IScsiDoDhcp6 (
|
||||
// All members in EFI_DHCP6_PACKET_OPTION are in network order.
|
||||
//
|
||||
Oro->OpCode = HTONS (DHCP6_OPT_REQUEST_OPTION);
|
||||
Oro->OpLen = HTONS (2 * 2);
|
||||
Oro->OpLen = HTONS (2 * 3);
|
||||
Oro->Data[1] = DHCP6_OPT_DNS_SERVERS;
|
||||
Oro->Data[3] = DHCP6_OPT_BOOT_FILE_URL;
|
||||
Oro->Data[5] = DHCP6_OPT_BOOT_FILE_PARA;
|
||||
|
||||
InfoReqReXmit.Irt = 4;
|
||||
InfoReqReXmit.Mrc = 1;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
The header file of iSCSI DHCP6 related configuration routines.
|
||||
|
||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 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
|
||||
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
/// Assigned by IANA, RFC 5970
|
||||
///
|
||||
#define DHCP6_OPT_BOOT_FILE_URL 59
|
||||
#define DHCP6_OPT_BOOT_FILE_PARA 60
|
||||
|
||||
#define ISCSI_ROOT_PATH_ID "iscsi:"
|
||||
#define ISCSI_ROOT_PATH_FIELD_DELIMITER ':'
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
The entry point of IScsi driver.
|
||||
|
||||
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 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
|
||||
@@ -23,8 +23,8 @@ EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = {
|
||||
NULL
|
||||
};
|
||||
|
||||
EFI_GUID mIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
|
||||
EFI_GUID mIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
|
||||
EFI_GUID gIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
|
||||
EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
|
||||
ISCSI_PRIVATE_DATA *mPrivate = NULL;
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ IScsiDriverBindingSupported (
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&mIScsiV4PrivateGuid,
|
||||
&gIScsiV4PrivateGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
@@ -150,7 +150,7 @@ IScsiDriverBindingSupported (
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&mIScsiV6PrivateGuid,
|
||||
&gIScsiV6PrivateGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
@@ -231,11 +231,11 @@ IScsiStart (
|
||||
//
|
||||
|
||||
if (IpVersion == IP_VERSION_4) {
|
||||
IScsiPrivateGuid = &mIScsiV4PrivateGuid;
|
||||
IScsiPrivateGuid = &gIScsiV4PrivateGuid;
|
||||
TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
||||
ProtocolGuid = &gEfiTcp4ProtocolGuid;
|
||||
} else if (IpVersion == IP_VERSION_6) {
|
||||
IScsiPrivateGuid = &mIScsiV6PrivateGuid;
|
||||
IScsiPrivateGuid = &gIScsiV6PrivateGuid;
|
||||
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
||||
ProtocolGuid = &gEfiTcp6ProtocolGuid;
|
||||
} else {
|
||||
@@ -931,13 +931,13 @@ IScsiDriverBindingStop (
|
||||
//
|
||||
IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
|
||||
if (IScsiController != NULL) {
|
||||
ProtocolGuid = &mIScsiV4PrivateGuid;
|
||||
ProtocolGuid = &gIScsiV4PrivateGuid;
|
||||
TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
|
||||
TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
||||
} else {
|
||||
IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);
|
||||
ASSERT (IScsiController != NULL);
|
||||
ProtocolGuid = &mIScsiV6PrivateGuid;
|
||||
ProtocolGuid = &gIScsiV6PrivateGuid;
|
||||
TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
|
||||
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
||||
}
|
||||
@@ -1060,6 +1060,11 @@ IScsiUnload (
|
||||
&gIScsiAuthenticationInfo,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (gIScsiControllerNameTable!= NULL) {
|
||||
FreeUnicodeStringTable (gIScsiControllerNameTable);
|
||||
gIScsiControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
return gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
The header file of IScsiDriver.c.
|
||||
|
||||
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 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
|
||||
@@ -33,9 +33,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName;
|
||||
extern EFI_UNICODE_STRING_TABLE *gIScsiControllerNameTable;
|
||||
extern EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName;
|
||||
extern EFI_AUTHENTICATION_INFO_PROTOCOL gIScsiAuthenticationInfo;
|
||||
extern EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate;
|
||||
extern EFI_GUID gIScsiV4PrivateGuid;
|
||||
extern EFI_GUID gIScsiV6PrivateGuid;
|
||||
|
||||
typedef struct {
|
||||
CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];
|
||||
|
@@ -321,14 +321,10 @@ IScsiFillNICAndTargetSections (
|
||||
Nic->SubnetMaskPrefixLength = NvData->PrefixLength;
|
||||
CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS));
|
||||
CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS));
|
||||
|
||||
CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS));
|
||||
CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS));
|
||||
//
|
||||
// TODO: DHCP server address cannot be retrieved by DHCPv6 process since
|
||||
// DHCP server option is removed.
|
||||
//CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
|
||||
//
|
||||
CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
|
||||
|
||||
} else {
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user