Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 1 | #include "fru.hpp" |
| 2 | |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 3 | #include "common/utils.hpp" |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 4 | |
Manojkiran Eda | cc5f158 | 2021-09-29 17:03:06 +0530 | [diff] [blame] | 5 | #include <config.h> |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 6 | #include <libpldm/entity.h> |
| 7 | #include <libpldm/utils.h> |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 8 | #include <systemd/sd-journal.h> |
| 9 | |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 10 | #include <sdbusplus/bus.hpp> |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 11 | |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 12 | #include <iostream> |
| 13 | #include <set> |
George Liu | 077fea2 | 2020-04-08 16:47:14 +0800 | [diff] [blame] | 14 | |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 15 | namespace pldm |
| 16 | { |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 17 | namespace responder |
| 18 | { |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 19 | void FruImpl::buildFRUTable() |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 20 | { |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 21 | if (isBuilt) |
| 22 | { |
| 23 | return; |
| 24 | } |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 25 | |
Tom Joseph | f007633 | 2020-02-06 10:18:50 +0530 | [diff] [blame] | 26 | fru_parser::DBusLookupInfo dbusInfo; |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 27 | // Read the all the inventory D-Bus objects |
| 28 | auto& bus = pldm::utils::DBusHandler::getBus(); |
| 29 | dbus::ObjectValueTree objects; |
| 30 | |
| 31 | try |
| 32 | { |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 33 | dbusInfo = parser.inventoryLookup(); |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 34 | auto method = bus.new_method_call( |
| 35 | std::get<0>(dbusInfo).c_str(), std::get<1>(dbusInfo).c_str(), |
| 36 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| 37 | auto reply = bus.call(method); |
| 38 | reply.read(objects); |
| 39 | } |
| 40 | catch (const std::exception& e) |
| 41 | { |
| 42 | std::cerr << "Look up of inventory objects failed and PLDM FRU table " |
Brad Bishop | 0b54073 | 2021-08-18 09:42:41 -0400 | [diff] [blame] | 43 | "creation failed\n"; |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 44 | return; |
| 45 | } |
| 46 | |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 47 | auto itemIntfsLookup = std::get<2>(dbusInfo); |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 48 | |
| 49 | for (const auto& object : objects) |
| 50 | { |
| 51 | const auto& interfaces = object.second; |
Sridevi Ramesh | eefe49b | 2022-06-27 11:51:02 -0500 | [diff] [blame] | 52 | bool isPresent = pldm::utils::checkForFruPresence(object.first.str); |
| 53 | // Do not create fru record if fru is not present. |
| 54 | // Pick up the next available fru. |
| 55 | if (!isPresent) |
| 56 | { |
| 57 | continue; |
| 58 | } |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 59 | for (const auto& interface : interfaces) |
| 60 | { |
| 61 | if (itemIntfsLookup.find(interface.first) != itemIntfsLookup.end()) |
| 62 | { |
| 63 | // An exception will be thrown by getRecordInfo, if the item |
| 64 | // D-Bus interface name specified in FRU_Master.json does |
| 65 | // not have corresponding config jsons |
| 66 | try |
| 67 | { |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 68 | pldm_entity entity{}; |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 69 | entity.entity_type = parser.getEntityType(interface.first); |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 70 | pldm_entity_node* parent = nullptr; |
| 71 | auto parentObj = pldm::utils::findParent(object.first.str); |
| 72 | // To add a FRU to the entity association tree, we need to |
| 73 | // determine if the FRU has a parent (D-Bus object). For eg |
| 74 | // /system/backplane's parent is /system. /system has no |
| 75 | // parent. Some D-Bus pathnames might just be namespaces |
| 76 | // (not D-Bus objects), so we need to iterate upwards until |
| 77 | // a parent is found, or we reach the root ("/"). |
| 78 | // Parents are always added first before children in the |
| 79 | // entity association tree. We're relying on the fact that |
| 80 | // the std::map containing object paths from the |
| 81 | // GetManagedObjects call will have a sorted pathname list. |
| 82 | do |
| 83 | { |
| 84 | auto iter = objToEntityNode.find(parentObj); |
| 85 | if (iter != objToEntityNode.end()) |
| 86 | { |
| 87 | parent = iter->second; |
| 88 | break; |
| 89 | } |
| 90 | parentObj = pldm::utils::findParent(parentObj); |
| 91 | } while (parentObj != "/"); |
| 92 | |
| 93 | auto node = pldm_entity_association_tree_add( |
George Liu | 64a8f0f | 2021-06-12 10:56:11 +0800 | [diff] [blame] | 94 | entityTree, &entity, 0xFFFF, parent, |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 95 | PLDM_ENTITY_ASSOCIAION_PHYSICAL); |
| 96 | objToEntityNode[object.first.str] = node; |
| 97 | |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 98 | auto recordInfos = parser.getRecordInfo(interface.first); |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 99 | populateRecords(interfaces, recordInfos, entity); |
George Liu | c4ea6a9 | 2020-07-14 15:48:44 +0800 | [diff] [blame] | 100 | |
| 101 | associatedEntityMap.emplace(object.first, entity); |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 102 | break; |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 103 | } |
| 104 | catch (const std::exception& e) |
| 105 | { |
| 106 | std::cout << "Config JSONs missing for the item " |
| 107 | "interface type, interface = " |
| 108 | << interface.first << "\n"; |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 115 | pldm_entity_association_pdr_add(entityTree, pdrRepo, false, |
| 116 | TERMINUS_HANDLE); |
Sampa Misra | c073a20 | 2021-05-08 10:56:05 -0500 | [diff] [blame] | 117 | // save a copy of bmc's entity association tree |
| 118 | pldm_entity_association_tree_copy_root(entityTree, bmcEntityTree); |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 119 | |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 120 | if (table.size()) |
| 121 | { |
Sridevi Ramesh | eefe49b | 2022-06-27 11:51:02 -0500 | [diff] [blame] | 122 | padBytes = pldm::utils::getNumPadBytes(table.size()); |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 123 | table.resize(table.size() + padBytes, 0); |
| 124 | |
| 125 | // Calculate the checksum |
George Liu | 077fea2 | 2020-04-08 16:47:14 +0800 | [diff] [blame] | 126 | checksum = crc32(table.data(), table.size()); |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 127 | } |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 128 | isBuilt = true; |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 129 | } |
Pavithra Barithaya | 47180ac | 2020-10-28 02:12:05 -0500 | [diff] [blame] | 130 | std::string FruImpl::populatefwVersion() |
| 131 | { |
| 132 | static constexpr auto fwFunctionalObjPath = |
| 133 | "/xyz/openbmc_project/software/functional"; |
| 134 | auto& bus = pldm::utils::DBusHandler::getBus(); |
| 135 | std::string currentBmcVersion; |
| 136 | try |
| 137 | { |
| 138 | auto method = |
| 139 | bus.new_method_call(pldm::utils::mapperService, fwFunctionalObjPath, |
| 140 | pldm::utils::dbusProperties, "Get"); |
| 141 | method.append("xyz.openbmc_project.Association", "endpoints"); |
| 142 | std::variant<std::vector<std::string>> paths; |
| 143 | auto reply = bus.call(method); |
| 144 | reply.read(paths); |
| 145 | auto fwRunningVersion = std::get<std::vector<std::string>>(paths)[0]; |
| 146 | constexpr auto versionIntf = "xyz.openbmc_project.Software.Version"; |
| 147 | auto version = pldm::utils::DBusHandler().getDbusPropertyVariant( |
| 148 | fwRunningVersion.c_str(), "Version", versionIntf); |
| 149 | currentBmcVersion = std::get<std::string>(version); |
| 150 | } |
| 151 | catch (const std::exception& e) |
| 152 | { |
| 153 | std::cerr << "failed to make a d-bus call " |
| 154 | "Asociation, ERROR= " |
| 155 | << e.what() << "\n"; |
| 156 | return {}; |
| 157 | } |
| 158 | return currentBmcVersion; |
| 159 | } |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 160 | void FruImpl::populateRecords( |
| 161 | const pldm::responder::dbus::InterfaceMap& interfaces, |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 162 | const fru_parser::FruRecordInfos& recordInfos, const pldm_entity& entity) |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 163 | { |
| 164 | // recordSetIdentifier for the FRU will be set when the first record gets |
| 165 | // added for the FRU |
| 166 | uint16_t recordSetIdentifier = 0; |
| 167 | auto numRecsCount = numRecs; |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 168 | static uint32_t bmc_record_handle = 0; |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 169 | |
| 170 | for (auto const& [recType, encType, fieldInfos] : recordInfos) |
| 171 | { |
| 172 | std::vector<uint8_t> tlvs; |
| 173 | uint8_t numFRUFields = 0; |
| 174 | for (auto const& [intf, prop, propType, fieldTypeNum] : fieldInfos) |
| 175 | { |
| 176 | try |
| 177 | { |
Pavithra Barithaya | 47180ac | 2020-10-28 02:12:05 -0500 | [diff] [blame] | 178 | pldm::responder::dbus::Value propValue; |
Manojkiran Eda | 2b7c1bf | 2021-09-09 12:26:00 +0530 | [diff] [blame] | 179 | |
| 180 | // Assuming that 0 container Id is assigned to the System (as |
| 181 | // that should be the top most container as per dbus hierarchy) |
| 182 | if (entity.entity_container_id == 0 && prop == "Version") |
Pavithra Barithaya | 47180ac | 2020-10-28 02:12:05 -0500 | [diff] [blame] | 183 | { |
| 184 | propValue = populatefwVersion(); |
| 185 | } |
| 186 | else |
| 187 | { |
| 188 | propValue = interfaces.at(intf).at(prop); |
| 189 | } |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 190 | if (propType == "bytearray") |
| 191 | { |
| 192 | auto byteArray = std::get<std::vector<uint8_t>>(propValue); |
| 193 | if (!byteArray.size()) |
| 194 | { |
| 195 | continue; |
| 196 | } |
| 197 | |
| 198 | numFRUFields++; |
| 199 | tlvs.emplace_back(fieldTypeNum); |
| 200 | tlvs.emplace_back(byteArray.size()); |
| 201 | std::move(std::begin(byteArray), std::end(byteArray), |
| 202 | std::back_inserter(tlvs)); |
| 203 | } |
| 204 | else if (propType == "string") |
| 205 | { |
| 206 | auto str = std::get<std::string>(propValue); |
| 207 | if (!str.size()) |
| 208 | { |
| 209 | continue; |
| 210 | } |
| 211 | |
| 212 | numFRUFields++; |
| 213 | tlvs.emplace_back(fieldTypeNum); |
| 214 | tlvs.emplace_back(str.size()); |
| 215 | std::move(std::begin(str), std::end(str), |
| 216 | std::back_inserter(tlvs)); |
| 217 | } |
| 218 | } |
| 219 | catch (const std::out_of_range& e) |
| 220 | { |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 221 | continue; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | if (tlvs.size()) |
| 226 | { |
| 227 | if (numRecs == numRecsCount) |
| 228 | { |
| 229 | recordSetIdentifier = nextRSI(); |
Pavithra Barithaya | 4f2538a | 2021-03-05 07:32:15 -0600 | [diff] [blame] | 230 | bmc_record_handle = nextRecordHandle(); |
Deepak Kodihalli | 3cd6181 | 2020-03-10 06:38:45 -0500 | [diff] [blame] | 231 | pldm_pdr_add_fru_record_set( |
Manojkiran Eda | cc5f158 | 2021-09-29 17:03:06 +0530 | [diff] [blame] | 232 | pdrRepo, TERMINUS_HANDLE, recordSetIdentifier, |
| 233 | entity.entity_type, entity.entity_instance_num, |
| 234 | entity.entity_container_id, bmc_record_handle); |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 235 | } |
| 236 | auto curSize = table.size(); |
| 237 | table.resize(curSize + recHeaderSize + tlvs.size()); |
| 238 | encode_fru_record(table.data(), table.size(), &curSize, |
| 239 | recordSetIdentifier, recType, numFRUFields, |
| 240 | encType, tlvs.data(), tlvs.size()); |
| 241 | numRecs++; |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | void FruImpl::getFRUTable(Response& response) |
| 247 | { |
| 248 | auto hdrSize = response.size(); |
| 249 | |
| 250 | response.resize(hdrSize + table.size() + sizeof(checksum), 0); |
| 251 | std::copy(table.begin(), table.end(), response.begin() + hdrSize); |
| 252 | |
| 253 | // Copy the checksum to response data |
| 254 | auto iter = response.begin() + hdrSize + table.size(); |
| 255 | std::copy_n(reinterpret_cast<const uint8_t*>(&checksum), sizeof(checksum), |
| 256 | iter); |
| 257 | } |
| 258 | |
John Wang | 9e82ad1 | 2020-06-12 10:53:32 +0800 | [diff] [blame] | 259 | int FruImpl::getFRURecordByOption(std::vector<uint8_t>& fruData, |
| 260 | uint16_t /* fruTableHandle */, |
| 261 | uint16_t recordSetIdentifer, |
| 262 | uint8_t recordType, uint8_t fieldType) |
| 263 | { |
Manojkiran Eda | 31a7844 | 2021-09-12 15:18:25 +0530 | [diff] [blame] | 264 | using sum = uint32_t; |
| 265 | |
John Wang | 9e82ad1 | 2020-06-12 10:53:32 +0800 | [diff] [blame] | 266 | // FRU table is built lazily, build if not done. |
| 267 | buildFRUTable(); |
| 268 | |
| 269 | /* 7 is sizeof(checksum,4) + padBytesMax(3) |
| 270 | * We can not know size of the record table got by options in advance, but |
| 271 | * it must be less than the source table. So it's safe to use sizeof the |
| 272 | * source table + 7 as the buffer length |
| 273 | */ |
| 274 | size_t recordTableSize = table.size() - padBytes + 7; |
| 275 | fruData.resize(recordTableSize, 0); |
| 276 | |
| 277 | get_fru_record_by_option(table.data(), table.size() - padBytes, |
| 278 | fruData.data(), &recordTableSize, |
| 279 | recordSetIdentifer, recordType, fieldType); |
| 280 | |
| 281 | if (recordTableSize == 0) |
| 282 | { |
| 283 | return PLDM_FRU_DATA_STRUCTURE_TABLE_UNAVAILABLE; |
| 284 | } |
| 285 | |
Sridevi Ramesh | eefe49b | 2022-06-27 11:51:02 -0500 | [diff] [blame] | 286 | auto pads = pldm::utils::getNumPadBytes(recordTableSize); |
Manojkiran Eda | 31a7844 | 2021-09-12 15:18:25 +0530 | [diff] [blame] | 287 | crc32(fruData.data(), recordTableSize + pads); |
John Wang | 9e82ad1 | 2020-06-12 10:53:32 +0800 | [diff] [blame] | 288 | |
| 289 | auto iter = fruData.begin() + recordTableSize + pads; |
| 290 | std::copy_n(reinterpret_cast<const uint8_t*>(&checksum), sizeof(checksum), |
| 291 | iter); |
| 292 | fruData.resize(recordTableSize + pads + sizeof(sum)); |
| 293 | |
| 294 | return PLDM_SUCCESS; |
| 295 | } |
| 296 | |
Deepak Kodihalli | e60c582 | 2019-10-23 03:26:15 -0500 | [diff] [blame] | 297 | namespace fru |
| 298 | { |
Deepak Kodihalli | e60c582 | 2019-10-23 03:26:15 -0500 | [diff] [blame] | 299 | Response Handler::getFRURecordTableMetadata(const pldm_msg* request, |
| 300 | size_t /*payloadLength*/) |
| 301 | { |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 302 | // FRU table is built lazily, build if not done. |
| 303 | buildFRUTable(); |
| 304 | |
Deepak Kodihalli | e60c582 | 2019-10-23 03:26:15 -0500 | [diff] [blame] | 305 | constexpr uint8_t major = 0x01; |
| 306 | constexpr uint8_t minor = 0x00; |
| 307 | constexpr uint32_t maxSize = 0xFFFFFFFF; |
| 308 | |
| 309 | Response response(sizeof(pldm_msg_hdr) + |
| 310 | PLDM_GET_FRU_RECORD_TABLE_METADATA_RESP_BYTES, |
| 311 | 0); |
| 312 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 313 | |
| 314 | auto rc = encode_get_fru_record_table_metadata_resp( |
| 315 | request->hdr.instance_id, PLDM_SUCCESS, major, minor, maxSize, |
| 316 | impl.size(), impl.numRSI(), impl.numRecords(), impl.checkSum(), |
| 317 | responsePtr); |
| 318 | if (rc != PLDM_SUCCESS) |
| 319 | { |
| 320 | return ccOnlyResponse(request, rc); |
| 321 | } |
| 322 | |
| 323 | return response; |
| 324 | } |
| 325 | |
| 326 | Response Handler::getFRURecordTable(const pldm_msg* request, |
| 327 | size_t payloadLength) |
| 328 | { |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 329 | // FRU table is built lazily, build if not done. |
| 330 | buildFRUTable(); |
| 331 | |
Deepak Kodihalli | e60c582 | 2019-10-23 03:26:15 -0500 | [diff] [blame] | 332 | if (payloadLength != PLDM_GET_FRU_RECORD_TABLE_REQ_BYTES) |
| 333 | { |
| 334 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 335 | } |
| 336 | |
| 337 | Response response( |
| 338 | sizeof(pldm_msg_hdr) + PLDM_GET_FRU_RECORD_TABLE_MIN_RESP_BYTES, 0); |
| 339 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 340 | |
| 341 | auto rc = |
| 342 | encode_get_fru_record_table_resp(request->hdr.instance_id, PLDM_SUCCESS, |
| 343 | 0, PLDM_START_AND_END, responsePtr); |
| 344 | if (rc != PLDM_SUCCESS) |
| 345 | { |
| 346 | return ccOnlyResponse(request, rc); |
| 347 | } |
| 348 | |
| 349 | impl.getFRUTable(response); |
| 350 | |
| 351 | return response; |
| 352 | } |
| 353 | |
John Wang | 9e82ad1 | 2020-06-12 10:53:32 +0800 | [diff] [blame] | 354 | Response Handler::getFRURecordByOption(const pldm_msg* request, |
| 355 | size_t payloadLength) |
| 356 | { |
| 357 | if (payloadLength != sizeof(pldm_get_fru_record_by_option_req)) |
| 358 | { |
| 359 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 360 | } |
| 361 | |
| 362 | uint32_t retDataTransferHandle{}; |
| 363 | uint16_t retFruTableHandle{}; |
| 364 | uint16_t retRecordSetIdentifier{}; |
| 365 | uint8_t retRecordType{}; |
| 366 | uint8_t retFieldType{}; |
| 367 | uint8_t retTransferOpFlag{}; |
| 368 | |
| 369 | auto rc = decode_get_fru_record_by_option_req( |
| 370 | request, payloadLength, &retDataTransferHandle, &retFruTableHandle, |
| 371 | &retRecordSetIdentifier, &retRecordType, &retFieldType, |
| 372 | &retTransferOpFlag); |
| 373 | |
| 374 | if (rc != PLDM_SUCCESS) |
| 375 | { |
| 376 | return ccOnlyResponse(request, rc); |
| 377 | } |
| 378 | |
| 379 | std::vector<uint8_t> fruData; |
| 380 | rc = impl.getFRURecordByOption(fruData, retFruTableHandle, |
| 381 | retRecordSetIdentifier, retRecordType, |
| 382 | retFieldType); |
| 383 | if (rc != PLDM_SUCCESS) |
| 384 | { |
| 385 | return ccOnlyResponse(request, rc); |
| 386 | } |
| 387 | |
| 388 | auto respPayloadLength = |
| 389 | PLDM_GET_FRU_RECORD_BY_OPTION_MIN_RESP_BYTES + fruData.size(); |
| 390 | Response response(sizeof(pldm_msg_hdr) + respPayloadLength, 0); |
| 391 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 392 | |
| 393 | rc = encode_get_fru_record_by_option_resp( |
| 394 | request->hdr.instance_id, PLDM_SUCCESS, 0, PLDM_START_AND_END, |
| 395 | fruData.data(), fruData.size(), responsePtr, respPayloadLength); |
| 396 | |
| 397 | if (rc != PLDM_SUCCESS) |
| 398 | { |
| 399 | return ccOnlyResponse(request, rc); |
| 400 | } |
| 401 | |
| 402 | return response; |
| 403 | } |
| 404 | |
Deepak Kodihalli | e60c582 | 2019-10-23 03:26:15 -0500 | [diff] [blame] | 405 | } // namespace fru |
| 406 | |
Deepak Kodihalli | 70e8db0 | 2019-10-21 00:59:46 -0500 | [diff] [blame] | 407 | } // namespace responder |
| 408 | |
| 409 | } // namespace pldm |