From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=eric.jin@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C550421168208 for ; Sat, 13 Oct 2018 19:25:58 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Oct 2018 19:25:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,379,1534834800"; d="scan'208";a="99208241" Received: from jjin9-mobl.ccr.corp.intel.com ([10.249.168.56]) by orsmga001.jf.intel.com with ESMTP; 13 Oct 2018 19:25:56 -0700 From: Eric Jin To: edk2-devel@lists.01.org Cc: Supreeth Venkatesh , Jiaxin Wu Date: Sun, 14 Oct 2018 10:25:52 +0800 Message-Id: <20181014022552.4800-1-eric.jin@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 Subject: [PATCH] uefi-sct/SctPkg:Implement the iSCSI devicepath to text X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Oct 2018 02:25:59 -0000 Cc: Supreeth Venkatesh Cc: Jiaxin Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Jin --- .../DevicePathToTextBBTestCoverage.c | 43 ++++++++++++++++++- .../BlackBoxTest/DevicePathToTextBBTestMain.c | 26 +++++++++-- .../DevicePathToText/BlackBoxTest/Guid.c | 1 + .../DevicePathToText/BlackBoxTest/Guid.h | 7 +++ 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c index c30af434..14c4c460 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c @@ -2202,7 +2202,48 @@ DevicePathToTextConvertDeviceNodeToTextCoverageTest ( SctFreePool (Text); } - + // + // iSCSI(Name,0x12AB,0x0000005678000000,CRC32C,None,CHAP_BI,TCP) + // + pDeviceNode1 = DevicePathUtilities->CreateDeviceNode (0x3, 0x13, sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + 4); + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->NetworkProtocol = 0x0; //TCP + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->LoginOption = 0x0002; + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->Lun = 0x0000007856000000; + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->TargetPortalGroupTag = 0x12AB; + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[0] = 'N'; + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[1] = 'a'; + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[2] = 'm'; + ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[3] = 'e'; + + Text = DevicePathToText->ConvertDeviceNodeToText (pDeviceNode1, FALSE, FALSE); + pDeviceNode2 = SctConvertTextToDeviceNode(Text); + + if ((pDeviceNode2 != NULL) && (SctCompareMem (pDeviceNode2, pDeviceNode1, SctDevicePathNodeLength(pDeviceNode1)) == 0)) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gDevicePathToTextBBTestFunctionAssertionGuid135, + L"EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL - ConvertDeviceNodeToText must correctly recover the converting ConvertTextToDeviceNode has acted on the device node string", + L"%a:%d: Convert result: %s - Expected:iSCSI(MyTargetName,0x12AB,0x0000005678000000,CRC32C,None,CHAP_BI,TCP)", + __FILE__, + (UINTN)__LINE__, + Text + ); + if (pDeviceNode1 != NULL) { + SctFreePool (pDeviceNode1); + } + if (pDeviceNode2 != NULL) { + SctFreePool (pDeviceNode2); + } + if (Text != NULL) { + SctFreePool (Text); + } + return EFI_SUCCESS; } diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c index 41cf217b..d755227c 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c @@ -2437,6 +2437,7 @@ BuildiSCSIDeviceNode ( CHAR16 *LunStr; UINT16 Options; UINT64 LunNum; + UINT64 TempLunNum; Status = GetNextRequiredParam(&TextDeviceNode, L"TargetName", &ParamIdentifierStr, &ParamIdentifierVal); if ((!EFI_ERROR(Status)) && (ParamIdentifierVal != NULL)) { @@ -2459,7 +2460,7 @@ BuildiSCSIDeviceNode ( return NULL; } - Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen (NameStr) * 2 + 2); + Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen (NameStr)); iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (0x3, 0x13, Length); if (iSCSI == NULL) { return NULL; @@ -2499,7 +2500,7 @@ BuildiSCSIDeviceNode ( if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) { Options |= 0x0002; } - break; + break; case 1: // DataDigest if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) { @@ -2514,6 +2515,9 @@ BuildiSCSIDeviceNode ( if (SctStrCmp (ParamIdentifierVal, L"CHAP_UNI") == 0) { Options |= 0x1000; } + if (SctStrCmp (ParamIdentifierVal, L"CHAP_BI") == 0) { + Options |= 0x0000; + } break; case 3: // Protocol @@ -2533,8 +2537,24 @@ BuildiSCSIDeviceNode ( SctUnicodeToAscii (iSCSI->iSCSITargetName, NameStr, SctStrLen (NameStr)); iSCSI->TargetPortalGroupTag = (UINT16) SctStrToUInt (PortalGroupStr); - SctStrToUInt64 (LunStr, &LunNum); + + // + // The LUN is an 8 byte array that is displayed in hexadecimal format with byte + // 0 first (i.e., on the left) and byte 7 last (i.e, on the right), and is required. + // + SctStrToUInt64 (LunStr, &TempLunNum); + LunNum = 0; + + LunNum = SctLShiftU64((TempLunNum & 0x00000000000000FF), 56);; + LunNum = LunNum | SctLShiftU64((TempLunNum & 0x000000000000FF00), 40); + LunNum = LunNum | SctLShiftU64((TempLunNum & 0x0000000000FF0000), 24); + LunNum = LunNum | SctLShiftU64((TempLunNum & 0x00000000FF000000), 8); + LunNum = LunNum | SctRShiftU64((TempLunNum & 0x000000FF00000000), 8); + LunNum = LunNum | SctRShiftU64((TempLunNum & 0x0000FF0000000000), 24); + LunNum = LunNum | SctRShiftU64((TempLunNum & 0x00FF000000000000), 40); + LunNum = LunNum | SctRShiftU64((TempLunNum & 0xFF00000000000000), 56); iSCSI->Lun = LunNum; + iSCSI->LoginOption = (UINT16) Options; return (EFI_DEVICE_PATH_PROTOCOL *) iSCSI; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.c index 9cad8d31..21944cee 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.c @@ -136,3 +136,4 @@ EFI_GUID gDevicePathToTextBBTestFunctionAssertionGuid133 = EFI_TEST_DEVICEPATHT EFI_GUID gDevicePathToTextBBTestFunctionAssertionGuid134 = EFI_TEST_DEVICEPATHTOTEXTBBTESTFUNCTION_ASSERTION_134_GUID; +EFI_GUID gDevicePathToTextBBTestFunctionAssertionGuid135 = EFI_TEST_DEVICEPATHTOTEXTBBTESTFUNCTION_ASSERTION_135_GUID; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.h index 41d2a8a8..e00186db 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/Guid.h @@ -400,3 +400,10 @@ extern EFI_GUID gDevicePathToTextBBTestFunctionAssertionGuid133; } extern EFI_GUID gDevicePathToTextBBTestFunctionAssertionGuid134; + +#define EFI_TEST_DEVICEPATHTOTEXTBBTESTFUNCTION_ASSERTION_135_GUID \ + { \ + 0xbf73c00e, 0x5a62, 0x4a20, { 0xbe, 0x15, 0x4d, 0x83, 0x7e, 0xe5, 0x7d, 0xdf } \ + } +extern EFI_GUID gDevicePathToTextBBTestFunctionAssertionGuid135; + -- 2.18.0.windows.1