diff options
Diffstat (limited to 'NetworkPkg/IScsiDxe')
24 files changed, 3394 insertions, 3366 deletions
diff --git a/NetworkPkg/IScsiDxe/ComponentName.c b/NetworkPkg/IScsiDxe/ComponentName.c index 8572ac281d..2e1324c569 100644 --- a/NetworkPkg/IScsiDxe/ComponentName.c +++ b/NetworkPkg/IScsiDxe/ComponentName.c @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// EFI Component Name Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName = {
IScsiComponentNameGetDriverName,
IScsiComponentNameGetControllerName,
"eng"
@@ -20,13 +20,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName = //
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IScsiComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IScsiComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)IScsiComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)IScsiComponentNameGetControllerName,
"en"
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable[] = {
{
"eng;en",
L"iSCSI Driver"
@@ -81,9 +81,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gIScsiControllerNameTab EFI_STATUS
EFIAPI
IScsiComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -91,7 +91,7 @@ IScsiComponentNameGetDriverName ( This->SupportedLanguages,
mIScsiDriverNameTable,
DriverName,
- (BOOLEAN) (This == &gIScsiComponentName)
+ (BOOLEAN)(This == &gIScsiComponentName)
);
}
@@ -108,14 +108,14 @@ IScsiComponentNameGetDriverName ( **/
EFI_STATUS
UpdateName (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru,
- IN BOOLEAN Ipv6Flag
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru,
+ IN BOOLEAN Ipv6Flag
)
{
- EFI_STATUS Status;
- CHAR16 HandleName[80];
- ISCSI_DRIVER_DATA *Private;
- UINT8 NicIndex;
+ EFI_STATUS Status;
+ CHAR16 HandleName[80];
+ ISCSI_DRIVER_DATA *Private;
+ UINT8 NicIndex;
if (IScsiExtScsiPassThru == NULL) {
return EFI_INVALID_PARAMETER;
@@ -130,7 +130,7 @@ UpdateName ( L"iSCSI (%s, NicIndex=%d)",
Ipv6Flag ? L"IPv6" : L"IPv4",
NicIndex
- );
+ );
if (gIScsiControllerNameTable != NULL) {
FreeUnicodeStringTable (gIScsiControllerNameTable);
@@ -228,21 +228,21 @@ UpdateName ( EFI_STATUS
EFIAPI
IScsiComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- EFI_HANDLE IScsiController;
- BOOLEAN Ipv6Flag;
- EFI_GUID *IScsiPrivateGuid;
- ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
+ EFI_HANDLE IScsiController;
+ BOOLEAN Ipv6Flag;
+ EFI_GUID *IScsiPrivateGuid;
+ ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru;
if (ControllerHandle == NULL) {
return EFI_UNSUPPORTED;
@@ -254,12 +254,12 @@ IScsiComponentNameGetControllerName ( IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
if (IScsiController != NULL) {
IScsiPrivateGuid = &gIScsiV4PrivateGuid;
- Ipv6Flag = FALSE;
+ Ipv6Flag = FALSE;
} else {
IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);
if (IScsiController != NULL) {
IScsiPrivateGuid = &gIScsiV6PrivateGuid;
- Ipv6Flag = TRUE;
+ Ipv6Flag = TRUE;
} else {
return EFI_UNSUPPORTED;
}
@@ -268,7 +268,7 @@ IScsiComponentNameGetControllerName ( Status = gBS->OpenProtocol (
IScsiController,
IScsiPrivateGuid,
- (VOID **) &IScsiIdentifier,
+ (VOID **)&IScsiIdentifier,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -277,8 +277,8 @@ IScsiComponentNameGetControllerName ( return Status;
}
- if(ChildHandle != NULL) {
- if(!Ipv6Flag) {
+ if (ChildHandle != NULL) {
+ if (!Ipv6Flag) {
//
// Make sure this driver produced ChildHandle
//
@@ -310,7 +310,7 @@ IScsiComponentNameGetControllerName ( Status = gBS->OpenProtocol (
ChildHandle,
&gEfiExtScsiPassThruProtocolGuid,
- (VOID **)&IScsiExtScsiPassThru,
+ (VOID **)&IScsiExtScsiPassThru,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
diff --git a/NetworkPkg/IScsiDxe/IScsiAuthenticationInfo.c b/NetworkPkg/IScsiDxe/IScsiAuthenticationInfo.c index aeff646156..de62ae8dbd 100644 --- a/NetworkPkg/IScsiDxe/IScsiAuthenticationInfo.c +++ b/NetworkPkg/IScsiDxe/IScsiAuthenticationInfo.c @@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-EFI_AUTHENTICATION_INFO_PROTOCOL gIScsiAuthenticationInfo = {
+EFI_AUTHENTICATION_INFO_PROTOCOL gIScsiAuthenticationInfo = {
IScsiGetAuthenticationInfo,
IScsiSetAuthenticationInfo
};
@@ -30,9 +30,9 @@ EFI_AUTHENTICATION_INFO_PROTOCOL gIScsiAuthenticationInfo = { EFI_STATUS
EFIAPI
IScsiGetAuthenticationInfo (
- IN EFI_AUTHENTICATION_INFO_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- OUT VOID **Buffer
+ IN EFI_AUTHENTICATION_INFO_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ OUT VOID **Buffer
)
{
return EFI_DEVICE_ERROR;
diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.c b/NetworkPkg/IScsiDxe/IScsiCHAP.c index 0491ef42db..b507f11cd4 100644 --- a/NetworkPkg/IScsiDxe/IScsiCHAP.c +++ b/NetworkPkg/IScsiDxe/IScsiCHAP.c @@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // macros. CHAP_HASH structures at lower subscripts in the array are preferred
// by the initiator.
//
-STATIC CONST CHAP_HASH mChapHash[] = {
+STATIC CONST CHAP_HASH mChapHash[] = {
{
ISCSI_CHAP_ALGORITHM_SHA256,
SHA256_DIGEST_SIZE,
@@ -23,7 +23,7 @@ STATIC CONST CHAP_HASH mChapHash[] = { Sha256Update,
Sha256Final
},
-#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
+ #ifdef ENABLE_MD5_DEPRECATED_INTERFACES
//
// Keep the deprecated MD5 entry at the end of the array (making MD5 the
// least preferred choice of the initiator).
@@ -36,7 +36,7 @@ STATIC CONST CHAP_HASH mChapHash[] = { Md5Update,
Md5Final
},
-#endif // ENABLE_MD5_DEPRECATED_INTERFACES
+ #endif // ENABLE_MD5_DEPRECATED_INTERFACES
};
//
@@ -44,17 +44,17 @@ STATIC CONST CHAP_HASH mChapHash[] = { // CHAP_A=<A1,A2...> value string, by the IScsiCHAPInitHashList() function. It
// is sent by the initiator in ISCSI_CHAP_STEP_ONE.
//
-STATIC CHAR8 mChapHashListString[
- 3 + // UINT8 identifier in
- // decimal
- (1 + 3) * (ARRAY_SIZE (mChapHash) - 1) + // comma prepended for
- // entries after the
- // first
- 1 + // extra character for
- // AsciiSPrint()
- // truncation check
- 1 // terminating NUL
- ];
+STATIC CHAR8 mChapHashListString[
+ 3 + // UINT8 identifier in
+ // decimal
+ (1 + 3) * (ARRAY_SIZE (mChapHash) - 1) + // comma prepended for
+ // entries after the
+ // first
+ 1 + // extra character for
+ // AsciiSPrint()
+ // truncation check
+ 1 // terminating NUL
+];
/**
Initiator calculates its own expected hash value.
@@ -82,13 +82,13 @@ STATIC CHAR8 mChapHashListString[ **/
EFI_STATUS
IScsiCHAPCalculateResponse (
- IN UINT32 ChapIdentifier,
- IN CHAR8 *ChapSecret,
- IN UINT32 SecretLength,
- IN UINT8 *ChapChallenge,
- IN UINT32 ChallengeLength,
- IN CONST CHAP_HASH *Hash,
- OUT UINT8 *ChapResponse
+ IN UINT32 ChapIdentifier,
+ IN CHAR8 *ChapSecret,
+ IN UINT32 SecretLength,
+ IN UINT8 *ChapChallenge,
+ IN UINT32 ChallengeLength,
+ IN CONST CHAP_HASH *Hash,
+ OUT UINT8 *ChapResponse
)
{
UINTN ContextSize;
@@ -103,7 +103,7 @@ IScsiCHAPCalculateResponse ( ASSERT (Hash != NULL);
ContextSize = Hash->GetContextSize ();
- Ctx = AllocatePool (ContextSize);
+ Ctx = AllocatePool (ContextSize);
if (Ctx == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -117,7 +117,7 @@ IScsiCHAPCalculateResponse ( //
// Hash Identifier - Only calculate 1 byte data (RFC1994)
//
- IdByte[0] = (CHAR8) ChapIdentifier;
+ IdByte[0] = (CHAR8)ChapIdentifier;
if (!Hash->Update (Ctx, IdByte, 1)) {
goto Exit;
}
@@ -170,9 +170,9 @@ IScsiCHAPAuthTarget ( UINT8 VerifyRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
INTN Mismatch;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
+ SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
ASSERT (AuthData->Hash != NULL);
@@ -198,7 +198,6 @@ IScsiCHAPAuthTarget ( return Status;
}
-
/**
This function checks the received iSCSI Login Response during the security
negotiation stage.
@@ -216,33 +215,34 @@ IScsiCHAPOnRspReceived ( IN ISCSI_CONNECTION *Conn
)
{
- EFI_STATUS Status;
- ISCSI_SESSION *Session;
- ISCSI_CHAP_AUTH_DATA *AuthData;
- CHAR8 *Value;
- UINT8 *Data;
- UINT32 Len;
- LIST_ENTRY *KeyValueList;
- UINTN Algorithm;
- CHAR8 *Identifier;
- CHAR8 *Challenge;
- CHAR8 *Name;
- CHAR8 *Response;
- UINT8 TargetRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
- UINT32 RspLen;
- UINTN Result;
- UINTN HashIndex;
+ EFI_STATUS Status;
+ ISCSI_SESSION *Session;
+ ISCSI_CHAP_AUTH_DATA *AuthData;
+ CHAR8 *Value;
+ UINT8 *Data;
+ UINT32 Len;
+ LIST_ENTRY *KeyValueList;
+ UINTN Algorithm;
+ CHAR8 *Identifier;
+ CHAR8 *Challenge;
+ CHAR8 *Name;
+ CHAR8 *Response;
+ UINT8 TargetRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
+ UINT32 RspLen;
+ UINTN Result;
+ UINTN HashIndex;
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
ASSERT (Conn->RspQue.BufNum != 0);
- Session = Conn->Session;
- AuthData = &Session->AuthData.CHAP;
- Len = Conn->RspQue.BufSize;
- Data = AllocateZeroPool (Len);
+ Session = Conn->Session;
+ AuthData = &Session->AuthData.CHAP;
+ Len = Conn->RspQue.BufSize;
+ Data = AllocateZeroPool (Len);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Copy the data in case the data spans over multiple PDUs.
//
@@ -251,7 +251,7 @@ IScsiCHAPOnRspReceived ( //
// Build the key-value list from the data segment of the Login Response.
//
- KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len);
+ KeyValueList = IScsiBuildKeyValueList ((CHAR8 *)Data, Len);
if (KeyValueList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
@@ -260,179 +260,184 @@ IScsiCHAPOnRspReceived ( Status = EFI_PROTOCOL_ERROR;
switch (Conn->AuthStep) {
- case ISCSI_AUTH_INITIAL:
- //
- // The first Login Response.
- //
- Value = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_TARGET_PORTAL_GROUP_TAG
- );
- if (Value == NULL) {
- goto ON_EXIT;
- }
-
- Result = IScsiNetNtoi (Value);
- if (Result > 0xFFFF) {
- goto ON_EXIT;
- }
-
- Session->TargetPortalGroupTag = (UINT16) Result;
-
- Value = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_AUTH_METHOD
- );
- if (Value == NULL) {
- goto ON_EXIT;
- }
- //
- // Initiator mandates CHAP authentication but target replies without
- // "CHAP", or initiator suggets "None" but target replies with some kind of
- // auth method.
- //
- if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
- if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) {
+ case ISCSI_AUTH_INITIAL:
+ //
+ // The first Login Response.
+ //
+ Value = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_TARGET_PORTAL_GROUP_TAG
+ );
+ if (Value == NULL) {
goto ON_EXIT;
}
- } else if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
- if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) != 0) {
+
+ Result = IScsiNetNtoi (Value);
+ if (Result > 0xFFFF) {
goto ON_EXIT;
}
- } else {
- goto ON_EXIT;
- }
- //
- // Transit to CHAP step one.
- //
- Conn->AuthStep = ISCSI_CHAP_STEP_ONE;
- Status = EFI_SUCCESS;
- break;
+ Session->TargetPortalGroupTag = (UINT16)Result;
- case ISCSI_CHAP_STEP_TWO:
- //
- // The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
- //
- Value = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_ALGORITHM
- );
- if (Value == NULL) {
- goto ON_EXIT;
- }
-
- Algorithm = IScsiNetNtoi (Value);
- for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) {
- if (Algorithm == mChapHash[HashIndex].Algorithm) {
- break;
+ Value = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_AUTH_METHOD
+ );
+ if (Value == NULL) {
+ goto ON_EXIT;
}
- }
- if (HashIndex == ARRAY_SIZE (mChapHash)) {
+
//
- // Unsupported algorithm is chosen by target.
+ // Initiator mandates CHAP authentication but target replies without
+ // "CHAP", or initiator suggets "None" but target replies with some kind of
+ // auth method.
//
- goto ON_EXIT;
- }
- //
- // Remember the target's chosen hash algorithm.
- //
- ASSERT (AuthData->Hash == NULL);
- AuthData->Hash = &mChapHash[HashIndex];
+ if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
+ if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) {
+ goto ON_EXIT;
+ }
+ } else if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
+ if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) != 0) {
+ goto ON_EXIT;
+ }
+ } else {
+ goto ON_EXIT;
+ }
- Identifier = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_IDENTIFIER
- );
- if (Identifier == NULL) {
- goto ON_EXIT;
- }
-
- Challenge = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_CHALLENGE
- );
- if (Challenge == NULL) {
- goto ON_EXIT;
- }
- //
- // Process the CHAP identifier and CHAP Challenge from Target.
- // Calculate Response value.
- //
- Result = IScsiNetNtoi (Identifier);
- if (Result > 0xFF) {
- goto ON_EXIT;
- }
-
- AuthData->InIdentifier = (UINT32) Result;
- AuthData->InChallengeLength = (UINT32) sizeof (AuthData->InChallenge);
- Status = IScsiHexToBin (
- (UINT8 *) AuthData->InChallenge,
- &AuthData->InChallengeLength,
- Challenge
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_PROTOCOL_ERROR;
- goto ON_EXIT;
- }
- Status = IScsiCHAPCalculateResponse (
- AuthData->InIdentifier,
- AuthData->AuthConfig->CHAPSecret,
- (UINT32) AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
- AuthData->InChallenge,
- AuthData->InChallengeLength,
- AuthData->Hash,
- AuthData->CHAPResponse
- );
+ //
+ // Transit to CHAP step one.
+ //
+ Conn->AuthStep = ISCSI_CHAP_STEP_ONE;
+ Status = EFI_SUCCESS;
+ break;
- //
- // Transit to next step.
- //
- Conn->AuthStep = ISCSI_CHAP_STEP_THREE;
- break;
+ case ISCSI_CHAP_STEP_TWO:
+ //
+ // The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
+ //
+ Value = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_ALGORITHM
+ );
+ if (Value == NULL) {
+ goto ON_EXIT;
+ }
- case ISCSI_CHAP_STEP_THREE:
- //
- // One way CHAP authentication and the target would like to
- // authenticate us.
- //
- Status = EFI_SUCCESS;
- break;
+ Algorithm = IScsiNetNtoi (Value);
+ for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) {
+ if (Algorithm == mChapHash[HashIndex].Algorithm) {
+ break;
+ }
+ }
- case ISCSI_CHAP_STEP_FOUR:
- ASSERT (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL);
- //
- // The forth step, CHAP_N=<N> CHAP_R=<R> is received from Target.
- //
- Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME);
- if (Name == NULL) {
- goto ON_EXIT;
- }
-
- Response = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_RESPONSE
+ if (HashIndex == ARRAY_SIZE (mChapHash)) {
+ //
+ // Unsupported algorithm is chosen by target.
+ //
+ goto ON_EXIT;
+ }
+
+ //
+ // Remember the target's chosen hash algorithm.
+ //
+ ASSERT (AuthData->Hash == NULL);
+ AuthData->Hash = &mChapHash[HashIndex];
+
+ Identifier = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_IDENTIFIER
+ );
+ if (Identifier == NULL) {
+ goto ON_EXIT;
+ }
+
+ Challenge = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_CHALLENGE
+ );
+ if (Challenge == NULL) {
+ goto ON_EXIT;
+ }
+
+ //
+ // Process the CHAP identifier and CHAP Challenge from Target.
+ // Calculate Response value.
+ //
+ Result = IScsiNetNtoi (Identifier);
+ if (Result > 0xFF) {
+ goto ON_EXIT;
+ }
+
+ AuthData->InIdentifier = (UINT32)Result;
+ AuthData->InChallengeLength = (UINT32)sizeof (AuthData->InChallenge);
+ Status = IScsiHexToBin (
+ (UINT8 *)AuthData->InChallenge,
+ &AuthData->InChallengeLength,
+ Challenge
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_PROTOCOL_ERROR;
+ goto ON_EXIT;
+ }
+
+ Status = IScsiCHAPCalculateResponse (
+ AuthData->InIdentifier,
+ AuthData->AuthConfig->CHAPSecret,
+ (UINT32)AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
+ AuthData->InChallenge,
+ AuthData->InChallengeLength,
+ AuthData->Hash,
+ AuthData->CHAPResponse
);
- if (Response == NULL) {
- goto ON_EXIT;
- }
-
- ASSERT (AuthData->Hash != NULL);
- RspLen = AuthData->Hash->DigestSize;
- Status = IScsiHexToBin (TargetRsp, &RspLen, Response);
- if (EFI_ERROR (Status) || RspLen != AuthData->Hash->DigestSize) {
- Status = EFI_PROTOCOL_ERROR;
- goto ON_EXIT;
- }
- //
- // Check the CHAP Name and Response replied by Target.
- //
- Status = IScsiCHAPAuthTarget (AuthData, TargetRsp);
- break;
+ //
+ // Transit to next step.
+ //
+ Conn->AuthStep = ISCSI_CHAP_STEP_THREE;
+ break;
+
+ case ISCSI_CHAP_STEP_THREE:
+ //
+ // One way CHAP authentication and the target would like to
+ // authenticate us.
+ //
+ Status = EFI_SUCCESS;
+ break;
+
+ case ISCSI_CHAP_STEP_FOUR:
+ ASSERT (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL);
+ //
+ // The forth step, CHAP_N=<N> CHAP_R=<R> is received from Target.
+ //
+ Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME);
+ if (Name == NULL) {
+ goto ON_EXIT;
+ }
+
+ Response = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_RESPONSE
+ );
+ if (Response == NULL) {
+ goto ON_EXIT;
+ }
- default:
- break;
+ ASSERT (AuthData->Hash != NULL);
+ RspLen = AuthData->Hash->DigestSize;
+ Status = IScsiHexToBin (TargetRsp, &RspLen, Response);
+ if (EFI_ERROR (Status) || (RspLen != AuthData->Hash->DigestSize)) {
+ Status = EFI_PROTOCOL_ERROR;
+ goto ON_EXIT;
+ }
+
+ //
+ // Check the CHAP Name and Response replied by Target.
+ //
+ Status = IScsiCHAPAuthTarget (AuthData, TargetRsp);
+ break;
+
+ default:
+ break;
}
ON_EXIT:
@@ -446,7 +451,6 @@ ON_EXIT: return Status;
}
-
/**
This function fills the CHAP authentication information into the login PDU
during the security negotiation stage in the iSCSI connection login.
@@ -467,140 +471,142 @@ IScsiCHAPToSendReq ( IN OUT NET_BUF *Pdu
)
{
- EFI_STATUS Status;
- ISCSI_SESSION *Session;
- ISCSI_LOGIN_REQUEST *LoginReq;
- ISCSI_CHAP_AUTH_DATA *AuthData;
- CHAR8 *Value;
- CHAR8 ValueStr[256];
- CHAR8 *Response;
- UINT32 RspLen;
- CHAR8 *Challenge;
- UINT32 ChallengeLen;
- EFI_STATUS BinToHexStatus;
+ EFI_STATUS Status;
+ ISCSI_SESSION *Session;
+ ISCSI_LOGIN_REQUEST *LoginReq;
+ ISCSI_CHAP_AUTH_DATA *AuthData;
+ CHAR8 *Value;
+ CHAR8 ValueStr[256];
+ CHAR8 *Response;
+ UINT32 RspLen;
+ CHAR8 *Challenge;
+ UINT32 ChallengeLen;
+ EFI_STATUS BinToHexStatus;
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
- Session = Conn->Session;
- AuthData = &Session->AuthData.CHAP;
- LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);
+ Session = Conn->Session;
+ AuthData = &Session->AuthData.CHAP;
+ LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, 0);
if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR;
}
- Status = EFI_SUCCESS;
- RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
- Response = AllocateZeroPool (RspLen);
+ Status = EFI_SUCCESS;
+
+ RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
+ Response = AllocateZeroPool (RspLen);
if (Response == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- ChallengeLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
- Challenge = AllocateZeroPool (ChallengeLen);
+ ChallengeLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
+ Challenge = AllocateZeroPool (ChallengeLen);
if (Challenge == NULL) {
FreePool (Response);
return EFI_OUT_OF_RESOURCES;
}
switch (Conn->AuthStep) {
- case ISCSI_AUTH_INITIAL:
- //
- // It's the initial Login Request. Fill in the key=value pairs mandatory
- // for the initial Login Request.
- //
- IScsiAddKeyValuePair (
- Pdu,
- ISCSI_KEY_INITIATOR_NAME,
- mPrivate->InitiatorName
- );
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
- IScsiAddKeyValuePair (
- Pdu,
- ISCSI_KEY_TARGET_NAME,
- Session->ConfigData->SessionConfigData.TargetName
- );
-
- if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
- Value = ISCSI_KEY_VALUE_NONE;
- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
- } else {
- Value = ISCSI_AUTH_METHOD_CHAP;
- }
-
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value);
+ case ISCSI_AUTH_INITIAL:
+ //
+ // It's the initial Login Request. Fill in the key=value pairs mandatory
+ // for the initial Login Request.
+ //
+ IScsiAddKeyValuePair (
+ Pdu,
+ ISCSI_KEY_INITIATOR_NAME,
+ mPrivate->InitiatorName
+ );
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
+ IScsiAddKeyValuePair (
+ Pdu,
+ ISCSI_KEY_TARGET_NAME,
+ Session->ConfigData->SessionConfigData.TargetName
+ );
- break;
+ if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
+ Value = ISCSI_KEY_VALUE_NONE;
+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
+ } else {
+ Value = ISCSI_AUTH_METHOD_CHAP;
+ }
- case ISCSI_CHAP_STEP_ONE:
- //
- // First step, send the Login Request with CHAP_A=<A1,A2...> key-value
- // pair.
- //
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, mChapHashListString);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value);
- Conn->AuthStep = ISCSI_CHAP_STEP_TWO;
- break;
+ break;
- case ISCSI_CHAP_STEP_THREE:
- //
- // Third step, send the Login Request with CHAP_N=<N> CHAP_R=<R> or
- // CHAP_N=<N> CHAP_R=<R> CHAP_I=<I> CHAP_C=<C> if target authentication is
- // required too.
- //
- // CHAP_N=<N>
- //
- IScsiAddKeyValuePair (
- Pdu,
- ISCSI_KEY_CHAP_NAME,
- (CHAR8 *) &AuthData->AuthConfig->CHAPName
- );
- //
- // CHAP_R=<R>
- //
- ASSERT (AuthData->Hash != NULL);
- BinToHexStatus = IScsiBinToHex (
- (UINT8 *) AuthData->CHAPResponse,
- AuthData->Hash->DigestSize,
- Response,
- &RspLen
- );
- ASSERT_EFI_ERROR (BinToHexStatus);
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
-
- if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
+ case ISCSI_CHAP_STEP_ONE:
//
- // CHAP_I=<I>
+ // First step, send the Login Request with CHAP_A=<A1,A2...> key-value
+ // pair.
//
- IScsiGenRandom ((UINT8 *) &AuthData->OutIdentifier, 1);
- AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, mChapHashListString);
+
+ Conn->AuthStep = ISCSI_CHAP_STEP_TWO;
+ break;
+
+ case ISCSI_CHAP_STEP_THREE:
//
- // CHAP_C=<C>
+ // Third step, send the Login Request with CHAP_N=<N> CHAP_R=<R> or
+ // CHAP_N=<N> CHAP_R=<R> CHAP_I=<I> CHAP_C=<C> if target authentication is
+ // required too.
//
- IScsiGenRandom (
- (UINT8 *) AuthData->OutChallenge,
- AuthData->Hash->DigestSize
+ // CHAP_N=<N>
+ //
+ IScsiAddKeyValuePair (
+ Pdu,
+ ISCSI_KEY_CHAP_NAME,
+ (CHAR8 *)&AuthData->AuthConfig->CHAPName
);
+ //
+ // CHAP_R=<R>
+ //
+ ASSERT (AuthData->Hash != NULL);
BinToHexStatus = IScsiBinToHex (
- (UINT8 *) AuthData->OutChallenge,
+ (UINT8 *)AuthData->CHAPResponse,
AuthData->Hash->DigestSize,
- Challenge,
- &ChallengeLen
+ Response,
+ &RspLen
);
ASSERT_EFI_ERROR (BinToHexStatus);
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
+
+ if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
+ //
+ // CHAP_I=<I>
+ //
+ IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1);
+ AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
+ //
+ // CHAP_C=<C>
+ //
+ IScsiGenRandom (
+ (UINT8 *)AuthData->OutChallenge,
+ AuthData->Hash->DigestSize
+ );
+ BinToHexStatus = IScsiBinToHex (
+ (UINT8 *)AuthData->OutChallenge,
+ AuthData->Hash->DigestSize,
+ Challenge,
+ &ChallengeLen
+ );
+ ASSERT_EFI_ERROR (BinToHexStatus);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
+
+ Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
+ }
- Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
- }
- //
- // Set the stage transition flag.
- //
- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
- break;
+ //
+ // Set the stage transition flag.
+ //
+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
+ break;
- default:
- Status = EFI_PROTOCOL_ERROR;
- break;
+ default:
+ Status = EFI_PROTOCOL_ERROR;
+ break;
}
FreePool (Response);
@@ -621,14 +627,14 @@ IScsiCHAPInitHashList ( VOID
)
{
- CHAR8 *Position;
- UINTN Left;
- UINTN HashIndex;
- CONST CHAP_HASH *Hash;
- UINTN Printed;
+ CHAR8 *Position;
+ UINTN Left;
+ UINTN HashIndex;
+ CONST CHAP_HASH *Hash;
+ UINTN Printed;
Position = mChapHashListString;
- Left = sizeof (mChapHashListString);
+ Left = sizeof (mChapHashListString);
for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) {
Hash = &mChapHash[HashIndex];
@@ -657,7 +663,7 @@ IScsiCHAPInitHashList ( ASSERT (Printed + 1 < Left);
Position += Printed;
- Left -= Printed;
+ Left -= Printed;
//
// Sanity-check the digest size for Hash.
diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.h b/NetworkPkg/IScsiDxe/IScsiCHAP.h index e2df634c4e..1be85d3978 100644 --- a/NetworkPkg/IScsiDxe/IScsiCHAP.h +++ b/NetworkPkg/IScsiDxe/IScsiCHAP.h @@ -9,41 +9,40 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _ISCSI_CHAP_H_
#define _ISCSI_CHAP_H_
-#define ISCSI_AUTH_METHOD_CHAP "CHAP"
+#define ISCSI_AUTH_METHOD_CHAP "CHAP"
-#define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"
-#define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
-#define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"
-#define ISCSI_KEY_CHAP_NAME "CHAP_N"
-#define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"
+#define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"
+#define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
+#define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"
+#define ISCSI_KEY_CHAP_NAME "CHAP_N"
+#define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"
//
// Identifiers of supported CHAP hash algorithms:
// https://www.iana.org/assignments/ppp-numbers/ppp-numbers.xhtml#ppp-numbers-9
//
-#define ISCSI_CHAP_ALGORITHM_MD5 5
-#define ISCSI_CHAP_ALGORITHM_SHA256 7
+#define ISCSI_CHAP_ALGORITHM_MD5 5
+#define ISCSI_CHAP_ALGORITHM_SHA256 7
//
// Byte count of the largest digest over the above-listed
// ISCSI_CHAP_ALGORITHM_* hash algorithms.
//
-#define ISCSI_CHAP_MAX_DIGEST_SIZE SHA256_DIGEST_SIZE
-
-#define ISCSI_CHAP_STEP_ONE 1
-#define ISCSI_CHAP_STEP_TWO 2
-#define ISCSI_CHAP_STEP_THREE 3
-#define ISCSI_CHAP_STEP_FOUR 4
+#define ISCSI_CHAP_MAX_DIGEST_SIZE SHA256_DIGEST_SIZE
+#define ISCSI_CHAP_STEP_ONE 1
+#define ISCSI_CHAP_STEP_TWO 2
+#define ISCSI_CHAP_STEP_THREE 3
+#define ISCSI_CHAP_STEP_FOUR 4
#pragma pack(1)
typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
- UINT8 CHAPType;
- CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
- CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
- CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
- CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
+ UINT8 CHAPType;
+ CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
+ CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
+ CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
+ CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
} ISCSI_CHAP_AUTH_CONFIG_NVDATA;
#pragma pack()
@@ -53,19 +52,19 @@ typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA { //
typedef
UINTN
-(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE) (
+(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE)(
VOID
);
typedef
BOOLEAN
-(EFIAPI *CHAP_HASH_INIT) (
+(EFIAPI *CHAP_HASH_INIT)(
OUT VOID *Context
);
typedef
BOOLEAN
-(EFIAPI *CHAP_HASH_UPDATE) (
+(EFIAPI *CHAP_HASH_UPDATE)(
IN OUT VOID *Context,
IN CONST VOID *Data,
IN UINTN DataSize
@@ -73,37 +72,37 @@ BOOLEAN typedef
BOOLEAN
-(EFIAPI *CHAP_HASH_FINAL) (
+(EFIAPI *CHAP_HASH_FINAL)(
IN OUT VOID *Context,
OUT UINT8 *HashValue
);
typedef struct {
- UINT8 Algorithm; // ISCSI_CHAP_ALGORITHM_*, CHAP_A
- UINT32 DigestSize;
- CHAP_HASH_GET_CONTEXT_SIZE GetContextSize;
- CHAP_HASH_INIT Init;
- CHAP_HASH_UPDATE Update;
- CHAP_HASH_FINAL Final;
+ UINT8 Algorithm; // ISCSI_CHAP_ALGORITHM_*, CHAP_A
+ UINT32 DigestSize;
+ CHAP_HASH_GET_CONTEXT_SIZE GetContextSize;
+ CHAP_HASH_INIT Init;
+ CHAP_HASH_UPDATE Update;
+ CHAP_HASH_FINAL Final;
} CHAP_HASH;
///
/// ISCSI CHAP Authentication Data
///
typedef struct _ISCSI_CHAP_AUTH_DATA {
- ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
- UINT32 InIdentifier;
- UINT8 InChallenge[1024];
- UINT32 InChallengeLength;
+ ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
+ UINT32 InIdentifier;
+ UINT8 InChallenge[1024];
+ UINT32 InChallengeLength;
//
// The hash algorithm (CHAP_A) that the target selects in
// ISCSI_CHAP_STEP_TWO.
//
- CONST CHAP_HASH *Hash;
+ CONST CHAP_HASH *Hash;
//
// Calculated CHAP Response (CHAP_R) value.
//
- UINT8 CHAPResponse[ISCSI_CHAP_MAX_DIGEST_SIZE];
+ UINT8 CHAPResponse[ISCSI_CHAP_MAX_DIGEST_SIZE];
//
// Auth-data to be sent out for mutual authentication.
@@ -113,8 +112,8 @@ typedef struct _ISCSI_CHAP_AUTH_DATA { // digest size. In other words, it's good practice to feed *at least as many
// bytes* to the hashing algorithm as the hashing algorithm will output.
//
- UINT32 OutIdentifier;
- UINT8 OutChallenge[ISCSI_CHAP_MAX_DIGEST_SIZE];
+ UINT32 OutIdentifier;
+ UINT8 OutChallenge[ISCSI_CHAP_MAX_DIGEST_SIZE];
} ISCSI_CHAP_AUTH_DATA;
/**
@@ -133,6 +132,7 @@ EFI_STATUS IScsiCHAPOnRspReceived (
IN ISCSI_CONNECTION *Conn
);
+
/**
This function fills the CHAP authentication information into the login PDU
during the security negotiation stage in the iSCSI connection login.
@@ -164,4 +164,5 @@ VOID IScsiCHAPInitHashList (
VOID
);
+
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiConfig.c index 326b1da39e..37f6255af0 100644 --- a/NetworkPkg/IScsiDxe/IScsiConfig.c +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c @@ -8,8 +8,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-CHAR16 mVendorStorageName[] = L"ISCSI_CONFIG_IFR_NVDATA";
-ISCSI_FORM_CALLBACK_INFO *mCallbackInfo = NULL;
+CHAR16 mVendorStorageName[] = L"ISCSI_CONFIG_IFR_NVDATA";
+ISCSI_FORM_CALLBACK_INFO *mCallbackInfo = NULL;
HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = {
{
@@ -17,8 +17,8 @@ HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = { HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
ISCSI_CONFIG_GUID
@@ -27,13 +27,12 @@ HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = { END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
-
/**
Convert the IP address into a dotted string.
@@ -44,32 +43,32 @@ HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = { **/
VOID
IScsiIpToStr (
- IN EFI_IP_ADDRESS *Ip,
- IN BOOLEAN Ipv6Flag,
- OUT CHAR16 *Str
+ IN EFI_IP_ADDRESS *Ip,
+ IN BOOLEAN Ipv6Flag,
+ OUT CHAR16 *Str
)
{
- EFI_IPv4_ADDRESS *Ip4;
- EFI_IPv6_ADDRESS *Ip6;
- UINTN Index;
- BOOLEAN Short;
- UINTN Number;
- CHAR16 FormatString[8];
+ EFI_IPv4_ADDRESS *Ip4;
+ EFI_IPv6_ADDRESS *Ip6;
+ UINTN Index;
+ BOOLEAN Short;
+ UINTN Number;
+ CHAR16 FormatString[8];
if (!Ipv6Flag) {
Ip4 = &Ip->v4;
UnicodeSPrint (
Str,
- (UINTN) 2 * IP4_STR_MAX_SIZE,
+ (UINTN)2 * IP4_STR_MAX_SIZE,
L"%d.%d.%d.%d",
- (UINTN) Ip4->Addr[0],
- (UINTN) Ip4->Addr[1],
- (UINTN) Ip4->Addr[2],
- (UINTN) Ip4->Addr[3]
+ (UINTN)Ip4->Addr[0],
+ (UINTN)Ip4->Addr[1],
+ (UINTN)Ip4->Addr[2],
+ (UINTN)Ip4->Addr[3]
);
- return ;
+ return;
}
Ip6 = &Ip->v6;
@@ -77,10 +76,11 @@ IScsiIpToStr ( for (Index = 0; Index < 15; Index = Index + 2) {
if (!Short &&
- Index % 2 == 0 &&
- Ip6->Addr[Index] == 0 &&
- Ip6->Addr[Index + 1] == 0
- ) {
+ (Index % 2 == 0) &&
+ (Ip6->Addr[Index] == 0) &&
+ (Ip6->Addr[Index + 1] == 0)
+ )
+ {
//
// Deal with the case of ::.
//
@@ -89,8 +89,8 @@ IScsiIpToStr ( *(Str + 1) = L':';
Str = Str + 2;
} else {
- *Str = L':';
- Str = Str + 1;
+ *Str = L':';
+ Str = Str + 1;
}
while ((Index < 15) && (Ip6->Addr[Index] == 0) && (Ip6->Addr[Index + 1] == 0)) {
@@ -111,7 +111,7 @@ IScsiIpToStr ( ASSERT (Index < 15);
if (Ip6->Addr[Index] == 0) {
- Number = UnicodeSPrint (Str, 2 * IP_STR_MAX_SIZE, L"%x:", (UINTN) Ip6->Addr[Index + 1]);
+ Number = UnicodeSPrint (Str, 2 * IP_STR_MAX_SIZE, L"%x:", (UINTN)Ip6->Addr[Index + 1]);
} else {
if (Ip6->Addr[Index + 1] < 0x10) {
CopyMem (FormatString, L"%x0%x:", StrSize (L"%x0%x:"));
@@ -122,9 +122,9 @@ IScsiIpToStr ( Number = UnicodeSPrint (
Str,
2 * IP_STR_MAX_SIZE,
- (CONST CHAR16 *) FormatString,
- (UINTN) Ip6->Addr[Index],
- (UINTN) Ip6->Addr[Index + 1]
+ (CONST CHAR16 *)FormatString,
+ (UINTN)Ip6->Addr[Index],
+ (UINTN)Ip6->Addr[Index + 1]
);
}
@@ -151,14 +151,15 @@ IScsiIpToStr ( **/
BOOLEAN
IpIsUnicast (
- IN EFI_IP_ADDRESS *Ip,
+ IN EFI_IP_ADDRESS *Ip,
IN UINT8 IpMode
)
{
if (IpMode == IP_MODE_IP4) {
- if (IP4_IS_UNSPECIFIED (NTOHL (Ip->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip->Addr[0]))) {
+ if (IP4_IS_UNSPECIFIED (NTOHL (Ip->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip->Addr[0]))) {
return FALSE;
}
+
return TRUE;
} else if (IpMode == IP_MODE_IP6) {
return NetIp6IsValidUnicast (&Ip->v6);
@@ -180,27 +181,27 @@ IpIsUnicast ( **/
EFI_STATUS
IScsiParseIsIdFromString (
- IN CONST CHAR16 *String,
- IN OUT UINT8 *IsId
+ IN CONST CHAR16 *String,
+ IN OUT UINT8 *IsId
)
{
- UINT8 Index;
- CHAR16 *IsIdStr;
- CHAR16 TempStr[3];
- UINTN NodeVal;
- CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];
- EFI_INPUT_KEY Key;
+ UINT8 Index;
+ CHAR16 *IsIdStr;
+ CHAR16 TempStr[3];
+ UINTN NodeVal;
+ CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];
+ EFI_INPUT_KEY Key;
if ((String == NULL) || (IsId == NULL)) {
return EFI_INVALID_PARAMETER;
}
- IsIdStr = (CHAR16 *) String;
+ IsIdStr = (CHAR16 *)String;
- if (StrLen (IsIdStr) != 6 && StrLen (IsIdStr) != 12) {
+ if ((StrLen (IsIdStr) != 6) && (StrLen (IsIdStr) != 12)) {
UnicodeSPrint (
PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Error! Only last 3 bytes are configurable, please input 6 hex numbers for last 3 bytes only or 12 hex numbers for full SSID!\n"
);
@@ -228,7 +229,7 @@ IScsiParseIsIdFromString ( //
NodeVal = StrHexToUintn (TempStr);
- IsId[Index] = (UINT8) NodeVal;
+ IsId[Index] = (UINT8)NodeVal;
IsIdStr = IsIdStr + 2;
}
@@ -248,12 +249,12 @@ IScsiParseIsIdFromString ( **/
EFI_STATUS
IScsiConvertIsIdToString (
- OUT CHAR16 *String,
- IN UINT8 *IsId
+ OUT CHAR16 *String,
+ IN UINT8 *IsId
)
{
- UINT8 Index;
- UINTN Number;
+ UINT8 Index;
+ UINTN Number;
if ((String == NULL) || (IsId == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -265,16 +266,15 @@ IScsiConvertIsIdToString ( String,
2 * ISID_CONFIGURABLE_STORAGE,
L"0%X",
- (UINTN) IsId[Index]
+ (UINTN)IsId[Index]
);
} else {
Number = UnicodeSPrint (
String,
2 * ISID_CONFIGURABLE_STORAGE,
L"%X",
- (UINTN) IsId[Index]
+ (UINTN)IsId[Index]
);
-
}
String = String + Number;
@@ -301,36 +301,37 @@ IScsiConvertIsIdToString ( **/
EFI_STATUS
IScsiGetValue (
- IN CONST EFI_STRING Configuration,
- IN CHAR16 *String,
- OUT UINTN *Value
+ 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;
+ 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;
+ Buf = NULL;
StringPtr = StrStr (Configuration, String);
- ASSERT(StringPtr != NULL);
+ ASSERT (StringPtr != NULL);
StringPtr += StrLen (String);
- TmpPtr = StringPtr;
+ TmpPtr = StringPtr;
while (*StringPtr != L'\0' && *StringPtr != L'&') {
- StringPtr ++;
+ StringPtr++;
}
+
Length = StringPtr - TmpPtr;
- Len = Length + 1;
+ Len = Length + 1;
Str = AllocateZeroPool (Len * sizeof (CHAR16));
if (Str == NULL) {
@@ -342,20 +343,20 @@ IScsiGetValue ( *(Str + Length) = L'\0';
Len = (Len + 1) / 2;
- Buf = (UINT8 *) AllocateZeroPool (Len);
+ 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);
+ for (Index = 0; Index < Length; Index++) {
+ TmpStr[0] = Str[Length - Index - 1];
+ DigitUint8 = (UINT8)StrHexToUint64 (TmpStr);
if ((Index & 1) == 0) {
- Buf [Index/2] = DigitUint8;
+ Buf[Index/2] = DigitUint8;
} else {
- Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]);
+ Buf[Index/2] = (UINT8)((DigitUint8 << 4) + Buf[Index/2]);
}
}
@@ -388,7 +389,7 @@ Exit: **/
ISCSI_ATTEMPT_CONFIG_NVDATA *
IScsiConfigGetAttemptByConfigIndex (
- IN UINT8 AttemptConfigIndex
+ IN UINT8 AttemptConfigIndex
)
{
LIST_ENTRY *Entry;
@@ -404,7 +405,6 @@ IScsiConfigGetAttemptByConfigIndex ( return NULL;
}
-
/**
Get the existing attempt config data from global structure by the NicIndex.
@@ -419,8 +419,8 @@ IScsiConfigGetAttemptByConfigIndex ( **/
ISCSI_ATTEMPT_CONFIG_NVDATA *
IScsiConfigGetAttemptByNic (
- IN ISCSI_ATTEMPT_CONFIG_NVDATA *NewAttempt,
- IN UINT8 IScsiMode
+ IN ISCSI_ATTEMPT_CONFIG_NVDATA *NewAttempt,
+ IN UINT8 IScsiMode
)
{
LIST_ENTRY *Entry;
@@ -428,8 +428,9 @@ IScsiConfigGetAttemptByNic ( NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
- if (Attempt != NewAttempt && Attempt->NicIndex == NewAttempt->NicIndex &&
- Attempt->SessionConfigData.Enabled == IScsiMode) {
+ if ((Attempt != NewAttempt) && (Attempt->NicIndex == NewAttempt->NicIndex) &&
+ (Attempt->SessionConfigData.Enabled == IScsiMode))
+ {
return Attempt;
}
}
@@ -451,16 +452,16 @@ IScsiConfigGetAttemptByNic ( **/
EFI_STATUS
IScsiGetAttemptIndexList (
- IN CHAR16 *AttemptNameList,
- OUT UINT8 *AttemptIndexList,
- IN BOOLEAN IsAddAttempts
-)
+ IN CHAR16 *AttemptNameList,
+ OUT UINT8 *AttemptIndexList,
+ IN BOOLEAN IsAddAttempts
+ )
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- CHAR16 *AttemptStr;
- UINT8 AttemptIndex;
- UINTN Len;
- UINTN Index;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ CHAR16 *AttemptStr;
+ UINT8 AttemptIndex;
+ UINTN Len;
+ UINTN Index;
Index = 0;
@@ -469,16 +470,17 @@ IScsiGetAttemptIndexList ( }
AttemptStr = AttemptNameList;
- Len = StrLen (L"attempt:");
+ 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);
+
+ AttemptStr += Len;
+ AttemptIndex = (UINT8)(*AttemptStr - L'0');
+ AttemptConfigData = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (IsAddAttempts) {
if ((AttemptConfigData != NULL) || ((AttemptIndex) > PcdGet8 (PcdMaxIScsiAttemptNumber))) {
return EFI_INVALID_PARAMETER;
@@ -490,9 +492,10 @@ IScsiGetAttemptIndexList ( }
AttemptIndexList[Index] = AttemptIndex;
- Index ++;
+ Index++;
AttemptStr += 2;
}
+
return EFI_SUCCESS;
}
@@ -509,22 +512,22 @@ IScsiConvertAttemptConfigDataToIfrNvData ( IN OUT ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
- ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData;
- ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
- EFI_IP_ADDRESS Ip;
- BOOLEAN DnsMode;
+ ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData;
+ ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
+ EFI_IP_ADDRESS Ip;
+ BOOLEAN DnsMode;
//
// Normal session configuration parameters.
//
- SessionConfigData = &Attempt->SessionConfigData;
- IfrNvData->Enabled = SessionConfigData->Enabled;
- IfrNvData->IpMode = SessionConfigData->IpMode;
- DnsMode = SessionConfigData->DnsMode;
+ SessionConfigData = &Attempt->SessionConfigData;
+ IfrNvData->Enabled = SessionConfigData->Enabled;
+ IfrNvData->IpMode = SessionConfigData->IpMode;
+ DnsMode = SessionConfigData->DnsMode;
- IfrNvData->InitiatorInfoFromDhcp = SessionConfigData->InitiatorInfoFromDhcp;
- IfrNvData->TargetInfoFromDhcp = SessionConfigData->TargetInfoFromDhcp;
- IfrNvData->TargetPort = SessionConfigData->TargetPort;
+ IfrNvData->InitiatorInfoFromDhcp = SessionConfigData->InitiatorInfoFromDhcp;
+ IfrNvData->TargetInfoFromDhcp = SessionConfigData->TargetInfoFromDhcp;
+ IfrNvData->TargetPort = SessionConfigData->TargetPort;
if (IfrNvData->IpMode == IP_MODE_IP4) {
CopyMem (&Ip.v4, &SessionConfigData->LocalIp, sizeof (EFI_IPv4_ADDRESS));
@@ -538,7 +541,6 @@ IScsiConvertAttemptConfigDataToIfrNvData ( CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
}
-
} else if (IfrNvData->IpMode == IP_MODE_IP6) {
ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
if (SessionConfigData->TargetIp.v6.Addr[0] != '\0') {
@@ -620,16 +622,16 @@ 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];
- ISCSI_NIC_INFO *NicInfo;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- EFI_IP_ADDRESS Ip;
- UINTN Index;
- UINTN StringLen;
+ 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];
+ ISCSI_NIC_INFO *NicInfo;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ EFI_IP_ADDRESS Ip;
+ UINTN Index;
+ UINTN StringLen;
NicInfo = NULL;
ZeroMem (AttemptNameList, sizeof (AttemptNameList));
@@ -640,10 +642,10 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( //
// Normal session configuration parameters.
//
- SessionConfigData = &Attempt->SessionConfigData;
+ SessionConfigData = &Attempt->SessionConfigData;
ASSERT ((Attempt->AttemptConfigIndex > 0) && (Attempt->AttemptConfigIndex <= FixedPcdGet8 (PcdMaxIScsiAttemptNumber)));
- Index = Attempt->AttemptConfigIndex - 1;
+ Index = Attempt->AttemptConfigIndex - 1;
//
// Save the attempt to AttemptNameList as Attempt:1 Attempt:2
@@ -652,7 +654,7 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( Attempt->AttemptName,
AttemptNameList + StrLen (AttemptNameList),
ATTEMPT_NAME_LIST_SIZE - StrLen (AttemptNameList)
- );
+ );
StringLen = StrLen (AttemptNameList);
ASSERT (StringLen > 2);
@@ -663,16 +665,16 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( Attempt->AttemptName,
IfrNvData->ISCSIAttemptName + ATTEMPT_NAME_SIZE * Index,
ATTEMPT_NAME_LIST_SIZE - ATTEMPT_NAME_SIZE * Index
- );
+ );
- IfrNvData->ISCSIBootEnableList[Index] = SessionConfigData->Enabled;
- IfrNvData->ISCSIIpAddressTypeList[Index] = SessionConfigData->IpMode;
+ 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;
+ 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));
@@ -710,10 +712,10 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->Keyword[Index].ISCSILun);
IScsiConvertIsIdToString (IfrNvData->Keyword[Index].ISCSIIsId, SessionConfigData->IsId);
- IfrNvData->ISCSIAuthenticationMethod[Index] = Attempt->AuthenticationType;
+ IfrNvData->ISCSIAuthenticationMethod[Index] = Attempt->AuthenticationType;
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
- AuthConfigData = &Attempt->AuthConfigData.CHAP;
+ AuthConfigData = &Attempt->AuthConfigData.CHAP;
IfrNvData->ISCSIChapType[Index] = AuthConfigData->CHAPType;
AsciiStrToUnicodeStrS (
AuthConfigData->CHAPName,
@@ -740,7 +742,7 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( );
}
}
- CopyMem(IfrNvData->ISCSIDisplayAttemptList, AttemptNameList, ATTEMPT_NAME_LIST_SIZE);
+ CopyMem (IfrNvData->ISCSIDisplayAttemptList, AttemptNameList, ATTEMPT_NAME_LIST_SIZE);
ZeroMem (IfrNvData->ISCSIMacAddr, sizeof (IfrNvData->ISCSIMacAddr));
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
@@ -786,34 +788,34 @@ IScsiConvertIfrNvDataToAttemptConfigData ( IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt
)
{
- EFI_IP_ADDRESS HostIp;
- EFI_IP_ADDRESS SubnetMask;
- EFI_IP_ADDRESS Gateway;
- CHAR16 *MacString;
- CHAR16 *AttemptName1;
- CHAR16 *AttemptName2;
- ISCSI_ATTEMPT_CONFIG_NVDATA *ExistAttempt;
- ISCSI_ATTEMPT_CONFIG_NVDATA *SameNicAttempt;
- CHAR16 IScsiMode[64];
- CHAR16 IpMode[64];
- ISCSI_NIC_INFO *NicInfo;
- EFI_INPUT_KEY Key;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINT8 *AttemptOrderTmp;
- UINTN TotalNumber;
- EFI_STATUS Status;
-
- if (IfrNvData == NULL || Attempt == NULL) {
+ EFI_IP_ADDRESS HostIp;
+ EFI_IP_ADDRESS SubnetMask;
+ EFI_IP_ADDRESS Gateway;
+ CHAR16 *MacString;
+ CHAR16 *AttemptName1;
+ CHAR16 *AttemptName2;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *ExistAttempt;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *SameNicAttempt;
+ CHAR16 IScsiMode[64];
+ CHAR16 IpMode[64];
+ ISCSI_NIC_INFO *NicInfo;
+ EFI_INPUT_KEY Key;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINT8 *AttemptOrderTmp;
+ UINTN TotalNumber;
+ EFI_STATUS Status;
+
+ if ((IfrNvData == NULL) || (Attempt == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Update those fields which don't have INTERACTIVE attribute.
//
- Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ConnectRetryCount;
- Attempt->SessionConfigData.ConnectTimeout = IfrNvData->ConnectTimeout;
- Attempt->SessionConfigData.IpMode = IfrNvData->IpMode;
+ Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ConnectRetryCount;
+ Attempt->SessionConfigData.ConnectTimeout = IfrNvData->ConnectTimeout;
+ Attempt->SessionConfigData.IpMode = IfrNvData->IpMode;
if (IfrNvData->IpMode < IP_MODE_AUTOCONFIG) {
Attempt->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData->InitiatorInfoFromDhcp;
@@ -878,10 +880,11 @@ IScsiConvertIfrNvDataToAttemptConfigData ( }
}
}
+
//
// Validate target configuration if DHCP isn't deployed.
//
- if (!Attempt->SessionConfigData.TargetInfoFromDhcp && Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
+ if (!Attempt->SessionConfigData.TargetInfoFromDhcp && (Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG)) {
if (!Attempt->SessionConfigData.DnsMode) {
if (!IpIsUnicast (&Attempt->SessionConfigData.TargetIp, IfrNvData->IpMode)) {
CreatePopUp (
@@ -937,7 +940,8 @@ IScsiConvertIfrNvDataToAttemptConfigData ( if ((IfrNvData->CHAPType == ISCSI_CHAP_MUTUAL) &&
((IfrNvData->ReverseCHAPName[0] == '\0') || (IfrNvData->ReverseCHAPSecret[0] == '\0'))
- ) {
+ )
+ {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@@ -953,12 +957,12 @@ IScsiConvertIfrNvDataToAttemptConfigData ( //
SameNicAttempt = IScsiConfigGetAttemptByNic (Attempt, IfrNvData->Enabled);
if (SameNicAttempt != NULL) {
- AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
+ AttemptName1 = (CHAR16 *)AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
if (AttemptName1 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
+ AttemptName2 = (CHAR16 *)AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
if (AttemptName2 == NULL) {
FreePool (AttemptName1);
return EFI_OUT_OF_RESOURCES;
@@ -969,7 +973,7 @@ IScsiConvertIfrNvDataToAttemptConfigData ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Warning! Attempt \"%s\" uses same NIC as Attempt \"%s\".",
AttemptName1,
AttemptName2
@@ -1011,7 +1015,7 @@ IScsiConvertIfrNvDataToAttemptConfigData ( return EFI_NOT_FOUND;
}
- MacString = (CHAR16 *) AllocateZeroPool (ISCSI_MAX_MAC_STRING_LEN * sizeof (CHAR16));
+ MacString = (CHAR16 *)AllocateZeroPool (ISCSI_MAX_MAC_STRING_LEN * sizeof (CHAR16));
if (MacString == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1020,7 +1024,7 @@ IScsiConvertIfrNvDataToAttemptConfigData ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (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,
@@ -1048,9 +1052,9 @@ IScsiConvertIfrNvDataToAttemptConfigData ( if (ExistAttempt != NULL) {
ASSERT (ExistAttempt == Attempt);
- if (IfrNvData->Enabled == ISCSI_DISABLED &&
- Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
-
+ if ((IfrNvData->Enabled == ISCSI_DISABLED) &&
+ (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED))
+ {
//
// User updates the Attempt from "Enabled"/"Enabled for MPIO" to "Disabled".
//
@@ -1066,11 +1070,12 @@ IScsiConvertIfrNvDataToAttemptConfigData ( if (mPrivate->SinglePathCount < 1) {
return EFI_ABORTED;
}
+
mPrivate->SinglePathCount--;
}
-
- } else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO &&
- Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) {
+ } else if ((IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) &&
+ (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED))
+ {
//
// User updates the Attempt from "Enabled" to "Enabled for MPIO".
//
@@ -1081,9 +1086,9 @@ IScsiConvertIfrNvDataToAttemptConfigData ( mPrivate->EnableMpio = TRUE;
mPrivate->MpioCount++;
mPrivate->SinglePathCount--;
-
- } else if (IfrNvData->Enabled == ISCSI_ENABLED &&
- Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
+ } else if ((IfrNvData->Enabled == ISCSI_ENABLED) &&
+ (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO))
+ {
//
// User updates the Attempt from "Enabled for MPIO" to "Enabled".
//
@@ -1094,22 +1099,21 @@ IScsiConvertIfrNvDataToAttemptConfigData ( if (--mPrivate->MpioCount == 0) {
mPrivate->EnableMpio = FALSE;
}
- mPrivate->SinglePathCount++;
- } else if (IfrNvData->Enabled != ISCSI_DISABLED &&
- Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) {
+ 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++;
}
}
-
} else if (ExistAttempt == NULL) {
//
// When a new attempt is created, pointer of the attempt is saved to
@@ -1138,6 +1142,7 @@ IScsiConvertIfrNvDataToAttemptConfigData ( if (AttemptConfigOrder != NULL) {
FreePool (AttemptConfigOrder);
}
+
return EFI_OUT_OF_RESOURCES;
}
@@ -1180,12 +1185,13 @@ IScsiConvertIfrNvDataToAttemptConfigData ( IScsiConfigUpdateAttempt ();
}
+
Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
//
// Record the user configuration information in NVR.
//
- UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex);
+ UnicodeSPrint (mPrivate->PortString, (UINTN)ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex);
FreePool (MacString);
@@ -1210,40 +1216,40 @@ IScsiConvertIfrNvDataToAttemptConfigData ( **/
EFI_STATUS
IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
- IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData,
- IN UINTN OffSet
+ IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData,
+ IN UINTN OffSet
)
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt;
- UINT8 AttemptIndex;
- UINT8 Index;
- UINT8 ChapSecretLen;
- UINT8 ReverseChapSecretLen;
- 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;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt;
+ UINT8 AttemptIndex;
+ UINT8 Index;
+ UINT8 ChapSecretLen;
+ UINT8 ReverseChapSecretLen;
+ 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;
Attempt = NULL;
ZeroMem (IScsiName, sizeof (IScsiName));
if (OffSet < ATTEMPT_BOOTENABLE_VAR_OFFSET) {
return EFI_SUCCESS;
-
} else if ((OffSet >= ATTEMPT_BOOTENABLE_VAR_OFFSET) && (OffSet < ATTEMPT_ADDRESS_TYPE_VAR_OFFSET)) {
- AttemptIndex = (UINT8) ((OffSet - ATTEMPT_BOOTENABLE_VAR_OFFSET) + 1);
- Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ 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.
@@ -1254,12 +1260,12 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( //
SameNicAttempt = IScsiConfigGetAttemptByNic (Attempt, IfrNvData->Enabled);
if (SameNicAttempt != NULL) {
- AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
+ AttemptName1 = (CHAR16 *)AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
if (AttemptName1 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
+ AttemptName2 = (CHAR16 *)AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16));
if (AttemptName2 == NULL) {
FreePool (AttemptName1);
return EFI_OUT_OF_RESOURCES;
@@ -1270,7 +1276,7 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Warning! \"%s\" uses same NIC as Attempt \"%s\".",
AttemptName1,
AttemptName2
@@ -1288,9 +1294,9 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( }
}
- if (IfrNvData->Enabled == ISCSI_DISABLED &&
- Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
-
+ if ((IfrNvData->Enabled == ISCSI_DISABLED) &&
+ (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED))
+ {
//
// User updates the Attempt from "Enabled"/"Enabled for MPIO" to "Disabled".
//
@@ -1306,11 +1312,12 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( if (mPrivate->SinglePathCount < 1) {
return EFI_ABORTED;
}
+
mPrivate->SinglePathCount--;
}
-
- } else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO &&
- Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) {
+ } else if ((IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) &&
+ (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED))
+ {
//
// User updates the Attempt from "Enabled" to "Enabled for MPIO".
//
@@ -1321,9 +1328,9 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( mPrivate->EnableMpio = TRUE;
mPrivate->MpioCount++;
mPrivate->SinglePathCount--;
-
- } else if (IfrNvData->Enabled == ISCSI_ENABLED &&
- Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
+ } else if ((IfrNvData->Enabled == ISCSI_ENABLED) &&
+ (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO))
+ {
//
// User updates the Attempt from "Enabled for MPIO" to "Enabled".
//
@@ -1334,61 +1341,62 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( if (--mPrivate->MpioCount == 0) {
mPrivate->EnableMpio = FALSE;
}
- mPrivate->SinglePathCount++;
- } else if (IfrNvData->Enabled != ISCSI_DISABLED &&
- Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) {
+ 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;
+ 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);
+ 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);
+ AttemptIndex = (UINT8)((OffSet - ATTEMPT_CONNECT_RETRY_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
if (IfrNvData->ISCSIConnectRetry[AttemptIndex - 1] > CONNECT_MAX_RETRY) {
CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"The minimum value is 0 and the maximum is 16. 0 means no retry.",
- NULL
- );
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"The minimum value is 0 and the maximum is 16. 0 means no retry.",
+ NULL
+ );
return EFI_INVALID_PARAMETER;
}
- Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1];
+ Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1];
} 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);
+ AttemptIndex = (UINT8)((OffSet - ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) / 2 + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
if ((IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] < CONNECT_MIN_TIMEOUT) ||
- (IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TIMEOUT)) {
+ (IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TIMEOUT))
+ {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@@ -1402,18 +1410,17 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( if (Attempt->SessionConfigData.ConnectTimeout == 0) {
Attempt->SessionConfigData.ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
}
-
} else if ((OffSet >= ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET)) {
- AttemptIndex = (UINT8) ((OffSet - ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) + 1);
- Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ 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];
+ Attempt->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData->ISCSIInitiatorInfoViaDHCP[AttemptIndex - 1];
} 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);
+ AttemptIndex = (UINT8)((OffSet - ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) + 1);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1429,13 +1436,13 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) && (OffSet < ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET)) {
- AttemptIndex = (UINT8) ((OffSet - ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) / 2 + 1);
- Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ 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) {
@@ -1450,30 +1457,28 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
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);
+ 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_ISID_VAR_OFFSET)) {
- AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CHARTYPE_VAR_OFFSET) + 1);
- Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ 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_ISID_VAR_OFFSET) {
- Index = (UINT8) ((OffSet - ATTEMPT_ISID_VAR_OFFSET) / sizeof (KEYWORD_STR));
+ Index = (UINT8)((OffSet - ATTEMPT_ISID_VAR_OFFSET) / sizeof (KEYWORD_STR));
AttemptIndex = Index + 1;
- Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
+ Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1482,15 +1487,15 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( if ((OffSet >= ATTEMPT_ISID_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET)) {
IScsiParseIsIdFromString (IfrNvData->Keyword[Index].ISCSIIsId, Attempt->SessionConfigData.IsId);
-
- } else if ((OffSet >= ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET)) {
+ } else if ((OffSet >= ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
//
// Config Local ip
//
Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorIpAddress, &HostIp.v4);
if (EFI_ERROR (Status) || ((Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) &&
- !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) {
+ !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL (*(UINT32 *)Attempt->SessionConfigData.SubnetMask.Addr))))
+ {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@@ -1510,7 +1515,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorNetmask, &SubnetMask.v4);
@@ -1534,13 +1538,13 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_NAME_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorGateway, &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)))) {
+ ((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,
@@ -1560,7 +1564,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_TARGET_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetName, IScsiName, ISCSI_NAME_MAX_SIZE);
@@ -1575,6 +1578,7 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( } else {
AsciiStrCpyS (Attempt->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName);
}
+
if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
if (Attempt->SessionConfigData.TargetName[0] == L'\0') {
CreatePopUp (
@@ -1595,7 +1599,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_LUN_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetIpAddress, IpString, sizeof (IpString));
@@ -1617,14 +1620,13 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_LUN_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_USER_NAME_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (Attempt->SessionConfigData.TargetInfoFromDhcp == 0)) {
//
// Config LUN.
//
UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSILun, LunString, ISCSI_LUN_STR_MAX_LEN);
- Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);
+ Status = IScsiAsciiStrToLun (LunString, (UINT8 *)&Lun);
if (EFI_ERROR (Status)) {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -1644,7 +1646,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_CHAR_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_SECRET_VAR_OFFSET)) {
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
UnicodeStrToAsciiStrS (
@@ -1673,7 +1674,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_CHAR_SECRET_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET)) {
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
ChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIChapSecret);
@@ -1703,7 +1703,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if ((OffSet >= ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET)) {
if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) {
UnicodeStrToAsciiStrS (
@@ -1731,7 +1730,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( );
return EFI_INVALID_PARAMETER;
}
-
} else if (OffSet >= ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) {
if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) {
ReverseChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIReverseChapSecret);
@@ -1764,13 +1762,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( }
}
-
-
//
// Record the user configuration information in NVR.
//
ASSERT (Attempt != NULL);
- UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex);
+ UnicodeSPrint (mPrivate->PortString, (UINTN)ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex);
return gRT->SetVariable (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
@@ -1778,7 +1774,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
Attempt
);
-
}
/**
@@ -1799,18 +1794,18 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( **/
EFI_STATUS
IScsiCreateOpCode (
- IN UINT16 StartLabelNumber,
- OUT VOID **StartOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **StartLabel,
- OUT VOID **EndOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **EndLabel
+ 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;
+ EFI_STATUS Status;
+ EFI_IFR_GUID_LABEL *InternalStartLabel;
+ EFI_IFR_GUID_LABEL *InternalEndLabel;
- if (StartOpCodeHandle == NULL || StartLabel == NULL || EndOpCodeHandle == NULL || EndLabel == NULL) {
+ if ((StartOpCodeHandle == NULL) || (StartLabel == NULL) || (EndOpCodeHandle == NULL) || (EndLabel == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1834,12 +1829,12 @@ IScsiCreateOpCode ( //
// Create Hii Extend Label OpCode as the start opcode.
//
- InternalStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- *StartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ InternalStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ *StartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
if (InternalStartLabel == NULL) {
goto Exit;
}
@@ -1850,12 +1845,12 @@ IScsiCreateOpCode ( //
// Create Hii Extend Label OpCode as the end opcode.
//
- InternalEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- *EndOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ InternalEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ *EndOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
if (InternalEndLabel == NULL) {
goto Exit;
}
@@ -1877,6 +1872,7 @@ Exit: if (*EndOpCodeHandle != NULL) {
HiiFreeOpCodeHandle (*EndOpCodeHandle);
}
+
return Status;
}
@@ -1889,13 +1885,13 @@ 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;
+ 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,
@@ -1905,7 +1901,7 @@ IScsiConfigUpdateAttempt ( &EndLabel
);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
@@ -1914,7 +1910,7 @@ IScsiConfigUpdateAttempt ( //
// Update Attempt Help Info.
//
- UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", (UINTN) AttemptConfigData->AttemptConfigIndex);
+ UnicodeSPrint (mPrivate->PortString, (UINTN)ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", (UINTN)AttemptConfigData->AttemptConfigIndex);
AttemptConfigData->AttemptTitleToken = HiiSetString (
mCallbackInfo->RegisteredHandle,
0,
@@ -1922,16 +1918,16 @@ IScsiConfigUpdateAttempt ( NULL
);
if (AttemptConfigData->AttemptTitleToken == 0) {
- return ;
+ 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
+ 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
);
}
}
@@ -1942,7 +1938,7 @@ IScsiConfigUpdateAttempt ( FORMID_MAIN_FORM, // Form ID
StartOpCodeHandle, // Label for where to insert opcodes
EndOpCodeHandle // Replace data
- );
+ );
HiiFreeOpCodeHandle (StartOpCodeHandle);
HiiFreeOpCodeHandle (EndOpCodeHandle);
@@ -1961,16 +1957,16 @@ IScsiConfigAddAttempt ( VOID
)
{
- LIST_ENTRY *Entry;
- ISCSI_NIC_INFO *NicInfo;
- EFI_STRING_ID PortTitleToken;
- EFI_STRING_ID PortTitleHelpToken;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- EFI_STATUS Status;
- VOID *StartOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *EndLabel;
+ LIST_ENTRY *Entry;
+ ISCSI_NIC_INFO *NicInfo;
+ EFI_STRING_ID PortTitleToken;
+ EFI_STRING_ID PortTitleHelpToken;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ EFI_STATUS Status;
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
Status = IScsiCreateOpCode (
MAC_ENTRY_LABEL,
@@ -1995,7 +1991,7 @@ IScsiConfigAddAttempt ( MacString
);
- UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"MAC %s", MacString);
+ UnicodeSPrint (mPrivate->PortString, (UINTN)ISCSI_NAME_IFR_MAX_SIZE, L"MAC %s", MacString);
PortTitleToken = HiiSetString (
mCallbackInfo->RegisteredHandle,
0,
@@ -2009,7 +2005,7 @@ IScsiConfigAddAttempt ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"PFA: Bus %d | Dev %d | Func %d",
NicInfo->BusNumber,
NicInfo->DeviceNumber,
@@ -2027,7 +2023,7 @@ IScsiConfigAddAttempt ( PortTitleToken,
PortTitleHelpToken,
EFI_IFR_FLAG_CALLBACK, // Question flag
- (UINT16) (KEY_MAC_ENTRY_BASE + NicInfo->NicIndex)
+ (UINT16)(KEY_MAC_ENTRY_BASE + NicInfo->NicIndex)
);
}
@@ -2062,24 +2058,24 @@ Exit: **/
EFI_STATUS
IScsiConfigAddAttemptsByKeywords (
- IN UINT8 *AttemptList
+ IN UINT8 *AttemptList
)
{
- 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;
-
- Nic = mPrivate->CurrentNic;
+ 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;
+
+ Nic = mPrivate->CurrentNic;
NicInfo = IScsiGetNicInfoByIndex (Nic);
if (NicInfo == NULL) {
return EFI_NOT_FOUND;
@@ -2107,22 +2103,22 @@ IScsiConfigAddAttemptsByKeywords ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (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) {
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID **)&AttemptConfigData,
+ NULL
+ );
+ if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED)) {
return EFI_INVALID_PARAMETER;
}
- AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED;
+ AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED;
AttemptConfigData->NicIndex = NicInfo->NicIndex;
UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, ISCSI_MAX_MAC_STRING_LEN);
@@ -2131,7 +2127,7 @@ IScsiConfigAddAttemptsByKeywords ( //
CopyMem (AttemptConfigData->SessionConfigData.IsId, &NicInfo->PermanentAddress, 6);
AttemptConfigData->SessionConfigData.IsId[0] =
- (UINT8) (AttemptConfigData->SessionConfigData.IsId[0] & 0x3F);
+ (UINT8)(AttemptConfigData->SessionConfigData.IsId[0] & 0x3F);
//
// Configure the iSCSI Mode and IpMode to default.
@@ -2141,7 +2137,7 @@ IScsiConfigAddAttemptsByKeywords ( UnicodeSPrint (IpMode, 64, L"IP4");
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (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,
@@ -2180,16 +2176,18 @@ IScsiConfigAddAttemptsByKeywords ( 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);
+ AttemptConfigOrder = AttemptConfigOrderTmp;
+ AttemptConfigOrderSize = TotalNumber * sizeof (UINT8);
Status = gRT->SetVariable (
L"AttemptOrder",
@@ -2208,7 +2206,7 @@ IScsiConfigAddAttemptsByKeywords ( //
InsertTailList (&mPrivate->AttemptConfigs, &AttemptConfigData->Link);
mPrivate->AttemptCount++;
- UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", AttemptConfigData->AttemptConfigIndex);
+ UnicodeSPrint (mPrivate->PortString, (UINTN)ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", AttemptConfigData->AttemptConfigIndex);
gRT->SetVariable (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
@@ -2216,7 +2214,6 @@ IScsiConfigAddAttemptsByKeywords ( sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
AttemptConfigData
);
-
}
return EFI_SUCCESS;
@@ -2240,22 +2237,22 @@ 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;
- UINT8 AttemptConfigIndex;
- UINT32 Attribute;
- UINTN Total;
- UINTN NewTotal;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigData;
-
- Index = 0;
+ 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",
@@ -2324,6 +2321,7 @@ IScsiConfigDeleteAttempts ( if (AttemptConfigData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
ConfigData = &AttemptConfigData->SessionConfigData;
ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
@@ -2341,9 +2339,9 @@ IScsiConfigDeleteAttempts ( //
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
+ (UINTN)AttemptConfigData->AttemptConfigIndex
);
UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE);
gRT->SetVariable (
@@ -2368,6 +2366,7 @@ IScsiConfigDeleteAttempts ( if (mCallbackInfo->Current == AttemptConfigData) {
mCallbackInfo->Current = NULL;
}
+
FreePool (AttemptConfigData);
//
@@ -2411,7 +2410,6 @@ Error: return Status;
}
-
/**
Callback function when user presses "Delete Attempts".
@@ -2427,17 +2425,16 @@ IScsiConfigDisplayDeleteAttempts ( IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
-
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- LIST_ENTRY *Entry;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- UINT8 Index;
- VOID *StartOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *EndLabel;
- EFI_STATUS Status;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ LIST_ENTRY *Entry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ UINT8 Index;
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ EFI_STATUS Status;
Status = IScsiCreateOpCode (
DELETE_ENTRY_LABEL,
@@ -2462,14 +2459,14 @@ IScsiConfigDisplayDeleteAttempts ( Index = 0;
NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
- AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
+ AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
IfrNvData->DeleteAttemptList[Index] = 0x00;
- HiiCreateCheckBoxOpCode(
+ HiiCreateCheckBoxOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_DEL_QUESTION_ID + Index),
+ (EFI_QUESTION_ID)(ATTEMPT_DEL_QUESTION_ID + Index),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_DEL_VAR_OFFSET + Index),
+ (UINT16)(ATTEMPT_DEL_VAR_OFFSET + Index),
AttemptConfigData->AttemptTitleToken,
AttemptConfigData->AttemptTitleHelpToken,
0,
@@ -2501,7 +2498,6 @@ IScsiConfigDisplayDeleteAttempts ( return Status;
}
-
/**
Callback function when user presses "Change Attempt Order".
@@ -2516,15 +2512,15 @@ IScsiConfigDisplayOrderAttempts ( VOID
)
{
- EFI_STATUS Status;
- UINT8 Index;
- LIST_ENTRY *Entry;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- VOID *StartOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *EndLabel;
- VOID *OptionsOpCodeHandle;
+ EFI_STATUS Status;
+ UINT8 Index;
+ LIST_ENTRY *Entry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ VOID *OptionsOpCodeHandle;
Status = IScsiCreateOpCode (
ORDER_ENTRY_LABEL,
@@ -2536,6 +2532,7 @@ IScsiConfigDisplayOrderAttempts ( if (EFI_ERROR (Status)) {
return Status;
}
+
ASSERT (StartOpCodeHandle != NULL);
OptionsOpCodeHandle = NULL;
@@ -2622,14 +2619,14 @@ IScsiConfigOrderAttempts ( IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN Indexj;
- UINT8 AttemptConfigIndex;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- UINT8 *AttemptConfigOrder;
- UINT8 *AttemptConfigOrderTmp;
- UINTN AttemptConfigOrderSize;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Indexj;
+ UINT8 AttemptConfigIndex;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ UINT8 *AttemptConfigOrder;
+ UINT8 *AttemptConfigOrderTmp;
+ UINTN AttemptConfigOrderSize;
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
@@ -2683,7 +2680,7 @@ IScsiConfigOrderAttempts ( //
// Adjust the attempt order in NVR.
//
- for (; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
+ for ( ; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
for (Indexj = 0; Indexj < AttemptConfigOrderSize / sizeof (UINT8); Indexj++) {
if (AttemptConfigOrder[Indexj] != 0) {
AttemptConfigOrderTmp[Index] = AttemptConfigOrder[Indexj];
@@ -2710,7 +2707,6 @@ Exit: return Status;
}
-
/**
Callback function when a user presses "Attempt *" or when a user selects a NIC to
create the new attempt.
@@ -2729,20 +2725,20 @@ Exit: **/
EFI_STATUS
IScsiConfigProcessDefault (
- IN EFI_QUESTION_ID KeyValue,
- IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
+ IN EFI_QUESTION_ID KeyValue,
+ IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
- BOOLEAN NewAttempt;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- UINT8 CurrentAttemptConfigIndex;
- ISCSI_NIC_INFO *NicInfo;
- UINT8 NicIndex;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
- EFI_INPUT_KEY Key;
+ BOOLEAN NewAttempt;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ UINT8 CurrentAttemptConfigIndex;
+ ISCSI_NIC_INFO *NicInfo;
+ UINT8 NicIndex;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
+ EFI_INPUT_KEY Key;
AttemptConfigData = NULL;
//
@@ -2751,14 +2747,15 @@ IScsiConfigProcessDefault ( NewAttempt = FALSE;
if ((KeyValue >= KEY_MAC_ENTRY_BASE) &&
- (KeyValue <= (UINT16) (mPrivate->MaxNic + KEY_MAC_ENTRY_BASE))) {
+ (KeyValue <= (UINT16)(mPrivate->MaxNic + KEY_MAC_ENTRY_BASE)))
+ {
//
// User has pressed "Add an Attempt" and then selects a NIC.
//
NewAttempt = TRUE;
} else if ((KeyValue >= KEY_ATTEMPT_ENTRY_BASE) &&
- (KeyValue < (ISCSI_MAX_ATTEMPTS_NUM + KEY_ATTEMPT_ENTRY_BASE))) {
-
+ (KeyValue < (ISCSI_MAX_ATTEMPTS_NUM + KEY_ATTEMPT_ENTRY_BASE)))
+ {
//
// User has pressed "Attempt *".
//
@@ -2774,8 +2771,8 @@ IScsiConfigProcessDefault ( //
// Determine which NIC user has selected for the new created attempt.
//
- NicIndex = (UINT8) (KeyValue - KEY_MAC_ENTRY_BASE);
- NicInfo = IScsiGetNicInfoByIndex (NicIndex);
+ NicIndex = (UINT8)(KeyValue - KEY_MAC_ENTRY_BASE);
+ NicInfo = IScsiGetNicInfoByIndex (NicIndex);
if (NicInfo == NULL) {
return EFI_NOT_FOUND;
}
@@ -2796,17 +2793,17 @@ IScsiConfigProcessDefault ( for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
- if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID **)&AttemptConfigData,
+ NULL
+ );
+ if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED)) {
continue;
}
@@ -2840,21 +2837,21 @@ IScsiConfigProcessDefault ( ASSERT (AttemptConfigData != NULL);
UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, sizeof (AttemptConfigData->MacString));
AttemptConfigData->NicIndex = NicIndex;
- AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED;
+ AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED;
//
// 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);
+ (UINT8)(AttemptConfigData->SessionConfigData.IsId[0] & 0x3F);
//
// Add the help info for the new attempt.
//
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"MAC: %s, PFA: Bus %d | Dev %d | Func %d",
MacString,
NicInfo->BusNumber,
@@ -2862,23 +2859,22 @@ IScsiConfigProcessDefault ( NicInfo->FunctionNumber
);
- AttemptConfigData->AttemptTitleHelpToken = HiiSetString (
- mCallbackInfo->RegisteredHandle,
- 0,
- mPrivate->PortString,
- NULL
- );
+ AttemptConfigData->AttemptTitleHelpToken = HiiSetString (
+ mCallbackInfo->RegisteredHandle,
+ 0,
+ mPrivate->PortString,
+ NULL
+ );
if (AttemptConfigData->AttemptTitleHelpToken == 0) {
FreePool (AttemptConfigData);
return EFI_OUT_OF_RESOURCES;
}
-
} else {
//
// Determine which Attempt user has selected to configure.
// Get the attempt configuration data.
//
- CurrentAttemptConfigIndex = (UINT8) (KeyValue - KEY_ATTEMPT_ENTRY_BASE);
+ CurrentAttemptConfigIndex = (UINT8)(KeyValue - KEY_ATTEMPT_ENTRY_BASE);
AttemptConfigData = IScsiConfigGetAttemptByConfigIndex (CurrentAttemptConfigIndex);
if (AttemptConfigData == NULL) {
@@ -2907,7 +2903,6 @@ IScsiConfigProcessDefault ( return EFI_SUCCESS;
}
-
/**
This function allows the caller to request the current
@@ -2982,23 +2977,23 @@ IScsiConfigProcessDefault ( EFI_STATUS
EFIAPI
IScsiFormExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- EFI_STATUS Status;
- CHAR8 *InitiatorName;
- UINTN BufferSize;
- ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
- ISCSI_FORM_CALLBACK_INFO *Private;
- EFI_STRING ConfigRequestHdr;
- EFI_STRING ConfigRequest;
- BOOLEAN AllocatedRequest;
- UINTN Size;
-
- if (This == NULL || Progress == NULL || Results == NULL) {
+ EFI_STATUS Status;
+ CHAR8 *InitiatorName;
+ UINTN BufferSize;
+ ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
+ ISCSI_FORM_CALLBACK_INFO *Private;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ BOOLEAN AllocatedRequest;
+ UINTN Size;
+
+ if ((This == NULL) || (Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -3012,14 +3007,13 @@ IScsiFormExtractConfig ( AllocatedRequest = FALSE;
Size = 0;
- Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
+ 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);
}
@@ -3029,7 +3023,7 @@ IScsiFormExtractConfig ( IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (IfrNvData);
BufferSize = ISCSI_NAME_MAX_SIZE;
- InitiatorName = (CHAR8 *) AllocateZeroPool (BufferSize);
+ InitiatorName = (CHAR8 *)AllocateZeroPool (BufferSize);
if (InitiatorName == NULL) {
FreePool (IfrNvData);
return EFI_OUT_OF_RESOURCES;
@@ -3049,7 +3043,7 @@ IScsiFormExtractConfig ( //
// Convert buffer data to <ConfigResp> by helper function BlockToConfig().
//
- BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
+ BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
@@ -3058,13 +3052,14 @@ IScsiFormExtractConfig ( // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
ConfigRequestHdr = HiiConstructConfigHdr (&gIScsiConfigGuid, mVendorStorageName, Private->DriverHandle);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
- ConfigRequest = AllocateZeroPool (Size);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ ConfigRequest = AllocateZeroPool (Size);
if (ConfigRequest == NULL) {
FreePool (IfrNvData);
FreePool (InitiatorName);
return EFI_OUT_OF_RESOURCES;
}
+
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
@@ -3073,7 +3068,7 @@ IScsiFormExtractConfig ( Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
- (UINT8 *) IfrNvData,
+ (UINT8 *)IfrNvData,
BufferSize,
Results,
Progress
@@ -3088,6 +3083,7 @@ IScsiFormExtractConfig ( FreePool (ConfigRequest);
ConfigRequest = NULL;
}
+
//
// Set Progress string to the original request string.
//
@@ -3100,7 +3096,6 @@ IScsiFormExtractConfig ( return Status;
}
-
/**
This function applies changes in a driver's configuration.
@@ -3144,33 +3139,33 @@ IScsiFormExtractConfig ( EFI_STATUS
EFIAPI
IScsiFormRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ 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;
+ 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;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- if (This == NULL || Configuration == NULL || Progress == NULL) {
+ if ((This == NULL) || (Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -3189,7 +3184,7 @@ IScsiFormRouteConfig ( }
BufferSize = ISCSI_NAME_MAX_SIZE;
- InitiatorName = (CHAR8 *) AllocateZeroPool (BufferSize);
+ InitiatorName = (CHAR8 *)AllocateZeroPool (BufferSize);
if (InitiatorName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
@@ -3199,22 +3194,22 @@ IScsiFormRouteConfig ( // Convert <ConfigResp> to buffer data by helper function ConfigToBlock().
//
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
- Status = gHiiConfigRouting->ConfigToBlock (
- gHiiConfigRouting,
- Configuration,
- (UINT8 *) IfrNvData,
- &BufferSize,
- Progress
- );
+ 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);
+ BufferSize = AsciiStrSize (InitiatorName);
- Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, InitiatorName);
+ Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, InitiatorName);
if (EFI_ERROR (Status)) {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -3246,14 +3241,14 @@ IScsiFormRouteConfig ( }
if (IfrNvData->ISCSIAddAttemptList[0] != L'\0') {
- Status =IScsiGetAttemptIndexList (IfrNvData->ISCSIAddAttemptList, IfrNvData->AddAttemptList, TRUE);
+ 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
- );
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: The add attempt list is invalid",
+ NULL
+ );
goto Exit;
}
@@ -3261,21 +3256,21 @@ IScsiFormRouteConfig ( if (EFI_ERROR (Status)) {
goto Exit;
}
-
} else if (IfrNvData->ISCSIDeleteAttemptList[0] != L'\0') {
- AttemptList =(UINT8 *) AllocateZeroPool ((ISCSI_MAX_ATTEMPTS_NUM + 1) * sizeof (UINT8));
+ 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
- );
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: The delete attempt list is invalid",
+ NULL
+ );
goto Exit;
}
@@ -3289,9 +3284,11 @@ IScsiFormRouteConfig ( IfrNvData->DeleteAttemptList[Index2] = 1;
break;
}
- Index ++;
+
+ Index++;
}
- Index2 ++;
+
+ Index2++;
Index = 0;
}
@@ -3301,16 +3298,15 @@ IScsiFormRouteConfig ( }
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
- );
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: The new attempt order list is invalid",
+ NULL
+ );
goto Exit;
}
@@ -3318,17 +3314,16 @@ IScsiFormRouteConfig ( 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)) {
+ &NicInfo->PermanentAddress,
+ NicInfo->HwAddressSize,
+ NicInfo->VlanId,
+ MacString
+ );
+ if (!StrCmp (MacString, IfrNvData->ISCSIMacAddr)) {
mPrivate->CurrentNic = NicInfo->NicIndex;
break;
}
@@ -3338,7 +3333,6 @@ IScsiFormRouteConfig ( Status = EFI_NOT_FOUND;
goto Exit;
}
-
} else {
Status = IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (IfrNvData, OffSet);
if (EFI_ERROR (Status)) {
@@ -3389,28 +3383,28 @@ Exit: EFI_STATUS
EFIAPI
IScsiFormCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN OUT EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN OUT EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- ISCSI_FORM_CALLBACK_INFO *Private;
- UINTN BufferSize;
- CHAR8 *IScsiName;
- CHAR8 IpString[ISCSI_NAME_MAX_SIZE];
- CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN];
- UINT64 Lun;
- EFI_IP_ADDRESS HostIp;
- EFI_IP_ADDRESS SubnetMask;
- EFI_IP_ADDRESS Gateway;
- ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
- ISCSI_CONFIG_IFR_NVDATA OldIfrNvData;
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- ISCSI_NIC_INFO *NicInfo;
+ ISCSI_FORM_CALLBACK_INFO *Private;
+ UINTN BufferSize;
+ CHAR8 *IScsiName;
+ CHAR8 IpString[ISCSI_NAME_MAX_SIZE];
+ CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN];
+ UINT64 Lun;
+ EFI_IP_ADDRESS HostIp;
+ EFI_IP_ADDRESS SubnetMask;
+ EFI_IP_ADDRESS Gateway;
+ ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
+ ISCSI_CONFIG_IFR_NVDATA OldIfrNvData;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ ISCSI_NIC_INFO *NicInfo;
NicInfo = NULL;
@@ -3439,12 +3433,12 @@ IScsiFormCallback ( //
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
- IfrNvData = AllocateZeroPool (BufferSize);
+ IfrNvData = AllocateZeroPool (BufferSize);
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- IScsiName = (CHAR8 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
+ IScsiName = (CHAR8 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
if (IScsiName == NULL) {
FreePool (IfrNvData);
return EFI_OUT_OF_RESOURCES;
@@ -3454,332 +3448,334 @@ IScsiFormCallback ( ZeroMem (&OldIfrNvData, BufferSize);
- HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);
+ HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *)IfrNvData);
CopyMem (&OldIfrNvData, IfrNvData, BufferSize);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
- case KEY_ADD_ATTEMPT:
- //
- // Check whether iSCSI initiator name is configured already.
- //
- mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE;
- Status = gIScsiInitiatorName.Get (
- &gIScsiInitiatorName,
- &mPrivate->InitiatorNameLength,
- mPrivate->InitiatorName
- );
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Error: please configure iSCSI initiator name first!",
- NULL
- );
- break;
- }
+ case KEY_ADD_ATTEMPT:
+ //
+ // Check whether iSCSI initiator name is configured already.
+ //
+ mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE;
+ Status = gIScsiInitiatorName.Get (
+ &gIScsiInitiatorName,
+ &mPrivate->InitiatorNameLength,
+ mPrivate->InitiatorName
+ );
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Error: please configure iSCSI initiator name first!",
+ NULL
+ );
+ break;
+ }
- Status = IScsiConfigAddAttempt ();
- break;
+ Status = IScsiConfigAddAttempt ();
+ break;
- case KEY_DELETE_ATTEMPT:
- CopyMem (
- OldIfrNvData.DeleteAttemptList,
- IfrNvData->DeleteAttemptList,
- sizeof (IfrNvData->DeleteAttemptList)
- );
- Status = IScsiConfigDisplayDeleteAttempts (IfrNvData);
- break;
+ case KEY_DELETE_ATTEMPT:
+ CopyMem (
+ OldIfrNvData.DeleteAttemptList,
+ IfrNvData->DeleteAttemptList,
+ sizeof (IfrNvData->DeleteAttemptList)
+ );
+ Status = IScsiConfigDisplayDeleteAttempts (IfrNvData);
+ break;
- case KEY_ORDER_ATTEMPT_CONFIG:
- //
- // Order the attempt according to user input.
- //
- CopyMem (
- OldIfrNvData.DynamicOrderedList,
- IfrNvData->DynamicOrderedList,
- sizeof (IfrNvData->DynamicOrderedList)
- );
- IScsiConfigDisplayOrderAttempts ();
- break;
+ case KEY_ORDER_ATTEMPT_CONFIG:
+ //
+ // Order the attempt according to user input.
+ //
+ CopyMem (
+ OldIfrNvData.DynamicOrderedList,
+ IfrNvData->DynamicOrderedList,
+ sizeof (IfrNvData->DynamicOrderedList)
+ );
+ IScsiConfigDisplayOrderAttempts ();
+ break;
- default:
- Status = IScsiConfigProcessDefault (QuestionId, IfrNvData);
- break;
+ default:
+ Status = IScsiConfigProcessDefault (QuestionId, IfrNvData);
+ break;
}
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (QuestionId) {
- case KEY_INITIATOR_NAME:
- UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, IScsiName, ISCSI_NAME_MAX_SIZE);
- BufferSize = AsciiStrSize (IScsiName);
+ case KEY_INITIATOR_NAME:
+ UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, IScsiName, ISCSI_NAME_MAX_SIZE);
+ BufferSize = AsciiStrSize (IScsiName);
- Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, IScsiName);
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid iSCSI Name!",
- NULL
- );
- }
+ Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, IScsiName);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid iSCSI Name!",
+ NULL
+ );
+ }
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
- break;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
+ break;
- case KEY_SAVE_ATTEMPT_CONFIG:
- Status = IScsiConvertIfrNvDataToAttemptConfigData (IfrNvData, Private->Current);
- if (EFI_ERROR (Status)) {
+ case KEY_SAVE_ATTEMPT_CONFIG:
+ Status = IScsiConvertIfrNvDataToAttemptConfigData (IfrNvData, Private->Current);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
break;
- }
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
- break;
+ case KEY_SAVE_ORDER_CHANGES:
+ //
+ // Sync the Attempt Order to NVR.
+ //
+ Status = IScsiConfigOrderAttempts (IfrNvData);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
- case KEY_SAVE_ORDER_CHANGES:
- //
- // Sync the Attempt Order to NVR.
- //
- Status = IScsiConfigOrderAttempts (IfrNvData);
- if (EFI_ERROR (Status)) {
+ IScsiConfigUpdateAttempt ();
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
break;
- }
- IScsiConfigUpdateAttempt ();
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
- break;
+ case KEY_IGNORE_ORDER_CHANGES:
+ CopyMem (
+ IfrNvData->DynamicOrderedList,
+ OldIfrNvData.DynamicOrderedList,
+ sizeof (IfrNvData->DynamicOrderedList)
+ );
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ break;
- case KEY_IGNORE_ORDER_CHANGES:
- CopyMem (
- IfrNvData->DynamicOrderedList,
- OldIfrNvData.DynamicOrderedList,
- sizeof (IfrNvData->DynamicOrderedList)
- );
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- break;
+ case KEY_SAVE_DELETE_ATTEMPT:
+ //
+ // Delete the Attempt Order from NVR
+ //
+ Status = IScsiConfigDeleteAttempts (IfrNvData);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
- case KEY_SAVE_DELETE_ATTEMPT:
- //
- // Delete the Attempt Order from NVR
- //
- Status = IScsiConfigDeleteAttempts (IfrNvData);
- if (EFI_ERROR (Status)) {
+ IScsiConfigUpdateAttempt ();
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
break;
- }
- IScsiConfigUpdateAttempt ();
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
- break;
+ case KEY_IGNORE_DELETE_ATTEMPT:
+ CopyMem (
+ IfrNvData->DeleteAttemptList,
+ OldIfrNvData.DeleteAttemptList,
+ sizeof (IfrNvData->DeleteAttemptList)
+ );
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ break;
- case KEY_IGNORE_DELETE_ATTEMPT:
- CopyMem (
- IfrNvData->DeleteAttemptList,
- OldIfrNvData.DeleteAttemptList,
- sizeof (IfrNvData->DeleteAttemptList)
- );
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- break;
+ case KEY_IP_MODE:
+ switch (Value->u8) {
+ case IP_MODE_IP6:
+ NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex);
+ if (NicInfo == NULL) {
+ break;
+ }
+
+ if (!NicInfo->Ipv6Available) {
+ //
+ // Current NIC doesn't Support IPv6, hence use IPv4.
+ //
+ IfrNvData->IpMode = IP_MODE_IP4;
+
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Current NIC doesn't Support IPv6!",
+ NULL
+ );
+ }
+
+ case IP_MODE_IP4:
+ ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp));
+ ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask));
+ ZeroMem (IfrNvData->Gateway, sizeof (IfrNvData->Gateway));
+ ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
+ Private->Current->AutoConfigureMode = 0;
+ ZeroMem (&Private->Current->SessionConfigData.LocalIp, sizeof (EFI_IP_ADDRESS));
+ ZeroMem (&Private->Current->SessionConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
+ ZeroMem (&Private->Current->SessionConfigData.Gateway, sizeof (EFI_IP_ADDRESS));
+ ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (EFI_IP_ADDRESS));
- case KEY_IP_MODE:
- switch (Value->u8) {
- case IP_MODE_IP6:
- NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex);
- if(NicInfo == NULL) {
- break;
+ break;
}
- if(!NicInfo->Ipv6Available) {
- //
- // Current NIC doesn't Support IPv6, hence use IPv4.
- //
- IfrNvData->IpMode = IP_MODE_IP4;
+ break;
+ case KEY_LOCAL_IP:
+ Status = NetLibStrToIp4 (IfrNvData->LocalIp, &HostIp.v4);
+ if (EFI_ERROR (Status) ||
+ ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
+ !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL (*(UINT32 *)Private->Current->SessionConfigData.SubnetMask.Addr))))
+ {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
- L"Current NIC doesn't Support IPv6!",
+ L"Invalid IP address!",
NULL
);
- }
- case IP_MODE_IP4:
- ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp));
- ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask));
- ZeroMem (IfrNvData->Gateway, sizeof (IfrNvData->Gateway));
- ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
- Private->Current->AutoConfigureMode = 0;
- ZeroMem (&Private->Current->SessionConfigData.LocalIp, sizeof (EFI_IP_ADDRESS));
- ZeroMem (&Private->Current->SessionConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
- ZeroMem (&Private->Current->SessionConfigData.Gateway, sizeof (EFI_IP_ADDRESS));
- ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (EFI_IP_ADDRESS));
+ Status = EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));
+ }
break;
- }
- break;
+ case KEY_SUBNET_MASK:
+ Status = NetLibStrToIp4 (IfrNvData->SubnetMask, &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
+ );
- case KEY_LOCAL_IP:
- Status = NetLibStrToIp4 (IfrNvData->LocalIp, &HostIp.v4);
- if (EFI_ERROR (Status) ||
- ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
- !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid IP address!",
- NULL
- );
+ Status = EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));
+ }
- Status = EFI_INVALID_PARAMETER;
- } else {
- CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));
- }
+ break;
- break;
+ case KEY_GATE_WAY:
+ Status = NetLibStrToIp4 (IfrNvData->Gateway, &Gateway.v4);
+ if (EFI_ERROR (Status) ||
+ ((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,
+ L"Invalid Gateway!",
+ NULL
+ );
+ Status = EFI_INVALID_PARAMETER;
+ } else {
+ CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));
+ }
- case KEY_SUBNET_MASK:
- Status = NetLibStrToIp4 (IfrNvData->SubnetMask, &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
- );
+ break;
- Status = EFI_INVALID_PARAMETER;
- } else {
- CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));
- }
+ case KEY_TARGET_IP:
+ UnicodeStrToAsciiStrS (IfrNvData->TargetIp, IpString, sizeof (IpString));
+ Status = IScsiAsciiStrToIp (IpString, IfrNvData->IpMode, &HostIp);
+ if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, IfrNvData->IpMode)) {
+ //
+ // The target is expressed in URL format or an invalid Ip address, just save.
+ //
+ Private->Current->SessionConfigData.DnsMode = TRUE;
+ ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (Private->Current->SessionConfigData.TargetIp));
+ UnicodeStrToAsciiStrS (IfrNvData->TargetIp, Private->Current->SessionConfigData.TargetUrl, ISCSI_NAME_MAX_SIZE);
+ } else {
+ Private->Current->SessionConfigData.DnsMode = FALSE;
+ CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp, sizeof (HostIp));
+ }
- break;
+ break;
- case KEY_GATE_WAY:
- Status = NetLibStrToIp4 (IfrNvData->Gateway, &Gateway.v4);
- if (EFI_ERROR (Status) ||
- ((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,
- L"Invalid Gateway!",
- NULL
- );
- Status = EFI_INVALID_PARAMETER;
- } else {
- CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));
- }
+ case KEY_TARGET_NAME:
+ UnicodeStrToAsciiStrS (IfrNvData->TargetName, 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 (Private->Current->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName);
+ }
- break;
+ break;
- case KEY_TARGET_IP:
- UnicodeStrToAsciiStrS (IfrNvData->TargetIp, IpString, sizeof (IpString));
- Status = IScsiAsciiStrToIp (IpString, IfrNvData->IpMode, &HostIp);
- if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, IfrNvData->IpMode)) {
- //
- // The target is expressed in URL format or an invalid Ip address, just save.
- //
- Private->Current->SessionConfigData.DnsMode = TRUE;
- ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (Private->Current->SessionConfigData.TargetIp));
- UnicodeStrToAsciiStrS (IfrNvData->TargetIp, Private->Current->SessionConfigData.TargetUrl, ISCSI_NAME_MAX_SIZE);
- } else {
- Private->Current->SessionConfigData.DnsMode = FALSE;
- CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp, sizeof (HostIp));
- }
+ case KEY_DHCP_ENABLE:
+ if (IfrNvData->InitiatorInfoFromDhcp == 0) {
+ IfrNvData->TargetInfoFromDhcp = 0;
+ }
- break;
+ break;
- case KEY_TARGET_NAME:
- UnicodeStrToAsciiStrS (IfrNvData->TargetName, 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 (Private->Current->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName);
- }
+ case KEY_BOOT_LUN:
+ UnicodeStrToAsciiStrS (IfrNvData->BootLun, LunString, sizeof (LunString));
+ Status = IScsiAsciiStrToLun (LunString, (UINT8 *)&Lun);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid LUN string!",
+ NULL
+ );
+ } else {
+ CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));
+ }
- break;
+ break;
- case KEY_DHCP_ENABLE:
- if (IfrNvData->InitiatorInfoFromDhcp == 0) {
- IfrNvData->TargetInfoFromDhcp = 0;
- }
+ case KEY_AUTH_TYPE:
+ switch (Value->u8) {
+ case ISCSI_AUTH_TYPE_CHAP:
+ IfrNvData->CHAPType = ISCSI_CHAP_UNI;
+ break;
+ default:
+ break;
+ }
- break;
+ break;
- case KEY_BOOT_LUN:
- UnicodeStrToAsciiStrS (IfrNvData->BootLun, LunString, sizeof (LunString));
- Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid LUN string!",
- NULL
+ case KEY_CHAP_NAME:
+ UnicodeStrToAsciiStrS (
+ IfrNvData->CHAPName,
+ Private->Current->AuthConfigData.CHAP.CHAPName,
+ sizeof (Private->Current->AuthConfigData.CHAP.CHAPName)
);
- } else {
- CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));
- }
-
- break;
-
- case KEY_AUTH_TYPE:
- switch (Value->u8) {
- case ISCSI_AUTH_TYPE_CHAP:
- IfrNvData->CHAPType = ISCSI_CHAP_UNI;
- break;
- default:
break;
- }
-
- break;
- case KEY_CHAP_NAME:
- UnicodeStrToAsciiStrS (
- IfrNvData->CHAPName,
- Private->Current->AuthConfigData.CHAP.CHAPName,
- sizeof (Private->Current->AuthConfigData.CHAP.CHAPName)
- );
- break;
-
- case KEY_CHAP_SECRET:
- UnicodeStrToAsciiStrS (
- IfrNvData->CHAPSecret,
- Private->Current->AuthConfigData.CHAP.CHAPSecret,
- sizeof (Private->Current->AuthConfigData.CHAP.CHAPSecret)
- );
- break;
+ case KEY_CHAP_SECRET:
+ UnicodeStrToAsciiStrS (
+ IfrNvData->CHAPSecret,
+ Private->Current->AuthConfigData.CHAP.CHAPSecret,
+ sizeof (Private->Current->AuthConfigData.CHAP.CHAPSecret)
+ );
+ break;
- case KEY_REVERSE_CHAP_NAME:
- UnicodeStrToAsciiStrS (
- IfrNvData->ReverseCHAPName,
- Private->Current->AuthConfigData.CHAP.ReverseCHAPName,
- sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPName)
- );
- break;
+ case KEY_REVERSE_CHAP_NAME:
+ UnicodeStrToAsciiStrS (
+ IfrNvData->ReverseCHAPName,
+ Private->Current->AuthConfigData.CHAP.ReverseCHAPName,
+ sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPName)
+ );
+ break;
- case KEY_REVERSE_CHAP_SECRET:
- UnicodeStrToAsciiStrS (
- IfrNvData->ReverseCHAPSecret,
- Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret,
- sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret)
- );
- break;
+ case KEY_REVERSE_CHAP_SECRET:
+ UnicodeStrToAsciiStrS (
+ IfrNvData->ReverseCHAPSecret,
+ Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret,
+ sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret)
+ );
+ break;
- case KEY_CONFIG_ISID:
- IScsiParseIsIdFromString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);
- IScsiConvertIsIdToString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);
+ case KEY_CONFIG_ISID:
+ IScsiParseIsIdFromString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);
+ IScsiConvertIsIdToString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -3788,7 +3784,7 @@ IScsiFormCallback ( // Pass changed uncommitted data back to Form Browser.
//
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
- HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);
+ HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *)IfrNvData, NULL);
}
FreePool (IfrNvData);
@@ -3797,7 +3793,6 @@ IScsiFormCallback ( return Status;
}
-
/**
Initialize the iSCSI configuration form.
@@ -3812,16 +3807,16 @@ IScsiConfigFormInit ( IN EFI_HANDLE DriverBindingHandle
)
{
- EFI_STATUS Status;
- ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
+ EFI_STATUS Status;
+ ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
- CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) AllocateZeroPool (sizeof (ISCSI_FORM_CALLBACK_INFO));
+ CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *)AllocateZeroPool (sizeof (ISCSI_FORM_CALLBACK_INFO));
if (CallbackInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- CallbackInfo->Signature = ISCSI_FORM_CALLBACK_INFO_SIGNATURE;
- CallbackInfo->Current = NULL;
+ CallbackInfo->Signature = ISCSI_FORM_CALLBACK_INFO_SIGNATURE;
+ CallbackInfo->Current = NULL;
CallbackInfo->ConfigAccess.ExtractConfig = IScsiFormExtractConfig;
CallbackInfo->ConfigAccess.RouteConfig = IScsiFormRouteConfig;
@@ -3859,7 +3854,7 @@ IScsiConfigFormInit ( &CallbackInfo->ConfigAccess,
NULL
);
- FreePool(CallbackInfo);
+ FreePool (CallbackInfo);
return EFI_OUT_OF_RESOURCES;
}
@@ -3868,7 +3863,6 @@ IScsiConfigFormInit ( return EFI_SUCCESS;
}
-
/**
Unload the iSCSI configuration form, this includes: delete all the iSCSI
configuration entries, uninstall the form callback protocol, and
@@ -3885,13 +3879,13 @@ IScsiConfigFormUnload ( IN EFI_HANDLE DriverBindingHandle
)
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_NIC_INFO *NicInfo;
- LIST_ENTRY *Entry;
- EFI_STATUS Status;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ EFI_STATUS Status;
while (!IsListEmpty (&mPrivate->AttemptConfigs)) {
- Entry = NetListRemoveHead (&mPrivate->AttemptConfigs);
+ Entry = NetListRemoveHead (&mPrivate->AttemptConfigs);
AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
FreePool (AttemptConfigData);
mPrivate->AttemptCount--;
@@ -3900,7 +3894,7 @@ IScsiConfigFormUnload ( ASSERT (mPrivate->AttemptCount == 0);
while (!IsListEmpty (&mPrivate->NicInfoList)) {
- Entry = NetListRemoveHead (&mPrivate->NicInfoList);
+ Entry = NetListRemoveHead (&mPrivate->NicInfoList);
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
FreePool (NicInfo);
mPrivate->NicCount--;
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.h b/NetworkPkg/IScsiDxe/IScsiConfig.h index 2125351ce8..1f9ec1fdb7 100644 --- a/NetworkPkg/IScsiDxe/IScsiConfig.h +++ b/NetworkPkg/IScsiDxe/IScsiConfig.h @@ -14,10 +14,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent typedef struct _ISCSI_FORM_CALLBACK_INFO ISCSI_FORM_CALLBACK_INFO;
-extern UINT8 IScsiConfigVfrBin[];
-extern UINT8 IScsiDxeStrings[];
-extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
-
+extern UINT8 IScsiConfigVfrBin[];
+extern UINT8 IScsiDxeStrings[];
+extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
#define VAR_OFFSET(Field) \
((UINT16) ((UINTN) &(((ISCSI_CONFIG_IFR_NVDATA *) 0)->Field)))
@@ -25,65 +24,64 @@ extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo; #define QUESTION_ID(Field) \
((UINT16) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET))
-#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)
+#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)
//
// Define QuestionId and OffSet for Keywords.
//
-#define ATTEMPT_MAC_ADDR_VAR_OFFSET VAR_OFFSET (ISCSIMacAddr)
-#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"
-
-#define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)
+#define ATTEMPT_MAC_ADDR_VAR_OFFSET VAR_OFFSET (ISCSIMacAddr)
+#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"
+
+#define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)
#define ISCSI_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'f', 'c', 'i')
@@ -97,47 +95,47 @@ extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo; #pragma pack(1)
struct _ISCSI_ATTEMPT_CONFIG_NVDATA {
- LIST_ENTRY Link;
- UINT8 NicIndex;
- UINT8 AttemptConfigIndex;
- BOOLEAN DhcpSuccess;
- BOOLEAN ValidiBFTPath;
- BOOLEAN ValidPath;
- UINT8 AutoConfigureMode;
- EFI_STRING_ID AttemptTitleToken;
- EFI_STRING_ID AttemptTitleHelpToken;
- 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;
+ LIST_ENTRY Link;
+ UINT8 NicIndex;
+ UINT8 AttemptConfigIndex;
+ BOOLEAN DhcpSuccess;
+ BOOLEAN ValidiBFTPath;
+ BOOLEAN ValidPath;
+ UINT8 AutoConfigureMode;
+ EFI_STRING_ID AttemptTitleToken;
+ EFI_STRING_ID AttemptTitleHelpToken;
+ 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;
+ ISCSI_CHAP_AUTH_CONFIG_NVDATA CHAP;
} AuthConfigData;
- BOOLEAN AutoConfigureSuccess;
- UINT8 Actived;
+ BOOLEAN AutoConfigureSuccess;
+ UINT8 Actived;
};
///
/// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
#pragma pack()
struct _ISCSI_FORM_CALLBACK_INFO {
- UINT32 Signature;
- EFI_HANDLE DriverHandle;
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
- UINT16 *KeyList;
- VOID *FormBuffer;
- EFI_HII_HANDLE RegisteredHandle;
- ISCSI_ATTEMPT_CONFIG_NVDATA *Current;
+ UINT32 Signature;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+ UINT16 *KeyList;
+ VOID *FormBuffer;
+ EFI_HII_HANDLE RegisteredHandle;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *Current;
};
/**
@@ -158,11 +156,11 @@ struct _ISCSI_FORM_CALLBACK_INFO { **/
EFI_STATUS
IScsiCreateOpCode (
- IN UINT16 StartLabelNumber,
- OUT VOID **StartOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **StartLabel,
- OUT VOID **EndOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **EndLabel
+ IN UINT16 StartLabelNumber,
+ OUT VOID **StartOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **StartLabel,
+ OUT VOID **EndOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **EndLabel
);
/**
@@ -215,7 +213,7 @@ IScsiConfigUpdateAttempt ( **/
ISCSI_ATTEMPT_CONFIG_NVDATA *
IScsiConfigGetAttemptByConfigIndex (
- IN UINT8 AttemptConfigIndex
+ IN UINT8 AttemptConfigIndex
);
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h index 688fb03bf5..bcc8923200 100644 --- a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h +++ b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h @@ -11,139 +11,139 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Guid/IScsiConfigHii.h>
-#define VAR_EQ_TEST_NAME 0x100
-#define CONFIGURATION_VARSTORE_ID 0x6666
+#define VAR_EQ_TEST_NAME 0x100
+#define CONFIGURATION_VARSTORE_ID 0x6666
-#define FORMID_MAIN_FORM 1
-#define FORMID_MAC_FORM 2
-#define FORMID_ATTEMPT_FORM 3
-#define FORMID_ORDER_FORM 4
-#define FORMID_DELETE_FORM 5
+#define FORMID_MAIN_FORM 1
+#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 FixedPcdGet8 (PcdMaxIScsiAttemptNumber)
+#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 ISCSI_NAME_IFR_MIN_SIZE 4
+#define ISCSI_NAME_IFR_MAX_SIZE 223
+#define ISCSI_NAME_MAX_SIZE 224
-#define ATTEMPT_NAME_LIST_SIZE 96
-#define ATTEMPT_NAME_SIZE 12
+#define ATTEMPT_NAME_LIST_SIZE 96
+#define ATTEMPT_NAME_SIZE 12
-#define CONNECT_MIN_RETRY 0
-#define CONNECT_MAX_RETRY 16
+#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 CONNECT_MIN_TIMEOUT 100
+#define CONNECT_MAX_TIMEOUT 20000
+#define CONNECT_DEFAULT_TIMEOUT 1000
-#define ISCSI_ACTIVE_DISABLED 0
-#define ISCSI_ACTIVE_ENABLED 1
+#define ISCSI_ACTIVE_DISABLED 0
+#define ISCSI_ACTIVE_ENABLED 1
-#define ISCSI_DISABLED 0
-#define ISCSI_ENABLED 1
-#define ISCSI_ENABLED_FOR_MPIO 2
+#define ISCSI_DISABLED 0
+#define ISCSI_ENABLED 1
+#define ISCSI_ENABLED_FOR_MPIO 2
-#define IP_MODE_IP4 0
-#define IP_MODE_IP6 1
-#define IP_MODE_AUTOCONFIG 2
+#define IP_MODE_IP4 0
+#define IP_MODE_IP6 1
+#define IP_MODE_AUTOCONFIG 2
-#define ISCSI_AUTH_TYPE_NONE 0
-#define ISCSI_AUTH_TYPE_CHAP 1
-#define ISCSI_AUTH_TYPE_KRB 2
+#define ISCSI_AUTH_TYPE_NONE 0
+#define ISCSI_AUTH_TYPE_CHAP 1
+#define ISCSI_AUTH_TYPE_KRB 2
-#define IP4_MIN_SIZE 7
-#define IP4_MAX_SIZE 15
-#define IP4_STR_MAX_SIZE 16
+#define IP4_MIN_SIZE 7
+#define IP4_MAX_SIZE 15
+#define IP4_STR_MAX_SIZE 16
//
// Macros used for an IPv4 or an IPv6 address.
//
-#define IP_MIN_SIZE 2
-#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
-#define TARGET_PORT_MAX_NUM 65535
-#define LABEL_END 0xffff
-
-#define KEY_INITIATOR_NAME 0x101
-#define KEY_DHCP_ENABLE 0x102
-#define KEY_LOCAL_IP 0x103
-#define KEY_SUBNET_MASK 0x104
-#define KEY_GATE_WAY 0x105
-#define KEY_TARGET_IP 0x106
-#define KEY_CHAP_NAME 0x107
-#define KEY_CHAP_SECRET 0x108
-#define KEY_REVERSE_CHAP_NAME 0x109
-#define KEY_REVERSE_CHAP_SECRET 0x10a
-#define KEY_SAVE_CHANGES 0x10b
-#define KEY_TARGET_NAME 0x10c
-#define KEY_BOOT_LUN 0x10d
-
-#define KEY_ADD_ATTEMPT 0x10e
-#define KEY_SAVE_ATTEMPT_CONFIG 0x10f
-#define KEY_ORDER_ATTEMPT_CONFIG 0x110
-#define KEY_SAVE_ORDER_CHANGES 0x111
-#define KEY_IGNORE_ORDER_CHANGES 0x112
-#define KEY_ATTEMPT_NAME 0x113
-#define KEY_SAVE_DELETE_ATTEMPT 0x114
-#define KEY_IGNORE_DELETE_ATTEMPT 0x115
-#define KEY_DELETE_ATTEMPT 0x116
-
-#define KEY_IP_MODE 0x11c
-#define KEY_AUTH_TYPE 0x11d
-#define KEY_CONFIG_ISID 0x11e
-
-#define ATTEMPT_ENTRY_LABEL 0x9000
-#define KEY_ATTEMPT_ENTRY_BASE 0xa000
-#define KEY_DE_ATTEMPT_ENTRY_BASE 0xb000
-
-#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_CHAP_SECRET_MIN_LEN 12
-#define ISCSI_CHAP_SECRET_MAX_LEN 16
+#define IP_MIN_SIZE 2
+#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
+#define TARGET_PORT_MAX_NUM 65535
+#define LABEL_END 0xffff
+
+#define KEY_INITIATOR_NAME 0x101
+#define KEY_DHCP_ENABLE 0x102
+#define KEY_LOCAL_IP 0x103
+#define KEY_SUBNET_MASK 0x104
+#define KEY_GATE_WAY 0x105
+#define KEY_TARGET_IP 0x106
+#define KEY_CHAP_NAME 0x107
+#define KEY_CHAP_SECRET 0x108
+#define KEY_REVERSE_CHAP_NAME 0x109
+#define KEY_REVERSE_CHAP_SECRET 0x10a
+#define KEY_SAVE_CHANGES 0x10b
+#define KEY_TARGET_NAME 0x10c
+#define KEY_BOOT_LUN 0x10d
+
+#define KEY_ADD_ATTEMPT 0x10e
+#define KEY_SAVE_ATTEMPT_CONFIG 0x10f
+#define KEY_ORDER_ATTEMPT_CONFIG 0x110
+#define KEY_SAVE_ORDER_CHANGES 0x111
+#define KEY_IGNORE_ORDER_CHANGES 0x112
+#define KEY_ATTEMPT_NAME 0x113
+#define KEY_SAVE_DELETE_ATTEMPT 0x114
+#define KEY_IGNORE_DELETE_ATTEMPT 0x115
+#define KEY_DELETE_ATTEMPT 0x116
+
+#define KEY_IP_MODE 0x11c
+#define KEY_AUTH_TYPE 0x11d
+#define KEY_CONFIG_ISID 0x11e
+
+#define ATTEMPT_ENTRY_LABEL 0x9000
+#define KEY_ATTEMPT_ENTRY_BASE 0xa000
+#define KEY_DE_ATTEMPT_ENTRY_BASE 0xb000
+
+#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_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_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
-#define KERBEROS_KDC_PORT_MIN_NUM 0
-#define KERBEROS_KDC_PORT_MAX_NUM 65535
+#define KERBEROS_SECRET_MIN_LEN 12
+#define KERBEROS_SECRET_MAX_LEN 16
+#define KERBEROS_SECRET_STORAGE 17
+#define KERBEROS_NAME_MAX_LEN 96
+#define KERBEROS_KDC_PORT_MIN_NUM 0
+#define KERBEROS_KDC_PORT_MAX_NUM 65535
-#define ISID_CONFIGURABLE_MIN_LEN 6
-#define ISID_CONFIGURABLE_MAX_LEN 12
-#define ISID_CONFIGURABLE_STORAGE 13
+#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
+#define ISCSI_MAX_MAC_STRING_LEN 96
///
/// Macro used for target Url.
///
-#define ISCSI_TARGET_URI_MIN_SIZE 0
-#define ISCSI_TARGET_URI_MAX_SIZE 255
+#define ISCSI_TARGET_URI_MIN_SIZE 0
+#define ISCSI_TARGET_URI_MAX_SIZE 255
#pragma pack(1)
@@ -151,81 +151,81 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // 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[ISCSI_TARGET_URI_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];
+ 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[ISCSI_TARGET_URI_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_SIZE];
- UINT8 Enabled;
- UINT8 IpMode;
-
- UINT8 ConnectRetryCount;
- UINT8 Padding1;
- UINT16 ConnectTimeout; // Timeout value in milliseconds.
-
- UINT8 InitiatorInfoFromDhcp;
- UINT8 TargetInfoFromDhcp;
- CHAR16 LocalIp[IP4_STR_MAX_SIZE];
- CHAR16 SubnetMask[IP4_STR_MAX_SIZE];
- CHAR16 Gateway[IP4_STR_MAX_SIZE];
-
- CHAR16 TargetName[ISCSI_NAME_MAX_SIZE];
- CHAR16 TargetIp[ISCSI_TARGET_URI_MAX_SIZE];
- UINT16 TargetPort;
- CHAR16 BootLun[ISCSI_LUN_STR_MAX_LEN];
-
- UINT8 AuthenticationType;
-
- UINT8 CHAPType;
- CHAR16 CHAPName[ISCSI_CHAP_NAME_STORAGE];
- CHAR16 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
- CHAR16 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
- CHAR16 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
-
- BOOLEAN MutualRequired;
- UINT8 Padding2;
- CHAR16 KerberosUserName[KERBEROS_NAME_MAX_LEN];
- CHAR16 KerberosUserSecret[KERBEROS_SECRET_STORAGE];
- CHAR16 KerberosKDCName[KERBEROS_NAME_MAX_LEN];
- CHAR16 KerberosKDCRealm[KERBEROS_NAME_MAX_LEN];
- 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];
+ CHAR16 InitiatorName[ISCSI_NAME_MAX_SIZE];
+ CHAR16 AttemptName[ATTEMPT_NAME_SIZE];
+ UINT8 Enabled;
+ UINT8 IpMode;
+
+ UINT8 ConnectRetryCount;
+ UINT8 Padding1;
+ UINT16 ConnectTimeout; // Timeout value in milliseconds.
+
+ UINT8 InitiatorInfoFromDhcp;
+ UINT8 TargetInfoFromDhcp;
+ CHAR16 LocalIp[IP4_STR_MAX_SIZE];
+ CHAR16 SubnetMask[IP4_STR_MAX_SIZE];
+ CHAR16 Gateway[IP4_STR_MAX_SIZE];
+
+ CHAR16 TargetName[ISCSI_NAME_MAX_SIZE];
+ CHAR16 TargetIp[ISCSI_TARGET_URI_MAX_SIZE];
+ UINT16 TargetPort;
+ CHAR16 BootLun[ISCSI_LUN_STR_MAX_LEN];
+
+ UINT8 AuthenticationType;
+
+ UINT8 CHAPType;
+ CHAR16 CHAPName[ISCSI_CHAP_NAME_STORAGE];
+ CHAR16 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
+ CHAR16 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
+ CHAR16 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
+
+ BOOLEAN MutualRequired;
+ UINT8 Padding2;
+ CHAR16 KerberosUserName[KERBEROS_NAME_MAX_LEN];
+ CHAR16 KerberosUserSecret[KERBEROS_SECRET_STORAGE];
+ CHAR16 KerberosKDCName[KERBEROS_NAME_MAX_LEN];
+ CHAR16 KerberosKDCRealm[KERBEROS_NAME_MAX_LEN];
+ 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];
- 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];
+ 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()
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c index 2c77e99f98..4af01a18a8 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp.c +++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c @@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-
/**
Extract the Root Path option and get the required target information.
@@ -27,46 +26,47 @@ EFI_STATUS IScsiDhcpExtractRootPath (
IN CHAR8 *RootPath,
IN UINT8 Length,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
)
{
- EFI_STATUS Status;
- UINT8 IScsiRootPathIdLen;
- CHAR8 *TmpStr;
- ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
- ISCSI_ROOT_PATH_FIELD *Field;
- UINT32 FieldIndex;
- UINT8 Index;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
- EFI_IP_ADDRESS Ip;
- UINT8 IpMode;
+ EFI_STATUS Status;
+ UINT8 IScsiRootPathIdLen;
+ CHAR8 *TmpStr;
+ ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
+ ISCSI_ROOT_PATH_FIELD *Field;
+ UINT32 FieldIndex;
+ UINT8 Index;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
+ EFI_IP_ADDRESS Ip;
+ UINT8 IpMode;
ConfigNvData = &ConfigData->SessionConfigData;
//
// "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
//
- IScsiRootPathIdLen = (UINT8) AsciiStrLen (ISCSI_ROOT_PATH_ID);
+ IScsiRootPathIdLen = (UINT8)AsciiStrLen (ISCSI_ROOT_PATH_ID);
if ((Length <= IScsiRootPathIdLen) || (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {
return EFI_NOT_FOUND;
}
+
//
// Skip the iSCSI RootPath ID "iscsi:".
//
RootPath += IScsiRootPathIdLen;
- Length = (UINT8) (Length - IScsiRootPathIdLen);
+ Length = (UINT8)(Length - IScsiRootPathIdLen);
- TmpStr = (CHAR8 *) AllocatePool (Length + 1);
+ TmpStr = (CHAR8 *)AllocatePool (Length + 1);
if (TmpStr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (TmpStr, RootPath, Length);
- TmpStr[Length] = '\0';
+ TmpStr[Length] = '\0';
- Index = 0;
- FieldIndex = RP_FIELD_IDX_SERVERNAME;
+ Index = 0;
+ FieldIndex = RP_FIELD_IDX_SERVERNAME;
ZeroMem (&Fields[0], sizeof (Fields));
//
@@ -88,7 +88,7 @@ IScsiDhcpExtractRootPath ( }
if (Fields[FieldIndex].Str != NULL) {
- Fields[FieldIndex].Len = (UINT8) AsciiStrLen (Fields[FieldIndex].Str);
+ Fields[FieldIndex].Len = (UINT8)AsciiStrLen (Fields[FieldIndex].Str);
}
}
}
@@ -101,15 +101,16 @@ IScsiDhcpExtractRootPath ( if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
- ) {
-
+ )
+ {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
+
//
// Get the IP address of the target.
//
- Field = &Fields[RP_FIELD_IDX_SERVERNAME];
+ Field = &Fields[RP_FIELD_IDX_SERVERNAME];
if (ConfigNvData->IpMode < IP_MODE_AUTOCONFIG) {
IpMode = ConfigNvData->IpMode;
@@ -125,11 +126,12 @@ IScsiDhcpExtractRootPath ( if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
return EFI_INVALID_PARAMETER;
}
+
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
} else {
ConfigNvData->DnsMode = FALSE;
- ZeroMem(ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
+ ZeroMem (ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
@@ -137,6 +139,7 @@ IScsiDhcpExtractRootPath ( goto ON_EXIT;
}
}
+
//
// Check the protocol type.
//
@@ -145,15 +148,17 @@ IScsiDhcpExtractRootPath ( Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
+
//
// Get the port of the iSCSI target.
//
Field = &Fields[RP_FIELD_IDX_PORT];
if (Field->Str != NULL) {
- ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
+ ConfigNvData->TargetPort = (UINT16)AsciiStrDecimalToUintn (Field->Str);
} else {
ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
//
// Get the LUN.
//
@@ -166,6 +171,7 @@ IScsiDhcpExtractRootPath ( } else {
ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
}
+
//
// Get the target iSCSI Name.
//
@@ -175,6 +181,7 @@ IScsiDhcpExtractRootPath ( Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
+
//
// Validate the iSCSI name.
//
@@ -220,10 +227,10 @@ IScsiDhcpSelectOffer ( OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
)
{
- EFI_STATUS Status;
- UINT32 OptionCount;
- EFI_DHCP4_PACKET_OPTION **OptionList;
- UINT32 Index;
+ EFI_STATUS Status;
+ UINT32 OptionCount;
+ EFI_DHCP4_PACKET_OPTION **OptionList;
+ UINT32 Index;
if ((Dhcp4Event != Dhcp4RcvdOffer) && (Dhcp4Event != Dhcp4SelectOffer)) {
return EFI_SUCCESS;
@@ -231,7 +238,7 @@ IScsiDhcpSelectOffer ( OptionCount = 0;
- Status = This->Parse (This, Packet, &OptionCount, NULL);
+ Status = This->Parse (This, Packet, &OptionCount, NULL);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_NOT_READY;
}
@@ -253,9 +260,9 @@ IScsiDhcpSelectOffer ( }
Status = IScsiDhcpExtractRootPath (
- (CHAR8 *) &OptionList[Index]->Data[0],
+ (CHAR8 *)&OptionList[Index]->Data[0],
OptionList[Index]->Length,
- (ISCSI_ATTEMPT_CONFIG_NVDATA *) Context
+ (ISCSI_ATTEMPT_CONFIG_NVDATA *)Context
);
break;
@@ -285,16 +292,16 @@ IScsiDhcpSelectOffer ( **/
EFI_STATUS
IScsiParseDhcpAck (
- IN EFI_DHCP4_PROTOCOL *Dhcp4,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN EFI_DHCP4_PROTOCOL *Dhcp4,
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
)
{
- EFI_STATUS Status;
- EFI_DHCP4_MODE_DATA Dhcp4ModeData;
- UINT32 OptionCount;
- EFI_DHCP4_PACKET_OPTION **OptionList;
- UINT32 Index;
- ISCSI_SESSION_CONFIG_NVDATA *NvData;
+ EFI_STATUS Status;
+ EFI_DHCP4_MODE_DATA Dhcp4ModeData;
+ UINT32 OptionCount;
+ EFI_DHCP4_PACKET_OPTION **OptionList;
+ UINT32 Index;
+ ISCSI_SESSION_CONFIG_NVDATA *NvData;
Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4ModeData);
if (EFI_ERROR (Status)) {
@@ -314,7 +321,7 @@ IScsiParseDhcpAck ( OptionCount = 0;
OptionList = NULL;
- Status = Dhcp4->Parse (Dhcp4, Dhcp4ModeData.ReplyPacket, &OptionCount, OptionList);
+ Status = Dhcp4->Parse (Dhcp4, Dhcp4ModeData.ReplyPacket, &OptionCount, OptionList);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_DEVICE_ERROR;
}
@@ -335,11 +342,11 @@ IScsiParseDhcpAck ( // Get DNS server addresses and DHCP server address from this offer.
//
if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
-
if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {
Status = EFI_INVALID_PARAMETER;
break;
}
+
//
// Primary DNS server address.
//
@@ -377,32 +384,32 @@ IScsiParseDhcpAck ( **/
EFI_STATUS
IScsiSetIp4Policy (
- IN EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2
+ IN EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2
)
{
- EFI_IP4_CONFIG2_POLICY Policy;
- EFI_STATUS Status;
- UINTN DataSize;
+ EFI_IP4_CONFIG2_POLICY Policy;
+ EFI_STATUS Status;
+ UINTN DataSize;
DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
- Status = Ip4Config2->GetData (
- Ip4Config2,
- Ip4Config2DataTypePolicy,
- &DataSize,
- &Policy
- );
+ Status = Ip4Config2->GetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ &DataSize,
+ &Policy
+ );
if (EFI_ERROR (Status)) {
return Status;
}
if (Policy != Ip4Config2PolicyStatic) {
Policy = Ip4Config2PolicyStatic;
- Status= Ip4Config2->SetData (
- Ip4Config2,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
+ Status = Ip4Config2->SetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ sizeof (EFI_IP4_CONFIG2_POLICY),
+ &Policy
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -426,19 +433,19 @@ IScsiSetIp4Policy ( **/
EFI_STATUS
IScsiDoDhcp (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
)
{
- EFI_HANDLE Dhcp4Handle;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
- EFI_DHCP4_PROTOCOL *Dhcp4;
- EFI_STATUS Status;
- EFI_DHCP4_PACKET_OPTION *ParaList;
- EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData;
- ISCSI_SESSION_CONFIG_NVDATA *NvData;
- EFI_STATUS MediaStatus;
+ EFI_HANDLE Dhcp4Handle;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
+ EFI_DHCP4_PROTOCOL *Dhcp4;
+ EFI_STATUS Status;
+ EFI_DHCP4_PACKET_OPTION *ParaList;
+ EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData;
+ ISCSI_SESSION_CONFIG_NVDATA *NvData;
+ EFI_STATUS MediaStatus;
Dhcp4Handle = NULL;
Ip4Config2 = NULL;
@@ -450,7 +457,7 @@ IScsiDoDhcp ( //
MediaStatus = EFI_SUCCESS;
NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus);
- if (MediaStatus!= EFI_SUCCESS) {
+ if (MediaStatus != EFI_SUCCESS) {
AsciiPrint ("\n Error: Could not detect network connection.\n");
return EFI_NO_MEDIA;
}
@@ -462,7 +469,7 @@ IScsiDoDhcp ( // will not be in the right state for the iSCSI to start a new round D.O.R.A.
// So, we need to switch its policy to static.
//
- Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (!EFI_ERROR (Status)) {
Status = IScsiSetIp4Policy (Ip4Config2);
if (EFI_ERROR (Status)) {
@@ -486,7 +493,7 @@ IScsiDoDhcp ( Status = gBS->OpenProtocol (
Dhcp4Handle,
&gEfiDhcp4ProtocolGuid,
- (VOID **) &Dhcp4,
+ (VOID **)&Dhcp4,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -495,7 +502,7 @@ IScsiDoDhcp ( goto ON_EXIT;
}
- NvData = &ConfigData->SessionConfigData;
+ NvData = &ConfigData->SessionConfigData;
ParaList = AllocatePool (sizeof (EFI_DHCP4_PACKET_OPTION) + 3);
if (ParaList == NULL) {
@@ -507,7 +514,7 @@ IScsiDoDhcp ( // Ask the server to reply with Netmask, Router, DNS, and RootPath options.
//
ParaList->OpCode = DHCP4_TAG_PARA_LIST;
- ParaList->Length = (UINT8) (NvData->TargetInfoFromDhcp ? 4 : 3);
+ ParaList->Length = (UINT8)(NvData->TargetInfoFromDhcp ? 4 : 3);
ParaList->Data[0] = DHCP4_TAG_NETMASK;
ParaList->Data[1] = DHCP4_TAG_ROUTER;
ParaList->Data[2] = DHCP4_TAG_DNS_SERVER;
@@ -534,6 +541,7 @@ IScsiDoDhcp ( if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
//
// Parse the ACK to get required information.
//
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.h b/NetworkPkg/IScsiDxe/IScsiDhcp.h index 69b501d630..9a0d5d27e5 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp.h +++ b/NetworkPkg/IScsiDxe/IScsiDhcp.h @@ -9,21 +9,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _ISCSI_DHCP_H_
#define _ISCSI_DHCP_H_
-#define ISCSI_ROOT_PATH_ID "iscsi:"
-#define ISCSI_ROOT_PATH_FIELD_DELIMITER ':'
+#define ISCSI_ROOT_PATH_ID "iscsi:"
+#define ISCSI_ROOT_PATH_FIELD_DELIMITER ':'
-#define RP_FIELD_IDX_SERVERNAME 0
-#define RP_FIELD_IDX_PROTOCOL 1
-#define RP_FIELD_IDX_PORT 2
-#define RP_FIELD_IDX_LUN 3
-#define RP_FIELD_IDX_TARGETNAME 4
-#define RP_FIELD_IDX_MAX 5
+#define RP_FIELD_IDX_SERVERNAME 0
+#define RP_FIELD_IDX_PROTOCOL 1
+#define RP_FIELD_IDX_PORT 2
+#define RP_FIELD_IDX_LUN 3
+#define RP_FIELD_IDX_TARGETNAME 4
+#define RP_FIELD_IDX_MAX 5
typedef struct _ISCSI_ATTEMPT_CONFIG_NVDATA ISCSI_ATTEMPT_CONFIG_NVDATA;
typedef struct _ISCSI_ROOT_PATH_FIELD {
- CHAR8 *Str;
- UINT8 Len;
+ CHAR8 *Str;
+ UINT8 Len;
} ISCSI_ROOT_PATH_FIELD;
/**
@@ -41,9 +41,9 @@ typedef struct _ISCSI_ROOT_PATH_FIELD { **/
EFI_STATUS
IScsiDoDhcp (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
);
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c b/NetworkPkg/IScsiDxe/IScsiDhcp6.c index 691650b733..8ca92b20d1 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp6.c +++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.c @@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-
/**
Extract the Root Path option and get the required target information from
Boot File Uniform Resource Locator (URL) Option.
@@ -29,47 +28,49 @@ EFI_STATUS IScsiDhcp6ExtractRootPath (
IN CHAR8 *RootPath,
IN UINT16 Length,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
)
{
- EFI_STATUS Status;
- UINT16 IScsiRootPathIdLen;
- CHAR8 *TmpStr;
- ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
- ISCSI_ROOT_PATH_FIELD *Field;
- UINT32 FieldIndex;
- UINT8 Index;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
- EFI_IP_ADDRESS Ip;
- UINT8 IpMode;
-
- ConfigNvData = &ConfigData->SessionConfigData;
+ EFI_STATUS Status;
+ UINT16 IScsiRootPathIdLen;
+ CHAR8 *TmpStr;
+ ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
+ ISCSI_ROOT_PATH_FIELD *Field;
+ UINT32 FieldIndex;
+ UINT8 Index;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
+ EFI_IP_ADDRESS Ip;
+ UINT8 IpMode;
+
+ ConfigNvData = &ConfigData->SessionConfigData;
ConfigNvData->DnsMode = FALSE;
//
// "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
//
- IScsiRootPathIdLen = (UINT16) AsciiStrLen (ISCSI_ROOT_PATH_ID);
+ IScsiRootPathIdLen = (UINT16)AsciiStrLen (ISCSI_ROOT_PATH_ID);
if ((Length <= IScsiRootPathIdLen) ||
- (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {
+ (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0))
+ {
return EFI_NOT_FOUND;
}
+
//
// Skip the iSCSI RootPath ID "iscsi:".
//
RootPath = RootPath + IScsiRootPathIdLen;
- Length = (UINT16) (Length - IScsiRootPathIdLen);
+ Length = (UINT16)(Length - IScsiRootPathIdLen);
- TmpStr = (CHAR8 *) AllocatePool (Length + 1);
+ TmpStr = (CHAR8 *)AllocatePool (Length + 1);
if (TmpStr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (TmpStr, RootPath, Length);
- TmpStr[Length] = '\0';
+ TmpStr[Length] = '\0';
- Index = 0;
- FieldIndex = 0;
+ Index = 0;
+ FieldIndex = 0;
ZeroMem (&Fields[0], sizeof (Fields));
//
@@ -87,7 +88,7 @@ IScsiDhcp6ExtractRootPath ( Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index];
if (!ConfigNvData->DnsMode) {
- while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER)&& (Index < Length)) {
+ while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER) && (Index < Length)) {
Index++;
}
@@ -95,25 +96,25 @@ IScsiDhcp6ExtractRootPath ( // Skip ']' and ':'.
//
TmpStr[Index] = '\0';
- Index += 2;
+ Index += 2;
} else {
while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {
Index++;
}
+
//
// Skip ':'.
//
TmpStr[Index] = '\0';
- Index += 1;
+ Index += 1;
}
- Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8) AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str);
+ Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8)AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str);
//
// Extract others fields in the Root Path option string.
//
for (FieldIndex = 1; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
-
if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
Fields[FieldIndex].Str = &TmpStr[Index];
}
@@ -129,7 +130,7 @@ IScsiDhcp6ExtractRootPath ( }
if (Fields[FieldIndex].Str != NULL) {
- Fields[FieldIndex].Len = (UINT8) AsciiStrLen (Fields[FieldIndex].Str);
+ Fields[FieldIndex].Len = (UINT8)AsciiStrLen (Fields[FieldIndex].Str);
}
}
}
@@ -142,15 +143,16 @@ IScsiDhcp6ExtractRootPath ( if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
- ) {
-
+ )
+ {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
+
//
// Get the IP address of the target.
//
- Field = &Fields[RP_FIELD_IDX_SERVERNAME];
+ Field = &Fields[RP_FIELD_IDX_SERVERNAME];
if (ConfigNvData->IpMode < IP_MODE_AUTOCONFIG) {
IpMode = ConfigNvData->IpMode;
} else {
@@ -164,10 +166,11 @@ IScsiDhcp6ExtractRootPath ( if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
return EFI_INVALID_PARAMETER;
}
+
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
} else {
- ZeroMem(&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
+ ZeroMem (&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
@@ -184,15 +187,17 @@ IScsiDhcp6ExtractRootPath ( Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
+
//
// Get the port of the iSCSI target.
//
Field = &Fields[RP_FIELD_IDX_PORT];
if (Field->Str != NULL) {
- ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
+ ConfigNvData->TargetPort = (UINT16)AsciiStrDecimalToUintn (Field->Str);
} else {
ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
//
// Get the LUN.
//
@@ -205,6 +210,7 @@ IScsiDhcp6ExtractRootPath ( } else {
ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
}
+
//
// Get the target iSCSI Name.
//
@@ -214,6 +220,7 @@ IScsiDhcp6ExtractRootPath ( Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
+
//
// Validate the iSCSI name.
//
@@ -258,23 +265,23 @@ ON_EXIT: EFI_STATUS
EFIAPI
IScsiDhcp6ParseReply (
- IN EFI_DHCP6_PROTOCOL *This,
- IN VOID *Context,
- IN EFI_DHCP6_PACKET *Packet
+ IN EFI_DHCP6_PROTOCOL *This,
+ IN VOID *Context,
+ IN EFI_DHCP6_PACKET *Packet
)
{
- EFI_STATUS Status;
- UINT32 Index;
- UINT32 OptionCount;
- EFI_DHCP6_PACKET_OPTION *BootFileOpt;
- EFI_DHCP6_PACKET_OPTION **OptionList;
- ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData;
- UINT16 ParaLen;
+ EFI_STATUS Status;
+ UINT32 Index;
+ UINT32 OptionCount;
+ EFI_DHCP6_PACKET_OPTION *BootFileOpt;
+ EFI_DHCP6_PACKET_OPTION **OptionList;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData;
+ UINT16 ParaLen;
OptionCount = 0;
BootFileOpt = NULL;
- Status = This->Parse (This, Packet, &OptionCount, NULL);
+ Status = This->Parse (This, Packet, &OptionCount, NULL);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_NOT_READY;
}
@@ -290,7 +297,7 @@ IScsiDhcp6ParseReply ( goto Exit;
}
- ConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *) Context;
+ ConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *)Context;
for (Index = 0; Index < OptionCount; Index++) {
OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode);
@@ -300,11 +307,11 @@ IScsiDhcp6ParseReply ( // Get DNS server addresses from this reply packet.
//
if (OptionList[Index]->OpCode == DHCP6_OPT_DNS_SERVERS) {
-
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
Status = EFI_UNSUPPORTED;
goto Exit;
}
+
//
// Primary DNS server address.
//
@@ -316,7 +323,6 @@ IScsiDhcp6ParseReply ( //
CopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[16], sizeof (EFI_IPv6_ADDRESS));
}
-
} else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_URL) {
//
// The server sends this option to inform the client about an URL to a boot file.
@@ -330,6 +336,7 @@ IScsiDhcp6ParseReply ( Status = EFI_UNSUPPORTED;
goto Exit;
}
+
//
// Check param-len 1, should be 16 bytes.
//
@@ -352,7 +359,7 @@ IScsiDhcp6ParseReply ( // Get iSCSI root path from Boot File Uniform Resource Locator (URL) Option
//
Status = IScsiDhcp6ExtractRootPath (
- (CHAR8 *) BootFileOpt->Data,
+ (CHAR8 *)BootFileOpt->Data,
BootFileOpt->OpLen,
ConfigData
);
@@ -363,7 +370,6 @@ Exit: return Status;
}
-
/**
Parse the DHCP ACK to get the address configuration and DNS information.
@@ -383,9 +389,9 @@ Exit: **/
EFI_STATUS
IScsiDoDhcp6 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
)
{
EFI_HANDLE Dhcp6Handle;
@@ -435,7 +441,7 @@ IScsiDoDhcp6 ( Status = gBS->OpenProtocol (
Dhcp6Handle,
&gEfiDhcp6ProtocolGuid,
- (VOID **) &Dhcp6,
+ (VOID **)&Dhcp6,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -493,7 +499,6 @@ IScsiDoDhcp6 ( }
do {
-
TimerStatus = gBS->CheckEvent (Timer);
if (!EFI_ERROR (TimerStatus)) {
@@ -509,9 +514,7 @@ IScsiDoDhcp6 ( ConfigData
);
}
-
} while (TimerStatus == EFI_NOT_READY);
-
}
ON_EXIT:
@@ -542,4 +545,3 @@ ON_EXIT: return Status;
}
-
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.h b/NetworkPkg/IScsiDxe/IScsiDhcp6.h index 666338c7d2..d086a69459 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp6.h +++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.h @@ -9,11 +9,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _ISCSI_DHCP6_H_
#define _ISCSI_DHCP6_H_
-#define ISCSI_ROOT_PATH_ID "iscsi:"
-#define ISCSI_ROOT_PATH_FIELD_DELIMITER ':'
-#define ISCSI_ROOT_PATH_ADDR_START_DELIMITER '['
-#define ISCSI_ROOT_PATH_ADDR_END_DELIMITER ']'
-
+#define ISCSI_ROOT_PATH_ID "iscsi:"
+#define ISCSI_ROOT_PATH_FIELD_DELIMITER ':'
+#define ISCSI_ROOT_PATH_ADDR_START_DELIMITER '['
+#define ISCSI_ROOT_PATH_ADDR_END_DELIMITER ']'
/**
Extract the Root Path option and get the required target information from
@@ -35,7 +34,7 @@ EFI_STATUS IScsiDhcp6ExtractRootPath (
IN CHAR8 *RootPath,
IN UINT16 Length,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
);
/**
@@ -57,9 +56,9 @@ IScsiDhcp6ExtractRootPath ( **/
EFI_STATUS
IScsiDoDhcp6 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
);
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiDns.c b/NetworkPkg/IScsiDxe/IScsiDns.c index f407c2bbc4..7725dcbc18 100644 --- a/NetworkPkg/IScsiDxe/IScsiDns.c +++ b/NetworkPkg/IScsiDxe/IScsiDns.c @@ -18,11 +18,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent VOID
EFIAPI
IScsiCommonNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- *((BOOLEAN *) Context) = TRUE;
+ *((BOOLEAN *)Context) = TRUE;
}
/**
@@ -40,22 +40,22 @@ IScsiCommonNotify ( **/
EFI_STATUS
IScsiDns4 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
)
{
- EFI_STATUS Status;
- EFI_DNS4_PROTOCOL *Dns4;
- EFI_DNS4_CONFIG_DATA Dns4CfgData;
- EFI_DNS4_COMPLETION_TOKEN Token;
- BOOLEAN IsDone;
- EFI_HANDLE Dns4Handle;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
- EFI_IPv4_ADDRESS *DnsServerList;
- UINTN DnsServerListCount;
- UINTN DataSize;
- CHAR16 *HostName;
+ EFI_STATUS Status;
+ EFI_DNS4_PROTOCOL *Dns4;
+ EFI_DNS4_CONFIG_DATA Dns4CfgData;
+ EFI_DNS4_COMPLETION_TOKEN Token;
+ BOOLEAN IsDone;
+ EFI_HANDLE Dns4Handle;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
+ EFI_IPv4_ADDRESS *DnsServerList;
+ UINTN DnsServerListCount;
+ UINTN DataSize;
+ CHAR16 *HostName;
DnsServerList = NULL;
DnsServerListCount = 0;
@@ -66,7 +66,7 @@ IScsiDns4 ( //
// Get DNS server list from EFI IPv4 Configuration II protocol.
//
- Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (!EFI_ERROR (Status)) {
//
// Get the required size.
@@ -79,7 +79,7 @@ IScsiDns4 ( return EFI_OUT_OF_RESOURCES;
}
- Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeDnsServer, &DataSize, DnsServerList);
+ Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeDnsServer, &DataSize, DnsServerList);
if (EFI_ERROR (Status)) {
FreePool (DnsServerList);
DnsServerList = NULL;
@@ -89,7 +89,6 @@ IScsiDns4 ( }
}
-
//
// Create a DNS child instance and get the protocol.
//
@@ -106,7 +105,7 @@ IScsiDns4 ( Status = gBS->OpenProtocol (
Dns4Handle,
&gEfiDns4ProtocolGuid,
- (VOID **) &Dns4,
+ (VOID **)&Dns4,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -124,11 +123,11 @@ IScsiDns4 ( Dns4CfgData.EnableDnsCache = TRUE;
IP4_COPY_ADDRESS (&Dns4CfgData.StationIp, &NvData->LocalIp);
IP4_COPY_ADDRESS (&Dns4CfgData.SubnetMask, &NvData->SubnetMask);
- Dns4CfgData.Protocol = EFI_IP_PROTO_UDP;
- Status = Dns4->Configure (
- Dns4,
- &Dns4CfgData
- );
+ Dns4CfgData.Protocol = EFI_IP_PROTO_UDP;
+ Status = Dns4->Configure (
+ Dns4,
+ &Dns4CfgData
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -154,7 +153,7 @@ IScsiDns4 ( Token.Status = EFI_NOT_READY;
IsDone = FALSE;
- HostName = (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
+ HostName = (CHAR16 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
if (HostName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -183,10 +182,12 @@ IScsiDns4 ( Status = EFI_DEVICE_ERROR;
goto Exit;
}
- if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
+
+ if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
Status = EFI_DEVICE_ERROR;
goto Exit;
}
+
//
// We just return the first IP address from DNS protocol.
//
@@ -199,10 +200,12 @@ Exit: if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event);
}
+
if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList);
}
+
FreePool (Token.RspData.H2AData);
}
@@ -244,39 +247,39 @@ Exit: **/
EFI_STATUS
IScsiDns6 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
)
{
- EFI_STATUS Status;
- EFI_DNS6_PROTOCOL *Dns6;
- EFI_DNS6_CONFIG_DATA Dns6ConfigData;
- EFI_DNS6_COMPLETION_TOKEN Token;
- EFI_HANDLE Dns6Handle;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- EFI_IPv6_ADDRESS *DnsServerList;
- UINTN DnsServerListCount;
- UINTN DataSize;
- BOOLEAN IsDone;
- CHAR16 *HostName;
-
- DnsServerList = NULL;
- DnsServerListCount = 0;
- Dns6 = NULL;
- Dns6Handle = NULL;
+ EFI_STATUS Status;
+ EFI_DNS6_PROTOCOL *Dns6;
+ EFI_DNS6_CONFIG_DATA Dns6ConfigData;
+ EFI_DNS6_COMPLETION_TOKEN Token;
+ EFI_HANDLE Dns6Handle;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_IPv6_ADDRESS *DnsServerList;
+ UINTN DnsServerListCount;
+ UINTN DataSize;
+ BOOLEAN IsDone;
+ CHAR16 *HostName;
+
+ DnsServerList = NULL;
+ DnsServerListCount = 0;
+ Dns6 = NULL;
+ Dns6Handle = NULL;
ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN));
//
// Get DNS server list from EFI IPv6 Configuration protocol.
//
- Status = gBS->HandleProtocol (Controller, &gEfiIp6ConfigProtocolGuid, (VOID **) &Ip6Config);
+ Status = gBS->HandleProtocol (Controller, &gEfiIp6ConfigProtocolGuid, (VOID **)&Ip6Config);
if (!EFI_ERROR (Status)) {
//
// Get the required size.
//
DataSize = 0;
- Status = Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer, &DataSize, NULL);
+ Status = Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer, &DataSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) {
DnsServerList = AllocatePool (DataSize);
if (DnsServerList == NULL) {
@@ -309,7 +312,7 @@ IScsiDns6 ( Status = gBS->OpenProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
- (VOID **) &Dns6,
+ (VOID **)&Dns6,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -326,10 +329,10 @@ IScsiDns6 ( Dns6ConfigData.DnsServerList = DnsServerList;
Dns6ConfigData.EnableDnsCache = TRUE;
Dns6ConfigData.Protocol = EFI_IP_PROTO_UDP;
- Status = Dns6->Configure (
- Dns6,
- &Dns6ConfigData
- );
+ Status = Dns6->Configure (
+ Dns6,
+ &Dns6ConfigData
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -353,7 +356,7 @@ IScsiDns6 ( //
// Start asynchronous name resolution.
//
- HostName = (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
+ HostName = (CHAR16 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
if (HostName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -381,10 +384,12 @@ IScsiDns6 ( Status = EFI_DEVICE_ERROR;
goto Exit;
}
- if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
+
+ if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
Status = EFI_DEVICE_ERROR;
goto Exit;
}
+
//
// We just return the first IPv6 address from DNS protocol.
//
@@ -397,10 +402,12 @@ Exit: if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event);
}
+
if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList);
}
+
FreePool (Token.RspData.H2AData);
}
@@ -426,4 +433,3 @@ Exit: return Status;
}
-
diff --git a/NetworkPkg/IScsiDxe/IScsiDns.h b/NetworkPkg/IScsiDxe/IScsiDns.h index 2e02309745..07efc6c6f9 100644 --- a/NetworkPkg/IScsiDxe/IScsiDns.h +++ b/NetworkPkg/IScsiDxe/IScsiDns.h @@ -25,9 +25,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
EFI_STATUS
IScsiDns4 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
);
/**
@@ -45,9 +45,9 @@ IScsiDns4 ( **/
EFI_STATUS
IScsiDns6 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData
);
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c index 485c929721..ba4abd4ef5 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.c +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = {
IScsiIp4DriverBindingSupported,
IScsiIp4DriverBindingStart,
IScsiIp4DriverBindingStop,
@@ -20,7 +20,7 @@ EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = { NULL
};
-EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = {
IScsiIp6DriverBindingSupported,
IScsiIp6DriverBindingStart,
IScsiIp6DriverBindingStop,
@@ -29,9 +29,9 @@ EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = { NULL
};
-EFI_GUID gIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
-EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
-ISCSI_PRIVATE_DATA *mPrivate = NULL;
+EFI_GUID gIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
+EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
+ISCSI_PRIVATE_DATA *mPrivate = NULL;
/**
Tests to see if this driver supports the RemainingDevicePath.
@@ -50,7 +50,7 @@ ISCSI_PRIVATE_DATA *mPrivate = NULL; **/
EFI_STATUS
IScsiIsDevicePathSupported (
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
@@ -85,34 +85,34 @@ IScsiCheckAip ( VOID
)
{
- UINTN AipHandleCount;
- EFI_HANDLE *AipHandleBuffer;
- UINTN AipIndex;
- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
- EFI_GUID *InfoTypesBuffer;
- UINTN InfoTypeBufferCount;
- UINTN TypeIndex;
- VOID *InfoBlock;
- UINTN InfoBlockSize;
- BOOLEAN Supported;
- EFI_ADAPTER_INFO_NETWORK_BOOT *NetworkBoot;
- EFI_STATUS Status;
- UINT8 NetworkBootPolicy;
+ UINTN AipHandleCount;
+ EFI_HANDLE *AipHandleBuffer;
+ UINTN AipIndex;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypeBufferCount;
+ UINTN TypeIndex;
+ VOID *InfoBlock;
+ UINTN InfoBlockSize;
+ BOOLEAN Supported;
+ EFI_ADAPTER_INFO_NETWORK_BOOT *NetworkBoot;
+ EFI_STATUS Status;
+ UINT8 NetworkBootPolicy;
//
// Check any AIP instances exist in system.
//
AipHandleCount = 0;
AipHandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiAdapterInformationProtocolGuid,
- NULL,
- &AipHandleCount,
- &AipHandleBuffer
- );
- if (EFI_ERROR (Status) || AipHandleCount == 0) {
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiAdapterInformationProtocolGuid,
+ NULL,
+ &AipHandleCount,
+ &AipHandleBuffer
+ );
+ if (EFI_ERROR (Status) || (AipHandleCount == 0)) {
return EFI_NOT_FOUND;
}
@@ -124,7 +124,7 @@ IScsiCheckAip ( Status = gBS->HandleProtocol (
AipHandleBuffer[AipIndex],
&gEfiAdapterInformationProtocolGuid,
- (VOID *) &Aip
+ (VOID *)&Aip
);
ASSERT_EFI_ERROR (Status);
ASSERT (Aip != NULL);
@@ -132,18 +132,19 @@ IScsiCheckAip ( Status = gBS->HandleProtocol (
AipHandleBuffer[AipIndex],
&gEfiExtScsiPassThruProtocolGuid,
- (VOID *) &ExtScsiPassThru
+ (VOID *)&ExtScsiPassThru
);
- if (EFI_ERROR (Status) || ExtScsiPassThru == NULL) {
+ if (EFI_ERROR (Status) || (ExtScsiPassThru == NULL)) {
continue;
}
InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0;
- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
continue;
}
+
//
// Check whether the AIP instance has Network boot information block.
//
@@ -165,33 +166,35 @@ IScsiCheckAip ( //
InfoBlock = NULL;
InfoBlockSize = 0;
- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize);
- if (EFI_ERROR (Status) || InfoBlock == NULL) {
+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize);
+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
continue;
}
//
// Check whether the network boot policy matches.
//
- NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *) InfoBlock;
+ NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *)InfoBlock;
NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);
if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) {
Status = EFI_SUCCESS;
goto Exit;
}
- if (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0 &&
+
+ if ((((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0) &&
!NetworkBoot->iScsiIpv4BootCapablity) ||
- ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0 &&
+ (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0) &&
!NetworkBoot->iScsiIpv6BootCapablity) ||
- ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0 &&
+ (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0) &&
!NetworkBoot->OffloadCapability) ||
- ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0 &&
+ (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0) &&
!NetworkBoot->iScsiMpioCapability) ||
- ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0 &&
+ (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0) &&
!NetworkBoot->iScsiIpv4Boot) ||
- ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0 &&
- !NetworkBoot->iScsiIpv6Boot)) {
+ (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0) &&
+ !NetworkBoot->iScsiIpv6Boot))
+ {
FreePool (InfoBlock);
continue;
}
@@ -206,9 +209,11 @@ Exit: if (InfoBlock != NULL) {
FreePool (InfoBlock);
}
+
if (AipHandleBuffer != NULL) {
FreePool (AipHandleBuffer);
}
+
return Status;
}
@@ -246,23 +251,22 @@ IScsiSupported ( IN UINT8 IpVersion
)
{
- EFI_STATUS Status;
- EFI_GUID *IScsiServiceBindingGuid;
- EFI_GUID *TcpServiceBindingGuid;
- EFI_GUID *DhcpServiceBindingGuid;
- EFI_GUID *DnsServiceBindingGuid;
+ EFI_STATUS Status;
+ EFI_GUID *IScsiServiceBindingGuid;
+ EFI_GUID *TcpServiceBindingGuid;
+ EFI_GUID *DhcpServiceBindingGuid;
+ EFI_GUID *DnsServiceBindingGuid;
if (IpVersion == IP_VERSION_4) {
- IScsiServiceBindingGuid = &gIScsiV4PrivateGuid;
- TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
- DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
- DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid;
-
+ IScsiServiceBindingGuid = &gIScsiV4PrivateGuid;
+ TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
+ DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
+ DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid;
} else {
- IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
- TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
- DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
- DnsServiceBindingGuid = &gEfiDns6ServiceBindingProtocolGuid;
+ IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
+ TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
+ DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
+ DnsServiceBindingGuid = &gEfiDns6ServiceBindingProtocolGuid;
}
Status = gBS->OpenProtocol (
@@ -325,7 +329,6 @@ IScsiSupported ( return EFI_SUCCESS;
}
-
/**
Start to manage the controller. This is the worker function for
IScsiIp4(6)DriverBindingStart.
@@ -347,33 +350,33 @@ IScsiSupported ( **/
EFI_STATUS
IScsiStart (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE ControllerHandle,
- IN UINT8 IpVersion
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT8 IpVersion
)
{
- EFI_STATUS Status;
- ISCSI_DRIVER_DATA *Private;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_SESSION *Session;
- UINT8 Index;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExistIScsiExtScsiPassThru;
- ISCSI_DRIVER_DATA *ExistPrivate;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINT8 BootSelected;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_GUID *IScsiPrivateGuid;
- EFI_GUID *TcpServiceBindingGuid;
- BOOLEAN NeedUpdate;
- VOID *Interface;
- EFI_GUID *ProtocolGuid;
- UINT8 NetworkBootPolicy;
- ISCSI_SESSION_CONFIG_NVDATA *NvData;
+ EFI_STATUS Status;
+ ISCSI_DRIVER_DATA *Private;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_SESSION *Session;
+ UINT8 Index;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExistIScsiExtScsiPassThru;
+ ISCSI_DRIVER_DATA *ExistPrivate;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINT8 BootSelected;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_GUID *IScsiPrivateGuid;
+ EFI_GUID *TcpServiceBindingGuid;
+ BOOLEAN NeedUpdate;
+ VOID *Interface;
+ EFI_GUID *ProtocolGuid;
+ UINT8 NetworkBootPolicy;
+ ISCSI_SESSION_CONFIG_NVDATA *NvData;
//
// Test to see if iSCSI driver supports the given controller.
@@ -518,7 +521,7 @@ IScsiStart ( if (mPrivate->OneSessionEstablished && mPrivate->EnableMpio) {
AttemptConfigData = NULL;
NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
- AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
+ AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
break;
}
@@ -558,7 +561,7 @@ IScsiStart ( Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
continue;
@@ -572,7 +575,7 @@ IScsiStart ( Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiExtScsiPassThruProtocolGuid,
- (VOID **) &ExistIScsiExtScsiPassThru
+ (VOID **)&ExistIScsiExtScsiPassThru
);
ASSERT_EFI_ERROR (Status);
break;
@@ -622,9 +625,10 @@ IScsiStart ( // Don't process the attempt that does not associate with the current NIC or
// this attempt is disabled or established.
//
- if (AttemptConfigData->NicIndex != mPrivate->CurrentNic ||
- AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED ||
- AttemptConfigData->ValidPath) {
+ if ((AttemptConfigData->NicIndex != mPrivate->CurrentNic) ||
+ (AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED) ||
+ AttemptConfigData->ValidPath)
+ {
continue;
}
@@ -633,9 +637,10 @@ IScsiStart ( // In default single path mode, don't process attempts configured for multipath.
//
if ((mPrivate->EnableMpio &&
- AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) ||
+ (AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO)) ||
(!mPrivate->EnableMpio &&
- AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)) {
+ (AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)))
+ {
continue;
}
@@ -643,18 +648,21 @@ IScsiStart ( // Don't process the attempt that fails to get the init/target information from DHCP.
//
if (AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp &&
- !AttemptConfigData->DhcpSuccess) {
- if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
+ !AttemptConfigData->DhcpSuccess)
+ {
+ if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
mPrivate->ValidSinglePathCount--;
}
+
continue;
}
//
// Don't process the autoconfigure path if it is already established.
//
- if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
- AttemptConfigData->AutoConfigureSuccess) {
+ if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
+ AttemptConfigData->AutoConfigureSuccess)
+ {
continue;
}
@@ -665,16 +673,20 @@ IScsiStart ( if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) {
continue;
}
- if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
- AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) {
+
+ if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
+ (AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6))
+ {
continue;
}
} else {
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) {
continue;
}
- if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
- AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) {
+
+ if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
+ (AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4))
+ {
continue;
}
}
@@ -682,7 +694,7 @@ IScsiStart ( //
// Fill in the Session and init it.
//
- Session = (ISCSI_SESSION *) AllocateZeroPool (sizeof (ISCSI_SESSION));
+ Session = (ISCSI_SESSION *)AllocateZeroPool (sizeof (ISCSI_SESSION));
if (Session == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
@@ -694,9 +706,9 @@ IScsiStart ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
+ (UINTN)AttemptConfigData->AttemptConfigIndex
);
if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
@@ -742,12 +754,11 @@ IScsiStart ( // In Single path mode, only the successful attempt will be recorded in iBFT;
// in multi-path mode, all the attempt entries in MPIO will be recorded in iBFT.
//
- if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
+ if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
mPrivate->ValidSinglePathCount--;
}
FreePool (Session);
-
} else {
AttemptConfigData->ValidPath = TRUE;
@@ -756,7 +767,7 @@ IScsiStart ( // TODO: record KRB5 attempt information in the iSCSI device path.
//
if (Session->AuthType == ISCSI_AUTH_TYPE_KRB) {
- if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
+ if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
mPrivate->ValidSinglePathCount--;
}
@@ -814,7 +825,7 @@ IScsiStart ( //
// Reinstall the original ExtScsiPassThru back.
//
- if (mPrivate->OneSessionEstablished && ExistPrivate != NULL) {
+ if (mPrivate->OneSessionEstablished && (ExistPrivate != NULL)) {
Status = gBS->InstallProtocolInterface (
&ExistPrivate->ExtScsiPassThruHandle,
&gEfiExtScsiPassThruProtocolGuid,
@@ -837,8 +848,7 @@ IScsiStart ( //
// More than one attempt successes.
//
- if (Private->Session != NULL && mPrivate->OneSessionEstablished) {
-
+ if ((Private->Session != NULL) && mPrivate->OneSessionEstablished) {
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
@@ -847,9 +857,11 @@ IScsiStart ( if (AttemptConfigOrder == NULL) {
goto ON_ERROR;
}
+
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
- if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex ||
- AttemptConfigOrder[Index] == BootSelected) {
+ if ((AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) ||
+ (AttemptConfigOrder[Index] == BootSelected))
+ {
break;
}
}
@@ -887,6 +899,7 @@ IScsiStart ( if (AttemptConfigOrder[Index] != BootSelected) {
goto ON_ERROR;
}
+
mPrivate->BootSelectedIndex = BootSelected;
//
// Clear the resource in ExistPrivate.
@@ -917,7 +930,6 @@ IScsiStart ( gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent);
FreePool (ExistPrivate);
-
}
} else {
//
@@ -927,7 +939,6 @@ IScsiStart ( NeedUpdate = FALSE;
}
}
-
}
if (NeedUpdate) {
@@ -945,6 +956,7 @@ IScsiStart ( Status = EFI_DEVICE_ERROR;
goto ON_ERROR;
}
+
//
// Install the updated device path onto the ExtScsiPassThruHandle.
//
@@ -1032,16 +1044,15 @@ IScsiStop ( IN UINT8 IpVersion
)
{
- EFI_HANDLE IScsiController;
- EFI_STATUS Status;
- ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
- ISCSI_DRIVER_DATA *Private;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
- ISCSI_CONNECTION *Conn;
- EFI_GUID *ProtocolGuid;
- EFI_GUID *TcpServiceBindingGuid;
- EFI_GUID *TcpProtocolGuid;
-
+ EFI_HANDLE IScsiController;
+ EFI_STATUS Status;
+ ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
+ ISCSI_DRIVER_DATA *Private;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
+ ISCSI_CONNECTION *Conn;
+ EFI_GUID *ProtocolGuid;
+ EFI_GUID *TcpServiceBindingGuid;
+ EFI_GUID *TcpProtocolGuid;
if (NumberOfChildren != 0) {
//
@@ -1050,7 +1061,7 @@ IScsiStop ( Status = gBS->OpenProtocol (
ChildHandleBuffer[0],
&gEfiExtScsiPassThruProtocolGuid,
- (VOID **) &PassThru,
+ (VOID **)&PassThru,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1094,14 +1105,15 @@ IScsiStop ( // Get the handle of the controller we are controlling.
//
if (IpVersion == IP_VERSION_4) {
- ProtocolGuid = &gIScsiV4PrivateGuid;
- TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
- TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
+ ProtocolGuid = &gIScsiV4PrivateGuid;
+ TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
+ TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
} else {
- ProtocolGuid = &gIScsiV6PrivateGuid;
- TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
- TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
+ ProtocolGuid = &gIScsiV6PrivateGuid;
+ TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
+ TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
}
+
IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
if (IScsiController == NULL) {
return EFI_SUCCESS;
@@ -1110,7 +1122,7 @@ IScsiStop ( Status = gBS->OpenProtocol (
IScsiController,
ProtocolGuid,
- (VOID **) &IScsiIdentifier,
+ (VOID **)&IScsiIdentifier,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1272,7 +1284,7 @@ IScsiIp4DriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
if (Status == EFI_ALREADY_STARTED) {
@@ -1427,7 +1439,7 @@ IScsiIp6DriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
if (Status == EFI_ALREADY_STARTED) {
@@ -1496,12 +1508,12 @@ IScsiUnload ( IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- UINTN DeviceHandleCount;
- EFI_HANDLE *DeviceHandleBuffer;
- UINTN Index;
- EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ EFI_STATUS Status;
+ UINTN DeviceHandleCount;
+ EFI_HANDLE *DeviceHandleBuffer;
+ UINTN Index;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Try to disconnect the driver from the devices it's controlling.
@@ -1524,11 +1536,13 @@ IScsiUnload ( Status = IScsiTestManagedDevice (
DeviceHandleBuffer[Index],
gIScsiIp4DriverBinding.DriverBindingHandle,
- &gEfiTcp4ProtocolGuid)
- ;
+ &gEfiTcp4ProtocolGuid
+ )
+ ;
if (EFI_ERROR (Status)) {
continue;
}
+
Status = gBS->DisconnectController (
DeviceHandleBuffer[Index],
gIScsiIp4DriverBinding.DriverBindingHandle,
@@ -1551,6 +1565,7 @@ IScsiUnload ( if (EFI_ERROR (Status)) {
continue;
}
+
Status = gBS->DisconnectController (
DeviceHandleBuffer[Index],
gIScsiIp6DriverBinding.DriverBindingHandle,
@@ -1582,11 +1597,12 @@ IScsiUnload ( goto ON_EXIT;
}
- if (gIScsiControllerNameTable!= NULL) {
+ if (gIScsiControllerNameTable != NULL) {
Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
gIScsiControllerNameTable = NULL;
}
@@ -1597,15 +1613,15 @@ IScsiUnload ( Status = gBS->HandleProtocol (
gIScsiIp4DriverBinding.DriverBindingHandle,
&gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
+ (VOID **)&ComponentName
);
if (!EFI_ERROR (Status)) {
Status = gBS->UninstallMultipleProtocolInterfaces (
- gIScsiIp4DriverBinding.DriverBindingHandle,
- &gEfiComponentNameProtocolGuid,
- ComponentName,
- NULL
- );
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ ComponentName,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -1614,7 +1630,7 @@ IScsiUnload ( Status = gBS->HandleProtocol (
gIScsiIp4DriverBinding.DriverBindingHandle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
@@ -1635,15 +1651,15 @@ IScsiUnload ( Status = gBS->HandleProtocol (
gIScsiIp6DriverBinding.DriverBindingHandle,
&gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
+ (VOID **)&ComponentName
);
if (!EFI_ERROR (Status)) {
Status = gBS->UninstallMultipleProtocolInterfaces (
- gIScsiIp6DriverBinding.DriverBindingHandle,
- &gEfiComponentNameProtocolGuid,
- ComponentName,
- NULL
- );
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ ComponentName,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -1652,7 +1668,7 @@ IScsiUnload ( Status = gBS->HandleProtocol (
gIScsiIp6DriverBinding.DriverBindingHandle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
@@ -1716,8 +1732,8 @@ ON_EXIT: EFI_STATUS
EFIAPI
IScsiDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -1730,7 +1746,7 @@ IScsiDriverEntryPoint ( Status = gBS->LocateProtocol (
&gEfiIScsiInitiatorNameProtocolGuid,
NULL,
- (VOID **) &IScsiInitiatorName
+ (VOID **)&IScsiInitiatorName
);
if (!EFI_ERROR (Status)) {
return EFI_ACCESS_DENIED;
@@ -1821,7 +1837,7 @@ IScsiDriverEntryPoint ( Status = gBS->LocateProtocol (
&gEfiAuthenticationInfoProtocolGuid,
NULL,
- (VOID **) &AuthenticationInfo
+ (VOID **)&AuthenticationInfo
);
if (Status == EFI_NOT_FOUND) {
Status = gBS->InstallProtocolInterface (
@@ -1873,4 +1889,3 @@ Error1: return Status;
}
-
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h b/NetworkPkg/IScsiDxe/IScsiDriver.h index 070dbbad75..bc8b147f0e 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.h +++ b/NetworkPkg/IScsiDxe/IScsiDriver.h @@ -21,10 +21,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent 0x28be27e5, 0x66cc, 0x4a31, { 0xa3, 0x15, 0xdb, 0x14, 0xc3, 0x74, 0x4d, 0x85 } \
}
-#define ISCSI_INITIATOR_NAME_VAR_NAME L"I_NAME"
+#define ISCSI_INITIATOR_NAME_VAR_NAME L"I_NAME"
-#define IP_MODE_AUTOCONFIG_IP4 3
-#define IP_MODE_AUTOCONFIG_IP6 4
+#define IP_MODE_AUTOCONFIG_IP4 3
+#define IP_MODE_AUTOCONFIG_IP6 4
#define ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_ISCSI_HBA 0x00
#define STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP 0x01
#define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4 0x02
@@ -45,41 +45,41 @@ extern EFI_GUID gIScsiV4PrivateGuid; extern EFI_GUID gIScsiV6PrivateGuid;
typedef struct {
- CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];
- LIST_ENTRY NicInfoList;
- UINT8 NicCount;
- UINT8 CurrentNic;
- UINT8 MaxNic;
- BOOLEAN Ipv6Flag;
- BOOLEAN OneSessionEstablished;
- BOOLEAN EnableMpio;
- UINT8 MpioCount; // The number of attempts in MPIO.
- UINT8 Krb5MpioCount; // The number of attempts login with KRB5 in MPIO.
- UINT8 SinglePathCount; // The number of single path attempts.
- UINT8 ValidSinglePathCount; // The number of valid single path attempts.
- UINT8 BootSelectedIndex;
- UINT8 AttemptCount;
- LIST_ENTRY AttemptConfigs; // User configured Attempt list.
- CHAR8 InitiatorName[ISCSI_NAME_MAX_SIZE];
- UINTN InitiatorNameLength;
+ CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];
+ LIST_ENTRY NicInfoList;
+ UINT8 NicCount;
+ UINT8 CurrentNic;
+ UINT8 MaxNic;
+ BOOLEAN Ipv6Flag;
+ BOOLEAN OneSessionEstablished;
+ BOOLEAN EnableMpio;
+ UINT8 MpioCount; // The number of attempts in MPIO.
+ UINT8 Krb5MpioCount; // The number of attempts login with KRB5 in MPIO.
+ UINT8 SinglePathCount; // The number of single path attempts.
+ UINT8 ValidSinglePathCount; // The number of valid single path attempts.
+ UINT8 BootSelectedIndex;
+ UINT8 AttemptCount;
+ LIST_ENTRY AttemptConfigs; // User configured Attempt list.
+ CHAR8 InitiatorName[ISCSI_NAME_MAX_SIZE];
+ UINTN InitiatorNameLength;
} ISCSI_PRIVATE_DATA;
-extern ISCSI_PRIVATE_DATA *mPrivate;
+extern ISCSI_PRIVATE_DATA *mPrivate;
typedef struct {
- LIST_ENTRY Link;
- UINT32 HwAddressSize;
- EFI_MAC_ADDRESS PermanentAddress;
- UINT8 NicIndex;
- UINT16 VlanId;
- UINTN BusNumber;
- UINTN DeviceNumber;
- UINTN FunctionNumber;
- BOOLEAN Ipv6Available;
+ LIST_ENTRY Link;
+ UINT32 HwAddressSize;
+ EFI_MAC_ADDRESS PermanentAddress;
+ UINT8 NicIndex;
+ UINT16 VlanId;
+ UINTN BusNumber;
+ UINTN DeviceNumber;
+ UINTN FunctionNumber;
+ BOOLEAN Ipv6Available;
} ISCSI_NIC_INFO;
typedef struct _ISCSI_PRIVATE_PROTOCOL {
- UINT32 Reserved;
+ UINT32 Reserved;
} ISCSI_PRIVATE_PROTOCOL;
//
@@ -388,9 +388,9 @@ IScsiIp6DriverBindingStop ( EFI_STATUS
EFIAPI
IScsiComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
);
/**
@@ -465,11 +465,11 @@ IScsiComponentNameGetDriverName ( EFI_STATUS
EFIAPI
IScsiComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
@@ -560,9 +560,9 @@ IScsiSetInitiatorName ( EFI_STATUS
EFIAPI
IScsiGetAuthenticationInfo (
- IN EFI_AUTHENTICATION_INFO_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- OUT VOID **Buffer
+ IN EFI_AUTHENTICATION_INFO_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ OUT VOID **Buffer
);
/**
@@ -641,11 +641,11 @@ IScsiSetAuthenticationInfo ( EFI_STATUS
EFIAPI
IScsiExtScsiPassThruFunction (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
);
/**
diff --git a/NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c b/NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c index 06fcf92bbe..fde47221f6 100644 --- a/NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c +++ b/NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c @@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
+EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
NULL,
IScsiExtScsiPassThruFunction,
IScsiExtScsiPassThruGetNextTargetLun,
@@ -19,7 +19,6 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = { IScsiExtScsiPassThruGetNextTarget
};
-
/**
Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel.
This function supports both blocking I/O and nonblocking I/O. The blocking I/O
@@ -73,11 +72,11 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = { EFI_STATUS
EFIAPI
IScsiExtScsiPassThruFunction (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
)
{
EFI_STATUS Status;
@@ -107,7 +106,6 @@ IScsiExtScsiPassThruFunction ( return Status;
}
-
/**
Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on
a SCSI channel. These can either be the list SCSI devices that are actually
@@ -145,14 +143,14 @@ IScsiExtScsiPassThruGetNextTargetLun ( IN OUT UINT64 *Lun
)
{
- ISCSI_DRIVER_DATA *Private;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
- UINT8 TargetId[TARGET_MAX_BYTES];
+ ISCSI_DRIVER_DATA *Private;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
+ UINT8 TargetId[TARGET_MAX_BYTES];
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
- ConfigNvData = &Private->Session->ConfigData->SessionConfigData;
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
+ ConfigNvData = &Private->Session->ConfigData->SessionConfigData;
- if ((*Target)[0] == 0 && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {
+ if (((*Target)[0] == 0) && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {
//
// Only one <Target, Lun> pair per iSCSI Driver instance.
//
@@ -170,7 +168,6 @@ IScsiExtScsiPassThruGetNextTargetLun ( return EFI_INVALID_PARAMETER;
}
-
/**
Allocate and build a device path node for a SCSI device on a SCSI channel.
@@ -206,12 +203,12 @@ IScsiExtScsiPassThruBuildDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- ISCSI_DRIVER_DATA *Private;
- ISCSI_SESSION *Session;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
- ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
- EFI_DEV_PATH *Node;
- UINTN DevPathNodeLen;
+ ISCSI_DRIVER_DATA *Private;
+ ISCSI_SESSION *Session;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
+ ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
+ EFI_DEV_PATH *Node;
+ UINTN DevPathNodeLen;
if (DevicePath == NULL) {
return EFI_INVALID_PARAMETER;
@@ -221,17 +218,17 @@ IScsiExtScsiPassThruBuildDevicePath ( return EFI_NOT_FOUND;
}
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
- Session = Private->Session;
- ConfigNvData = &Session->ConfigData->SessionConfigData;
- AuthConfig = Session->AuthData.CHAP.AuthConfig;
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
+ Session = Private->Session;
+ ConfigNvData = &Session->ConfigData->SessionConfigData;
+ AuthConfig = Session->AuthData.CHAP.AuthConfig;
if (CompareMem (&Lun, ConfigNvData->BootLun, sizeof (UINT64)) != 0) {
return EFI_NOT_FOUND;
}
- DevPathNodeLen = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData->TargetName) + 1;
- Node = AllocateZeroPool (DevPathNodeLen);
+ DevPathNodeLen = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData->TargetName) + 1;
+ Node = AllocateZeroPool (DevPathNodeLen);
if (Node == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -245,36 +242,36 @@ IScsiExtScsiPassThruBuildDevicePath ( //
Node->Iscsi.NetworkProtocol = 0;
- Node->Iscsi.LoginOption = 0;
+ Node->Iscsi.LoginOption = 0;
switch (Session->AuthType) {
- case ISCSI_AUTH_TYPE_NONE:
- Node->Iscsi.LoginOption |= 0x0800;
- break;
-
- case ISCSI_AUTH_TYPE_CHAP:
- //
- // Bit12: 0=CHAP_BI, 1=CHAP_UNI
- //
- if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
- Node->Iscsi.LoginOption |= 0x1000;
- }
- break;
-
- default:
- break;
+ case ISCSI_AUTH_TYPE_NONE:
+ Node->Iscsi.LoginOption |= 0x0800;
+ break;
+
+ case ISCSI_AUTH_TYPE_CHAP:
+ //
+ // Bit12: 0=CHAP_BI, 1=CHAP_UNI
+ //
+ if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
+ Node->Iscsi.LoginOption |= 0x1000;
+ }
+
+ break;
+
+ default:
+ break;
}
CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));
Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;
- AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);
+ AsciiStrCpyS ((CHAR8 *)Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);
- *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Node;
return EFI_SUCCESS;
}
-
/**
Translate a device path node to a Target ID and LUN.
@@ -305,8 +302,8 @@ IScsiExtScsiPassThruGetTargetLun ( OUT UINT64 *Lun
)
{
- ISCSI_DRIVER_DATA *Private;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
+ ISCSI_DRIVER_DATA *Private;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -315,17 +312,18 @@ IScsiExtScsiPassThruGetTargetLun ( if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
(DevicePath->SubType != MSG_ISCSI_DP) ||
(DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH))
- ) {
+ )
+ {
return EFI_UNSUPPORTED;
}
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
- ConfigNvData = &Private->Session->ConfigData->SessionConfigData;
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
+ ConfigNvData = &Private->Session->ConfigData->SessionConfigData;
SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
(*Target)[0] = 0;
- if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *) DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) {
+ if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *)DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) {
return EFI_UNSUPPORTED;
}
@@ -334,7 +332,6 @@ IScsiExtScsiPassThruGetTargetLun ( return EFI_SUCCESS;
}
-
/**
Resets a SCSI channel. This operation resets all the SCSI devices connected to
the SCSI channel.
@@ -353,7 +350,6 @@ IScsiExtScsiPassThruResetChannel ( return EFI_UNSUPPORTED;
}
-
/**
Resets a SCSI device that is connected to a SCSI channel.
@@ -403,7 +399,7 @@ IScsiExtScsiPassThruGetNextTarget ( IN OUT UINT8 **Target
)
{
- UINT8 TargetId[TARGET_MAX_BYTES];
+ UINT8 TargetId[TARGET_MAX_BYTES];
SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);
@@ -416,4 +412,3 @@ IScsiExtScsiPassThruGetNextTarget ( return EFI_INVALID_PARAMETER;
}
}
-
diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c index b2f82cb9b1..155ecad554 100644 --- a/NetworkPkg/IScsiDxe/IScsiIbft.c +++ b/NetworkPkg/IScsiDxe/IScsiIbft.c @@ -8,8 +8,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-BOOLEAN mIbftInstalled = FALSE;
-UINTN mTableKey;
+BOOLEAN mIbftInstalled = FALSE;
+UINTN mTableKey;
/**
Initialize the header of the iSCSI Boot Firmware Table.
@@ -21,9 +21,9 @@ UINTN mTableKey; **/
VOID
IScsiInitIbfTableHeader (
- OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header,
- IN UINT8 *OemId,
- IN UINT64 *OemTableId
+ OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header,
+ IN UINT8 *OemId,
+ IN UINT64 *OemTableId
)
{
Header->Signature = EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE;
@@ -35,7 +35,6 @@ IScsiInitIbfTableHeader ( CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
}
-
/**
Initialize the control section of the iSCSI Boot Firmware Table.
@@ -50,11 +49,11 @@ IScsiInitControlSection ( EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control;
UINTN NumOffset;
- Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1);
+ Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
Control->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID;
Control->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION;
- Control->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE);
+ Control->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE);
//
// If in multipathing mode, enable the Boot Failover Flag.
@@ -65,7 +64,7 @@ IScsiInitControlSection ( //
if (mPrivate->EnableMpio) {
Control->Header.Flags = 0;
- NumOffset = 2 * (mPrivate->MpioCount - mPrivate->Krb5MpioCount);
+ NumOffset = 2 * (mPrivate->MpioCount - mPrivate->Krb5MpioCount);
} else {
NumOffset = 2 * mPrivate->ValidSinglePathCount;
}
@@ -79,11 +78,10 @@ IScsiInitControlSection ( // Need expand the control section if more than 2 NIC/Target attempts
// exist.
//
- Control->Header.Length = (UINT16) (Control->Header.Length + (NumOffset - 4) * sizeof (UINT16));
+ Control->Header.Length = (UINT16)(Control->Header.Length + (NumOffset - 4) * sizeof (UINT16));
}
}
-
/**
Add one item into the heap.
@@ -109,7 +107,6 @@ IScsiAddHeapItem ( *(*Heap + Len) = 0;
}
-
/**
Fill the Initiator section of the iSCSI Boot Firmware Table.
@@ -126,19 +123,19 @@ IScsiFillInitiatorSection ( EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control;
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *Initiator;
- Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1);
+ Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
//
// Initiator section immediately follows the control section.
//
Initiator = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *)
- ((UINT8 *) Control + IBFT_ROUNDUP (Control->Header.Length));
+ ((UINT8 *)Control + IBFT_ROUNDUP (Control->Header.Length));
- Control->InitiatorOffset = (UINT16) ((UINTN) Initiator - (UINTN) Table);
+ Control->InitiatorOffset = (UINT16)((UINTN)Initiator - (UINTN)Table);
Initiator->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID;
Initiator->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION;
- Initiator->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE);
+ Initiator->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE);
Initiator->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOCK_VALID |
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED;
@@ -147,11 +144,10 @@ IScsiFillInitiatorSection ( //
IScsiAddHeapItem (Heap, mPrivate->InitiatorName, mPrivate->InitiatorNameLength - 1);
- Initiator->IScsiNameLength = (UINT16) (mPrivate->InitiatorNameLength - 1);
- Initiator->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
+ Initiator->IScsiNameLength = (UINT16)(mPrivate->InitiatorNameLength - 1);
+ Initiator->IScsiNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
}
-
/**
Map the v4 IP address into v6 IP address.
@@ -161,23 +157,22 @@ IScsiFillInitiatorSection ( **/
VOID
IScsiMapV4ToV6Addr (
- IN EFI_IPv4_ADDRESS *V4,
- OUT EFI_IPv6_ADDRESS *V6
+ IN EFI_IPv4_ADDRESS *V4,
+ OUT EFI_IPv6_ADDRESS *V6
)
{
- UINTN Index;
+ UINTN Index;
ZeroMem (V6, sizeof (EFI_IPv6_ADDRESS));
- V6->Addr[10] = 0xff;
- V6->Addr[11] = 0xff;
+ V6->Addr[10] = 0xff;
+ V6->Addr[11] = 0xff;
for (Index = 0; Index < 4; Index++) {
V6->Addr[12 + Index] = V4->Addr[Index];
}
}
-
/**
Fill the NIC and target sections in iSCSI Boot Firmware Table.
@@ -208,11 +203,11 @@ IScsiFillNICAndTargetSections ( //
// Get the offset of the first Nic and Target section.
//
- Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1);
- Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *) ((UINTN) Table +
- Control->InitiatorOffset + IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE)));
- Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *) ((UINTN) Nic +
- IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
+ Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
+ Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)((UINTN)Table +
+ Control->InitiatorOffset + IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE)));
+ Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *)((UINTN)Nic +
+ IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
SectionOffset = &Control->NIC0Offset;
@@ -233,11 +228,10 @@ IScsiFillNICAndTargetSections ( }
ASSERT (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED);
-
} else {
- if (Index == 1 && Flag) {
+ if ((Index == 1) && Flag) {
Entry = mPrivate->AttemptConfigs.ForwardLink;
- Flag = FALSE;
+ Flag = FALSE;
}
Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
@@ -260,7 +254,7 @@ IScsiFillNICAndTargetSections ( //
// If multipath mode is enabled, only the attempts in MPIO will be recorded in iBFT.
//
- if (mPrivate->EnableMpio && Attempt->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) {
+ if (mPrivate->EnableMpio && (Attempt->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO)) {
continue;
}
@@ -280,13 +274,13 @@ IScsiFillNICAndTargetSections ( Nic->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID;
Nic->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION;
- Nic->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);
- Nic->Header.Index = (UINT8) Index;
+ Nic->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);
+ Nic->Header.Index = (UINT8)Index;
Nic->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID |
- EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL;
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL;
if (Index == 0) {
- Nic->Header.Flags |= EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BOOT_SELECTED;
+ Nic->Header.Flags |= EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BOOT_SELECTED;
}
if (NvData->InitiatorInfoFromDhcp) {
@@ -295,7 +289,7 @@ IScsiFillNICAndTargetSections ( Nic->Origin = IpPrefixOriginManual;
}
- if (NvData->IpMode == IP_MODE_IP4 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
+ if ((NvData->IpMode == IP_MODE_IP4) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
//
// Get the subnet mask prefix length.
//
@@ -309,16 +303,13 @@ IScsiFillNICAndTargetSections ( IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns);
IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns);
IScsiMapV4ToV6Addr (&Attempt->DhcpServer.v4, &Nic->DhcpServer);
-
- } else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
-
+ } else if ((NvData->IpMode == IP_MODE_IP6) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
Nic->SubnetMaskPrefixLength = NvData->PrefixLength;
CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
-
} else {
ASSERT (FALSE);
}
@@ -331,26 +322,26 @@ IScsiFillNICAndTargetSections ( Nic->VLanTag = NicInfo->VlanId;
CopyMem (Nic->Mac, &NicInfo->PermanentAddress, sizeof (Nic->Mac));
- Nic->PciLocation = (UINT16) ((NicInfo->BusNumber << 8) |
- (NicInfo->DeviceNumber << 3) | NicInfo->FunctionNumber);
- *SectionOffset = (UINT16) ((UINTN) Nic - (UINTN) Table);
+ Nic->PciLocation = (UINT16)((NicInfo->BusNumber << 8) |
+ (NicInfo->DeviceNumber << 3) | NicInfo->FunctionNumber);
+ *SectionOffset = (UINT16)((UINTN)Nic - (UINTN)Table);
SectionOffset++;
//
// Fill the Target section.
//
- Target->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID;
- Target->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION;
- Target->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);
- Target->Header.Index = (UINT8) Index;
- Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID;
+ Target->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID;
+ Target->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION;
+ Target->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);
+ Target->Header.Index = (UINT8)Index;
+ Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID;
if (Index == 0) {
- Target->Header.Flags |= EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_SELECTED;
+ Target->Header.Flags |= EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_SELECTED;
}
- Target->Port = NvData->TargetPort;
+ Target->Port = NvData->TargetPort;
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
@@ -362,11 +353,11 @@ IScsiFillNICAndTargetSections ( Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP;
}
- Target->NicIndex = (UINT8) Index;
+ Target->NicIndex = (UINT8)Index;
- if (NvData->IpMode == IP_MODE_IP4 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
+ if ((NvData->IpMode == IP_MODE_IP4) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
IScsiMapV4ToV6Addr (&NvData->TargetIp.v4, &Target->Ip);
- } else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
+ } else if ((NvData->IpMode == IP_MODE_IP6) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
CopyMem (&Target->Ip, &NvData->TargetIp, sizeof (EFI_IPv6_ADDRESS));
} else {
ASSERT (FALSE);
@@ -377,64 +368,63 @@ IScsiFillNICAndTargetSections ( //
// Target iSCSI Name, CHAP name/secret, reverse CHAP name/secret.
//
- Length = (UINT16) AsciiStrLen (NvData->TargetName);
+ Length = (UINT16)AsciiStrLen (NvData->TargetName);
IScsiAddHeapItem (Heap, NvData->TargetName, Length);
Target->IScsiNameLength = Length;
- Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
+ Target->IScsiNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
//
// CHAP Name
//
- Length = (UINT16) AsciiStrLen (AuthConfig->CHAPName);
+ Length = (UINT16)AsciiStrLen (AuthConfig->CHAPName);
IScsiAddHeapItem (Heap, AuthConfig->CHAPName, Length);
- Target->CHAPNameLength = Length;
- Target->CHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
+ Target->CHAPNameLength = Length;
+ Target->CHAPNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
//
// CHAP Secret
//
- Length = (UINT16) AsciiStrLen (AuthConfig->CHAPSecret);
+ Length = (UINT16)AsciiStrLen (AuthConfig->CHAPSecret);
IScsiAddHeapItem (Heap, AuthConfig->CHAPSecret, Length);
- Target->CHAPSecretLength = Length;
- Target->CHAPSecretOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
+ Target->CHAPSecretLength = Length;
+ Target->CHAPSecretOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) {
//
// Reverse CHAP Name.
//
- Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPName);
+ Length = (UINT16)AsciiStrLen (AuthConfig->ReverseCHAPName);
IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPName, Length);
Target->ReverseCHAPNameLength = Length;
- Target->ReverseCHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
+ Target->ReverseCHAPNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
//
// Reverse CHAP Secret.
//
- Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPSecret);
+ Length = (UINT16)AsciiStrLen (AuthConfig->ReverseCHAPSecret);
IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPSecret, Length);
Target->ReverseCHAPSecretLength = Length;
- Target->ReverseCHAPSecretOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
+ Target->ReverseCHAPSecretOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
}
}
- *SectionOffset = (UINT16) ((UINTN) Target - (UINTN) Table);
+ *SectionOffset = (UINT16)((UINTN)Target - (UINTN)Table);
SectionOffset++;
//
// Advance to the next NIC/Target pair.
//
- Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *) ((UINTN) Target +
- IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE)));
- Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *) ((UINTN) Nic +
- IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
+ Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)((UINTN)Target +
+ IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE)));
+ Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *)((UINTN)Nic +
+ IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
Index++;
}
}
-
/**
Publish and remove the iSCSI Boot Firmware Table according to the iSCSI
session status.
@@ -457,29 +447,29 @@ IScsiPublishIbft ( Rsdt = NULL;
Xsdt = NULL;
- Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
// Find ACPI table RSD_PTR from the system table.
//
- Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp);
+ Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **)&Rsdp);
if (EFI_ERROR (Status)) {
- Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp);
+ Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **)&Rsdp);
}
if (EFI_ERROR (Status) || (Rsdp == NULL)) {
- return ;
- } else if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) {
- Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
+ return;
+ } else if ((Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) && (Rsdp->XsdtAddress != 0)) {
+ Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress;
} else if (Rsdp->RsdtAddress != 0) {
- Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
+ Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress;
}
if ((Xsdt == NULL) && (Rsdt == NULL)) {
- return ;
+ return;
}
if (mIbftInstalled) {
@@ -488,17 +478,19 @@ IScsiPublishIbft ( mTableKey
);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
+
mIbftInstalled = FALSE;
}
//
// If there is no valid attempt configuration, just return.
//
- if ((!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount == 0) ||
- (mPrivate->EnableMpio && mPrivate->MpioCount <= mPrivate->Krb5MpioCount)) {
- return ;
+ if ((!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount == 0)) ||
+ (mPrivate->EnableMpio && (mPrivate->MpioCount <= mPrivate->Krb5MpioCount)))
+ {
+ return;
}
//
@@ -506,10 +498,10 @@ IScsiPublishIbft ( //
Table = AllocateZeroPool (IBFT_MAX_SIZE);
if (Table == NULL) {
- return ;
+ return;
}
- Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
+ Heap = (UINT8 *)Table + IBFT_HEAP_OFFSET;
//
// Fill in the various section of the iSCSI Boot Firmware Table.
@@ -524,7 +516,7 @@ IScsiPublishIbft ( IScsiFillInitiatorSection (Table, &Heap);
IScsiFillNICAndTargetSections (Table, &Heap);
- Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
+ Checksum = CalculateCheckSum8 ((UINT8 *)Table, Table->Length);
Table->Checksum = Checksum;
//
@@ -536,7 +528,7 @@ IScsiPublishIbft ( Table->Length,
&mTableKey
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.h b/NetworkPkg/IScsiDxe/IScsiIbft.h index 98eb56e5c5..168734d3f1 100644 --- a/NetworkPkg/IScsiDxe/IScsiIbft.h +++ b/NetworkPkg/IScsiDxe/IScsiIbft.h @@ -14,9 +14,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/AcpiTable.h>
#include <Protocol/PciIo.h>
-#define IBFT_TABLE_VAR_NAME L"iBFT"
-#define IBFT_MAX_SIZE 4096
-#define IBFT_HEAP_OFFSET 2048
+#define IBFT_TABLE_VAR_NAME L"iBFT"
+#define IBFT_MAX_SIZE 4096
+#define IBFT_HEAP_OFFSET 2048
#define IBFT_ROUNDUP(size) NET_ROUNDUP ((size), EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_ALIGNMENT)
diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiImpl.h index ac3a25730e..1d1a170c0e 100644 --- a/NetworkPkg/IScsiDxe/IScsiImpl.h +++ b/NetworkPkg/IScsiDxe/IScsiImpl.h @@ -67,105 +67,105 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiDns.h"
#include "IScsiConfig.h"
-#define ISCSI_AUTH_INITIAL 0
+#define ISCSI_AUTH_INITIAL 0
-#define ISCSI_SESSION_SIGNATURE SIGNATURE_32 ('I', 'S', 'S', 'N')
+#define ISCSI_SESSION_SIGNATURE SIGNATURE_32 ('I', 'S', 'S', 'N')
///
/// 10 seconds
///
-#define ISCSI_GET_MAPPING_TIMEOUT 100000000U
+#define ISCSI_GET_MAPPING_TIMEOUT 100000000U
///
/// 3 seconds
///
#define ISCSI_WAIT_IPSEC_TIMEOUT 30000000U
struct _ISCSI_SESSION {
- UINT32 Signature;
+ UINT32 Signature;
- ISCSI_DRIVER_DATA *Private;
- ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData;
+ ISCSI_DRIVER_DATA *Private;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData;
- UINT8 AuthType;
+ UINT8 AuthType;
union {
- ISCSI_CHAP_AUTH_DATA CHAP;
+ ISCSI_CHAP_AUTH_DATA CHAP;
} AuthData;
- UINT8 State;
+ UINT8 State;
- UINT8 Isid[6];
- UINT16 Tsih;
+ UINT8 Isid[6];
+ UINT16 Tsih;
- UINT32 CmdSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
+ UINT32 CmdSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
- UINT32 InitiatorTaskTag;
- UINT16 NextCid;
+ UINT32 InitiatorTaskTag;
+ UINT16 NextCid;
- LIST_ENTRY Conns;
- UINT32 NumConns;
+ LIST_ENTRY Conns;
+ UINT32 NumConns;
- LIST_ENTRY TcbList;
+ LIST_ENTRY TcbList;
//
// Session-wide parameters
//
- UINT16 TargetPortalGroupTag;
- UINT32 MaxConnections;
- BOOLEAN InitialR2T;
- BOOLEAN ImmediateData;
- UINT32 MaxBurstLength;
- UINT32 FirstBurstLength;
- UINT32 DefaultTime2Wait;
- UINT32 DefaultTime2Retain;
- UINT16 MaxOutstandingR2T;
- BOOLEAN DataPDUInOrder;
- BOOLEAN DataSequenceInOrder;
- UINT8 ErrorRecoveryLevel;
+ UINT16 TargetPortalGroupTag;
+ UINT32 MaxConnections;
+ BOOLEAN InitialR2T;
+ BOOLEAN ImmediateData;
+ UINT32 MaxBurstLength;
+ UINT32 FirstBurstLength;
+ UINT32 DefaultTime2Wait;
+ UINT32 DefaultTime2Retain;
+ UINT16 MaxOutstandingR2T;
+ BOOLEAN DataPDUInOrder;
+ BOOLEAN DataSequenceInOrder;
+ UINT8 ErrorRecoveryLevel;
};
#define ISCSI_CONNECTION_SIGNATURE SIGNATURE_32 ('I', 'S', 'C', 'N')
struct _ISCSI_CONNECTION {
- UINT32 Signature;
- LIST_ENTRY Link;
+ UINT32 Signature;
+ LIST_ENTRY Link;
- EFI_EVENT TimeoutEvent;
+ EFI_EVENT TimeoutEvent;
- ISCSI_SESSION *Session;
+ ISCSI_SESSION *Session;
- UINT8 State;
- UINT8 CurrentStage;
- UINT8 NextStage;
+ UINT8 State;
+ UINT8 CurrentStage;
+ UINT8 NextStage;
- UINT8 AuthStep;
+ UINT8 AuthStep;
- BOOLEAN PartialReqSent;
- BOOLEAN PartialRspRcvd;
+ BOOLEAN PartialReqSent;
+ BOOLEAN PartialRspRcvd;
- BOOLEAN TransitInitiated;
- BOOLEAN ParamNegotiated;
+ BOOLEAN TransitInitiated;
+ BOOLEAN ParamNegotiated;
- UINT16 Cid;
- UINT32 ExpStatSN;
+ UINT16 Cid;
+ UINT32 ExpStatSN;
//
// Queues...
//
- NET_BUF_QUEUE RspQue;
+ NET_BUF_QUEUE RspQue;
- BOOLEAN Ipv6Flag;
- TCP_IO TcpIo;
+ BOOLEAN Ipv6Flag;
+ TCP_IO TcpIo;
//
// Connection-only parameters.
//
- UINT32 MaxRecvDataSegmentLength;
- ISCSI_DIGEST_TYPE HeaderDigest;
- ISCSI_DIGEST_TYPE DataDigest;
+ UINT32 MaxRecvDataSegmentLength;
+ ISCSI_DIGEST_TYPE HeaderDigest;
+ ISCSI_DIGEST_TYPE DataDigest;
};
-#define ISCSI_DRIVER_DATA_SIGNATURE SIGNATURE_32 ('I', 'S', 'D', 'A')
+#define ISCSI_DRIVER_DATA_SIGNATURE SIGNATURE_32 ('I', 'S', 'D', 'A')
#define ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU(PassThru) \
CR ( \
@@ -184,19 +184,19 @@ struct _ISCSI_CONNECTION { )
struct _ISCSI_DRIVER_DATA {
- UINT32 Signature;
- EFI_HANDLE Image;
- EFI_HANDLE Controller;
- ISCSI_PRIVATE_PROTOCOL IScsiIdentifier;
-
- EFI_EVENT ExitBootServiceEvent;
-
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL IScsiExtScsiPassThru;
- EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
- EFI_HANDLE ExtScsiPassThruHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE ChildHandle;
- ISCSI_SESSION *Session;
+ UINT32 Signature;
+ EFI_HANDLE Image;
+ EFI_HANDLE Controller;
+ ISCSI_PRIVATE_PROTOCOL IScsiIdentifier;
+
+ EFI_EVENT ExitBootServiceEvent;
+
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL IScsiExtScsiPassThru;
+ EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
+ EFI_HANDLE ExtScsiPassThruHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE ChildHandle;
+ ISCSI_SESSION *Session;
};
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiInitiatorName.c b/NetworkPkg/IScsiDxe/IScsiInitiatorName.c index 0d332e5c6c..3eee10ba29 100644 --- a/NetworkPkg/IScsiDxe/IScsiInitiatorName.c +++ b/NetworkPkg/IScsiDxe/IScsiInitiatorName.c @@ -8,12 +8,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {
+EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {
IScsiGetInitiatorName,
IScsiSetInitiatorName
};
-
/**
Retrieves the current set value of iSCSI Initiator Name.
@@ -64,7 +63,6 @@ IScsiGetInitiatorName ( return Status;
}
-
/**
Sets the iSSI Initiator Name.
@@ -110,10 +108,11 @@ IScsiSetInitiatorName ( *BufferSize = ISCSI_NAME_MAX_SIZE;
return EFI_INVALID_PARAMETER;
}
+
//
// Only support iqn iSCSI names.
//
- Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1);
+ Status = IScsiNormalizeName ((CHAR8 *)Buffer, *BufferSize - 1);
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index 4069547867..b3ea90158f 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -21,22 +21,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFa **/
VOID
IScsiStrTrim (
- IN OUT CHAR16 *Str,
- IN CHAR16 CharC
+ IN OUT CHAR16 *Str,
+ IN CHAR16 CharC
)
{
CHAR16 *Pointer1;
CHAR16 *Pointer2;
if (*Str == 0) {
- return ;
+ return;
}
//
// Trim off the leading and trailing characters c
//
for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) {
- ;
}
Pointer2 = Str;
@@ -47,18 +46,18 @@ IScsiStrTrim ( }
} else {
while (*Pointer1 != 0) {
- *Pointer2 = *Pointer1;
- Pointer1++;
- Pointer2++;
+ *Pointer2 = *Pointer1;
+ Pointer1++;
+ Pointer2++;
}
+
*Pointer2 = 0;
}
-
- for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {
- ;
+ for (Pointer1 = Str + StrLen (Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {
}
- if (Pointer1 != Str + StrLen(Str) - 1) {
+
+ if (Pointer1 != Str + StrLen (Str) - 1) {
*(Pointer1 + 1) = 0;
}
}
@@ -101,10 +100,9 @@ IScsiGetSubnetMaskPrefixLength ( Len++;
}
- return (UINT8) (32 - Len);
+ return (UINT8)(32 - Len);
}
-
/**
Convert the hexadecimal encoded LUN string into the 64-bit LUN.
@@ -128,15 +126,15 @@ IScsiAsciiStrToLun ( ZeroMem (Lun, 8);
ZeroMem (TemStr, 2);
- ZeroMem ((UINT8 *) Value, sizeof (Value));
+ ZeroMem ((UINT8 *)Value, sizeof (Value));
SizeStr = AsciiStrLen (Str);
IndexValue = 0;
IndexNum = 0;
- for (Index = 0; Index < SizeStr; Index ++) {
+ for (Index = 0; Index < SizeStr; Index++) {
TemStr[0] = Str[Index];
- TemValue = (UINT8) AsciiStrHexToUint64 (TemStr);
- if (TemValue == 0 && TemStr[0] != '0') {
+ TemValue = (UINT8)AsciiStrHexToUint64 (TemStr);
+ if ((TemValue == 0) && (TemStr[0] != '0')) {
if ((TemStr[0] != '-') || (IndexNum == 0)) {
//
// Invalid Lun Char.
@@ -155,6 +153,7 @@ IScsiAsciiStrToLun ( //
return EFI_INVALID_PARAMETER;
}
+
//
// Restart str index for the next lun value.
//
@@ -172,11 +171,11 @@ IScsiAsciiStrToLun ( //
// Combine UINT16 value.
//
- Value[IndexValue] = (UINT16) ((Value[IndexValue] << 4) + TemValue);
+ Value[IndexValue] = (UINT16)((Value[IndexValue] << 4) + TemValue);
}
- for (Index = 0; Index <= IndexValue; Index ++) {
- *((UINT16 *) &Lun[Index * 2]) = HTONS (Value[Index]);
+ for (Index = 0; Index <= IndexValue; Index++) {
+ *((UINT16 *)&Lun[Index * 2]) = HTONS (Value[Index]);
}
return EFI_SUCCESS;
@@ -201,26 +200,26 @@ IScsiLunToUnicodeStr ( TempStr = Str;
for (Index = 0; Index < 4; Index++) {
-
if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) {
CopyMem (TempStr, L"0-", sizeof (L"0-"));
} else {
- TempStr[0] = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];
- TempStr[1] = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F];
- TempStr[2] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] >> 4];
- TempStr[3] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] & 0x0F];
- TempStr[4] = L'-';
- TempStr[5] = 0;
+ TempStr[0] = (CHAR16)IScsiHexString[Lun[2 * Index] >> 4];
+ TempStr[1] = (CHAR16)IScsiHexString[Lun[2 * Index] & 0x0F];
+ TempStr[2] = (CHAR16)IScsiHexString[Lun[2 * Index + 1] >> 4];
+ TempStr[3] = (CHAR16)IScsiHexString[Lun[2 * Index + 1] & 0x0F];
+ TempStr[4] = L'-';
+ TempStr[5] = 0;
IScsiStrTrim (TempStr, L'0');
}
TempStr += StrLen (TempStr);
}
+
//
// Remove the last '-'
//
- ASSERT (StrLen(Str) >= 1);
+ ASSERT (StrLen (Str) >= 1);
Str[StrLen (Str) - 1] = 0;
for (Index = StrLen (Str) - 1; Index > 1; Index = Index - 2) {
@@ -246,26 +245,24 @@ IScsiLunToUnicodeStr ( **/
EFI_STATUS
IScsiAsciiStrToIp (
- IN CHAR8 *Str,
- IN UINT8 IpMode,
- OUT EFI_IP_ADDRESS *Ip
+ IN CHAR8 *Str,
+ IN UINT8 IpMode,
+ OUT EFI_IP_ADDRESS *Ip
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- if (IpMode == IP_MODE_IP4 || IpMode == IP_MODE_AUTOCONFIG_IP4) {
+ if ((IpMode == IP_MODE_IP4) || (IpMode == IP_MODE_AUTOCONFIG_IP4)) {
return NetLibAsciiStrToIp4 (Str, &Ip->v4);
-
- } else if (IpMode == IP_MODE_IP6 || IpMode == IP_MODE_AUTOCONFIG_IP6) {
+ } else if ((IpMode == IP_MODE_IP6) || (IpMode == IP_MODE_AUTOCONFIG_IP6)) {
return NetLibAsciiStrToIp6 (Str, &Ip->v6);
-
} else if (IpMode == IP_MODE_AUTOCONFIG) {
Status = NetLibAsciiStrToIp4 (Str, &Ip->v4);
if (!EFI_ERROR (Status)) {
return Status;
}
- return NetLibAsciiStrToIp6 (Str, &Ip->v6);
+ return NetLibAsciiStrToIp6 (Str, &Ip->v6);
}
return EFI_INVALID_PARAMETER;
@@ -292,14 +289,14 @@ IScsiMacAddrToStr ( CHAR16 *String;
for (Index = 0; Index < Len; Index++) {
- Str[3 * Index] = (CHAR16) IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F];
- Str[3 * Index + 1] = (CHAR16) IScsiHexString[Mac->Addr[Index] & 0x0F];
- Str[3 * Index + 2] = L':';
+ Str[3 * Index] = (CHAR16)IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F];
+ Str[3 * Index + 1] = (CHAR16)IScsiHexString[Mac->Addr[Index] & 0x0F];
+ Str[3 * Index + 2] = L':';
}
- String = &Str[3 * Index - 1] ;
+ String = &Str[3 * Index - 1];
if (VlanId != 0) {
- String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN) VlanId);
+ String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN)VlanId);
}
*String = L'\0';
@@ -322,15 +319,15 @@ IScsiMacAddrToStr ( **/
EFI_STATUS
IScsiBinToHex (
- IN UINT8 *BinBuffer,
- IN UINT32 BinLength,
- IN OUT CHAR8 *HexStr,
- IN OUT UINT32 *HexLength
+ IN UINT8 *BinBuffer,
+ IN UINT32 BinLength,
+ IN OUT CHAR8 *HexStr,
+ IN OUT UINT32 *HexLength
)
{
- UINT32 HexLengthMin;
- UINT32 HexLengthProvided;
- UINT32 Index;
+ UINT32 HexLengthMin;
+ UINT32 HexLengthProvided;
+ UINT32 Index;
if ((HexStr == NULL) || (BinBuffer == NULL) || (BinLength == 0)) {
return EFI_INVALID_PARAMETER;
@@ -340,12 +337,13 @@ IScsiBinToHex ( // Safely calculate: HexLengthMin := BinLength * 2 + 3.
//
if (RETURN_ERROR (SafeUint32Mult (BinLength, 2, &HexLengthMin)) ||
- RETURN_ERROR (SafeUint32Add (HexLengthMin, 3, &HexLengthMin))) {
+ RETURN_ERROR (SafeUint32Add (HexLengthMin, 3, &HexLengthMin)))
+ {
return EFI_BAD_BUFFER_SIZE;
}
HexLengthProvided = *HexLength;
- *HexLength = HexLengthMin;
+ *HexLength = HexLengthMin;
if (HexLengthProvided < HexLengthMin) {
return EFI_BUFFER_TOO_SMALL;
}
@@ -366,7 +364,6 @@ IScsiBinToHex ( return EFI_SUCCESS;
}
-
/**
Convert the hexadecimal string into a binary encoded buffer.
@@ -385,9 +382,9 @@ IScsiBinToHex ( **/
EFI_STATUS
IScsiHexToBin (
- IN OUT UINT8 *BinBuffer,
- IN OUT UINT32 *BinLength,
- IN CHAR8 *HexStr
+ IN OUT UINT8 *BinBuffer,
+ IN OUT UINT32 *BinLength,
+ IN CHAR8 *HexStr
)
{
UINTN BinLengthMin;
@@ -411,9 +408,10 @@ IScsiHexToBin ( //
// Reject an empty hex string; reject a stray nibble.
//
- if (Length == 0 || Length % 2 != 0) {
+ if ((Length == 0) || (Length % 2 != 0)) {
return EFI_INVALID_PARAMETER;
}
+
//
// Check if the caller provides enough room for the decoded blob.
//
@@ -421,31 +419,33 @@ IScsiHexToBin ( if (BinLengthMin > MAX_UINT32) {
return EFI_BAD_BUFFER_SIZE;
}
+
BinLengthProvided = *BinLength;
- *BinLength = (UINT32)BinLengthMin;
+ *BinLength = (UINT32)BinLengthMin;
if (BinLengthProvided < BinLengthMin) {
return EFI_BUFFER_TOO_SMALL;
}
- for (Index = 0; Index < Length; Index ++) {
+ for (Index = 0; Index < Length; Index++) {
TemStr[0] = HexStr[Index];
- Digit = (UINT8) AsciiStrHexToUint64 (TemStr);
- if (Digit == 0 && TemStr[0] != '0') {
+ Digit = (UINT8)AsciiStrHexToUint64 (TemStr);
+ if ((Digit == 0) && (TemStr[0] != '0')) {
//
// Invalid Hex Char.
//
return EFI_INVALID_PARAMETER;
}
+
if ((Index & 1) == 0) {
- BinBuffer [Index/2] = Digit;
+ BinBuffer[Index/2] = Digit;
} else {
- BinBuffer [Index/2] = (UINT8) ((BinBuffer [Index/2] << 4) + Digit);
+ BinBuffer[Index/2] = (UINT8)((BinBuffer[Index/2] << 4) + Digit);
}
}
+
return EFI_SUCCESS;
}
-
/**
Convert the decimal-constant string or hex-constant string into a numerical value.
@@ -468,7 +468,6 @@ IScsiNetNtoi ( return AsciiStrDecimalToUintn (Str);
}
-
/**
Generate random numbers.
@@ -486,12 +485,11 @@ IScsiGenRandom ( while (RandLength > 0) {
Random = NET_RANDOM (NetRandomInitSeed ());
- *Rand++ = (UINT8) (Random);
+ *Rand++ = (UINT8)(Random);
RandLength--;
}
}
-
/**
Check whether UNDI protocol supports IPv6.
@@ -505,22 +503,22 @@ IScsiGenRandom ( **/
EFI_STATUS
IScsiCheckIpv6Support (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE Image,
- OUT BOOLEAN *Ipv6Support
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE Image,
+ OUT BOOLEAN *Ipv6Support
)
{
- EFI_HANDLE Handle;
- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
- EFI_STATUS Status;
- EFI_GUID *InfoTypesBuffer;
- UINTN InfoTypeBufferCount;
- UINTN TypeIndex;
- BOOLEAN Supported;
- VOID *InfoBlock;
- UINTN InfoBlockSize;
-
- EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
+ EFI_HANDLE Handle;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ EFI_STATUS Status;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypeBufferCount;
+ UINTN TypeIndex;
+ BOOLEAN Supported;
+ VOID *InfoBlock;
+ UINTN InfoBlockSize;
+
+ EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
ASSERT (Ipv6Support != NULL);
@@ -530,7 +528,7 @@ IScsiCheckIpv6Support ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
- (VOID **) &Nii,
+ (VOID **)&Nii,
Image,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -552,16 +550,16 @@ IScsiCheckIpv6Support ( Status = gBS->HandleProtocol (
Handle,
&gEfiAdapterInformationProtocolGuid,
- (VOID *) &Aip
+ (VOID *)&Aip
);
- if (EFI_ERROR (Status) || Aip == NULL) {
+ if (EFI_ERROR (Status) || (Aip == NULL)) {
return EFI_NOT_FOUND;
}
InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0;
- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
FreePool (InfoTypesBuffer);
return EFI_NOT_FOUND;
}
@@ -584,13 +582,13 @@ IScsiCheckIpv6Support ( //
InfoBlock = NULL;
InfoBlockSize = 0;
- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
- if (EFI_ERROR (Status) || InfoBlock == NULL) {
+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
FreePool (InfoBlock);
return EFI_NOT_FOUND;
}
- *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;
+ *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
FreePool (InfoBlock);
return EFI_SUCCESS;
@@ -613,12 +611,12 @@ IScsiAddNic ( IN EFI_HANDLE Image
)
{
- EFI_STATUS Status;
- ISCSI_NIC_INFO *NicInfo;
- LIST_ENTRY *Entry;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
+ EFI_STATUS Status;
+ ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
//
// Get MAC address of this network device.
@@ -638,9 +636,10 @@ IScsiAddNic ( //
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
- if (NicInfo->HwAddressSize == HwAddressSize &&
- CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&
- NicInfo->VlanId == VlanId) {
+ if ((NicInfo->HwAddressSize == HwAddressSize) &&
+ (CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0) &&
+ (NicInfo->VlanId == VlanId))
+ {
mPrivate->CurrentNic = NicInfo->NicIndex;
//
@@ -672,10 +671,10 @@ IScsiAddNic ( }
CopyMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize);
- NicInfo->HwAddressSize = (UINT32) HwAddressSize;
- NicInfo->VlanId = VlanId;
- NicInfo->NicIndex = (UINT8) (mPrivate->MaxNic + 1);
- mPrivate->MaxNic = NicInfo->NicIndex;
+ NicInfo->HwAddressSize = (UINT32)HwAddressSize;
+ NicInfo->VlanId = VlanId;
+ NicInfo->NicIndex = (UINT8)(mPrivate->MaxNic + 1);
+ mPrivate->MaxNic = NicInfo->NicIndex;
//
// Set IPv6 available flag.
@@ -706,7 +705,6 @@ IScsiAddNic ( return EFI_SUCCESS;
}
-
/**
Delete the recorded NIC info from global structure. Also delete corresponding
attempts.
@@ -722,15 +720,15 @@ IScsiRemoveNic ( IN EFI_HANDLE Controller
)
{
- EFI_STATUS Status;
- ISCSI_NIC_INFO *NicInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_NIC_INFO *ThisNic;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
+ EFI_STATUS Status;
+ ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_NIC_INFO *ThisNic;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
//
// Get MAC address of this network device.
@@ -752,10 +750,10 @@ IScsiRemoveNic ( NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
- if (NicInfo->HwAddressSize == HwAddressSize &&
- CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&
- NicInfo->VlanId == VlanId) {
-
+ if ((NicInfo->HwAddressSize == HwAddressSize) &&
+ (CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0) &&
+ (NicInfo->VlanId == VlanId))
+ {
ThisNic = NicInfo;
break;
}
@@ -780,16 +778,15 @@ IScsiRemoveNic ( RemoveEntryList (&AttemptConfigData->Link);
mPrivate->AttemptCount--;
- if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO && mPrivate->MpioCount > 0) {
+ if ((AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) && (mPrivate->MpioCount > 0)) {
if (--mPrivate->MpioCount == 0) {
mPrivate->EnableMpio = FALSE;
}
- if (AttemptConfigData->AuthenticationType == ISCSI_AUTH_TYPE_KRB && mPrivate->Krb5MpioCount > 0) {
+ if ((AttemptConfigData->AuthenticationType == ISCSI_AUTH_TYPE_KRB) && (mPrivate->Krb5MpioCount > 0)) {
mPrivate->Krb5MpioCount--;
}
-
- } else if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED && mPrivate->SinglePathCount > 0) {
+ } else if ((AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED) && (mPrivate->SinglePathCount > 0)) {
mPrivate->SinglePathCount--;
if (mPrivate->ValidSinglePathCount > 0) {
@@ -815,19 +812,19 @@ IScsiRemoveNic ( **/
EFI_STATUS
IScsiCreateAttempts (
- IN UINTN AttemptNum
-)
+ 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;
+ 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 ++) {
+ for (Index = 1; Index <= AttemptNum; Index++) {
//
// Get the initialized attempt order. This is used to essure creating attempts by order.
//
@@ -841,6 +838,7 @@ IScsiCreateAttempts ( Status = EFI_SUCCESS;
break;
}
+
TotalNumber++;
//
@@ -851,6 +849,7 @@ IScsiCreateAttempts ( if (AttemptConfigOrder != NULL) {
FreePool (AttemptConfigOrder);
}
+
return EFI_OUT_OF_RESOURCES;
}
@@ -872,10 +871,14 @@ IScsiCreateAttempts ( );
FreePool (AttemptConfigOrder);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"%a: Failed to set 'InitialAttemptOrder' with Guid (%g): "
"%r\n",
- __FUNCTION__, &gIScsiConfigGuid, Status));
+ __FUNCTION__,
+ &gIScsiConfigGuid,
+ Status
+ ));
return Status;
}
@@ -886,6 +889,7 @@ IScsiCreateAttempts ( if (AttemptConfigData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
ConfigData = &AttemptConfigData->SessionConfigData;
ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
@@ -903,9 +907,9 @@ IScsiCreateAttempts ( //
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
+ (UINTN)AttemptConfigData->AttemptConfigIndex
);
UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE);
@@ -918,10 +922,14 @@ IScsiCreateAttempts ( );
FreePool (AttemptConfigData);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: Failed to set variable (mPrivate->PortString) with Guid (%g): "
- "%r\n",
- __FUNCTION__, &gEfiIScsiInitiatorNameProtocolGuid, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Failed to set variable (mPrivate->PortString) with Guid (%g): "
+ "%r\n",
+ __FUNCTION__,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ Status
+ ));
return Status;
}
}
@@ -941,18 +949,18 @@ IScsiCreateAttempts ( **/
EFI_STATUS
IScsiCreateKeywords (
- IN UINTN KeywordNum
-)
+ 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;
+ 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,
@@ -965,7 +973,7 @@ IScsiCreateKeywords ( return EFI_OUT_OF_RESOURCES;
}
- for (Index = 1; Index <= KeywordNum; Index ++) {
+ for (Index = 1; Index <= KeywordNum; Index++) {
//
// Create iSCSIAttemptName Keyword.
//
@@ -980,9 +988,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)),
StringToken,
StringToken,
EFI_IFR_FLAG_READ_ONLY,
@@ -1006,9 +1014,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)),
+ (UINT16)(ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)),
StringToken,
StringToken,
0,
@@ -1033,9 +1041,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)),
+ (UINT16)(ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)),
StringToken,
StringToken,
0,
@@ -1060,9 +1068,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)),
+ (UINT16)(ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)),
StringToken,
StringToken,
0,
@@ -1087,9 +1095,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)),
+ (UINT16)(ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1114,9 +1122,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_ISID_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_ISID_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
STRING_TOKEN (STR_ISCSI_ISID_HELP),
0,
@@ -1139,19 +1147,19 @@ IScsiCreateKeywords ( 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
- );
+ 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.
@@ -1167,9 +1175,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1193,9 +1201,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1219,9 +1227,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1244,19 +1252,19 @@ IScsiCreateKeywords ( 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
- );
+ 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.
@@ -1272,9 +1280,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)),
+ (UINT16)(ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1299,9 +1307,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1325,9 +1333,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1351,9 +1359,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_LUN_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_LUN_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1376,19 +1384,19 @@ IScsiCreateKeywords ( 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
- );
+ 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.
@@ -1403,19 +1411,19 @@ IScsiCreateKeywords ( 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
- );
+ 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.
@@ -1431,9 +1439,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1457,9 +1465,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1483,9 +1491,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1509,9 +1517,9 @@ IScsiCreateKeywords ( HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)),
+ (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)),
+ (UINT16)(ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1544,12 +1552,12 @@ IScsiCreateKeywords ( VOID
IScsiCleanAttemptVariable (
IN VOID
-)
+ )
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
//
// Get the initialized attempt order.
@@ -1559,14 +1567,14 @@ IScsiCleanAttemptVariable ( &gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return;
}
for (Index = 1; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
Index
);
@@ -1574,7 +1582,7 @@ IScsiCleanAttemptVariable ( GetVariable2 (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
+ (VOID **)&AttemptConfigData,
NULL
);
@@ -1588,6 +1596,7 @@ IScsiCleanAttemptVariable ( );
}
}
+
return;
}
@@ -1601,11 +1610,11 @@ IScsiCleanAttemptVariable ( **/
ISCSI_NIC_INFO *
IScsiGetNicInfoByIndex (
- IN UINT8 NicIndex
+ IN UINT8 NicIndex
)
{
- LIST_ENTRY *Entry;
- ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ ISCSI_NIC_INFO *NicInfo;
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
@@ -1617,7 +1626,6 @@ IScsiGetNicInfoByIndex ( return NULL;
}
-
/**
Get the NIC's PCI location and return it according to the composited
format defined in iSCSI Boot Firmware Table.
@@ -1647,7 +1655,7 @@ IScsiGetNICPciLocation ( Status = gBS->HandleProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
return 0;
@@ -1662,7 +1670,7 @@ IScsiGetNICPciLocation ( return 0;
}
- Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID **) &PciIo);
+ Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID **)&PciIo);
if (EFI_ERROR (Status)) {
return 0;
}
@@ -1672,10 +1680,9 @@ IScsiGetNICPciLocation ( return 0;
}
- return (UINT16) ((*Bus << 8) | (*Device << 3) | *Function);
+ return (UINT16)((*Bus << 8) | (*Device << 3) | *Function);
}
-
/**
Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
buffer, and the size of the buffer. If failure, return NULL.
@@ -1691,9 +1698,9 @@ IScsiGetNICPciLocation ( **/
VOID *
IScsiGetVariableAndSize (
- IN CHAR16 *Name,
- IN EFI_GUID *VendorGuid,
- OUT UINTN *VariableSize
+ IN CHAR16 *Name,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VariableSize
)
{
EFI_STATUS Status;
@@ -1705,8 +1712,8 @@ IScsiGetVariableAndSize ( //
// Pass in a zero size buffer to find the required buffer size.
//
- BufferSize = 0;
- Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
+ BufferSize = 0;
+ Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate the buffer to return
@@ -1715,6 +1722,7 @@ IScsiGetVariableAndSize ( if (Buffer == NULL) {
return NULL;
}
+
//
// Read variable into the allocated buffer.
//
@@ -1728,7 +1736,6 @@ IScsiGetVariableAndSize ( return Buffer;
}
-
/**
Create the iSCSI driver data.
@@ -1745,8 +1752,8 @@ IScsiCreateDriverData ( IN EFI_HANDLE Controller
)
{
- ISCSI_DRIVER_DATA *Private;
- EFI_STATUS Status;
+ ISCSI_DRIVER_DATA *Private;
+ EFI_STATUS Status;
Private = AllocateZeroPool (sizeof (ISCSI_DRIVER_DATA));
if (Private == NULL) {
@@ -1776,7 +1783,7 @@ IScsiCreateDriverData ( }
Private->ExtScsiPassThruHandle = NULL;
- CopyMem(&Private->IScsiExtScsiPassThru, &gIScsiExtScsiPassThruProtocolTemplate, sizeof(EFI_EXT_SCSI_PASS_THRU_PROTOCOL));
+ CopyMem (&Private->IScsiExtScsiPassThru, &gIScsiExtScsiPassThruProtocolTemplate, sizeof (EFI_EXT_SCSI_PASS_THRU_PROTOCOL));
//
// 0 is designated to the TargetId, so use another value for the AdapterId.
@@ -1789,7 +1796,6 @@ IScsiCreateDriverData ( return Private;
}
-
/**
Clean the iSCSI driver data.
@@ -1804,7 +1810,7 @@ IScsiCleanDriverData ( IN ISCSI_DRIVER_DATA *Private
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -1859,24 +1865,24 @@ IScsiDhcpIsConfigured ( IN UINT8 IpVersion
)
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
- 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];
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
+ 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,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return FALSE;
}
@@ -1884,29 +1890,30 @@ IScsiDhcpIsConfigured ( // Get MAC address of this network device.
//
Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
- if(EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
return FALSE;
}
+
//
// Get VLAN ID of this network device.
//
VlanId = NetLibGetVlanId (Controller);
- IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
+ IScsiMacAddrToStr (&MacAddr, (UINT32)HwAddressSize, VlanId, MacString);
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
AttemptName,
- (UINTN) 128,
+ (UINTN)128,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
Status = GetVariable2 (
AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptTmp,
+ (VOID **)&AttemptTmp,
NULL
);
- if(AttemptTmp == NULL || EFI_ERROR (Status)) {
+ if ((AttemptTmp == NULL) || EFI_ERROR (Status)) {
continue;
}
@@ -1917,21 +1924,23 @@ IScsiDhcpIsConfigured ( continue;
}
- if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG &&
- AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)) {
+ 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)) {
+ 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) {
+ if ((AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) ||
+ (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE) ||
+ (AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE))
+ {
FreePool (AttemptTmp);
FreePool (AttemptConfigOrder);
return TRUE;
@@ -1958,24 +1967,24 @@ IScsiDnsIsConfigured ( IN EFI_HANDLE Controller
)
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
- EFI_STATUS Status;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return FALSE;
}
@@ -1983,30 +1992,31 @@ IScsiDnsIsConfigured ( // Get MAC address of this network device.
//
Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
- if(EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
return FALSE;
}
+
//
// Get VLAN ID of this network device.
//
VlanId = NetLibGetVlanId (Controller);
- IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
+ IScsiMacAddrToStr (&MacAddr, (UINT32)HwAddressSize, VlanId, MacString);
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
AttemptName,
- (UINTN) 128,
+ (UINTN)128,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
Status = GetVariable2 (
AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptTmp,
+ (VOID **)&AttemptTmp,
NULL
);
- if(AttemptTmp == NULL || EFI_ERROR (Status)) {
+ if ((AttemptTmp == NULL) || EFI_ERROR (Status)) {
continue;
}
@@ -2014,7 +2024,7 @@ IScsiDnsIsConfigured ( AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
- if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp (MacString, AttemptMacString)) {
+ if ((AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) || StrCmp (MacString, AttemptMacString)) {
FreePool (AttemptTmp);
continue;
}
@@ -2027,12 +2037,10 @@ IScsiDnsIsConfigured ( FreePool (AttemptTmp);
continue;
}
-
}
FreePool (AttemptConfigOrder);
return FALSE;
-
}
/**
@@ -2050,17 +2058,17 @@ 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;
- UINTN AttemptConfigOrderSize;
- CHAR16 IScsiMode[64];
- CHAR16 IpMode[64];
+ 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;
+ UINTN AttemptConfigOrderSize;
+ CHAR16 IScsiMode[64];
+ CHAR16 IpMode[64];
//
// There should be at least one attempt configured.
@@ -2070,19 +2078,19 @@ IScsiGetConfigData ( &gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return EFI_NOT_FOUND;
}
//
// Get the iSCSI Initiator Name.
//
- mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE;
- Status = gIScsiInitiatorName.Get (
- &gIScsiInitiatorName,
- &mPrivate->InitiatorNameLength,
- mPrivate->InitiatorName
- );
+ mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE;
+ Status = gIScsiInitiatorName.Get (
+ &gIScsiInitiatorName,
+ &mPrivate->InitiatorNameLength,
+ mPrivate->InitiatorName
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2091,27 +2099,29 @@ IScsiGetConfigData ( // Get the normal configuration.
//
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
-
//
// Check whether the attempt exists in AttemptConfig.
//
AttemptTmp = IScsiConfigGetAttemptByConfigIndex (AttemptConfigOrder[Index]);
- if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {
+ if ((AttemptTmp != NULL) && (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED)) {
continue;
- } else if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED) {
+ } else if ((AttemptTmp != NULL) && (AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED)) {
//
// Check the autoconfig path to see whether it should be retried.
//
- if (AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
- !AttemptTmp->AutoConfigureSuccess) {
+ if ((AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
+ !AttemptTmp->AutoConfigureSuccess)
+ {
if (mPrivate->Ipv6Flag &&
- AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) {
+ (AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6))
+ {
//
// Autoconfigure for IP6 already attempted but failed. Do not try again.
//
continue;
} else if (!mPrivate->Ipv6Flag &&
- AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) {
+ (AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4))
+ {
//
// Autoconfigure for IP4 already attempted but failed. Do not try again.
//
@@ -2121,7 +2131,7 @@ IScsiGetConfigData ( // Try another approach for this autoconfigure path.
//
AttemptTmp->AutoConfigureMode =
- (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
+ (UINT8)(mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp = TRUE;
AttemptTmp->SessionConfigData.TargetInfoFromDhcp = TRUE;
AttemptTmp->DhcpSuccess = FALSE;
@@ -2146,9 +2156,9 @@ IScsiGetConfigData ( //
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptTmp->AttemptConfigIndex
+ (UINTN)AttemptTmp->AttemptConfigIndex
);
gRT->SetVariable (
@@ -2163,7 +2173,8 @@ IScsiGetConfigData ( }
} else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp &&
!AttemptTmp->ValidPath &&
- AttemptTmp->NicIndex == mPrivate->CurrentNic) {
+ (AttemptTmp->NicIndex == mPrivate->CurrentNic))
+ {
//
// If the attempt associates with the current NIC, we can
// get DHCP information for already added, but failed, attempt.
@@ -2186,9 +2197,9 @@ IScsiGetConfigData ( //
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptTmp->AttemptConfigIndex
+ (UINTN)AttemptTmp->AttemptConfigIndex
);
gRT->SetVariable (
@@ -2200,7 +2211,6 @@ IScsiGetConfigData ( );
continue;
-
} else {
continue;
}
@@ -2215,21 +2225,22 @@ IScsiGetConfigData ( IScsiMacAddrToStr (&NicInfo->PermanentAddress, NicInfo->HwAddressSize, NicInfo->VlanId, MacString);
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
GetVariable2 (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
+ (VOID **)&AttemptConfigData,
NULL
);
AsciiStrToUnicodeStrS (AttemptConfigData->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
- if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED ||
- StrCmp (MacString, AttemptMacString)) {
+ if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED) ||
+ StrCmp (MacString, AttemptMacString))
+ {
continue;
}
@@ -2237,7 +2248,7 @@ IScsiGetConfigData ( AttemptConfigData->NicIndex = NicInfo->NicIndex;
AttemptConfigData->DhcpSuccess = FALSE;
- AttemptConfigData->ValidiBFTPath = (BOOLEAN) (mPrivate->EnableMpio ? TRUE : FALSE);
+ AttemptConfigData->ValidiBFTPath = (BOOLEAN)(mPrivate->EnableMpio ? TRUE : FALSE);
AttemptConfigData->ValidPath = FALSE;
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) {
@@ -2245,26 +2256,28 @@ IScsiGetConfigData ( AttemptConfigData->SessionConfigData.TargetInfoFromDhcp = TRUE;
AttemptConfigData->AutoConfigureMode =
- (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
+ (UINT8)(mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
AttemptConfigData->AutoConfigureSuccess = FALSE;
}
//
// Get some information from dhcp server.
//
- if (AttemptConfigData->SessionConfigData.Enabled != ISCSI_DISABLED &&
- AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp) {
-
+ if ((AttemptConfigData->SessionConfigData.Enabled != ISCSI_DISABLED) &&
+ AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp)
+ {
if (!mPrivate->Ipv6Flag &&
- (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4 ||
- AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4)) {
+ ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) ||
+ (AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4)))
+ {
Status = IScsiDoDhcp (Private->Image, Private->Controller, AttemptConfigData);
if (!EFI_ERROR (Status)) {
AttemptConfigData->DhcpSuccess = TRUE;
}
} else if (mPrivate->Ipv6Flag &&
- (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6 ||
- AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6)) {
+ ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) ||
+ (AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6)))
+ {
Status = IScsiDoDhcp6 (Private->Image, Private->Controller, AttemptConfigData);
if (!EFI_ERROR (Status)) {
AttemptConfigData->DhcpSuccess = TRUE;
@@ -2276,9 +2289,9 @@ IScsiGetConfigData ( //
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
+ (UINTN)AttemptConfigData->AttemptConfigIndex
);
gRT->SetVariable (
@@ -2312,7 +2325,7 @@ IScsiGetConfigData ( UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (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,
@@ -2377,13 +2390,13 @@ IScsiGetConfigData ( if (mPrivate->SinglePathCount == 0) {
return EFI_NOT_FOUND;
}
+
mPrivate->ValidSinglePathCount = mPrivate->SinglePathCount;
}
return EFI_SUCCESS;
}
-
/**
Get the device path of the iSCSI tcp connection and update it.
@@ -2395,7 +2408,7 @@ IScsiGetConfigData ( **/
EFI_DEVICE_PATH_PROTOCOL *
IScsiGetTcpConnDevicePath (
- IN ISCSI_SESSION *Session
+ IN ISCSI_SESSION *Session
)
{
ISCSI_CONNECTION *Conn;
@@ -2418,28 +2431,29 @@ IScsiGetTcpConnDevicePath ( Status = gBS->HandleProtocol (
Conn->TcpIo.Handle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
return NULL;
}
+
//
// Duplicate it.
//
- DevicePath = DuplicateDevicePath (DevicePath);
+ DevicePath = DuplicateDevicePath (DevicePath);
if (DevicePath == NULL) {
return NULL;
}
- DPathNode = (EFI_DEV_PATH *) DevicePath;
+ DPathNode = (EFI_DEV_PATH *)DevicePath;
while (!IsDevicePathEnd (&DPathNode->DevPath)) {
if (DevicePathType (&DPathNode->DevPath) == MESSAGING_DEVICE_PATH) {
- if (!Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP) {
- DPathNode->Ipv4.LocalPort = 0;
+ if (!Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP)) {
+ DPathNode->Ipv4.LocalPort = 0;
DPathNode->Ipv4.StaticIpAddress =
- (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
+ (BOOLEAN)(!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
//
// Add a judgement here to support previous versions of IPv4_DEVICE_PATH.
@@ -2451,7 +2465,6 @@ IScsiGetTcpConnDevicePath ( PathLen = DevicePathNodeLength (&DPathNode->Ipv4);
if (PathLen == IP4_NODE_LEN_NEW_VERSIONS) {
-
IP4_COPY_ADDRESS (
&DPathNode->Ipv4.GatewayIpAddress,
&Session->ConfigData->SessionConfigData.Gateway
@@ -2464,8 +2477,8 @@ IScsiGetTcpConnDevicePath ( }
break;
- } else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) {
- DPathNode->Ipv6.LocalPort = 0;
+ } else if (Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP)) {
+ DPathNode->Ipv6.LocalPort = 0;
//
// Add a judgement here to support previous versions of IPv6_DEVICE_PATH.
@@ -2478,32 +2491,28 @@ IScsiGetTcpConnDevicePath ( PathLen = DevicePathNodeLength (&DPathNode->Ipv6);
if (PathLen == IP6_NODE_LEN_NEW_VERSIONS ) {
-
DPathNode->Ipv6.IpAddressOrigin = 0;
DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS));
- }
- else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) {
-
+ } else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) {
//
// StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new
// version. Set StaticIPAddress through its' offset in old IPv6_DEVICE_PATH.
//
*((UINT8 *)(&DPathNode->Ipv6) + IP6_OLD_IPADDRESS_OFFSET) =
- (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
+ (BOOLEAN)(!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
}
break;
}
}
- DPathNode = (EFI_DEV_PATH *) NextDevicePathNode (&DPathNode->DevPath);
+ DPathNode = (EFI_DEV_PATH *)NextDevicePathNode (&DPathNode->DevPath);
}
return DevicePath;
}
-
/**
Abort the session when the transition from BS to RT is initiated.
@@ -2518,9 +2527,9 @@ IScsiOnExitBootService ( IN VOID *Context
)
{
- ISCSI_DRIVER_DATA *Private;
+ ISCSI_DRIVER_DATA *Private;
- Private = (ISCSI_DRIVER_DATA *) Context;
+ Private = (ISCSI_DRIVER_DATA *)Context;
gBS->CloseEvent (Private->ExitBootServiceEvent);
Private->ExitBootServiceEvent = NULL;
@@ -2556,14 +2565,14 @@ IScsiOnExitBootService ( EFI_STATUS
EFIAPI
IScsiTestManagedDevice (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE DriverBindingHandle,
- IN EFI_GUID *ProtocolGuid
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_GUID *ProtocolGuid
)
{
- EFI_STATUS Status;
- VOID *ManagedInterface;
- EFI_HANDLE NicControllerHandle;
+ EFI_STATUS Status;
+ VOID *ManagedInterface;
+ EFI_HANDLE NicControllerHandle;
ASSERT (ProtocolGuid != NULL);
@@ -2574,7 +2583,7 @@ IScsiTestManagedDevice ( Status = gBS->OpenProtocol (
ControllerHandle,
- (EFI_GUID *) ProtocolGuid,
+ (EFI_GUID *)ProtocolGuid,
&ManagedInterface,
DriverBindingHandle,
NicControllerHandle,
@@ -2583,7 +2592,7 @@ IScsiTestManagedDevice ( if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
ControllerHandle,
- (EFI_GUID *) ProtocolGuid,
+ (EFI_GUID *)ProtocolGuid,
DriverBindingHandle,
NicControllerHandle
);
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.h index fddef4f466..a951eee70e 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.h +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h @@ -14,49 +14,47 @@ typedef struct _ISCSI_DRIVER_DATA ISCSI_DRIVER_DATA; ///
/// IPv4 Device Path Node Length
///
-#define IP4_NODE_LEN_NEW_VERSIONS 27
+#define IP4_NODE_LEN_NEW_VERSIONS 27
///
/// IPv6 Device Path Node Length
///
-#define IP6_NODE_LEN_OLD_VERSIONS 43
-#define IP6_NODE_LEN_NEW_VERSIONS 60
+#define IP6_NODE_LEN_OLD_VERSIONS 43
+#define IP6_NODE_LEN_NEW_VERSIONS 60
///
/// The ignored field StaticIpAddress's offset in old IPv6 Device Path
///
-#define IP6_OLD_IPADDRESS_OFFSET 42
-
+#define IP6_OLD_IPADDRESS_OFFSET 42
#pragma pack(1)
typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
- UINT16 TargetPort;
- UINT8 Enabled;
- UINT8 IpMode;
-
- EFI_IP_ADDRESS LocalIp;
- EFI_IPv4_ADDRESS SubnetMask;
- EFI_IP_ADDRESS Gateway;
+ UINT16 TargetPort;
+ UINT8 Enabled;
+ UINT8 IpMode;
- BOOLEAN InitiatorInfoFromDhcp;
- BOOLEAN TargetInfoFromDhcp;
+ EFI_IP_ADDRESS LocalIp;
+ EFI_IPv4_ADDRESS SubnetMask;
+ EFI_IP_ADDRESS Gateway;
- CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];
- EFI_IP_ADDRESS TargetIp;
- UINT8 PrefixLength;
- UINT8 BootLun[8];
+ BOOLEAN InitiatorInfoFromDhcp;
+ BOOLEAN TargetInfoFromDhcp;
- UINT16 ConnectTimeout; ///< timeout value in milliseconds.
- UINT8 ConnectRetryCount;
- UINT8 IsId[6];
+ CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];
+ EFI_IP_ADDRESS TargetIp;
+ UINT8 PrefixLength;
+ UINT8 BootLun[8];
- BOOLEAN RedirectFlag;
- UINT16 OriginalTargetPort; // The port of proxy/virtual target.
- EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+ UINT16 ConnectTimeout; ///< timeout value in milliseconds.
+ UINT8 ConnectRetryCount;
+ UINT8 IsId[6];
- BOOLEAN DnsMode; // Flag indicate whether the Target address is expressed as URL format.
- CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE];
+ BOOLEAN RedirectFlag;
+ UINT16 OriginalTargetPort; // The port of proxy/virtual target.
+ EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+ BOOLEAN DnsMode; // Flag indicate whether the Target address is expressed as URL format.
+ CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE];
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
@@ -134,9 +132,9 @@ IScsiMacAddrToStr ( **/
EFI_STATUS
IScsiAsciiStrToIp (
- IN CHAR8 *Str,
- IN UINT8 IpMode,
- OUT EFI_IP_ADDRESS *Ip
+ IN CHAR8 *Str,
+ IN UINT8 IpMode,
+ OUT EFI_IP_ADDRESS *Ip
);
/**
@@ -156,10 +154,10 @@ IScsiAsciiStrToIp ( **/
EFI_STATUS
IScsiBinToHex (
- IN UINT8 *BinBuffer,
- IN UINT32 BinLength,
- IN OUT CHAR8 *HexStr,
- IN OUT UINT32 *HexLength
+ IN UINT8 *BinBuffer,
+ IN UINT32 BinLength,
+ IN OUT CHAR8 *HexStr,
+ IN OUT UINT32 *HexLength
);
/**
@@ -180,12 +178,11 @@ IScsiBinToHex ( **/
EFI_STATUS
IScsiHexToBin (
- IN OUT UINT8 *BinBuffer,
- IN OUT UINT32 *BinLength,
- IN CHAR8 *HexStr
+ IN OUT UINT8 *BinBuffer,
+ IN OUT UINT32 *BinLength,
+ IN CHAR8 *HexStr
);
-
/**
Convert the decimal-constant string or hex-constant string into a numerical value.
@@ -255,7 +252,7 @@ IScsiRemoveNic ( **/
EFI_STATUS
IScsiCreateAttempts (
- IN UINTN AttemptNum
+ IN UINTN AttemptNum
);
/**
@@ -269,7 +266,7 @@ IScsiCreateAttempts ( **/
EFI_STATUS
IScsiCreateKeywords (
- IN UINTN KeywordNum
+ IN UINTN KeywordNum
);
/**
@@ -292,10 +289,9 @@ IScsiCleanAttemptVariable ( **/
ISCSI_NIC_INFO *
IScsiGetNicInfoByIndex (
- IN UINT8 NicIndex
+ IN UINT8 NicIndex
);
-
/**
Get the NIC's PCI location and return it according to the composited
format defined in iSCSI Boot Firmware Table.
@@ -331,9 +327,9 @@ IScsiGetNICPciLocation ( **/
VOID *
IScsiGetVariableAndSize (
- IN CHAR16 *Name,
- IN EFI_GUID *VendorGuid,
- OUT UINTN *VariableSize
+ IN CHAR16 *Name,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VariableSize
);
/**
@@ -422,7 +418,7 @@ IScsiGetConfigData ( **/
EFI_DEVICE_PATH_PROTOCOL *
IScsiGetTcpConnDevicePath (
- IN ISCSI_SESSION *Session
+ IN ISCSI_SESSION *Session
);
/**
@@ -465,8 +461,9 @@ IScsiOnExitBootService ( EFI_STATUS
EFIAPI
IScsiTestManagedDevice (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE DriverBindingHandle,
- IN EFI_GUID *ProtocolGuid
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_GUID *ProtocolGuid
);
+
#endif
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c index 215f275a2d..ef587649a0 100644 --- a/NetworkPkg/IScsiDxe/IScsiProto.c +++ b/NetworkPkg/IScsiDxe/IScsiProto.c @@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "IScsiImpl.h"
-UINT32 mDataSegPad = 0;
+UINT32 mDataSegPad = 0;
/**
Attach the iSCSI connection to the iSCSI session.
@@ -44,7 +44,6 @@ IScsiDetatchConnection ( Conn->Session = NULL;
}
-
/**
Check the sequence number according to RFC3720.
@@ -80,7 +79,6 @@ IScsiCheckSN ( }
}
-
/**
Update the sequence numbers for the iSCSI command.
@@ -97,7 +95,7 @@ IScsiUpdateCmdSN ( )
{
if (ISCSI_SEQ_LT (MaxCmdSN, ExpCmdSN - 1)) {
- return ;
+ return;
}
if (ISCSI_SEQ_GT (MaxCmdSN, Session->MaxCmdSN)) {
@@ -109,7 +107,6 @@ IScsiUpdateCmdSN ( }
}
-
/**
This function does the iSCSI connection login.
@@ -123,8 +120,8 @@ IScsiUpdateCmdSN ( **/
EFI_STATUS
IScsiConnLogin (
- IN OUT ISCSI_CONNECTION *Conn,
- IN UINT16 Timeout
+ IN OUT ISCSI_CONNECTION *Conn,
+ IN UINT16 Timeout
)
{
EFI_STATUS Status;
@@ -171,7 +168,6 @@ IScsiConnLogin ( return Status;
}
-
/**
Reset the iSCSI connection.
@@ -186,7 +182,6 @@ IScsiConnReset ( TcpIoReset (&Conn->TcpIo);
}
-
/**
Create a TCP connection for the iSCSI session.
@@ -197,7 +192,7 @@ IScsiConnReset ( **/
ISCSI_CONNECTION *
IScsiCreateConnection (
- IN ISCSI_SESSION *Session
+ IN ISCSI_SESSION *Session
)
{
ISCSI_DRIVER_DATA *Private;
@@ -245,9 +240,9 @@ IScsiCreateConnection ( //
// Set the default connection-only parameters.
//
- Conn->MaxRecvDataSegmentLength = DEFAULT_MAX_RECV_DATA_SEG_LEN;
- Conn->HeaderDigest = IScsiDigestNone;
- Conn->DataDigest = IScsiDigestNone;
+ Conn->MaxRecvDataSegmentLength = DEFAULT_MAX_RECV_DATA_SEG_LEN;
+ Conn->HeaderDigest = IScsiDigestNone;
+ Conn->DataDigest = IScsiDigestNone;
if (NvData->DnsMode) {
//
@@ -259,7 +254,7 @@ IScsiCreateConnection ( Status = IScsiDns6 (Private->Image, Private->Controller, NvData);
}
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "The configuration of Target address or DNS server address is invalid!\n"));
FreePool (Conn);
return NULL;
@@ -292,7 +287,7 @@ IScsiCreateConnection ( Status = TcpIoCreateSocket (
Private->Image,
Private->Controller,
- (UINT8) (!Conn->Ipv6Flag ? TCP_VERSION_4: TCP_VERSION_6),
+ (UINT8)(!Conn->Ipv6Flag ? TCP_VERSION_4 : TCP_VERSION_6),
&TcpIoConfig,
&Conn->TcpIo
);
@@ -305,7 +300,6 @@ IScsiCreateConnection ( return Conn;
}
-
/**
Destroy an iSCSI connection.
@@ -381,15 +375,16 @@ IScsiGetIp6NicInfo ( }
SubnetPrefixLength = 0;
- RouteEntry = Ip6ModeData.RouteCount;
+ RouteEntry = Ip6ModeData.RouteCount;
for (Index = 0; Index < Ip6ModeData.RouteCount; Index++) {
if (NetIp6IsNetEqual (TargetIp, &Ip6ModeData.RouteTable[Index].Destination, Ip6ModeData.RouteTable[Index].PrefixLength)) {
if (SubnetPrefixLength < Ip6ModeData.RouteTable[Index].PrefixLength) {
SubnetPrefixLength = Ip6ModeData.RouteTable[Index].PrefixLength;
- RouteEntry = Index;
+ RouteEntry = Index;
}
}
}
+
if (RouteEntry != Ip6ModeData.RouteCount) {
IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway);
}
@@ -398,19 +393,24 @@ ON_EXIT: if (Ip6ModeData.AddressList != NULL) {
FreePool (Ip6ModeData.AddressList);
}
- if (Ip6ModeData.GroupTable!= NULL) {
+
+ if (Ip6ModeData.GroupTable != NULL) {
FreePool (Ip6ModeData.GroupTable);
}
- if (Ip6ModeData.RouteTable!= NULL) {
+
+ if (Ip6ModeData.RouteTable != NULL) {
FreePool (Ip6ModeData.RouteTable);
}
- if (Ip6ModeData.NeighborCache!= NULL) {
+
+ if (Ip6ModeData.NeighborCache != NULL) {
FreePool (Ip6ModeData.NeighborCache);
}
- if (Ip6ModeData.PrefixTable!= NULL) {
+
+ if (Ip6ModeData.PrefixTable != NULL) {
FreePool (Ip6ModeData.PrefixTable);
}
- if (Ip6ModeData.IcmpTypeList!= NULL) {
+
+ if (Ip6ModeData.IcmpTypeList != NULL) {
FreePool (Ip6ModeData.IcmpTypeList);
}
@@ -429,7 +429,7 @@ ON_EXIT: STATIC
VOID
IScsiSessionResetAuthData (
- IN OUT ISCSI_SESSION *Session
+ IN OUT ISCSI_SESSION *Session
)
{
if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
@@ -517,7 +517,7 @@ IScsiSessionLogin ( Status = gBS->OpenProtocol (
Conn->TcpIo.Handle,
ProtocolGuid,
- (VOID **) &Tcp,
+ (VOID **)&Tcp,
Session->Private->Image,
Session->Private->ExtScsiPassThruHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -533,7 +533,6 @@ IScsiSessionLogin ( return Status;
}
-
/**
Wait for IPsec negotiation, then try to login the iSCSI session again.
@@ -549,10 +548,9 @@ IScsiSessionReLogin ( IN ISCSI_SESSION *Session
)
{
-
- EFI_STATUS Status;
- EFI_STATUS TimerStatus;
- EFI_EVENT Timer;
+ EFI_STATUS Status;
+ EFI_STATUS TimerStatus;
+ EFI_EVENT Timer;
Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer);
if (EFI_ERROR (Status)) {
@@ -571,20 +569,17 @@ IScsiSessionReLogin ( }
do {
-
TimerStatus = gBS->CheckEvent (Timer);
if (!EFI_ERROR (TimerStatus)) {
Status = IScsiSessionLogin (Session);
}
-
} while (TimerStatus == EFI_NOT_READY);
gBS->CloseEvent (Timer);
return Status;
}
-
/**
Build and send the iSCSI login request to the iSCSI target according to
the current login stage.
@@ -612,6 +607,7 @@ IScsiSendLoginReq ( if (Pdu == NULL) {
return EFI_DEVICE_ERROR;
}
+
//
// Send it to the iSCSI target.
//
@@ -622,7 +618,6 @@ IScsiSendLoginReq ( return Status;
}
-
/**
Receive and process the iSCSI login response.
@@ -649,6 +644,7 @@ IScsiReceiveLoginRsp ( if (EFI_ERROR (Status)) {
return Status;
}
+
ASSERT (Pdu != NULL);
//
@@ -661,7 +657,6 @@ IScsiReceiveLoginRsp ( return Status;
}
-
/**
Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU.
The DataSegmentLength and the actual size of the net buffer containing this PDU will be
@@ -680,26 +675,27 @@ IScsiReceiveLoginRsp ( **/
EFI_STATUS
IScsiAddKeyValuePair (
- IN OUT NET_BUF *Pdu,
- IN CHAR8 *Key,
- IN CHAR8 *Value
+ IN OUT NET_BUF *Pdu,
+ IN CHAR8 *Key,
+ IN CHAR8 *Value
)
{
- UINT32 DataSegLen;
- UINT32 KeyLen;
- UINT32 ValueLen;
- UINT32 TotalLen;
- ISCSI_LOGIN_REQUEST *LoginReq;
- CHAR8 *Data;
-
- LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, NULL);
+ UINT32 DataSegLen;
+ UINT32 KeyLen;
+ UINT32 ValueLen;
+ UINT32 TotalLen;
+ ISCSI_LOGIN_REQUEST *LoginReq;
+ CHAR8 *Data;
+
+ LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, NULL);
if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR;
}
- DataSegLen = NTOH24 (LoginReq->DataSegmentLength);
- KeyLen = (UINT32) AsciiStrLen (Key);
- ValueLen = (UINT32) AsciiStrLen (Value);
+ DataSegLen = NTOH24 (LoginReq->DataSegmentLength);
+
+ KeyLen = (UINT32)AsciiStrLen (Key);
+ ValueLen = (UINT32)AsciiStrLen (Value);
//
// 1 byte for the key value separator '=' and 1 byte for the null
@@ -710,10 +706,11 @@ IScsiAddKeyValuePair ( //
// Allocate the space for the key-value pair.
//
- Data = (CHAR8 *) NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
+ Data = (CHAR8 *)NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Add the key.
//
@@ -739,7 +736,6 @@ IScsiAddKeyValuePair ( return EFI_SUCCESS;
}
-
/**
Prepare the iSCSI login request to be sent according to the current login status.
@@ -754,23 +750,24 @@ IScsiPrepareLoginReq ( IN OUT ISCSI_CONNECTION *Conn
)
{
- ISCSI_SESSION *Session;
- NET_BUF *Nbuf;
- ISCSI_LOGIN_REQUEST *LoginReq;
- EFI_STATUS Status;
+ ISCSI_SESSION *Session;
+ NET_BUF *Nbuf;
+ ISCSI_LOGIN_REQUEST *LoginReq;
+ EFI_STATUS Status;
Session = Conn->Session;
- Nbuf = NetbufAlloc (sizeof (ISCSI_LOGIN_REQUEST) + DEFAULT_MAX_RECV_DATA_SEG_LEN);
+ Nbuf = NetbufAlloc (sizeof (ISCSI_LOGIN_REQUEST) + DEFAULT_MAX_RECV_DATA_SEG_LEN);
if (Nbuf == NULL) {
return NULL;
}
- LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufAllocSpace (Nbuf, sizeof (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL);
+ LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufAllocSpace (Nbuf, sizeof (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL);
if (LoginReq == NULL) {
NetbufFree (Nbuf);
return NULL;
}
+
ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
//
@@ -778,12 +775,12 @@ IScsiPrepareLoginReq ( //
ISCSI_SET_OPCODE (LoginReq, ISCSI_OPCODE_LOGIN_REQ, ISCSI_REQ_IMMEDIATE);
ISCSI_SET_STAGES (LoginReq, Conn->CurrentStage, Conn->NextStage);
- LoginReq->VersionMax = ISCSI_VERSION_MAX;
- LoginReq->VersionMin = ISCSI_VERSION_MIN;
- LoginReq->Tsih = HTONS (Session->Tsih);
- LoginReq->InitiatorTaskTag = HTONL (Session->InitiatorTaskTag);
- LoginReq->Cid = HTONS (Conn->Cid);
- LoginReq->CmdSN = HTONL (Session->CmdSN);
+ LoginReq->VersionMax = ISCSI_VERSION_MAX;
+ LoginReq->VersionMin = ISCSI_VERSION_MIN;
+ LoginReq->Tsih = HTONS (Session->Tsih);
+ LoginReq->InitiatorTaskTag = HTONL (Session->InitiatorTaskTag);
+ LoginReq->Cid = HTONS (Conn->Cid);
+ LoginReq->CmdSN = HTONL (Session->CmdSN);
//
// For the first Login Request on a connection this is ExpStatSN for the
@@ -805,34 +802,34 @@ IScsiPrepareLoginReq ( Status = EFI_SUCCESS;
switch (Conn->CurrentStage) {
- case ISCSI_SECURITY_NEGOTIATION:
- //
- // Both none authentication and CHAP authentication share the CHAP path.
- //
- //
- if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) {
- Status = IScsiCHAPToSendReq (Conn, Nbuf);
- }
+ case ISCSI_SECURITY_NEGOTIATION:
+ //
+ // Both none authentication and CHAP authentication share the CHAP path.
+ //
+ //
+ if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) {
+ Status = IScsiCHAPToSendReq (Conn, Nbuf);
+ }
- break;
+ break;
- case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
- //
- // Only negotiate the parameter once.
- //
- if (!Conn->ParamNegotiated) {
- IScsiFillOpParams (Conn, Nbuf);
- }
+ case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
+ //
+ // Only negotiate the parameter once.
+ //
+ if (!Conn->ParamNegotiated) {
+ IScsiFillOpParams (Conn, Nbuf);
+ }
- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
- break;
+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
+ break;
- default:
- //
- // An error occurs...
- //
- Status = EFI_DEVICE_ERROR;
- break;
+ default:
+ //
+ // An error occurs...
+ //
+ Status = EFI_DEVICE_ERROR;
+ break;
}
if (EFI_ERROR (Status)) {
@@ -852,7 +849,6 @@ IScsiPrepareLoginReq ( return Nbuf;
}
-
/**
Process the iSCSI Login Response.
@@ -881,19 +877,21 @@ IScsiProcessLoginRsp ( UINT8 *DataSeg;
UINT32 DataSegLen;
- Status = EFI_SUCCESS;
- Session = Conn->Session;
+ Status = EFI_SUCCESS;
+ Session = Conn->Session;
- LoginRsp = (ISCSI_LOGIN_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
+ LoginRsp = (ISCSI_LOGIN_RESPONSE *)NetbufGetByte (Pdu, 0, NULL);
if (LoginRsp == NULL) {
return EFI_PROTOCOL_ERROR;
}
+
if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) {
//
// It is not a Login Response.
//
return EFI_PROTOCOL_ERROR;
}
+
//
// Get the data segment, if any.
//
@@ -903,53 +901,57 @@ IScsiProcessLoginRsp ( } else {
DataSeg = NULL;
}
+
//
// Check the status class in the login response PDU.
//
switch (LoginRsp->StatusClass) {
- case ISCSI_LOGIN_STATUS_SUCCESS:
- //
- // Just break here; the response and the data segment will be processed later.
- //
- break;
+ case ISCSI_LOGIN_STATUS_SUCCESS:
+ //
+ // Just break here; the response and the data segment will be processed later.
+ //
+ break;
- case ISCSI_LOGIN_STATUS_REDIRECTION:
- //
- // The target may be moved to a different address.
- //
- if (DataSeg == NULL) {
- return EFI_PROTOCOL_ERROR;
- }
- //
- // Process the TargetAddress key-value strings in the data segment to update the
- // target address info.
- //
- Status = IScsiUpdateTargetAddress (Session, (CHAR8 *) DataSeg, DataSegLen);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Session will be restarted on this error status because the Target is
- // redirected by this Login Response.
- //
- return EFI_MEDIA_CHANGED;
+ case ISCSI_LOGIN_STATUS_REDIRECTION:
+ //
+ // The target may be moved to a different address.
+ //
+ if (DataSeg == NULL) {
+ return EFI_PROTOCOL_ERROR;
+ }
- default:
- //
- // Initiator Error, Target Error, or any other undefined error code.
- //
- return EFI_PROTOCOL_ERROR;
+ //
+ // Process the TargetAddress key-value strings in the data segment to update the
+ // target address info.
+ //
+ Status = IScsiUpdateTargetAddress (Session, (CHAR8 *)DataSeg, DataSegLen);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Session will be restarted on this error status because the Target is
+ // redirected by this Login Response.
+ //
+ return EFI_MEDIA_CHANGED;
+
+ default:
+ //
+ // Initiator Error, Target Error, or any other undefined error code.
+ //
+ return EFI_PROTOCOL_ERROR;
}
+
//
// The status is success; extract the wanted fields from the header segment.
//
- Transit = ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT);
- Continue = ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE);
+ Transit = ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT);
+ Continue = ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE);
- CurrentStage = ISCSI_GET_CURRENT_STAGE (LoginRsp);
- NextStage = ISCSI_GET_NEXT_STAGE (LoginRsp);
+ CurrentStage = ISCSI_GET_CURRENT_STAGE (LoginRsp);
+ NextStage = ISCSI_GET_NEXT_STAGE (LoginRsp);
- LoginRsp->InitiatorTaskTag = NTOHL (LoginRsp->InitiatorTaskTag);
+ LoginRsp->InitiatorTaskTag = NTOHL (LoginRsp->InitiatorTaskTag);
if ((Transit && Continue) ||
(CurrentStage != Conn->CurrentStage) ||
@@ -957,7 +959,8 @@ IScsiProcessLoginRsp ( (Transit && (NextStage != Conn->NextStage)) ||
(CompareMem (Session->Isid, LoginRsp->Isid, sizeof (LoginRsp->Isid)) != 0) ||
(LoginRsp->InitiatorTaskTag != Session->InitiatorTaskTag)
- ) {
+ )
+ {
//
// A Login Response with the C bit set to 1 MUST have the T bit set to 0.
// The CSG in the Login Response MUST be the same with the I-end of this connection.
@@ -969,9 +972,9 @@ IScsiProcessLoginRsp ( return EFI_PROTOCOL_ERROR;
}
- LoginRsp->StatSN = NTOHL (LoginRsp->StatSN);
- LoginRsp->ExpCmdSN = NTOHL (LoginRsp->ExpCmdSN);
- LoginRsp->MaxCmdSN = NTOHL (LoginRsp->MaxCmdSN);
+ LoginRsp->StatSN = NTOHL (LoginRsp->StatSN);
+ LoginRsp->ExpCmdSN = NTOHL (LoginRsp->ExpCmdSN);
+ LoginRsp->MaxCmdSN = NTOHL (LoginRsp->MaxCmdSN);
if ((Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION) && (Conn->AuthStep == ISCSI_AUTH_INITIAL)) {
//
@@ -1003,6 +1006,7 @@ IScsiProcessLoginRsp ( return Status;
}
}
+
//
// Trim off the header segment.
//
@@ -1026,32 +1030,33 @@ IScsiProcessLoginRsp ( }
switch (CurrentStage) {
- case ISCSI_SECURITY_NEGOTIATION:
- //
- // In security negotiation stage, let CHAP module handle it.
- //
- if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) {
- Status = IScsiCHAPOnRspReceived (Conn);
- }
- break;
+ case ISCSI_SECURITY_NEGOTIATION:
+ //
+ // In security negotiation stage, let CHAP module handle it.
+ //
+ if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) {
+ Status = IScsiCHAPOnRspReceived (Conn);
+ }
- case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
- //
- // Response received with negotiation response on iSCSI parameters: check them.
- //
- Status = IScsiCheckOpParams (Conn);
- if (!EFI_ERROR (Status)) {
- Conn->ParamNegotiated = TRUE;
- }
+ break;
- break;
+ case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
+ //
+ // Response received with negotiation response on iSCSI parameters: check them.
+ //
+ Status = IScsiCheckOpParams (Conn);
+ if (!EFI_ERROR (Status)) {
+ Conn->ParamNegotiated = TRUE;
+ }
- default:
- //
- // Should never get here.
- //
- Status = EFI_PROTOCOL_ERROR;
- break;
+ break;
+
+ default:
+ //
+ // Should never get here.
+ //
+ Status = EFI_PROTOCOL_ERROR;
+ break;
}
if (Transit && (Status == EFI_SUCCESS)) {
@@ -1070,6 +1075,7 @@ IScsiProcessLoginRsp ( Session->Tsih = NTOHS (LoginRsp->Tsih);
}
}
+
//
// Flush the response(s) received.
//
@@ -1078,7 +1084,6 @@ IScsiProcessLoginRsp ( return Status;
}
-
/**
Updated the target information according the data received in the iSCSI
login response with an target redirection status.
@@ -1096,9 +1101,9 @@ IScsiProcessLoginRsp ( **/
EFI_STATUS
IScsiUpdateTargetAddress (
- IN OUT ISCSI_SESSION *Session,
- IN CHAR8 *Data,
- IN UINT32 Len
+ IN OUT ISCSI_SESSION *Session,
+ IN CHAR8 *Data,
+ IN UINT32 Len
)
{
LIST_ENTRY *KeyValueList;
@@ -1140,11 +1145,11 @@ IScsiUpdateTargetAddress ( //
TargetAddress++;
}
- } else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER){
+ } else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER) {
//
// The domainname of the target is presented in a bracketed IPv6 address format.
//
- TargetAddress ++;
+ TargetAddress++;
IpStr = TargetAddress;
while ((*TargetAddress != '\0') && (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER)) {
//
@@ -1158,8 +1163,7 @@ IScsiUpdateTargetAddress ( }
*TargetAddress = '\0';
- TargetAddress ++;
-
+ TargetAddress++;
} else {
//
// The domainname of the target is presented in the format of a DNS host name.
@@ -1169,6 +1173,7 @@ IScsiUpdateTargetAddress ( while ((*TargetAddress != '\0') && (*TargetAddress != ':') && (*TargetAddress != ',')) {
TargetAddress++;
}
+
NvData->DnsMode = TRUE;
}
@@ -1192,7 +1197,7 @@ IScsiUpdateTargetAddress ( if (Number > 0xFFFF) {
continue;
} else {
- NvData->TargetPort = (UINT16) Number;
+ NvData->TargetPort = (UINT16)Number;
}
} else {
//
@@ -1220,9 +1225,10 @@ IScsiUpdateTargetAddress ( // Target address is expressed as URL format, just save it and
// do DNS resolution when creating a TCP connection.
//
- if (AsciiStrSize (IpStr) > sizeof (Session->ConfigData->SessionConfigData.TargetUrl)){
+ if (AsciiStrSize (IpStr) > sizeof (Session->ConfigData->SessionConfigData.TargetUrl)) {
return EFI_INVALID_PARAMETER;
}
+
CopyMem (&Session->ConfigData->SessionConfigData.TargetUrl, IpStr, AsciiStrSize (IpStr));
} else {
Status = IScsiAsciiStrToIp (
@@ -1245,7 +1251,6 @@ IScsiUpdateTargetAddress ( return Status;
}
-
/**
The callback function to free the net buffer list.
@@ -1255,16 +1260,15 @@ IScsiUpdateTargetAddress ( VOID
EFIAPI
IScsiFreeNbufList (
- VOID *Arg
+ VOID *Arg
)
{
ASSERT (Arg != NULL);
- NetbufFreeList ((LIST_ENTRY *) Arg);
+ NetbufFreeList ((LIST_ENTRY *)Arg);
FreePool (Arg);
}
-
/**
The callback function called in NetBufFree; it does nothing.
@@ -1274,12 +1278,11 @@ IScsiFreeNbufList ( VOID
EFIAPI
IScsiNbufExtFree (
- VOID *Arg
+ VOID *Arg
)
{
}
-
/**
Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and
an optional data segment. The two parts will be put into two blocks of buffers in the
@@ -1302,25 +1305,25 @@ IScsiNbufExtFree ( **/
EFI_STATUS
IScsiReceivePdu (
- IN ISCSI_CONNECTION *Conn,
- OUT NET_BUF **Pdu,
- IN ISCSI_IN_BUFFER_CONTEXT *Context OPTIONAL,
- IN BOOLEAN HeaderDigest,
- IN BOOLEAN DataDigest,
- IN EFI_EVENT TimeoutEvent OPTIONAL
+ IN ISCSI_CONNECTION *Conn,
+ OUT NET_BUF **Pdu,
+ IN ISCSI_IN_BUFFER_CONTEXT *Context OPTIONAL,
+ IN BOOLEAN HeaderDigest,
+ IN BOOLEAN DataDigest,
+ IN EFI_EVENT TimeoutEvent OPTIONAL
)
{
- LIST_ENTRY *NbufList;
- UINT32 Len;
- NET_BUF *PduHdr;
- UINT8 *Header;
- EFI_STATUS Status;
- UINT32 PadLen;
- UINT32 InDataOffset;
- NET_FRAGMENT Fragment[2];
- UINT32 FragmentCount;
- NET_BUF *DataSeg;
- UINT32 PadAndCRC32[2];
+ LIST_ENTRY *NbufList;
+ UINT32 Len;
+ NET_BUF *PduHdr;
+ UINT8 *Header;
+ EFI_STATUS Status;
+ UINT32 PadLen;
+ UINT32 InDataOffset;
+ NET_FRAGMENT Fragment[2];
+ UINT32 FragmentCount;
+ NET_BUF *DataSeg;
+ UINT32 PadAndCRC32[2];
NbufList = AllocatePool (sizeof (LIST_ENTRY));
if (NbufList == NULL) {
@@ -1332,8 +1335,8 @@ IScsiReceivePdu ( //
// The header digest will be received together with the PDU header, if exists.
//
- Len = sizeof (ISCSI_BASIC_HEADER) + (HeaderDigest ? sizeof (UINT32) : 0);
- PduHdr = NetbufAlloc (Len);
+ Len = sizeof (ISCSI_BASIC_HEADER) + (HeaderDigest ? sizeof (UINT32) : 0);
+ PduHdr = NetbufAlloc (Len);
if (PduHdr == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
@@ -1344,6 +1347,7 @@ IScsiReceivePdu ( Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
InsertTailList (NbufList, &PduHdr->List);
//
@@ -1372,72 +1376,73 @@ IScsiReceivePdu ( //
goto FORM_PDU;
}
+
//
// Get the length of the padding bytes of the data segment.
//
PadLen = ISCSI_GET_PAD_LEN (Len);
switch (ISCSI_GET_OPCODE (Header)) {
- case ISCSI_OPCODE_SCSI_DATA_IN:
- //
- // To reduce memory copy overhead, try to use the buffer described by Context
- // if the PDU is an iSCSI SCSI data.
- //
- InDataOffset = ISCSI_GET_BUFFER_OFFSET (Header);
- if ((Context == NULL) || ((InDataOffset + Len) > Context->InDataLen)) {
- Status = EFI_PROTOCOL_ERROR;
- goto ON_EXIT;
- }
-
- Fragment[0].Len = Len;
- Fragment[0].Bulk = Context->InData + InDataOffset;
-
- if (DataDigest || (PadLen != 0)) {
+ case ISCSI_OPCODE_SCSI_DATA_IN:
//
- // The data segment is padded. Use two fragments to receive it:
- // the first to receive the useful data; the second to receive the padding.
+ // To reduce memory copy overhead, try to use the buffer described by Context
+ // if the PDU is an iSCSI SCSI data.
//
- Fragment[1].Len = PadLen + (DataDigest ? sizeof (UINT32) : 0);
- Fragment[1].Bulk = (UINT8 *)PadAndCRC32 + (4 - PadLen);
+ InDataOffset = ISCSI_GET_BUFFER_OFFSET (Header);
+ if ((Context == NULL) || ((InDataOffset + Len) > Context->InDataLen)) {
+ Status = EFI_PROTOCOL_ERROR;
+ goto ON_EXIT;
+ }
- FragmentCount = 2;
- } else {
- FragmentCount = 1;
- }
+ Fragment[0].Len = Len;
+ Fragment[0].Bulk = Context->InData + InDataOffset;
- DataSeg = NetbufFromExt (&Fragment[0], FragmentCount, 0, 0, IScsiNbufExtFree, NULL);
- if (DataSeg == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
+ if (DataDigest || (PadLen != 0)) {
+ //
+ // The data segment is padded. Use two fragments to receive it:
+ // the first to receive the useful data; the second to receive the padding.
+ //
+ Fragment[1].Len = PadLen + (DataDigest ? sizeof (UINT32) : 0);
+ Fragment[1].Bulk = (UINT8 *)PadAndCRC32 + (4 - PadLen);
+
+ FragmentCount = 2;
+ } else {
+ FragmentCount = 1;
+ }
- break;
+ DataSeg = NetbufFromExt (&Fragment[0], FragmentCount, 0, 0, IScsiNbufExtFree, NULL);
+ if (DataSeg == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
- case ISCSI_OPCODE_SCSI_RSP:
- case ISCSI_OPCODE_NOP_IN:
- case ISCSI_OPCODE_LOGIN_RSP:
- case ISCSI_OPCODE_TEXT_RSP:
- case ISCSI_OPCODE_ASYNC_MSG:
- case ISCSI_OPCODE_REJECT:
- case ISCSI_OPCODE_VENDOR_T0:
- case ISCSI_OPCODE_VENDOR_T1:
- case ISCSI_OPCODE_VENDOR_T2:
- //
- // Allocate buffer to receive the data segment.
- //
- Len += PadLen + (DataDigest ? sizeof (UINT32) : 0);
- DataSeg = NetbufAlloc (Len);
- if (DataSeg == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
+ break;
- NetbufAllocSpace (DataSeg, Len, NET_BUF_TAIL);
- break;
+ case ISCSI_OPCODE_SCSI_RSP:
+ case ISCSI_OPCODE_NOP_IN:
+ case ISCSI_OPCODE_LOGIN_RSP:
+ case ISCSI_OPCODE_TEXT_RSP:
+ case ISCSI_OPCODE_ASYNC_MSG:
+ case ISCSI_OPCODE_REJECT:
+ case ISCSI_OPCODE_VENDOR_T0:
+ case ISCSI_OPCODE_VENDOR_T1:
+ case ISCSI_OPCODE_VENDOR_T2:
+ //
+ // Allocate buffer to receive the data segment.
+ //
+ Len += PadLen + (DataDigest ? sizeof (UINT32) : 0);
+ DataSeg = NetbufAlloc (Len);
+ if (DataSeg == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
- default:
- Status = EFI_PROTOCOL_ERROR;
- goto ON_EXIT;
+ NetbufAllocSpace (DataSeg, Len, NET_BUF_TAIL);
+ break;
+
+ default:
+ Status = EFI_PROTOCOL_ERROR;
+ goto ON_EXIT;
}
InsertTailList (NbufList, &DataSeg->List);
@@ -1486,7 +1491,6 @@ ON_EXIT: return Status;
}
-
/**
Check and get the result of the parameter negotiation.
@@ -1502,25 +1506,25 @@ IScsiCheckOpParams ( IN OUT ISCSI_CONNECTION *Conn
)
{
- EFI_STATUS Status;
- LIST_ENTRY *KeyValueList;
- CHAR8 *Data;
- UINT32 Len;
- ISCSI_SESSION *Session;
- CHAR8 *Value;
- UINTN NumericValue;
+ EFI_STATUS Status;
+ LIST_ENTRY *KeyValueList;
+ CHAR8 *Data;
+ UINT32 Len;
+ ISCSI_SESSION *Session;
+ CHAR8 *Value;
+ UINTN NumericValue;
ASSERT (Conn->RspQue.BufNum != 0);
Session = Conn->Session;
- Len = Conn->RspQue.BufSize;
- Data = AllocatePool (Len);
+ Len = Conn->RspQue.BufSize;
+ Data = AllocatePool (Len);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *) Data);
+ NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *)Data);
Status = EFI_PROTOCOL_ERROR;
@@ -1532,6 +1536,7 @@ IScsiCheckOpParams ( FreePool (Data);
return Status;
}
+
//
// HeaderDigest
//
@@ -1549,6 +1554,7 @@ IScsiCheckOpParams ( } else {
goto ON_ERROR;
}
+
//
// DataDigest
//
@@ -1566,6 +1572,7 @@ IScsiCheckOpParams ( } else {
goto ON_ERROR;
}
+
//
// ErrorRecoveryLevel: result function is Minimum.
//
@@ -1579,7 +1586,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->ErrorRecoveryLevel = (UINT8) MIN (Session->ErrorRecoveryLevel, NumericValue);
+ Session->ErrorRecoveryLevel = (UINT8)MIN (Session->ErrorRecoveryLevel, NumericValue);
//
// InitialR2T: result function is OR.
@@ -1590,7 +1597,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
+ Session->InitialR2T = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
}
//
@@ -1601,15 +1608,16 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));
+ Session->ImmediateData = (BOOLEAN)(Session->ImmediateData && (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0));
//
// MaxRecvDataSegmentLength is declarative.
//
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH);
if (Value != NULL) {
- Conn->MaxRecvDataSegmentLength = (UINT32) IScsiNetNtoi (Value);
+ Conn->MaxRecvDataSegmentLength = (UINT32)IScsiNetNtoi (Value);
}
+
//
// MaxBurstLength: result function is Minimum.
//
@@ -1619,7 +1627,7 @@ IScsiCheckOpParams ( }
NumericValue = IScsiNetNtoi (Value);
- Session->MaxBurstLength = (UINT32) MIN (Session->MaxBurstLength, NumericValue);
+ Session->MaxBurstLength = (UINT32)MIN (Session->MaxBurstLength, NumericValue);
//
// FirstBurstLength: result function is Minimum. Irrelevant when InitialR2T=Yes and
@@ -1632,7 +1640,7 @@ IScsiCheckOpParams ( }
NumericValue = IScsiNetNtoi (Value);
- Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);
+ Session->FirstBurstLength = (UINT32)MIN (Session->FirstBurstLength, NumericValue);
}
//
@@ -1648,7 +1656,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->MaxConnections = (UINT32) MIN (Session->MaxConnections, NumericValue);
+ Session->MaxConnections = (UINT32)MIN (Session->MaxConnections, NumericValue);
//
// DataPDUInOrder: result function is OR.
@@ -1659,7 +1667,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->DataPDUInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
+ Session->DataPDUInOrder = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
}
//
@@ -1671,7 +1679,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->DataSequenceInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
+ Session->DataSequenceInOrder = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
}
//
@@ -1688,8 +1696,9 @@ IScsiCheckOpParams ( } else if (NumericValue > 3600) {
goto ON_ERROR;
} else {
- Session->DefaultTime2Wait = (UINT32) MAX (Session->DefaultTime2Wait, NumericValue);
+ Session->DefaultTime2Wait = (UINT32)MAX (Session->DefaultTime2Wait, NumericValue);
}
+
//
// DefaultTime2Retain: result function is Minimum.
//
@@ -1704,8 +1713,9 @@ IScsiCheckOpParams ( } else if (NumericValue > 3600) {
goto ON_ERROR;
} else {
- Session->DefaultTime2Retain = (UINT32) MIN (Session->DefaultTime2Retain, NumericValue);
+ Session->DefaultTime2Retain = (UINT32)MIN (Session->DefaultTime2Retain, NumericValue);
}
+
//
// MaxOutstandingR2T: result function is Minimum.
//
@@ -1719,7 +1729,7 @@ IScsiCheckOpParams ( goto ON_ERROR;
}
- Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue);
+ Session->MaxOutstandingR2T = (UINT16)MIN (Session->MaxOutstandingR2T, NumericValue);
//
// Remove declarative key-value pairs, if any.
@@ -1728,7 +1738,6 @@ IScsiCheckOpParams ( IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
-
//
// Remove the key-value that may not needed for result function is OR.
//
@@ -1759,7 +1768,6 @@ ON_ERROR: return Status;
}
-
/**
Fill the operational parameters.
@@ -1773,8 +1781,8 @@ IScsiFillOpParams ( IN OUT NET_BUF *Pdu
)
{
- ISCSI_SESSION *Session;
- CHAR8 Value[256];
+ ISCSI_SESSION *Session;
+ CHAR8 Value[256];
Session = Conn->Session;
@@ -1821,7 +1829,6 @@ IScsiFillOpParams ( IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_OUTSTANDING_R2T, Value);
}
-
/**
Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
@@ -1834,8 +1841,8 @@ IScsiFillOpParams ( **/
EFI_STATUS
IScsiPadSegment (
- IN OUT NET_BUF *Pdu,
- IN UINT32 Len
+ IN OUT NET_BUF *Pdu,
+ IN UINT32 Len
)
{
UINT32 PadLen;
@@ -1855,7 +1862,6 @@ IScsiPadSegment ( return EFI_SUCCESS;
}
-
/**
Build a key-value list from the data segment.
@@ -1868,8 +1874,8 @@ IScsiPadSegment ( **/
LIST_ENTRY *
IScsiBuildKeyValueList (
- IN CHAR8 *Data,
- IN UINT32 Len
+ IN CHAR8 *Data,
+ IN UINT32 Len
)
{
LIST_ENTRY *ListHead;
@@ -1909,10 +1915,10 @@ IScsiBuildKeyValueList ( KeyValuePair->Value = Data;
- InsertTailList (ListHead, &KeyValuePair->List);;
+ InsertTailList (ListHead, &KeyValuePair->List);
Data += AsciiStrLen (KeyValuePair->Value) + 1;
- Len -= (UINT32) AsciiStrLen (KeyValuePair->Value) + 1;
+ Len -= (UINT32)AsciiStrLen (KeyValuePair->Value) + 1;
}
return ListHead;
@@ -1924,7 +1930,6 @@ ON_ERROR: return NULL;
}
-
/**
Get the value string by the key name from the key-value list. If found,
the key-value entry will be removed from the list.
@@ -1938,8 +1943,8 @@ ON_ERROR: **/
CHAR8 *
IScsiGetValueByKeyFromList (
- IN OUT LIST_ENTRY *KeyValueList,
- IN CHAR8 *Key
+ IN OUT LIST_ENTRY *KeyValueList,
+ IN CHAR8 *Key
)
{
LIST_ENTRY *Entry;
@@ -1963,7 +1968,6 @@ IScsiGetValueByKeyFromList ( return Value;
}
-
/**
Free the key-value list.
@@ -1972,15 +1976,15 @@ IScsiGetValueByKeyFromList ( **/
VOID
IScsiFreeKeyValueList (
- IN LIST_ENTRY *KeyValueList
+ IN LIST_ENTRY *KeyValueList
)
{
LIST_ENTRY *Entry;
ISCSI_KEY_VALUE_PAIR *KeyValuePair;
while (!IsListEmpty (KeyValueList)) {
- Entry = NetListRemoveHead (KeyValueList);
- KeyValuePair = NET_LIST_USER_STRUCT (Entry, ISCSI_KEY_VALUE_PAIR, List);
+ Entry = NetListRemoveHead (KeyValueList);
+ KeyValuePair = NET_LIST_USER_STRUCT (Entry, ISCSI_KEY_VALUE_PAIR, List);
FreePool (KeyValuePair);
}
@@ -1988,7 +1992,6 @@ IScsiFreeKeyValueList ( FreePool (KeyValueList);
}
-
/**
Normalize the iSCSI name according to RFC.
@@ -2001,18 +2004,18 @@ IScsiFreeKeyValueList ( **/
EFI_STATUS
IScsiNormalizeName (
- IN OUT CHAR8 *Name,
- IN UINTN Len
+ IN OUT CHAR8 *Name,
+ IN UINTN Len
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < Len; Index++) {
if (NET_IS_UPPER_CASE_CHAR (Name[Index])) {
//
// Convert the upper-case characters to lower-case ones.
//
- Name[Index] = (CHAR8) (Name[Index] - 'A' + 'a');
+ Name[Index] = (CHAR8)(Name[Index] - 'A' + 'a');
}
if (!NET_IS_LOWER_CASE_CHAR (Name[Index]) &&
@@ -2020,7 +2023,8 @@ IScsiNormalizeName ( (Name[Index] != '-') &&
(Name[Index] != '.') &&
(Name[Index] != ':')
- ) {
+ )
+ {
//
// ASCII dash, dot, colon lower-case characters and digit characters
// are allowed.
@@ -2039,7 +2043,6 @@ IScsiNormalizeName ( return EFI_SUCCESS;
}
-
/**
Create an iSCSI task control block.
@@ -2057,8 +2060,8 @@ IScsiNewTcb ( OUT ISCSI_TCB **Tcb
)
{
- ISCSI_SESSION *Session;
- ISCSI_TCB *NewTcb;
+ ISCSI_SESSION *Session;
+ ISCSI_TCB *NewTcb;
ASSERT (Tcb != NULL);
@@ -2075,10 +2078,10 @@ IScsiNewTcb ( InitializeListHead (&NewTcb->Link);
- NewTcb->SoFarInOrder = TRUE;
- NewTcb->InitiatorTaskTag = Session->InitiatorTaskTag;
- NewTcb->CmdSN = Session->CmdSN;
- NewTcb->Conn = Conn;
+ NewTcb->SoFarInOrder = TRUE;
+ NewTcb->InitiatorTaskTag = Session->InitiatorTaskTag;
+ NewTcb->CmdSN = Session->CmdSN;
+ NewTcb->Conn = Conn;
InsertTailList (&Session->TcbList, &NewTcb->Link);
@@ -2093,7 +2096,6 @@ IScsiNewTcb ( return EFI_SUCCESS;
}
-
/**
Delete the tcb from the connection and destroy it.
@@ -2110,7 +2112,6 @@ IScsiDelTcb ( FreePool (Tcb);
}
-
/**
Create a data segment, pad it, and calculate the CRC if needed.
@@ -2133,15 +2134,15 @@ IScsiNewDataSegment ( UINT32 PadLen;
NET_BUF *DataSeg;
- Fragment[0].Len = Len;
- Fragment[0].Bulk = Data;
+ Fragment[0].Len = Len;
+ Fragment[0].Bulk = Data;
- PadLen = ISCSI_GET_PAD_LEN (Len);
+ PadLen = ISCSI_GET_PAD_LEN (Len);
if (PadLen != 0) {
- Fragment[1].Len = PadLen;
- Fragment[1].Bulk = (UINT8 *) &mDataSegPad;
+ Fragment[1].Len = PadLen;
+ Fragment[1].Bulk = (UINT8 *)&mDataSegPad;
- FragmentCount = 2;
+ FragmentCount = 2;
} else {
FragmentCount = 1;
}
@@ -2151,7 +2152,6 @@ IScsiNewDataSegment ( return DataSeg;
}
-
/**
Create a iSCSI SCSI command PDU to encapsulate the command issued
by SCSI through the EXT SCSI PASS THRU Protocol.
@@ -2166,9 +2166,9 @@ IScsiNewDataSegment ( **/
NET_BUF *
IScsiNewScsiCmdPdu (
- IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
- IN UINT64 Lun,
- IN ISCSI_TCB *Tcb
+ IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN UINT64 Lun,
+ IN ISCSI_TCB *Tcb
)
{
LIST_ENTRY *NbufList;
@@ -2197,7 +2197,7 @@ IScsiNewScsiCmdPdu ( //
// The CDB exceeds 16 bytes. An extended CDB AHS is required.
//
- AHSLength = (UINT8) (AHSLength + ISCSI_ROUNDUP (Packet->CdbLength - 16) + sizeof (ISCSI_ADDITIONAL_HEADER));
+ AHSLength = (UINT8)(AHSLength + ISCSI_ROUNDUP (Packet->CdbLength - 16) + sizeof (ISCSI_ADDITIONAL_HEADER));
}
Length = sizeof (SCSI_COMMAND) + AHSLength;
@@ -2206,12 +2206,13 @@ IScsiNewScsiCmdPdu ( return NULL;
}
- ScsiCmd = (SCSI_COMMAND *) NetbufAllocSpace (PduHeader, Length, NET_BUF_TAIL);
+ ScsiCmd = (SCSI_COMMAND *)NetbufAllocSpace (PduHeader, Length, NET_BUF_TAIL);
if (ScsiCmd == NULL) {
NetbufFree (PduHeader);
return NULL;
}
- Header = (ISCSI_ADDITIONAL_HEADER *) (ScsiCmd + 1);
+
+ Header = (ISCSI_ADDITIONAL_HEADER *)(ScsiCmd + 1);
ZeroMem (ScsiCmd, Length);
@@ -2222,31 +2223,31 @@ IScsiNewScsiCmdPdu ( // Set the READ/WRITE flags according to the IO type of this request.
//
switch (Packet->DataDirection) {
- case DataIn:
- ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_READ);
- ScsiCmd->ExpDataXferLength = NTOHL (Packet->InTransferLength);
- break;
+ case DataIn:
+ ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_READ);
+ ScsiCmd->ExpDataXferLength = NTOHL (Packet->InTransferLength);
+ break;
- case DataOut:
- ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_WRITE);
- ScsiCmd->ExpDataXferLength = NTOHL (Packet->OutTransferLength);
- break;
+ case DataOut:
+ ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_WRITE);
+ ScsiCmd->ExpDataXferLength = NTOHL (Packet->OutTransferLength);
+ break;
- case DataBi:
- ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_READ | SCSI_CMD_PDU_FLAG_WRITE);
- ScsiCmd->ExpDataXferLength = NTOHL (Packet->OutTransferLength);
+ case DataBi:
+ ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_READ | SCSI_CMD_PDU_FLAG_WRITE);
+ ScsiCmd->ExpDataXferLength = NTOHL (Packet->OutTransferLength);
- //
- // Fill the bidirectional expected read data length AHS.
- //
- BiExpReadDataLenAHS = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *) Header;
- Header = (ISCSI_ADDITIONAL_HEADER *) (BiExpReadDataLenAHS + 1);
+ //
+ // Fill the bidirectional expected read data length AHS.
+ //
+ BiExpReadDataLenAHS = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *)Header;
+ Header = (ISCSI_ADDITIONAL_HEADER *)(BiExpReadDataLenAHS + 1);
- BiExpReadDataLenAHS->Length = NTOHS (5);
- BiExpReadDataLenAHS->Type = ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN;
- BiExpReadDataLenAHS->ExpReadDataLength = NTOHL (Packet->InTransferLength);
+ BiExpReadDataLenAHS->Length = NTOHS (5);
+ BiExpReadDataLenAHS->Type = ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN;
+ BiExpReadDataLenAHS->ExpReadDataLength = NTOHL (Packet->InTransferLength);
- break;
+ break;
}
ScsiCmd->TotalAHSLength = AHSLength;
@@ -2258,15 +2259,15 @@ IScsiNewScsiCmdPdu ( CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
if (Packet->CdbLength > 16) {
- Header->Length = NTOHS ((UINT16) (Packet->CdbLength - 15));
- Header->Type = ISCSI_AHS_TYPE_EXT_CDB;
+ Header->Length = NTOHS ((UINT16)(Packet->CdbLength - 15));
+ Header->Type = ISCSI_AHS_TYPE_EXT_CDB;
- CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16);
+ CopyMem (Header + 1, (UINT8 *)Packet->Cdb + 16, Packet->CdbLength - 16);
}
- Pdu = PduHeader;
- Session = Tcb->Conn->Session;
- ImmediateDataLen = 0;
+ Pdu = PduHeader;
+ Session = Tcb->Conn->Session;
+ ImmediateDataLen = 0;
if (Session->ImmediateData && (Packet->OutTransferLength != 0)) {
//
@@ -2274,8 +2275,8 @@ IScsiNewScsiCmdPdu ( // data is the minimum of FirstBurstLength, the data length to be xfered, and
// the MaxRecvdataSegmentLength on this connection.
//
- ImmediateDataLen = MIN (Session->FirstBurstLength, Packet->OutTransferLength);
- ImmediateDataLen = MIN (ImmediateDataLen, Tcb->Conn->MaxRecvDataSegmentLength);
+ ImmediateDataLen = MIN (Session->FirstBurstLength, Packet->OutTransferLength);
+ ImmediateDataLen = MIN (ImmediateDataLen, Tcb->Conn->MaxRecvDataSegmentLength);
//
// Update the data segment length in the PDU header.
@@ -2285,7 +2286,7 @@ IScsiNewScsiCmdPdu ( //
// Create the data segment.
//
- DataSeg = IScsiNewDataSegment ((UINT8 *) Packet->OutDataBuffer, ImmediateDataLen, FALSE);
+ DataSeg = IScsiNewDataSegment ((UINT8 *)Packet->OutDataBuffer, ImmediateDataLen, FALSE);
if (DataSeg == NULL) {
NetbufFree (PduHeader);
Pdu = NULL;
@@ -2314,7 +2315,8 @@ IScsiNewScsiCmdPdu ( if (Session->InitialR2T ||
(ImmediateDataLen == Session->FirstBurstLength) ||
(ImmediateDataLen == Packet->OutTransferLength)
- ) {
+ )
+ {
//
// Unsolicited data out sequence is not allowed,
// or FirstBustLength data is already sent out by immediate data,
@@ -2330,7 +2332,6 @@ ON_EXIT: return Pdu;
}
-
/**
Create a new iSCSI SCSI Data Out PDU.
@@ -2353,12 +2354,12 @@ IScsiNewDataOutPdu ( IN UINT64 Lun
)
{
- LIST_ENTRY *NbufList;
- NET_BUF *PduHdr;
- NET_BUF *DataSeg;
- NET_BUF *Pdu;
- ISCSI_SCSI_DATA_OUT *DataOutHdr;
- ISCSI_XFER_CONTEXT *XferContext;
+ LIST_ENTRY *NbufList;
+ NET_BUF *PduHdr;
+ NET_BUF *DataSeg;
+ NET_BUF *Pdu;
+ ISCSI_SCSI_DATA_OUT *DataOutHdr;
+ ISCSI_XFER_CONTEXT *XferContext;
NbufList = AllocatePool (sizeof (LIST_ENTRY));
if (NbufList == NULL) {
@@ -2375,16 +2376,18 @@ IScsiNewDataOutPdu ( FreePool (NbufList);
return NULL;
}
+
//
// Insert the BHS into the buffer list.
//
InsertTailList (NbufList, &PduHdr->List);
- DataOutHdr = (ISCSI_SCSI_DATA_OUT *) NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL);
+ DataOutHdr = (ISCSI_SCSI_DATA_OUT *)NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL);
if (DataOutHdr == NULL) {
IScsiFreeNbufList (NbufList);
return NULL;
}
+
XferContext = &Tcb->XferContext;
ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
@@ -2404,6 +2407,7 @@ IScsiNewDataOutPdu ( if (XferContext->TargetTransferTag != ISCSI_RESERVED_TAG) {
CopyMem (&DataOutHdr->Lun, &Lun, sizeof (DataOutHdr->Lun));
}
+
//
// Build the data segment for this Data Out PDU.
//
@@ -2412,6 +2416,7 @@ IScsiNewDataOutPdu ( IScsiFreeNbufList (NbufList);
return NULL;
}
+
//
// Put the data segment into the buffer list and combine it with the BHS
// into a full Data Out PDU.
@@ -2425,7 +2430,6 @@ IScsiNewDataOutPdu ( return Pdu;
}
-
/**
Generate a consecutive sequence of iSCSI SCSI Data Out PDUs.
@@ -2486,11 +2490,12 @@ IScsiGenerateDataOutPduSequence ( //
// Update the context and DataSN.
//
- Data += DataLen;
- XferContext->Offset += DataLen;
+ Data += DataLen;
+ XferContext->Offset += DataLen;
XferContext->DesiredLength -= DataLen;
DataSN++;
}
+
//
// Set the F bit for the last data out PDU in this sequence.
//
@@ -2527,10 +2532,10 @@ IScsiSendDataOutPduSequence ( IN ISCSI_TCB *Tcb
)
{
- LIST_ENTRY *DataOutPduList;
- LIST_ENTRY *Entry;
- NET_BUF *Pdu;
- EFI_STATUS Status;
+ LIST_ENTRY *DataOutPduList;
+ LIST_ENTRY *Entry;
+ NET_BUF *Pdu;
+ EFI_STATUS Status;
//
// Generate the Data Out PDU sequence.
@@ -2546,7 +2551,7 @@ IScsiSendDataOutPduSequence ( // Send the Data Out PDU's one by one.
//
NET_LIST_FOR_EACH (Entry, DataOutPduList) {
- Pdu = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
+ Pdu = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
Status = TcpIoTransmit (&Tcb->Conn->TcpIo, Pdu);
@@ -2560,7 +2565,6 @@ IScsiSendDataOutPduSequence ( return Status;
}
-
/**
Process the received iSCSI SCSI Data In PDU.
@@ -2585,7 +2589,7 @@ IScsiOnDataInRcvd ( ISCSI_SCSI_DATA_IN *DataInHdr;
EFI_STATUS Status;
- DataInHdr = (ISCSI_SCSI_DATA_IN *) NetbufGetByte (Pdu, 0, NULL);
+ DataInHdr = (ISCSI_SCSI_DATA_IN *)NetbufGetByte (Pdu, 0, NULL);
if (DataInHdr == NULL) {
return EFI_PROTOCOL_ERROR;
}
@@ -2606,6 +2610,7 @@ IScsiOnDataInRcvd ( if (DataInHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) {
return EFI_PROTOCOL_ERROR;
}
+
//
// Update the command related sequence numbers.
//
@@ -2627,6 +2632,7 @@ IScsiOnDataInRcvd ( //
return EFI_PROTOCOL_ERROR;
}
+
//
// S bit is on, the StatSN is valid.
//
@@ -2640,7 +2646,7 @@ IScsiOnDataInRcvd ( if (ISCSI_FLAG_ON (DataInHdr, SCSI_RSP_PDU_FLAG_OVERFLOW)) {
Packet->InTransferLength += NTOHL (DataInHdr->ResidualCount);
- Status = EFI_BAD_BUFFER_SIZE;
+ Status = EFI_BAD_BUFFER_SIZE;
}
if (ISCSI_FLAG_ON (DataInHdr, SCSI_RSP_PDU_FLAG_UNDERFLOW)) {
@@ -2651,7 +2657,6 @@ IScsiOnDataInRcvd ( return Status;
}
-
/**
Process the received iSCSI R2T PDU.
@@ -2673,26 +2678,27 @@ IScsiOnR2TRcvd ( IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
- ISCSI_READY_TO_TRANSFER *R2THdr;
- EFI_STATUS Status;
- ISCSI_XFER_CONTEXT *XferContext;
- UINT8 *Data;
+ ISCSI_READY_TO_TRANSFER *R2THdr;
+ EFI_STATUS Status;
+ ISCSI_XFER_CONTEXT *XferContext;
+ UINT8 *Data;
- R2THdr = (ISCSI_READY_TO_TRANSFER *) NetbufGetByte (Pdu, 0, NULL);
+ R2THdr = (ISCSI_READY_TO_TRANSFER *)NetbufGetByte (Pdu, 0, NULL);
if (R2THdr == NULL) {
return EFI_PROTOCOL_ERROR;
}
- R2THdr->InitiatorTaskTag = NTOHL (R2THdr->InitiatorTaskTag);
- R2THdr->TargetTransferTag = NTOHL (R2THdr->TargetTransferTag);
- R2THdr->StatSN = NTOHL (R2THdr->StatSN);
- R2THdr->R2TSeqNum = NTOHL (R2THdr->R2TSeqNum);
- R2THdr->BufferOffset = NTOHL (R2THdr->BufferOffset);
+ R2THdr->InitiatorTaskTag = NTOHL (R2THdr->InitiatorTaskTag);
+ R2THdr->TargetTransferTag = NTOHL (R2THdr->TargetTransferTag);
+ R2THdr->StatSN = NTOHL (R2THdr->StatSN);
+ R2THdr->R2TSeqNum = NTOHL (R2THdr->R2TSeqNum);
+ R2THdr->BufferOffset = NTOHL (R2THdr->BufferOffset);
R2THdr->DesiredDataTransferLength = NTOHL (R2THdr->DesiredDataTransferLength);
if ((R2THdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) || !ISCSI_SEQ_EQ (R2THdr->StatSN, Tcb->Conn->ExpStatSN)) {
- return EFI_PROTOCOL_ERROR;;
+ return EFI_PROTOCOL_ERROR;
}
+
//
// Check the sequence number.
//
@@ -2701,26 +2707,27 @@ IScsiOnR2TRcvd ( return Status;
}
- XferContext = &Tcb->XferContext;
- XferContext->TargetTransferTag = R2THdr->TargetTransferTag;
- XferContext->Offset = R2THdr->BufferOffset;
- XferContext->DesiredLength = R2THdr->DesiredDataTransferLength;
+ XferContext = &Tcb->XferContext;
+ XferContext->TargetTransferTag = R2THdr->TargetTransferTag;
+ XferContext->Offset = R2THdr->BufferOffset;
+ XferContext->DesiredLength = R2THdr->DesiredDataTransferLength;
if (((XferContext->Offset + XferContext->DesiredLength) > Packet->OutTransferLength) ||
(XferContext->DesiredLength > Tcb->Conn->Session->MaxBurstLength)
- ) {
+ )
+ {
return EFI_PROTOCOL_ERROR;
}
+
//
// Send the data solicited by this R2T.
//
- Data = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset;
- Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
+ Data = (UINT8 *)Packet->OutDataBuffer + XferContext->Offset;
+ Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
return Status;
}
-
/**
Process the received iSCSI SCSI Response PDU.
@@ -2746,28 +2753,28 @@ IScsiOnScsiRspRcvd ( EFI_STATUS Status;
UINT32 DataSegLen;
- ScsiRspHdr = (SCSI_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
+ ScsiRspHdr = (SCSI_RESPONSE *)NetbufGetByte (Pdu, 0, NULL);
if (ScsiRspHdr == NULL) {
return EFI_PROTOCOL_ERROR;
}
- ScsiRspHdr->InitiatorTaskTag = NTOHL (ScsiRspHdr->InitiatorTaskTag);
+ ScsiRspHdr->InitiatorTaskTag = NTOHL (ScsiRspHdr->InitiatorTaskTag);
if (ScsiRspHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) {
return EFI_PROTOCOL_ERROR;
}
- ScsiRspHdr->StatSN = NTOHL (ScsiRspHdr->StatSN);
+ ScsiRspHdr->StatSN = NTOHL (ScsiRspHdr->StatSN);
- Status = IScsiCheckSN (&Tcb->Conn->ExpStatSN, ScsiRspHdr->StatSN);
+ Status = IScsiCheckSN (&Tcb->Conn->ExpStatSN, ScsiRspHdr->StatSN);
if (EFI_ERROR (Status)) {
return Status;
}
- ScsiRspHdr->MaxCmdSN = NTOHL (ScsiRspHdr->MaxCmdSN);
- ScsiRspHdr->ExpCmdSN = NTOHL (ScsiRspHdr->ExpCmdSN);
+ ScsiRspHdr->MaxCmdSN = NTOHL (ScsiRspHdr->MaxCmdSN);
+ ScsiRspHdr->ExpCmdSN = NTOHL (ScsiRspHdr->ExpCmdSN);
IScsiUpdateCmdSN (Tcb->Conn->Session, ScsiRspHdr->MaxCmdSN, ScsiRspHdr->ExpCmdSN);
- Tcb->StatusXferd = TRUE;
+ Tcb->StatusXferd = TRUE;
Packet->HostAdapterStatus = ScsiRspHdr->Response;
if (Packet->HostAdapterStatus != ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET) {
@@ -2778,13 +2785,14 @@ IScsiOnScsiRspRcvd ( if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW | SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW) ||
ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_OVERFLOW | SCSI_RSP_PDU_FLAG_UNDERFLOW)
- ) {
+ )
+ {
return EFI_PROTOCOL_ERROR;
}
if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW)) {
Packet->InTransferLength += NTOHL (ScsiRspHdr->BiReadResidualCount);
- Status = EFI_BAD_BUFFER_SIZE;
+ Status = EFI_BAD_BUFFER_SIZE;
}
if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW)) {
@@ -2811,14 +2819,14 @@ IScsiOnScsiRspRcvd ( DataSegLen = ISCSI_GET_DATASEG_LEN (ScsiRspHdr);
if (DataSegLen != 0) {
- SenseData = (ISCSI_SENSE_DATA *) NetbufGetByte (Pdu, sizeof (SCSI_RESPONSE), NULL);
+ SenseData = (ISCSI_SENSE_DATA *)NetbufGetByte (Pdu, sizeof (SCSI_RESPONSE), NULL);
if (SenseData == NULL) {
return EFI_PROTOCOL_ERROR;
}
- SenseData->Length = NTOHS (SenseData->Length);
+ SenseData->Length = NTOHS (SenseData->Length);
- Packet->SenseDataLength = (UINT8) MIN (SenseData->Length, Packet->SenseDataLength);
+ Packet->SenseDataLength = (UINT8)MIN (SenseData->Length, Packet->SenseDataLength);
if (Packet->SenseDataLength != 0) {
CopyMem (Packet->SenseData, &SenseData->Data[0], Packet->SenseDataLength);
}
@@ -2829,7 +2837,6 @@ IScsiOnScsiRspRcvd ( return Status;
}
-
/**
Process the received NOP In PDU.
@@ -2850,14 +2857,14 @@ IScsiOnNopInRcvd ( ISCSI_NOP_IN *NopInHdr;
EFI_STATUS Status;
- NopInHdr = (ISCSI_NOP_IN *) NetbufGetByte (Pdu, 0, NULL);
+ NopInHdr = (ISCSI_NOP_IN *)NetbufGetByte (Pdu, 0, NULL);
if (NopInHdr == NULL) {
return EFI_PROTOCOL_ERROR;
}
- NopInHdr->StatSN = NTOHL (NopInHdr->StatSN);
- NopInHdr->ExpCmdSN = NTOHL (NopInHdr->ExpCmdSN);
- NopInHdr->MaxCmdSN = NTOHL (NopInHdr->MaxCmdSN);
+ NopInHdr->StatSN = NTOHL (NopInHdr->StatSN);
+ NopInHdr->ExpCmdSN = NTOHL (NopInHdr->ExpCmdSN);
+ NopInHdr->MaxCmdSN = NTOHL (NopInHdr->MaxCmdSN);
if (NopInHdr->InitiatorTaskTag == ISCSI_RESERVED_TAG) {
if (NopInHdr->StatSN != Tcb->Conn->ExpStatSN) {
@@ -2875,7 +2882,6 @@ IScsiOnNopInRcvd ( return EFI_SUCCESS;
}
-
/**
Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
@@ -2902,25 +2908,25 @@ IScsiExecuteScsiCommand ( IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
- EFI_STATUS Status;
- ISCSI_DRIVER_DATA *Private;
- ISCSI_SESSION *Session;
- EFI_EVENT TimeoutEvent;
- ISCSI_CONNECTION *Conn;
- ISCSI_TCB *Tcb;
- NET_BUF *Pdu;
- ISCSI_XFER_CONTEXT *XferContext;
- UINT8 *Data;
- ISCSI_IN_BUFFER_CONTEXT InBufferContext;
- UINT64 Timeout;
- UINT8 *PduHdr;
-
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
- Session = Private->Session;
- Status = EFI_SUCCESS;
- Tcb = NULL;
- TimeoutEvent = NULL;
- Timeout = 0;
+ EFI_STATUS Status;
+ ISCSI_DRIVER_DATA *Private;
+ ISCSI_SESSION *Session;
+ EFI_EVENT TimeoutEvent;
+ ISCSI_CONNECTION *Conn;
+ ISCSI_TCB *Tcb;
+ NET_BUF *Pdu;
+ ISCSI_XFER_CONTEXT *XferContext;
+ UINT8 *Data;
+ ISCSI_IN_BUFFER_CONTEXT InBufferContext;
+ UINT64 Timeout;
+ UINT8 *PduHdr;
+
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
+ Session = Private->Session;
+ Status = EFI_SUCCESS;
+ Tcb = NULL;
+ TimeoutEvent = NULL;
+ Timeout = 0;
if (Session->State != SESSION_STATE_LOGGED_IN) {
Status = EFI_DEVICE_ERROR;
@@ -2942,6 +2948,7 @@ IScsiExecuteScsiCommand ( if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
//
// Encapsulate the SCSI request packet into an iSCSI SCSI Command PDU.
//
@@ -2951,13 +2958,14 @@ IScsiExecuteScsiCommand ( goto ON_EXIT;
}
- XferContext = &Tcb->XferContext;
- PduHdr = NetbufGetByte (Pdu, 0, NULL);
+ XferContext = &Tcb->XferContext;
+ PduHdr = NetbufGetByte (Pdu, 0, NULL);
if (PduHdr == NULL) {
Status = EFI_PROTOCOL_ERROR;
NetbufFree (Pdu);
goto ON_EXIT;
}
+
XferContext->Offset = ISCSI_GET_DATASEG_LEN (PduHdr);
//
@@ -2974,25 +2982,26 @@ IScsiExecuteScsiCommand ( if (!Session->InitialR2T &&
(XferContext->Offset < Session->FirstBurstLength) &&
(XferContext->Offset < Packet->OutTransferLength)
- ) {
+ )
+ {
//
// Unsolicited Data-Out sequence is allowed. There is remaining SCSI
// OUT data, and the limit of FirstBurstLength is not reached.
//
XferContext->TargetTransferTag = ISCSI_RESERVED_TAG;
- XferContext->DesiredLength = MIN (
- Session->FirstBurstLength,
- Packet->OutTransferLength - XferContext->Offset
- );
+ XferContext->DesiredLength = MIN (
+ Session->FirstBurstLength,
+ Packet->OutTransferLength - XferContext->Offset
+ );
- Data = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset;
- Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
+ Data = (UINT8 *)Packet->OutDataBuffer + XferContext->Offset;
+ Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
}
- InBufferContext.InData = (UINT8 *) Packet->InDataBuffer;
+ InBufferContext.InData = (UINT8 *)Packet->InDataBuffer;
InBufferContext.InDataLen = Packet->InTransferLength;
while (!Tcb->StatusXferd) {
@@ -3022,34 +3031,35 @@ IScsiExecuteScsiCommand ( NetbufFree (Pdu);
goto ON_EXIT;
}
+
switch (ISCSI_GET_OPCODE (PduHdr)) {
- case ISCSI_OPCODE_SCSI_DATA_IN:
- Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet);
- break;
+ case ISCSI_OPCODE_SCSI_DATA_IN:
+ Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet);
+ break;
- case ISCSI_OPCODE_R2T:
- Status = IScsiOnR2TRcvd (Pdu, Tcb, Lun, Packet);
- break;
+ case ISCSI_OPCODE_R2T:
+ Status = IScsiOnR2TRcvd (Pdu, Tcb, Lun, Packet);
+ break;
- case ISCSI_OPCODE_SCSI_RSP:
- Status = IScsiOnScsiRspRcvd (Pdu, Tcb, Packet);
- break;
+ case ISCSI_OPCODE_SCSI_RSP:
+ Status = IScsiOnScsiRspRcvd (Pdu, Tcb, Packet);
+ break;
- case ISCSI_OPCODE_NOP_IN:
- Status = IScsiOnNopInRcvd (Pdu, Tcb);
- break;
+ case ISCSI_OPCODE_NOP_IN:
+ Status = IScsiOnNopInRcvd (Pdu, Tcb);
+ break;
- case ISCSI_OPCODE_VENDOR_T0:
- case ISCSI_OPCODE_VENDOR_T1:
- case ISCSI_OPCODE_VENDOR_T2:
- //
- // These messages are vendor specific. Skip them.
- //
- break;
+ case ISCSI_OPCODE_VENDOR_T0:
+ case ISCSI_OPCODE_VENDOR_T1:
+ case ISCSI_OPCODE_VENDOR_T2:
+ //
+ // These messages are vendor specific. Skip them.
+ //
+ break;
- default:
- Status = EFI_PROTOCOL_ERROR;
- break;
+ default:
+ Status = EFI_PROTOCOL_ERROR;
+ break;
}
NetbufFree (Pdu);
@@ -3072,7 +3082,6 @@ ON_EXIT: return Status;
}
-
/**
Reinstate the session on some error.
@@ -3087,7 +3096,7 @@ IScsiSessionReinstatement ( IN ISCSI_SESSION *Session
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (Session->State != SESSION_STATE_FREE);
@@ -3105,7 +3114,6 @@ IScsiSessionReinstatement ( return Status;
}
-
/**
Initialize some session parameters before login.
@@ -3120,18 +3128,18 @@ IScsiSessionInit ( )
{
if (!Recovery) {
- Session->Signature = ISCSI_SESSION_SIGNATURE;
- Session->State = SESSION_STATE_FREE;
+ Session->Signature = ISCSI_SESSION_SIGNATURE;
+ Session->State = SESSION_STATE_FREE;
InitializeListHead (&Session->Conns);
InitializeListHead (&Session->TcbList);
}
- Session->Tsih = 0;
+ Session->Tsih = 0;
- Session->CmdSN = 1;
- Session->InitiatorTaskTag = 1;
- Session->NextCid = 1;
+ Session->CmdSN = 1;
+ Session->InitiatorTaskTag = 1;
+ Session->NextCid = 1;
Session->TargetPortalGroupTag = 0;
Session->MaxConnections = ISCSI_MAX_CONNS_PER_SESSION;
@@ -3147,7 +3155,6 @@ IScsiSessionInit ( Session->ErrorRecoveryLevel = 0;
}
-
/**
Abort the iSCSI session. That is, reset all the connection(s), and free the
resources.
@@ -3164,7 +3171,7 @@ IScsiSessionAbort ( EFI_GUID *ProtocolGuid;
if (Session->State != SESSION_STATE_LOGGED_IN) {
- return ;
+ return;
}
ASSERT (!IsListEmpty (&Session->Conns));
@@ -3197,5 +3204,5 @@ IScsiSessionAbort ( Session->State = SESSION_STATE_FAILED;
- return ;
+ return;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.h b/NetworkPkg/IScsiDxe/IScsiProto.h index a5792a8bae..4848f88b04 100644 --- a/NetworkPkg/IScsiDxe/IScsiProto.h +++ b/NetworkPkg/IScsiDxe/IScsiProto.h @@ -24,21 +24,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) < ((UINT32) 1 << 31)) \
)
-#define ISCSI_WELL_KNOWN_PORT 3260
-#define ISCSI_MAX_CONNS_PER_SESSION 1
+#define ISCSI_WELL_KNOWN_PORT 3260
+#define ISCSI_MAX_CONNS_PER_SESSION 1
-#define DEFAULT_MAX_RECV_DATA_SEG_LEN 8192
-#define MAX_RECV_DATA_SEG_LEN_IN_FFP 65536
-#define DEFAULT_MAX_OUTSTANDING_R2T 1
+#define DEFAULT_MAX_RECV_DATA_SEG_LEN 8192
+#define MAX_RECV_DATA_SEG_LEN_IN_FFP 65536
+#define DEFAULT_MAX_OUTSTANDING_R2T 1
-#define ISCSI_VERSION_MAX 0x00
-#define ISCSI_VERSION_MIN 0x00
+#define ISCSI_VERSION_MAX 0x00
+#define ISCSI_VERSION_MIN 0x00
-#define ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
-#define ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
+#define ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
+#define ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
-#define ISCSI_REDIRECT_ADDR_START_DELIMITER '['
-#define ISCSI_REDIRECT_ADDR_END_DELIMITER ']'
+#define ISCSI_REDIRECT_ADDR_START_DELIMITER '['
+#define ISCSI_REDIRECT_ADDR_END_DELIMITER ']'
#define ISCSI_KEY_AUTH_METHOD "AuthMethod"
#define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"
@@ -63,32 +63,32 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define ISCSI_KEY_SESSION_TYPE "SessionType"
#define ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH "MaxRecvDataSegmentLength"
-#define ISCSI_KEY_VALUE_NONE "None"
+#define ISCSI_KEY_VALUE_NONE "None"
///
/// connection state for initiator
///
-#define CONN_STATE_FREE 0
-#define CONN_STATE_XPT_WAIT 1
-#define CONN_STATE_IN_LOGIN 2
-#define CONN_STATE_LOGGED_IN 3
-#define CONN_STATE_IN_LOGOUT 4
-#define CONN_STATE_LOGOUT_REQUESTED 5
-#define CONN_STATE_CLEANUP_WAIT 6
-#define CONN_STATE_IN_CLEANUP 7
+#define CONN_STATE_FREE 0
+#define CONN_STATE_XPT_WAIT 1
+#define CONN_STATE_IN_LOGIN 2
+#define CONN_STATE_LOGGED_IN 3
+#define CONN_STATE_IN_LOGOUT 4
+#define CONN_STATE_LOGOUT_REQUESTED 5
+#define CONN_STATE_CLEANUP_WAIT 6
+#define CONN_STATE_IN_CLEANUP 7
///
/// session state for initiator
///
-#define SESSION_STATE_FREE 0
-#define SESSION_STATE_LOGGED_IN 1
-#define SESSION_STATE_FAILED 2
+#define SESSION_STATE_FREE 0
+#define SESSION_STATE_LOGGED_IN 1
+#define SESSION_STATE_FAILED 2
-#define ISCSI_RESERVED_TAG 0xffffffff
+#define ISCSI_RESERVED_TAG 0xffffffff
-#define ISCSI_REQ_IMMEDIATE 0x40
-#define ISCSI_OPCODE_MASK 0x3F
+#define ISCSI_REQ_IMMEDIATE 0x40
+#define ISCSI_OPCODE_MASK 0x3F
#define ISCSI_SET_OPCODE(PduHdr, Op, Flgs) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) = ((Op) | (Flgs)))
#define ISCSI_GET_OPCODE(PduHdr) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) & ISCSI_OPCODE_MASK)
@@ -101,8 +101,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define ISCSI_GET_CURRENT_STAGE(PduHdr) ((UINT8) (((PduHdr)->Flags >> 2) & 0x3))
#define ISCSI_GET_NEXT_STAGE(PduHdr) ((UINT8) (((PduHdr)->Flags) & 0x3))
-#define ISCSI_GET_PAD_LEN(DataLen) ((~(DataLen) + 1) & 0x3)
-#define ISCSI_ROUNDUP(DataLen) (((DataLen) + 3) &~(0x3))
+#define ISCSI_GET_PAD_LEN(DataLen) ((~(DataLen) + 1) & 0x3)
+#define ISCSI_ROUNDUP(DataLen) (((DataLen) + 3) &~(0x3))
#define HTON24(Dst, Src) \
do { \
@@ -111,7 +111,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent (Dst)[2] = (UINT8) ((UINT8) (Src) & 0xFF); \
} while (0);
-#define NTOH24(src) (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))
+#define NTOH24(src) (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))
#define ISCSI_GET_DATASEG_LEN(PduHdr) NTOH24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength)
#define ISCSI_SET_DATASEG_LEN(PduHdr, Len) HTON24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength, (Len))
@@ -135,30 +135,30 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Target opcodes.
//
-#define ISCSI_OPCODE_NOP_IN 0x20
-#define ISCSI_OPCODE_SCSI_RSP 0x21
-#define ISCSI_OPCODE_SCSI_TMF_RSP 0x22
-#define ISCSI_OPCODE_LOGIN_RSP 0x23
-#define ISCSI_OPCODE_TEXT_RSP 0x24
-#define ISCSI_OPCODE_SCSI_DATA_IN 0x25
-#define ISCSI_OPCODE_LOGOUT_RSP 0x26
-#define ISCSI_OPCODE_R2T 0x31
-#define ISCSI_OPCODE_ASYNC_MSG 0x32
-#define ISCSI_OPCODE_VENDOR_T0 0x3c
-#define ISCSI_OPCODE_VENDOR_T1 0x3d
-#define ISCSI_OPCODE_VENDOR_T2 0x3e
-#define ISCSI_OPCODE_REJECT 0x3f
-
-#define ISCSI_BHS_FLAG_FINAL 0x80
+#define ISCSI_OPCODE_NOP_IN 0x20
+#define ISCSI_OPCODE_SCSI_RSP 0x21
+#define ISCSI_OPCODE_SCSI_TMF_RSP 0x22
+#define ISCSI_OPCODE_LOGIN_RSP 0x23
+#define ISCSI_OPCODE_TEXT_RSP 0x24
+#define ISCSI_OPCODE_SCSI_DATA_IN 0x25
+#define ISCSI_OPCODE_LOGOUT_RSP 0x26
+#define ISCSI_OPCODE_R2T 0x31
+#define ISCSI_OPCODE_ASYNC_MSG 0x32
+#define ISCSI_OPCODE_VENDOR_T0 0x3c
+#define ISCSI_OPCODE_VENDOR_T1 0x3d
+#define ISCSI_OPCODE_VENDOR_T2 0x3e
+#define ISCSI_OPCODE_REJECT 0x3f
+
+#define ISCSI_BHS_FLAG_FINAL 0x80
//
// Defined AHS types, others are reserved.
//
-#define ISCSI_AHS_TYPE_EXT_CDB 0x1
-#define ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN 0x2
+#define ISCSI_AHS_TYPE_EXT_CDB 0x1
+#define ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN 0x2
-#define SCSI_CMD_PDU_FLAG_READ 0x40
-#define SCSI_CMD_PDU_FLAG_WRITE 0x20
+#define SCSI_CMD_PDU_FLAG_READ 0x40
+#define SCSI_CMD_PDU_FLAG_WRITE 0x20
#define ISCSI_CMD_PDU_TASK_ATTR_MASK 0x07
@@ -174,10 +174,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Flag bit definitions in SCSI response.
//
-#define SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW 0x10
-#define SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW 0x08
-#define SCSI_RSP_PDU_FLAG_OVERFLOW 0x04
-#define SCSI_RSP_PDU_FLAG_UNDERFLOW 0x02
+#define SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW 0x10
+#define SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW 0x08
+#define SCSI_RSP_PDU_FLAG_OVERFLOW 0x04
+#define SCSI_RSP_PDU_FLAG_UNDERFLOW 0x02
//
// iSCSI service response codes.
@@ -185,25 +185,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET 0x00
#define ISCSI_SERVICE_RSP_TARGET_FAILURE 0x01
-#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_COMPLETE 0
-#define ISCSI_TMF_RSP_PDU_RSP_TASK_NOT_EXIST 1
-#define ISCSI_TMF_RSP_PDU_RSP_LUN_NOT_EXIST 2
-#define ISCSI_TMF_RSP_PDU_RSP_TASK_STILL_ALLEGIANT 3
-#define ISCSI_TMF_RSP_PDU_RSP_TASK_REASSGIN_NOT_SUPPORTED 4
-#define ISCSI_TMF_RSP_PDU_RSP_NOT_SUPPORTED 5
-#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_AHTH_FAILED 6
-#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_REJECTED 255
+#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_COMPLETE 0
+#define ISCSI_TMF_RSP_PDU_RSP_TASK_NOT_EXIST 1
+#define ISCSI_TMF_RSP_PDU_RSP_LUN_NOT_EXIST 2
+#define ISCSI_TMF_RSP_PDU_RSP_TASK_STILL_ALLEGIANT 3
+#define ISCSI_TMF_RSP_PDU_RSP_TASK_REASSGIN_NOT_SUPPORTED 4
+#define ISCSI_TMF_RSP_PDU_RSP_NOT_SUPPORTED 5
+#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_AHTH_FAILED 6
+#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_REJECTED 255
#define SCSI_DATA_IN_PDU_FLAG_ACKKNOWLEDGE 0x40
#define SCSI_DATA_IN_PDU_FLAG_OVERFLOW SCSI_RSP_PDU_FLAG_OVERFLOW
#define SCSI_DATA_IN_PDU_FLAG_UNDERFLOW SCSI_RSP_PDU_FLAG_UNDERFLOW
#define SCSI_DATA_IN_PDU_FLAG_STATUS_VALID 0x01
-#define ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT 0x80
-#define ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE 0x40
+#define ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT 0x80
+#define ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE 0x40
-#define ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT
-#define ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE
+#define ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT
+#define ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE
#define ISCSI_LOGIN_STATUS_SUCCESS 0
#define ISCSI_LOGIN_STATUS_REDIRECTION 1
@@ -224,12 +224,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define ISCSI_SNACK_REQUEST_TYPE_DATA_ACK 2
#define ISCSI_SNACK_REQUEST_TYPE_RDATA 3
-#define ISCSI_SECURITY_NEGOTIATION 0
-#define ISCSI_LOGIN_OPERATIONAL_NEGOTIATION 1
-#define ISCSI_FULL_FEATURE_PHASE 3
+#define ISCSI_SECURITY_NEGOTIATION 0
+#define ISCSI_LOGIN_OPERATIONAL_NEGOTIATION 1
+#define ISCSI_FULL_FEATURE_PHASE 3
-typedef struct _ISCSI_SESSION ISCSI_SESSION;
-typedef struct _ISCSI_CONNECTION ISCSI_CONNECTION;
+typedef struct _ISCSI_SESSION ISCSI_SESSION;
+typedef struct _ISCSI_CONNECTION ISCSI_CONNECTION;
typedef enum {
DataIn = 0,
@@ -241,340 +241,340 @@ typedef enum { /// iSCSI Basic Header Segment
///
typedef struct _ISCSI_BASIC_HEADER {
- UINT8 OpCode;
- UINT8 Flags;
- UINT16 OpCodeSpecific1;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 OpCodeSpecific2[7];
+ UINT8 OpCode;
+ UINT8 Flags;
+ UINT16 OpCodeSpecific1;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 OpCodeSpecific2[7];
} ISCSI_BASIC_HEADER;
typedef struct _ISCSI_ADDTIONAL_HEADER {
- UINT16 Length;
- UINT8 Type;
- UINT8 TypeSpecific[1];
+ UINT16 Length;
+ UINT8 Type;
+ UINT8 TypeSpecific[1];
} ISCSI_ADDITIONAL_HEADER;
typedef struct _ISCSI_BI_EXP_READ_DATA_LEN_AHS {
- UINT16 Length;
- UINT8 Type;
- UINT8 Reserved;
- UINT32 ExpReadDataLength;
+ UINT16 Length;
+ UINT8 Type;
+ UINT8 Reserved;
+ UINT32 ExpReadDataLength;
} ISCSI_BI_EXP_READ_DATA_LEN_AHS;
///
/// SCSI Command
///
typedef struct _SCSI_COMMAND {
- UINT8 OpCode;
- UINT8 Flags;
- UINT16 Reserved;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 ExpDataXferLength;
- UINT32 CmdSN;
- UINT32 ExpStatSN;
- UINT8 Cdb[16];
+ UINT8 OpCode;
+ UINT8 Flags;
+ UINT16 Reserved;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 ExpDataXferLength;
+ UINT32 CmdSN;
+ UINT32 ExpStatSN;
+ UINT8 Cdb[16];
} SCSI_COMMAND;
///
/// SCSI Response
///
typedef struct _SCSI_RESPONSE {
- UINT8 OpCode;
- UINT8 Flags;
- UINT8 Response;
- UINT8 Status;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Reserved[8];
- UINT32 InitiatorTaskTag;
- UINT32 SNACKTag;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 ExpDataSN;
- UINT32 BiReadResidualCount;
- UINT32 ResidualCount;
+ UINT8 OpCode;
+ UINT8 Flags;
+ UINT8 Response;
+ UINT8 Status;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Reserved[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 SNACKTag;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 ExpDataSN;
+ UINT32 BiReadResidualCount;
+ UINT32 ResidualCount;
} SCSI_RESPONSE;
typedef struct _ISCSI_SENSE_DATA {
- UINT16 Length;
- UINT8 Data[2];
+ UINT16 Length;
+ UINT8 Data[2];
} ISCSI_SENSE_DATA;
///
/// iSCSI Task Management Function Request.
///
typedef struct _ISCSI_TMF_REQUEST {
- UINT8 OpCode;
- UINT8 Fuction;
- UINT16 Reserved1;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 ReferencedTaskTag;
- UINT32 CmdSN;
- UINT32 ExpStatSN;
- UINT32 RefCmdSN;
- UINT32 ExpDataSN;
- UINT32 Reserved2[2];
+ UINT8 OpCode;
+ UINT8 Fuction;
+ UINT16 Reserved1;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 ReferencedTaskTag;
+ UINT32 CmdSN;
+ UINT32 ExpStatSN;
+ UINT32 RefCmdSN;
+ UINT32 ExpDataSN;
+ UINT32 Reserved2[2];
} ISCSI_TMF_REQUEST;
///
/// iSCSI Task Management Function Response.
///
typedef struct _ISCSI_TMF_RESPONSE {
- UINT8 OpCode;
- UINT8 Reserved1;
- UINT8 Response;
- UINT8 Reserved2;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT32 Reserver3[2];
- UINT32 InitiatorTaskTag;
- UINT32 Reserved4;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 Reserved[3];
+ UINT8 OpCode;
+ UINT8 Reserved1;
+ UINT8 Response;
+ UINT8 Reserved2;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT32 Reserver3[2];
+ UINT32 InitiatorTaskTag;
+ UINT32 Reserved4;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 Reserved[3];
} ISCSI_TMF_RESPONSE;
///
/// SCSI Data-Out
///
typedef struct _ISCSI_SCSI_DATA_OUT {
- UINT8 OpCode;
- UINT8 Reserved1[3];
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 TargetTransferTag;
- UINT32 Reserved2;
- UINT32 ExpStatSN;
- UINT32 Reserved3;
- UINT32 DataSN;
- UINT32 BufferOffset;
- UINT32 Reserved4;
+ UINT8 OpCode;
+ UINT8 Reserved1[3];
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 TargetTransferTag;
+ UINT32 Reserved2;
+ UINT32 ExpStatSN;
+ UINT32 Reserved3;
+ UINT32 DataSN;
+ UINT32 BufferOffset;
+ UINT32 Reserved4;
} ISCSI_SCSI_DATA_OUT;
///
/// SCSI Data-In
///
typedef struct _ISCSI_SCSI_DATA_IN {
- UINT8 OpCode;
- UINT8 Flags;
- UINT8 Reserved1;
- UINT8 Status;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 TargetTransferTag;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 DataSN;
- UINT32 BufferOffset;
- UINT32 ResidualCount;
+ UINT8 OpCode;
+ UINT8 Flags;
+ UINT8 Reserved1;
+ UINT8 Status;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 TargetTransferTag;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 DataSN;
+ UINT32 BufferOffset;
+ UINT32 ResidualCount;
} ISCSI_SCSI_DATA_IN;
///
/// Ready To Transfer.
///
typedef struct _ISCSI_READY_TO_TRANSFER {
- UINT8 OpCode;
- UINT8 Reserved1[3];
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 TargetTransferTag;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 R2TSeqNum;
- UINT32 BufferOffset;
- UINT32 DesiredDataTransferLength;
+ UINT8 OpCode;
+ UINT8 Reserved1[3];
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 TargetTransferTag;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 R2TSeqNum;
+ UINT32 BufferOffset;
+ UINT32 DesiredDataTransferLength;
} ISCSI_READY_TO_TRANSFER;
typedef struct _ISCSI_ASYNC_MESSAGE {
- UINT8 OpCode;
- UINT8 Reserved1[8];
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 Reserved2;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT8 AsyncEvent;
- UINT8 AsyncVCode;
- UINT16 Parameter1;
- UINT16 Parameter2;
- UINT16 Parameter3;
- UINT32 Reserved3;
+ UINT8 OpCode;
+ UINT8 Reserved1[8];
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 Reserved2;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT8 AsyncEvent;
+ UINT8 AsyncVCode;
+ UINT16 Parameter1;
+ UINT16 Parameter2;
+ UINT16 Parameter3;
+ UINT32 Reserved3;
} ISCSI_ASYNC_MESSAGE;
///
/// Login Request.
///
typedef struct _ISCSI_LOGIN_REQUEST {
- UINT8 OpCode;
- UINT8 Flags;
- UINT8 VersionMax;
- UINT8 VersionMin;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Isid[6];
- UINT16 Tsih;
- UINT32 InitiatorTaskTag;
- UINT16 Cid;
- UINT16 Reserved1;
- UINT32 CmdSN;
- UINT32 ExpStatSN;
- UINT32 Reserved2[4];
+ UINT8 OpCode;
+ UINT8 Flags;
+ UINT8 VersionMax;
+ UINT8 VersionMin;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Isid[6];
+ UINT16 Tsih;
+ UINT32 InitiatorTaskTag;
+ UINT16 Cid;
+ UINT16 Reserved1;
+ UINT32 CmdSN;
+ UINT32 ExpStatSN;
+ UINT32 Reserved2[4];
} ISCSI_LOGIN_REQUEST;
///
/// Login Response.
///
typedef struct _ISCSI_LOGIN_RESPONSE {
- UINT8 OpCode;
- UINT8 Flags;
- UINT8 VersionMax;
- UINT8 VersionActive;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Isid[6];
- UINT16 Tsih;
- UINT32 InitiatorTaskTag;
- UINT32 Reserved1;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT8 StatusClass;
- UINT8 StatusDetail;
- UINT8 Reserved2[10];
+ UINT8 OpCode;
+ UINT8 Flags;
+ UINT8 VersionMax;
+ UINT8 VersionActive;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Isid[6];
+ UINT16 Tsih;
+ UINT32 InitiatorTaskTag;
+ UINT32 Reserved1;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT8 StatusClass;
+ UINT8 StatusDetail;
+ UINT8 Reserved2[10];
} ISCSI_LOGIN_RESPONSE;
///
/// Logout Request.
///
typedef struct _ISCSI_LOGOUT_REQUEST {
- UINT8 OpCode;
- UINT8 ReasonCode;
- UINT16 Reserved1;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT32 Reserved2[2];
- UINT32 InitiatorTaskTag;
- UINT16 Cid;
- UINT16 Reserved3;
- UINT32 CmdSN;
- UINT32 ExpStatSN;
- UINT32 Reserved4[4];
+ UINT8 OpCode;
+ UINT8 ReasonCode;
+ UINT16 Reserved1;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT32 Reserved2[2];
+ UINT32 InitiatorTaskTag;
+ UINT16 Cid;
+ UINT16 Reserved3;
+ UINT32 CmdSN;
+ UINT32 ExpStatSN;
+ UINT32 Reserved4[4];
} ISCSI_LOGOUT_REQUEST;
///
/// Logout Response.
///
typedef struct _ISCSI_LOGOUT_RESPONSE {
- UINT8 OpCode;
- UINT8 Reserved1;
- UINT8 Response;
- UINT8 Reserved2;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT32 Reserved3[2];
- UINT32 InitiatorTaskTag;
- UINT32 Reserved4;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 Reserved5;
- UINT16 Time2Wait;
- UINT16 Time2Retain;
- UINT32 Reserved6;
+ UINT8 OpCode;
+ UINT8 Reserved1;
+ UINT8 Response;
+ UINT8 Reserved2;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT32 Reserved3[2];
+ UINT32 InitiatorTaskTag;
+ UINT32 Reserved4;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 Reserved5;
+ UINT16 Time2Wait;
+ UINT16 Time2Retain;
+ UINT32 Reserved6;
} ISCSI_LOGOUT_RESPONSE;
///
/// SNACK Request.
///
typedef struct _ISCSI_SNACK_REQUEST {
- UINT8 OpCode;
- UINT8 Type;
- UINT16 Reserved1;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 TargetTransferTag;
- UINT32 Reserved2;
- UINT32 ExpStatSN;
- UINT32 Reserved[2];
- UINT32 BegRun;
- UINT32 RunLength;
+ UINT8 OpCode;
+ UINT8 Type;
+ UINT16 Reserved1;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 TargetTransferTag;
+ UINT32 Reserved2;
+ UINT32 ExpStatSN;
+ UINT32 Reserved[2];
+ UINT32 BegRun;
+ UINT32 RunLength;
} ISCSI_SNACK_REQUEST;
///
/// Reject.
///
typedef struct _ISCSI_REJECT {
- UINT8 OpCode;
- UINT8 Reserved1;
- UINT8 Reason;
- UINT8 Reserved2;
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT32 Reserved3[2];
- UINT32 InitiatorTaskTag;
- UINT32 Reserved4;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 DataSN;
- UINT32 Reserved5[2];
+ UINT8 OpCode;
+ UINT8 Reserved1;
+ UINT8 Reason;
+ UINT8 Reserved2;
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT32 Reserved3[2];
+ UINT32 InitiatorTaskTag;
+ UINT32 Reserved4;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 DataSN;
+ UINT32 Reserved5[2];
} ISCSI_REJECT;
///
/// NOP-Out.
///
typedef struct _ISCSI_NOP_OUT {
- UINT8 OpCode;
- UINT8 Reserved1[3];
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 TargetTransferTag;
- UINT32 CmdSN;
- UINT32 ExpStatSN;
- UINT32 Reserved2[4];
+ UINT8 OpCode;
+ UINT8 Reserved1[3];
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 TargetTransferTag;
+ UINT32 CmdSN;
+ UINT32 ExpStatSN;
+ UINT32 Reserved2[4];
} ISCSI_NOP_OUT;
///
/// NOP-In.
///
typedef struct _ISCSI_NOP_IN {
- UINT8 OpCode;
- UINT8 Reserved1[3];
- UINT8 TotalAHSLength;
- UINT8 DataSegmentLength[3];
- UINT8 Lun[8];
- UINT32 InitiatorTaskTag;
- UINT32 TargetTransferTag;
- UINT32 StatSN;
- UINT32 ExpCmdSN;
- UINT32 MaxCmdSN;
- UINT32 Reserved2[3];
+ UINT8 OpCode;
+ UINT8 Reserved1[3];
+ UINT8 TotalAHSLength;
+ UINT8 DataSegmentLength[3];
+ UINT8 Lun[8];
+ UINT32 InitiatorTaskTag;
+ UINT32 TargetTransferTag;
+ UINT32 StatSN;
+ UINT32 ExpCmdSN;
+ UINT32 MaxCmdSN;
+ UINT32 Reserved2[3];
} ISCSI_NOP_IN;
typedef enum {
@@ -583,41 +583,41 @@ typedef enum { } ISCSI_DIGEST_TYPE;
typedef struct _ISCSI_XFER_CONTEXT {
- UINT32 TargetTransferTag;
- UINT32 Offset;
- UINT32 DesiredLength;
- UINT32 ExpDataSN;
+ UINT32 TargetTransferTag;
+ UINT32 Offset;
+ UINT32 DesiredLength;
+ UINT32 ExpDataSN;
} ISCSI_XFER_CONTEXT;
typedef struct _ISCSI_IN_BUFFER_CONTEXT {
- UINT8 *InData;
- UINT32 InDataLen;
+ UINT8 *InData;
+ UINT32 InDataLen;
} ISCSI_IN_BUFFER_CONTEXT;
typedef struct _ISCSI_TCB {
- LIST_ENTRY Link;
-
- BOOLEAN SoFarInOrder;
- UINT32 ExpDataSN;
- BOOLEAN FbitReceived;
- BOOLEAN StatusXferd;
- UINT32 ActiveR2Ts;
- UINT32 Response;
- CHAR8 *Reason;
- UINT32 InitiatorTaskTag;
- UINT32 CmdSN;
- UINT32 SNACKTag;
-
- ISCSI_XFER_CONTEXT XferContext;
-
- ISCSI_CONNECTION *Conn;
+ LIST_ENTRY Link;
+
+ BOOLEAN SoFarInOrder;
+ UINT32 ExpDataSN;
+ BOOLEAN FbitReceived;
+ BOOLEAN StatusXferd;
+ UINT32 ActiveR2Ts;
+ UINT32 Response;
+ CHAR8 *Reason;
+ UINT32 InitiatorTaskTag;
+ UINT32 CmdSN;
+ UINT32 SNACKTag;
+
+ ISCSI_XFER_CONTEXT XferContext;
+
+ ISCSI_CONNECTION *Conn;
} ISCSI_TCB;
typedef struct _ISCSI_KEY_VALUE_PAIR {
- LIST_ENTRY List;
+ LIST_ENTRY List;
- CHAR8 *Key;
- CHAR8 *Value;
+ CHAR8 *Key;
+ CHAR8 *Value;
} ISCSI_KEY_VALUE_PAIR;
/**
@@ -657,8 +657,8 @@ IScsiDetatchConnection ( **/
EFI_STATUS
IScsiConnLogin (
- IN OUT ISCSI_CONNECTION *Conn,
- IN UINT16 Timeout
+ IN OUT ISCSI_CONNECTION *Conn,
+ IN UINT16 Timeout
);
/**
@@ -671,7 +671,7 @@ IScsiConnLogin ( **/
ISCSI_CONNECTION *
IScsiCreateConnection (
- IN ISCSI_SESSION *Session
+ IN ISCSI_SESSION *Session
);
/**
@@ -764,9 +764,9 @@ IScsiReceiveLoginRsp ( **/
EFI_STATUS
IScsiAddKeyValuePair (
- IN OUT NET_BUF *Pdu,
- IN CHAR8 *Key,
- IN CHAR8 *Value
+ IN OUT NET_BUF *Pdu,
+ IN CHAR8 *Key,
+ IN CHAR8 *Value
);
/**
@@ -818,9 +818,9 @@ IScsiProcessLoginRsp ( **/
EFI_STATUS
IScsiUpdateTargetAddress (
- IN OUT ISCSI_SESSION *Session,
- IN CHAR8 *Data,
- IN UINT32 Len
+ IN OUT ISCSI_SESSION *Session,
+ IN CHAR8 *Data,
+ IN UINT32 Len
);
/**
@@ -832,7 +832,7 @@ IScsiUpdateTargetAddress ( VOID
EFIAPI
IScsiFreeNbufList (
- VOID *Arg
+ VOID *Arg
);
/**
@@ -857,12 +857,12 @@ IScsiFreeNbufList ( **/
EFI_STATUS
IScsiReceivePdu (
- IN ISCSI_CONNECTION *Conn,
- OUT NET_BUF **Pdu,
- IN ISCSI_IN_BUFFER_CONTEXT *Context OPTIONAL,
- IN BOOLEAN HeaderDigest,
- IN BOOLEAN DataDigest,
- IN EFI_EVENT TimeoutEvent OPTIONAL
+ IN ISCSI_CONNECTION *Conn,
+ OUT NET_BUF **Pdu,
+ IN ISCSI_IN_BUFFER_CONTEXT *Context OPTIONAL,
+ IN BOOLEAN HeaderDigest,
+ IN BOOLEAN DataDigest,
+ IN EFI_EVENT TimeoutEvent OPTIONAL
);
/**
@@ -905,8 +905,8 @@ IScsiFillOpParams ( **/
EFI_STATUS
IScsiPadSegment (
- IN OUT NET_BUF *Pdu,
- IN UINT32 Len
+ IN OUT NET_BUF *Pdu,
+ IN UINT32 Len
);
/**
@@ -921,8 +921,8 @@ IScsiPadSegment ( **/
LIST_ENTRY *
IScsiBuildKeyValueList (
- IN CHAR8 *Data,
- IN UINT32 Len
+ IN CHAR8 *Data,
+ IN UINT32 Len
);
/**
@@ -938,8 +938,8 @@ IScsiBuildKeyValueList ( **/
CHAR8 *
IScsiGetValueByKeyFromList (
- IN OUT LIST_ENTRY *KeyValueList,
- IN CHAR8 *Key
+ IN OUT LIST_ENTRY *KeyValueList,
+ IN CHAR8 *Key
);
/**
@@ -950,7 +950,7 @@ IScsiGetValueByKeyFromList ( **/
VOID
IScsiFreeKeyValueList (
- IN LIST_ENTRY *KeyValueList
+ IN LIST_ENTRY *KeyValueList
);
/**
@@ -965,8 +965,8 @@ IScsiFreeKeyValueList ( **/
EFI_STATUS
IScsiNormalizeName (
- IN OUT CHAR8 *Name,
- IN UINTN Len
+ IN OUT CHAR8 *Name,
+ IN UINTN Len
);
/**
|