From e66c3b042c0cd2d94059fa93298e0ba52c92b248 Mon Sep 17 00:00:00 2001 From: Dhruvaraj Subhashchandran Date: Wed, 7 Feb 2018 01:21:56 -0600 Subject: Add Get Repository Info Command Adding support for Get Repository Info command, which returns information about the SDR repository. resolves openbmc/openbmc#2614 Change-Id: Id1219de8021b5403a775ad6e8577dbc8edfc60cb Signed-off-by: Dhruvaraj Subhashchandran --- storagehandler.cpp | 31 +++++++++++++++++++++++++++++++ storagehandler.h | 14 ++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/storagehandler.cpp b/storagehandler.cpp index 6ae2f91..59dfdde 100644 --- a/storagehandler.cpp +++ b/storagehandler.cpp @@ -11,6 +11,7 @@ #include #include +#include "fruread.hpp" #include "host-ipmid/ipmid-api.h" #include "read_fru_data.hpp" #include "selutility.hpp" @@ -24,6 +25,8 @@ void register_netfn_storage_functions() __attribute__((constructor)); unsigned int g_sel_time = 0xFFFFFFFF; extern unsigned short g_sel_reserve; +extern const ipmi::sensor::IdInfoMap sensors; +extern const FruMap frus; namespace { constexpr auto TIME_INTERFACE = "xyz.openbmc_project.Time.EpochTime"; @@ -673,6 +676,29 @@ ipmi_ret_t ipmi_storage_read_fru_data( return rc; } +ipmi_ret_t ipmi_get_repository_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, + ipmi_request_t request, ipmi_response_t response, + ipmi_data_len_t data_len, ipmi_context_t context) +{ + constexpr auto sdrVersion = 0x51; + auto responseData = + reinterpret_cast(response); + + memset(responseData, 0 , sizeof(GetRepositoryInfoResponse)); + + responseData->sdrVersion = sdrVersion; + + uint16_t records = frus.size() + sensors.size(); + responseData->recordCountMs = records >> 8; + responseData->recordCountLs = records; + + responseData->freeSpace[0] = 0xFF; + responseData->freeSpace[1] = 0xFF; + + *data_len = sizeof(GetRepositoryInfoResponse); + + return IPMI_CC_OK; +} void register_netfn_storage_functions() { @@ -731,6 +757,11 @@ void register_netfn_storage_functions() ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_READ_FRU_DATA, NULL, ipmi_storage_read_fru_data, PRIVILEGE_OPERATOR); + // + ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_REPOSITORY_INFO, + nullptr, ipmi_get_repository_info, + PRIVILEGE_USER); + ipmi::fru::registerCallbackHandler(); return; } diff --git a/storagehandler.h b/storagehandler.h index a971f77..497db82 100644 --- a/storagehandler.h +++ b/storagehandler.h @@ -6,6 +6,7 @@ enum ipmi_netfn_storage_cmds { // Get capability bits IPMI_CMD_GET_FRU_INV_AREA_INFO = 0x10, + IPMI_CMD_GET_REPOSITORY_INFO = 0x20, IPMI_CMD_READ_FRU_DATA = 0x11, IPMI_CMD_GET_SEL_INFO = 0x40, IPMI_CMD_RESERVE_SEL = 0x42, @@ -62,4 +63,17 @@ struct FruInvenAreaInfoResponse uint8_t access; ///< 0b Devices is accessed by bytes, 1b - by words }__attribute__ ((packed)); +/** + * @struct Get Repository info command response + */ +struct GetRepositoryInfoResponse +{ + uint8_t sdrVersion; //< SDR version + uint8_t recordCountLs; //< Record count LS byte + uint8_t recordCountMs; //< Record count MS bte + uint8_t freeSpace[2]; //< Free space in bytes, LS first + uint8_t additionTimestamp[4]; //< Most recent addition timestamp LS first + uint8_t deletionTimestamp[4]; //< Most recent deletion timestamp LS first + uint8_t operationSupport; //< Operation support +}__attribute__ ((packed)); #endif -- cgit v1.2.1