From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B941D7803D2 for ; Wed, 3 Jan 2024 07:54:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=A7iB8qErSP+F+LtJFpKunffWjG+gALY0cNxU69mvMfM=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1704268446; v=1; b=fi6SHTte6Ye2YYxE/lt4ZCYzyXi99gm0ctyyj3R10BpoOJJl1BHDilvLAySqNbyi77wfP5Gc tkk/2ljdb94Te/F3apznnQFmJpVvrqKSgqCTgxXU9X6acMOfKkG5oFM9z5MhWsjiAh7olWAt3/A YBQITpcPKlq5rr3DvOwnpCDk= X-Received: by 127.0.0.2 with SMTP id tKsjYY7687511xJsESAQBduj; Tue, 02 Jan 2024 23:54:06 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.42]) by mx.groups.io with SMTP id smtpd.web11.13202.1704268445501309594 for ; Tue, 02 Jan 2024 23:54:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nDzsUP51vwHMFONsNckzBkx0exFAdceWaQw7ITWmJCYpVIgL1r2Me0BJUODAW6p3Gjm6R85S+vyTQ/qsp6NFxVMyFvtzqNasBBFacCkfRILMPyI60jz6rJirHenaQx+f5GdiSwR6CWhT/Xlgj+OStaYYu0zpwk6i7ZKRAvGDMqTUH3l9sWSMpQBYjMr+amIiW7JBwQO9wrbkE9D53tE3jykWyg10XEqu3eW+8V27J3x0SaCgSur4YODdVW47TR+t/Y8UI3eCcWgQSYjCcaNLx5uOu56q1mYLoD97Mnt655urEzzjSoEZyezNdSE6ArCaUWjgB9c1guh2prj8rO0c3A== 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=dD6CHHyUBDiDEpf+xwC/dKhCCMtWR7im5V8EHeC+l+A=; b=QMZ+HuDfl+iu8/dgqPHLUA7oTk2UwL+R8JWAeQbBZBErnZEddbZbysc0Vc7fo74Ii2AGRYYN++EvKd58Ge7wCchBS2ZIHK2Wf4bMm8WURhSpyZ+lytA9rh31eQbDTJpiTACHCEI7IfK2PkMgtEuh3sIH1EaNbiyRwwuIV7eky4jr4byp1XaF2REnZDIDCtg3HfS01Fomo4uQEfMNganYSD/m/cpPTgWovLYnm6d6djvoLA/rhtPFleSfh7Y9bXxiybm1Hs3RcZ7xrmrRJyCHNyutn+FYioCMuWVvS3SJuWKT3DH37ORRfuJHA9fl3DfSCxIhNMMa+DfTbmGfU0XLcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from DS7PR03CA0334.namprd03.prod.outlook.com (2603:10b6:8:55::11) by DM6PR12MB4281.namprd12.prod.outlook.com (2603:10b6:5:21e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Wed, 3 Jan 2024 07:54:02 +0000 X-Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:8:55:cafe::60) by DS7PR03CA0334.outlook.office365.com (2603:10b6:8:55::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25 via Frontend Transport; Wed, 3 Jan 2024 07:54:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7159.9 via Frontend Transport; Wed, 3 Jan 2024 07:54:02 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 3 Jan 2024 01:54:00 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy , Mike Maslenkin Subject: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions Date: Wed, 3 Jan 2024 15:53:46 +0800 Message-ID: <20240103075346.2024-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003441:EE_|DM6PR12MB4281:EE_ X-MS-Office365-Filtering-Correlation-Id: 70f5982b-a286-413a-e501-08dc0c312717 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: nG4itmTZ8R4r18Dfe9BhYQykEn6BSO7afXneQggUKzv/EfkX2M7grXzoMZO4JeNSPgeBTvACY8f1ZKcREbzkWMMyCXHN6DEm3O7Y7gyrfWB8MspuzqyGxWpoSB56NI+Y76f0vf9d5YZE4dt0GO71ADv6ZzX9q9+ofh9VJ8gZkz2Nlh2dhxHNvSJQfCo+c44IZPWa9SeA+39U4XahfoHO2SZAnwt546SVZl43DUMEOhcnN2xKmAeARDGrCmSBnGRxvySyp+ELVLnvZhaALZgjnLtNJWOQsR/Y058a8/2IGY9wVZ4vTPhVKplowahnyXFruE7ICLdotxgb7cbxJgib9Z8PwkMJJt5XywXFU1GsQYVj1SC2I6bZRFCX39AHwTTq5VsTQ53WLNdehgeN87J9D2WYWo0HiwT/6hPSPjgqIS3nV0CAcK3tWE0O1olezMQsU9/8/BEMhyZZWYJPzHFDPIRbenfnXcV6edZl/ENabhhJZ1pdJ32FGC/ZeNM95NCkZdcJlJRAYYDQK1XuUSVt4fXAdCJ5mPloyT9YgLoSw3hBNDYvwJG2d1DGSuDQc9NvoHn1bMq0i8cJIcLKDQJQf2H1IRJdziMNwER7QU7p+/X4B/obSfdHkfof1kLjsIIjHNyJorkFIhU42HpOsATiyVKssGfeycRdsZTiquLKBmrV72rQHxifpWJdGthnS27berQzR+2z6aQJoeiXzn54samf4M3qsdgj+Lu36oUlgblh/olT5EcnKAob8RGkirOVtdTj6r/2B2OSGwsayMw69sCDNNXomC0K9Jf6vtR0HV+1oX/b4mu74eqb/iR32Msh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 07:54:02.7794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70f5982b-a286-413a-e501-08dc0c312717 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4281 Precedence: Bulk 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,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: iVp6DSWWBrOR5Cr719Q9Sux0x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=fi6SHTte; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Abner Chang Add PCD to disable ETag capability for the case Redfish service doesn't support ETag. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Cc: Mike Maslenkin --- RedfishClientPkg/RedfishClientPkg.dec | 2 + .../RedfishFeatureUtilityLib.inf | 1 + .../Library/RedfishFeatureUtilityLib.h | 46 +++- .../RedfishFeatureUtilityLib.c | 212 ++++++++++++------ 4 files changed, 180 insertions(+), 81 deletions(-) diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 5f8a03501d..155eea9812 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -75,6 +75,8 @@ gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID*|= 0x10000004 ## The number of seconds that the firmware will wait before system reboo= t gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout|5|UINT1= 6|0x20000002 + ## Default capability of Redfish service side ETAG support + gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishServiceEtagSupported|TRUE|B= OOLEAN|0x10000005 =20 [PcdsDynamicEx] ## The flag used to indicate that system reboot is required due to syste= m configuration change diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/Redfis= hFeatureUtilityLib.inf index fd66b8ac34..681c121a13 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf @@ -53,6 +53,7 @@ =20 [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired + gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishServiceEtagSupported =20 [Guids] =20 diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/= RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index 24f0ad2447..2f0833632c 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -100,7 +100,7 @@ CopyConfiglanguageList ( =20 /** =20 - Get number of node from the string. Node is seperated by '/'. + Get number of node from the string. Node is separated by '/'. =20 @param[in] NodeString The node string to parse. =20 @@ -578,6 +578,19 @@ GetEtagWithUri ( IN EFI_STRING Uri ); =20 +/** + + This function returns a boolean of ETAG support on Redfish service side. + + @retval TRUE ETAG is supported on Redfish service. + @retval FALSE ETAG is not supported on Redfish service. + +**/ +BOOLEAN +CheckIsServerEtagSupported ( + VOID + ); + /** =20 Get @odata.id from give HTTP payload. It's call responsibility to releas= e returned buffer. @@ -950,22 +963,33 @@ CompareRedfishPropertyVagueValues ( ); =20 /** + Find "ETag" from either HTTP header or Redfish response. =20 - Find "ETag" and "Location" from either HTTP header or Redfish response. + @param[in] Response HTTP response + @param[out] Etag String buffer to return ETag =20 - @param[in] Response HTTP response - @param[out] Etag String buffer to return ETag - @param[out] Location String buffer to return Location + @retval EFI_SUCCESS ETag is returned in Etag + @retval EFI_UNSUPPORTED ETag is unsupported + @retval EFI_INVALID_PARAMETER Response, Etag or both are NULL. =20 - @retval EFI_SUCCESS Data is found and returned. - @retval Others Errors occur. +**/ +EFI_STATUS +GetHttpResponseEtag ( + IN REDFISH_RESPONSE *Response, + OUT CHAR8 **Etag + ); + +/** + Find "Location" from either HTTP header or Redfish response. + + @param[in] Response HTTP response + @param[out] Location String buffer to return Location =20 **/ EFI_STATUS -GetEtagAndLocation ( - IN REDFISH_RESPONSE *Response, - OUT CHAR8 **Etag, OPTIONAL - OUT EFI_STRING *Location OPTIONAL +GetHttpResponseLocation ( + IN REDFISH_RESPONSE *Response, + OUT EFI_STRING *Location ); =20 /** diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index 01c054ae3b..a77758d0a2 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -133,6 +133,11 @@ SetEtagFromUri ( REDFISH_RESPONSE Response; EFI_STRING PendingSettingUri; =20 + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", __func__)= ); + return EFI_SUCCESS; + } + if ((RedfishService =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; } @@ -156,9 +161,9 @@ SetEtagFromUri ( // // Find etag in HTTP response header // - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); + Status =3D GetHttpResponseEtag (&Response, &Etag); + if (EFI_ERROR (Status) && (Status !=3D EFI_UNSUPPORTED)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to get ETag from HTTP header\n", __fu= nc__)); Status =3D EFI_NOT_FOUND; goto ON_RELEASE; } @@ -240,6 +245,11 @@ SetEtagWithUri ( EFI_STATUS Status; CHAR8 *AsciiUri; =20 + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", __func__)= ); + return EFI_SUCCESS; + } + if (IS_EMPTY_STRING (EtagStr) || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; } @@ -285,6 +295,11 @@ GetEtagWithUri ( return NULL; } =20 + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", __func__)= ); + return NULL; + } + Status =3D RedfishLocateProtocol ((VOID **)&mEtagProtocol, &gEdkIIRedfis= hETagProtocolGuid); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: fail to locate gEdkIIRedfishETagProtocolGuid= : %r\n", __func__, Status)); @@ -1785,44 +1800,39 @@ RedfishFeatureGetUnifiedArrayTypeConfigureLang ( } =20 /** + Find "ETag" from either HTTP header or Redfish response. =20 - Find "ETag" and "Location" from either HTTP header or Redfish response. + @param[in] Response HTTP response + @param[out] Etag String buffer to return ETag =20 - @param[in] Response HTTP response - @param[out] Etag String buffer to return ETag - @param[out] Location String buffer to return Location - - @retval EFI_SUCCESS Data is found and returned. - @retval Others Errors occur. + @retval EFI_SUCCESS ETag is returned in Etag + @retval EFI_UNSUPPORTED ETag is unsupported + @retval EFI_INVALID_PARAMETER Response, Etag or both are NULL. =20 **/ EFI_STATUS -GetEtagAndLocation ( - IN REDFISH_RESPONSE *Response, - OUT CHAR8 **Etag, OPTIONAL - OUT EFI_STRING *Location OPTIONAL +GetHttpResponseEtag ( + IN REDFISH_RESPONSE *Response, + OUT CHAR8 **Etag ) { + EFI_STATUS Status; EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE OdataValue; CHAR8 *OdataString; - CHAR8 *AsciiLocation; EFI_HTTP_HEADER *Header; - EFI_STATUS Status; =20 - if (Response =3D=3D NULL) { + if ((Response =3D=3D NULL) || (Etag =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 - if ((Etag =3D=3D NULL) && (Location =3D=3D NULL)) { - return EFI_SUCCESS; - } - Status =3D EFI_SUCCESS; - - if (Etag !=3D NULL) { - *Etag =3D NULL; - + *Etag =3D NULL; + if (!CheckIsServerEtagSupported ()) { + // Don't look for ETAG header or property in this case. + DEBUG ((DEBUG_INFO, "%a: WARNING - No ETag support on Redfish service.= \n", __func__)); + return EFI_UNSUPPORTED; + } else { if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers,= HTTP_HEADER_ETAG); if (Header !=3D NULL) { @@ -1852,51 +1862,94 @@ GetEtagAndLocation ( =20 if (*Etag =3D=3D NULL) { Status =3D EFI_NOT_FOUND; + DEBUG ((DEBUG_ERROR, "%a: Failed to retrieve ETag from HTTP response= paylaod.\n", __func__)); } } =20 - if (Location !=3D NULL) { - *Location =3D NULL; - AsciiLocation =3D NULL; + return Status; +} =20 - if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { - Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers,= HTTP_HEADER_LOCATION); - if (Header !=3D NULL) { - AsciiLocation =3D AllocateCopyPool (AsciiStrSize (Header->FieldVal= ue), Header->FieldValue); - ASSERT (AsciiLocation !=3D NULL); - } +/** + Find "Location" from either HTTP header or Redfish response. + + @param[in] Response HTTP response + @param[out] Location String buffer to return Location + +**/ +EFI_STATUS +GetHttpResponseLocation ( + IN REDFISH_RESPONSE *Response, + OUT EFI_STRING *Location + ) +{ + EFI_STATUS Status; + EDKII_JSON_VALUE JsonValue; + EDKII_JSON_VALUE OdataValue; + CHAR8 *OdataString; + CHAR8 *AsciiLocation; + EFI_HTTP_HEADER *Header; + + if ((Response =3D=3D NULL) || (Location =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_SUCCESS; + *Location =3D NULL; + AsciiLocation =3D NULL; + if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { + Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers, H= TTP_HEADER_LOCATION); + if (Header !=3D NULL) { + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (Header->FieldValue= ), Header->FieldValue); + ASSERT (AsciiLocation !=3D NULL); } + } =20 - // - // No header is returned. Search payload for location. - // - if ((*Location =3D=3D NULL) && (Response->Payload !=3D NULL)) { - JsonValue =3D RedfishJsonInPayload (Response->Payload); - if (JsonValue !=3D NULL) { - OdataValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue),= "@odata.id"); - if (OdataValue !=3D NULL) { - OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue); - if (OdataString !=3D NULL) { - AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataString)= , OdataString); - ASSERT (AsciiLocation !=3D NULL); - } + // + // No header is returned. Search payload for location. + // + if ((*Location =3D=3D NULL) && (Response->Payload !=3D NULL)) { + JsonValue =3D RedfishJsonInPayload (Response->Payload); + if (JsonValue !=3D NULL) { + OdataValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue), "= @odata.id"); + if (OdataValue !=3D NULL) { + OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue); + if (OdataString !=3D NULL) { + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataString), = OdataString); + ASSERT (AsciiLocation !=3D NULL); } - - JsonValueFree (JsonValue); } - } =20 - if (AsciiLocation !=3D NULL) { - *Location =3D StrAsciiToUnicode (AsciiLocation); - FreePool (AsciiLocation); - } else { - Status =3D EFI_NOT_FOUND; + JsonValueFree (JsonValue); } } =20 + if (AsciiLocation !=3D NULL) { + *Location =3D StrAsciiToUnicode (AsciiLocation); + FreePool (AsciiLocation); + } else { + Status =3D EFI_NOT_FOUND; + DEBUG ((DEBUG_ERROR, "%a: Failed to retrieve Location from HTTP respon= se paylaod.\n", __func__)); + } + return Status; } =20 +/** + + This function returns a boolean of ETAG support on Redfish service side. + + @retval TRUE ETAG is supported on Redfish service. + @retval FALSE ETAG is not supported on Redfish service. + +**/ +BOOLEAN +CheckIsServerEtagSupported ( + VOID + ) +{ + return FixedPcdGetBool (PcdRedfishServiceEtagSupported); +} + /** =20 Create HTTP payload and send them to redfish service with PATCH method. @@ -1915,15 +1968,15 @@ CreatePayloadToPatchResource ( IN REDFISH_SERVICE *Service, IN REDFISH_PAYLOAD *TargetPayload, IN CHAR8 *Json, - OUT CHAR8 **Etag + OUT CHAR8 **Etag OPTIONAL ) { REDFISH_PAYLOAD Payload; EDKII_JSON_VALUE ResourceJsonValue; - REDFISH_RESPONSE PostResponse; + REDFISH_RESPONSE PatchResponse; EFI_STATUS Status; =20 - if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json) || (Etag =3D=3D NULL)) { + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json)) { return EFI_INVALID_PARAMETER; } =20 @@ -1935,8 +1988,8 @@ CreatePayloadToPatchResource ( goto EXIT_FREE_JSON_VALUE; } =20 - ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); - Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PostResponse)= ; + ZeroMem (&PatchResponse, sizeof (REDFISH_RESPONSE)); + Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PatchResponse= ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a:%d Failed to PATCH payload to Redfish service= .\n", __func__, __LINE__)); =20 @@ -1944,7 +1997,7 @@ CreatePayloadToPatchResource ( DEBUG ((DEBUG_ERROR, "%a: Request:\n", __func__)); DumpRedfishPayload (DEBUG_ERROR, Payload); DEBUG ((DEBUG_ERROR, "%a: Response:\n", __func__)); - DumpRedfishResponse (__func__, DEBUG_ERROR, &PostResponse); + DumpRedfishResponse (__func__, DEBUG_ERROR, &PatchResponse); DEBUG_CODE_END (); goto EXIT_FREE_JSON_VALUE; } @@ -1952,16 +2005,20 @@ CreatePayloadToPatchResource ( // // Find ETag // - Status =3D GetEtagAndLocation (&PostResponse, Etag, NULL); - if (EFI_ERROR (Status)) { + Status =3D GetHttpResponseEtag (&PatchResponse, Etag); + if (Status =3D=3D EFI_UNSUPPORTED) { + Status =3D EFI_SUCCESS; + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported on Redfish se= rvice.\n", __func__)); + } else { Status =3D EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor proerty from= HTTP response payload.\n", __func__)); } =20 RedfishFreeResponse ( - PostResponse.StatusCode, - PostResponse.HeaderCount, - PostResponse.Headers, - PostResponse.Payload + PatchResponse.StatusCode, + PatchResponse.HeaderCount, + PatchResponse.Headers, + PatchResponse.Payload ); =20 EXIT_FREE_JSON_VALUE: @@ -1994,7 +2051,7 @@ CreatePayloadToPostResource ( IN REDFISH_PAYLOAD *TargetPayload, IN CHAR8 *Json, OUT EFI_STRING *Location, - OUT CHAR8 **Etag + OUT CHAR8 **Etag OPTIONAL ) { REDFISH_PAYLOAD Payload; @@ -2002,7 +2059,7 @@ CreatePayloadToPostResource ( REDFISH_RESPONSE PostResponse; EFI_STATUS Status; =20 - if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json) || (Location =3D=3D NULL) || (Etag =3D=3D NULL)) { + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json) || (Location =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 @@ -2029,12 +2086,22 @@ CreatePayloadToPostResource ( goto EXIT_FREE_JSON_VALUE; } =20 + Status =3D GetHttpResponseEtag (&PostResponse, Etag); + if (Status =3D=3D EFI_UNSUPPORTED) { + Status =3D EFI_SUCCESS; + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported on Redfish se= rvice.\n", __func__)); + } else if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a: Fail to get ETAG header nor ETAG propertyfro= m HTTP response payload.\n", __func__)); + } + // // per Redfish spec. the URL of new resource will be returned in "Locati= on" header. // - Status =3D GetEtagAndLocation (&PostResponse, Etag, Location); + Status =3D GetHttpResponseLocation (&PostResponse, Location); if (EFI_ERROR (Status)) { Status =3D EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor proerty from= HTTP response payload.\n", __func__)); } =20 RedfishFreeResponse ( @@ -3176,6 +3243,11 @@ CheckEtag ( { CHAR8 *EtagInDb; =20 + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported, always retur= ns FALSE to consume resource (Performance would be reduced).\n", __func__))= ; + return FALSE; + } + if (IS_EMPTY_STRING (Uri)) { return FALSE; } --=20 2.37.1.windows.1 -=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 (#113059): https://edk2.groups.io/g/devel/message/113059 Mute This Topic: https://groups.io/mt/103498331/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-