From nobody Mon May 20 22:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106608+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106608+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1688395423085730.655712563025; Mon, 3 Jul 2023 07:43:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id gME0YY1788612xkIJdQYmffK; Mon, 03 Jul 2023 07:43:42 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.81]) by mx.groups.io with SMTP id smtpd.web10.34565.1688395421545142037 for ; Mon, 03 Jul 2023 07:43:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvSanyR8nDhr63TvQNpVIHuNhN3bjLTG+KM382Je7VrHgNJEWaTGfpIwlcNkRDCHfaGCPpz0oBXWWVNkPl5/gPueNRcSjB60YWSAgIA1y64nGe5IflMNPGK0p+IBDgMaGjtZ+H1ixDXI0DkfdYp7HOjM0AZZRMz9IUrLq0nEeZ0Bpkuqkowz4/ej/oeZWKO0zDwQyJC69tbCT5Fciwlvj3cXtB8AMYy0mTXKMShzS+NkB96f2pMzFRrRdbIEkselTGLDkCln6yZhOu1hkcmtiUxsTliSIqLvApTNgSddKpjQfhCpAGyJOKm1Hudtt5ax0dZNyCX7y7gXs2kt/lcEuA== 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=hR3QA9hxy2rxxLapCTcaaWBrfMnk78RYDs3u6LTcZqE=; b=dm25wQ/lg7C9JYlyO/u/NYmfY/l2BS+tw3dnPO9xCN3q32RDSNWCmF6qKLXf32l1MRxLuPoI0g5tLByEKUAtIl3+XsvkzZtUjr71ailp9iz4XrUvDFnr2vrsL/SVcRWTypeRx7XEzqaTVL0klW6x180WlHQMrfDcf1yD5YY1JSO/pD3xvhkIP12HR+0nzKIErOHJVaMMNMDYtMvQ0h4tcL2SxeMv7e0a+TWc67BtD8jbJEw9GSImux+W73kNf0oHrjPWDoLVf6DtaJgZZFST7qKkeBbJ4EyJAaPuBcD/Vq5DYWmz/f0K+471N0sSDDUTY5waOb3mTYYQUIg0NVMKZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from PH0PR10MB5403.namprd10.prod.outlook.com (2603:10b6:510:e3::17) by CYYPR10MB7625.namprd10.prod.outlook.com (2603:10b6:930:c0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Mon, 3 Jul 2023 14:43:36 +0000 X-Received: from PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::a30c:64b7:c3a0:fff7]) by PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::a30c:64b7:c3a0:fff7%4]) with mapi id 15.20.6544.024; Mon, 3 Jul 2023 14:43:35 +0000 From: "Arun K via groups.io" To: "devel@edk2.groups.io" , Arun K CC: "isaac.w.oram@intel.com" , "nathaniel.l.desimone@intel.com" , Ramkumar Krishnamoorthi , Liming Gao Subject: [edk2-devel][edk2-platforms][PATCH V4-2] IpmiFeaturePkg:Provided multiple IPMI interface support in DXE and SMM Thread-Topic: [edk2-devel][edk2-platforms][PATCH V4-2] IpmiFeaturePkg:Provided multiple IPMI interface support in DXE and SMM Thread-Index: AQHZrby/I+mS1c+qP06vG/hMEvtJ6w== Date: Mon, 3 Jul 2023 14:43:35 +0000 Message-ID: <36aec8fd621de67e5695aceb25aa168ca53f82b3.1688392902.git.arunk@ami.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR10MB5403:EE_|CYYPR10MB7625:EE_ x-ms-office365-filtering-correlation-id: 7aeccf25-140c-4858-0915-08db7bd3e1c0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: DwynnsJuuihvbE4++T6dJoBRMRsgNVUK5eVYlm1WCJdSgsv5gXYkJH5wpiHpzwuofxzALSYCvdRyww8B6hiXBeTcZMVQdj5wlFgiubh98cGbgA0WoL1D3HSsoLu3x+XHFk7KidpWVhX5PnVEag06KmWrQ2yqc9XEpYJnamwOy6ToldpfbQugSwuLuFKsJWBKOAP1RGEiFzmoq+MtfYHLuPDkefZsCVvRQdKRB64d3H16wZnXwMNzMaEBHrJD3dhgln/geqCdadICMFOZMHnF0dz9+MfjcMV+FOV/SspN5kvM2BuDt2XjLHCQrp1DmMzR6+MwmziS5TSc1iPmues6ufnPONkdedOzXBKdKma1bNGi79c+iOPD716kmWWtGrSHOStcgxtZa2uRBzKo6lztSmdWKVOFypmcqAzk35mi+iCw0jxM2NO7my2n//dtuFJh9doZF37+SUi8lGit2UORbng/0uu2pj/+MFuc8OyFFp+mDb44S0wgazypkyTfCEEimeruBISQUEPE0easaK+zLhXeZ+R8eAWuI3yIdfP5rrsZ9bHkfB2xxXt/QR19SM+Nl9jKa4kErJDq01ptT/I6qzdUBwhsNgABoP5xiu/9vzRfbKSmra43C4Gm0M6CE35C x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?PaYlkb68gJS04RWcCm2FK0eMGEleuZ15P6ThGr7yuFp8GIgbyeOh2KAv/E?= =?iso-8859-1?Q?E83OZGogWWPAYvw3CyQZkBBD9DvJhscAXxjSV50pCRx7THjnrheUXAN5cq?= =?iso-8859-1?Q?mRAbj4m/JCFBEFVZKUliukZWMPZSgGWnTySF+QmjakxXcMlUSuNtGZx/pr?= =?iso-8859-1?Q?xG0wuDTZ3XKU4wt/vvUCBh3Zvva0k9h3i0THTk+HS71gpDw1oNXhjtjP7L?= =?iso-8859-1?Q?N3u9FiRZEoe5+vDqxEqb8FtZW0bOtdkpzbFj4ozakA9+5tJUx5ogWrpwSu?= =?iso-8859-1?Q?8U+6iJOD7Op13wxXJfKbcva3e0EwVT3d7bb76XXFFC1A/VRWh/Y+EeXar2?= =?iso-8859-1?Q?lVoqA+OYZzl5xY8999EV+/URtTXOdhToSKmcjCHCKCklYlaRJOb5oYm1c0?= =?iso-8859-1?Q?NPvl3FTMUCOXGj4JZhiJR/7W8fmba23M8IcNtjMnKOqr9tekGpNFO3UZPf?= =?iso-8859-1?Q?oi60rjkKM7M7aS8ptPk2qgor0dhJ3IqxdXgjWsYH4TZLL4zVvstPanUt2I?= =?iso-8859-1?Q?A6COYbm9hMXs1iRnhAti6t9z/QfUNLBwp5bBAN+a6l9zlEDqAMNn57YpQo?= =?iso-8859-1?Q?Fa03VmnpEmgsoYKzMwrhX1pmJGB3tZ2a2Ki5pB1xTXPxtmfma0kciQRmR2?= =?iso-8859-1?Q?CrTgG45Rdsk0MS16B5uoq+Zrmm9QzGOKYIyLRp5AT9YW3IcSnTYSRvmqld?= =?iso-8859-1?Q?DT9xfFGLtqprSMqqyBe6oobyWRqLiMRkRVBoTkqAHPoOzjsMcloJBfdqcM?= =?iso-8859-1?Q?AensQkElChe23W/l92X2mk/lbDwZ/0ai3mHLPUslkKUod95g3HPY0aeY7H?= =?iso-8859-1?Q?G34qxyNRpGOrruvBOFWCVfXnQ6V8xztiAuJb7k4iNIjOfmw0jgIivOZOcf?= =?iso-8859-1?Q?Wr7RCaccxXrcz73/yHIJ2P9aurIXIWT4uvGHL43z5ttcvVBwqqASY9ni5m?= =?iso-8859-1?Q?q+Q8zylSqrDOf58bQ7HMa2HqmG2krEuKRhNwgfit2dmW8xCDiRKoGOkJ/J?= =?iso-8859-1?Q?Pe58cn6P+w0glF67S4ePXOvVyj4oL9ReHurXIfOEHe1we/0crL/OY0O0n1?= =?iso-8859-1?Q?vNLBfMWM38gYJW3Od1r4uGEV19/4B4yyeOjtxMXHc/mvzGJBZl8gK8ikI+?= =?iso-8859-1?Q?zCSQpprWMH/0YmiEVbVgAkZvkB/veAeFJOc6TB4j5sth9rZIaFG3qOtQxv?= =?iso-8859-1?Q?fHr/YxJmJLq1A59pDG5+vtOnSd6kt5PovQyVYvy8+ZKO5AnrI1UK7VzlBa?= =?iso-8859-1?Q?nU36ju7BMJJW89Lik9g4aiNTuAgA1sV+him/NQcFC3xJlHSRaKF6LgY9Z1?= =?iso-8859-1?Q?2Kuji8g2TrVTCjK5TRKgV8NNJonf7BhPBNv3FsIzhzLsxnQhfH9fBhqs+X?= =?iso-8859-1?Q?+Zkm7kNuLxqI7dFiCWYLFcEAApBF8XUqquTrXF+y0J5in3TVv0QnV8CYco?= =?iso-8859-1?Q?yXBEBT0tXCSm/I2M2i1SIN+jWkRy44/TXW3v5eHEh/CAZYBu1CvZEGxXew?= =?iso-8859-1?Q?JxhraTIbdQezxCNmOsXiEOXZWJyFkJfB1uGWfAJtx/ouoh0/ckzdTqUfRE?= =?iso-8859-1?Q?a5BU+AaCZAWr2F9587YPk3dp7u72J3YfMX4iLZYza4AoIZNG9sDcjO9iB5?= =?iso-8859-1?Q?ME11GRPFablBT8EqtjHp+0sz+MNos88qB1?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5403.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aeccf25-140c-4858-0915-08db7bd3e1c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2023 14:43:35.8294 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lM+JBaFhHbU5TJjw3kxPPRfzsrDnBuRikuzxTU2/XMxklBmlDj2afk0Icwd8Ugdg X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7625 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,arunk@ami.com X-Gm-Message-State: wtnivqxnO0Qtd7kOZX96Tzdzx1787277AA= Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1688395422; bh=sUzk2kk02NB3DX3SKK2eWONcDSBNTaYci2R07Wn+KTQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=vKTXRqkxCuJN4FoH3d1ZMYab8xr/3t3XAtG13v3XbyMgN1yhtgTIVkesJ0o5vMqv8y5 X5PQ3NAr2FBx2OncuMPMvRciVxUtianNOQDPFAsCLOhHCYsxKbmbUHVI3zMrdJC1uOTDI 0CL+DmdZL+mlbs8Q+/sZUyQHVgk3o20PFAg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1688395423605100001 Content-Type: text/plain; charset="utf-8" Created IpmiTransport2 PPI/Protocol to support multiple IPMI BMC Interface support such as KCS/BT/SSIF/IPMB with 2 API's IpmiSubmitCommand2 & IpmiSubmitCommand2Ex. IpmiSubmitCommand2 - This API use the default interface (PcdDefaultSystemInterface) to send IPMI command. IpmiSubmitCommand2Ex - This API use the specific interface type to send IPMI command which is passed as an argument. Cc: Isaac Oram Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Arun K --- .../GenericIpmi/Common/IpmiBmc.h | 13 +- .../GenericIpmi/Common/IpmiBmcCommon.h | 82 +-- .../GenericIpmi/Common/IpmiHooks.c | 316 +++++++++++- .../GenericIpmi/Common/IpmiHooks.h | 119 ++++- .../GenericIpmi/Dxe/GenericIpmi.inf | 14 +- .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 471 ++++++++++++++---- .../GenericIpmi/Smm/SmmGenericIpmi.c | 329 +++++++++--- .../GenericIpmi/Smm/SmmGenericIpmi.inf | 12 + .../IpmiFeaturePkg/IpmiFeaturePkg.dec | 61 +++ .../IpmiFeaturePkg/Readme.md | 24 + 10 files changed, 1193 insertions(+), 248 deletions(-) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Generi= cIpmi/Common/IpmiBmc.h index d306a085e5..76ee988623 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmc.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmc.h @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -21,17 +22,17 @@ #include #include #include +#include #include "IpmiBmcCommon.h" #include "KcsBmc.h" - #define BMC_KCS_TIMEOUT 5 // [s] Single KSC request timeout // // IPMI Instance signature // -#define SM_IPMI_BMC_SIGNATURE SIGNATURE_32 ('i', 'p', 'm', 'i') +#define SM_IPMI_BMC_SIGNATURE SIGNATURE_32 ('i', 'p', 'm', 'i') #define IPMI_SEND_COMMAND_MAX_RETRY 3 // Number of retries #define INSTANCE_FROM_SM_IPMI_BMC_THIS(a) \ CR ( \ @@ -41,4 +42,12 @@ SM_IPMI_BMC_SIGNATURE \ ) +#define INSTANCE_FROM_IPMI_TRANSPORT2_THIS(a) \ + CR ( \ + a, \ + IPMI_BMC_INSTANCE_DATA, \ + IpmiTransport2, \ + SM_IPMI_BMC_SIGNATURE \ + ) + #endif // _IPMI_BMC_H_ diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiBmcCommon.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= GenericIpmi/Common/IpmiBmcCommon.h index 06eab62aae..faf6cc6685 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmcCommon.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmcCommon.h @@ -3,16 +3,17 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _IPMI_COMMON_BMC_H_ #define _IPMI_COMMON_BMC_H_ -#define MAX_TEMP_DATA 255 // 160 Modified to increase number of bytes = transfered per command -#define BMC_SLAVE_ADDRESS 0x20 -#define MAX_SOFT_COUNT 10 -#define COMP_CODE_NORMAL 0x00 +#define MAX_TEMP_DATA 255// 160 Modified to increase number of bytes = transfered per command +#define BMC_SLAVE_ADDRESS 0x20 +#define MAX_SOFT_COUNT 10 +#define COMP_CODE_NORMAL 0x00 // // IPMI command completion codes to check for in the UpdateErrorStatus rou= tine. @@ -33,8 +34,8 @@ // D4h C Insufficient privilege, in KCS channel this indicates KCS Policy = Control Mode is Deny All. // In authenticated channels this indicates invalid authentication/privile= ge. // -#define COMP_INSUFFICIENT_PRIVILEGE 0xD4 -#define COMP_CODE_UNSPECIFIED 0xFF +#define COMP_INSUFFICIENT_PRIVILEGE 0xD4 +#define COMP_CODE_UNSPECIFIED 0xFF #define COMPLETION_CODES \ { \ @@ -47,15 +48,16 @@ // Dxe Ipmi instance data // typedef struct { - UINTN Signature; - UINT64 KcsTimeoutPeriod; - UINT8 SlaveAddress; - BMC_STATUS BmcStatus; - UINT64 ErrorStatus; - UINT8 SoftErrorCount; - UINT16 IpmiIoBase; - IPMI_TRANSPORT IpmiTransport; - EFI_HANDLE IpmiSmmHandle; + UINTN Signature; + UINT64 KcsTimeoutPeriod; + UINT8 SlaveAddress; + BMC_STATUS BmcStatus; + UINT64 ErrorStatus; + UINT8 SoftErrorCount; + UINT16 IpmiIoBase; + IPMI_TRANSPORT IpmiTransport; + IPMI_TRANSPORT2 IpmiTransport2; + EFI_HANDLE IpmiSmmHandle; } IPMI_BMC_INSTANCE_DATA; // @@ -64,38 +66,39 @@ typedef struct { #define IPMI_COMMAND_HEADER_SIZE 2 typedef struct { - UINT8 Lun : 2; - UINT8 NetFunction : 6; - UINT8 Command; - UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE]; + UINT8 Lun : 2; + UINT8 NetFunction : 6; + UINT8 Command; + UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE]; } IPMI_COMMAND; // // Structure of IPMI Command response buffer // -#define IPMI_RESPONSE_HEADER_SIZE 3 +#define IPMI_RESPONSE_HEADER_SIZE 3 typedef struct { - UINT8 Lun : 2; - UINT8 NetFunction : 6; - UINT8 Command; - UINT8 CompletionCode; - UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE]; + UINT8 Lun : 2; + UINT8 NetFunction : 6; + UINT8 Command; + UINT8 CompletionCode; + UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE]; } IPMI_RESPONSE; EFI_STATUS EFIAPI IpmiSendCommandToBmc ( - IN IPMI_TRANSPORT *This, - IN UINT8 NetFunction, - IN UINT8 Lun, - IN UINT8 Command, - IN UINT8 *CommandData, - IN UINT8 CommandDataSize, - IN OUT UINT8 *ResponseData, - IN OUT UINT8 *ResponseDataSize, - IN VOID *Context + IN IPMI_TRANSPORT *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize, + IN VOID *Context ) + /*++ Routine Description: @@ -124,15 +127,15 @@ Returns: --*/ ; - EFI_STATUS EFIAPI IpmiBmcStatus ( - IN IPMI_TRANSPORT *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress, - IN VOID *Context + IN IPMI_TRANSPORT *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context ) + /*++ Routine Description: @@ -157,6 +160,7 @@ VOID GetDeviceSpecificTestResults ( IN IPMI_BMC_INSTANCE_DATA *IpmiInstance ) + /*++ Routine Description: diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiHooks.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Common/IpmiHooks.c index b2788e5a4c..9705e07660 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.c @@ -3,6 +3,7 @@ @copyright Copyright 2014 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,15 +12,16 @@ EFI_STATUS EFIAPI IpmiSendCommand ( - IN IPMI_TRANSPORT *This, - IN UINT8 NetFunction, - IN UINT8 Lun, - IN UINT8 Command, - IN UINT8 *CommandData, - IN UINT32 CommandDataSize, - IN OUT UINT8 *ResponseData, - IN OUT UINT32 *ResponseDataSize + IN IPMI_TRANSPORT *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize ) + /*++ Routine Description: @@ -48,29 +50,287 @@ Returns: --*/ { + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + // // This Will be unchanged ( BMC/KCS style ) // return IpmiSendCommandToBmc ( - This, - NetFunction, - Lun, - Command, - CommandData, - (UINT8) CommandDataSize, - ResponseData, - (UINT8*) ResponseDataSize, - NULL - ); + This, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); } // IpmiSendCommand() +EFI_STATUS +EFIAPI +IpmiSendCommand2 ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) + +/*++ + +Routine Description: + + This API use the default interface (PcdDefaultSystemInterface) to send I= PMI command + in the right mode to the appropiate device, ME or BMC. + +Arguments: + + This - Pointer to IPMI protocol instance + NetFunction - Net Function of command to send + Lun - LUN of command to send + Command - IPMI command to send + CommandData - Pointer to command data buffer, if needed + CommandDataSize - Size of command data buffer + ResponseData - Pointer to response data buffer + ResponseDataSize - Pointer to response data buffer size + +Returns: + + EFI_INVALID_PARAMETER - One of the input values is bad + EFI_DEVICE_ERROR - IPMI command failed + EFI_BUFFER_TOO_SMALL - Response buffer is too small + EFI_UNSUPPORTED - Command is not supported by BMC + EFI_SUCCESS - Command completed successfully + +--*/ +{ + IPMI_BMC_INSTANCE_DATA *IpmiInstance; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + IpmiInstance =3D INSTANCE_FROM_IPMI_TRANSPORT2_THIS (This); + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceKcs) = && + (IpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=3D Ipm= iInterfaceInitialized)) + { + return IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + #endif + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceBt) && + (IpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D Ipm= iInterfaceInitialized)) + { + return IpmiBtSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceSsif)= && + (IpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D I= pmiInterfaceInitialized)) + { + return IpmiSsifSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceIpmb)= && + (IpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D I= pmiInterfaceInitialized)) + { + return IpmiIpmbSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + return EFI_UNSUPPORTED; +} // IpmiSendCommand2() + +EFI_STATUS +EFIAPI +IpmiSendCommand2Ex ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ) +{ + /*++ + Routine Description: + + This API use the specific interface type to send IPMI command + in the right mode to the appropiate device, ME or BMC. + + Arguments: + + This - Pointer to IPMI protocol instance + NetFunction - Net Function of command to send + Lun - LUN of command to send + Command - IPMI command to send + CommandData - Pointer to command data buffer, if needed + CommandDataSize - Size of command data buffer + ResponseData - Pointer to response data buffer + ResponseDataSize - Pointer to response data buffer size + InterfaceType - BMC Interface type. + + Returns: + + EFI_INVALID_PARAMETER - One of the input values is bad + EFI_DEVICE_ERROR - IPMI command failed + EFI_BUFFER_TOO_SMALL - Response buffer is too small + EFI_UNSUPPORTED - Command is not supported by BMC + EFI_SUCCESS - Command completed successfully + + --*/ + + IPMI_BMC_INSTANCE_DATA *IpmiInstance; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + IpmiInstance =3D INSTANCE_FROM_IPMI_TRANSPORT2_THIS (This); + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + if ((InterfaceType =3D=3D SysInterfaceKcs) && + (IpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=3D Ipm= iInterfaceInitialized)) + { + return IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + #endif + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + if ((InterfaceType =3D=3D SysInterfaceBt) && + (IpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D Ipm= iInterfaceInitialized)) + { + return IpmiBtSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + if ((InterfaceType =3D=3D SysInterfaceSsif) && + (IpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D I= pmiInterfaceInitialized)) + { + return IpmiSsifSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + if ((InterfaceType =3D=3D SysInterfaceIpmb) && + (IpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D I= pmiInterfaceInitialized)) + { + return IpmiIpmbSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + return EFI_UNSUPPORTED; +} + EFI_STATUS EFIAPI IpmiGetBmcStatus ( - IN IPMI_TRANSPORT *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress + IN IPMI_TRANSPORT *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress ) + /*++ Routine Description: @@ -89,10 +349,14 @@ Returns: --*/ { + if ((This =3D=3D NULL) || (BmcStatus =3D=3D NULL) || (ComAddress =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + return IpmiBmcStatus ( - This, - BmcStatus, - ComAddress, - NULL - ); + This, + BmcStatus, + ComAddress, + NULL + ); } diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiHooks.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Common/IpmiHooks.h index 823cc08c61..a3985588c3 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.h @@ -3,13 +3,21 @@ @copyright Copyright 2014 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _IPMI_HOOKS_H #define _IPMI_HOOKS_H -#include "IpmiBmc.h" +#include +#include +#include +#include +#include +#include +#include +#include // // Internal(hook) function list @@ -17,15 +25,16 @@ EFI_STATUS EFIAPI IpmiSendCommand ( - IN IPMI_TRANSPORT *This, - IN UINT8 NetFunction, - IN UINT8 Lun, - IN UINT8 Command, - IN UINT8 *CommandData, - IN UINT32 CommandDataSize, - IN OUT UINT8 *ResponseData, - IN OUT UINT32 *ResponseDataSize + IN IPMI_TRANSPORT *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize ) + /*++ Routine Description: @@ -54,13 +63,99 @@ Returns: --*/ ; +EFI_STATUS +EFIAPI +IpmiSendCommand2 ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) + +/*++ + +Routine Description: + + This API use the default interface (PcdDefaultSystemInterface) to send I= PMI command + in the right mode to the appropiate device, ME or BMC. + +Arguments: + + This - Pointer to IPMI protocol instance + NetFunction - Net Function of command to send + Lun - LUN of command to send + Command - IPMI command to send + CommandData - Pointer to command data buffer, if needed + CommandDataSize - Size of command data buffer + ResponseData - Pointer to response data buffer + ResponseDataSize - Pointer to response data buffer size + +Returns: + + EFI_INVALID_PARAMETER - One of the input values is bad + EFI_DEVICE_ERROR - IPMI command failed + EFI_BUFFER_TOO_SMALL - Response buffer is too small + EFI_UNSUPPORTED - Command is not supported by BMC + EFI_SUCCESS - Command completed successfully + +--*/ +; + +EFI_STATUS +EFIAPI +IpmiSendCommand2Ex ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ) + +/*++ +Routine Description: + + This API use the specific interface type to send IPMI command + in the right mode to the appropiate device, ME or BMC. + +Arguments: + + This - Pointer to IPMI protocol instance + NetFunction - Net Function of command to send + Lun - LUN of command to send + Command - IPMI command to send + CommandData - Pointer to command data buffer, if needed + CommandDataSize - Size of command data buffer + ResponseData - Pointer to response data buffer + ResponseDataSize - Pointer to response data buffer size + InterfaceType - BMC Interface type. + +Returns: + + EFI_INVALID_PARAMETER - One of the input values is bad + EFI_DEVICE_ERROR - IPMI command failed + EFI_BUFFER_TOO_SMALL - Response buffer is too small + EFI_UNSUPPORTED - Command is not supported by BMC + EFI_SUCCESS - Command completed successfully + +--*/ +; + EFI_STATUS EFIAPI IpmiGetBmcStatus ( - IN IPMI_TRANSPORT *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress + IN IPMI_TRANSPORT *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress ) + /*++ Routine Description: diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Dxe/GenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gen= ericIpmi/Dxe/GenericIpmi.inf index 8d80aeb6b5..1564ceb08a 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Gen= ericIpmi.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Gen= ericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2010 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -49,16 +50,25 @@ IoLib ReportStatusCodeLib TimerLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib [Protocols] gIpmiTransportProtocolGuid # PROTOCOL ALWAYS_PRODUCED gEfiVideoPrintProtocolGuid - -[Guids] + gIpmiTransport2ProtocolGuid [Pcd] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort [Depex] gEfiRuntimeArchProtocolGuid AND diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericI= pmi/Dxe/IpmiInit.c index c333ca2e06..b49215fab0 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Ipm= iInit.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Ipm= iInit.c @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -13,25 +14,26 @@ #include "IpmiBmc.h" #include "IpmiPhysicalLayer.h" #include +#include #ifdef FAST_VIDEO_SUPPORT #include #endif #include - /*************************************************************************= ***** * Local variables */ -IPMI_BMC_INSTANCE_DATA *mIpmiInstance =3D NULL; -EFI_HANDLE mImageHandle; +IPMI_BMC_INSTANCE_DATA *mIpmiInstance =3D NULL; +EFI_HANDLE mImageHandle; // // Specific test interface // VOID GetDeviceSpecificTestResults ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance ) + /*++ Routine Description: @@ -54,10 +56,11 @@ Returns: EFI_STATUS GetSelfTest ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, - IN EFI_STATUS_CODE_VALUE StatusCodeValue[], - IN OUT UINT8 *ErrorCount + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, + IN EFI_STATUS_CODE_VALUE StatusCodeValue[], + IN OUT UINT8 *ErrorCount ) + /*++ Routine Description: @@ -86,13 +89,13 @@ Returns: BOOLEAN bResultFlag =3D FALSE; UINT8 TempData[MAX_TEMP_DATA]; - IPMI_SELF_TEST_RESULT_RESPONSE *SelfTestResult; + IPMI_SELF_TEST_RESULT_RESPONSE *SelfTestResult; // // Get the SELF TEST Results. // // - //Note: If BMC PcdIpmiBmcReadyDelayTimer < BMC_KCS_TIMEOUT, it need set = Retries as 1. Otherwise it will make SELT failure, caused by below conditio= n (EFI_ERROR(Status) || Retries =3D=3D 0) + // Note: If BMC PcdIpmiBmcReadyDelayTimer < BMC_KCS_TIMEOUT, it need set= Retries as 1. Otherwise it will make SELT failure, caused by below conditi= on (EFI_ERROR(Status) || Retries =3D=3D 0) // if (PcdGet8 (PcdIpmiBmcReadyDelayTimer) < BMC_KCS_TIMEOUT) { Retries =3D 1; @@ -102,20 +105,20 @@ Returns: DataSize =3D sizeof (TempData); - SelfTestResult =3D (IPMI_SELF_TEST_RESULT_RESPONSE *) &TempData[0]; + SelfTestResult =3D (IPMI_SELF_TEST_RESULT_RESPONSE *)&TempData[0= ]; SelfTestResult->Result =3D 0; do { Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, - 0, - IPMI_APP_GET_SELFTEST_RESULTS, - NULL, - 0, - TempData, - &DataSize - ); + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_SELFTEST_RESULTS, + NULL, + 0, + TempData, + &DataSize + ); if (Status =3D=3D EFI_SUCCESS) { switch (SelfTestResult->Result) { case IPMI_APP_SELFTEST_NO_ERROR: @@ -127,7 +130,7 @@ Returns: default: break; - } //switch + } // switch if (bResultFlag) { break; @@ -140,7 +143,7 @@ Returns: // // If Status indicates a Device error, then the BMC is not responding, s= o send an error. // - if (EFI_ERROR (Status) || Retries =3D=3D 0) { + if (EFI_ERROR (Status) || (Retries =3D=3D 0)) { DEBUG ((EFI_D_ERROR, "\n[IPMI] BMC self-test does not respond (status= : %r)!\n\n", Status)); if (*ErrorCount < MAX_SOFT_COUNT) { StatusCodeValue[*ErrorCount] =3D EFI_COMPUTING_UNIT_FIRMWARE_PROCESS= OR | EFI_CU_FP_EC_COMM_ERROR; @@ -155,12 +158,14 @@ Returns: // Copy the Self test results to Error Status. Data will be copied as= long as it // does not exceed the size of the ErrorStatus variable. // - for (Index =3D 0, TempPtr =3D (UINT8 *) &IpmiInstance->ErrorStatus; + for (Index =3D 0, TempPtr =3D (UINT8 *)&IpmiInstance->ErrorStatus; (Index < DataSize) && (Index < sizeof (IpmiInstance->ErrorStatus)= ); Index++, TempPtr++ - ) { + ) + { *TempPtr =3D TempData[Index]; } + // // Check the IPMI defined self test results. // Additional Cases are device specific test results. @@ -182,6 +187,7 @@ Returns: } else { IpmiInstance->BmcStatus =3D BMC_SOFTFAIL; } + // // Check if SDR repository is empty and report it if it is. // @@ -191,6 +197,7 @@ Returns: (*ErrorCount)++; } } + break; case IPMI_APP_SELFTEST_FATAL_HW_ERROR: @@ -221,13 +228,13 @@ Returns: return EFI_SUCCESS; } // GetSelfTest() - EFI_STATUS GetDeviceId ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, - IN EFI_STATUS_CODE_VALUE StatusCodeValue[ ], - IN OUT UINT8 *ErrorCount + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, + IN EFI_STATUS_CODE_VALUE StatusCodeValue[], + IN OUT UINT8 *ErrorCount ) + /*++ Routine Description: @@ -244,25 +251,25 @@ Returns: --*/ { - EFI_STATUS Status; - UINT32 DataSize; - SM_CTRL_INFO *pBmcInfo; - IPMI_MSG_GET_BMC_EXEC_RSP *pBmcExecContext; - UINT32 Retries; - UINT8 TempData[MAX_TEMP_DATA]; - -#ifdef FAST_VIDEO_SUPPORT - EFI_VIDEOPRINT_PROTOCOL *VideoPrintProtocol; - EFI_STATUS VideoPrintStatus; -#endif - -#ifdef FAST_VIDEO_SUPPORT + EFI_STATUS Status; + UINT32 DataSize; + SM_CTRL_INFO *pBmcInfo; + IPMI_MSG_GET_BMC_EXEC_RSP *pBmcExecContext; + UINT32 Retries; + UINT8 TempData[MAX_TEMP_DATA]; + + #ifdef FAST_VIDEO_SUPPORT + EFI_VIDEOPRINT_PROTOCOL *VideoPrintProtocol; + EFI_STATUS VideoPrintStatus; + #endif + + #ifdef FAST_VIDEO_SUPPORT VideoPrintStatus =3D gBS->LocateProtocol ( - &gEfiVideoPrintProtocolGuid, - NULL, - &VideoPrintProtocol - ); -#endif + &gEfiVideoPrintProtocolGuid, + NULL, + &VideoPrintProtocol + ); + #endif // // Set up a loop to retry for up to PcdIpmiBmcReadyDelayTimer seconds. C= alculate retries not timeout @@ -274,28 +281,38 @@ Returns: // Get the device ID information for the BMC. // DataSize =3D sizeof (TempData); - while (EFI_ERROR (Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, 0, - IPMI_APP_GET_DEVICE_ID, - NULL, 0, - TempData, &DataSize)) - ) { - DEBUG ((DEBUG_ERROR, "[IPMI] BMC does not respond by Get BMC DID (stat= us: %r), %d retries left, ResponseData: 0x%lx\n", - Status, Retries, TempData)); + while (EFI_ERROR ( + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ) + ) + ) + { + DEBUG ( + (DEBUG_ERROR, "[IPMI] BMC does not respond by Get BMC DID (stat= us: %r), %d retries left, ResponseData: 0x%lx\n", + Status, Retries, TempData) + ); if (Retries-- =3D=3D 0) { IpmiInstance->BmcStatus =3D BMC_HARDFAIL; return Status; } + // - //Handle the case that BMC FW still not enable KCS channel after AC cy= cle. just stall 1 second + // Handle the case that BMC FW still not enable KCS channel after AC c= ycle. just stall 1 second // MicroSecondDelay (1*1000*1000); } - pBmcInfo =3D (SM_CTRL_INFO*)&TempData[0]; - DEBUG ((EFI_D_ERROR, "[IPMI] BMC Device ID: 0x%02X, firmware version: %d= .%02X UpdateMode:%x\n", pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBm= cInfo->MinorFirmwareRev,pBmcInfo->UpdateMode)); + pBmcInfo =3D (SM_CTRL_INFO *)&TempData[0]; + DEBUG ((EFI_D_ERROR, "[IPMI] BMC Device ID: 0x%02X, firmware version: %d= .%02X UpdateMode:%x\n", pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBm= cInfo->MinorFirmwareRev, pBmcInfo->UpdateMode)); // // In OpenBMC, UpdateMode: the bit 7 of byte 4 in get device id command = is used for the BMC status: // 0 means BMC is ready, 1 means BMC is not ready. @@ -306,18 +323,22 @@ Returns: return EFI_SUCCESS; } else { DataSize =3D sizeof (TempData); - Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_FIRMWARE, 0, - IPMI_GET_BMC_EXECUTION_CONTEXT, - NULL, 0, - TempData, &DataSize - ); - - pBmcExecContext =3D (IPMI_MSG_GET_BMC_EXEC_RSP*)&TempData[0]; + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_FIRMWARE, + 0, + IPMI_GET_BMC_EXECUTION_CONTEXT, + NULL, + 0, + TempData, + &DataSize + ); + + pBmcExecContext =3D (IPMI_MSG_GET_BMC_EXEC_RSP *)&TempData[0]; DEBUG ((DEBUG_INFO, "[IPMI] Operational status of BMC: 0x%x\n", pBmcEx= ecContext->CurrentExecutionContext)); if ((pBmcExecContext->CurrentExecutionContext =3D=3D IPMI_BMC_IN_FORCE= D_UPDATE_MODE) && - !EFI_ERROR (Status)) { + !EFI_ERROR (Status)) + { DEBUG ((DEBUG_ERROR, "[IPMI] BMC in Forced Update mode, skip waiting= for BMC_READY.\n")); IpmiInstance->BmcStatus =3D BMC_UPDATE_IN_PROGRESS; } else { @@ -325,32 +346,175 @@ Returns: // Updatemode =3D 1 mean BMC is not ready, continue waiting. // while (Retries-- !=3D 0) { - MicroSecondDelay(1*1000*1000); //delay 1 seconds - DEBUG ((EFI_D_ERROR, "[IPMI] UpdateMode Retries: %d \n",Retries)); + MicroSecondDelay (1*1000*1000); // delay 1 seconds + DEBUG ((EFI_D_ERROR, "[IPMI] UpdateMode Retries: %d \n", Retries)); DataSize =3D sizeof (TempData); - Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, 0, - IPMI_APP_GET_DEVICE_ID, - NULL, 0, - TempData, &DataSize - ); + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ); if (!EFI_ERROR (Status)) { - pBmcInfo =3D (SM_CTRL_INFO*)&TempData[0]; - DEBUG ((DEBUG_ERROR, "[IPMI] UpdateMode Retries: %d pBmcInfo->= UpdateMode:%x, Status: %r, Response Data: 0x%lx\n",Retries, pBmcInfo->Updat= eMode, Status, TempData)); + pBmcInfo =3D (SM_CTRL_INFO *)&TempData[0]; + DEBUG ((DEBUG_ERROR, "[IPMI] UpdateMode Retries: %d pBmcInfo->= UpdateMode:%x, Status: %r, Response Data: 0x%lx\n", Retries, pBmcInfo->Upda= teMode, Status, TempData)); if (pBmcInfo->UpdateMode =3D=3D BMC_READY) { mIpmiInstance->BmcStatus =3D BMC_OK; return EFI_SUCCESS; } } } + mIpmiInstance->BmcStatus =3D BMC_HARDFAIL; } } + return Status; } // GetDeviceId() +/*++ + +Routine Description: + Initialize the API and parameters for IPMI Transport2 Instance + +Arguments: + IpmiInstance - Pointer to IPMI Instance. + +Returns: + VOID + +--*/ +VOID +InitIpmiTransport2 ( + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + ) +{ + IpmiInstance->IpmiTransport2.InterfaceType =3D FixedPcdGet8 (P= cdDefaultSystemInterface); + IpmiInstance->IpmiTransport2.IpmiTransport2BmcStatus =3D BmcStatusOk; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2 =3D IpmiSendCommand= 2; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2Ex =3D IpmiSendCommand= 2Ex; + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + InitBtInterfaceData (&IpmiInstance->IpmiTransport2); + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2); + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2); + #endif +} + +/*++ + +Routine Description: + Notify call back function. + +Arguments: + Event - Event which caused this handler. + Context - Context passed during Event Handler registration. + +Returns: + VOID + +--*/ +VOID +EFIAPI +DxeNotifyCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + IPMI_INTERFACE_STATE InterfaceState; + EFI_HANDLE Handle; + + InterfaceState =3D IpmiInterfaceNotReady; + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + InitSsifInterfaceData (&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D I= pmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + InitIpmbInterfaceData (&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D I= pmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + #endif + // Default Interface data should be initialized to install Ipmi Transpor= t2 Protocol. + if (InterfaceState !=3D IpmiInterfaceInitialized) { + return; + } + + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + ASSERT_EFI_ERROR (Status); +} + +/*++ + +Routine Description: + Registers protocol notify call back. + +Arguments: + ProtocolGuid - Pointer to Protocol Guid to register call back. + +Returns: + Status + +--*/ +EFI_STATUS +DxeRegisterProtocolCallback ( + IN EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + EFI_EVENT NotifyEvent; + VOID *Registration; + + if ((ProtocolGuid =3D=3D NULL) || + ((ProtocolGuid !=3D NULL) && IsZeroBuffer (ProtocolGuid, sizeof (EFI= _GUID)))) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + DxeNotifyCallback, + NULL, + &NotifyEvent + ); + + if (!EFI_ERROR (Status)) { + Status =3D gBS->RegisterProtocolNotify ( + ProtocolGuid, + NotifyEvent, + &Registration + ); + } + + return Status; +} /** This function initializes KCS interface to BMC. @@ -368,17 +532,21 @@ Returns: **/ EFI_STATUS InitializeIpmiKcsPhysicalLayer ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - UINT8 ErrorCount; - EFI_HANDLE Handle; - UINT8 Index; + EFI_STATUS Status; + UINT8 ErrorCount; + EFI_HANDLE Handle; + UINT8 Index; + IPMI_INTERFACE_STATE InterfaceState =3D IpmiInterfaceNotReady; + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; + #endif - ErrorCount =3D 0; + ErrorCount =3D 0; mImageHandle =3D ImageHandle; mIpmiInstance =3D AllocateZeroPool (sizeof (*mIpmiInstance)); @@ -396,39 +564,42 @@ InitializeIpmiKcsPhysicalLayer ( // Initialize the KCS transaction timeout. // mIpmiInstance->KcsTimeoutPeriod =3D (BMC_KCS_TIMEOUT * 1000*1000) / KC= S_DELAY_UNIT; - DEBUG ((EFI_D_ERROR, "[IPMI] mIpmiInstance->KcsTimeoutPeriod: 0x%lx\n"= ,mIpmiInstance->KcsTimeoutPeriod)); + DEBUG ((EFI_D_ERROR, "[IPMI] mIpmiInstance->KcsTimeoutPeriod: 0x%lx\n"= , mIpmiInstance->KcsTimeoutPeriod)); // // Initialize IPMI IO Base. // - mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiI= oBaseAddress); - mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNAT= URE; - mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; - mIpmiInstance->BmcStatus =3D BMC_NOTREADY; - mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; - mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; + mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiIoBaseAddress); + mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNATURE; + mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; + mIpmiInstance->BmcStatus =3D BMC_NOTREADY; + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; + mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; // // Get the Device ID and check if the system is in Force Update mode. // Status =3D GetDeviceId ( - mIpmiInstance, - StatusCodeValue, - &ErrorCount - ); + mIpmiInstance, + StatusCodeValue, + &ErrorCount + ); // // Do not continue initialization if the BMC is in Force Update Mode. // if ((mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS) && - (mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL)) { + (mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL)) + { // // Get the SELF TEST Results. // Status =3D GetSelfTest ( - mIpmiInstance, - StatusCodeValue, - &ErrorCount - ); + mIpmiInstance, + StatusCodeValue, + &ErrorCount + ); } // @@ -436,9 +607,9 @@ InitializeIpmiKcsPhysicalLayer ( // for (Index =3D 0; Index < ErrorCount; Index++) { ReportStatusCode ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - StatusCodeValue[Index] - ); + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + StatusCodeValue[Index] + ); } // @@ -447,15 +618,95 @@ InitializeIpmiKcsPhysicalLayer ( if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInstance->Bm= cStatus !=3D BMC_UPDATE_IN_PROGRESS)) { Handle =3D NULL; Status =3D gBS->InstallProtocolInterface ( - &Handle, - &gIpmiTransportProtocolGuid, - EFI_NATIVE_INTERFACE, - &mIpmiInstance->IpmiTransport - ); + &Handle, + &gIpmiTransportProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport + ); ASSERT_EFI_ERROR (Status); } + #endif + + // Initialise the IPMI transport2 + InitIpmiTransport2 (mIpmiInstance); + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + switch (Index) { + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInstan= ce->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D = IpmiInterfaceInitialized; + Status =3D = CheckSelfTestByInterfaceType ( + = &mIpmiInstance->IpmiTransport2, + = &BmcStatus, + = SysInterfaceKcs + = ); + if (!EFI_ERROR (Status) && (BmcStatus !=3D BmcStatusHardFail))= { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = =3D IpmiInterfaceInitError; + } + } + + break; + #endif + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + break; + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + case SysInterfaceSsif: + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.Interfac= eState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D DxeRegisterProtocolCallback ( + &mIpmiInstance->IpmiTran= sport2.Interface.Ssif.SsifInterfaceApiGuid + ); + } + + break; + #endif + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + case SysInterfaceIpmb: + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.Interfac= eState =3D=3D IpmiInterfaceInitError) { + // Register Protocol notify for I2C Protocol. + Status =3D DxeRegisterProtocolCallback ( + &mIpmiInstance->IpmiTran= sport2.Interface.Ipmb.IpmbInterfaceApiGuid + ); + } + + break; + #endif + default: + break; + } + } + + // Any one of the Interface data should be initialized to install IPMI= Transport2 Protocol. + if (InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_SUCCESS; + } + + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; } } // InitializeIpmiKcsPhysicalLayer() - diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Smm/SmmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Ge= nericIpmi/Smm/SmmGenericIpmi.c index 1af2d18f79..39cb8808db 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.c @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -24,17 +25,18 @@ #include "IpmiBmcCommon.h" #include "IpmiBmc.h" #include +#include -IPMI_BMC_INSTANCE_DATA *mIpmiInstance; -EFI_HANDLE mImageHandle; - +IPMI_BMC_INSTANCE_DATA *mIpmiInstance; +EFI_HANDLE mImageHandle; EFI_STATUS GetDeviceId ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, - IN EFI_STATUS_CODE_VALUE StatusCodeValue[ ], - IN OUT UINT8 *ErrorCount + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, + IN EFI_STATUS_CODE_VALUE StatusCodeValue[], + IN OUT UINT8 *ErrorCount ) + /*++ Routine Description: @@ -51,12 +53,12 @@ Returns: --*/ { - EFI_STATUS Status; - UINT32 DataSize; - SM_CTRL_INFO *ControllerInfo; - UINT8 TimeOut; - UINT8 Retries; - UINT8 TempData[MAX_TEMP_DATA]; + EFI_STATUS Status; + UINT32 DataSize; + SM_CTRL_INFO *ControllerInfo; + UINT8 TimeOut; + UINT8 Retries; + UINT8 TempData[MAX_TEMP_DATA]; TimeOut =3D 0; Retries =3D PcdGet8 (PcdIpmiBmcReadyDelayTimer); @@ -66,16 +68,16 @@ Returns: // Get the device ID information for the BMC. // DataSize =3D MAX_TEMP_DATA; - Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, - 0, - IPMI_APP_GET_DEVICE_ID, - NULL, - 0, - TempData, - &DataSize - ); + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ); if (Status =3D=3D EFI_SUCCESS) { DEBUG ((EFI_D_INFO, "IPMI: SendCommand success!\n")); break; @@ -84,10 +86,10 @@ Returns: // Display message and retry. // DEBUG ( - (EFI_D_ERROR | EFI_D_INFO, - "IPMI: Waiting for BMC (KCS 0x%x)...\n", - IpmiInstance->IpmiIoBase) - ); + (EFI_D_ERROR | EFI_D_INFO, + "IPMI: Waiting for BMC (KCS 0x%x)...\n", + IpmiInstance->IpmiIoBase) + ); MicroSecondDelay (500 * 1000); TimeOut++; } @@ -97,7 +99,7 @@ Returns: // If there is no error then proceed to check the data returned by the B= MC // if (!EFI_ERROR (Status)) { - ControllerInfo =3D (SM_CTRL_INFO *) TempData; + ControllerInfo =3D (SM_CTRL_INFO *)TempData; // // If the controller is in Update Mode and the maximum number of error= s has not been exceeded, then // save the error code to the StatusCode array and increment the count= er. Set the BMC Status to indicate @@ -115,11 +117,144 @@ Returns: return Status; } +/*++ + +Routine Description: + Initialize the API and parameters for IPMI Transport2 Instance + +Arguments: + IpmiInstance - Pointer to IPMI Instance. + +Returns: + VOID - Nothing. + +--*/ +VOID +InitIpmiTransport2 ( + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + ) +{ + IpmiInstance->IpmiTransport2.InterfaceType =3D FixedPcdGet8 (P= cdDefaultSystemInterface); + IpmiInstance->IpmiTransport2.IpmiTransport2BmcStatus =3D BmcStatusOk; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2 =3D IpmiSendCommand= 2; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2Ex =3D IpmiSendCommand= 2Ex; + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + InitBtInterfaceData (&IpmiInstance->IpmiTransport2); + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2); + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2); + #endif +} + +/*++ + +Routine Description: + Notify call back to initialize the interfaces and install SMM IPMI + protocol. + +Arguments: + Protocol - Pointer to the protocol guid. + Interface - Pointer to the protocol instance. + Handle - Handle on which the protocol is installed. + +Returns: + Status of Notify call back. + +--*/ +EFI_STATUS +EFIAPI +SmmNotifyCallback ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + IPMI_INTERFACE_STATE InterfaceState; + + InterfaceState =3D IpmiInterfaceNotReady; + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + InitSsifInterfaceData (&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D I= pmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + InitIpmbInterfaceData (&mIpmiInstance->IpmiTransport2); + #endif + + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D I= pmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + if (InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_SUCCESS; + } + + // Default Interface data should be initialized to install Ipmi Transpor= t2 Protocol. + if (InterfaceState =3D=3D IpmiInterfaceInitialized) { + Handle =3D NULL; + Status =3D gSmst->SmmInstallProtocolInterface ( + &Handle, + &gSmmIpmiTransport2Protoc= olGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTrans= port2 + ); + } + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Registers Protocol call back. + +Arguments: + ProtocolGuid - Pointer to Protocol GUID to register call back. + +Returns: + Status. + +--*/ +EFI_STATUS +SmmRegisterProtocolCallback ( + IN EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + VOID *Registration; + + if ((ProtocolGuid =3D=3D NULL) || + ((ProtocolGuid !=3D NULL) && IsZeroBuffer (ProtocolGuid, sizeof (EFI= _GUID)))) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D gSmst->SmmRegisterProtocolNotify ( + ProtocolGuid, + SmmNotifyCallback, + &Registration + ); + return Status; +} + EFI_STATUS SmmInitializeIpmiKcsPhysicalLayer ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) + /*++ Routine Description: @@ -138,14 +273,17 @@ Returns: --*/ { - EFI_STATUS Status; - UINT8 ErrorCount; - EFI_HANDLE Handle; - EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; + EFI_STATUS Status; + UINT8 ErrorCount; + EFI_HANDLE Handle; + EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; + IPMI_INTERFACE_STATE InterfaceState; + UINT8 Index; - DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n")); - ErrorCount =3D 0; - mImageHandle =3D ImageHandle; + DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer entry \n")); + ErrorCount =3D 0; + mImageHandle =3D ImageHandle; + InterfaceState =3D IpmiInterfaceNotReady; mIpmiInstance =3D AllocateZeroPool (sizeof (IPMI_BMC_INSTANCE_DATA)); ASSERT (mIpmiInstance !=3D NULL); @@ -154,7 +292,6 @@ Returns: ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES); return EFI_OUT_OF_RESOURCES; } else { - // // Initialize the KCS transaction timeout. Assume delay unit is 1000 u= s. // @@ -163,14 +300,15 @@ Returns: // // Initialize IPMI IO Base, we still use SMS IO base to get device ID = and Seltest result since SMM IF may have different cmds supported // - mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiS= mmIoBaseAddress); - mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNAT= URE; - mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; - mIpmiInstance->BmcStatus =3D BMC_NOTREADY; - mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; - mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; - - DEBUG ((DEBUG_INFO,"IPMI: Waiting for Getting BMC DID in SMM \n")); + mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiSm= mIoBaseAddress); + mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNATU= RE; + mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; + mIpmiInstance->BmcStatus =3D BMC_NOTREADY; + mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; + mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + DEBUG ((DEBUG_INFO, "IPMI: Waiting for Getting BMC DID in SMM \n")); // // Get the Device ID and check if the system is in Force Update mode. // @@ -178,21 +316,98 @@ Returns: // If we want to improve performance, we're going to comment it. // Status =3D GetDeviceId ( - mIpmiInstance, - StatusCodeValue, - &ErrorCount - ); + mIpmiInstance, + StatusCodeValue, + &ErrorCount + ); ASSERT_EFI_ERROR (Status); Handle =3D NULL; Status =3D gSmst->SmmInstallProtocolInterface ( - &Handle, - &gSmmIpmiTransportProtocolGuid, - EFI_NATIVE_INTERFACE, - &mIpmiInstance->IpmiTransport - ); + &Handle, + &gSmmIpmiTransportProtoco= lGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTrans= port + ); ASSERT_EFI_ERROR (Status); + #endif + + InitIpmiTransport2 (mIpmiInstance); + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + switch (Index) { + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInstan= ce->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D = IpmiInterfaceInitialized; + Status =3D = CheckSelfTestByInterfaceType ( + = &mIpmiInstance->IpmiTransport2, + = &BmcStatus, + = SysInterfaceKcs + = ); + if (!EFI_ERROR (Status) && (BmcStatus !=3D BmcStatusHardFail))= { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = =3D IpmiInterfaceInitError; + } + } + + break; + #endif + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + break; + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + case SysInterfaceSsif: + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.Interfac= eState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTr= ansport2.Interface.Ssif.SsifInterfaceApiGuid); + } + + break; + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + case SysInterfaceIpmb: + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.Interfac= eState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTr= ansport2.Interface.Ipmb.IpmbInterfaceApiGuid); + } + + break; + #endif + default: + break; + } + } + + // Default Interface data should be initialized to install Ipmi Transp= ort2 Protocol. + if (InterfaceState =3D=3D IpmiInterfaceInitialized) { + Handle =3D NULL; + Status =3D gSmst->SmmInstallProtocolInterface ( + &Handle, + &gSmmIpmiTransport2Prot= ocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTra= nsport2 + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IPMI Transport2 protocol install Status =3D = %r \n", Status)); + } + } - DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n")); + DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer exit \n")); return EFI_SUCCESS; } @@ -200,8 +415,8 @@ Returns: EFI_STATUS InitializeSmmGenericIpmi ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { SmmInitializeIpmiKcsPhysicalLayer (ImageHandle, SystemTable); diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Smm/SmmGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= GenericIpmi/Smm/SmmGenericIpmi.inf index f430195d1e..12dc17ae84 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2010 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -39,15 +40,26 @@ IoLib ReportStatusCodeLib TimerLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib [Protocols] gSmmIpmiTransportProtocolGuid # PROTOCOL ALWAYS_PROD= UCED + gSmmIpmiTransport2ProtocolGuid # PROTOCOL ALWAYS_PROD= UCED [Guids] [Pcd] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport [Depex] gIpmiTransportProtocolGuid diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeatureP= kg.dec b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.d= ec index 8c1b902446..3bbb918fa3 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec @@ -9,6 +9,7 @@ # # Copyright (c) 2019-2021, Intel Corporation. All rights reserved.
# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -43,16 +44,36 @@ # IpmiBaseLib|Include/Library/IpmiBaseLib.h + ## @libraryclass Provides generic functions among all interfaces. + # + BmcCommonInterfaceLib|Include/Library/BmcCommonInterfaceLib.h + + ## @libraryclass Provides generic functions among BT interface. + # + BtInterfaceLib|Include/Library/BtInterfaceLib.h + + ## @libraryclass Provides generic functions among SSIF interface. + # + SsifInterfaceLib|Include/Library/SsifInterfaceLib.h + + ## @libraryclass Provides generic functions among IPMB interface. + # + IpmbInterfaceLib|Include/Library/IpmbInterfaceLib.h + [Guids] gIpmiFeaturePkgTokenSpaceGuid =3D {0xc05283f6, 0xd6a8, 0x48f3, {0x9b, = 0x59, 0xfb, 0xca, 0x71, 0x32, 0x0f, 0x12}} + gPeiIpmiHobGuid =3D {0xcb4d3e13, 0x1e34, 0x4373, {0x8a, 0= x81, 0xe9, 0x0, 0x10, 0xf1, 0xdb, 0xa4}} [Ppis] gPeiIpmiTransportPpiGuid =3D {0x7bf5fecc, 0xc5b5, 0x4b25, {0x81, 0x1b, 0= xb4, 0xb5, 0xb, 0x28, 0x79, 0xf7}} + gPeiIpmiTransport2PpiGuid =3D {0x8122CEBD, 0xF4FD, 0x4EA8, { 0x97, 0x6C,= 0xF0, 0x30, 0xAD, 0xDC, 0x4C, 0xB4 }} [Protocols] gIpmiTransportProtocolGuid =3D {0x6bb945e8, 0x3743, 0x433e, {0xb9, 0x0e= , 0x29, 0xb3, 0x0d, 0x5d, 0xc6, 0x30}} gSmmIpmiTransportProtocolGuid =3D {0x8bb070f1, 0xa8f3, 0x471d, {0x86, 0= x16, 0x77, 0x4b, 0xa3, 0xf4, 0x30, 0xa0}} gEfiVideoPrintProtocolGuid =3D {0x3dbf3e06, 0x9d0c, 0x40d3, {0xb2, 0= x17, 0x45, 0x5f, 0x33, 0x9e, 0x29, 0x09}} + gIpmiTransport2ProtocolGuid =3D { 0x4A1D0E66, 0x5271, 0x4E22, { 0x83, 0x= FE, 0x90, 0x92, 0x1B, 0x74, 0x82, 0x13 }} + gSmmIpmiTransport2ProtocolGuid =3D { 0x1DBD1503, 0x0A60, 0x4230, { 0xAA,= 0xA3, 0x80, 0x16, 0xD8, 0xC3, 0xDE, 0x2F }} [PcdsFeatureFlag] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE|BOOLEAN|0xA0000= 001 @@ -61,6 +82,46 @@ gIpmiFeaturePkgTokenSpaceGuid.PcdMaxSOLChannels|3|UINT8|0xF0000001 #When True, BIOS will send a Pre-Boot signal to BMC gIpmiFeaturePkgTokenSpaceGuid.PcdSignalPreBootToBmc|FALSE|BOOLEAN|0xF000= 0002 + #typedef enum { + # SysInterfaceUnknown, // Unknown interface type. + # SysInterfaceKcs, // Kcs interface =3D 1. + # SysInterfaceSmic, // Smic interface =3D 2. + # SysInterfaceBt, // Bt interface =3D 3. + # SysInterfaceSsif, // Ssif interface =3D 4. + # SysInterfaceMax // Maximum interface type. + #} SYSTEM_INTERFACE_TYPE; + #While selecting Default Interface type, the respective Interface Suppor= t should need to be Enabled, else the IPMI will be unsupported. + #Example, for SysInterfaceKcs, PcdKcsInterfaceSupport Should be enable. + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface|1|UINT8|0xF00000= 03 + + #BT Base address, retry counter and delay parameters + gIpmiFeaturePkgTokenSpaceGuid.PcdBtCommandRetryCounter|0x0004E400|UINT32= |0xF0000004 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort|0xE4|UINT16|0xF0000005 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferPort|0xE5|UINT16|0xF0000006 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtDelayPerRetry|15|UINT32|0xF0000007 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterruptMaskPort|0xE6|UINT16|0xF0000= 008 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferSize|0x40|UINT8|0xF0000009 + + #SSIF slave address, retry counter and delay parameters + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifSlaveAddress|0x10|UINT16|0xF000000A + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay|0xCB20|UINT32|0= xF000000B + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifCommandtRetryCounter|0x5|UINT16|0xF= 000000C + + #Interface access type for BMC communication. 0-MMIO, 1-IO + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiDefaultAccessType|1|UINT8|0xF000000D + gIpmiFeaturePkgTokenSpaceGuid.PcdMmioBaseAddress|0x0|UINT32|0xF000000E + gIpmiFeaturePkgTokenSpaceGuid.PcdBaseAddressRange|0x0|UINT32|0xF000000F + + gIpmiFeaturePkgTokenSpaceGuid.PcdBmcSlaveAddress|0x20|UINT32|0xF0000010 + + #Interface access support for KCS + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport|1|UINT8|0xF0000011 + #Interface access support for BT + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport|1|UINT8|0xF0000012 + #Interface access support for SSIF + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport|1|UINT8|0xF0000013 + #Interface access support for IPMB + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport|1|UINT8|0xF0000014 [PcdsDynamic, PcdsDynamicEx] gIpmiFeaturePkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0xD0000001 diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md b/= Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md index 7551fcc64f..7380022a2a 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md @@ -35,6 +35,18 @@ to better understand the module source code. Each library in the feature should have a section that describes the libra= ry in a level of detail that is useful to better understand the library source code. +#BmcInterfaceCommonAccess +This Library provides the common API's functions among the different Inter= faces such as BT, SSIF,and IPMB interface. + +#BtInterfaceLib +This Library provides the API's function for the BT interface. + +#IpmbInterfaceLib +This Library provides the API's function for the IPMB/I2C interface. + +#SsifInterfaceLib +This Function provides the API's function for the SSIF interface. + ## Key Functions *_TODO_* A bulleted list of key functions for interacting with the feature. @@ -42,6 +54,14 @@ A bulleted list of key functions for interacting with th= e feature. Not all features need to be listed. Only functions exposed through externa= l interfaces that are important for feature users to be aware of. +* Some BMC may have various interface support, in this case IpmiTransport2= Protocol will check the available interfaces Supports +and initialize the Interface API for IPMI communication. it will check for= multiple interfaces such as KCS,BT,SSIF and IPMB/I2C interface. +* PcdDefaultSystemInterface, helps to select the default Interface type to= communicate with BMC. +IpmiSubmitCommand2 API will send the IPMI command via by selected PcdDefau= ltSystemInterface Type. +* We can able to send the IPMI command via the specific Interface type thr= ough IpmiSubmitCommand2Ex. +* In case if the platform BMC doesn't have any interface support, we can d= isable the +respective Interface support(PcdKcsInterfaceSupport,PcdBtInterfaceSupport,= PcdSsifInterfaceSupport and PcdIpmbInterfaceSupport) + ## Configuration *_TODO_* Information that is useful for configuring the feature. @@ -49,6 +69,10 @@ Information that is useful for configuring the feature. Not all configuration options need to be listed. This section is used to p= rovide more background on configuration options than possible elsewhere. +* While selecting Default Interface type on PcdDefaultSystemInterface, the= respective Interface Support should need to be Enabled, +else the IpmiTransport2Protocol will be unsupported. Example, for SysInter= faceKcs on PcdDefaultSystemInterface, PcdKcsInterfaceSupport Should be enab= le. + + ## Data Flows *_TODO_* Architecturally defined data structures and flows for the feature. -- 2.38.1.windows.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#106608): https://edk2.groups.io/g/devel/message/106608 Mute This Topic: https://groups.io/mt/99927876/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-