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 8AD77D8118F for ; Fri, 5 Jan 2024 11:33:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6YMLAk0YolvQ9VRXtqeXEKUQO5IYG//HDCC4kmWWM3w=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1704454433; v=1; b=KH8nYFdF6UgFWjleStldLyQ0avrrg4TX4TUfgmulVMxsaOlTjAeWkj/41pgmISi04RTqPSAt rIT6tc8aqLRYYK6JS0HgMHghGMKdt+Lpxx9rrRyKH/ZLspehY/U7/lg9mkcHJPYBry/Xdlb1Y78 LyIYAAU58IGw7dx0Y0tp0EVw= X-Received: by 127.0.0.2 with SMTP id a6hCYY7687511x9X41PIACFY; Fri, 05 Jan 2024 03:33:53 -0800 X-Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by mx.groups.io with SMTP id smtpd.web11.21582.1704454432473286021 for ; Fri, 05 Jan 2024 03:33:52 -0800 X-Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-dbd73ac40ecso1352511276.1 for ; Fri, 05 Jan 2024 03:33:52 -0800 (PST) X-Gm-Message-State: VTOMaE2G1PAB94xqIUgzwSAyx7686176AA= X-Google-Smtp-Source: AGHT+IFp0sjRWz+5ZEoDvhsBKi/jXVcldqzUJIHd3OHkYaO4PJkcUUjSa+3uXQe6oPRD79NVqjfGhhRkf4FB5qRs6QE= X-Received: by 2002:a25:8746:0:b0:dbd:b599:19a1 with SMTP id e6-20020a258746000000b00dbdb59919a1mr2048070ybn.73.1704454431398; Fri, 05 Jan 2024 03:33:51 -0800 (PST) MIME-Version: 1.0 References: <20240104085651.41-1-abner.chang@amd.com> In-Reply-To: From: "Mike Maslenkin" Date: Fri, 5 Jan 2024 14:33:15 +0300 Message-ID: Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions To: "Chang, Abner" Cc: "devel@edk2.groups.io" , Nickle Wang , Igor Kulchytskyy 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,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=KH8nYFdF; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) Hi Abner, Thank you for the clarification. Regards, Mike. On Fri, Jan 5, 2024 at 12:03=E2=80=AFPM Chang, Abner = wrote: > > [AMD Official Use Only - General] > > Hi Mike, > This PCD is introduced for the platform that connects to the Redfish serv= ice which doesn't support ETag. > We disable the client code that handles ETag with setting this PCD to FAL= SE. So client will just consume any Redfish property from service even ther= e is nothing changed. This knob doesn't control Redfish service behavior on= BMC. > Yes, there is no method to detect if Redfish service supports ETag or not= . So we introduce a client side knob to disable ETag checking although it m= entions the service "should" support ETag in Redfish spec. However, a simpl= e Redfish services may not implementing ETag HTTP header. > Does above clarify the question? > > Thanks > Abner > > > -----Original Message----- > > From: Mike Maslenkin > > Sent: Friday, January 5, 2024 8:20 AM > > To: devel@edk2.groups.io; Chang, Abner > > Cc: Nickle Wang ; Igor Kulchytskyy > > Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClient= Pkg: > > Add ETag PCD and revise Redfish ETag functions > > > > Caution: This message originated from an External Source. Use proper ca= ution > > when opening attachments, clicking links, or responding. > > > > > > Looks good to me. > > > > But could it be possible to rephrase "ETAG is not supported on Redfish > > service." ? > > May be I misunderstand, but I assume "Redfish service" is a service at > > BMC side, while we are disabling ETAG functionality at Redfish client > > side. > > README.md says "Redfish service hosted by Board Management Controller > > (BMC) in server". > > Currently there is no method to get server features (AFAIR), so we > > disable a work with those explicitly on the client side. > > > > Regards, > > Mike. > > > > On Thu, Jan 4, 2024 at 11:57=E2=80=AFAM Chang, Abner via groups.io > > wrote: > > > > > > 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 +++- > > > .../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 18 +- > > > .../v1_0_4/Common/BootOptionCommon.c | 4 +- > > > .../BootOption/v1_0_4/Dxe/BootOptionDxe.c | 16 +- > > > .../v1_5_0/Dxe/ComputerSystemDxe.c | 16 +- > > > .../Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 16 +- > > > .../RedfishFeatureUtilityLib.c | 208 ++++++++++++----= -- > > > 9 files changed, 197 insertions(+), 130 deletions(-) > > > > > > diff --git a/RedfishClientPkg/RedfishClientPkg.dec > > b/RedfishClientPkg/RedfishClientPkg.dec > > > index b350facae0..8adef327fb 100644 > > > --- a/RedfishClientPkg/RedfishClientPkg.dec > > > +++ b/RedfishClientPkg/RedfishClientPkg.dec > > > @@ -76,6 +76,8 @@ > > > > > gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID* > > |0x10000004 > > > ## The number of seconds that the firmware will wait before system= reboot > > > > > gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout|5|UI > > NT16|0x20000002 > > > + ## Default capability of Redfish service side ETAG support > > > + > > gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishServiceEtagSupported|TRUE| > > BOOLEAN|0x10000005 > > > > > > [PcdsDynamicEx] > > > ## The flag used to indicate that system reboot is required due to= system > > configuration change > > > diff --git > > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.i > > nf > > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.i > > nf > > > index 718273b248..fde6a176d0 100644 > > > --- > > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.i > > nf > > > +++ > > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.i > > nf > > > @@ -54,6 +54,7 @@ > > > > > > [Pcd] > > > gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired > > > + gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishServiceEtagSupported > > > > > > [Guids] > > > > > > diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLi= b.h > > b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > > > index 9513a65617..834ea0fcfe 100644 > > > --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > > > +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > > > @@ -81,7 +81,7 @@ CopyConfiglanguageList ( > > > > > > /** > > > > > > - Get number of node from the string. Node is seperated by '/'. > > > + Get number of node from the string. Node is separated by '/'. > > > > > > @param[in] NodeString The node string to parse. > > > > > > @@ -559,6 +559,19 @@ GetEtagWithUri ( > > > IN EFI_STRING Uri > > > ); > > > > > > +/** > > > + > > > + 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 > > > + ); > > > + > > > /** > > > > > > Get @odata.id from give HTTP payload. It's call responsibility to = release > > returned buffer. > > > @@ -931,22 +944,33 @@ CompareRedfishPropertyVagueValues ( > > > ); > > > > > > /** > > > + Find "ETag" from either HTTP header or Redfish response. > > > > > > - Find "ETag" and "Location" from either HTTP header or Redfish resp= onse. > > > + @param[in] Response HTTP response > > > + @param[out] Etag String buffer to return ETag > > > > > > - @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. > > > > > > - @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 > > > > > > **/ > > > 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 > > > ); > > > > > > /** > > > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > > b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > > > index 2a49c5cd22..14e854c861 100644 > > > --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > > > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > > > @@ -153,14 +153,10 @@ RedfishResourceConsumeResource ( > > > ASSERT (Private->Json !=3D NULL); > > > > > > // > > > - // Find etag in HTTP response header > > > + // Searching for etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (ExpectedResponse, &Etag); > > > Status =3D RedfishConsumeResourceCommon (Private, Private->Json, E= tag); > > > if (EFI_ERROR (Status)) { > > > if (Status !=3D EFI_ALREADY_STARTED) { > > > @@ -365,12 +361,8 @@ RedfishResourceCheck ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (&Response, &Etag); > > > Status =3D RedfishCheckResourceCommon (Private, Private->Json, Eta= g); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\= n", > > __func__, Uri, Status)); > > > diff --git > > a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > > mon.c > > b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > > mon.c > > > index 0d4c2162c6..0b9a72abc3 100644 > > > --- > > a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > > mon.c > > > +++ > > b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > > mon.c > > > @@ -455,9 +455,9 @@ RedfishProvisioningResourceCommon ( > > > } > > > > > > // > > > - // per Redfish spec. the URL of new resource will be returned in "= Location" > > header. > > > + // Per Redfish spec. the URL of new resource will be returned in "= Location" > > header. > > > // > > > - Status =3D GetEtagAndLocation (&Response, NULL, &NewResourceLocati= on); > > > + Status =3D GetHttpResponseLocation (&Response, &NewResourceLocatio= n); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __fun= c__, > > Status)); > > > goto RELEASE_RESOURCE; > > > diff --git > > a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > > b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > > > index ba090c51d3..204c6b0757 100644 > > > --- a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > > > +++ > > b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > > > @@ -154,12 +154,8 @@ RedfishResourceConsumeResource ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (ExpectedResponse, &Etag); > > > Status =3D RedfishConsumeResourceCommon (Private, Private->Json, E= tag); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: > > %r\n", __func__, Private->Uri, Status)); > > > @@ -358,12 +354,8 @@ RedfishResourceCheck ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (&Response, &Etag); > > > Status =3D RedfishCheckResourceCommon (Private, Private->Json, Eta= g); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: failed to check > > resource from: %s: %r\n", __func__, Uri, Status)); > > > diff --git > > a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste > > mDxe.c > > b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste > > mDxe.c > > > index 0bbaa92bf4..7805bcf36b 100644 > > > --- > > a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste > > mDxe.c > > > +++ > > b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste > > mDxe.c > > > @@ -149,12 +149,8 @@ RedfishResourceConsumeResource ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (ExpectedResponse, &Etag); > > > Status =3D RedfishConsumeResourceCommon (Private, Private->Json, E= tag); > > > if (EFI_ERROR (Status)) { > > > if (Status !=3D EFI_ALREADY_STARTED) { > > > @@ -359,12 +355,8 @@ RedfishResourceCheck ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (&Response, &Etag); > > > Status =3D RedfishCheckResourceCommon (Private, Private->Json, Eta= g); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\= n", > > __func__, Uri, Status)); > > > diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > > b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > > > index 9230078051..b87da775b3 100644 > > > --- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > > > +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > > > @@ -149,12 +149,8 @@ RedfishResourceConsumeResource ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (ExpectedResponse, &Etag); > > > Status =3D RedfishConsumeResourceCommon (Private, Private->Json, E= tag); > > > if (EFI_ERROR (Status)) { > > > if (Status !=3D EFI_ALREADY_STARTED) { > > > @@ -359,12 +355,8 @@ RedfishResourceCheck ( > > > // > > > // Find etag in HTTP response header > > > // > > > - Etag =3D NULL; > > > - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); > > > - if (EFI_ERROR (Status)) { > > > - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n"= , > > __func__)); > > > - } > > > - > > > + Etag =3D NULL; > > > + GetHttpResponseEtag (&Response, &Etag); > > > Status =3D RedfishCheckResourceCommon (Private, Private->Json, Eta= g); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\= n", > > __func__, Uri, Status)); > > > diff --git > > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib. > > c > > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib. > > c > > > index 1c2d40f622..7709a9d1a2 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; > > > > > > + 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; > > > } > > > @@ -157,9 +162,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"= , > > __func__)); > > > + 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"= , > > __func__)); > > > Status =3D EFI_NOT_FOUND; > > > goto ON_RELEASE; > > > } > > > @@ -241,6 +246,11 @@ SetEtagWithUri ( > > > EFI_STATUS Status; > > > CHAR8 *AsciiUri; > > > > > > + 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; > > > } > > > @@ -286,6 +296,11 @@ GetEtagWithUri ( > > > return NULL; > > > } > > > > > > + if (!CheckIsServerEtagSupported ()) { > > > + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", > > __func__)); > > > + return NULL; > > > + } > > > + > > > Status =3D RedfishLocateProtocol ((VOID **)&mEtagProtocol, > > &gEdkIIRedfishETagProtocolGuid); > > > if (EFI_ERROR (Status)) { > > > DEBUG ((DEBUG_ERROR, "%a: fail to locate > > gEdkIIRedfishETagProtocolGuid: %r\n", __func__, Status)); > > > @@ -1726,44 +1741,39 @@ > > RedfishFeatureGetUnifiedArrayTypeConfigureLang ( > > > } > > > > > > /** > > > + Find "ETag" from either HTTP header or Redfish response. > > > > > > - Find "ETag" and "Location" from either HTTP header or Redfish resp= onse. > > > + @param[in] Response HTTP response > > > + @param[out] Etag String buffer to return ETag > > > > > > - @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. > > > > > > **/ > > > 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; > > > > > > - if (Response =3D=3D NULL) { > > > + if ((Response =3D=3D NULL) || (Etag =3D=3D NULL)) { > > > return EFI_INVALID_PARAMETER; > > > } > > > > > > - 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) { > > > @@ -1793,51 +1803,94 @@ GetEtagAndLocation ( > > > > > > if (*Etag =3D=3D NULL) { > > > Status =3D EFI_NOT_FOUND; > > > + DEBUG ((DEBUG_ERROR, "%a: Failed to retrieve ETag from HTTP > > response paylaod.\n", __func__)); > > > } > > > } > > > > > > - if (Location !=3D NULL) { > > > - *Location =3D NULL; > > > - AsciiLocation =3D NULL; > > > + return Status; > > > +} > > > > > > - 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->Fi= eldValue), > > 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->Head= ers, > > HTTP_HEADER_LOCATION); > > > + if (Header !=3D NULL) { > > > + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (Header->Fiel= dValue), > > Header->FieldValue); > > > + 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 (JsonV= alue), > > "@odata.id"); > > > - if (OdataValue !=3D NULL) { > > > - OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataVal= ue); > > > - if (OdataString !=3D NULL) { > > > - AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataS= tring), > > 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 (JsonVal= ue), > > "@odata.id"); > > > + if (OdataValue !=3D NULL) { > > > + OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue= ); > > > + if (OdataString !=3D NULL) { > > > + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataStr= ing), > > OdataString); > > > + ASSERT (AsciiLocation !=3D NULL); > > > } > > > - > > > - JsonValueFree (JsonValue); > > > } > > > - } > > > > > > - if (AsciiLocation !=3D NULL) { > > > - *Location =3D StrAsciiToUnicode (AsciiLocation); > > > - FreePool (AsciiLocation); > > > - } else { > > > - Status =3D EFI_NOT_FOUND; > > > + JsonValueFree (JsonValue); > > > } > > > } > > > > > > + 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 > > response paylaod.\n", __func__)); > > > + } > > > + > > > return Status; > > > } > > > > > > +/** > > > + > > > + 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); > > > +} > > > + > > > /** > > > > > > Create HTTP payload and send them to redfish service with PATCH me= thod. > > > @@ -1861,7 +1914,7 @@ CreatePayloadToPatchResource ( > > > { > > > REDFISH_PAYLOAD Payload; > > > EDKII_JSON_VALUE ResourceJsonValue; > > > - REDFISH_RESPONSE PostResponse; > > > + REDFISH_RESPONSE PatchResponse; > > > EFI_STATUS Status; > > > > > > if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMP= TY_STRING > > (Json)) { > > > @@ -1876,8 +1929,8 @@ CreatePayloadToPatchResource ( > > > goto EXIT_FREE_JSON_VALUE; > > > } > > > > > > - ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); > > > - Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PostRes= ponse); > > > + 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__)); > > > > > > @@ -1885,7 +1938,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; > > > } > > > @@ -1893,16 +1946,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 service.\n", __func__)); > > > + } else { > > > Status =3D EFI_DEVICE_ERROR; > > > + DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor proert= y > > from HTTP response payload.\n", __func__)); > > > } > > > > > > RedfishFreeResponse ( > > > - PostResponse.StatusCode, > > > - PostResponse.HeaderCount, > > > - PostResponse.Headers, > > > - PostResponse.Payload > > > + PatchResponse.StatusCode, > > > + PatchResponse.HeaderCount, > > > + PatchResponse.Headers, > > > + PatchResponse.Payload > > > ); > > > > > > EXIT_FREE_JSON_VALUE: > > > @@ -1935,7 +1992,7 @@ CreatePayloadToPostResource ( > > > IN REDFISH_PAYLOAD *TargetPayload, > > > IN CHAR8 *Json, > > > OUT EFI_STRING *Location, > > > - OUT CHAR8 **Etag > > > + OUT CHAR8 **Etag OPTIONAL > > > ) > > > { > > > REDFISH_PAYLOAD Payload; > > > @@ -1943,7 +2000,7 @@ CreatePayloadToPostResource ( > > > REDFISH_RESPONSE PostResponse; > > > EFI_STATUS Status; > > > > > > - if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMP= TY_STRING > > (Json) || (Location =3D=3D NULL) || (Etag =3D=3D NULL)) { > > > + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMP= TY_STRING > > (Json) || (Location =3D=3D NULL)) { > > > return EFI_INVALID_PARAMETER; > > > } > > > > > > @@ -1970,12 +2027,22 @@ CreatePayloadToPostResource ( > > > goto EXIT_FREE_JSON_VALUE; > > > } > > > > > > + 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 service.\n", __func__)); > > > + } else if (EFI_ERROR (Status)) { > > > + Status =3D EFI_DEVICE_ERROR; > > > + DEBUG ((DEBUG_ERROR, "%a: Fail to get ETAG header nor ETAG > > propertyfrom HTTP response payload.\n", __func__)); > > > + } > > > + > > > // > > > // per Redfish spec. the URL of new resource will be returned in "= Location" > > 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 proert= y > > from HTTP response payload.\n", __func__)); > > > } > > > > > > RedfishFreeResponse ( > > > @@ -3117,6 +3184,11 @@ CheckEtag ( > > > { > > > CHAR8 *EtagInDb; > > > > > > + if (!CheckIsServerEtagSupported ()) { > > > + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported, always > > returns FALSE to consume resource (Performance would be reduced).\n", > > __func__)); > > > + return FALSE; > > > + } > > > + > > > if (IS_EMPTY_STRING (Uri)) { > > > return FALSE; > > > } > > > -- > > > 2.37.1.windows.1 > > > > > > > > > > > >=20 > > > > > > -=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 (#113275): https://edk2.groups.io/g/devel/message/113275 Mute This Topic: https://groups.io/mt/103519287/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-