[edk2-devel] [edk2-platforms][PATCH 2/3] IpmiFeaturePkg/IpmiCommandLib: Add IPMI functions
From: Abner Chang Add functions to get system UUID and LAN configuration parameter. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Nate DeSimone Cc: Liming Gao Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../IpmiCommandLib/IpmiCommandLibNetFnApp.c | 81 +++ .../IpmiCommandLibNetFnTransport.c| 36 + 2 files changed, 117 insertions(+) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c index addabc554e..e89ba27d15 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c @@ -2,6 +2,8 @@ IPMI Command - NetFnApp. Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved. + Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -245,3 +247,82 @@ IpmiSendMessage ( ); return Status; } + +/** + This function gets the system UUID. + + @param[out] SystemGuid The pointer to retrieve system UUID. + + @retval EFI_SUCCESS UUID is returned. + @retval EFI_INVALID_PARAMETER SystemGuid is a NULL pointer. + @retval OthersOther errors. + +**/ +EFI_STATUS +EFIAPI +IpmiGetSystemUuid ( + OUT EFI_GUID *SystemGuid + ) +{ + EFI_STATUS Status; + IPMI_GET_SYSTEM_UUID_RESPONSE GetSystemUuidResponse; + UINT32 RequestSize; + UINT32 ResponseSize; + + if (SystemGuid == NULL) { +return EFI_INVALID_PARAMETER; + } + RequestSize = 0; + ResponseSize = sizeof (IPMI_GET_SYSTEM_UUID_RESPONSE); + Status = IpmiSubmitCommand ( + IPMI_NETFN_APP, + IPMI_APP_GET_SYSTEM_GUID, + (VOID *)NULL, + RequestSize, + (VOID *)&GetSystemUuidResponse, + &ResponseSize + ); + if (!EFI_ERROR (Status) && GetSystemUuidResponse.CompletionCode == IPMI_COMP_CODE_NORMAL) { +CopyMem ( + (VOID *)SystemGuid, + (VOID *)&GetSystemUuidResponse.SystemUuid, + sizeof (EFI_GUID) + ); + } + return Status; +} + +/** + This function gets the channel information. + + @param[in] GetChannelInfoRequest The get channel information request. + @param[in] GetChannelInfoResponse The get channel information response. + @param[in,out] GetChannelInfoResponseSize When input, the expected size of response. + When output, the exact size of the returned + response. + + @retval EFI_SUCCESS Get channel information successfully. + @retval Others Other errors. + +**/ +EFI_STATUS +EFIAPI +IpmiGetChannelInfo ( + IN IPMI_GET_CHANNEL_INFO_REQUEST *GetChannelInfoRequest, + OUT IPMI_GET_CHANNEL_INFO_RESPONSE *GetChannelInfoResponse, + OUT UINT32 *GetChannelInfoResponseSize + ) +{ + EFI_STATUS Status; + + *GetChannelInfoResponseSize = sizeof (IPMI_GET_CHANNEL_INFO_RESPONSE); + Status = IpmiSubmitCommand ( + IPMI_NETFN_APP, + IPMI_APP_GET_CHANNEL_INFO, + (UINT8 *)GetChannelInfoRequest, + sizeof (IPMI_GET_CHANNEL_INFO_REQUEST), + (UINT8 *)GetChannelInfoResponse, + GetChannelInfoResponseSize + ); + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c index 7dfcf86126..135a905844 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c @@ -2,6 +2,8 @@ IPMI Command - NetFnTransport. Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved. + Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -78,3 +80,37 @@ IpmiGetSolConfigurationParameters ( ); return Status; } + +/** + This function gets the LAN configuration parameter. + + @param[in] GetLanConfigurationParametersRequest Request data + @param[in] GetLanConfigurationParametersResponse Response data + @param[in,out] GetLanConfigurationParametersSize When input, the expected size of response data. +When out, the exact size of response data. + + @retval EFI_SUCCESS Lan configuration parameter is returned in the response. + @retval Others Other errors. + +**/ + +EFI_STATUS +EFIAPI +IpmiGetLanConfigurationP
Re: [edk2-devel] [edk2-platforms][PATCH 2/3] IpmiFeaturePkg/IpmiCommandLib: Add IPMI functions
Reviewed-by: Isaac Oram If you are making changes, I would note/request improvement for: IpmiGetSystemUuid (); Please align local variable columns as is convention in this file. IpmiGetChannelInfo (); Should we check that input pointers are not null? Other functions don't, so I wouldn't block commit for this, but if you are fixing other things, it seems beneficial to add some error checking. Regards, Isaac -Original Message- From: devel@edk2.groups.io On Behalf Of Chang, Abner via groups.io Sent: Friday, December 23, 2022 5:27 AM To: devel@edk2.groups.io Cc: Oram, Isaac W ; Desimone, Nathaniel L ; Gao, Liming ; Nickle Wang ; Igor Kulchytskyy Subject: [edk2-devel] [edk2-platforms][PATCH 2/3] IpmiFeaturePkg/IpmiCommandLib: Add IPMI functions From: Abner Chang Add functions to get system UUID and LAN configuration parameter. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Nate DeSimone Cc: Liming Gao Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../IpmiCommandLib/IpmiCommandLibNetFnApp.c | 81 +++ .../IpmiCommandLibNetFnTransport.c| 36 + 2 files changed, 117 insertions(+) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c index addabc554e..e89ba27d15 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiComm +++ andLib/IpmiCommandLibNetFnApp.c @@ -2,6 +2,8 @@ IPMI Command - NetFnApp. Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved. + Copyright (C) 2022 Advanced Micro Devices, Inc. All rights + reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -245,3 +247,82 @@ IpmiSendMessage ( ); return Status; } + +/** + This function gets the system UUID. + + @param[out] SystemGuid The pointer to retrieve system UUID. + + @retval EFI_SUCCESS UUID is returned. + @retval EFI_INVALID_PARAMETER SystemGuid is a NULL pointer. + @retval OthersOther errors. + +**/ +EFI_STATUS +EFIAPI +IpmiGetSystemUuid ( + OUT EFI_GUID *SystemGuid + ) +{ + EFI_STATUS Status; + IPMI_GET_SYSTEM_UUID_RESPONSE GetSystemUuidResponse; + UINT32 RequestSize; + UINT32 ResponseSize; + + if (SystemGuid == NULL) { +return EFI_INVALID_PARAMETER; + } + RequestSize = 0; + ResponseSize = sizeof (IPMI_GET_SYSTEM_UUID_RESPONSE); + Status = IpmiSubmitCommand ( + IPMI_NETFN_APP, + IPMI_APP_GET_SYSTEM_GUID, + (VOID *)NULL, + RequestSize, + (VOID *)&GetSystemUuidResponse, + &ResponseSize + ); + if (!EFI_ERROR (Status) && GetSystemUuidResponse.CompletionCode == IPMI_COMP_CODE_NORMAL) { +CopyMem ( + (VOID *)SystemGuid, + (VOID *)&GetSystemUuidResponse.SystemUuid, + sizeof (EFI_GUID) + ); + } + return Status; +} + +/** + This function gets the channel information. + + @param[in] GetChannelInfoRequest The get channel information request. + @param[in] GetChannelInfoResponse The get channel information response. + @param[in,out] GetChannelInfoResponseSize When input, the expected size of response. + When output, the exact size of the returned + response. + + @retval EFI_SUCCESS Get channel information successfully. + @retval Others Other errors. + +**/ +EFI_STATUS +EFIAPI +IpmiGetChannelInfo ( + IN IPMI_GET_CHANNEL_INFO_REQUEST *GetChannelInfoRequest, + OUT IPMI_GET_CHANNEL_INFO_RESPONSE *GetChannelInfoResponse, + OUT UINT32 *GetChannelInfoResponseSize + ) +{ + EFI_STATUS Status; + + *GetChannelInfoResponseSize = sizeof +(IPMI_GET_CHANNEL_INFO_RESPONSE); + Status = IpmiSubmitCommand ( + IPMI_NETFN_APP, + IPMI_APP_GET_CHANNEL_INFO, + (UINT8 *)GetChannelInfoRequest, + sizeof (IPMI_GET_CHANNEL_INFO_REQUEST), + (UINT8 *)GetChannelInfoResponse, + GetChannelInfoResponseSize + ); + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c index 7dfcf86126..135a905844 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiComm +++ andLib/IpmiCommandLibNetFnTransport.c @@ -2,6 +2,8 @@ IPMI Command - NetFnTransport. Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved. + Cop