Skip to content

Commit

Permalink
RedfishClientPkg/RedfishMessageLib: add library to keep Redfish message
Browse files Browse the repository at this point in the history
Introduce new library to handle Redfish message. This library associate
Redfish message to corresponding Redfish URI. When Redfish resource is
ready for provisioning, driver can get all Redfish messages associated
with this Redfish URI and add them into provision data.

Signed-off-by: Nickle Wang <[email protected]>
  • Loading branch information
nicklela committed Oct 24, 2024
1 parent 0610c20 commit 8c9e4df
Show file tree
Hide file tree
Showing 5 changed files with 798 additions and 0 deletions.
86 changes: 86 additions & 0 deletions RedfishClientPkg/Include/Library/RedfishMessageLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/** @file
This file defines the Redfish message library interface.
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef REDFISH_MESSAGE_LIB_H_
#define REDFISH_MESSAGE_LIB_H_

#include <Uefi.h>

///
/// Definition of REDFISH_MESSAGE_SEVERITY
///
typedef enum {
RedfishMessageSeverityOk = 0x0,
RedfishMessageSeverityWarning,
RedfishMessageSeverityCritical,
RedfishMessageSeverityMax
} REDFISH_MESSAGE_SEVERITY;

typedef struct {
CHAR8 *Message;
CHAR8 *Resolution;
REDFISH_MESSAGE_SEVERITY MessageSeverity;
} REDFISH_MESSAGE_DATA;

/**
Add Redfish message to given resource URI.
@param[in] ResourceUri Report Redfish message to this resource URI.
@param[in] Message String message.
@param[in] Resolution Resolution message. This is optional.
@param[in] MessageSeverity Message severity.
@retval EFI_SUCCESS Redfish message is reported.
@retval Others Error occurs.
**/
EFI_STATUS
RedfishMessageReport (
IN EFI_STRING ResourceUri,
IN CHAR8 *Message,
IN CHAR8 *Resolution OPTIONAL,
IN REDFISH_MESSAGE_SEVERITY MessageSeverity
);

/**
Get all messages reported to given URI. It's caller's responsibility to release
MessageArray by calling RedfishMessageFree().
@param[in] TargetUri Report Redfish message to this resource URI.
@param[out] MessageArray The array of REDFISH_MESSAGE_DATA.
@param[out] MessageCount The number of REDFISH_MESSAGE_DATA in MessageArray.
@retval EFI_SUCCESS Redfish message is reported.
@retval Others Error occurs.
**/
EFI_STATUS
RedfishMessageGet (
IN EFI_STRING TargetUri,
OUT REDFISH_MESSAGE_DATA **MessageArray,
OUT UINTN *MessageCount
);

/**
Release MessageArray.
@param[in] MessageArray The array of REDFISH_MESSAGE_DATA.
@param[in] MessageCount The number of REDFISH_MESSAGE_DATA in MessageArray.
@retval EFI_SUCCESS Redfish message is released.
@retval Others Error occurs.
**/
EFI_STATUS
RedfishMessageFree (
IN REDFISH_MESSAGE_DATA *MessageArray,
IN UINTN MessageCount
);

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/** @file
Redfish message library internal header file.
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef REDFISH_MESSAGE_INTERNAL_H_
#define REDFISH_MESSAGE_INTERNAL_H_

#include <Uefi.h>
#include <RedfishBase.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/RedfishMessageLib.h>

#define REDFISH_MESSAGE_DEBUG DEBUG_ERROR
#define REDFISH_MESSAGE_MAX 0xFF

///
/// Definition of REDFISH_MESSAGE_RECORD
///
typedef struct {
LIST_ENTRY List;
CHAR8 *Message;
CHAR8 *Resolution;
REDFISH_MESSAGE_SEVERITY MessageSeverity;
} REDFISH_MESSAGE_RECORD;

#define REDFISH_MESSAGE_RECORD_FROM_LIST(a) BASE_CR (a, REDFISH_MESSAGE_RECORD, List)

///
/// Definition of REDFISH_MESSAGE_ENTRY
///
typedef struct {
LIST_ENTRY List;
EFI_STRING Uri;
LIST_ENTRY MessageHead;
UINTN Count;
} REDFISH_MESSAGE_ENTRY;

#define REDFISH_MESSAGE_ENTRY_FROM_LIST(a) BASE_CR (a, REDFISH_MESSAGE_ENTRY, List)

///
/// Definition of REDFISH_MESSAGE_INFO
///
typedef struct {
LIST_ENTRY ListHead;
UINTN Count;
} REDFISH_MESSAGE_PRIVATE;

#endif
Loading

0 comments on commit 8c9e4df

Please sign in to comment.