diff options
author | jayaprakash Mutyala <mutyalax.jayaprakash@intel.com> | 2019-05-02 21:13:30 +0000 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2019-07-25 04:49:25 +0000 |
commit | b755772f87f0be2b034d04ae0e2f29062bcbb9f3 (patch) | |
tree | 64cd8f1d78ec05d2da7e96b65d682bc02d987fdb | |
parent | 77381f15bdee2bf867337a3ad6c7e2aaed93b2f5 (diff) | |
download | phosphor-host-ipmid-b755772f87f0be2b034d04ae0e2f29062bcbb9f3.tar.gz phosphor-host-ipmid-b755772f87f0be2b034d04ae0e2f29062bcbb9f3.zip |
storagehandler: move get & reserve SEL to new API
Rewrite "Get sel info & Reserve SEL" commands to use the new API.
Tested:
1. verified ipmitool sel info is same both before and
after the changes
Command: ipmitool sel info
Output:
SEL Information
Version : 1.5 (v1.5, v2 compliant)
Entries : 0
Free Space : 65535 bytes or more
Percent Used : unknown
Last Add Time : Not Available
Last Del Time : Not Available
Overflow : false
Supported Cmds : 'Delete' 'Reserve'
Command: ipmitool raw 0x0a 0x40
Output: 51 00 00 ff ff ff ff ff ff ff ff ff ff 0a
2. verfied the Reserve SEL command
ipmitool raw 0x0a 0x42
01 00
ipmitool raw 0x0a 0x42
02 00
Change-Id: I37d602293066274a3fc417ad7e59cea3c73315f7
Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
-rw-r--r-- | selutility.hpp | 24 | ||||
-rw-r--r-- | storagehandler.cpp | 102 |
2 files changed, 61 insertions, 65 deletions
diff --git a/selutility.hpp b/selutility.hpp index bf16a5c..49ec1b7 100644 --- a/selutility.hpp +++ b/selutility.hpp @@ -33,27 +33,21 @@ using PropertyType = static constexpr auto selVersion = 0x51; static constexpr auto invalidTimeStamp = 0xFFFFFFFF; -static constexpr auto operationSupport = 0x0A; - -/** @struct GetSELInfoResponse - * - * IPMI payload for Get SEL Info command response. - */ -struct GetSELInfoResponse -{ - uint8_t selVersion; //!< SEL revision. - uint16_t entries; //!< Number of log entries in SEL. - uint16_t freeSpace; //!< Free Space in bytes. - uint32_t addTimeStamp; //!< Most recent addition timestamp. - uint32_t eraseTimeStamp; //!< Most recent erase timestamp. - uint8_t operationSupport; //!< Operation support. -} __attribute__((packed)); static constexpr auto firstEntry = 0x0000; static constexpr auto lastEntry = 0xFFFF; static constexpr auto entireRecord = 0xFF; static constexpr auto selRecordSize = 16; +namespace operationSupport +{ +static constexpr bool overflow = false; +static constexpr bool deleteSel = true; +static constexpr bool partialAddSelEntry = false; +static constexpr bool reserveSel = true; +static constexpr bool getSelAllocationInfo = false; +} // namespace operationSupport + /** @struct GetSELEntryRequest * * IPMI payload for Get SEL Entry command request. diff --git a/storagehandler.cpp b/storagehandler.cpp index d86b273..8bfde05 100644 --- a/storagehandler.cpp +++ b/storagehandler.cpp @@ -81,24 +81,34 @@ ipmi_ret_t ipmi_storage_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd, return rc; } -ipmi_ret_t getSELInfo(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) -{ - if (*data_len != 0) - { - *data_len = 0; - return IPMI_CC_REQ_DATA_LEN_INVALID; - } - - std::vector<uint8_t> outPayload(sizeof(ipmi::sel::GetSELInfoResponse)); - auto responseData = - reinterpret_cast<ipmi::sel::GetSELInfoResponse*>(outPayload.data()); +/** @brief implements the get SEL Info command + * @returns IPMI completion code plus response data + * - selVersion - SEL revision + * - entries - Number of log entries in SEL. + * - freeSpace - Free Space in bytes. + * - addTimeStamp - Most recent addition timestamp + * - eraseTimeStamp - Most recent erase timestamp + * - operationSupport - Reserve & Delete SEL operations supported + */ - responseData->selVersion = ipmi::sel::selVersion; - // Last erase timestamp is not available from log manager. - responseData->eraseTimeStamp = ipmi::sel::invalidTimeStamp; - responseData->operationSupport = ipmi::sel::operationSupport; +ipmi::RspType<uint8_t, // SEL revision. + uint16_t, // number of log entries in SEL. + uint16_t, // free Space in bytes. + uint32_t, // most recent addition timestamp + uint32_t, // most recent erase timestamp. + + bool, // SEL allocation info supported + bool, // reserve SEL supported + bool, // partial Add SEL Entry supported + bool, // delete SEL supported + uint3_t, // reserved + bool // overflow flag + > + ipmiStorageGetSelInfo() +{ + uint16_t entries = 0; + // Most recent addition timestamp. + uint32_t addTimeStamp = ipmi::sel::invalidTimeStamp; try { @@ -112,16 +122,13 @@ ipmi_ret_t getSELInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, // as 0. } - responseData->entries = 0; - responseData->addTimeStamp = ipmi::sel::invalidTimeStamp; - if (!cache::paths.empty()) { - responseData->entries = static_cast<uint16_t>(cache::paths.size()); + entries = static_cast<uint16_t>(cache::paths.size()); try { - responseData->addTimeStamp = static_cast<uint32_t>( + addTimeStamp = static_cast<uint32_t>( (ipmi::sel::getEntryTimeStamp(cache::paths.back()).count())); } catch (InternalFailure& e) @@ -133,10 +140,18 @@ ipmi_ret_t getSELInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, } } - std::memcpy(response, outPayload.data(), outPayload.size()); - *data_len = outPayload.size(); + constexpr uint8_t selVersion = ipmi::sel::selVersion; + constexpr uint16_t freeSpace = 0xFFFF; + constexpr uint32_t eraseTimeStamp = ipmi::sel::invalidTimeStamp; + constexpr uint3_t reserved{0}; - return IPMI_CC_OK; + return ipmi::responseSuccess( + selVersion, entries, freeSpace, addTimeStamp, eraseTimeStamp, + ipmi::sel::operationSupport::getSelAllocationInfo, + ipmi::sel::operationSupport::reserveSel, + ipmi::sel::operationSupport::partialAddSelEntry, + ipmi::sel::operationSupport::deleteSel, reserved, + ipmi::sel::operationSupport::overflow); } ipmi_ret_t getSELEntry(ipmi_netfn_t netfn, ipmi_cmd_t cmd, @@ -559,27 +574,13 @@ ipmi::RspType<> ipmiStorageSetSelTime(uint32_t selDeviceTime) return ipmi::responseSuccess(); } -ipmi_ret_t ipmi_storage_reserve_sel(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) +/** @brief implements the reserve SEL command + * @returns IPMI completion code plus response data + * - SEL reservation ID. + */ +ipmi::RspType<uint16_t> ipmiStorageReserveSel() { - if (*data_len != 0) - { - *data_len = 0; - return IPMI_CC_REQ_DATA_LEN_INVALID; - } - - ipmi_ret_t rc = IPMI_CC_OK; - unsigned short selResID = reserveSel(); - - *data_len = sizeof(selResID); - - // Pack the actual response - std::memcpy(response, &selResID, *data_len); - - return rc; + return ipmi::responseSuccess(reserveSel()); } /** @brief implements the Add SEL entry command @@ -738,8 +739,9 @@ void register_netfn_storage_functions() ipmi_storage_wildcard, PRIVILEGE_USER); // <Get SEL Info> - ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SEL_INFO, NULL, - getSELInfo, PRIVILEGE_USER); + ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, + ipmi::storage::cmdGetSelInfo, ipmi::Privilege::User, + ipmiStorageGetSelInfo); // <Get SEL Time> ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, @@ -752,9 +754,9 @@ void register_netfn_storage_functions() ipmi::Privilege::Operator, ipmiStorageSetSelTime); // <Reserve SEL> - ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_RESERVE_SEL, NULL, - ipmi_storage_reserve_sel, PRIVILEGE_USER); - + ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, + ipmi::storage::cmdReserveSel, ipmi::Privilege::User, + ipmiStorageReserveSel); // <Get SEL Entry> ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SEL_ENTRY, NULL, getSELEntry, PRIVILEGE_USER); |