summaryrefslogtreecommitdiffstats
path: root/storagehandler.cpp
diff options
context:
space:
mode:
authoranil kumar appana <anil.kumarx.appana@intel.com>2019-05-27 18:10:23 +0000
committerVernon Mauery <vernon.mauery@linux.intel.com>2020-01-14 16:25:34 +0000
commit5b7c3266d3f8e49f48f1fed43caed078c8a8af8d (patch)
tree14c312f8adc6bdca11819baaed6021822ff4d731 /storagehandler.cpp
parentc665652df4c6d05f34ae1af49b2e7756629abbe3 (diff)
downloadphosphor-host-ipmid-5b7c3266d3f8e49f48f1fed43caed078c8a8af8d.tar.gz
phosphor-host-ipmid-5b7c3266d3f8e49f48f1fed43caed078c8a8af8d.zip
storagehandler: move read FRU data to new API
Rewrite "Read FRU Data" command to new IPMI provider API. Tested: 1. verified Read FRU data is same both before and after the changes ipmitool raw 0x0a 0x11 0x74 58 00 3 //request 03 32 36 31 //response Signed-off-by: anil kumar appana <anil.kumarx.appana@intel.com> Change-Id: I3bd497068462ee97a7b3fe648c3b0727f998bb0b
Diffstat (limited to 'storagehandler.cpp')
-rw-r--r--storagehandler.cpp60
1 files changed, 32 insertions, 28 deletions
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 437f858..d2bc8a5 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -662,59 +662,62 @@ ipmi::RspType<uint16_t, // FRU Inventory area size in bytes,
}
}
-// Read FRU data
-ipmi_ret_t ipmi_storage_read_fru_data(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 Read FRU Data command
+ * @param fruDeviceId - FRU device ID. FFh = reserved
+ * @param offset - FRU inventory offset to read
+ * @param readCount - count to read
+ *
+ * @return IPMI completion code plus response data
+ * - returnCount - response data count.
+ * - data - response data
+ */
+ipmi::RspType<uint8_t, // count returned
+ std::vector<uint8_t>> // FRU data
+ ipmiStorageReadFruData(uint8_t fruDeviceId, uint16_t offset,
+ uint8_t readCount)
{
- ipmi_ret_t rc = IPMI_CC_OK;
- const ReadFruDataRequest* reqptr =
- reinterpret_cast<const ReadFruDataRequest*>(request);
- auto resptr = reinterpret_cast<ReadFruDataResponse*>(response);
+ if (fruDeviceId == 0xFF)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
- auto iter = frus.find(reqptr->fruID);
+ auto iter = frus.find(fruDeviceId);
if (iter == frus.end())
{
- *data_len = 0;
- return IPMI_CC_SENSOR_INVALID;
+ return ipmi::responseSensorInvalid();
}
- auto offset =
- static_cast<uint16_t>(reqptr->offsetMS << 8 | reqptr->offsetLS);
try
{
- const auto& fruArea = getFruAreaData(reqptr->fruID);
+ const auto& fruArea = getFruAreaData(fruDeviceId);
auto size = fruArea.size();
if (offset >= size)
{
- return IPMI_CC_PARM_OUT_OF_RANGE;
+ return ipmi::responseParmOutOfRange();
}
// Write the count of response data.
- if ((offset + reqptr->count) <= size)
+ uint8_t returnCount;
+ if ((offset + readCount) <= size)
{
- resptr->count = reqptr->count;
+ returnCount = readCount;
}
else
{
- resptr->count = size - offset;
+ returnCount = size - offset;
}
- std::copy((fruArea.begin() + offset),
- (fruArea.begin() + offset + resptr->count), resptr->data);
+ std::vector<uint8_t> fruData((fruArea.begin() + offset),
+ (fruArea.begin() + offset + returnCount));
- *data_len = resptr->count + 1; // additional one byte for count
+ return ipmi::responseSuccess(returnCount, fruData);
}
catch (const InternalFailure& e)
{
- rc = IPMI_CC_UNSPECIFIED_ERROR;
- *data_len = 0;
log<level::ERR>(e.what());
+ return ipmi::responseUnspecifiedError();
}
- return rc;
}
ipmi::RspType<uint8_t, // SDR version
@@ -789,8 +792,9 @@ void register_netfn_storage_functions()
ipmi::Privilege::User, ipmiStorageGetFruInvAreaInfo);
// <READ FRU Data>
- ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_READ_FRU_DATA, NULL,
- ipmi_storage_read_fru_data, PRIVILEGE_USER);
+ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
+ ipmi::storage::cmdReadFruData,
+ ipmi::Privilege::Operator, ipmiStorageReadFruData);
// <Get Repository Info>
ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
OpenPOWER on IntegriCloud