blob: 98f696ca24fefb274ccbb0c863f09ca4b0fe9bba [file] [log] [blame]
Deepak Kodihalli70e8db02019-10-21 00:59:46 -05001#include "fru.hpp"
2
Deepak Kodihallid130e1a2020-06-17 05:55:32 -05003#include "common/utils.hpp"
Deepak Kodihalli70e8db02019-10-21 00:59:46 -05004
George Liuc453e162022-12-21 17:16:23 +08005#include <libpldm/entity.h>
6#include <libpldm/utils.h>
Deepak Kodihalli70e8db02019-10-21 00:59:46 -05007#include <systemd/sd-journal.h>
8
Riya Dixit49cfb132023-03-02 04:26:53 -06009#include <phosphor-logging/lg2.hpp>
Deepak Kodihalli70e8db02019-10-21 00:59:46 -050010#include <sdbusplus/bus.hpp>
Deepak Kodihalli70e8db02019-10-21 00:59:46 -050011
George Liu6492f522020-06-16 10:34:05 +080012#include <iostream>
George Liu5bfb0dc2021-05-01 14:28:41 +080013#include <optional>
George Liu6492f522020-06-16 10:34:05 +080014#include <set>
George Liu5bfb0dc2021-05-01 14:28:41 +080015#include <stack>
George Liu077fea22020-04-08 16:47:14 +080016
Riya Dixit49cfb132023-03-02 04:26:53 -060017PHOSPHOR_LOG2_USING;
18
Deepak Kodihalli70e8db02019-10-21 00:59:46 -050019namespace pldm
20{
Deepak Kodihalli70e8db02019-10-21 00:59:46 -050021namespace responder
22{
George Liu5bfb0dc2021-05-01 14:28:41 +080023
24constexpr auto root = "/xyz/openbmc_project/inventory/";
25
26std::optional<pldm_entity>
27 FruImpl::getEntityByObjectPath(const dbus::InterfaceMap& intfMaps)
28{
29 for (const auto& intfMap : intfMaps)
30 {
31 try
32 {
33 pldm_entity entity{};
34 entity.entity_type = parser.getEntityType(intfMap.first);
35 return entity;
36 }
37 catch (const std::exception& e)
38 {
39 continue;
40 }
41 }
42
43 return std::nullopt;
44}
45
46void FruImpl::updateAssociationTree(const dbus::ObjectValueTree& objects,
47 const std::string& path)
48{
49 if (path.find(root) == std::string::npos)
50 {
51 return;
52 }
53
54 std::stack<std::string> tmpObjPaths{};
55 tmpObjPaths.emplace(path);
56
57 auto obj = pldm::utils::findParent(path);
58 while ((obj + '/') != root)
59 {
60 tmpObjPaths.emplace(obj);
61 obj = pldm::utils::findParent(obj);
62 }
63
64 std::stack<std::string> tmpObj = tmpObjPaths;
65 while (!tmpObj.empty())
66 {
67 std::string s = tmpObj.top();
Riya Dixit797f3382023-08-22 22:27:51 -050068 info("{TMP_OBJ_STR}", "TMP_OBJ_PATH", s);
George Liu5bfb0dc2021-05-01 14:28:41 +080069 tmpObj.pop();
70 }
71 // Update pldm entity to assocition tree
72 std::string prePath = tmpObjPaths.top();
73 while (!tmpObjPaths.empty())
74 {
75 std::string currPath = tmpObjPaths.top();
76 tmpObjPaths.pop();
77
78 do
79 {
80 if (objToEntityNode.contains(currPath))
81 {
82 pldm_entity node =
83 pldm_entity_extract(objToEntityNode.at(currPath));
Manojkiran Eda8e715ae2021-07-04 21:46:43 +053084 if (pldm_entity_association_tree_find_with_locality(
85 entityTree, &node, false))
George Liu5bfb0dc2021-05-01 14:28:41 +080086 {
87 break;
88 }
89 }
90 else
91 {
92 if (!objects.contains(currPath))
93 {
94 break;
95 }
96
97 auto entityPtr = getEntityByObjectPath(objects.at(currPath));
98 if (!entityPtr)
99 {
100 break;
101 }
102
103 pldm_entity entity = *entityPtr;
104
105 for (auto& it : objToEntityNode)
106 {
107 pldm_entity node = pldm_entity_extract(it.second);
108 if (node.entity_type == entity.entity_type)
109 {
110 entity.entity_instance_num = node.entity_instance_num +
111 1;
112 break;
113 }
114 }
115
116 if (currPath == prePath)
117 {
Manojkiran Eda8e715ae2021-07-04 21:46:43 +0530118 auto node = pldm_entity_association_tree_add_entity(
George Liu5bfb0dc2021-05-01 14:28:41 +0800119 entityTree, &entity, 0xFFFF, nullptr,
Manojkiran Eda8e715ae2021-07-04 21:46:43 +0530120 PLDM_ENTITY_ASSOCIAION_PHYSICAL, false, true, 0xFFFF);
George Liu5bfb0dc2021-05-01 14:28:41 +0800121 objToEntityNode[currPath] = node;
122 }
123 else
124 {
125 if (objToEntityNode.contains(prePath))
126 {
Manojkiran Eda8e715ae2021-07-04 21:46:43 +0530127 auto node = pldm_entity_association_tree_add_entity(
George Liu5bfb0dc2021-05-01 14:28:41 +0800128 entityTree, &entity, 0xFFFF,
129 objToEntityNode[prePath],
Manojkiran Eda8e715ae2021-07-04 21:46:43 +0530130 PLDM_ENTITY_ASSOCIAION_PHYSICAL, false, true,
131 0xFFFF);
George Liu5bfb0dc2021-05-01 14:28:41 +0800132 objToEntityNode[currPath] = node;
133 }
134 }
135 }
136 } while (0);
137
138 prePath = currPath;
139 }
140}
141
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530142void FruImpl::buildFRUTable()
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500143{
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530144 if (isBuilt)
145 {
146 return;
147 }
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500148
Tom Josephf0076332020-02-06 10:18:50 +0530149 fru_parser::DBusLookupInfo dbusInfo;
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500150 // Read the all the inventory D-Bus objects
151 auto& bus = pldm::utils::DBusHandler::getBus();
152 dbus::ObjectValueTree objects;
153
154 try
155 {
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530156 dbusInfo = parser.inventoryLookup();
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500157 auto method = bus.new_method_call(
158 std::get<0>(dbusInfo).c_str(), std::get<1>(dbusInfo).c_str(),
159 "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
vkaverap@in.ibm.com9138c202023-05-19 07:50:47 -0500160 auto reply = bus.call(
161 method,
162 std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500163 reply.read(objects);
164 }
165 catch (const std::exception& e)
166 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600167 error(
168 "Look up of inventory objects failed and PLDM FRU table creation failed");
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500169 return;
170 }
171
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500172 auto itemIntfsLookup = std::get<2>(dbusInfo);
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500173
174 for (const auto& object : objects)
175 {
176 const auto& interfaces = object.second;
Sridevi Ramesheefe49b2022-06-27 11:51:02 -0500177 bool isPresent = pldm::utils::checkForFruPresence(object.first.str);
178 // Do not create fru record if fru is not present.
179 // Pick up the next available fru.
180 if (!isPresent)
181 {
182 continue;
183 }
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500184 for (const auto& interface : interfaces)
185 {
186 if (itemIntfsLookup.find(interface.first) != itemIntfsLookup.end())
187 {
188 // An exception will be thrown by getRecordInfo, if the item
189 // D-Bus interface name specified in FRU_Master.json does
190 // not have corresponding config jsons
191 try
192 {
George Liu5bfb0dc2021-05-01 14:28:41 +0800193 updateAssociationTree(objects, object.first.str);
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500194 pldm_entity entity{};
George Liu5bfb0dc2021-05-01 14:28:41 +0800195 if (objToEntityNode.contains(object.first.str))
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500196 {
George Liu5bfb0dc2021-05-01 14:28:41 +0800197 pldm_entity_node* node =
198 objToEntityNode.at(object.first.str);
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500199
George Liu5bfb0dc2021-05-01 14:28:41 +0800200 entity = pldm_entity_extract(node);
201 }
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500202
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530203 auto recordInfos = parser.getRecordInfo(interface.first);
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500204 populateRecords(interfaces, recordInfos, entity);
George Liuc4ea6a92020-07-14 15:48:44 +0800205
206 associatedEntityMap.emplace(object.first, entity);
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500207 break;
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500208 }
209 catch (const std::exception& e)
210 {
Riya Dixit797f3382023-08-22 22:27:51 -0500211 error(
Riya Dixit49cfb132023-03-02 04:26:53 -0600212 "Config JSONs missing for the item interface type, interface = {INTF}",
213 "INTF", interface.first);
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500214 break;
215 }
216 }
217 }
218 }
219
Andrew Jefferyb0ba34d2023-07-17 17:47:16 +0930220 int rc = pldm_entity_association_pdr_add_check(entityTree, pdrRepo, false,
221 TERMINUS_HANDLE);
222 if (rc < 0)
223 {
224 // pldm_entity_assocation_pdr_add() assert()ed on failure
225 error("Failed to add PLDM entity association PDR: {LIBPLDM_ERROR}",
226 "LIBPLDM_ERROR", rc);
227 throw std::runtime_error("Failed to add PLDM entity association PDR");
228 }
229
Sampa Misrac073a202021-05-08 10:56:05 -0500230 // save a copy of bmc's entity association tree
231 pldm_entity_association_tree_copy_root(entityTree, bmcEntityTree);
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500232
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500233 if (table.size())
234 {
Sridevi Ramesheefe49b2022-06-27 11:51:02 -0500235 padBytes = pldm::utils::getNumPadBytes(table.size());
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500236 table.resize(table.size() + padBytes, 0);
237
238 // Calculate the checksum
George Liu077fea22020-04-08 16:47:14 +0800239 checksum = crc32(table.data(), table.size());
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500240 }
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530241 isBuilt = true;
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500242}
Pavithra Barithaya47180ac2020-10-28 02:12:05 -0500243std::string FruImpl::populatefwVersion()
244{
245 static constexpr auto fwFunctionalObjPath =
246 "/xyz/openbmc_project/software/functional";
247 auto& bus = pldm::utils::DBusHandler::getBus();
248 std::string currentBmcVersion;
249 try
250 {
Patrick Williams6da4f912023-05-10 07:50:53 -0500251 auto method = bus.new_method_call(pldm::utils::mapperService,
252 fwFunctionalObjPath,
253 pldm::utils::dbusProperties, "Get");
Pavithra Barithaya47180ac2020-10-28 02:12:05 -0500254 method.append("xyz.openbmc_project.Association", "endpoints");
255 std::variant<std::vector<std::string>> paths;
vkaverap@in.ibm.com9138c202023-05-19 07:50:47 -0500256 auto reply = bus.call(
257 method,
258 std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
Pavithra Barithaya47180ac2020-10-28 02:12:05 -0500259 reply.read(paths);
260 auto fwRunningVersion = std::get<std::vector<std::string>>(paths)[0];
261 constexpr auto versionIntf = "xyz.openbmc_project.Software.Version";
262 auto version = pldm::utils::DBusHandler().getDbusPropertyVariant(
263 fwRunningVersion.c_str(), "Version", versionIntf);
264 currentBmcVersion = std::get<std::string>(version);
265 }
266 catch (const std::exception& e)
267 {
Riya Dixit49cfb132023-03-02 04:26:53 -0600268 error("failed to make a d-bus call Asociation, ERROR= {ERR_EXCEP}",
269 "ERR_EXCEP", e.what());
Pavithra Barithaya47180ac2020-10-28 02:12:05 -0500270 return {};
271 }
272 return currentBmcVersion;
273}
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500274void FruImpl::populateRecords(
275 const pldm::responder::dbus::InterfaceMap& interfaces,
Deepak Kodihalli3cd61812020-03-10 06:38:45 -0500276 const fru_parser::FruRecordInfos& recordInfos, const pldm_entity& entity)
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500277{
278 // recordSetIdentifier for the FRU will be set when the first record gets
279 // added for the FRU
280 uint16_t recordSetIdentifier = 0;
281 auto numRecsCount = numRecs;
Pavithra Barithaya4f2538a2021-03-05 07:32:15 -0600282 static uint32_t bmc_record_handle = 0;
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500283
Patrick Williams6da4f912023-05-10 07:50:53 -0500284 for (const auto& [recType, encType, fieldInfos] : recordInfos)
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500285 {
286 std::vector<uint8_t> tlvs;
287 uint8_t numFRUFields = 0;
Patrick Williams6da4f912023-05-10 07:50:53 -0500288 for (const auto& [intf, prop, propType, fieldTypeNum] : fieldInfos)
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500289 {
290 try
291 {
Pavithra Barithaya47180ac2020-10-28 02:12:05 -0500292 pldm::responder::dbus::Value propValue;
Manojkiran Eda2b7c1bf2021-09-09 12:26:00 +0530293
294 // Assuming that 0 container Id is assigned to the System (as
295 // that should be the top most container as per dbus hierarchy)
296 if (entity.entity_container_id == 0 && prop == "Version")
Pavithra Barithaya47180ac2020-10-28 02:12:05 -0500297 {
298 propValue = populatefwVersion();
299 }
300 else
301 {
302 propValue = interfaces.at(intf).at(prop);
303 }
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500304 if (propType == "bytearray")
305 {
306 auto byteArray = std::get<std::vector<uint8_t>>(propValue);
307 if (!byteArray.size())
308 {
309 continue;
310 }
311
312 numFRUFields++;
313 tlvs.emplace_back(fieldTypeNum);
314 tlvs.emplace_back(byteArray.size());
315 std::move(std::begin(byteArray), std::end(byteArray),
316 std::back_inserter(tlvs));
317 }
318 else if (propType == "string")
319 {
320 auto str = std::get<std::string>(propValue);
321 if (!str.size())
322 {
323 continue;
324 }
325
326 numFRUFields++;
327 tlvs.emplace_back(fieldTypeNum);
328 tlvs.emplace_back(str.size());
329 std::move(std::begin(str), std::end(str),
330 std::back_inserter(tlvs));
331 }
332 }
333 catch (const std::out_of_range& e)
334 {
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500335 continue;
336 }
337 }
338
339 if (tlvs.size())
340 {
341 if (numRecs == numRecsCount)
342 {
343 recordSetIdentifier = nextRSI();
Pavithra Barithaya4f2538a2021-03-05 07:32:15 -0600344 bmc_record_handle = nextRecordHandle();
Andrew Jeffery2e248e82023-07-03 17:23:24 +0930345 int rc = pldm_pdr_add_fru_record_set_check(
Manojkiran Edacc5f1582021-09-29 17:03:06 +0530346 pdrRepo, TERMINUS_HANDLE, recordSetIdentifier,
347 entity.entity_type, entity.entity_instance_num,
Andrew Jeffery2e248e82023-07-03 17:23:24 +0930348 entity.entity_container_id, &bmc_record_handle);
349 if (rc)
350 {
351 // pldm_pdr_add_fru_record_set() assert()ed on failure
352 throw std::runtime_error(
353 "Failed to add PDR FRU record set");
354 }
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500355 }
356 auto curSize = table.size();
357 table.resize(curSize + recHeaderSize + tlvs.size());
358 encode_fru_record(table.data(), table.size(), &curSize,
359 recordSetIdentifier, recType, numFRUFields,
360 encType, tlvs.data(), tlvs.size());
361 numRecs++;
362 }
363 }
364}
365
366void FruImpl::getFRUTable(Response& response)
367{
368 auto hdrSize = response.size();
369
370 response.resize(hdrSize + table.size() + sizeof(checksum), 0);
371 std::copy(table.begin(), table.end(), response.begin() + hdrSize);
372
373 // Copy the checksum to response data
374 auto iter = response.begin() + hdrSize + table.size();
375 std::copy_n(reinterpret_cast<const uint8_t*>(&checksum), sizeof(checksum),
376 iter);
377}
378
John Wang9e82ad12020-06-12 10:53:32 +0800379int FruImpl::getFRURecordByOption(std::vector<uint8_t>& fruData,
380 uint16_t /* fruTableHandle */,
381 uint16_t recordSetIdentifer,
382 uint8_t recordType, uint8_t fieldType)
383{
Manojkiran Eda31a78442021-09-12 15:18:25 +0530384 using sum = uint32_t;
385
John Wang9e82ad12020-06-12 10:53:32 +0800386 // FRU table is built lazily, build if not done.
387 buildFRUTable();
388
389 /* 7 is sizeof(checksum,4) + padBytesMax(3)
390 * We can not know size of the record table got by options in advance, but
391 * it must be less than the source table. So it's safe to use sizeof the
392 * source table + 7 as the buffer length
393 */
394 size_t recordTableSize = table.size() - padBytes + 7;
395 fruData.resize(recordTableSize, 0);
396
Andrew Jeffery663783b2023-07-03 12:58:14 +0930397 int rc = get_fru_record_by_option_check(
398 table.data(), table.size() - padBytes, fruData.data(), &recordTableSize,
399 recordSetIdentifer, recordType, fieldType);
John Wang9e82ad12020-06-12 10:53:32 +0800400
Andrew Jeffery663783b2023-07-03 12:58:14 +0930401 if (rc != PLDM_SUCCESS || recordTableSize == 0)
John Wang9e82ad12020-06-12 10:53:32 +0800402 {
403 return PLDM_FRU_DATA_STRUCTURE_TABLE_UNAVAILABLE;
404 }
405
Sridevi Ramesheefe49b2022-06-27 11:51:02 -0500406 auto pads = pldm::utils::getNumPadBytes(recordTableSize);
Manojkiran Eda31a78442021-09-12 15:18:25 +0530407 crc32(fruData.data(), recordTableSize + pads);
John Wang9e82ad12020-06-12 10:53:32 +0800408
409 auto iter = fruData.begin() + recordTableSize + pads;
410 std::copy_n(reinterpret_cast<const uint8_t*>(&checksum), sizeof(checksum),
411 iter);
412 fruData.resize(recordTableSize + pads + sizeof(sum));
413
414 return PLDM_SUCCESS;
415}
416
Deepak Kodihallie60c5822019-10-23 03:26:15 -0500417namespace fru
418{
Deepak Kodihallie60c5822019-10-23 03:26:15 -0500419Response Handler::getFRURecordTableMetadata(const pldm_msg* request,
420 size_t /*payloadLength*/)
421{
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530422 // FRU table is built lazily, build if not done.
423 buildFRUTable();
424
Deepak Kodihallie60c5822019-10-23 03:26:15 -0500425 constexpr uint8_t major = 0x01;
426 constexpr uint8_t minor = 0x00;
427 constexpr uint32_t maxSize = 0xFFFFFFFF;
428
429 Response response(sizeof(pldm_msg_hdr) +
430 PLDM_GET_FRU_RECORD_TABLE_METADATA_RESP_BYTES,
431 0);
432 auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
433
434 auto rc = encode_get_fru_record_table_metadata_resp(
435 request->hdr.instance_id, PLDM_SUCCESS, major, minor, maxSize,
436 impl.size(), impl.numRSI(), impl.numRecords(), impl.checkSum(),
437 responsePtr);
438 if (rc != PLDM_SUCCESS)
439 {
440 return ccOnlyResponse(request, rc);
441 }
442
443 return response;
444}
445
446Response Handler::getFRURecordTable(const pldm_msg* request,
447 size_t payloadLength)
448{
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530449 // FRU table is built lazily, build if not done.
450 buildFRUTable();
451
Deepak Kodihallie60c5822019-10-23 03:26:15 -0500452 if (payloadLength != PLDM_GET_FRU_RECORD_TABLE_REQ_BYTES)
453 {
454 return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
455 }
456
457 Response response(
458 sizeof(pldm_msg_hdr) + PLDM_GET_FRU_RECORD_TABLE_MIN_RESP_BYTES, 0);
459 auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
460
Patrick Williams6da4f912023-05-10 07:50:53 -0500461 auto rc = encode_get_fru_record_table_resp(request->hdr.instance_id,
462 PLDM_SUCCESS, 0,
463 PLDM_START_AND_END, responsePtr);
Deepak Kodihallie60c5822019-10-23 03:26:15 -0500464 if (rc != PLDM_SUCCESS)
465 {
466 return ccOnlyResponse(request, rc);
467 }
468
469 impl.getFRUTable(response);
470
471 return response;
472}
473
John Wang9e82ad12020-06-12 10:53:32 +0800474Response Handler::getFRURecordByOption(const pldm_msg* request,
475 size_t payloadLength)
476{
477 if (payloadLength != sizeof(pldm_get_fru_record_by_option_req))
478 {
479 return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
480 }
481
482 uint32_t retDataTransferHandle{};
483 uint16_t retFruTableHandle{};
484 uint16_t retRecordSetIdentifier{};
485 uint8_t retRecordType{};
486 uint8_t retFieldType{};
487 uint8_t retTransferOpFlag{};
488
489 auto rc = decode_get_fru_record_by_option_req(
490 request, payloadLength, &retDataTransferHandle, &retFruTableHandle,
491 &retRecordSetIdentifier, &retRecordType, &retFieldType,
492 &retTransferOpFlag);
493
494 if (rc != PLDM_SUCCESS)
495 {
496 return ccOnlyResponse(request, rc);
497 }
498
499 std::vector<uint8_t> fruData;
500 rc = impl.getFRURecordByOption(fruData, retFruTableHandle,
501 retRecordSetIdentifier, retRecordType,
502 retFieldType);
503 if (rc != PLDM_SUCCESS)
504 {
505 return ccOnlyResponse(request, rc);
506 }
507
Patrick Williams6da4f912023-05-10 07:50:53 -0500508 auto respPayloadLength = PLDM_GET_FRU_RECORD_BY_OPTION_MIN_RESP_BYTES +
509 fruData.size();
John Wang9e82ad12020-06-12 10:53:32 +0800510 Response response(sizeof(pldm_msg_hdr) + respPayloadLength, 0);
511 auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
512
513 rc = encode_get_fru_record_by_option_resp(
514 request->hdr.instance_id, PLDM_SUCCESS, 0, PLDM_START_AND_END,
515 fruData.data(), fruData.size(), responsePtr, respPayloadLength);
516
517 if (rc != PLDM_SUCCESS)
518 {
519 return ccOnlyResponse(request, rc);
520 }
521
522 return response;
523}
524
Deepak Kodihallie60c5822019-10-23 03:26:15 -0500525} // namespace fru
526
Deepak Kodihalli70e8db02019-10-21 00:59:46 -0500527} // namespace responder
528
529} // namespace pldm