AsciiStrToUnicodeStr (Attempt->AttemptName, IfrNvData->AttemptName);\r
}\r
\r
-\r
/**\r
Convert the IFR data to iSCSI configuration data.\r
\r
- @param[in] IfrNvData The IFR nv data.\r
+ @param[in] IfrNvData Point to ISCSI_CONFIG_IFR_NVDATA.\r
@param[in, out] Attempt The iSCSI attempt config data.\r
\r
@retval EFI_INVALID_PARAMETER Any input or configured parameter is invalid.\r
@retval EFI_NOT_FOUND Cannot find the corresponding variable.\r
+ @retval EFI_OUT_OF_RESOURCES The operation is failed due to lack of resources.\r
+ @retval EFI_ABORTED The operation is aborted.\r
@retval EFI_SUCCESS The operation is completed successfully.\r
\r
**/\r
CHAR16 IpMode[64];\r
ISCSI_NIC_INFO *NicInfo;\r
EFI_INPUT_KEY Key;\r
+ UINT8 *AttemptConfigOrder;\r
+ UINTN AttemptConfigOrderSize;\r
+ UINT8 *AttemptOrderTmp;\r
+ UINTN TotalNumber;\r
+ EFI_STATUS Status;\r
\r
if (IfrNvData == NULL || Attempt == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r
\r
+ //\r
+ // Update the iSCSI Mode data and record it in attempt help info.\r
+ //\r
+ Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;\r
+ if (IfrNvData->Enabled == ISCSI_DISABLED) {\r
+ UnicodeSPrint (IScsiMode, 64, L"Disabled");\r
+ } else if (IfrNvData->Enabled == ISCSI_ENABLED) {\r
+ UnicodeSPrint (IScsiMode, 64, L"Enabled");\r
+ } else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {\r
+ UnicodeSPrint (IScsiMode, 64, L"Enabled for MPIO");\r
+ }\r
+\r
+ if (IfrNvData->IpMode == IP_MODE_IP4) {\r
+ UnicodeSPrint (IpMode, 64, L"IP4");\r
+ } else if (IfrNvData->IpMode == IP_MODE_IP6) {\r
+ UnicodeSPrint (IpMode, 64, L"IP6");\r
+ } else if (IfrNvData->IpMode == IP_MODE_AUTOCONFIG) {\r
+ UnicodeSPrint (IpMode, 64, L"Autoconfigure");\r
+ }\r
+\r
+ NicInfo = IScsiGetNicInfoByIndex (Attempt->NicIndex);\r
+ if (NicInfo == NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ MacString = (CHAR16 *) AllocateZeroPool (ISCSI_MAX_MAC_STRING_LEN * sizeof (CHAR16));\r
+ if (MacString == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ AsciiStrToUnicodeStr (Attempt->MacString, MacString);\r
+\r
+ UnicodeSPrint (\r
+ mPrivate->PortString,\r
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,\r
+ L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s",\r
+ MacString,\r
+ NicInfo->BusNumber,\r
+ NicInfo->DeviceNumber,\r
+ NicInfo->FunctionNumber,\r
+ IScsiMode,\r
+ IpMode\r
+ );\r
+\r
+ Attempt->AttemptTitleHelpToken = HiiSetString (\r
+ mCallbackInfo->RegisteredHandle,\r
+ Attempt->AttemptTitleHelpToken,\r
+ mPrivate->PortString,\r
+ NULL\r
+ );\r
+ if (Attempt->AttemptTitleHelpToken == 0) {\r
+ FreePool (MacString);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
//\r
// Check whether this attempt is an existing one.\r
//\r
}\r
}\r
\r
- } else if (ExistAttempt == NULL && IfrNvData->Enabled != ISCSI_DISABLED) {\r
+ } else if (ExistAttempt == NULL) {\r
+ //\r
+ // When a new attempt is created, pointer of the attempt is saved to\r
+ // mPrivate->NewAttempt, and also saved to mCallbackInfo->Current in\r
+ // IScsiConfigProcessDefault. If input Attempt does not match any existing\r
+ // attempt, it should be a new created attempt. Save it to system now.\r
+ // \r
+ ASSERT (Attempt == mPrivate->NewAttempt);\r
+\r
+ //\r
+ // Save current order number for this attempt.\r
+ //\r
+ AttemptConfigOrder = IScsiGetVariableAndSize (\r
+ L"AttemptOrder",\r
+ &mVendorGuid,\r
+ &AttemptConfigOrderSize\r
+ );\r
+\r
+ TotalNumber = AttemptConfigOrderSize / sizeof (UINT8);\r
+ TotalNumber++;\r
+\r
+ //\r
+ // Append the new created attempt order to the end.\r
+ //\r
+ AttemptOrderTmp = AllocateZeroPool (TotalNumber * sizeof (UINT8));\r
+ if (AttemptOrderTmp == NULL) {\r
+ if (AttemptConfigOrder != NULL) {\r
+ FreePool (AttemptConfigOrder);\r
+ }\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ if (AttemptConfigOrder != NULL) {\r
+ CopyMem (AttemptOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize);\r
+ FreePool (AttemptConfigOrder);\r
+ }\r
+\r
+ AttemptOrderTmp[TotalNumber - 1] = Attempt->AttemptConfigIndex;\r
+ AttemptConfigOrder = AttemptOrderTmp;\r
+ AttemptConfigOrderSize = TotalNumber * sizeof (UINT8);\r
+\r
+ Status = gRT->SetVariable (\r
+ L"AttemptOrder",\r
+ &mVendorGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ AttemptConfigOrderSize,\r
+ AttemptConfigOrder\r
+ );\r
+ FreePool (AttemptConfigOrder);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Insert new created attempt to array.\r
+ //\r
+ InsertTailList (&mPrivate->AttemptConfigs, &Attempt->Link);\r
+ mPrivate->AttemptCount++;\r
+ //\r
+ // Reset mPrivate->NewAttempt to NULL, which indicates none attempt is created\r
+ // but not saved now.\r
+ //\r
+ mPrivate->NewAttempt = NULL;\r
+\r
if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {\r
//\r
// This new Attempt is enabled for MPIO; enable the multipath mode.\r
} else if (IfrNvData->Enabled == ISCSI_ENABLED) {\r
mPrivate->SinglePathCount++;\r
}\r
- }\r
-\r
- //\r
- // Update the iSCSI Mode data and record it in attempt help info.\r
- //\r
- Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;\r
- if (IfrNvData->Enabled == ISCSI_DISABLED) {\r
- UnicodeSPrint (IScsiMode, 64, L"Disabled");\r
- } else if (IfrNvData->Enabled == ISCSI_ENABLED) {\r
- UnicodeSPrint (IScsiMode, 64, L"Enabled");\r
- } else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {\r
- UnicodeSPrint (IScsiMode, 64, L"Enabled for MPIO");\r
- }\r
\r
- if (IfrNvData->IpMode == IP_MODE_IP4) {\r
- UnicodeSPrint (IpMode, 64, L"IP4");\r
- } else if (IfrNvData->IpMode == IP_MODE_IP6) {\r
- UnicodeSPrint (IpMode, 64, L"IP6");\r
- } else if (IfrNvData->IpMode == IP_MODE_AUTOCONFIG) {\r
- UnicodeSPrint (IpMode, 64, L"Autoconfigure");\r
- }\r
-\r
- NicInfo = IScsiGetNicInfoByIndex (Attempt->NicIndex);\r
- if (NicInfo == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- MacString = (CHAR16 *) AllocateZeroPool (ISCSI_MAX_MAC_STRING_LEN * sizeof (CHAR16));\r
- if (MacString == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- AsciiStrToUnicodeStr (Attempt->MacString, MacString);\r
-\r
- UnicodeSPrint (\r
- mPrivate->PortString,\r
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,\r
- L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s",\r
- MacString,\r
- NicInfo->BusNumber,\r
- NicInfo->DeviceNumber,\r
- NicInfo->FunctionNumber,\r
- IScsiMode,\r
- IpMode\r
- );\r
-\r
- Attempt->AttemptTitleHelpToken = HiiSetString (\r
- mCallbackInfo->RegisteredHandle,\r
- Attempt->AttemptTitleHelpToken,\r
- mPrivate->PortString,\r
- NULL\r
- );\r
- if (Attempt->AttemptTitleHelpToken == 0) {\r
- FreePool (MacString);\r
- return EFI_OUT_OF_RESOURCES;\r
+ IScsiConfigUpdateAttempt ();\r
}\r
\r
//\r
MacString\r
);\r
\r
- UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Port %s", MacString);\r
+ UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"MAC %s", MacString);\r
PortTitleToken = HiiSetString (\r
mCallbackInfo->RegisteredHandle,\r
0,\r
\r
AttemptNewOrder = AllocateZeroPool (AttemptConfigOrderSize);\r
if (AttemptNewOrder == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
}\r
\r
Total = AttemptConfigOrderSize / sizeof (UINT8);\r
);\r
\r
Error:\r
- FreePool (AttemptConfigOrder);\r
- FreePool (AttemptNewOrder);\r
+ if (AttemptConfigOrder != NULL) {\r
+ FreePool (AttemptConfigOrder);\r
+ }\r
+\r
+ if (AttemptNewOrder != NULL) {\r
+ FreePool (AttemptNewOrder);\r
+ }\r
\r
return Status;\r
}\r
UINT8 *AttemptConfigOrder;\r
UINTN AttemptConfigOrderSize;\r
UINTN TotalNumber;\r
- UINT8 *AttemptOrderTmp;\r
UINTN Index;\r
- EFI_STATUS Status;\r
\r
+ //\r
+ // Free any attempt that is previously created but not saved to system.\r
+ //\r
+ if (mPrivate->NewAttempt != NULL) {\r
+ FreePool (mPrivate->NewAttempt);\r
+ mPrivate->NewAttempt = NULL;\r
+ }\r
+\r
+ //\r
+ // Is User creating a new attempt?\r
+ //\r
NewAttempt = FALSE;\r
\r
if ((KeyValue >= KEY_MAC_ENTRY_BASE) &&\r
}\r
\r
//\r
- // Create the new attempt and save to NVR.\r
+ // Create new attempt.\r
//\r
\r
AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA));\r
TotalNumber++;\r
\r
//\r
- // Append the new created attempt order to the end.\r
+ // Record the mapping between attempt order and attempt's configdata.\r
//\r
- AttemptOrderTmp = AllocateZeroPool (TotalNumber * sizeof (UINT8));\r
- if (AttemptOrderTmp == NULL) {\r
- FreePool (AttemptConfigData);\r
- if (AttemptConfigOrder != NULL) {\r
- FreePool (AttemptConfigOrder);\r
- }\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ AttemptConfigData->AttemptConfigIndex = CurrentAttemptConfigIndex;\r
\r
if (AttemptConfigOrder != NULL) {\r
- CopyMem (AttemptOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize);\r
- FreePool (AttemptConfigOrder); \r
- }\r
-\r
- AttemptOrderTmp[TotalNumber - 1] = CurrentAttemptConfigIndex; \r
- AttemptConfigOrder = AttemptOrderTmp;\r
- AttemptConfigOrderSize = TotalNumber * sizeof (UINT8);\r
-\r
- Status = gRT->SetVariable (\r
- L"AttemptOrder",\r
- &mVendorGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- AttemptConfigOrderSize,\r
- AttemptConfigOrder\r
- );\r
- FreePool (AttemptConfigOrder);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (AttemptConfigData);\r
- return Status;\r
+ FreePool (AttemptConfigOrder);\r
}\r
\r
- //\r
- // Record the mapping between attempt order and attempt's configdata.\r
- //\r
- AttemptConfigData->AttemptConfigIndex = CurrentAttemptConfigIndex;\r
- InsertTailList (&mPrivate->AttemptConfigs, &AttemptConfigData->Link);\r
- mPrivate->AttemptCount++;\r
-\r
//\r
// Record the MAC info in Config Data.\r
//\r
);\r
UnicodeStrToAsciiStr (mPrivate->PortString, AttemptConfigData->AttemptName);\r
\r
+ //\r
+ // Save the created Attempt temporarily. If user does not save the attempt\r
+ // by press 'KEY_SAVE_ATTEMPT_CONFIG' later, iSCSI driver would know that\r
+ // and free resources.\r
+ //\r
+ mPrivate->NewAttempt = (VOID *) AttemptConfigData;\r
+\r
} else {\r
//\r
// Determine which Attempt user has selected to configure.\r
\r
IScsiConvertAttemptConfigDataToIfrNvData (AttemptConfigData, IfrNvData);\r
\r
+ //\r
+ // Update current attempt to be a new created attempt or an existing attempt.\r
+ //\r
mCallbackInfo->Current = AttemptConfigData;\r
\r
- IScsiConfigUpdateAttempt ();\r
-\r
return EFI_SUCCESS;\r
}\r
\r
\r
ASSERT (mPrivate->NicCount == 0);\r
\r
+ //\r
+ // Free attempt is created but not saved to system.\r
+ //\r
+ if (mPrivate->NewAttempt != NULL) {\r
+ FreePool (mPrivate->NewAttempt);\r
+ }\r
+\r
FreePool (mPrivate);\r
mPrivate = NULL;\r
\r
\r
endif;\r
\r
- suppressif NOT ideqval ISCSI_CONFIG_IFR_NVDATA.AuthenticationType == ISCSI_AUTH_TYPE_KRB;\r
-\r
- checkbox varid = ISCSI_CONFIG_IFR_NVDATA.MutualRequired,\r
- prompt = STRING_TOKEN(STR_ISCSI_MUTUAL_REQUIRED),\r
- help = STRING_TOKEN(STR_ISCSI_MUTUAL_REQUIRED_HELP),\r
- flags = 0,\r
- endcheckbox;\r
- \r
- string varid = ISCSI_CONFIG_IFR_NVDATA.KerberosUserName,\r
- prompt = STRING_TOKEN(STR_ISCSI_KERBEROS_USER_NAME),\r
- help = STRING_TOKEN(STR_ISCSI_KERBEROS_USER_NAME),\r
- flags = INTERACTIVE,\r
- key = KEY_KERBEROS_USER_NAME,\r
- minsize = 0,\r
- maxsize = KERBEROS_NAME_MAX_LEN,\r
- endstring;\r
-\r
- string varid = ISCSI_CONFIG_IFR_NVDATA.KerberosUserSecret,\r
- prompt = STRING_TOKEN(STR_ISCSI_KERBEROS_USER_SECRET),\r
- help = STRING_TOKEN(STR_ISCSI_KERBEROS_USER_SECRET),\r
- flags = INTERACTIVE,\r
- key = KEY_KERBEROS_USER_SECRET,\r
- minsize = KERBEROS_SECRET_MIN_LEN,\r
- maxsize = KERBEROS_SECRET_MAX_LEN,\r
- endstring;\r
- \r
- string varid = ISCSI_CONFIG_IFR_NVDATA.KerberosKDCName,\r
- prompt = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_NAME),\r
- help = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_NAME),\r
- flags = INTERACTIVE,\r
- key = KEY_KERBEROS_KDC_NAME,\r
- minsize = 0,\r
- maxsize = KERBEROS_NAME_MAX_LEN,\r
- endstring;\r
-\r
- string varid = ISCSI_CONFIG_IFR_NVDATA.KerberosKDCRealm,\r
- prompt = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_REALM),\r
- help = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_REALM),\r
- flags = INTERACTIVE,\r
- key = KEY_KERBEROS_KDC_REALM,\r
- minsize = 0,\r
- maxsize = KERBEROS_NAME_MAX_LEN,\r
- endstring;\r
-\r
- string varid = ISCSI_CONFIG_IFR_NVDATA.KerberosKDCIp,\r
- prompt = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_IP),\r
- help = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_IP),\r
- flags = INTERACTIVE,\r
- key = KEY_KERBEROS_KDC_IP_ADDR,\r
- minsize = IP_MIN_SIZE,\r
- maxsize = IP_MAX_SIZE,\r
- endstring;\r
-\r
- numeric varid = ISCSI_CONFIG_IFR_NVDATA.KerberosKDCPort,\r
- prompt = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_PORT),\r
- help = STRING_TOKEN(STR_ISCSI_KERBEROS_KDC_PORT),\r
- flags = 0,\r
- minimum = KERBEROS_KDC_PORT_MIN_NUM,\r
- maximum = KERBEROS_KDC_PORT_MAX_NUM,\r
- step = 0,\r
- endnumeric;\r
- \r
- endif;\r
-\r
subtitle text = STRING_TOKEN(STR_NULL);\r
\r
goto FORMID_ATTEMPT_FORM,\r
prompt = STRING_TOKEN (STR_SAVE_CHANGES),\r
- help = STRING_TOKEN (STR_SAVE_CHANGES),\r
+ help = STRING_TOKEN (STR_SAVE_CHANGES_HELP),\r
flags = INTERACTIVE,\r
key = KEY_SAVE_ATTEMPT_CONFIG;\r
\r