summaryrefslogtreecommitdiffstats
path: root/storagehandler.cpp
diff options
context:
space:
mode:
authorPradeep Kumar <pradeep1x.kumar@intel.com>2019-05-02 13:09:14 +0000
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-05-08 03:23:34 +0000
commitb0c794d83c6ed5ac25db7f93ba8be54c570f971b (patch)
treec088b95eaec7432777962703c558af46bb8e1f22 /storagehandler.cpp
parent94930a1147ffc3bfd8a8ee50c4513c58a1bd2b55 (diff)
downloadphosphor-host-ipmid-b0c794d83c6ed5ac25db7f93ba8be54c570f971b.tar.gz
phosphor-host-ipmid-b0c794d83c6ed5ac25db7f93ba8be54c570f971b.zip
storagehandler: move get FRU area info to new API
Rewritten "Get FRU inventory area info" command to use the newly introduced IPMI provider API. Tested: Unable to verify as command was returning error earlier too. Change-Id: I535e1d5c41a1e0dc253148bc52df5f22b70b4330 Signed-off-by: Pradeep Kumar <pradeep1x.kumar@intel.com> Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'storagehandler.cpp')
-rw-r--r--storagehandler.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 95a72e4..6f20835 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -651,43 +651,35 @@ ipmi_ret_t ipmi_storage_add_sel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
return rc;
}
-// Read FRU info area
-ipmi_ret_t ipmi_storage_get_fru_inv_area_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)
+/** @brief implements the get FRU Inventory Area Info command
+ *
+ * @returns IPMI completion code plus response data
+ * - FRU Inventory area size in bytes,
+ * - access bit
+ **/
+ipmi::RspType<uint16_t, // FRU Inventory area size in bytes,
+ uint8_t // access size (bytes / words)
+ >
+ ipmiStorageGetFruInvAreaInfo(uint8_t fruID)
{
- ipmi_ret_t rc = IPMI_CC_OK;
- const FruInvenAreaInfoRequest* reqptr =
- reinterpret_cast<const FruInvenAreaInfoRequest*>(request);
- auto iter = frus.find(reqptr->fruID);
+ auto iter = frus.find(fruID);
if (iter == frus.end())
{
- *data_len = 0;
- return IPMI_CC_SENSOR_INVALID;
+ return ipmi::responseSensorInvalid();
}
try
{
- const auto& fruArea = getFruAreaData(reqptr->fruID);
- auto size = static_cast<uint16_t>(fruArea.size());
- FruInvenAreaInfoResponse resp;
- resp.sizems = size >> 8;
- resp.sizels = size;
- resp.access = static_cast<uint8_t>(AccessMode::bytes);
-
- *data_len = sizeof(resp);
-
- // Pack the actual response
- std::memcpy(response, &resp, *data_len);
+ return ipmi::responseSuccess(
+ static_cast<uint16_t>(getFruAreaData(fruID).size()),
+ static_cast<uint8_t>(AccessMode::bytes));
}
catch (const InternalFailure& e)
{
- rc = IPMI_CC_UNSPECIFIED_ERROR;
- *data_len = 0;
log<level::ERR>(e.what());
+ return ipmi::responseUnspecifiedError();
}
- return rc;
}
// Read FRU data
@@ -810,9 +802,9 @@ void register_netfn_storage_functions()
clearSEL);
// <Get FRU Inventory Area Info>
- ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_FRU_INV_AREA_INFO, NULL,
- ipmi_storage_get_fru_inv_area_info,
- PRIVILEGE_OPERATOR);
+ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
+ ipmi::storage::cmdGetFruInventoryAreaInfo,
+ ipmi::Privilege::User, ipmiStorageGetFruInvAreaInfo);
// <Add READ FRU Data
ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_READ_FRU_DATA, NULL,
OpenPOWER on IntegriCloud