From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.73]) by mx.groups.io with SMTP id smtpd.web11.26390.1683619011328400058 for ; Tue, 09 May 2023 00:56:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=RwEEQ3s9; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.244.73, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mi3vnj8e4UZeCKTHYaEzopMcZ6KH3X/dAtFYCPxTwul9HO/sS9iIT2I9utikWLYMBBiDW4LDvB89d0oljwec2DNu4brkVV2PyfFW1CYfAY9GtpOGBSS1ZVelSGDEnP3alTm6PnpxBszRo04eMF6U9VDZ5uCv9tagikmout8IcZa3JfLvDla1u51b4ddpo30BUJ4qT6mb3abMUr7Zl9dWk4XL+Dg2ST7+Be59Lx+6DRawPCyskU3fNK84UDi0ezbwNWLgHHfMRO1ufORQqyCsRKez9y6kj6Qi3i9DNfxBhyvIGaWLlROeSHCYLmKJmWZ4p2/PZ3lLQJQUNu7khjFw0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WPVJcBreqR43y7xcPg/4zM+rbwAfW0uNeoIYcb0oUJE=; b=Q0Cg1FP/afa83dRQsLW+SyP8/1tF5hulEx0YABJkXzJWF8BvSAS330BOaqzBxAMVmrKZ/nuxjs7dQ4KEKSX0klCPX2CPhAHKcRLMDmjKFIC4FZiLTNDJDMMeEFpT/K2tWT17iq1Cuy6D7NtQwaIQsYnkMvD0KPOJ5RL6VN/3TKNw9QvF8oktUYFC7VkjjUTCHzAzcUow2XukTi6AwoUBBAgEVt2nG886QxsA+PHVrCAZO5wsak6t/DO+TqRiTtH5fjpfEZCzPWTYdn7ZryfSD2fS1foTpoKwgw6uwrUqu8aw8C1qGb41Zb4zWMNJ2xSHV36Nv/7A+v2SzxtJ5J4Xeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WPVJcBreqR43y7xcPg/4zM+rbwAfW0uNeoIYcb0oUJE=; b=RwEEQ3s98hq4oymLv9i0Ed4nKAr62V4B7KcKKQmHdJsa5OqK7qHVCFtEyWa99mDV3LjyGI2JuwDZV9smkANwDVqU3SRvw4XOsLXSvsjTXAjx3jXEYOH4QVtlX5cIREwtFM7by8s0E1kPZ7wgAXrPEaHg8ixsUrXB2g1NI0XWUpc= Received: from BN1PR14CA0004.namprd14.prod.outlook.com (2603:10b6:408:e3::9) by CY5PR12MB6527.namprd12.prod.outlook.com (2603:10b6:930:30::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 07:56:47 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e3:cafe::10) by BN1PR14CA0004.outlook.office365.com (2603:10b6:408:e3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33 via Frontend Transport; Tue, 9 May 2023 07:56:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.33 via Frontend Transport; Tue, 9 May 2023 07:56:46 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 9 May 2023 02:56:44 -0500 From: "Chang, Abner" To: CC: Isaac Oram , Abdul Lateef Attar , Nickle Wang , Tinh Nguyen Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg: Add Manageability IPMI helper Library Date: Tue, 9 May 2023 15:56:01 +0800 Message-ID: <20230509075602.342-1-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT039:EE_|CY5PR12MB6527:EE_ X-MS-Office365-Filtering-Correlation-Id: 14d1a0cf-8924-47f5-9265-08db5062f028 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LKYd6T2qVN7fFwIGMiE+8ojOc5bTZRRiMP91qtIDO6c7/xtySZs2ZQlNx3VHpcrJO3+W7mX+uYOZYn1fduvAiz6NSNEBwJEbisASPevYt97FDwcbWM85rN0BidcWsyjBs+T1W9mfM4ziAdjFRUu0FcQ+hupSjr08DuzOIsJ4WUSwLARE0MjhIHtr8Wk0jr3a2ihZvQjYxAPIrF13LbM4kaUC6qjU3Cdh1d1IiiuBue3pBzDkt9jBIVY29rYe9dAZks9TKsPIHm6XI244BIGLx39MIgt2ylOUXEeRiZ1x7KT0h83urhOghnaMG2CZklIiH80gJhkzK4DRG5Pn79ous2Y3N1Np0fxIFp9KMdDFOdfXzIEVRFT7qUl8KKKSdxw4jIXSti5+tposRt4c/cPORwmOnHaLfJiviVL6ortf9H0I9JN1HwdgteydbH5JOZ1MDtp5LWBjq6dfZmoVlj7zmY0b/Agoy8w38czOTFLe1oNvZyFwrVQD3lltMaPJdJXd7vNfI2XqA8BGhdMeYPBVnTDd4ZpuhR/sINne+JG5JIcyg9YorTcCq5qbo0SCH6QsoRHsTLYOxT8HODGeg51nKk4jqQwfh6AVuYOKYK19CfdyZWgFHOdsRennFsVe25GDcb/Z6tYGh2NOnZ/wdzYod9CwgZIITWkF9bxuEvBBmZI9ZLq2xJSoQFRpWhudiVCAmQ5jSBb3u+Yk3/ATdv6oiEfUdpT/B4Mf8P74mzCy0Us= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(478600001)(2616005)(83380400001)(47076005)(336012)(426003)(36860700001)(86362001)(40480700001)(1076003)(26005)(6666004)(7696005)(81166007)(82740400003)(356005)(316002)(54906003)(4326008)(70586007)(70206006)(6916009)(16526019)(186003)(41300700001)(8676002)(8936002)(40460700003)(2906002)(2876002)(82310400005)(5660300002)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 07:56:46.8640 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14d1a0cf-8924-47f5-9265-08db5062f028 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6527 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang Add IPMI helper library to print debug message of IPMI Completion Code in human readable string and return the transport interface additional status. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Tinh Nguyen --- .../BaseManageabilityTransportHelper.inf | 1 + .../Library/ManageabilityTransportHelperLib.h | 24 +++++++ .../Library/ManageabilityTransportIpmiLib.h | 13 +++- .../Library/ManageabilityTransportLib.h | 11 +-- .../BaseManageabilityTransportIpmiHelper.c | 70 +++++++++++++++++++ 5 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTran= sportHelperLib/BaseManageabilityTransportIpmiHelper.c diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Li= brary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.= inf index c9e5eaef60..0936449fda 100644 --- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.inf +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.inf @@ -21,6 +21,7 @@ =20 [Sources] BaseManageabilityTransportHelper.c + BaseManageabilityTransportIpmiHelper.c =20 [LibraryClasses] BaseMemoryLib diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTran= sportHelperLib.h index c2c98d6c2d..11a1bd0521 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe= rLib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe= rLib.h @@ -187,4 +187,28 @@ HelperManageabilityDebugPrint ( ... ); =20 +/// +/// IPMI Helper Functions. +/// + +/** + This function returns a human readable string of IPMI KCS Completion Cod= e + and returns the corresponding additional status of transport interface. + + @param [in] CompletionCode The Completion Code returned from KCS. + @param [out] CompletionCodeStr Human readable string of IPMI Completion= Code. + @param [out] AdditionalStatus Return the addtional status. + + @retval EFI_SUCCESS The information of Completion Code is re= turned. + @retval EFI_NOT_FOUND No information of Completion Code is ret= urned. + @retval EFI_INVALID_PARAMETER The given parameter is incorrect. + +**/ +EFI_STATUS +IpmiHelperCheckCompletionCode ( + IN UINT8 CompletionCode, + OUT CHAR16 **CompletionCodeStr, + OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus + ); + #endif diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtIpmiLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransp= ortIpmiLib.h index 1628255a6a..6d136e460f 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiL= ib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportIpmiL= ib.h @@ -16,9 +16,18 @@ /// the payload. /// typedef struct { - UINT8 Lun:2; - UINT8 NetFn:6; + UINT8 Lun : 2; + UINT8 NetFn : 6; UINT8 Command; } MANAGEABILITY_IPMI_TRANSPORT_HEADER; =20 +/// +/// The IPMI Completion Code mapping. +/// +typedef struct { + UINT8 CompletionCode; + CHAR16 *CompletionCodeString; + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS AdditionalStatus; +} MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING; + #endif diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportL= ib.h index 04072aee89..f423a1ed44 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h @@ -61,11 +61,12 @@ typedef union { /// Additional transport interface status. /// typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS; -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS 0x0000000= 0 -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR 0x0000000= 1 -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ 0x0000000= 2 -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE 0x0000000= 4 -#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE 0xfffffff= f +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS 0x00000= 000 +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR 0x00000= 001 +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ 0x00000= 002 +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_WRITE 0x00000= 004 +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND 0x00000= 008 +#define MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NOT_AVAILABLE 0xfffff= fff =20 /// /// Additional transport interface features. diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportIpmiHelper.c b/Features/ManageabilityPkg/= Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportIpmiH= elper.c new file mode 100644 index 0000000000..8710cafc99 --- /dev/null +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportIpmiHelper.c @@ -0,0 +1,70 @@ +/** @file + Null instance of Manageability IPMI Helper Library + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include + +#include + +// +// BaseManageabilityTransportHelper is used by PEI, DXE and SMM. +// Make sure the global variables added here should be unchangeable. +// +MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING IpmiCompletionCodeMapping[] = =3D { + { IPMI_COMP_CODE_NORMAL, L"IPMI Completion Code - Normal", = MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERRORS }, + { IPMI_COMP_CODE_NODE_BUSY, L"IPMI Completion Code - Busy", = MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_BUSY_IN_READ }, + { IPMI_COMP_CODE_INVALID_COMMAND, L"IPMI Completion Code - Invalid comma= nd", MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_INVALID_COMMAND } +}; + +UINT8 IpmiCompletionCodeMappingEntries =3D sizeof (IpmiCompletionCodeMapp= ing) / sizeof (MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING); + +/// +/// IPMI Helper Functions. +/// + +/** + This function returns a human readable string of IPMI KCS Completion Cod= e + and returns the corresponding additional status of transport interface. + + @param [in] CompletionCode The Completion Code returned from KCS. + @param [out] CompletionCodeStr Human readable string of IPMI Completion= Code. + @param [out] AdditionalStatus Return the addtional status. + + @retval EFI_SUCCESS The information of Completion Code is re= turned. + @retval EFI_NOT_FOUND No information of Completion Code is ret= urned. + @retval EFI_INVALID_PARAMETER The given parameter is incorrect. + +**/ +EFI_STATUS +IpmiHelperCheckCompletionCode ( + IN UINT8 CompletionCode, + OUT CHAR16 **CompletionCodeStr, + OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus + ) +{ + UINT8 Index; + MANAGEABILITY_IPMI_COMPLETTION_CODE_MAPPING *ThisCcMapping; + + if ((CompletionCodeStr =3D=3D NULL) || (AdditionalStatus =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + *AdditionalStatus =3D 0; + ThisCcMapping =3D IpmiCompletionCodeMapping; + for (Index =3D 0; Index < IpmiCompletionCodeMappingEntries; Index++) { + if (ThisCcMapping->CompletionCode =3D=3D CompletionCode) { + *CompletionCodeStr =3D ThisCcMapping->CompletionCodeString; + *AdditionalStatus =3D ThisCcMapping->AdditionalStatus; + return EFI_SUCCESS; + } + + ThisCcMapping++; + } + + return EFI_NOT_FOUND; +} --=20 2.37.1.windows.1