* [patch] NetworkPkg:Add scriptable configuration to iSCSI driver by leveraging x-UEFI.
@ 2016-11-25 8:11 Zhang Lubo
0 siblings, 0 replies; only message in thread
From: Zhang Lubo @ 2016-11-25 8:11 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin
Enable iSCSI keywords configuration based on x-UEFI
name space. we introduce new PCD to control the attempt
numbers which will be created in non activated state, besides
the Attempt name is changed to READ_ONLY attribute in UI.
We can invoke KEYWORD HANDLER Protocol to configure
the related keywords.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
NetworkPkg/IScsiDxe/IScsiConfig.c | 1769 +++++++++++++++++++++-----
NetworkPkg/IScsiDxe/IScsiConfig.h | 78 +-
NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h | 75 +-
NetworkPkg/IScsiDxe/IScsiConfigStrings.uni | 30 +-
NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 48 +-
NetworkPkg/IScsiDxe/IScsiDriver.c | 21 +-
NetworkPkg/IScsiDxe/IScsiDriver.h | 1 -
NetworkPkg/IScsiDxe/IScsiDxe.inf | 21 +-
NetworkPkg/IScsiDxe/IScsiImpl.h | 1 +
NetworkPkg/IScsiDxe/IScsiMisc.c | 759 ++++++++++-
NetworkPkg/IScsiDxe/IScsiMisc.h | 28 +
NetworkPkg/NetworkPkg.dec | 5 +
12 files changed, 2479 insertions(+), 357 deletions(-)
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 57571ad..0f7b30d 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -288,10 +288,102 @@ IScsiConvertIsIdToString (
return EFI_SUCCESS;
}
/**
+ Get the Offset value specified by the input String.
+
+ @param[in] Configuration A null-terminated Unicode string in
+ <ConfigString> format.
+ @param[in] String The string is "&OFFSET=".
+ @param[in] Value The Offset value.
+
+ @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary
+ structures.
+ @retval EFI_SUCCESS Value of <Number> is outputted in Number
+ successfully.
+
+**/
+EFI_STATUS
+IScsiGetValue (
+ IN CONST EFI_STRING Configuration,
+ IN CHAR16 *String,
+ OUT UINTN *Value
+ )
+{
+ CHAR16 *StringPtr;
+ CHAR16 *TmpPtr;
+ CHAR16 *Str;
+ CHAR16 TmpStr[2];
+ UINTN Length;
+ UINTN Len;
+ UINTN Index;
+ UINT8 *Buf;
+ UINT8 DigitUint8;
+ EFI_STATUS Status;
+
+ //
+ // Get Value.
+ //
+ Buf = NULL;
+ StringPtr = StrStr (Configuration, String);
+ ASSERT(StringPtr != NULL);
+ StringPtr += StrLen (String);
+ TmpPtr = StringPtr;
+
+ while (*StringPtr != L'\0' && *StringPtr != L'&') {
+ StringPtr ++;
+ }
+ Length = StringPtr - TmpPtr;
+ Len = Length + 1;
+
+ Str = AllocateZeroPool (Len * sizeof (CHAR16));
+ if (Str == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ CopyMem (Str, TmpPtr, Len * sizeof (CHAR16));
+ *(Str + Length) = L'\0';
+
+ Len = (Len + 1) / 2;
+ Buf = (UINT8 *) AllocateZeroPool (Len);
+ if (Buf == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ ZeroMem (TmpStr, sizeof (TmpStr));
+ for (Index = 0; Index < Length; Index ++) {
+ TmpStr[0] = Str[Length - Index - 1];
+ DigitUint8 = (UINT8) StrHexToUint64 (TmpStr);
+ if ((Index & 1) == 0) {
+ Buf [Index/2] = DigitUint8;
+ } else {
+ Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]);
+ }
+ }
+
+ *Value = 0;
+ CopyMem (
+ Value,
+ Buf,
+ (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
+ );
+
+ FreePool (Buf);
+ Status = EFI_SUCCESS;
+
+Exit:
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+
+ return Status;
+}
+
+/**
Get the attempt config data from global structure by the ConfigIndex.
@param[in] AttemptConfigIndex The unique index indicates the attempt.
@return Pointer to the attempt config data.
@@ -347,10 +439,68 @@ IScsiConfigGetAttemptByNic (
}
return NULL;
}
+/**
+ Extract the Index of the attempt list.
+
+ @param[in] AttemptNameList The Name list of the Attempts.
+ @param[out] AttemptIndexList The Index list of the Attempts.
+ @param[in] IsAddAttempts If TRUE, Indicates add one or more attempts.
+ If FALSE, Indicates delete attempts or change attempt order.
+
+ @retval EFI_SUCCESS The Attempt list is valid.
+ @retval EFI_INVALID_PARAMETERS The Attempt List is invalid.
+
+**/
+EFI_STATUS
+IScsiGetAttemptIndexList (
+ IN CHAR16 *AttemptNameList,
+ IN OUT UINT8 *AttemptIndexList,
+ IN BOOLEAN IsAddAttempts
+)
+{
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ CHAR16 *AttemptStr;
+ UINT8 AttemptIndex;
+ UINTN Len;
+ UINTN Index;
+
+ Index = 0;
+
+ if ((AttemptNameList == NULL) || (*AttemptNameList == L'\0')) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AttemptStr = AttemptNameList;
+ Len = StrLen (L"attempt:");
+
+ while (*AttemptStr != L'\0') {
+ AttemptStr = StrStr (AttemptStr, L"attempt:");
+ if (AttemptStr == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ AttemptStr += Len;
+ AttemptIndex = (UINT8)(*AttemptStr - L'0');
+ AttemptConfigData = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (IsAddAttempts) {
+ if ((AttemptConfigData != NULL) || ((AttemptIndex) > PcdGet8 (PcdMaxIScsiAttemptNumber))) {
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ if (AttemptConfigData == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ AttemptIndexList[Index] = AttemptIndex;
+ Index ++;
+ AttemptStr += 2;
+ }
+ return EFI_SUCCESS;
+}
/**
Convert the iSCSI configuration data into the IFR data.
@param[in] Attempt The iSCSI attempt config data.
@@ -443,10 +593,125 @@ IScsiConvertAttemptConfigDataToIfrNvData (
sizeof (IfrNvData->AttemptName) / sizeof (IfrNvData->AttemptName[0])
);
}
/**
+ Convert the iSCSI configuration data into the IFR data.
+
+ @param[in, out] IfrNvData The IFR nv data.
+
+**/
+VOID
+EFIAPI
+IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (
+ IN OUT ISCSI_CONFIG_IFR_NVDATA *IfrNvData
+ )
+{
+ LIST_ENTRY *Entry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt;
+ ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData;
+ ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
+ CHAR16 AttemptNameList[ATTEMPT_NAME_LIST_SIZE];
+ EFI_IP_ADDRESS Ip;
+ UINTN Index;
+
+ ZeroMem (AttemptNameList, sizeof (AttemptNameList));
+
+ NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
+ Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
+ //
+ // Normal session configuration parameters.
+ //
+ SessionConfigData = &Attempt->SessionConfigData;
+
+ Index = Attempt->AttemptConfigIndex - 1;
+
+ //
+ // Save the attempt to AttemptNameList as Attempt:1 Attempt:2
+ //
+ AsciiStrToUnicodeStrS (
+ Attempt->AttemptName,
+ AttemptNameList + StrLen (AttemptNameList),
+ ATTEMPT_NAME_LIST_SIZE
+ );
+ *(AttemptNameList + StrLen (AttemptNameList) - 2) = L':';
+ *(AttemptNameList + StrLen (AttemptNameList)) = L' ';
+
+ AsciiStrToUnicodeStrS (
+ Attempt->AttemptName,
+ IfrNvData->ISCSIAttemptName + ATTEMPT_NAME_SIZE * Index,
+ ATTEMPT_NAME_SIZE
+ );
+
+ IfrNvData->ISCSIBootEnableList[Index] = SessionConfigData->Enabled;
+ IfrNvData->ISCSIIpAddressTypeList[Index] = SessionConfigData->IpMode;
+
+ IfrNvData->ISCSIInitiatorInfoViaDHCP[Index] = SessionConfigData->InitiatorInfoFromDhcp;
+ IfrNvData->ISCSITargetInfoViaDHCP[Index] = SessionConfigData->TargetInfoFromDhcp;
+ IfrNvData->ISCSIConnectRetry[Index] = SessionConfigData->ConnectRetryCount;
+ IfrNvData->ISCSIConnectTimeout[Index] = SessionConfigData->ConnectTimeout;
+ IfrNvData->ISCSITargetTcpPort[Index] = SessionConfigData->TargetPort;
+
+ if (SessionConfigData->IpMode == IP_MODE_IP4) {
+ CopyMem (&Ip.v4, &SessionConfigData->LocalIp, sizeof (EFI_IPv4_ADDRESS));
+ IScsiIpToStr (&Ip, FALSE, (IfrNvData->ISCSIInitiatorIpAddress + IP4_STR_MAX_SIZE * Index));
+ CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS));
+ IScsiIpToStr (&Ip, FALSE, (IfrNvData->ISCSIInitiatorNetmask + IP4_STR_MAX_SIZE * Index));
+ CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS));
+ IScsiIpToStr (&Ip, FALSE, (IfrNvData->ISCSIInitiatorGateway + IP4_STR_MAX_SIZE * Index));
+ CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
+ IScsiIpToStr (&Ip, FALSE, (IfrNvData->ISCSITargetIpAddress + IP_STR_MAX_SIZE * Index));
+ } else if (SessionConfigData->IpMode == IP_MODE_IP6) {
+ ZeroMem (IfrNvData->ISCSITargetIpAddress, sizeof (IfrNvData->TargetIp));
+ IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp);
+ IScsiIpToStr (&Ip, TRUE, (IfrNvData->ISCSITargetIpAddress + IP_STR_MAX_SIZE * Index));
+ }
+
+ AsciiStrToUnicodeStrS (
+ SessionConfigData->TargetName,
+ IfrNvData->ISCSITargetName + ISCSI_NAME_MAX_SIZE * Index,
+ ISCSI_NAME_MAX_SIZE
+ );
+
+ IScsiLunToUnicodeStr (SessionConfigData->BootLun, (IfrNvData->ISCSILUN + ISCSI_LUN_STR_MAX_LEN * Index));
+ IScsiConvertIsIdToString ((IfrNvData->ISCSIISID + ISID_CONFIGURABLE_STORAGE * Index), SessionConfigData->IsId);
+
+ IfrNvData->ISCSIAuthenticationMethod[Index] = Attempt->AuthenticationType;
+
+ if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
+ AuthConfigData = &Attempt->AuthConfigData.CHAP;
+ IfrNvData->ISCSIChapType[Index] = AuthConfigData->CHAPType;
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->CHAPName,
+ IfrNvData->ISCSIChapUsername + ISCSI_CHAP_NAME_STORAGE * Index,
+ ISCSI_CHAP_NAME_STORAGE
+ );
+
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->CHAPSecret,
+ IfrNvData->ISCSIChapSecret + ISCSI_CHAP_SECRET_STORAGE * Index,
+ ISCSI_CHAP_SECRET_STORAGE
+ );
+
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->ReverseCHAPName,
+ IfrNvData->ISCSIReverseChapUsername + ISCSI_CHAP_NAME_STORAGE * Index,
+ ISCSI_CHAP_NAME_STORAGE
+ );
+
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->ReverseCHAPSecret,
+ IfrNvData->ISCSIReverseChapSecret + ISCSI_CHAP_SECRET_STORAGE * Index,
+ ISCSI_CHAP_SECRET_STORAGE
+ );
+ }
+ }
+
+ CopyMem(IfrNvData->ISCSIDisplayAttemptList, AttemptNameList, ATTEMPT_NAME_LIST_SIZE);
+}
+
+/**
Convert the IFR data to iSCSI configuration data.
@param[in] IfrNvData Point to ISCSI_CONFIG_IFR_NVDATA.
@param[in, out] Attempt The iSCSI attempt config data.
@@ -518,11 +783,11 @@ IScsiConvertIfrNvDataToAttemptConfigData (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"Connection Establishing Timeout is less than minimum value 100ms.",
NULL
);
-
+
return EFI_INVALID_PARAMETER;
}
//
// Validate the address configuration of the Initiator if DHCP isn't
@@ -539,20 +804,20 @@ IScsiConvertIfrNvDataToAttemptConfigData (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"Gateway address is set but subnet mask is zero.",
NULL
);
-
+
return EFI_INVALID_PARAMETER;
} else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"Local IP and Gateway are not in the same subnet.",
NULL
);
-
+
return EFI_INVALID_PARAMETER;
}
}
}
//
@@ -583,11 +848,10 @@ IScsiConvertIfrNvDataToAttemptConfigData (
);
return EFI_INVALID_PARAMETER;
}
}
-
//
// Validate the authentication info.
//
if (IfrNvData->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
if ((IfrNvData->CHAPName[0] == '\0') || (IfrNvData->CHAPSecret[0] == '\0')) {
@@ -617,30 +881,23 @@ IScsiConvertIfrNvDataToAttemptConfigData (
//
// Check whether this attempt uses NIC which is already used by existing attempt.
//
SameNicAttempt = IScsiConfigGetAttemptByNic (Attempt, IfrNvData->Enabled);
if (SameNicAttempt != NULL) {
- AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_MAX_SIZE * sizeof (CHAR16));
+ AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
if (AttemptName1 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_MAX_SIZE * sizeof (CHAR16));
+ AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
if (AttemptName2 == NULL) {
FreePool (AttemptName1);
return EFI_OUT_OF_RESOURCES;
}
-
- AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_MAX_SIZE);
- if (StrLen (AttemptName1) > ATTEMPT_NAME_SIZE) {
- CopyMem (&AttemptName1[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));
- }
- AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_MAX_SIZE);
- if (StrLen (AttemptName2) > ATTEMPT_NAME_SIZE) {
- CopyMem (&AttemptName2[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));
- }
+ AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_SIZE);
+ AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_SIZE);
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
L"Warning! Attempt \"%s\" uses same NIC as Attempt \"%s\".",
@@ -661,11 +918,10 @@ IScsiConvertIfrNvDataToAttemptConfigData (
}
//
// Update the iSCSI Mode data and record it in attempt help info.
//
- Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
if (IfrNvData->Enabled == ISCSI_DISABLED) {
UnicodeSPrint (IScsiMode, 64, L"Disabled");
} else if (IfrNvData->Enabled == ISCSI_ENABLED) {
UnicodeSPrint (IScsiMode, 64, L"Enabled");
} else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {
@@ -785,15 +1041,14 @@ IScsiConvertIfrNvDataToAttemptConfigData (
}
} else if (ExistAttempt == NULL) {
//
// When a new attempt is created, pointer of the attempt is saved to
- // mPrivate->NewAttempt, and also saved to mCallbackInfo->Current in
- // IScsiConfigProcessDefault. If input Attempt does not match any existing
- // attempt, it should be a new created attempt. Save it to system now.
- //
- ASSERT (Attempt == mPrivate->NewAttempt);
+ // mCallbackInfo->Current in IScsiConfigProcessDefault. If input Attempt
+ // does not match any existing attempt, it should be a new created attempt.
+ // Save it to system now.
+ //
//
// Save current order number for this attempt.
//
AttemptConfigOrder = IScsiGetVariableAndSize (
@@ -840,15 +1095,10 @@ IScsiConvertIfrNvDataToAttemptConfigData (
//
// Insert new created attempt to array.
//
InsertTailList (&mPrivate->AttemptConfigs, &Attempt->Link);
mPrivate->AttemptCount++;
- //
- // Reset mPrivate->NewAttempt to NULL, which indicates none attempt is created
- // but not saved now.
- //
- mPrivate->NewAttempt = NULL;
if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {
//
// This new Attempt is enabled for MPIO; enable the multipath mode.
//
@@ -858,21 +1108,16 @@ IScsiConvertIfrNvDataToAttemptConfigData (
mPrivate->SinglePathCount++;
}
IScsiConfigUpdateAttempt ();
}
+ Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
//
// Record the user configuration information in NVR.
//
- UnicodeSPrint (
- mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
- L"%s%d",
- MacString,
- (UINTN) Attempt->AttemptConfigIndex
- );
+ UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex);
FreePool (MacString);
return gRT->SetVariable (
mPrivate->PortString,
@@ -882,108 +1127,790 @@ IScsiConvertIfrNvDataToAttemptConfigData (
Attempt
);
}
/**
- Create Hii Extend Label OpCode as the start opcode and end opcode. It is
- a help function.
+ Convert the IFR data to iSCSI configuration data by keyword.
- @param[in] StartLabelNumber The number of start label.
- @param[out] StartOpCodeHandle Points to the start opcode handle.
- @param[out] StartLabel Points to the created start opcode.
- @param[out] EndOpCodeHandle Points to the end opcode handle.
- @param[out] EndLabel Points to the created end opcode.
+ @param[in] IfrNvData Point to ISCSI_CONFIG_IFR_NVDATA.
+ @param[in] OffSet The offset of the variable to the configuration structure.
- @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this
- operation.
- @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
+ @retval EFI_INVALID_PARAMETER Any input or configured parameter is invalid.
@retval EFI_SUCCESS The operation is completed successfully.
**/
EFI_STATUS
-IScsiCreateOpCode (
- IN UINT16 StartLabelNumber,
- OUT VOID **StartOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **StartLabel,
- OUT VOID **EndOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **EndLabel
+IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
+ IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData,
+ IN UINTN OffSet
)
{
- EFI_STATUS Status;
- EFI_IFR_GUID_LABEL *InternalStartLabel;
- EFI_IFR_GUID_LABEL *InternalEndLabel;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt;
+ UINT8 AttemptIndex;
+ CHAR16 *AttemptName1;
+ CHAR16 *AttemptName2;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *SameNicAttempt;
+ CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN];
+ CHAR8 IScsiName[ISCSI_NAME_MAX_SIZE];
+ CHAR8 IpString[IP_STR_MAX_SIZE];
+ EFI_IP_ADDRESS HostIp;
+ EFI_IP_ADDRESS SubnetMask;
+ EFI_IP_ADDRESS Gateway;
+ EFI_INPUT_KEY Key;
+ UINT64 Lun;
+ EFI_STATUS Status;
- if (StartOpCodeHandle == NULL || StartLabel == NULL || EndOpCodeHandle == NULL || EndLabel == NULL) {
- return EFI_INVALID_PARAMETER;
- }
+ ZeroMem (IScsiName, sizeof (IScsiName));
- *StartOpCodeHandle = NULL;
- *EndOpCodeHandle = NULL;
- Status = EFI_OUT_OF_RESOURCES;
+ if (OffSet < ATTEMPT_BOOTENABLE_VAR_OFFSET) {
+ return EFI_SUCCESS;
- //
- // Initialize the container for dynamic opcodes.
- //
- *StartOpCodeHandle = HiiAllocateOpCodeHandle ();
- if (*StartOpCodeHandle == NULL) {
- return Status;
- }
+ } else if ((OffSet >= ATTEMPT_BOOTENABLE_VAR_OFFSET) && (OffSet < ATTEMPT_ADDRESS_TYPE_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_BOOTENABLE_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ IfrNvData->Enabled = IfrNvData->ISCSIBootEnableList[AttemptIndex - 1];
+ //
+ // Validate the configuration of attempt.
+ //
+ if (IfrNvData->Enabled != ISCSI_DISABLED) {
+ //
+ // Check whether this attempt uses NIC which is already used by existing attempt.
+ //
+ SameNicAttempt = IScsiConfigGetAttemptByNic (Attempt, IfrNvData->Enabled);
+ if (SameNicAttempt != NULL) {
+ AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
+ if (AttemptName1 == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
- *EndOpCodeHandle = HiiAllocateOpCodeHandle ();
- if (*EndOpCodeHandle == NULL) {
- goto Exit;
- }
+ AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
+ if (AttemptName2 == NULL) {
+ FreePool (AttemptName1);
+ return EFI_OUT_OF_RESOURCES;
+ }
- //
- // Create Hii Extend Label OpCode as the start opcode.
- //
- InternalStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- *StartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
- if (InternalStartLabel == NULL) {
- goto Exit;
- }
-
- InternalStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- InternalStartLabel->Number = StartLabelNumber;
+ AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_SIZE);
+ AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_SIZE);
- //
- // Create Hii Extend Label OpCode as the end opcode.
- //
- InternalEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- *EndOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
- if (InternalEndLabel == NULL) {
- goto Exit;
- }
+ UnicodeSPrint (
+ mPrivate->PortString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Warning! \"%s\" uses same NIC as Attempt \"%s\".",
+ AttemptName1,
+ AttemptName2
+ );
- InternalEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- InternalEndLabel->Number = LABEL_END;
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ mPrivate->PortString,
+ NULL
+ );
- *StartLabel = InternalStartLabel;
- *EndLabel = InternalEndLabel;
+ FreePool (AttemptName1);
+ FreePool (AttemptName2);
+ }
+ }
- return EFI_SUCCESS;
+ if (IfrNvData->Enabled == ISCSI_DISABLED &&
+ Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
-Exit:
+ //
+ // User updates the Attempt from "Enabled"/"Enabled for MPIO" to "Disabled".
+ //
+ if (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
+ if (mPrivate->MpioCount < 1) {
+ return EFI_ABORTED;
+ }
- if (*StartOpCodeHandle != NULL) {
- HiiFreeOpCodeHandle (*StartOpCodeHandle);
- }
+ if (--mPrivate->MpioCount == 0) {
+ mPrivate->EnableMpio = FALSE;
+ }
+ } else if (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) {
+ if (mPrivate->SinglePathCount < 1) {
+ return EFI_ABORTED;
+ }
+ mPrivate->SinglePathCount--;
+ }
- if (*EndOpCodeHandle != NULL) {
- HiiFreeOpCodeHandle (*EndOpCodeHandle);
- }
-
- return Status;
-}
+ } else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO &&
+ Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) {
+ //
+ // User updates the Attempt from "Enabled" to "Enabled for MPIO".
+ //
+ if (mPrivate->SinglePathCount < 1) {
+ return EFI_ABORTED;
+ }
+
+ mPrivate->EnableMpio = TRUE;
+ mPrivate->MpioCount++;
+ mPrivate->SinglePathCount--;
+
+ } else if (IfrNvData->Enabled == ISCSI_ENABLED &&
+ Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
+ //
+ // User updates the Attempt from "Enabled for MPIO" to "Enabled".
+ //
+ if (mPrivate->MpioCount < 1) {
+ return EFI_ABORTED;
+ }
+
+ if (--mPrivate->MpioCount == 0) {
+ mPrivate->EnableMpio = FALSE;
+ }
+ mPrivate->SinglePathCount++;
+
+ } else if (IfrNvData->Enabled != ISCSI_DISABLED &&
+ Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) {
+ //
+ // User updates the Attempt from "Disabled" to "Enabled"/"Enabled for MPIO".
+ //
+ if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {
+ mPrivate->EnableMpio = TRUE;
+ mPrivate->MpioCount++;
+
+ } else if (IfrNvData->Enabled == ISCSI_ENABLED) {
+ mPrivate->SinglePathCount++;
+ }
+ }
+ Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
+
+ } else if ((OffSet >= ATTEMPT_ADDRESS_TYPE_VAR_OFFSET) && (OffSet < ATTEMPT_CONNECT_RETRY_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_ADDRESS_TYPE_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Attempt->SessionConfigData.IpMode = IfrNvData->ISCSIIpAddressTypeList[AttemptIndex - 1];
+ if (Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
+ Attempt->AutoConfigureMode = 0;
+ }
+
+ } else if ((OffSet >= ATTEMPT_CONNECT_RETRY_VAR_OFFSET) && (OffSet < ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CONNECT_RETRY_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1];
+ if (Attempt->SessionConfigData.ConnectRetryCount == 0) {
+ Attempt->SessionConfigData.ConnectRetryCount = CONNECT_MIN_RETRY;
+ }
+
+ } else if ((OffSet >= ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) / 2 + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Attempt->SessionConfigData.ConnectTimeout = IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1];
+ if (Attempt->SessionConfigData.ConnectTimeout == 0) {
+ Attempt->SessionConfigData.ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
+ }
+
+ if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ if (Attempt->SessionConfigData.ConnectTimeout < CONNECT_MIN_TIMEOUT) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Connection Establishing Timeout is less than minimum value 100ms.",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ } else if ((OffSet >= ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_ISID_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Attempt->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData->ISCSIInitiatorInfoViaDHCP[AttemptIndex - 1];
+
+ } else if ((OffSet >= ATTEMPT_ISID_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_ISID_VAR_OFFSET) / (ISID_CONFIGURABLE_STORAGE * sizeof (CHAR16))) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IScsiParseIsIdFromString (IfrNvData->ISCSIISID + (AttemptIndex - 1) * ISID_CONFIGURABLE_STORAGE, Attempt->SessionConfigData.IsId);
+
+ } else if ((OffSet >= ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET) / (IP4_STR_MAX_SIZE * sizeof (CHAR16))) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
+ //
+ // Config Local ip
+ //
+ Status = NetLibStrToIp4 ((IfrNvData->ISCSIInitiatorIpAddress + (AttemptIndex - 1) * IP4_STR_MAX_SIZE), &HostIp.v4);
+ if (EFI_ERROR (Status) || ((Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) &&
+ !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid IP address!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Attempt->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Enable DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET) / (IP4_STR_MAX_SIZE * sizeof (CHAR16))) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
+ Status = NetLibStrToIp4 ((IfrNvData->ISCSIInitiatorNetmask + (AttemptIndex - 1) * IP4_STR_MAX_SIZE), &SubnetMask.v4);
+ if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (IScsiGetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Subnet Mask!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Attempt->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Enable DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET) / (IP4_STR_MAX_SIZE * sizeof (CHAR16)))+ 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
+ Status = NetLibStrToIp4 ((IfrNvData->ISCSIInitiatorGateway + (AttemptIndex - 1) * IP4_STR_MAX_SIZE), &Gateway.v4);
+ if (EFI_ERROR (Status) ||
+ ((Gateway.Addr[0] != 0) && (Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) &&
+ !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Gateway!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Attempt->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Enable DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
+ Attempt->SessionConfigData.TargetInfoFromDhcp = IfrNvData->ISCSITargetInfoViaDHCP[AttemptIndex - 1];
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Enable DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_NAME_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) / 2 + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
+ Attempt->SessionConfigData.TargetPort = IfrNvData->ISCSITargetTcpPort[AttemptIndex - 1];
+ if (Attempt->SessionConfigData.TargetPort == 0) {
+ Attempt->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT;
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Target Via DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_TARGET_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_TARGET_NAME_VAR_OFFSET) / (ISCSI_NAME_MAX_SIZE * sizeof (CHAR16)))+ 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
+ UnicodeStrToAsciiStrS ((IfrNvData->ISCSITargetName + (AttemptIndex - 1) * ISCSI_NAME_MAX_SIZE), IScsiName, ISCSI_NAME_MAX_SIZE);
+ Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName));
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid iSCSI Name!",
+ NULL
+ );
+ } else {
+ AsciiStrCpyS (Attempt->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName);
+ }
+ if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ if (Attempt->SessionConfigData.TargetName[0] == L'\0') {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"iSCSI target name is NULL!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Target Via DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_LUN_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET) / (IP_STR_MAX_SIZE * sizeof (CHAR16))) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
+ UnicodeStrToAsciiStrS ((IfrNvData->ISCSITargetIpAddress + (AttemptIndex - 1) * IP_STR_MAX_SIZE), IpString, IP_STR_MAX_SIZE);
+ Status = IScsiAsciiStrToIp (IpString, Attempt->SessionConfigData.IpMode, &HostIp);
+ if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, Attempt->SessionConfigData.IpMode)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid IP address!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Attempt->SessionConfigData.TargetIp, &HostIp, sizeof (HostIp));
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Target Via DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_LUN_VAR_OFFSET) && (OffSet < ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_LUN_VAR_OFFSET) / (ISCSI_LUN_STR_MAX_LEN * sizeof (CHAR16))) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (Attempt->SessionConfigData.TargetInfoFromDhcp == 0)) {
+ //
+ // Config LUN.
+ //
+ UnicodeStrToAsciiStrS ((IfrNvData->ISCSILUN + (AttemptIndex - 1) * ISCSI_LUN_STR_MAX_LEN), LunString, ISCSI_LUN_STR_MAX_LEN);
+ Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid LUN string, Examples are: 4752-3A4F-6b7e-2F99, 6734-9-156f-127, 4186-9!",
+ NULL
+ );
+ } else {
+ CopyMem (&Attempt->SessionConfigData.BootLun, &Lun, sizeof (Lun));
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of IpMode or Target Via DHCP!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET) && (OffSet < ATTEMPT_CHARTYPE_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Attempt->AuthenticationType = IfrNvData->ISCSIAuthenticationMethod[AttemptIndex - 1];
+
+ } else if ((OffSet >= ATTEMPT_CHARTYPE_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_USER_NAME_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CHARTYPE_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
+ Attempt->AuthConfigData.CHAP.CHAPType = IfrNvData->ISCSIChapType[AttemptIndex - 1];
+ }
+ } else if ((OffSet >= ATTEMPT_CHAR_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_SECRET_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_CHAR_USER_NAME_VAR_OFFSET) / (ISCSI_CHAP_NAME_STORAGE * sizeof (CHAR16)))+ 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
+ UnicodeStrToAsciiStrS (
+ IfrNvData->ISCSIChapUsername + (AttemptIndex - 1) * ISCSI_CHAP_NAME_STORAGE,
+ Attempt->AuthConfigData.CHAP.CHAPName,
+ ISCSI_CHAP_NAME_STORAGE
+ );
+
+ if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ if (IfrNvData->CHAPName[0] == L'\0') {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"CHAP Name is invalid!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of AuthenticationType!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_CHAR_SECRET_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_CHAR_SECRET_VAR_OFFSET) / (ISCSI_CHAP_SECRET_STORAGE * sizeof (CHAR16)))+ 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
+ UnicodeStrToAsciiStrS (
+ IfrNvData->ISCSIChapSecret + (AttemptIndex - 1) * ISCSI_CHAP_SECRET_STORAGE,
+ Attempt->AuthConfigData.CHAP.CHAPSecret,
+ ISCSI_CHAP_SECRET_STORAGE
+ );
+
+ if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ if (IfrNvData->CHAPSecret[0] == L'\0') {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"CHAP Secret is invalid!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of AuthenticationType!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if ((OffSet >= ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET)) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET) / (ISCSI_CHAP_NAME_STORAGE * sizeof (CHAR16)))+ 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) {
+ UnicodeStrToAsciiStrS (
+ IfrNvData->ISCSIReverseChapUsername + (AttemptIndex - 1) * ISCSI_CHAP_NAME_STORAGE,
+ Attempt->AuthConfigData.CHAP.ReverseCHAPName,
+ ISCSI_CHAP_NAME_STORAGE
+ );
+ if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ if (IfrNvData->ReverseCHAPName[0] == L'\0') {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Reverse CHAP Name is invalid!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of AuthenticationType or Chap Type!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else if (OffSet >= ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) {
+ AttemptIndex = (UINT8) (((OffSet - ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) / (ISCSI_CHAP_SECRET_STORAGE * sizeof (CHAR16)))+ 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ if (Attempt == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) {
+ UnicodeStrToAsciiStrS (
+ IfrNvData->ISCSIReverseChapSecret + (AttemptIndex - 1) * ISCSI_CHAP_SECRET_STORAGE,
+ Attempt->AuthConfigData.CHAP.ReverseCHAPSecret,
+ ISCSI_CHAP_SECRET_STORAGE
+ );
+
+ if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ if (IfrNvData->ReverseCHAPSecret[0] == L'\0') {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Reverse CHAP Secret is invalid!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ } else {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Configuration, Check value of AuthenticationType or Chap Type!",
+ NULL
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // Record the user configuration information in NVR.
+ //
+
+ UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex);
+ return gRT->SetVariable (
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ ISCSI_CONFIG_VAR_ATTR,
+ sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
+ Attempt
+ );
+
+}
+
+/**
+ Create Hii Extend Label OpCode as the start opcode and end opcode. It is
+ a help function.
+
+ @param[in] StartLabelNumber The number of start label.
+ @param[out] StartOpCodeHandle Points to the start opcode handle.
+ @param[out] StartLabel Points to the created start opcode.
+ @param[out] EndOpCodeHandle Points to the end opcode handle.
+ @param[out] EndLabel Points to the created end opcode.
+
+ @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this
+ operation.
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
+ @retval EFI_SUCCESS The operation is completed successfully.
+
+**/
+EFI_STATUS
+IScsiCreateOpCode (
+ IN UINT16 StartLabelNumber,
+ OUT VOID **StartOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **StartLabel,
+ OUT VOID **EndOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **EndLabel
+ )
+{
+ EFI_STATUS Status;
+ EFI_IFR_GUID_LABEL *InternalStartLabel;
+ EFI_IFR_GUID_LABEL *InternalEndLabel;
+
+ if (StartOpCodeHandle == NULL || StartLabel == NULL || EndOpCodeHandle == NULL || EndLabel == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *StartOpCodeHandle = NULL;
+ *EndOpCodeHandle = NULL;
+ Status = EFI_OUT_OF_RESOURCES;
+
+ //
+ // Initialize the container for dynamic opcodes.
+ //
+ *StartOpCodeHandle = HiiAllocateOpCodeHandle ();
+ if (*StartOpCodeHandle == NULL) {
+ return Status;
+ }
+
+ *EndOpCodeHandle = HiiAllocateOpCodeHandle ();
+ if (*EndOpCodeHandle == NULL) {
+ goto Exit;
+ }
+
+ //
+ // Create Hii Extend Label OpCode as the start opcode.
+ //
+ InternalStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
+ *StartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
+ if (InternalStartLabel == NULL) {
+ goto Exit;
+ }
+
+ InternalStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
+ InternalStartLabel->Number = StartLabelNumber;
+
+ //
+ // Create Hii Extend Label OpCode as the end opcode.
+ //
+ InternalEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
+ *EndOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
+ if (InternalEndLabel == NULL) {
+ goto Exit;
+ }
+
+ InternalEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
+ InternalEndLabel->Number = LABEL_END;
+
+ *StartLabel = InternalStartLabel;
+ *EndLabel = InternalEndLabel;
+
+ return EFI_SUCCESS;
+
+Exit:
+
+ if (*StartOpCodeHandle != NULL) {
+ HiiFreeOpCodeHandle (*StartOpCodeHandle);
+ }
+
+ if (*EndOpCodeHandle != NULL) {
+ HiiFreeOpCodeHandle (*EndOpCodeHandle);
+ }
+ return Status;
+}
+
+/**
+ Update the MAIN form to display the configured attempts.
+
+**/
+VOID
+IScsiConfigUpdateAttempt (
+ VOID
+ )
+{
+ LIST_ENTRY *Entry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ EFI_STATUS Status;
+
+ Status = IScsiCreateOpCode (
+ ATTEMPT_ENTRY_LABEL,
+ &StartOpCodeHandle,
+ &StartLabel,
+ &EndOpCodeHandle,
+ &EndLabel
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
+ AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
+ if (AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {
+ //
+ // Update Attempt Help Info.
+ //
+ UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", (UINTN) AttemptConfigData->AttemptConfigIndex);
+ AttemptConfigData->AttemptTitleToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ mPrivate->PortString,
+ NULL
+ );
+ if (AttemptConfigData->AttemptTitleToken == 0) {
+ return ;
+ }
+
+ HiiCreateGotoOpCode (
+ StartOpCodeHandle, // Container for dynamic created opcodes
+ FORMID_ATTEMPT_FORM, // Form ID
+ AttemptConfigData->AttemptTitleToken, // Prompt text
+ AttemptConfigData->AttemptTitleHelpToken, // Help text
+ EFI_IFR_FLAG_CALLBACK, // Question flag
+ (UINT16) (KEY_ATTEMPT_ENTRY_BASE + AttemptConfigData->AttemptConfigIndex) // Question ID
+ );
+ }
+ }
+
+ HiiUpdateForm (
+ mCallbackInfo->RegisteredHandle, // HII handle
+ &gIScsiConfigGuid, // Formset GUID
+ FORMID_MAIN_FORM, // Form ID
+ StartOpCodeHandle, // Label for where to insert opcodes
+ EndOpCodeHandle // Replace data
+ );
+
+ HiiFreeOpCodeHandle (StartOpCodeHandle);
+ HiiFreeOpCodeHandle (EndOpCodeHandle);
+}
/**
Callback function when user presses "Add an Attempt".
@retval EFI_OUT_OF_RESOURCES Does not have sufficient resources to finish this
@@ -1079,80 +2006,186 @@ Exit:
HiiFreeOpCodeHandle (EndOpCodeHandle);
return Status;
}
-
/**
- Update the MAIN form to display the configured attempts.
+ Add the attempts by keywords.
+
+ @param[in] AttemptList The new attempt List will be added.
+
+ @retval EFI_SUCCESS The operation to add attempt list successfully.
+ @retval EFI_INVALID_PARAMETER Any parameter is invalid.
+ @retval EFI_NOT_FOUND Cannot find the corresponding variable.
+ @retval EFI_OUT_OF_RESOURCES Fail to finish the operation due to lack of
+ resources.
**/
-VOID
-IScsiConfigUpdateAttempt (
- VOID
+EFI_STATUS
+IScsiConfigAddAttemptsByKeywords (
+ IN UINT8 *AttemptList
)
{
- CHAR16 AttemptName[ATTEMPT_NAME_MAX_SIZE];
- LIST_ENTRY *Entry;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- VOID *StartOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *EndLabel;
- EFI_STATUS Status;
+ UINT8 Index;
+ UINT8 Number;
+ UINTN TotalNumber;
+ UINT8 Nic;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINT8 *AttemptConfigOrderTmp;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_NIC_INFO *NicInfo;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 IScsiMode[64];
+ CHAR16 IpMode[64];
+ EFI_STATUS Status;
- Status = IScsiCreateOpCode (
- ATTEMPT_ENTRY_LABEL,
- &StartOpCodeHandle,
- &StartLabel,
- &EndOpCodeHandle,
- &EndLabel
- );
- if (EFI_ERROR (Status)) {
- return ;
+ Nic = mPrivate->CurrentNic;
+ NicInfo = IScsiGetNicInfoByIndex (Nic);
+ if (NicInfo == NULL) {
+ return EFI_NOT_FOUND;
}
- NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
- AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
+ //
+ // The MAC info will be recorded in Config Data.
+ //
+ IScsiMacAddrToStr (
+ &NicInfo->PermanentAddress,
+ NicInfo->HwAddressSize,
+ NicInfo->VlanId,
+ MacString
+ );
+
+ for (Index = 0; Index < PcdGet8 (PcdMaxIScsiAttemptNumber); Index++) {
+ if (AttemptList[Index] == 0) {
+ continue;
+ }
+
+ //
+ // Add the attempt.
+ //
+ Number = AttemptList[Index];
+
+ UnicodeSPrint (
+ mPrivate->PortString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Attempt %d",
+ Number
+ );
+
+ GetVariable2 (
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
+ if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED;
+ AttemptConfigData->NicIndex = NicInfo->NicIndex;
+ UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, ISCSI_MAX_MAC_STRING_LEN);
+
+ //
+ // Generate OUI-format ISID based on MAC address.
+ //
+ CopyMem (AttemptConfigData->SessionConfigData.IsId, &NicInfo->PermanentAddress, 6);
+ AttemptConfigData->SessionConfigData.IsId[0] =
+ (UINT8) (AttemptConfigData->SessionConfigData.IsId[0] & 0x3F);
+
+ //
+ // Configure the iSCSI Mode and IpMode to default.
+ // Add Attempt Help Info.
+ //
+ UnicodeSPrint (IScsiMode, 64, L"Disabled");
+ UnicodeSPrint (IpMode, 64, L"IP4");
+ UnicodeSPrint (
+ mPrivate->PortString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s",
+ MacString,
+ NicInfo->BusNumber,
+ NicInfo->DeviceNumber,
+ NicInfo->FunctionNumber,
+ IScsiMode,
+ IpMode
+ );
+
+ AttemptConfigData->AttemptTitleHelpToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ mPrivate->PortString,
+ NULL
+ );
+ if (AttemptConfigData->AttemptTitleHelpToken == 0) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Get current Attempt order and number.
+ //
+ AttemptConfigOrder = IScsiGetVariableAndSize (
+ L"AttemptOrder",
+ &gIScsiConfigGuid,
+ &AttemptConfigOrderSize
+ );
+ TotalNumber = AttemptConfigOrderSize / sizeof (UINT8);
+ TotalNumber++;
+
+ //
+ // Append the new created attempt order to the end.
+ //
+ AttemptConfigOrderTmp = AllocateZeroPool (TotalNumber * sizeof (UINT8));
+ if (AttemptConfigOrderTmp == NULL) {
+ if (AttemptConfigOrder != NULL) {
+ FreePool (AttemptConfigOrder);
+ }
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if (AttemptConfigOrder != NULL) {
+ CopyMem (AttemptConfigOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize);
+ FreePool (AttemptConfigOrder);
+ }
+
+ AttemptConfigOrderTmp[TotalNumber - 1] = Number;
+ AttemptConfigOrder = AttemptConfigOrderTmp;
+ AttemptConfigOrderSize = TotalNumber * sizeof (UINT8);
- AsciiStrToUnicodeStrS (AttemptConfigData->AttemptName, AttemptName, ARRAY_SIZE (AttemptName));
- UnicodeSPrint (mPrivate->PortString, (UINTN) 128, L"Attempt %s", AttemptName);
- AttemptConfigData->AttemptTitleToken = HiiSetString (
- mCallbackInfo->RegisteredHandle,
- 0,
- mPrivate->PortString,
- NULL
- );
- if (AttemptConfigData->AttemptTitleToken == 0) {
- return ;
+ Status = gRT->SetVariable (
+ L"AttemptOrder",
+ &gIScsiConfigGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ AttemptConfigOrderSize,
+ AttemptConfigOrder
+ );
+ FreePool (AttemptConfigOrder);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
- HiiCreateGotoOpCode (
- StartOpCodeHandle, // Container for dynamic created opcodes
- FORMID_ATTEMPT_FORM, // Form ID
- AttemptConfigData->AttemptTitleToken, // Prompt text
- AttemptConfigData->AttemptTitleHelpToken, // Help text
- EFI_IFR_FLAG_CALLBACK, // Question flag
- (UINT16) (KEY_ATTEMPT_ENTRY_BASE + AttemptConfigData->AttemptConfigIndex) // Question ID
- );
- }
+ //
+ // Record the attempt in global link list.
+ //
+ InsertTailList (&mPrivate->AttemptConfigs, &AttemptConfigData->Link);
+ mPrivate->AttemptCount++;
+ UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", AttemptConfigData->AttemptConfigIndex);
+ gRT->SetVariable (
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ ISCSI_CONFIG_VAR_ATTR,
+ sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
+ AttemptConfigData
+ );
- HiiUpdateForm (
- mCallbackInfo->RegisteredHandle, // HII handle
- &gIScsiConfigGuid, // Formset GUID
- FORMID_MAIN_FORM, // Form ID
- StartOpCodeHandle, // Label for where to insert opcodes
- EndOpCodeHandle // Replace data
- );
+ }
- HiiFreeOpCodeHandle (StartOpCodeHandle);
- HiiFreeOpCodeHandle (EndOpCodeHandle);
+ return EFI_SUCCESS;
}
-
/**
- Callback function when user presses "Commit Changes and Exit" in Delete Attempts.
+ Callback function when user presses "Commit Changes and Exit" in Delete Attempts or Delete Attempts by Keyword.
@param[in] IfrNvData The IFR NV data.
@retval EFI_NOT_FOUND Cannot find the corresponding variable.
@retval EFI_SUCCESS The operation is completed successfully.
@@ -1165,23 +2198,26 @@ IScsiConfigUpdateAttempt (
EFI_STATUS
IScsiConfigDeleteAttempts (
IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN NewIndex;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINT8 *AttemptNewOrder;
- UINT32 Attribute;
- UINTN Total;
- UINTN NewTotal;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN NewIndex;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINT8 *AttemptNewOrder;
+ UINT8 AttemptConfigIndex;
+ UINT32 Attribute;
+ UINTN Total;
+ UINTN NewTotal;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigData;
+
+ Index = 0;
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
@@ -1196,11 +2232,10 @@ IScsiConfigDeleteAttempts (
goto Error;
}
Total = AttemptConfigOrderSize / sizeof (UINT8);
NewTotal = Total;
- Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mPrivate->AttemptConfigs) {
if (IfrNvData->DeleteAttemptList[Index] == 0) {
Index++;
continue;
@@ -1241,26 +2276,48 @@ IScsiConfigDeleteAttempts (
}
mPrivate->SinglePathCount--;
}
- AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, ARRAY_SIZE (MacString));
+ AttemptConfigIndex = AttemptConfigData->AttemptConfigIndex;
+ FreePool (AttemptConfigData);
+
+ //
+ // Create a new Attempt
+ //
+ AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA));
+ if (AttemptConfigData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ ConfigData = &AttemptConfigData->SessionConfigData;
+ ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
+ ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
+ ConfigData->ConnectRetryCount = CONNECT_MIN_RETRY;
+
+ AttemptConfigData->AuthenticationType = ISCSI_AUTH_TYPE_CHAP;
+ AttemptConfigData->AuthConfigData.CHAP.CHAPType = ISCSI_CHAP_UNI;
+ //
+ // Configure the Attempt index and set variable.
+ //
+ AttemptConfigData->AttemptConfigIndex = AttemptConfigIndex;
+ //
+ // Set the attempt name to default.
+ //
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) 128,
- L"%s%d",
- MacString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Attempt %d",
(UINTN) AttemptConfigData->AttemptConfigIndex
);
-
+ UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE);
gRT->SetVariable (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
- 0,
- 0,
- NULL
+ ISCSI_CONFIG_VAR_ATTR,
+ sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
+ AttemptConfigData
);
//
// Mark the attempt order in NVR to be deleted - 0.
//
@@ -1270,10 +2327,13 @@ IScsiConfigDeleteAttempts (
break;
}
}
NewTotal--;
+ if (mCallbackInfo->Current == AttemptConfigData) {
+ mCallbackInfo->Current = NULL;
+ }
FreePool (AttemptConfigData);
//
// Check next Attempt.
//
@@ -1309,11 +2369,11 @@ Error:
}
if (AttemptNewOrder != NULL) {
FreePool (AttemptNewOrder);
}
-
+
return Status;
}
/**
@@ -1508,24 +2568,23 @@ Error:
}
return Status;
}
-
/**
- Callback function when user presses "Commit Changes and Exit" in Change Attempt Order.
+ Callback function when user presses "Commit Changes and Exit" in Change Attempt Order or Change Attempt Order by Keyword.
@param[in] IfrNvData The IFR nv data.
@retval EFI_OUT_OF_RESOURCES Does not have sufficient resources to finish this
operation.
@retval EFI_NOT_FOUND Cannot find the corresponding variable.
@retval EFI_SUCCESS The operation is completed successfully.
**/
EFI_STATUS
-IScsiConfigOrderAttempts (
+ IScsiConfigOrderAttempts (
IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
EFI_STATUS Status;
UINTN Index;
@@ -1637,18 +2696,16 @@ IScsiConfigProcessDefault (
IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
BOOLEAN NewAttempt;
ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigData;
UINT8 CurrentAttemptConfigIndex;
ISCSI_NIC_INFO *NicInfo;
UINT8 NicIndex;
CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
UINT8 *AttemptConfigOrder;
UINTN AttemptConfigOrderSize;
- UINTN TotalNumber;
UINTN Index;
//
// Is User creating a new attempt?
//
@@ -1671,80 +2728,53 @@ IScsiConfigProcessDefault (
//
// Don't process anything.
//
return EFI_SUCCESS;
}
-
- //
- // Free any attempt that is previously created but not saved to system.
- //
- if (mPrivate->NewAttempt != NULL) {
- FreePool (mPrivate->NewAttempt);
- mPrivate->NewAttempt = NULL;
- }
if (NewAttempt) {
//
// Determine which NIC user has selected for the new created attempt.
//
NicIndex = (UINT8) (KeyValue - KEY_MAC_ENTRY_BASE);
NicInfo = IScsiGetNicInfoByIndex (NicIndex);
if (NicInfo == NULL) {
return EFI_NOT_FOUND;
}
-
- //
- // Create new attempt.
- //
-
- AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA));
- if (AttemptConfigData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- ConfigData = &AttemptConfigData->SessionConfigData;
- ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
- ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
- ConfigData->ConnectRetryCount = CONNECT_MIN_RETRY;
-
- AttemptConfigData->AuthenticationType = ISCSI_AUTH_TYPE_CHAP;
- AttemptConfigData->AuthConfigData.CHAP.CHAPType = ISCSI_CHAP_UNI;
//
- // Get current order number for this attempt.
+ // Create an attempt following the initialized attempt order.
//
AttemptConfigOrder = IScsiGetVariableAndSize (
- L"AttemptOrder",
+ L"InitiatorAttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- TotalNumber = AttemptConfigOrderSize / sizeof (UINT8);
+ if (AttemptConfigOrder != NULL) {
- if (AttemptConfigOrder == NULL) {
- CurrentAttemptConfigIndex = 1;
- } else {
- //
- // Get the max attempt config index.
- //
- CurrentAttemptConfigIndex = AttemptConfigOrder[0];
- for (Index = 1; Index < TotalNumber; Index++) {
- if (CurrentAttemptConfigIndex < AttemptConfigOrder[Index]) {
- CurrentAttemptConfigIndex = AttemptConfigOrder[Index];
+ for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
+ UnicodeSPrint (
+ mPrivate->PortString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Attempt %d",
+ (UINTN) AttemptConfigOrder[Index]
+ );
+ GetVariable2 (
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
+ if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {
+ continue;
}
- }
- CurrentAttemptConfigIndex++;
+ break;
+ }
}
- TotalNumber++;
-
- //
- // Record the mapping between attempt order and attempt's configdata.
- //
- AttemptConfigData->AttemptConfigIndex = CurrentAttemptConfigIndex;
-
if (AttemptConfigOrder != NULL) {
FreePool (AttemptConfigOrder);
}
//
@@ -1757,10 +2787,11 @@ IScsiConfigProcessDefault (
MacString
);
UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, sizeof (AttemptConfigData->MacString));
AttemptConfigData->NicIndex = NicIndex;
+ AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED;
//
// Generate OUI-format ISID based on MAC address.
//
CopyMem (AttemptConfigData->SessionConfigData.IsId, &NicInfo->PermanentAddress, 6);
@@ -1786,31 +2817,13 @@ IScsiConfigProcessDefault (
mPrivate->PortString,
NULL
);
if (AttemptConfigData->AttemptTitleHelpToken == 0) {
FreePool (AttemptConfigData);
- return EFI_INVALID_PARAMETER;
+ return EFI_OUT_OF_RESOURCES;
}
- //
- // Set the attempt name to default.
- //
- UnicodeSPrint (
- mPrivate->PortString,
- (UINTN) 128,
- L"%d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
- );
- UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, sizeof (AttemptConfigData->AttemptName));
-
- //
- // Save the created Attempt temporarily. If user does not save the attempt
- // by press 'KEY_SAVE_ATTEMPT_CONFIG' later, iSCSI driver would know that
- // and free resources.
- //
- mPrivate->NewAttempt = (VOID *) AttemptConfigData;
-
} else {
//
// Determine which Attempt user has selected to configure.
// Get the attempt configuration data.
//
@@ -1951,15 +2964,21 @@ IScsiFormExtractConfig (
Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
-
- if (Private->Current != NULL) {
+
+
+ if (Private->Current!= NULL) {
IScsiConvertAttemptConfigDataToIfrNvData (Private->Current, IfrNvData);
}
+ //
+ // Extract all AttemptConfigData to Keyword stroage of IfrNvData.
+ //
+ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (IfrNvData);
+
BufferSize = ISCSI_NAME_MAX_SIZE;
InitiatorName = (CHAR8 *) AllocateZeroPool (BufferSize);
if (InitiatorName == NULL) {
FreePool (IfrNvData);
return EFI_OUT_OF_RESOURCES;
@@ -2077,10 +3096,30 @@ IScsiFormRouteConfig (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
)
{
+ EFI_STATUS Status;
+ ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ ISCSI_NIC_INFO *NicInfo;
+ EFI_INPUT_KEY Key;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR8 *InitiatorName;
+ UINT8 *AttemptList;
+ UINTN BufferSize;
+ UINTN OffSet;
+ UINTN Index;
+ UINTN Index2;
+
+ Index = 0;
+ Index2 = 0;
+ NicInfo = NULL;
+ AttemptList = NULL;
+
if (This == NULL || Configuration == NULL || Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
//
@@ -2090,14 +3129,184 @@ IScsiFormRouteConfig (
if (!HiiIsConfigHdrMatch (Configuration, &gIScsiConfigGuid, mVendorStorageName)) {
*Progress = Configuration;
return EFI_NOT_FOUND;
}
- *Progress = Configuration + StrLen (Configuration);
- return EFI_SUCCESS;
-}
+ IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));
+ if (IfrNvData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ BufferSize = ISCSI_NAME_MAX_SIZE;
+ InitiatorName = (CHAR8 *) AllocateZeroPool (BufferSize);
+ if (InitiatorName == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ //
+ // Convert <ConfigResp> to buffer data by helper function ConfigToBlock().
+ //
+ BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
+ Status = gHiiConfigRouting->ConfigToBlock (
+ gHiiConfigRouting,
+ Configuration,
+ (UINT8 *) IfrNvData,
+ &BufferSize,
+ Progress
+ );
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+
+ if (IfrNvData->InitiatorName[0] != L'\0') {
+ UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, InitiatorName, ISCSI_NAME_MAX_SIZE);
+ BufferSize = AsciiStrSize (InitiatorName);
+
+ Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, InitiatorName);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid iSCSI Name!",
+ NULL
+ );
+ goto Exit;
+ }
+ } else {
+ Status = gIScsiInitiatorName.Get (&gIScsiInitiatorName, &BufferSize, InitiatorName);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: please configure iSCSI initiator name first!",
+ NULL
+ );
+ goto Exit;
+ }
+
+ if (IfrNvData->ISCSIAddAttemptList[0] != L'\0') {
+ Status =IScsiGetAttemptIndexList (IfrNvData->ISCSIAddAttemptList, IfrNvData->AddAttemptList, TRUE);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: The add attempt list is invalid",
+ NULL
+ );
+ goto Exit;
+ }
+
+ Status = IScsiConfigAddAttemptsByKeywords (IfrNvData->AddAttemptList);
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+
+ } else if (IfrNvData->ISCSIDeleteAttemptList[0] != L'\0') {
+ AttemptList =(UINT8 *) AllocateZeroPool ((ISCSI_MAX_ATTEMPTS_NUM + 1) * sizeof (UINT8));
+ if (AttemptList == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ Status = IScsiGetAttemptIndexList (IfrNvData->ISCSIDeleteAttemptList, AttemptList, FALSE);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: The delete attempt list is invalid",
+ NULL
+ );
+ goto Exit;
+ }
+ //
+ // Mark the attempt which will be delete in the global list.
+ //
+ NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mPrivate->AttemptConfigs) {
+ AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
+ while (AttemptList[Index] != 0) {
+ if (AttemptConfigData->AttemptConfigIndex == AttemptList[Index]) {
+ IfrNvData->DeleteAttemptList[Index2] = 1;
+ break;
+ }
+ Index ++;
+ }
+ Index2 ++;
+ Index = 0;
+ }
+
+ Status = IScsiConfigDeleteAttempts (IfrNvData);
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+
+ FreePool (AttemptList);
+
+ } else if (IfrNvData->ISCSIAttemptOrder[0] != L'\0') {
+ Status = IScsiGetAttemptIndexList (IfrNvData->ISCSIAttemptOrder, IfrNvData->DynamicOrderedList, FALSE);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: The new attempt order list is invalid",
+ NULL
+ );
+ goto Exit;
+ }
+
+ Status = IScsiConfigOrderAttempts (IfrNvData);
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+
+ } else if (IfrNvData->ISCSIMacAddr[0] != L'\0') {
+ NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
+ NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
+ IScsiMacAddrToStr (
+ &NicInfo->PermanentAddress,
+ NicInfo->HwAddressSize,
+ NicInfo->VlanId,
+ MacString
+ );
+ if (!StrCmp(MacString, IfrNvData->ISCSIMacAddr)) {
+ mPrivate->CurrentNic = NicInfo->NicIndex;
+ break;
+ }
+ }
+
+ if ((NicInfo == NULL) || (NicInfo->NicIndex == 0)) {
+ Status = EFI_NOT_FOUND;
+ goto Exit;
+ }
+
+ } else {
+ Status = IScsiGetValue (Configuration, L"&OFFSET=", &OffSet);
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+ Status = IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (IfrNvData, OffSet);
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+ }
+ }
+
+ IScsiConfigUpdateAttempt ();
+
+ Status = EFI_SUCCESS;
+
+Exit:
+ if (InitiatorName != NULL) {
+ FreePool (InitiatorName);
+ }
+
+ if (IfrNvData != NULL) {
+ FreePool (IfrNvData);
+ }
+
+ return Status;
+}
/**
This function is called to provide results data to the driver.
This data consists of a unique key that is used to identify
@@ -2143,11 +3352,10 @@ IScsiFormCallback (
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS Gateway;
ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
ISCSI_CONFIG_IFR_NVDATA OldIfrNvData;
EFI_STATUS Status;
- CHAR16 AttemptName[ATTEMPT_NAME_SIZE + 4];
EFI_INPUT_KEY Key;
if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {
//
// Do nothing for UEFI OPEN/CLOSE Action
@@ -2258,36 +3466,18 @@ IScsiFormCallback (
);
}
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
break;
- case KEY_ATTEMPT_NAME:
- if (StrLen (IfrNvData->AttemptName) > ATTEMPT_NAME_SIZE) {
- CopyMem (AttemptName, IfrNvData->AttemptName, ATTEMPT_NAME_SIZE * sizeof (CHAR16));
- CopyMem (&AttemptName[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));
- } else {
- CopyMem (
- AttemptName,
- IfrNvData->AttemptName,
- (StrLen (IfrNvData->AttemptName) + 1) * sizeof (CHAR16)
- );
- }
-
- UnicodeStrToAsciiStrS (IfrNvData->AttemptName, Private->Current->AttemptName, sizeof (Private->Current->AttemptName));
-
- IScsiConfigUpdateAttempt ();
-
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
- break;
case KEY_SAVE_ATTEMPT_CONFIG:
Status = IScsiConvertIfrNvDataToAttemptConfigData (IfrNvData, Private->Current);
if (EFI_ERROR (Status)) {
break;
}
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
break;
case KEY_SAVE_ORDER_CHANGES:
//
// Sync the Attempt Order to NVR.
@@ -2387,11 +3577,11 @@ IScsiFormCallback (
break;
case KEY_GATE_WAY:
Status = NetLibStrToIp4 (IfrNvData->Gateway, &Gateway.v4);
if (EFI_ERROR (Status) ||
- ((Gateway.Addr[0] != 0) &&
+ ((Gateway.Addr[0] != 0) &&
(Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@@ -2569,11 +3759,11 @@ IScsiConfigFormInit (
&gEfiHiiConfigAccessProtocolGuid,
&CallbackInfo->ConfigAccess,
NULL
);
ASSERT_EFI_ERROR (Status);
-
+
//
// Publish our HII data.
//
CallbackInfo->RegisteredHandle = HiiAddPackages (
&gIScsiConfigGuid,
@@ -2638,17 +3828,10 @@ IScsiConfigFormUnload (
mPrivate->NicCount--;
}
ASSERT (mPrivate->NicCount == 0);
- //
- // Free attempt is created but not saved to system.
- //
- if (mPrivate->NewAttempt != NULL) {
- FreePool (mPrivate->NewAttempt);
- }
-
FreePool (mPrivate);
mPrivate = NULL;
//
// Remove HII package list.
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.h b/NetworkPkg/IScsiDxe/IScsiConfig.h
index daa0d34..75cb0cd 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.h
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.h
@@ -1,10 +1,10 @@
/** @file
The header file of functions for configuring or getting the parameters
relating to iSCSI.
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, 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
http://opensource.org/licenses/bsd-license.php
@@ -35,15 +35,59 @@ extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
#define DYNAMIC_ONE_OF_VAR_OFFSET VAR_OFFSET (Enabled)
#define DYNAMIC_ORDERED_LIST_QUESTION_ID QUESTION_ID (DynamicOrderedList)
#define DYNAMIC_ORDERED_LIST_VAR_OFFSET VAR_OFFSET (DynamicOrderedList)
#define ATTEMPT_DEL_QUESTION_ID QUESTION_ID (DeleteAttemptList)
#define ATTEMPT_DEL_VAR_OFFSET VAR_OFFSET (DeleteAttemptList)
+#define ATTEMPT_ADD_QUESTION_ID QUESTION_ID (AddAttemptList)
+#define ATTEMPT_ADD_VAR_OFFSET VAR_OFFSET (AddAttemptList)
//
-// sizeof (EFI_MAC_ADDRESS) * 3
+// Define QuestionId and OffSet for Keywords.
//
-#define ISCSI_MAX_MAC_STRING_LEN 96
+#define ATTEMPT_ATTEMPT_NAME_QUESTION_ID QUESTION_ID (ISCSIAttemptName)
+#define ATTEMPT_ATTEMPT_NAME_VAR_OFFSET VAR_OFFSET (ISCSIAttemptName)
+#define ATTEMPT_BOOTENABLE_QUESTION_ID QUESTION_ID (ISCSIBootEnableList)
+#define ATTEMPT_BOOTENABLE_VAR_OFFSET VAR_OFFSET (ISCSIBootEnableList)
+#define ATTEMPT_ADDRESS_TYPE_QUESTION_ID QUESTION_ID (ISCSIIpAddressTypeList)
+#define ATTEMPT_ADDRESS_TYPE_VAR_OFFSET VAR_OFFSET (ISCSIIpAddressTypeList)
+#define ATTEMPT_CONNECT_RETRY_QUESTION_ID QUESTION_ID (ISCSIConnectRetry)
+#define ATTEMPT_CONNECT_RETRY_VAR_OFFSET VAR_OFFSET (ISCSIConnectRetry)
+#define ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID QUESTION_ID (ISCSIConnectTimeout)
+#define ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET VAR_OFFSET (ISCSIConnectTimeout)
+#define ATTEMPT_ISID_QUESTION_ID QUESTION_ID (ISCSIISID)
+#define ATTEMPT_ISID_VAR_OFFSET VAR_OFFSET (ISCSIISID)
+#define ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID QUESTION_ID (ISCSIInitiatorInfoViaDHCP)
+#define ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET VAR_OFFSET (ISCSIInitiatorInfoViaDHCP)
+#define ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID QUESTION_ID (ISCSIInitiatorIpAddress)
+#define ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET VAR_OFFSET (ISCSIInitiatorIpAddress)
+#define ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID QUESTION_ID (ISCSIInitiatorNetmask)
+#define ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET VAR_OFFSET (ISCSIInitiatorNetmask)
+#define ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID QUESTION_ID (ISCSIInitiatorGateway)
+#define ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET VAR_OFFSET (ISCSIInitiatorGateway)
+#define ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID QUESTION_ID (ISCSITargetInfoViaDHCP)
+#define ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET VAR_OFFSET (ISCSITargetInfoViaDHCP)
+#define ATTEMPT_TARGET_NAME_QUESTION_ID QUESTION_ID (ISCSITargetName)
+#define ATTEMPT_TARGET_NAME_VAR_OFFSET VAR_OFFSET (ISCSITargetName)
+#define ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID QUESTION_ID (ISCSITargetIpAddress)
+#define ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET VAR_OFFSET (ISCSITargetIpAddress)
+#define ATTEMPT_TARGET_TCP_PORT_QUESTION_ID QUESTION_ID (ISCSITargetTcpPort)
+#define ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET VAR_OFFSET (ISCSITargetTcpPort)
+#define ATTEMPT_LUN_QUESTION_ID QUESTION_ID (ISCSILUN)
+#define ATTEMPT_LUN_VAR_OFFSET VAR_OFFSET (ISCSILUN)
+#define ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID QUESTION_ID (ISCSIAuthenticationMethod)
+#define ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET VAR_OFFSET (ISCSIAuthenticationMethod)
+#define ATTEMPT_CHARTYPE_QUESTION_ID QUESTION_ID (ISCSIChapType)
+#define ATTEMPT_CHARTYPE_VAR_OFFSET VAR_OFFSET (ISCSIChapType)
+#define ATTEMPT_CHAR_USER_NAME_QUESTION_ID QUESTION_ID (ISCSIChapUsername)
+#define ATTEMPT_CHAR_USER_NAME_VAR_OFFSET VAR_OFFSET (ISCSIChapUsername)
+#define ATTEMPT_CHAR_SECRET_QUESTION_ID QUESTION_ID (ISCSIChapSecret)
+#define ATTEMPT_CHAR_SECRET_VAR_OFFSET VAR_OFFSET (ISCSIChapSecret)
+#define ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID QUESTION_ID (ISCSIReverseChapUsername)
+#define ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET VAR_OFFSET (ISCSIReverseChapUsername)
+#define ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID QUESTION_ID (ISCSIReverseChapSecret)
+#define ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET VAR_OFFSET (ISCSIReverseChapSecret)
+
#define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME"
#define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)
@@ -66,21 +110,22 @@ struct _ISCSI_ATTEMPT_CONFIG_NVDATA {
BOOLEAN ValidiBFTPath;
BOOLEAN ValidPath;
UINT8 AutoConfigureMode;
EFI_STRING_ID AttemptTitleToken;
EFI_STRING_ID AttemptTitleHelpToken;
- CHAR8 AttemptName[ATTEMPT_NAME_MAX_SIZE];
+ CHAR8 AttemptName[ATTEMPT_NAME_SIZE];
CHAR8 MacString[ISCSI_MAX_MAC_STRING_LEN];
EFI_IP_ADDRESS PrimaryDns;
EFI_IP_ADDRESS SecondaryDns;
EFI_IP_ADDRESS DhcpServer;
ISCSI_SESSION_CONFIG_NVDATA SessionConfigData;
UINT8 AuthenticationType;
union {
ISCSI_CHAP_AUTH_CONFIG_NVDATA CHAP;
} AuthConfigData;
BOOLEAN AutoConfigureSuccess;
+ UINT8 Actived;
};
///
/// HII specific Vendor Device Path definition.
///
@@ -100,10 +145,35 @@ struct _ISCSI_FORM_CALLBACK_INFO {
EFI_HII_HANDLE RegisteredHandle;
ISCSI_ATTEMPT_CONFIG_NVDATA *Current;
};
/**
+ Create Hii Extend Label OpCode as the start opcode and end opcode. It is
+ a help function.
+
+ @param[in] StartLabelNumber The number of start label.
+ @param[out] StartOpCodeHandle Points to the start opcode handle.
+ @param[out] StartLabel Points to the created start opcode.
+ @param[out] EndOpCodeHandle Points to the end opcode handle.
+ @param[out] EndLabel Points to the created end opcode.
+
+ @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this
+ operation.
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
+ @retval EFI_SUCCESS The operation is completed successfully.
+
+**/
+EFI_STATUS
+IScsiCreateOpCode (
+ IN UINT16 StartLabelNumber,
+ OUT VOID **StartOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **StartLabel,
+ OUT VOID **EndOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **EndLabel
+ );
+
+/**
Initialize the iSCSI configuration form.
@param[in] DriverBindingHandle The iSCSI driverbinding handle.
@retval EFI_SUCCESS The iSCSI configuration form is initialized.
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
index 56ebb50..6267332 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
+++ b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
@@ -1,9 +1,9 @@
/** @file
Define NVData structures used by the iSCSI configuration component.
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, 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
http://opensource.org/licenses/bsd-license.php
@@ -24,25 +24,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define FORMID_MAC_FORM 2
#define FORMID_ATTEMPT_FORM 3
#define FORMID_ORDER_FORM 4
#define FORMID_DELETE_FORM 5
+#define ISCSI_MAX_ATTEMPTS_NUM 8 // The value must be equal or larger than PcdMaxIScsiAttemptNumber.
+
#define ISCSI_NAME_IFR_MIN_SIZE 4
#define ISCSI_NAME_IFR_MAX_SIZE 223
#define ISCSI_NAME_MAX_SIZE 224
-#define ATTEMPT_NAME_MAX_SIZE 96
-#define ATTEMPT_NAME_SIZE 10
+#define ATTEMPT_NAME_LIST_SIZE 96
+#define ATTEMPT_NAME_SIZE 12
#define CONNECT_MIN_RETRY 0
#define CONNECT_MAX_RETRY 16
#define CONNECT_MIN_TIMEOUT 100
#define CONNECT_MAX_TIMEOUT 20000
#define CONNECT_DEFAULT_TIMEOUT 1000
-#define ISCSI_MAX_ATTEMPTS_NUM 255
+#define ISCSI_ACTIVE_DISABLED 0
+#define ISCSI_ACTIVE_ENABLED 1
#define ISCSI_DISABLED 0
#define ISCSI_ENABLED 1
#define ISCSI_ENABLED_FOR_MPIO 2
@@ -65,10 +68,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define IP_MAX_SIZE 39
#define IP_STR_MAX_SIZE 40
#define LUN_MIN_SIZE 1
#define LUN_MAX_SIZE 20
+#define ISCSI_LUN_STR_MAX_LEN 21
#define ISCSI_CHAP_UNI 0
#define ISCSI_CHAP_MUTUAL 1
#define TARGET_PORT_MIN_NUM 0
@@ -110,21 +114,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define KEY_DEVICE_ENTRY_BASE 0x1000
#define KEY_MAC_ENTRY_BASE 0x2000
#define MAC_ENTRY_LABEL 0x3000
#define ORDER_ENTRY_LABEL 0x4000
#define DELETE_ENTRY_LABEL 0x5000
+#define KEYWORD_ENTRY_LABEL 0x6000
#define CONFIG_OPTION_OFFSET 0x9000
-#define ISCSI_LUN_STR_MAX_LEN 21
#define ISCSI_CHAP_SECRET_MIN_LEN 12
#define ISCSI_CHAP_SECRET_MAX_LEN 16
//
// ISCSI_CHAP_SECRET_STORAGE = ISCSI_CHAP_SECRET_MAX_LEN + sizeof (NULL-Terminator)
//
-#define ISCSI_CHAP_SECRET_STORAGE 17
-#define ISCSI_CHAP_NAME_MAX_LEN 126
-#define ISCSI_CHAP_NAME_STORAGE 127
+#define ISCSI_CHAP_SECRET_STORAGE 17
+
+#define ISCSI_CHAP_NAME_MAX_LEN 126
+#define ISCSI_CHAP_NAME_STORAGE 127
#define KERBEROS_SECRET_MIN_LEN 12
#define KERBEROS_SECRET_MAX_LEN 16
#define KERBEROS_SECRET_STORAGE 17
#define KERBEROS_NAME_MAX_LEN 96
@@ -133,15 +138,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define ISID_CONFIGURABLE_MIN_LEN 6
#define ISID_CONFIGURABLE_MAX_LEN 12
#define ISID_CONFIGURABLE_STORAGE 13
+//
+// sizeof (EFI_MAC_ADDRESS) * 3
+//
+#define ISCSI_MAX_MAC_STRING_LEN 96
+
+//
+// Defined for Keyword. If the value PcdMaxIScsiAttemptNumber
+// has changed to a big one, these macro should also be updated
+// according to ISCSI_MAX_ATTEMPTS_NUM.
+//
+#define KEYWORD_TARGET_NAME_MAX_SIZE 1792 // ISCSI_MAX_ATTEMPTS_NUM * ISCSI_NAME_MAX_SIZE
+#define KEYWORD_IP4_STR_MAX_SIZE 28 // ISCSI_MAX_ATTEMPTS_NUM * IP4_STR_MAX_SIZE
+#define KEYWORD_IP_STR_MAX_SIZE 320 // ISCSI_MAX_ATTEMPTS_NUM * IP_STR_MAX_SIZE
+#define KEYWORD_LUN_STR_MAX_LEN 168 // ISCSI_MAX_ATTEMPTS_NUM * ISCSI_LUN_STR_MAX_LEN
+#define KEYWORD_CHAP_SECRET_STORAGE 136 // ISCSI_MAX_ATTEMPTS_NUM * ISCSI_CHAP_SECRET_STORAGE
+#define KEYWORD_CHAP_NAME_STORAGE 1016 // ISCSI_MAX_ATTEMPTS_NUM * ISCSI_CHAP_NAME_STORAGE
+#define KEYWORD_CONFIGURABLE_STORAGE 104 // ISCSI_MAX_ATTEMPTS_NUM * ISID_CONFIGURABLE_STORAGE
+
#pragma pack(1)
typedef struct _ISCSI_CONFIG_IFR_NVDATA {
CHAR16 InitiatorName[ISCSI_NAME_MAX_SIZE];
- CHAR16 AttemptName[ATTEMPT_NAME_MAX_SIZE];
-
+ CHAR16 AttemptName[ATTEMPT_NAME_SIZE];
UINT8 Enabled;
UINT8 IpMode;
UINT8 ConnectRetryCount;
UINT8 Padding1;
@@ -175,11 +197,42 @@ typedef struct _ISCSI_CONFIG_IFR_NVDATA {
CHAR16 KerberosKDCIp[IP_STR_MAX_SIZE];
UINT16 KerberosKDCPort;
UINT8 DynamicOrderedList[ISCSI_MAX_ATTEMPTS_NUM];
UINT8 DeleteAttemptList[ISCSI_MAX_ATTEMPTS_NUM];
-
+ UINT8 AddAttemptList[ISCSI_MAX_ATTEMPTS_NUM];
CHAR16 IsId[ISID_CONFIGURABLE_STORAGE];
+
+ //
+ // This will be used by keywords.
+ //
+ CHAR16 ISCSIMacAddr[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 ISCSIAttemptOrder[ATTEMPT_NAME_LIST_SIZE];
+ CHAR16 ISCSIAddAttemptList[ATTEMPT_NAME_LIST_SIZE];
+ CHAR16 ISCSIDeleteAttemptList[ATTEMPT_NAME_LIST_SIZE];
+ CHAR16 ISCSIDisplayAttemptList[ATTEMPT_NAME_LIST_SIZE];
+
+ CHAR16 ISCSIAttemptName[ATTEMPT_NAME_LIST_SIZE];
+ UINT8 ISCSIBootEnableList[ISCSI_MAX_ATTEMPTS_NUM];
+ UINT8 ISCSIIpAddressTypeList[ISCSI_MAX_ATTEMPTS_NUM];
+ UINT8 ISCSIConnectRetry[ISCSI_MAX_ATTEMPTS_NUM];
+ UINT16 ISCSIConnectTimeout[ISCSI_MAX_ATTEMPTS_NUM];
+ UINT8 ISCSIInitiatorInfoViaDHCP[ISCSI_MAX_ATTEMPTS_NUM];
+ CHAR16 ISCSIISID[KEYWORD_CONFIGURABLE_STORAGE];
+ CHAR16 ISCSIInitiatorIpAddress[KEYWORD_IP4_STR_MAX_SIZE];
+ CHAR16 ISCSIInitiatorNetmask[KEYWORD_IP4_STR_MAX_SIZE];
+ CHAR16 ISCSIInitiatorGateway[KEYWORD_IP4_STR_MAX_SIZE];
+ UINT8 ISCSITargetInfoViaDHCP[ISCSI_MAX_ATTEMPTS_NUM];
+ UINT16 ISCSITargetTcpPort[ISCSI_MAX_ATTEMPTS_NUM];
+ CHAR16 ISCSITargetName[KEYWORD_TARGET_NAME_MAX_SIZE];
+ CHAR16 ISCSITargetIpAddress[KEYWORD_IP_STR_MAX_SIZE];
+ CHAR16 ISCSILUN[KEYWORD_LUN_STR_MAX_LEN];
+ UINT8 ISCSIAuthenticationMethod[ISCSI_MAX_ATTEMPTS_NUM];
+ UINT8 ISCSIChapType[ISCSI_MAX_ATTEMPTS_NUM];
+ CHAR16 ISCSIChapUsername[KEYWORD_CHAP_NAME_STORAGE];
+ CHAR16 ISCSIChapSecret[KEYWORD_CHAP_SECRET_STORAGE];
+ CHAR16 ISCSIReverseChapUsername[KEYWORD_CHAP_NAME_STORAGE];
+ CHAR16 ISCSIReverseChapSecret[KEYWORD_CHAP_SECRET_STORAGE];
} ISCSI_CONFIG_IFR_NVDATA;
#pragma pack()
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
index 7a80fab..681f674 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
+++ b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
@@ -1,8 +1,8 @@
// *++
//
-// Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2004 - 2016, 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
// http://opensource.org/licenses/bsd-license.php
//
@@ -10,28 +10,30 @@
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Module Name:
//
// IScsiConfigStrings.uni
-//
+//
// Abstract:
-//
+//
// String definitions for iSCSI configuration.
-//
+//
// Revision History:
-//
+//
// --*/
/=#
#langdef en-US "English"
+#langdef x-UEFI-ns "UefiNameSpace"
#string STR_ISCSI_CONFIG_FORM_TITLE #language en-US "iSCSI Configuration"
#string STR_ISCSI_CONFIG_FORM_HELP #language en-US "Configure the iSCSI parameters."
#string STR_ISCSI_MAIN_FORM_TITLE #language en-US "iSCSI Configuration"
#string STR_ISCSI_MAC_FORM_TITLE #language en-US "MAC Selection"
#string STR_ISCSI_CONFIG_INIT_NAME #language en-US "iSCSI Initiator Name"
+ #language x-UEFI-ns "iSCSIInitiatorName"
#string STR_ISCSI_CONFIG_INIT_NAME_HELP #language en-US "The worldwide unique name of iSCSI Initiator. Only IQN format is accepted."
#string STR_ISCSI_ATTEMPT_NAME #language en-US "iSCSI Attempt Name"
#string STR_ISCSI_ATTEMPT_NAME_HELP #language en-US "The human name defined for this attempt."
#string STR_ISCSI_CONFIG_RETRY #language en-US "Connection Retry Count"
#string STR_ISCSI_CONFIG_RETRY_HELP #language en-US "The minimum value is 0 and the maximum is 16. 0 means no retry."
@@ -65,11 +67,11 @@
#string STR_ISCSI_TARGET_NAME_HELP #language en-US "The worldwide unique name of the target. Only iqn. format is accepted."
#string STR_ISCSI_TARGET_IP_ADDRESS #language en-US " Target IP Address"
#string STR_ISCSI_TARGET_PORT #language en-US " Target Port"
#string STR_ISCSI_BOOT_LUN #language en-US " Boot LUN"
#string STR_ISCSI_BOOT_LUN_HELP #language en-US "Hexadecimal representation of the LU number. Examples are: 4752-3A4F-6b7e-2F99, 6734-9-156f-127, 4186-9"
-#string STR_ISCSI_ENABLE_DHCP #language en-US "Enable DHCP"
+#string STR_ISCSI_ENABLE_DHCP #language en-US "Enable DHCP"
#string STR_ISCSI_ENABLE_DHCP_ON_TARGET #language en-US "Get target info via DHCP"
#string STR_CHAP_TYPE_PROMPT #language en-US " CHAP Type"
#string STR_CHAP_TYPE_HELP #language en-US "None, One way CHAP or mutual CHAP"
#string STR_CHAP_TYPE_UNI #language en-US "One way"
#string STR_CHAP_TYPE_MUTUAL #language en-US "Mutual"
@@ -80,11 +82,19 @@
#string STR_ISCSI_REVERSE_CHAP_SECRET #language en-US " Reverse CHAP Secret"
#string STR_RETURN_MAIN_FORM #language en-US "Back to Previous Page"
#string STR_SAVE_CHANGES #language en-US "Save Changes"
#string STR_SAVE_CHANGES_HELP #language en-US "Must reboot system manually for changes to take place."
#string STR_NULL #language en-US ""
-#string STR_SAVE_AND_EXIT #language en-US "Commit Changes and Exit"
-#string STR_NO_SAVE_AND_EXIT #language en-US "Discard Changes and Exit"
+#string STR_SAVE_AND_EXIT #language en-US "Commit Changes and Exit"
+#string STR_NO_SAVE_AND_EXIT #language en-US "Discard Changes and Exit"
#string STR_ISCSI_CONFIG_ISID #language en-US "ISID"
#string STR_ISCSI_CONFIG_ISID_HELP #language en-US "OUI-format ISID in 6 bytes, default value are derived from MAC address. Only last 3 bytes are configurable. Example: update 0ABBCCDDEEFF to 0ABBCCF07901 by input F07901."
-
-
\ No newline at end of file
+#string STR_ISCSI_MAC_PROMPT #language en-US "Configure the mac address for the attempt"
+ #language x-UEFI-ns "iSCSIMacAddr"
+#string STR_ISCSI_ADD_ATTEMPTS #language en-US "Add Attempts"
+ #language x-UEFI-ns "iSCSIAddAttempts"
+#string STR_ISCSI_DELETE_ATTEMPTS #language en-US "Delete Attempts"
+ #language x-UEFI-ns "iSCSIDeleteAttempts"
+#string STR_ISCSI_DISPLAY_ATTEMPTS #language en-US "Display Attempts"
+ #language x-UEFI-ns "iSCSIDisplayAttemptList"
+#string STR_ISCSI_ATTEMPT_ORDER #language en-US "New Attempt Order"
+ #language x-UEFI-ns "iSCSIAttemptOrder"
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
index db77c0f..2d6d5c8 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
+++ b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
@@ -1,9 +1,9 @@
/** @file
VFR file used by the iSCSI configuration component.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, 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
http://opensource.org/licenses/bsd-license.php
@@ -119,14 +119,14 @@ formset
title = STRING_TOKEN(STR_ISCSI_ATTEMPT_FORM_TITLE);
string varid = ISCSI_CONFIG_IFR_NVDATA.AttemptName,
prompt = STRING_TOKEN(STR_ISCSI_ATTEMPT_NAME),
help = STRING_TOKEN(STR_ISCSI_ATTEMPT_NAME_HELP),
- flags = INTERACTIVE,
+ flags = READ_ONLY,
key = KEY_ATTEMPT_NAME,
minsize = 0,
- maxsize = ATTEMPT_NAME_MAX_SIZE,
+ maxsize = ATTEMPT_NAME_SIZE,
endstring;
subtitle text = STRING_TOKEN(STR_NULL);
oneof varid = ISCSI_CONFIG_IFR_NVDATA.Enabled,
@@ -340,10 +340,52 @@ formset
maxsize = ISCSI_CHAP_SECRET_MAX_LEN,
endstring;
endif;
+ suppressif TRUE;
+
+ string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIMacAddr,
+ prompt = STRING_TOKEN(STR_ISCSI_MAC_PROMPT),
+ help = STRING_TOKEN(STR_ISCSI_MAC_PROMPT),
+ minsize = 0,
+ maxsize = ISCSI_MAX_MAC_STRING_LEN,
+ endstring;
+
+ string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIAttemptOrder,
+ prompt = STRING_TOKEN(STR_ISCSI_ATTEMPT_ORDER),
+ help = STRING_TOKEN(STR_ISCSI_ATTEMPT_ORDER),
+ minsize = 0,
+ maxsize = ATTEMPT_NAME_LIST_SIZE,
+ endstring;
+
+ string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIAddAttemptList,
+ prompt = STRING_TOKEN(STR_ISCSI_ADD_ATTEMPTS),
+ help = STRING_TOKEN(STR_ISCSI_ADD_ATTEMPTS),
+ minsize = 0,
+ maxsize = ATTEMPT_NAME_LIST_SIZE,
+ endstring;
+
+ string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIDeleteAttemptList,
+ prompt = STRING_TOKEN(STR_ISCSI_DELETE_ATTEMPTS),
+ help = STRING_TOKEN(STR_ISCSI_DELETE_ATTEMPTS),
+ minsize = 0,
+ maxsize = ATTEMPT_NAME_LIST_SIZE,
+ endstring;
+
+ string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIDisplayAttemptList,
+ prompt = STRING_TOKEN(STR_ISCSI_DISPLAY_ATTEMPTS),
+ help = STRING_TOKEN(STR_ISCSI_DISPLAY_ATTEMPTS),
+ flags = READ_ONLY,
+ minsize = 0,
+ maxsize = ATTEMPT_NAME_LIST_SIZE,
+ endstring;
+
+ label KEYWORD_ENTRY_LABEL;
+ label LABEL_END;
+ endif;
+
subtitle text = STRING_TOKEN(STR_NULL);
text
help = STRING_TOKEN (STR_SAVE_CHANGES_HELP),
text = STRING_TOKEN (STR_SAVE_CHANGES),
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c
index ac10fa2..a451568 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -351,11 +351,10 @@ IScsiStart (
EFI_HANDLE *HandleBuffer;
UINTN NumberOfHandles;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_GUID *IScsiPrivateGuid;
EFI_GUID *TcpServiceBindingGuid;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
BOOLEAN NeedUpdate;
VOID *Interface;
EFI_GUID *ProtocolGuid;
UINT8 NetworkBootPolicy;
ISCSI_SESSION_CONFIG_NVDATA *NvData;
@@ -671,16 +670,14 @@ IScsiStart (
Session->Private = Private;
Session->ConfigData = AttemptConfigData;
Session->AuthType = AttemptConfigData->AuthenticationType;
- AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, ARRAY_SIZE (MacString));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
- L"%s%d",
- MacString,
+ L"Attempt %d",
(UINTN) AttemptConfigData->AttemptConfigIndex
);
if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
Session->AuthData.CHAP.AuthConfig = &AttemptConfigData->AuthConfigData.CHAP;
@@ -1778,10 +1775,26 @@ IScsiDriverEntryPoint (
if (EFI_ERROR (Status)) {
goto Error4;
}
//
+ // Create the Maxmum Attempts.
+ //
+ Status = IScsiCreateAttempts (PcdGet8 (PcdMaxIScsiAttemptNumber));
+ if (EFI_ERROR (Status)) {
+ goto Error4;
+ }
+
+ //
+ // Creat Keywords for all the Attempts.
+ //
+ Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber));
+ if (EFI_ERROR (Status)) {
+ goto Error4;
+ }
+
+ //
// There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists,
// do not produce the protocol instance.
//
Status = gBS->LocateProtocol (
&gEfiAuthenticationInfoProtocolGuid,
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h b/NetworkPkg/IScsiDxe/IScsiDriver.h
index 9e59b38..1312b54 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.h
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.h
@@ -63,11 +63,10 @@ typedef struct {
UINT8 BootSelectedIndex;
UINT8 AttemptCount;
LIST_ENTRY AttemptConfigs; // User configured Attempt list.
CHAR8 InitiatorName[ISCSI_NAME_MAX_SIZE];
UINTN InitiatorNameLength;
- VOID *NewAttempt; // Attempt is created but not saved.
} ISCSI_PRIVATE_DATA;
extern ISCSI_PRIVATE_DATA *mPrivate;
typedef struct {
diff --git a/NetworkPkg/IScsiDxe/IScsiDxe.inf b/NetworkPkg/IScsiDxe/IScsiDxe.inf
index 8952120..1ec4dfd 100644
--- a/NetworkPkg/IScsiDxe/IScsiDxe.inf
+++ b/NetworkPkg/IScsiDxe/IScsiDxe.inf
@@ -2,11 +2,11 @@
# Client-side iSCSI service.
#
# The iSCSI driver provides iSCSI service in the preboot environment and supports
# booting over iSCSI.
#
-# Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2016, 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
# http://opensource.org/licenses/bsd-license.php
#
@@ -53,11 +53,11 @@
IScsiDriver.c
IScsiDriver.h
IScsiExtScsiPassThru.c
IScsiIbft.c
IScsiIbft.h
- IScsiInitiatorName.c
+ IScsiInitiatorName.c
IScsiImpl.h
IScsiMisc.c
IScsiMisc.h
IScsiProto.c
IScsiProto.h
@@ -78,27 +78,27 @@
NetLib
TcpIoLib
PrintLib
UefiBootServicesTableLib
UefiDriverEntryPoint
- UefiLib
+ UefiLib
UefiRuntimeServicesTableLib
UefiHiiServicesLib
BaseCryptLib
[Protocols]
gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES ## SystemTable
gEfiDriverBindingProtocolGuid ## SOMETIMES_PRODUCES
gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES
gEfiDhcp4ProtocolGuid ## TO_START
- gEfiDhcp6ProtocolGuid ## TO_START
+ gEfiDhcp6ProtocolGuid ## TO_START
gEfiDhcp4ServiceBindingProtocolGuid ## TO_START
- gEfiDhcp6ServiceBindingProtocolGuid ## TO_START
+ gEfiDhcp6ServiceBindingProtocolGuid ## TO_START
gEfiTcp4ProtocolGuid ## TO_START
- gEfiTcp6ProtocolGuid ## TO_START
+ gEfiTcp6ProtocolGuid ## TO_START
gEfiTcp4ServiceBindingProtocolGuid ## TO_START
- gEfiTcp6ServiceBindingProtocolGuid ## TO_START
+ gEfiTcp6ServiceBindingProtocolGuid ## TO_START
gEfiExtScsiPassThruProtocolGuid ## BY_START
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
## TO_START
## PRODUCES
gEfiDevicePathProtocolGuid
@@ -115,20 +115,23 @@
gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## UNDEFINED
gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## SystemTable
gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable
gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable
gEfiAdapterInfoNetworkBootGuid ## SOMETIMES_CONSUMES ## UNDEFINED
-
+
## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder"
## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder"
+ ## SOMETIMES_PRODUCES ## Variable:L"InitiatorAttemptOrder"
+ ## SOMETIMES_CONSUMES ## Variable:L"InitiatorAttemptOrder"
## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch mVendorStorageName
## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVendorStorageName
## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData mVendorStorageName
## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData mVendorStorageName
## SOMETIMES_CONSUMES ## HII
gIScsiConfigGuid
[Pcd]
gEfiNetworkPkgTokenSpaceGuid.PcdIScsiAIPNetworkBootPolicy ## CONSUMES
-
+ gEfiNetworkPkgTokenSpaceGuid.PcdMaxIScsiAttemptNumber ## CONSUMES
+
[UserExtensions.TianoCore."ExtraFiles"]
IScsiDxeExtra.uni
diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiImpl.h
index af46871..4a12b3f 100644
--- a/NetworkPkg/IScsiDxe/IScsiImpl.h
+++ b/NetworkPkg/IScsiDxe/IScsiImpl.h
@@ -48,10 +48,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/DpcLib.h>
#include <Library/NetLib.h>
#include <Library/TcpIoLib.h>
+#include <Library/PcdLib.h>
#include <Library/BaseCryptLib.h>
#include <Guid/MdeModuleHii.h>
#include <Guid/EventGroup.h>
#include <Guid/Acpi.h>
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 11a80f2..eaf6dbe 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -641,21 +641,734 @@ IScsiRemoveNic (
FreePool (AttemptConfigData);
}
}
- //
- // Free attempt is created but not saved to system.
- //
- if (mPrivate->NewAttempt != NULL) {
- FreePool (mPrivate->NewAttempt);
- mPrivate->NewAttempt = NULL;
+ return EFI_SUCCESS;
+}
+
+/**
+ Create and initialize the Attempts.
+
+ @param[in] AttemptNum The number of Attempts will be created.
+
+ @retval EFI_SUCCESS The Attempts have been created successfully.
+ @retval Others Failed to create the Attempt.
+
+**/
+EFI_STATUS
+IScsiCreateAttempts (
+ IN UINTN AttemptNum
+)
+{
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigData;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINT8 *AttemptOrderTmp;
+ UINTN TotalNumber;
+ UINT8 Index;
+ EFI_STATUS Status;
+
+ for (Index = 1; Index <= AttemptNum; Index ++) {
+ //
+ // Get the initialized attempt order.
+ //
+ AttemptConfigOrder = IScsiGetVariableAndSize (
+ L"InitiatorAttemptOrder",
+ &gIScsiConfigGuid,
+ &AttemptConfigOrderSize
+ );
+ TotalNumber = AttemptConfigOrderSize / sizeof (UINT8);
+ if (TotalNumber == AttemptNum) {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ TotalNumber++;
+
+ //
+ // Append the new created attempt to the end.
+ //
+ AttemptOrderTmp = AllocateZeroPool (TotalNumber * sizeof (UINT8));
+ if (AttemptOrderTmp == NULL) {
+ if (AttemptConfigOrder != NULL) {
+ FreePool (AttemptConfigOrder);
+ }
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (AttemptConfigOrder != NULL) {
+ CopyMem (AttemptOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize);
+ FreePool (AttemptConfigOrder);
+ }
+
+ AttemptOrderTmp[TotalNumber - 1] = Index;
+ AttemptConfigOrder = AttemptOrderTmp;
+ AttemptConfigOrderSize = TotalNumber * sizeof (UINT8);
+
+ Status = gRT->SetVariable (
+ L"InitiatorAttemptOrder",
+ &gIScsiConfigGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ AttemptConfigOrderSize,
+ AttemptConfigOrder
+ );
+ FreePool (AttemptConfigOrder);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Create new Attempt
+ //
+ AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA));
+ if (AttemptConfigData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ ConfigData = &AttemptConfigData->SessionConfigData;
+ ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
+ ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
+ ConfigData->ConnectRetryCount = CONNECT_MIN_RETRY;
+
+ AttemptConfigData->AuthenticationType = ISCSI_AUTH_TYPE_CHAP;
+ AttemptConfigData->AuthConfigData.CHAP.CHAPType = ISCSI_CHAP_UNI;
+ //
+ // Configure the Attempt index and set variable.
+ //
+ AttemptConfigData->AttemptConfigIndex = Index;
+
+ //
+ // Set the attempt name according to the order.
+ //
+ UnicodeSPrint (
+ mPrivate->PortString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Attempt %d",
+ (UINTN) AttemptConfigData->AttemptConfigIndex
+ );
+ UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE);
+
+ Status = gRT->SetVariable (
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ ISCSI_CONFIG_VAR_ATTR,
+ sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
+ AttemptConfigData
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
}
return EFI_SUCCESS;
}
+/**
+ Create the iSCSI configuration Keywords for each attempt.
+
+ @param[in] KeywordNum The number Sets of Keywords will be created.
+
+ @retval EFI_SUCCESS The operation is completed.
+ @retval Others Failed to create the Keywords.
+
+**/
+EFI_STATUS
+IScsiCreateKeywords (
+ IN UINTN KeywordNum
+)
+{
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ UINTN Index;
+ EFI_STRING_ID StringToken;
+ CHAR16 StringId[64];
+ CHAR16 KeywordId[32];
+ EFI_STATUS Status;
+
+ Status = IScsiCreateOpCode (
+ KEYWORD_ENTRY_LABEL,
+ &StartOpCodeHandle,
+ &StartLabel,
+ &EndOpCodeHandle,
+ &EndLabel
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (Index = 1; Index <= KeywordNum; Index ++) {
+ //
+ // Create iSCSIAttemptName Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_ATTEMPTT_NAME_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIAttemptName:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ EFI_IFR_FLAG_READ_ONLY,
+ 0,
+ 0,
+ ATTEMPT_NAME_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSIBootEnable Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_MODE_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIBootEnable:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ EFI_IFR_NUMERIC_SIZE_1,
+ 0,
+ 2,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSIIpAddressType Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_IP_MODE_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIIpAddressType:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ EFI_IFR_NUMERIC_SIZE_1,
+ 0,
+ 2,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSIConnectRetry Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CONNECT_RETRY_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIConnectRetry:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ EFI_IFR_NUMERIC_SIZE_1,
+ 0,
+ 16,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSIConnectTimeout Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CONNECT_TIMEOUT_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIConnectTimeout:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ EFI_IFR_NUMERIC_SIZE_2,
+ CONNECT_MIN_TIMEOUT,
+ CONNECT_MAX_TIMEOUT,
+ 0,
+ NULL
+ );
+
+ //
+ // Create ISID Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_ISID_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIISID:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_ISID_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_ISID_VAR_OFFSET + ISID_CONFIGURABLE_STORAGE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ ISID_CONFIGURABLE_MIN_LEN,
+ ISID_CONFIGURABLE_STORAGE,
+ NULL
+ );
+
+ //
+ // Create iSCSIInitiatorInfoViaDHCP Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_VIA_DHCP_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorInfoViaDHCP:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSIInitiatorIpAddress Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_IP_ADDRESS_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorIpAddress:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + IP4_STR_MAX_SIZE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ IP4_MIN_SIZE,
+ IP4_MAX_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSIInitiatorNetmask Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_NET_MASK_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorNetmask:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + IP4_STR_MAX_SIZE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ IP4_MIN_SIZE,
+ IP4_MAX_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSIInitiatorGateway Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_GATE_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorGateway:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + IP4_STR_MAX_SIZE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ IP4_MIN_SIZE,
+ IP4_MAX_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSITargetInfoViaDHCP Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_VIA_DHCP_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetInfoViaDHCP:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSITargetTcpPort Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_TCP_PORT_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetTcpPort:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ EFI_IFR_NUMERIC_SIZE_2,
+ TARGET_PORT_MIN_NUM,
+ TARGET_PORT_MAX_NUM,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSITargetName Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_NAME_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetName:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_TARGET_NAME_VAR_OFFSET + ISCSI_NAME_MAX_SIZE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ ISCSI_NAME_IFR_MIN_SIZE,
+ ISCSI_NAME_IFR_MAX_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSITargetIpAddress Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_IP_ADDRESS_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetIpAddress:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + IP_STR_MAX_SIZE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ IP_MIN_SIZE,
+ IP_MAX_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSILUN Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_LUN_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSILUN:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_LUN_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_LUN_VAR_OFFSET + ISCSI_LUN_STR_MAX_LEN * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ LUN_MIN_SIZE,
+ LUN_MAX_SIZE,
+ NULL
+ );
+
+ //
+ // Create iSCSIAuthenticationMethod Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_AUTHENTICATION_METHOD_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIAuthenticationMethod:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSIChapType Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHARTYPE_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapType:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateNumericOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CHARTYPE_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CHARTYPE_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
+
+ //
+ // Create iSCSIChapUsername Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_USER_NAME_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapUsername:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + ISCSI_CHAP_NAME_STORAGE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ ISCSI_CHAP_NAME_MAX_LEN,
+ NULL
+ );
+
+ //
+ // Create iSCSIChapSecret Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_SECRET_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapSecret:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CHAR_SECRET_VAR_OFFSET + ISCSI_CHAP_SECRET_STORAGE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ ISCSI_CHAP_SECRET_MIN_LEN,
+ ISCSI_CHAP_SECRET_MAX_LEN,
+ NULL
+ );
+
+ //
+ // Create iSCSIReverseChapUsername Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_REVERSE_USER_NAME_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIReverseChapUsername:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + ISCSI_CHAP_NAME_STORAGE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ ISCSI_CHAP_NAME_MAX_LEN,
+ NULL
+ );
+
+ //
+ // Create iSCSIReverseChapSecret Keyword.
+ //
+ UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_REVERSE_SECRET_PROMPT%d", Index);
+ StringToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ StringId,
+ NULL
+ );
+ UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIReverseChapSecret:%d", Index);
+ HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
+ HiiCreateStringOpCode (
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16) (ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + ISCSI_CHAP_SECRET_STORAGE * (Index - 1) * sizeof (CHAR16)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ ISCSI_CHAP_SECRET_MIN_LEN,
+ ISCSI_CHAP_SECRET_MAX_LEN,
+ NULL
+ );
+ }
+
+ Status = HiiUpdateForm (
+ mCallbackInfo->RegisteredHandle, // HII handle
+ &gIScsiConfigGuid, // Formset GUID
+ FORMID_ATTEMPT_FORM, // Form ID
+ StartOpCodeHandle, // Label for where to insert opcodes
+ EndOpCodeHandle // Replace data
+ );
+
+ HiiFreeOpCodeHandle (StartOpCodeHandle);
+ HiiFreeOpCodeHandle (EndOpCodeHandle);
+
+ return Status;
+}
/**
Get the recorded NIC info from global structure by the Index.
@param[in] NicIndex The index indicates the position of NIC info.
@@ -929,10 +1642,11 @@ IScsiDhcpIsConfigured (
EFI_STATUS Status;
EFI_MAC_ADDRESS MacAddr;
UINTN HwAddressSize;
UINT16 VlanId;
CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
@@ -957,12 +1671,11 @@ IScsiDhcpIsConfigured (
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
AttemptName,
(UINTN) 128,
- L"%s%d",
- MacString,
+ L"Attempt %d",
(UINTN) AttemptConfigOrder[Index]
);
Status = GetVariable2 (
AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid,
@@ -983,11 +1696,17 @@ IScsiDhcpIsConfigured (
if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG &&
AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)) {
FreePool (AttemptTmp);
continue;
}
-
+
+ AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
+
+ if (AttemptTmp->Actived == ISCSI_ACTIVE_DISABLED || StrCmp (MacString, AttemptMacString)) {
+ continue;
+ }
+
if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG ||
AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE ||
AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) {
FreePool (AttemptTmp);
FreePool (AttemptConfigOrder);
@@ -1016,10 +1735,11 @@ IScsiGetConfigData (
IN ISCSI_DRIVER_DATA *Private
)
{
EFI_STATUS Status;
CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
UINTN Index;
ISCSI_NIC_INFO *NicInfo;
ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
UINT8 *AttemptConfigOrder;
@@ -1107,16 +1827,14 @@ IScsiGetConfigData (
}
//
// Refresh the state of this attempt to NVR.
//
- AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, ARRAY_SIZE (MacString));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
- L"%s%d",
- MacString,
+ L"Attempt %d",
(UINTN) AttemptTmp->AttemptConfigIndex
);
gRT->SetVariable (
mPrivate->PortString,
@@ -1146,16 +1864,14 @@ IScsiGetConfigData (
}
//
// Refresh the state of this attempt to NVR.
//
- AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, ARRAY_SIZE (MacString));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
- L"%s%d",
- MacString,
+ L"Attempt %d",
(UINTN) AttemptTmp->AttemptConfigIndex
);
gRT->SetVariable (
mPrivate->PortString,
@@ -1179,24 +1895,25 @@ IScsiGetConfigData (
NicInfo = IScsiGetNicInfoByIndex (mPrivate->CurrentNic);
ASSERT (NicInfo != NULL);
IScsiMacAddrToStr (&NicInfo->PermanentAddress, NicInfo->HwAddressSize, NicInfo->VlanId, MacString);
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) 128,
- L"%s%d",
- MacString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Attempt %d",
(UINTN) AttemptConfigOrder[Index]
);
GetVariable2 (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
(VOID**)&AttemptConfigData,
NULL
);
+ AsciiStrToUnicodeStrS (AttemptConfigData->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
- if (AttemptConfigData == NULL) {
+ if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED ||
+ StrCmp (MacString, AttemptMacString)) {
continue;
}
ASSERT (AttemptConfigOrder[Index] == AttemptConfigData->AttemptConfigIndex);
@@ -1237,16 +1954,14 @@ IScsiGetConfigData (
}
//
// Refresh the state of this attempt to NVR.
//
- AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, ARRAY_SIZE (MacString));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
- L"%s%d",
- MacString,
+ L"Attempt %d",
(UINTN) AttemptConfigData->AttemptConfigIndex
);
gRT->SetVariable (
mPrivate->PortString,
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.h
index 912a871..a208a77 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.h
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.h
@@ -237,10 +237,38 @@ EFI_STATUS
IScsiRemoveNic (
IN EFI_HANDLE Controller
);
/**
+ Create and initialize the Attempts.
+
+ @param[in] AttemptNum The number of Attempts will be created.
+
+ @retval EFI_SUCCESS The Attempts have been created successfully.
+ @retval Others Failed to create the Attempt.
+
+**/
+EFI_STATUS
+IScsiCreateAttempts (
+ IN UINTN AttemptNum
+);
+
+/**
+ Create the iSCSI configuration Keywords for each attempt.
+
+ @param[in] KeywordNum The number Sets of Keywords will be created.
+
+ @retval EFI_SUCCESS The operation is completed.
+ @retval Others Failed to create the Keywords.
+
+**/
+EFI_STATUS
+IScsiCreateKeywords (
+ IN UINTN KeywordNum
+);
+
+/**
Get the recorded NIC information from a global structure by the Index.
@param[in] NicIndex The index indicates the position of NIC info.
@return Pointer to the NIC info or NULL if not found.
diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec
index 268188a..f73128f 100644
--- a/NetworkPkg/NetworkPkg.dec
+++ b/NetworkPkg/NetworkPkg.dec
@@ -38,10 +38,15 @@
gIScsiConfigGuid = { 0x4b47d616, 0xa8d6, 0x4552, { 0x9d, 0x44, 0xcc, 0xad, 0x2e, 0xf, 0x4c, 0xf9}}
# Include/Guid/HttpBootConfigHii.h
gHttpBootConfigGuid = { 0x4d20583a, 0x7765, 0x4e7a, { 0x8a, 0x67, 0xdc, 0xde, 0x74, 0xee, 0x3e, 0xc5 }}
+[PcdsFixedAtBuild]
+ ## The max attempt number will be created by iSCSI driver.
+ # @Prompt Max attempt number.
+ gEfiNetworkPkgTokenSpaceGuid.PcdMaxIScsiAttemptNumber|0x08|UINT8|0x0000000D
+
[PcdsFeatureFlag]
## Indicates if the IPsec IKEv2 Certificate Authentication feature is enabled or not.<BR><BR>
# TRUE - Certificate Authentication feature is enabled.<BR>
# FALSE - Does not support Certificate Authentication.<BR>
# @Prompt Enable IPsec IKEv2 Certificate Authentication.
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-11-25 8:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-25 8:11 [patch] NetworkPkg:Add scriptable configuration to iSCSI driver by leveraging x-UEFI Zhang Lubo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox