NetworkPkg:Add scriptable configuration to iSCSI driver by leveraging x-UEFI.

v2:
Add error handling if can not create Attempts in driver entry point.
Since we support to define a macro be a PCD value, we enhance our code
by modifying the structure in IFR_NVDATA. This effect code logic mainly
in Creating Keywords,Convert IFR NvData To AttemptConfigData ByKeyword and
reverse function.
Fix typo errors and sync based on the latest code.

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>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin jiaxin.wu@intel.com
This commit is contained in:
Zhang Lubo 2017-02-17 14:43:41 +08:00 committed by Jiaxin Wu
parent 1d8cebf910
commit 8d1f5e0416
11 changed files with 2438 additions and 271 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
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 - 2017, 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
@ -37,11 +37,55 @@ extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
#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 (Keyword->ISCSIIsId)
#define ATTEMPT_ISID_VAR_OFFSET VAR_OFFSET (Keyword->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 (Keyword->ISCSIInitiatorIpAddress)
#define ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIInitiatorIpAddress)
#define ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID QUESTION_ID (Keyword->ISCSIInitiatorNetmask)
#define ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIInitiatorNetmask)
#define ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID QUESTION_ID (Keyword->ISCSIInitiatorGateway)
#define ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET VAR_OFFSET (Keyword->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 (Keyword->ISCSITargetName)
#define ATTEMPT_TARGET_NAME_VAR_OFFSET VAR_OFFSET (Keyword->ISCSITargetName)
#define ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID QUESTION_ID (Keyword->ISCSITargetIpAddress)
#define ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET VAR_OFFSET (Keyword->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 (Keyword->ISCSILun)
#define ATTEMPT_LUN_VAR_OFFSET VAR_OFFSET (Keyword->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 (Keyword->ISCSIChapUsername)
#define ATTEMPT_CHAR_USER_NAME_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIChapUsername)
#define ATTEMPT_CHAR_SECRET_QUESTION_ID QUESTION_ID (Keyword->ISCSIChapSecret)
#define ATTEMPT_CHAR_SECRET_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIChapSecret)
#define ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID QUESTION_ID (Keyword->ISCSIReverseChapUsername)
#define ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapUsername)
#define ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID QUESTION_ID (Keyword->ISCSIReverseChapSecret)
#define ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapSecret)
#define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME"
@ -68,7 +112,7 @@ struct _ISCSI_ATTEMPT_CONFIG_NVDATA {
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;
@ -79,6 +123,7 @@ struct _ISCSI_ATTEMPT_CONFIG_NVDATA {
ISCSI_CHAP_AUTH_CONFIG_NVDATA CHAP;
} AuthConfigData;
BOOLEAN AutoConfigureSuccess;
UINT8 Actived;
};
///
@ -101,6 +146,31 @@ struct _ISCSI_FORM_CALLBACK_INFO {
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.

View File

@ -26,12 +26,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define FORMID_ORDER_FORM 4
#define FORMID_DELETE_FORM 5
#define ISCSI_MAX_ATTEMPTS_NUM FixedPcdGet8 (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
@ -40,7 +42,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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
@ -67,6 +70,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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
@ -112,17 +116,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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
@ -135,6 +140,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define ISID_CONFIGURABLE_MAX_LEN 12
#define ISID_CONFIGURABLE_STORAGE 13
//
// sizeof (EFI_MAC_ADDRESS) * 3
//
#define ISCSI_MAX_MAC_STRING_LEN 96
///
/// Macro used for target Url.
///
@ -142,10 +152,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define ISCSI_TARGET_URI_MAX_SIZE 255
#pragma pack(1)
//
// Used by keyword.
//
typedef struct {
CHAR16 ISCSIIsId[ISID_CONFIGURABLE_STORAGE];
CHAR16 ISCSIInitiatorIpAddress[IP4_STR_MAX_SIZE];
CHAR16 ISCSIInitiatorNetmask[IP4_STR_MAX_SIZE];
CHAR16 ISCSIInitiatorGateway[IP4_STR_MAX_SIZE];
CHAR16 ISCSITargetName[ISCSI_NAME_MAX_SIZE];
CHAR16 ISCSITargetIpAddress[IP_STR_MAX_SIZE];
CHAR16 ISCSILun[ISCSI_LUN_STR_MAX_LEN];
CHAR16 ISCSIChapUsername[ISCSI_CHAP_NAME_STORAGE];
CHAR16 ISCSIChapSecret[ISCSI_CHAP_SECRET_STORAGE];
CHAR16 ISCSIReverseChapUsername[ISCSI_CHAP_NAME_STORAGE];
CHAR16 ISCSIReverseChapSecret[ISCSI_CHAP_SECRET_STORAGE];
} KEYWORD_STR;
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;
@ -183,8 +210,28 @@ typedef struct _ISCSI_CONFIG_IFR_NVDATA {
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];
UINT8 ISCSITargetInfoViaDHCP[ISCSI_MAX_ATTEMPTS_NUM];
UINT16 ISCSITargetTcpPort[ISCSI_MAX_ATTEMPTS_NUM];
UINT8 ISCSIAuthenticationMethod[ISCSI_MAX_ATTEMPTS_NUM];
UINT8 ISCSIChapType[ISCSI_MAX_ATTEMPTS_NUM];
KEYWORD_STR Keyword[ISCSI_MAX_ATTEMPTS_NUM];
} ISCSI_CONFIG_IFR_NVDATA;
#pragma pack()

View File

@ -12,24 +12,26 @@
// 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."
@ -68,7 +70,7 @@
#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"
@ -83,9 +85,17 @@
#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."
#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"

View File

@ -121,10 +121,10 @@ formset
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);
@ -342,6 +342,48 @@ formset
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

View File

@ -373,7 +373,6 @@ IScsiStart (
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;
@ -697,12 +696,10 @@ IScsiStart (
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
);
@ -1803,6 +1800,22 @@ IScsiDriverEntryPoint (
goto Error4;
}
//
// Create the Maximum Attempts.
//
Status = IScsiCreateAttempts (PcdGet8 (PcdMaxIScsiAttemptNumber));
if (EFI_ERROR (Status)) {
goto Error5;
}
//
// Create Keywords for all the Attempts.
//
Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber));
if (EFI_ERROR (Status)) {
goto Error5;
}
//
// There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists,
// do not produce the protocol instance.
@ -1820,15 +1833,18 @@ IScsiDriverEntryPoint (
&gIScsiAuthenticationInfo
);
if (EFI_ERROR (Status)) {
goto Error5;
goto Error6;
}
}
return EFI_SUCCESS;
Error5:
Error6:
IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
Error5:
IScsiCleanAttemptVariable ();
Error4:
FreePool (mPrivate);

View File

@ -1,7 +1,7 @@
/** @file
The header file of IScsiDriver.c.
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
@ -68,7 +68,6 @@ typedef struct {
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;

View File

@ -128,6 +128,8 @@
## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder"
## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder"
## SOMETIMES_PRODUCES ## Variable:L"InitialAttemptOrder"
## SOMETIMES_CONSUMES ## Variable:L"InitialAttemptOrder"
## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch mVendorStorageName
## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVendorStorageName
## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData mVendorStorageName
@ -137,6 +139,7 @@
[Pcd]
gEfiNetworkPkgTokenSpaceGuid.PcdIScsiAIPNetworkBootPolicy ## CONSUMES
gEfiNetworkPkgTokenSpaceGuid.PcdMaxIScsiAttemptNumber ## CONSUMES
[UserExtensions.TianoCore."ExtraFiles"]
IScsiDxeExtra.uni

View File

@ -643,17 +643,787 @@ IScsiRemoveNic (
}
}
//
// 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. This is used to essure creating attempts by order.
//
AttemptConfigOrder = IScsiGetVariableAndSize (
L"InitialAttemptOrder",
&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"InitialAttemptOrder",
&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
);
FreePool (AttemptConfigData);
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
}
/**
Create the iSCSI configuration Keywords for each attempt. You can find the keywords
defined in the "x-UEFI-ns" namespace (http://www.uefi.org/confignamespace).
@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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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 + sizeof (KEYWORD_STR) * (Index - 1)),
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;
}
/**
Free the attempt configure data variable.
**/
VOID
IScsiCleanAttemptVariable (
IN VOID
)
{
ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
UINT8 *AttemptConfigOrder;
UINTN AttemptConfigOrderSize;
UINTN Index;
//
// Get the initialized attempt order.
//
AttemptConfigOrder = IScsiGetVariableAndSize (
L"InitialAttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
return;
}
for (Index = 1; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
Index
);
GetVariable2 (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
(VOID**)&AttemptConfigData,
NULL
);
if (AttemptConfigData != NULL) {
gRT->SetVariable (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
0,
0,
NULL
);
}
}
return;
}
/**
Get the recorded NIC info from global structure by the Index.
@ -931,6 +1701,7 @@ IScsiDhcpIsConfigured (
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 (
@ -959,8 +1730,7 @@ IScsiDhcpIsConfigured (
UnicodeSPrint (
AttemptName,
(UINTN) 128,
L"%s%d",
MacString,
L"Attempt %d",
(UINTN) AttemptConfigOrder[Index]
);
Status = GetVariable2 (
@ -985,7 +1755,13 @@ IScsiDhcpIsConfigured (
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) {
@ -1106,6 +1882,7 @@ IScsiGetConfigData (
{
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;
@ -1197,12 +1974,10 @@ 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
);
@ -1236,12 +2011,10 @@ 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
);
@ -1269,9 +2042,8 @@ IScsiGetConfigData (
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]
);
@ -1281,8 +2053,10 @@ IScsiGetConfigData (
(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;
}
@ -1327,12 +2101,10 @@ 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
);

View File

@ -243,6 +243,44 @@ 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
);
/**
Free the attempt configure data variable.
**/
VOID
IScsiCleanAttemptVariable (
IN VOID
);
/**
Get the recorded NIC information from a global structure by the Index.

View File

@ -45,7 +45,11 @@
# Include/Guid/TlsAuthentication.h
gEfiTlsCaCertificateGuid = { 0xfd2340D0, 0x3dab, 0x4349, { 0xa6, 0xc7, 0x3b, 0x4f, 0x12, 0xb4, 0x8e, 0xae }}
[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>