From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.2453.1686616044492064880 for ; Mon, 12 Jun 2023 17:27:24 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Q8o+oqaD; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686616044; x=1718152044; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=CgCj5WzlzzKBauQzXljKxSIijXqi8QOnwMKh8jMuRTc=; b=Q8o+oqaDJ3ZAazOixcjKG8mFiflPr3LDF4zHkX1vOwmjJHOYB8IlpqHJ QdmuvvPRD3NBzK3YCS8h8Zk5sJWCC40RTshxA/XPfl6xkpHmkKPVWDdl/ LKzjWTHJPFjdhywLvFj2+9tYjU/TgRzT7SnmXy/gwT43hYLkXZJjx57CR ywx4pOvllrXVh3CWGxJbEDkDLXhsai1oZkNAK3SXkGJA3zsmvVBOdytFz lGiX1JBhnTALlWU+oIFJBhFLkuVKzH8PJqJnwWy3mVYTeUcaqkfHnU7gC DNMOMHeztF+8qQ6eRv/4iW7YMPOYJHraxnTxY4aW946kz6+CdIEZyl4If w==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="347846061" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="347846061" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 17:27:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="711411966" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="711411966" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga002.jf.intel.com with ESMTP; 12 Jun 2023 17:27:23 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 12 Jun 2023 17:27:23 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Mon, 12 Jun 2023 17:27:23 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.175) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Mon, 12 Jun 2023 17:27:22 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MTQ5n8GPgTzIJkyXhuHY5SkzkUzY+I2R/NRtpS62Oq4H04XI6V9HV97+hMsdxLprAtPshPspOJnu0qZ5HuGJDC589C1k8GCNyoPbaUH5s9CVlsk6ufc0EwJqvVGDFJy+mrzvGb7sD1ujVmQER0iiL5Hz7ijsPy0MKH4waPVxnxQXXyqtO09WIFejSTQVXSanE/2ERZ5Soau84fsdCjm4eWsYTmpf2E/Eb6ijQdUDwAg4IJrbo3wiOXbc6/mw51DORBp+XTMTL3D1Vb4uxyqTSSH3dfH1ttldwHkZaFAyMBBZoFpD0zLTnhgGieWXINX1lBBB7FuzPKNT7gngQJKqFA== 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=uREizQ7sQ9W5yLMlOQIduAh2Y/1iESuF0jd+KtujcV8=; b=YdmynVNfIaypTkD2ETFxD9nFKBIVznmbMcGny8rxrUVZ+W1WdubaB/W4h6sjgGMyTwnoo+HPbHKcKd+ewnE3qAYWdYb3cwystwkVz5OR5JP9u8TA6hZhjoVwyTkt+5C2ROP5V6y1p3AbzLW7raOyTqZwyjha1YUsYQ/Uow2eaCzOzzz3tihBHngsD3+uFJXtUVBs/iCSgYO1EReO28fHle6kPCkplCg4z7nsDRgqig+dQ+Arwx2AlUwr1JpHojnkL8zUdJfeyXKrv61DF31HuQ2CsNMpk1D9osZ92G+l1QhzscJh7OqhqULo+dR+sttAjlMcWzkEsGBiP/0bDSFyUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by SA0PR11MB4768.namprd11.prod.outlook.com (2603:10b6:806:71::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Tue, 13 Jun 2023 00:27:18 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::6979:a90f:e224:41c5]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::6979:a90f:e224:41c5%4]) with mapi id 15.20.6455.043; Tue, 13 Jun 2023 00:27:18 +0000 From: "Isaac Oram" To: Arun K , "devel@edk2.groups.io" CC: "Desimone, Nathaniel L" , "Ramkumar Krishnamoorthi" , "Gao, Liming" Subject: Re: [edk2-devel][edk2-platforms][PATCH V3-1] IpmiFeaturePkg:Provided multiple IPMI interface support in DXE and SMM Thread-Topic: [edk2-devel][edk2-platforms][PATCH V3-1] IpmiFeaturePkg:Provided multiple IPMI interface support in DXE and SMM Thread-Index: AQHZnSyvCWQvvaPlU027p17cENlsz6+HbL3g Date: Tue, 13 Jun 2023 00:27:17 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR11MB5801:EE_|SA0PR11MB4768:EE_ x-ms-office365-filtering-correlation-id: 6e0f5488-ed13-4a93-1114-08db6ba4f1e1 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: f0vpMasyNKj5xXv1ySpVNG5rgqVkdxJmoTy4kWKU17CoZigeD3YzSdG1CucZeceibbosPt+O/RbcQyuShAX1SZ0eQV4joN+ZIfZvpf56tQtHwWXDimRm5yOwc0EZ9rQsVXYuqbUEUASOOISQeMNiNB5zi2pKTHpCufInk9EPh/ozmbksNbVVWKgwMTMJeH7fi2fFrbDORiCgT+5KANsDllTZrjnw7OlyEvHyTgF06UchieB6SolnSnkUpugrCNUsazZFgb9PvD6TDebN6Fr2icLPKEBmcMRhgJsQG/LI/FuHwWfgZj3BM9l+nnTjwyDSNcLUw+J8+D0BbxhGHE8Vn+rNPHKbgXmdjjUJBKMwbuOnZJRVF1bjSzz6IhJh5kakS/+INgfnc8cKP5MeL9rBQx1AJpZhibe6OWvNhF9QzADzodV6zvWOiYLnFKb7b/9jAJujX5PuV3Df7+fWRUrbQhCnACYjCODn/FFWPTEIlG2O56WHEju+d4xGwaMs64vzk9gCUkTLhHejdJu7U023eC7VinVVN1qzB2q9D7UJQUnABPxeSPswEeB2uQ2zpZkayuvZB4o47FKnI/U0AzJMd1bByKjj25gg9ZFuqqFZszSuiIOl+iUMF0G36LrpR+Up x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(376002)(39860400002)(366004)(346002)(396003)(451199021)(7696005)(82960400001)(9686003)(83380400001)(38100700002)(40140700001)(86362001)(38070700005)(122000001)(33656002)(6506007)(53546011)(26005)(55016003)(186003)(30864003)(2906002)(54906003)(110136005)(19627235002)(66446008)(316002)(66556008)(4326008)(64756008)(66476007)(76116006)(41300700001)(52536014)(5660300002)(66946007)(71200400001)(8936002)(8676002)(478600001)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?uTmAHPKwS7smsRFyfxKNKBc/+aGQeHeMuM7tVN2Fqwbw3Zim/HUMLYCR68yt?= =?us-ascii?Q?t2yRmYUW8rKIgRr81nFFto25CmXRaZJv6ndJIHK0XzJiBVTOWyCI/XetqAnm?= =?us-ascii?Q?u9n5FZ2rVE42dHk+FGeccgP8fkFlhDy6ScbKGTabZqXbNj6iVrw4fc2NqJI4?= =?us-ascii?Q?FmCXQx1kQetsSa4vgB1oUbOm09qLdyI6wA51d642BBGb+ddXdRG1c2Fi2X6e?= =?us-ascii?Q?2Xf/9jex8lN/cYejIiPqZXHEDEWo7TyE/sqpTvYvRe7NwKlspgxnW9H699kj?= =?us-ascii?Q?pFByNSTBFy2UaJB4v39OUG7visrzjrVaD9I1gtIhjWYAvPWyYWgWCx/oYmtH?= =?us-ascii?Q?hur5VqfK0AJtpc5wCcy/+iJI2JkfTYaKcwg6FCFLsPyJpssyDe+XwDhSstwf?= =?us-ascii?Q?slrbCrxdTFtHVlM20M1yF73px6o8KhY6BqjLDNWnhhMuOsDmn0Ve89GzG1GX?= =?us-ascii?Q?gjuw6X4ckRbLMdBi6Q4KQTPToCX4N2JjYhbJ7xYC4ke12Zg/31ftu82LjRly?= =?us-ascii?Q?os7zc9WG5SaBxEgo7rC9fp/9lnFG/tRkuWusbCDDPp+XAyYI7o6d5zC9S4mz?= =?us-ascii?Q?EbvC3aZFve8tbDah/T58x9ADkd8NZ/Bs0VRTVG4z33QpnI9dAVHadET5ZTa4?= =?us-ascii?Q?i9UYHrGexlH087ELKOWPvFUGyBnrsTTsP+DTnACfssMWCJEfjyzajdLSAE/l?= =?us-ascii?Q?wvsCWv4wua/VIdDX1D2rX4x/zBRSaoxdh+TwPnQf9jpJbbajSwlrxah5jSdS?= =?us-ascii?Q?CoJfX3Kwq5O4ivWA8C4HwJGoTQLDZ+ZYLxpOcLZvHcVzcz5VC2ehmU2tfx4i?= =?us-ascii?Q?kJtRWt3THqaTbZKI5mcbnoP77emoZcRs+W3VPUfWmjbS+8OcQISofxkyIq47?= =?us-ascii?Q?P2jOpgEYQMv3iUXrk78MldoaT+Sj67lhUjYUV87tUH4hXaOq4DjL0xlMfjl1?= =?us-ascii?Q?fKbcpTixmA/lKrj36KR2dk9kuxLu7Kb4qtANVrKO+mebxLZOSygGuZuqOfcJ?= =?us-ascii?Q?jIh4D7sAnwsVizF2UGaA/PpgjxufIMvCKuPBXniwVa/+5tpJ2FHDxjRgZOGh?= =?us-ascii?Q?xhbEQ60Kx8NuLynEvZVAsCKsKiBC0F6Uy3KitvBUmdd8V2bWNgQqsFo/RmF2?= =?us-ascii?Q?0uBL9/LeQWeinOS0hf10BgrRq5Wxn+lDwXVsucAXcpp+meB8VnLO5HxUzklv?= =?us-ascii?Q?AG6zSLijJHMHKtiiU1urOxt53EZxXaRcE92Dk7aZAMO81rnKkJTmB1vEdcMO?= =?us-ascii?Q?qKXUjtqH1ct2YYDhUZVwGw63BG2sBdPwu+F38+688IxFKnddORcFZfrDjFRF?= =?us-ascii?Q?G3KQEqKYbCjzwYman8KfAMkGn+eKl5+IkuzrhHBbV99hZGjRpNtYlSCeZ9GY?= =?us-ascii?Q?dT4++/e0CdzeY5GRY2Gzhlww03nKsFrdvKkbkVq6gwst5ZZUM4Lv/GoD+Zlt?= =?us-ascii?Q?IDn27AT8Qh3ZmFgxEL++1vrJ9aPOV+rzOaF69ynSslRCJ8cWrh+GGYBeeGUA?= =?us-ascii?Q?/UVVn2QYlwYm9irWy5X1pEOA/aUQG0IWEnRII4rRWm4FFM54jltFQztxDctN?= =?us-ascii?Q?UqM2vYwA+P9kyxYNw8S8zHFdTTky6OqNFa/9y1T8?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e0f5488-ed13-4a93-1114-08db6ba4f1e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2023 00:27:17.9900 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Jj91DWQBLoEfwziFpvZJwtrKqPvzPNz+attP++zoZ1QRM3PBOzFK1cE7CrnDFN1CpDFq3ioC7Ta6F8RfouXewg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4768 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Comments inline, prefaced with "[Isaac]". Mostly style things that you cou= ld probably fix with uncrustify also. The main concern is the controls seem confused with #defines and PCD. Simp= lifying to just use the PCD directly seems clear to me and eliminating the = #if logic in favor of regular C logic is also preferred. Thanks, Isaac -----Original Message----- From: Arun K =20 Sent: Monday, June 12, 2023 5:52 AM To: devel@edk2.groups.io; Arun K Cc: Oram, Isaac W ; Desimone, Nathaniel L ; Ramkumar Krishnamoorthi ; Gao, = Liming Subject: [edk2-devel][edk2-platforms][PATCH V3-1] IpmiFeaturePkg:Provided m= ultiple IPMI interface support in DXE and SMM Created IpmiTransport2 PPI/Protocol to support multiple IPMI BMC Interface = support such as KCS/BT/SSIF 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 IPM= I 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 | 10 + .../GenericIpmi/Common/IpmiBmcCommon.h | 2 + .../GenericIpmi/Common/IpmiHooks.c | 256 ++++++++++++++++++ .../GenericIpmi/Common/IpmiHooks.h | 93 ++++++- .../GenericIpmi/Dxe/GenericIpmi.inf | 14 +- .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 205 ++++++++++++++ .../GenericIpmi/Smm/SmmGenericIpmi.c | 200 +++++++++++++- .../GenericIpmi/Smm/SmmGenericIpmi.inf | 12 + .../IpmiFeaturePkg/IpmiFeaturePkg.dec | 45 +++ 9 files changed, 832 insertions(+), 5 deletions(-) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Generi= cIpmi/Common/IpmiBmc.h index d306a085e5..19fb2a26a3 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmc.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Comm +++ on/IpmiBmc.h @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -21,6 +22,7 @@ #include #include #include +#include #include "IpmiBmcCommon.h" #include "KcsBmc.h" @@ -41,4 +43,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..3b252f5f1c 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmcCommon.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Comm +++ on/IpmiBmcCommon.h @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -55,6 +56,7 @@ typedef struct { UINT8 SoftErrorCount; UINT16 IpmiIoBase; IPMI_TRANSPORT IpmiTransport; + IPMI_TRANSPORT2 IpmiTransport2; EFI_HANDLE IpmiSmmHandle; } IPMI_BMC_INSTANCE_DATA; diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiHooks.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Common/IpmiHooks.c index b2788e5a4c..19e5c1c04b 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Comm +++ on/IpmiHooks.c @@ -3,6 +3,7 @@ @copyright Copyright 2014 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -48,6 +49,11 @@ Returns: --*/ { + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; [Isaac] The preceding line is improperly indented. + } + // // This Will be unchanged ( BMC/KCS style ) // @@ -64,6 +70,251 @@ Returns: ); } // 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=20 + 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 + +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; [Isaac] The preceding line is improperly indented. + } + + IpmiInstance =3D INSTANCE_FROM_IPMI_TRANSPORT2_THIS(This); + +#if KcsInterfaceSupport [Isaac] I don't think that using #defines helps the code. I think obscurin= g the PCD makes the code harder to understand. Also not following the MACR= O_NAMING_CONVENTION. If you really prefer the macro, change it to something like IS_KCS_INTERFAC= E_PCD_ENABLED. I also prefer using regular C code instead of c preprocessors. All major t= oolchains support optimization that should remove any benefit to using #if.= If we use regular if statements, then code is compiled and thus tested fo= r build more regularly. + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceKcs)= =20 + && + (IpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } +#endif + +#if BtInterfaceSupport + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceBt) &= & + (IpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiBtSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8) CommandDataSize, + ResponseData, + (UINT8*) ResponseDataSize, + NULL + ); + } +#endif + +#if SsifInterfaceSupport + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceSsif)= =20 + && + (IpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiSsifSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8) CommandDataSize, + ResponseData, + (UINT8*) ResponseDataSize, + NULL + ); + } +#endif + +#if IpmbInterfaceSupport + if ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceIpmb)= =20 + && + (IpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiIpmbSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8) CommandDataSize, + ResponseData, + (UINT8*) ResponseDataSize, + NULL + ); + } +#endif + return EFI_UNSUPPORTED; [Isaac] Should we comment this a bit more? It isn't really obvious if hitt= ing this is a valid configuration. Should there be an assert here to indic= ate that one of the interfaces must be enabled? Are the function comments = about default interface correct? Same for next function. +} // 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 KcsInterfaceSupport + if ((InterfaceType =3D=3D SysInterfaceKcs) && + (IpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } +#endif + +#if BtInterfaceSupport + if ((InterfaceType =3D=3D SysInterfaceBt) && + (IpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiBtSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8) CommandDataSize, + ResponseData, + (UINT8*) ResponseDataSize, + NULL + ); + } +#endif + +#if SsifInterfaceSupport + if ((InterfaceType =3D=3D SysInterfaceSsif) && + (IpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiSsifSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8) CommandDataSize, + ResponseData, + (UINT8*) ResponseDataSize, + NULL + ); + } +#endif + +#if IpmbInterfaceSupport + if ((InterfaceType =3D=3D SysInterfaceIpmb) && + (IpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized)) { + + return IpmiIpmbSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8) CommandDataSize, + ResponseData, + (UINT8*) ResponseDataSize, + NULL + ); + } +#endif + return EFI_UNSUPPORTED; +} + EFI_STATUS EFIAPI IpmiGetBmcStatus ( @@ -89,6 +340,11 @@ Returns: --*/ { + + if ((This =3D=3D NULL) || (BmcStatus =3D=3D NULL) || (ComAddress =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + return IpmiBmcStatus ( This, BmcStatus, diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiHooks.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Common/IpmiHooks.h index 823cc08c61..3933e07443 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Comm +++ on/IpmiHooks.h @@ -3,13 +3,21 @@ @copyright Copyright 2014 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
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 [Isaac] Add a space before < in the two preceding lines. // // Internal(hook) function list @@ -54,6 +62,89 @@ 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=20 + 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 + +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 ( 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/ +++ GenericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2010 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
# 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..74d96f8684 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Ipm= iInit.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/ +++ IpmiInit.c @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -13,6 +14,7 @@ #include "IpmiBmc.h" #include "IpmiPhysicalLayer.h" #include +#include #ifdef FAST_VIDEO_SUPPORT #include #endif @@ -351,6 +353,130 @@ Returns: return Status; } // GetDeviceId() +/** + Initialize the API and parameters for IPMI Transport2 Instance + + @param[in] IpmiInstance Pointer to IPMI Instance + + @return VOID Nothing. + +**/ +VOID +InitIpmiTransport2 ( + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + ) +{ + + IpmiInstance->IpmiTransport2.InterfaceType =3D FixedPcdGet8 (= PcdDefaultSystemInterface); + IpmiInstance->IpmiTransport2.IpmiTransport2BmcStatus =3D BmcStatusOk; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2 =3D IpmiSendComman= d2; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2Ex =3D IpmiSendComman= d2Ex; + +#if BtInterfaceSupport + InitBtInterfaceData(&IpmiInstance->IpmiTransport2); +#endif + +#if SsifInterfaceSupport + InitSsifInterfaceData(&IpmiInstance->IpmiTransport2); +#endif + +#if IpmbInterfaceSupport + InitIpmbInterfaceData(&IpmiInstance->IpmiTransport2); +#endif +} + +/** + Notify call back function. + + @param[in] Event Event which caused this handler. + @param[in] Context Context passed during Event Handler registration. + + @return VOID Nothing. + +**/ +VOID +EFIAPI +DxeNotifyCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + IPMI_INTERFACE_STATE InterfaceState; + EFI_HANDLE Handle; + + InterfaceState =3D IpmiInterfaceNotReady; + +#if SsifInterfaceSupport + InitSsifInterfaceData(&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } +#endif + +#if IpmbInterfaceSupport + InitIpmbInterfaceData(&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized) { + 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); +} + +/** + Registers protocol notify call back. + + @param[in] ProtocolGuid Pointer to Protocol Guid to register + call back. + + @retval EFI_INVALID_PARAMETER If the ProtocolGuid is 0 or NULL. + @retval Others Status of call back registration. + +**/ +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=20 + (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. @@ -376,7 +502,10 @@ InitializeIpmiKcsPhysicalLayer ( UINT8 ErrorCount; EFI_HANDLE Handle; UINT8 Index; + IPMI_INTERFACE_STATE InterfaceState =3D IpmiInterfaceNotReady; +#if KcsInterfaceSupport EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; +#endif ErrorCount =3D 0; mImageHandle =3D ImageHandle; @@ -405,6 +534,8 @@ InitializeIpmiKcsPhysicalLayer ( mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNAT= URE; mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; mIpmiInstance->BmcStatus =3D BMC_NOTREADY; + +#if KcsInterfaceSupport mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; @@ -454,7 +585,81 @@ InitializeIpmiKcsPhysicalLayer ( ); ASSERT_EFI_ERROR (Status); } +#endif + + // Initialise the IPMI transport2 [Isaac] I find the mismatch in spelling with some use of s and more use of = z to be confusing. + InitIpmiTransport2(mIpmiInstance); [Isaac] Space before ( + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + + switch (Index) { +#if KcsInterfaceSupport [Isaac] A lot of the following code is not indented properly. + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) &&=20 + (mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; [Isaac] I would prefer this at the beginning of the function with other loc= al variables. + =20 + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=20 + IpmiInterfaceInitialized; + Status =3D CheckSelfTestByInterfaceType( [Isaac] Please insert space before (. Please add newline between the inter= esting code and the variable init. + &mIpmiInstance->IpmiTransport2, + &BmcStatus, + SysInterfaceKcs); [Isaac] Put ); on its own line as per other code conventions. + if (!EFI_ERROR (Status) && (BmcStatus !=3D=20 + BmcStatusHardFail)) { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + =20 + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=20 + IpmiInterfaceInitError; + } + } + break; +#endif + +#if BtInterfaceSupport + case SysInterfaceBt: + if=20 + (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized){ [Isaac] Space before { + InterfaceState =3D IpmiInterfaceInitialized; + } + break; +#endif + +#if SsifInterfaceSupport + case SysInterfaceSsif: + if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D DxeRegisterProtocolCallback ( + =20 + &mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid); [Isaac] Indent this line 2 characters from the beginning of the function na= me on the prior line per coding style. Also put ); on its own line. + } + break; +#endif +#if IpmbInterfaceSupport + case SysInterfaceIpmb: + if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitError) { + // Register Protocol notify for I2C Protocol. + Status =3D DxeRegisterProtocolCallback ( + =20 + &mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid); [Isaac] Put ); on its own line as per other code conventions. + } + 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..adf59374b3 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/ +++ SmmGenericIpmi.c @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -24,6 +25,7 @@ #include "IpmiBmcCommon.h" #include "IpmiBmc.h" #include +#include IPMI_BMC_INSTANCE_DATA *mIpmiInstance; EFI_HANDLE mImageHandle; @@ -115,6 +117,123 @@ Returns: return Status; } +/** + Initialize the API and parameters for IPMI Transport2 Instance [Isaac] There are a lot of four space indents. + + @param[in] IpmiInstance Pointer to IPMI Instance + + @return 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 BtInterfaceSupport + InitBtInterfaceData (&IpmiInstance->IpmiTransport2); +#endif + +#if SsifInterfaceSupport + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2); +#endif + +#if IpmbInterfaceSupport + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2); +#endif +} + +/** + Notify call back to initialize the interfaces and install Smm Ipmi + protocol. + + @param[in] Protocol Pointer to the protocol guid. + @param[in] Interface Pointer to the protocol instance. + @param[in] Handle Handle on which the protocol is installed. + + @return EFI_STATUS 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 SsifInterfaceSupport + InitSsifInterfaceData(&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized){ [Isaac] Space before { + InterfaceState =3D IpmiInterfaceInitialized; + } +#endif + +#if IpmbInterfaceSupport + InitIpmbInterfaceData(&mIpmiInstance->IpmiTransport2); +#endif + + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized){ [Isaac] Space before { + 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, + &gSmmIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + } + return EFI_SUCCESS; +} + +/** + Registers Protocol call back + + @param ProtocolGuid Pointer to Protocol GUID to register call ba= ck + + @retval EFI_INVALID_PARAMETER If the ProtocolGuid is 0 or NULL. + @retval Others Status of Notify registration. +**/ +EFI_STATUS +SmmRegisterProtocolCallback ( + IN EFI_GUID *ProtocolGuid +) [Isaac] Not Indented the same way other functions are. +{ + EFI_STATUS Status; + VOID *Registration; + + if ((ProtocolGuid =3D=3D NULL) || + ((ProtocolGuid !=3D NULL) && IsZeroBuffer (ProtocolGuid, sizeof=20 + (EFI_GUID)))) { + return EFI_INVALID_PARAMETER; + } + + Status =3D gSmst->SmmRegisterProtocolNotify ( + ProtocolGuid, + SmmNotifyCallback, + &Registration ); + return Status; +} + EFI_STATUS SmmInitializeIpmiKcsPhysicalLayer ( IN EFI_HANDLE ImageHandle, @@ -142,10 +261,13 @@ Returns: 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; + ErrorCount =3D 0; + mImageHandle =3D ImageHandle; + InterfaceState =3D IpmiInterfaceNotReady; mIpmiInstance =3D AllocateZeroPool (sizeof (IPMI_BMC_INSTANCE_DATA)); ASSERT (mIpmiInstance !=3D NULL); @@ -170,6 +292,7 @@ Returns: mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; +#if KcsInterfaceSupport 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. @@ -191,6 +314,79 @@ Returns: &mIpmiInstance->IpmiTransport ); ASSERT_EFI_ERROR (Status); +#endif + + InitIpmiTransport2(mIpmiInstance); [Isaac] Space before ( + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + + switch (Index) { +#if KcsInterfaceSupport + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) &&=20 + (mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; [Isaac] Better to be with other local variables at beginning of function. + =20 + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=20 + IpmiInterfaceInitialized; + Status =3D CheckSelfTestByInterfaceType( [Isaac] Insert space before ( + =20 + &mIpmiInstance->IpmiTransport2, + &BmcStatus, + SysInterfaceKcs); [Isaac] Place ); on own line. + if (!EFI_ERROR (Status) && (BmcStatus !=3D=20 + BmcStatusHardFail)) { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + =20 + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=20 + IpmiInterfaceInitError; + } + } + break; +#endif + +#if BtInterfaceSupport + case SysInterfaceBt: + if=20 + (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized){ [Isaac] Insert space before { + InterfaceState =3D IpmiInterfaceInitialized; + } + break; +#endif + +#if SsifInterfaceSupport + case SysInterfaceSsif: + if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized){ [Isaac] Insert space before { + InterfaceState =3D IpmiInterfaceInitialized; + } else if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D=20 + IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D SmmRegisterProtocolCallback=20 + (&mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid); + } + break; +#endif + +#if IpmbInterfaceSupport + case SysInterfaceIpmb: + if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } else if=20 + (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D=20 + IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D SmmRegisterProtocolCallback=20 + (&mIpmiInstance->IpmiTransport2.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, + &gSmmIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR,"IPMI Transport2 protocol install=20 + Status =3D %r \n",Status)); + } + } DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n")); 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/ +++ SmmGenericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2010 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.=20 +
# 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..2131ec475b 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.d +++ ec @@ -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.=20 +
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -43,16 +44,26 @@ # IpmiBaseLib|Include/Library/IpmiBaseLib.h + ## @libraryclass Provides generic functions among all interfaces. + BmcCommonInterfaceLib|Include/Library/BmcCommonInterfaceLib.h + BtInterfaceLib|Include/Library/BtInterfaceLib.h + SsifInterfaceLib|Include/Library/SsifInterfaceLib.h + 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,=20 + 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,=20 + 0xFE, 0x90, 0x92, 0x1B, 0x74, 0x82, 0x13 }} + gSmmIpmiTransport2ProtocolGuid =3D { 0x1DBD1503, 0x0A60, 0x4230, {=20 + 0xAA, 0xA3, 0x80, 0x16, 0xD8, 0xC3, 0xDE, 0x2F }} [PcdsFeatureFlag] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE|BOOLEAN|0xA0000= 001 @@ -61,6 +72,40 @@ 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; + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface|1|UINT8|0xF000 + 0003 + + #BT Base address, retry counter and delay parameters + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtCommandRetryCounter|0x0004E400|UINT + 32|0xF0000004 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort|0xE4|UINT16|0xF0000005 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferPort|0xE5|UINT16|0xF0000006 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtDelayPerRetry|15|UINT32|0xF0000007 + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterruptMaskPort|0xE6|UINT16|0xF00 + 00008 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferSize|0x40|UINT8|0xF0000009 + + #SSIF slave address, retry counter and delay parameters + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifSlaveAddress|0x10|UINT16|0xF00000 + 0A + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay|0xCB20|UINT32 + |0xF000000B + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifCommandtRetryCounter|0x5|UINT16|0 + xF000000C + + #Interface access type for BMC communication. 0-MMIO, 1-IO + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiDefaultAccessType|1|UINT8|0xF0000 + 00D + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdMmioBaseAddress|0x0|UINT32|0xF000000E + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdBaseAddressRange|0x0|UINT32|0xF000000 + F + + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdBmcSlaveAddress|0x20|UINT32|0xF000001 + 0 + + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport|1|UINT8|0xF000001 + 1 + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport|1|UINT8|0xF0000012 + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport|1|UINT8|0xF00000 + 13 + =20 + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport|1|UINT8|0xF00000 + 14 [PcdsDynamic, PcdsDynamicEx] gIpmiFeaturePkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0xD0000001 -- 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= .