Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions #68

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

Expand Down Expand Up @@ -153,14 +154,10 @@ RedfishResourceConsumeResource (
ASSERT (Private->Json != NULL);

//
// Find etag in HTTP response header
// Searching for etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (ExpectedResponse, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (ExpectedResponse, &Etag);
Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
if (Status != EFI_ALREADY_STARTED) {
Expand Down Expand Up @@ -365,12 +362,8 @@ RedfishResourceCheck (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (&Response, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (&Response, &Etag);
Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __func__, Uri, Status));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

Expand Down Expand Up @@ -455,9 +456,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 = GetEtagAndLocation (&Response, NULL, &NewResourceLocation);
Status = GetHttpResponseLocation (&Response, &NewResourceLocation);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, Status));
goto RELEASE_RESOURCE;
Expand Down
17 changes: 5 additions & 12 deletions RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

Expand Down Expand Up @@ -154,12 +155,8 @@ RedfishResourceConsumeResource (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (ExpectedResponse, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (ExpectedResponse, &Etag);
Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", __func__, Private->Uri, Status));
Expand Down Expand Up @@ -358,12 +355,8 @@ RedfishResourceCheck (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (&Response, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (&Response, &Etag);
Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: failed to check resource from: %s: %r\n", __func__, Uri, Status));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

Expand Down Expand Up @@ -149,12 +150,8 @@ RedfishResourceConsumeResource (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (ExpectedResponse, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (ExpectedResponse, &Etag);
Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
if (Status != EFI_ALREADY_STARTED) {
Expand Down Expand Up @@ -359,12 +356,8 @@ RedfishResourceCheck (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (&Response, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (&Response, &Etag);
Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __func__, Uri, Status));
Expand Down
17 changes: 5 additions & 12 deletions RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

Expand Down Expand Up @@ -149,12 +150,8 @@ RedfishResourceConsumeResource (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (ExpectedResponse, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (ExpectedResponse, &Etag);
Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
if (Status != EFI_ALREADY_STARTED) {
Expand Down Expand Up @@ -359,12 +356,8 @@ RedfishResourceCheck (
//
// Find etag in HTTP response header
//
Etag = NULL;
Status = GetEtagAndLocation (&Response, &Etag, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
}

Etag = NULL;
GetHttpResponseEtag (&Response, &Etag);
Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __func__, Uri, Status));
Expand Down
47 changes: 36 additions & 11 deletions RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

(C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

Expand Down Expand Up @@ -81,7 +82,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.

Expand Down Expand Up @@ -559,6 +560,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.
Expand Down Expand Up @@ -931,22 +945,33 @@ CompareRedfishPropertyVagueValues (
);

/**
Find "ETag" from either HTTP header or Redfish response.

Find "ETag" and "Location" from either HTTP header or Redfish response.
@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
);

/**
Expand Down
Loading