From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.49823.1606209853795679304 for ; Tue, 24 Nov 2020 01:24:14 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=nGJ+9m51; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) IronPort-SDR: twrui1nZv67RjZvsCD1Vt2NmQ2ViLeGXP981YNa2/vcSYHoYxaJRxbx0I70iQnCdsbd/0Jueli hQ1YWZ4U0D5g== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="233524453" X-IronPort-AV: E=Sophos;i="5.78,365,1599548400"; d="scan'208";a="233524453" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 01:24:12 -0800 IronPort-SDR: 4Ob3ZhcaCBAApEeZu3HtSzTlgBbitJK7RdAHLTc0R62SZ1HogioxDAxgbSO9BTHjG0KVWc1k+W 2aN7AQOfGj9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,365,1599548400"; d="scan'208";a="432551696" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga001.fm.intel.com with ESMTP; 24 Nov 2020 01:24:12 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 24 Nov 2020 01:24:11 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 24 Nov 2020 01:24:11 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 24 Nov 2020 01:24:11 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GREaSkJZhBx4EgXgy9Do+nU/KUYWjCAphfJrv3KhLih9at+4DliVZD+TqQ33KxagboHCSMRMg19edKisaPeVvXqmcm4mE4/js0lmxBAtUUZIlKd7SNZxLqPBwfnfkOzgfnUuroMIpNOuluYEJbyv9AOdXrspnGsS+9OoYHNWYqUlxeMMBZoLPTjw9t9Tuz5+BWbIy+UUPtA+VVExCxHUYEpXZFO047/hNWYMjMxwD2XB3nbtqmcH60Iz528xBTAtXp7xKTghIuOXRiW9QF71O0PeOeVInz76LCCeT8dxdf3cXLMKekKfh2uviDEUP2pSUqW9nKQ2HRICLHuWpdPeKg== 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-SenderADCheck; bh=eW+gNvX55BMQzds6vL7lru0c8qb7A50sPXlokC9W8Pk=; b=R4XmEr4TMv49mj41GI7l3UenGegGpXuJ+U+H5VvU8FqTpehwWweFudgY8I1AJ6jwIS1oVUv+m84cZhigYf/2BjtKlio6c18V8t6eJPxUMaVIfJQAitJRNyXN8+pCQssbxKyEziSkoLj2FRE6ImDRexsIoLBccrwsR+7HHBE4PAEzt6plgNwWUTHUiPC5DfkGNi3Tu8Ht/R2Y5RIKRdQFHDQC5AiCq6FpPI+ouCNLFoygFD8GMkPI4ItXjkv5dhEvPp61/o1hZQM6gipoiCulFoJ3Lf4cE07MFB8Rgzx9FHPl8Rzm+zP2Uyxy1P4Bqa8NFKfUatKvmpDA/ru7CxmNnQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eW+gNvX55BMQzds6vL7lru0c8qb7A50sPXlokC9W8Pk=; b=nGJ+9m517G1p/Y12tOgksM6OLBNfsVg5zd8qPysUSYFjsppFkPWaVgqSQd5Ifo1y9KbGu6LimGeZI3hGHRPMMSiAkCQlzCi7L4C6Q2oLtpTI91oY3dtB+guRmaHxD98Q1reZhRYq+MDaR7/5uQAjM8T11+c6dsDHTUj4Ntek7YM= Received: from CO1PR11MB4930.namprd11.prod.outlook.com (2603:10b6:303:9b::11) by MWHPR11MB1823.namprd11.prod.outlook.com (2603:10b6:300:10e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.25; Tue, 24 Nov 2020 09:24:05 +0000 Received: from CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::d18:1234:c1d6:5936]) by CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::d18:1234:c1d6:5936%7]) with mapi id 15.20.3611.020; Tue, 24 Nov 2020 09:24:05 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Chang, Abner (HPS SW/FW Technologist)" CC: "Justen, Jordan L" , Andrew Fish , "Wang, Nickle (HPS SW)" , "O'Hanley, Peter (EXL)" Subject: Re: [edk2-devel] [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library Thread-Topic: [edk2-devel] [Platform Redfish Host Interface PATCH 3/6] EmulatorPkg/RedfishPlatformHostInterfaceLib library Thread-Index: AQHWwkONmN+HUh3RVUyqXEvQQeH2xw== Date: Tue, 24 Nov 2020 09:24:05 +0000 Message-ID: References: <20201105143853.2180-1-abner.chang@hpe.com> <1644A5FDFD825A04.31306@groups.io> In-Reply-To: <1644A5FDFD825A04.31306@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.220] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0edf0278-d11d-4ae2-3723-08d8905ab076 x-ms-traffictypediagnostic: MWHPR11MB1823: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:47; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BxG1JNr39Ir8rzHm2euJb152tMsPRr7/9MtO6ih6wzztYhdqg1AIJTJKzQrwoaJF8PMUiYCLeeodttGerjxREvxijZLxuG6rDSbLcZlzuNw8DEsvZDuxY525VBGPCBesXnNQaTsjXvIJTv/4q1O2RrqbKK3r/I+CFX8W7FyDuggXS56nYb2ZXda7a6Z5ytdP37gr1P/aK9C7xaNma3ftyGyBMlpN96T62vxJndV5BXDYWVwRB7eO33hjYjMmCXkvFjAJGanVBXKP7h7CjUA1ykdQTAddEDt891Taih2i+lyS4YXSbNO7JAQdZpJ+znqtHkcHbPE7IF+S6aRJxQv2brlrcOslwkPSyIgHOt6HeYfFirmHppeoNrdMob6T5+am6DAXrDcbV65+06NbiEonDEkwdOGSreCPta97Rjjc4KDQ2Wxoo+Icu9ogKkgECywVdYUefAcnmCXHs86A5LBrmQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4930.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(346002)(376002)(136003)(366004)(39860400002)(6506007)(26005)(186003)(55016002)(30864003)(53546011)(966005)(7696005)(19627235002)(8936002)(5660300002)(8676002)(33656002)(86362001)(71200400001)(83380400001)(316002)(9686003)(110136005)(2906002)(54906003)(66446008)(4326008)(52536014)(66556008)(66946007)(478600001)(76116006)(64756008)(66476007)(213903007)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: VeHAmkOS2rXZYuiNumQEKryz7geSuD0iSSr2PLGiLfXLv+qdY70e3Q2dgt+U3QCecDIiheqnhqB30O4wYMMA4yg/0od2RDMhmrX4C/JRUXeu4XZJt/9l7t4NFbso5HltgaWCTgbUa4XozUIcV2VsQJ98smUeD6fvjtwP4zKlEehY9BQxvUh6/1j62ZPSmoii+Z5gXF97nZuPAZUb6i3OcZBB6O/QxxjxBish+zGIvCRYP9T7/70h2K0Gr3StxMsY9sXG4R6ZzqbEePZ+8NH9Xi8oBECkK8ar/3jNFynmWsHg01qqofKW22F8BabdoyQ1rYVnvhvp89xf7TTXK0RfxET2m9NQwum1TV4DBtviUmGJsA98VWKLxPDo/2idh+ggIF45F61I4G/t7hOneYBXGzRD+iqog8HpCWa+gZQsXF2A9Ld4HyiNXERez3Kcxl0NSXHCXw9oI15iZHddHPa2PPBlAzMhtzkwvu9w2QwvhK9fqLEX4cwbu3CkjHDGLz5LVarS1VWFIaLetxjWYzVIgra+dViXNnW2e8x7mkynKE2gUV4suh4Lbkem6s97thlYgobddWdF/6QzWw6rPbQjCMmwI0yL5JYxPZdoZkIQ7O84hCXp+DTVb7XDkjJ8vGhDUDOktiyx+TJws/c6LxqVgosnhgWilwVwHmMgMDPuAWiwAXLCyxSYJtMtrmbiT4N6E0K+jB7SIS6kvT0OrUsjOoMS5zTi1uVwSz0IOLSIzo7pzHdEAsBNl5zEdY3FhpM3ZTkkCbwozOct5Z89MYRsVBqSgRB16lLluYeRc2CBV3M0mhjlCmJBj3IjFxKwwqkezw9Q9sBgkj+1SrKd6gcJ5sgEPxwPgKZr0ZuAOWLgLm6K+9bgoWnsk7skLo1p2DUd683HztMBBSgrZwtvGL1hDA== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4930.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0edf0278-d11d-4ae2-3723-08d8905ab076 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2020 09:24:05.3883 (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: qs2tY5xSwyBx7Hd2PWIlhh3WAjEXwvT3PUregRuVA/nvtCTK6hnquDiSMbBLCy0knccCXkypvzFt9h7iTI86hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1823 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Ray Ni > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Chang, Ab= ner (HPS SW/FW Technologist) > Sent: Thursday, November 5, 2020 10:39 PM > To: devel@edk2.groups.io > Cc: Justen, Jordan L ; Andrew Fish ; Ni, Ray ; Wang, Nickle > (HPS SW) ; O'Hanley, Peter (EXL) > Subject: [edk2-devel] [Platform Redfish Host Interface PATCH 3/6] Emulat= orPkg/RedfishPlatformHostInterfaceLib library >=20 > Platform specific implementation of providing > Redfish host interface information. >=20 > Signed-off-by: Jiaxin Wu > Signed-off-by: Ting Ye > Signed-off-by: Siyuan Fu > Signed-off-by: Fan Wang > Signed-off-by: Abner Chang >=20 > Cc: Jordan Justen > Cc: Andrew Fish > Cc: Ray Ni > Cc: Nickle Wang > Cc: Peter O'Hanley > --- > EmulatorPkg/EmulatorPkg.dec | 1 + > .../RedfishPlatformHostInterfaceLib.c | 528 ++++++++++++++++++ > .../RedfishPlatformHostInterfaceLib.inf | 47 ++ > 3 files changed, 576 insertions(+) > create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/= RedfishPlatformHostInterfaceLib.c > create mode 100644 EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/= RedfishPlatformHostInterfaceLib.inf >=20 > diff --git a/EmulatorPkg/EmulatorPkg.dec b/EmulatorPkg/EmulatorPkg.dec > index 064f963c72..5d7fe6473e 100644 > --- a/EmulatorPkg/EmulatorPkg.dec > +++ b/EmulatorPkg/EmulatorPkg.dec > @@ -46,6 +46,7 @@ > gEmuSystemConfigGuid =3D { 0xF8626165, 0x6CEB, 0x924A, { 0xBA, = 0xFC, 0xF1, 0x3A, 0xB9, 0xD6, 0x57, 0x28 } } > gEmuVirtualDisksGuid =3D { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, = 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } } > gEmuPhysicalDisksGuid =3D { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, = 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } } > + gEmuRedfishServiceGuid =3D { 0x3fb208ac, 0x2185, 0x498c, { 0xbf, = 0x46, 0xdc, 0x23, 0xda, 0x58, 0x7b, 0x55 } } >=20 > [PcdsFeatureFlag] > ## If TRUE, if symbols only load on breakpoints and gdb entry > diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/Redfish= PlatformHostInterfaceLib.c > b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHos= tInterfaceLib.c > new file mode 100644 > index 0000000000..4e7bb65c06 > --- /dev/null > +++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatfor= mHostInterfaceLib.c > @@ -0,0 +1,528 @@ > +/** @file > + PCI/PCIe network interface instace of RedfishPlatformHostInterfaceLib > + > + Copyright (c) 2019, Intel Corporation. All rights reserved.
> + (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +#define VERBOSE_COLUME_SIZE (16) > + > +REDFISH_OVER_IP_PROTOCOL_DATA *mRedfishOverIpProtocolData; > +UINT8 mRedfishProtocolDataSize; > + > +/** > + Get the MAC address of NIC. > + > + @param[out] MacAddress Pointer to retrieve MAC address > + > + @retval EFI_SUCCESS MAC address is returned in MacAddress > + > +**/ > +EFI_STATUS > +GetMacAddressInformation ( > + OUT EFI_MAC_ADDRESS *MacAddress > + ) > +{ > + MAC_ADDR_DEVICE_PATH *Mac; > + REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData= ; > + EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath; > + MAC_ADDR_DEVICE_PATH *MacAddressDevicePath; > + > + Mac =3D NULL; > + RestExServiceDevicePathData =3D NULL; > + RestExServiceDevicePath =3D NULL; > + > + RestExServiceDevicePathData =3D (REST_EX_SERVICE_DEVICE_PATH_DATA *)P= cdGetPtr(PcdRedfishRestExServiceDevicePath); > + if (RestExServiceDevicePathData =3D=3D NULL || > + RestExServiceDevicePathData->DevicePathNum =3D=3D 0 || > + !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0)) = { > + return EFI_NOT_FOUND; > + } > + > + RestExServiceDevicePath =3D RestExServiceDevicePathData->DevicePath; > + if (RestExServiceDevicePathData->DevicePathMatchMode !=3D DEVICE_PATH= _MATCH_MAC_NODE) { > + return EFI_NOT_FOUND; > + } > + > + // > + // Find Mac DevicePath Node. > + // > + while (!IsDevicePathEnd (RestExServiceDevicePath) && > + ((DevicePathType (RestExServiceDevicePath) !=3D MESSAGING_DEVI= CE_PATH) || > + (DevicePathSubType (RestExServiceDevicePath) !=3D MSG_MAC_ADD= R_DP))) { > + RestExServiceDevicePath =3D NextDevicePathNode (RestExServiceDevice= Path); > + } > + > + if (!IsDevicePathEnd (RestExServiceDevicePath)) { > + MacAddressDevicePath =3D (MAC_ADDR_DEVICE_PATH *)RestExServiceDevic= ePath; > + CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddr= ess, sizeof (EFI_MAC_ADDRESS)); > + return EFI_SUCCESS; > + } > + return EFI_NOT_FOUND; > +} > + > +/** > + Get platform Redfish host interface device descriptor. > + > + @param[out] DeviceType Pointer to retrieve device type. > + @param[out] DeviceDescriptor Pointer to retrieve REDFISH_INTERFACE_D= ATA, caller has to free > + this memory using FreePool(). > + @retval EFI_SUCCESS Device descriptor is returned successfully in= DeviceDescriptor. > + @retval EFI_NOT_FOUND No Redfish host interface descriptor provided= on this platform. > + @retval Others Fail to get device descriptor. > +**/ > +EFI_STATUS > +RedfishPlatformHostInterfaceDeviceDescriptor ( > + OUT UINT8 *DeviceType, > + OUT REDFISH_INTERFACE_DATA **DeviceDescriptor > +) > +{ > + EFI_STATUS Status; > + EFI_MAC_ADDRESS MacAddress; > + REDFISH_INTERFACE_DATA *RedfishInterfaceData; > + PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor; > + > + RedfishInterfaceData =3D AllocateZeroPool (sizeof (PCI_OR_PCIE_INTERF= ACE_DEVICE_DESCRIPTOR_V2) + 1); > + if (RedfishInterfaceData =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + RedfishInterfaceData->DeviceType =3D REDFISH_HOST_INTERFACE_DEVICE_TY= PE_PCI_PCIE_V2; > + // > + // Fill up device type information. > + // > + ThisDeviceDescriptor =3D (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 = *)((UINT8 *)RedfishInterfaceData + 1); > + ThisDeviceDescriptor->Length =3D sizeof (PCI_OR_PCIE_INTERFACE_DEVICE= _DESCRIPTOR_V2) + 1; > + Status =3D GetMacAddressInformation (&MacAddress); > + if (EFI_ERROR (Status)) { > + FreePool (RedfishInterfaceData); > + return EFI_NOT_FOUND; > + } > + CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddre= ss, sizeof (ThisDeviceDescriptor- > >MacAddress)); > + *DeviceType =3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2; > + *DeviceDescriptor =3D RedfishInterfaceData; > + return EFI_SUCCESS; > +} > +/** > + Get platform Redfish host interface protocol data. > + Caller should pass NULL in ProtocolRecord to retrive the first protoc= ol record. > + Then continuously pass previous ProtocolRecord for retrieving the nex= t ProtocolRecord. > + > + @param[out] ProtocolRecord Pointer to retrieve the protocol recor= d. > + caller has to free the new protocol re= cord returned from > + this function using FreePool(). > + @param[in] IndexOfProtocolData The index of protocol data. > + > + @retval EFI_SUCCESS Protocol records are all returned. > + @retval EFI_NOT_FOUND No more protocol records. > + @retval Others Fail to get protocol records. > +**/ > +EFI_STATUS > +RedfishPlatformHostInterfaceProtocolData ( > + OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, > + IN UINT8 IndexOfProtocolData > +) > +{ > + MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord; > + > + if (mRedfishOverIpProtocolData =3D=3D 0) { > + return EFI_NOT_FOUND; > + } > + if (IndexOfProtocolData =3D=3D 0) { > + // > + // Return the first Redfish protocol data to caller. We only have > + // one protocol data in this case. > + // > + ThisProtocolRecord =3D (MC_HOST_INTERFACE_PROTOCOL_RECORD *) Alloca= tePool (mRedfishProtocolDataSize + sizeof > (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1); > + ThisProtocolRecord->ProtocolType =3D MCHostInterfaceProtocolTypeRed= fishOverIP; > + ThisProtocolRecord->ProtocolTypeDataLen =3D mRedfishProtocolDataSiz= e; > + CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRe= dfishOverIpProtocolData, > mRedfishProtocolDataSize); > + *ProtocolRecord =3D ThisProtocolRecord; > + return EFI_SUCCESS; > + } > + return EFI_NOT_FOUND; > +} > +/** > + Dump IPv4 address. > + > + @param[in] Ip IPv4 address > +**/ > +VOID > +InternalDumpIp4Addr ( > + IN EFI_IPv4_ADDRESS *Ip > + ) > +{ > + UINTN Index; > + > + for (Index =3D 0; Index < 4; Index++) { > + DEBUG ((DEBUG_VERBOSE, "%d", Ip->Addr[Index])); > + if (Index < 3) { > + DEBUG ((DEBUG_VERBOSE, ".")); > + } > + } > + > + DEBUG ((DEBUG_VERBOSE, "\n")); > +} > +/** > + Dump IPv6 address. > + > + @param[in] Ip IPv6 address > +**/ > +VOID > +InternalDumpIp6Addr ( > + IN EFI_IPv6_ADDRESS *Ip > + ) > +{ > + UINTN Index; > + > + for (Index =3D 0; Index < 16; Index++) { > + if (Ip->Addr[Index] !=3D 0) { > + DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index])); > + } > + Index++; > + > + if (Index > 15) { > + return; > + } > + > + if (((Ip->Addr[Index] & 0xf0) =3D=3D 0) && (Ip->Addr[Index - 1] != =3D 0)) { > + DEBUG ((DEBUG_VERBOSE, "0")); > + } > + DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index])); > + > + if (Index < 15) { > + DEBUG ((DEBUG_VERBOSE, ":")); > + } > + } > + DEBUG ((DEBUG_VERBOSE, "\n")); > +} > +/** > + Dump data > + > + @param[in] Data Pointer to data. > + @param[in] Size size of data to dump. > +**/ > +VOID > +InternalDumpData ( > + IN UINT8 *Data, > + IN UINTN Size > + ) > +{ > + UINTN Index; > + for (Index =3D 0; Index < Size; Index++) { > + DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index])); > + } > +} > +/** > + Dump hex data > + > + @param[in] Data Pointer to hex data. > + @param[in] Size size of hex data to dump. > +**/ > +VOID > +InternalDumpHex ( > + IN UINT8 *Data, > + IN UINTN Size > + ) > +{ > + UINTN Index; > + UINTN Count; > + UINTN Left; > + > + Count =3D Size / VERBOSE_COLUME_SIZE; > + Left =3D Size % VERBOSE_COLUME_SIZE; > + for (Index =3D 0; Index < Count; Index++) { > + InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, VERBOSE_COLUM= E_SIZE); > + DEBUG ((DEBUG_VERBOSE, "\n")); > + } > + > + if (Left !=3D 0) { > + InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, Left); > + DEBUG ((DEBUG_VERBOSE, "\n")); > + } > + > + DEBUG ((DEBUG_VERBOSE, "\n")); > +} > +/** > + Dump Redfish over IP protocol data > + > + @param[in] RedfishProtocolData Pointer to REDFISH_OVER_IP_PROTOCO= L_DATA > + @param[in] RedfishProtocolDataSize size of data to dump. > +**/ > +VOID > +DumpRedfishIpProtocolData ( > + IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData, > + IN UINT8 RedfishProtocolDataSize > + ) > +{ > + CHAR16 Hostname[16]; > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n")); > + InternalDumpHex ((UINT8 *) RedfishProtocolData, RedfishProtocolDataSi= ze); > + > + DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n")); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->ServiceUuid - %g\n", &(R= edfishProtocolData->ServiceUuid))); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAssignmentType - %= d\n", RedfishProtocolData- > >HostIpAssignmentType)); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddressFormat - %d= \n", RedfishProtocolData- > >HostIpAddressFormat)); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n")); > + if (RedfishProtocolData->HostIpAddressFormat =3D=3D 0x01) { > + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->Hos= tIpAddress)); > + } else { > + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->Hos= tIpAddress)); > + } > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n")); > + if (RedfishProtocolData->HostIpAddressFormat =3D=3D 0x01) { > + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->Hos= tIpMask)); > + } else { > + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->Hos= tIpMask)); > + } > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscover= yType - %d\n", RedfishProtocolData- > >RedfishServiceIpDiscoveryType)); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddressF= ormat - %d\n", RedfishProtocolData- > >RedfishServiceIpAddressFormat)); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress:= \n")); > + if (RedfishProtocolData->RedfishServiceIpAddressFormat =3D=3D 0x01) { > + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->Red= fishServiceIpAddress)); > + } else { > + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->Red= fishServiceIpAddress)); > + } > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n= ")); > + if (RedfishProtocolData->RedfishServiceIpAddressFormat =3D=3D 0x01) { > + InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->Red= fishServiceIpMask)); > + } else { > + InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->Red= fishServiceIpMask)); > + } > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %= d\n", RedfishProtocolData- > >RedfishServiceIpPort)); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceVlanId - %= d\n", RedfishProtocolData- > >RedfishServiceVlanId)); > + > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLe= ngth - %d\n", RedfishProtocolData- > >RedfishServiceHostnameLength)); > + > + AsciiStrToUnicodeStrS((CHAR8 *) RedfishProtocolData->RedfishServiceHo= stname, Hostname, sizeof (Hostname) / sizeof > (Hostname[0])); > + DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname -= %s\n", Hostname)); > +} > + > +/** > + Get Redfish host interface protocol data from variale. > + > + @param[out] RedfishProtocolData Pointer to retrieve REDFISH_OVER_IP_= PROTOCOL_DATA. > + @param[out] RedfishProtocolDataSize Size of REDFISH_OVER_IP_PROTOCOL= _DATA. > + > + @retval EFI_SUCESS REDFISH_OVER_IP_PROTOCOL_DATA is returned succes= sfully. > +**/ > +EFI_STATUS > +GetRedfishRecordFromVariable ( > + OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData, > + OUT UINT8 *RedfishProtocolDataSize > + ) > +{ > + EFI_STATUS Status; > + UINT8 HostIpAssignmentType; > + UINTN HostIpAssignmentTypeSize; > + EFI_IPv4_ADDRESS HostIpAddress; > + UINTN IPv4DataSize; > + EFI_IPv4_ADDRESS HostIpMask; > + EFI_IPv4_ADDRESS RedfishServiceIpAddress; > + EFI_IPv4_ADDRESS RedfishServiceIpMask; > + UINT16 RedfishServiceIpPort; > + UINTN IpPortDataSize; > + UINT8 HostNameSize; > + CHAR8 RedfishHostName[20]; > + > + if (RedfishProtocolData =3D=3D NULL || RedfishProtocolDataSize =3D=3D= NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // 1. Retrieve Address Information from variable. > + // > + Status =3D gRT->GetVariable ( > + L"HostIpAssignmentType", > + &gEmuRedfishServiceGuid, > + NULL, > + &HostIpAssignmentTypeSize, > + &HostIpAssignmentType > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAssignm= entType - %r\n", Status)); > + return Status; > + } > + > + IPv4DataSize =3D sizeof (EFI_IPv4_ADDRESS); > + if (HostIpAssignmentType =3D=3D 1 ) { > + Status =3D gRT->GetVariable ( > + L"HostIpAddress", > + &gEmuRedfishServiceGuid, > + NULL, > + &IPv4DataSize, > + &HostIpAddress > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAddre= ss - %r\n", Status)); > + return Status; > + } > + > + Status =3D gRT->GetVariable ( > + L"HostIpMask", > + &gEmuRedfishServiceGuid, > + NULL, > + &IPv4DataSize, > + &HostIpMask > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpMask = - %r\n", Status)); > + return Status; > + } > + } > + > + Status =3D gRT->GetVariable ( > + L"RedfishServiceIpAddress", > + &gEmuRedfishServiceGuid, > + NULL, > + &IPv4DataSize, > + &RedfishServiceIpAddress > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServic= eIpAddress - %r\n", Status)); > + return Status; > + } > + > + Status =3D gRT->GetVariable ( > + L"RedfishServiceIpMask", > + &gEmuRedfishServiceGuid, > + NULL, > + &IPv4DataSize, > + &RedfishServiceIpMask > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServic= eIpMask - %r\n", Status)); > + return Status; > + } > + > + Status =3D gRT->GetVariable ( > + L"RedfishServiceIpPort", > + &gEmuRedfishServiceGuid, > + NULL, > + &IpPortDataSize, > + &RedfishServiceIpPort > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServic= eIpPort - %r\n", Status)); > + return Status; > + } > + > + AsciiSPrint ( > + RedfishHostName, > + sizeof (RedfishHostName), > + "%d.%d.%d.%d", > + RedfishServiceIpAddress.Addr[0], > + RedfishServiceIpAddress.Addr[1], > + RedfishServiceIpAddress.Addr[2], > + RedfishServiceIpAddress.Addr[3] > + ); > + > + HostNameSize =3D (UINT8) AsciiStrLen (RedfishHostName) + 1; > + > + // > + // 2. Protocol Data Size. > + // > + *RedfishProtocolDataSize =3D sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) -= 1 + HostNameSize; > + > + // > + // 3. Protocol Data. > + // > + *RedfishProtocolData =3D (REDFISH_OVER_IP_PROTOCOL_DATA *) AllocateZe= roPool (*RedfishProtocolDataSize); > + if (*RedfishProtocolData =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGu= id); > + > + (*RedfishProtocolData)->HostIpAssignmentType =3D HostIpAssignmentType= ; > + (*RedfishProtocolData)->HostIpAddressFormat =3D 1; // Only support = IPv4 > + > + if (HostIpAssignmentType =3D=3D 1 ) { > + (*RedfishProtocolData)->HostIpAddress[0] =3D HostIpAddress.Addr[0]; > + (*RedfishProtocolData)->HostIpAddress[1] =3D HostIpAddress.Addr[1]; > + (*RedfishProtocolData)->HostIpAddress[2] =3D HostIpAddress.Addr[2]; > + (*RedfishProtocolData)->HostIpAddress[3] =3D HostIpAddress.Addr[3]; > + > + (*RedfishProtocolData)->HostIpMask[0] =3D HostIpMask.Addr[0]; > + (*RedfishProtocolData)->HostIpMask[1] =3D HostIpMask.Addr[1]; > + (*RedfishProtocolData)->HostIpMask[2] =3D HostIpMask.Addr[2]; > + (*RedfishProtocolData)->HostIpMask[3] =3D HostIpMask.Addr[3]; > + } > + > + (*RedfishProtocolData)->RedfishServiceIpDiscoveryType =3D 1; // Use = static IP address > + (*RedfishProtocolData)->RedfishServiceIpAddressFormat =3D 1; // Only= support IPv4 > + > + (*RedfishProtocolData)->RedfishServiceIpAddress[0] =3D RedfishService= IpAddress.Addr[0]; > + (*RedfishProtocolData)->RedfishServiceIpAddress[1] =3D RedfishService= IpAddress.Addr[1]; > + (*RedfishProtocolData)->RedfishServiceIpAddress[2] =3D RedfishService= IpAddress.Addr[2]; > + (*RedfishProtocolData)->RedfishServiceIpAddress[3] =3D RedfishService= IpAddress.Addr[3]; > + > + (*RedfishProtocolData)->RedfishServiceIpMask[0] =3D RedfishServiceIpM= ask.Addr[0]; > + (*RedfishProtocolData)->RedfishServiceIpMask[1] =3D RedfishServiceIpM= ask.Addr[1]; > + (*RedfishProtocolData)->RedfishServiceIpMask[2] =3D RedfishServiceIpM= ask.Addr[2]; > + (*RedfishProtocolData)->RedfishServiceIpMask[3] =3D RedfishServiceIpM= ask.Addr[3]; > + > + (*RedfishProtocolData)->RedfishServiceIpPort =3D RedfishServiceIpPort= ; > + (*RedfishProtocolData)->RedfishServiceVlanId =3D 0xffffffff; > + > + (*RedfishProtocolData)->RedfishServiceHostnameLength =3D HostNameSize= ; > + AsciiStrCpyS ((CHAR8 *) ((*RedfishProtocolData)->RedfishServiceHostna= me), HostNameSize, RedfishHostName); > + > + return Status; > +} > + > +/** > + Construct Redfish host interface protocol data. > + > + @param ImageHandle The image handle. > + @param SystemTable The system table. > + > + @retval EFI_SUCEESS Install Boot manager menu success. > + @retval Other Return error status. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPlatformHostInterfaceConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > +) > +{ > + EFI_STATUS Status; > + > + Status =3D GetRedfishRecordFromVariable (&mRedfishOverIpProtocolData,= &mRedfishProtocolDataSize); > + DEBUG ((DEBUG_INFO, "%a: GetRedfishRecordFromVariable() - %r\n", __FU= NCTION__, Status)); > + if (!EFI_ERROR (Status)) { > + DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProt= ocolDataSize); > + } > + return EFI_SUCCESS; > +} > diff --git a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/Redfish= PlatformHostInterfaceLib.inf > b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHos= tInterfaceLib.inf > new file mode 100644 > index 0000000000..6fe5d9b32b > --- /dev/null > +++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatfor= mHostInterfaceLib.inf > @@ -0,0 +1,47 @@ > +## @file > +# NULL instance of RedfishPlatformHostInterfaceLib > +# > +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x0001000b > + BASE_NAME =3D RedfishPlatformHostInterfaceLib > + FILE_GUID =3D D5ECB7F2-4906-94E2-45B1-31BF4FD901= 22 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RedfishPlatformHostInterfaceLib > + CONSTRUCTOR =3D RedfishPlatformHostInterfaceConstr= uctor > +# > +# VALID_ARCHITECTURES =3D IA32 X64 > +# > + > +[Sources] > + RedfishPlatformHostInterfaceLib.c > + > +[Packages] > + EmulatorPkg/EmulatorPkg.dec > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + > +[LibraryClasses] > + UefiLib > + BaseLib > + BaseMemoryLib > + DebugLib > + PcdLib > + MemoryAllocationLib > + > +[Pcd] > + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceDevicePath = ## CONSUMES > + > +[Guids] > + gEmuRedfishServiceGuid > + > +[Depex] > + gEfiVariableArchProtocolGuid AND > + gEfiVariableWriteArchProtocolGuid > -- > 2.17.1 >=20 >=20 >=20 >=20 >=20