Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 1 | |
| 2 | #include "platform.hpp" |
| 3 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 4 | #include "libpldm/entity.h" |
| 5 | #include "libpldm/state_set.h" |
| 6 | |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 7 | #include "common/types.hpp" |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 8 | #include "common/utils.hpp" |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 9 | #include "event_parser.hpp" |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 10 | #include "pdr.hpp" |
George Liu | 456c9a2 | 2020-01-13 11:36:22 +0800 | [diff] [blame] | 11 | #include "pdr_numeric_effecter.hpp" |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 12 | #include "pdr_state_effecter.hpp" |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 13 | #include "pdr_state_sensor.hpp" |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 14 | #include "pdr_utils.hpp" |
George Liu | eccb0c5 | 2020-01-14 11:09:56 +0800 | [diff] [blame] | 15 | #include "platform_numeric_effecter.hpp" |
George Liu | 0d7aca8 | 2020-03-30 15:01:36 +0800 | [diff] [blame] | 16 | #include "platform_state_effecter.hpp" |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 17 | #include "platform_state_sensor.hpp" |
George Liu | 8340957 | 2019-12-24 18:42:54 +0800 | [diff] [blame] | 18 | |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 19 | using namespace pldm::utils; |
| 20 | using namespace pldm::responder::pdr; |
| 21 | using namespace pldm::responder::pdr_utils; |
| 22 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 23 | namespace pldm |
| 24 | { |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 25 | namespace responder |
| 26 | { |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 27 | namespace platform |
| 28 | { |
| 29 | |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 30 | using InternalFailure = |
| 31 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 32 | |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 33 | static const Json empty{}; |
| 34 | |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 35 | void Handler::addDbusObjMaps( |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 36 | uint16_t id, |
| 37 | std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj, |
| 38 | TypeId typeId) |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 39 | { |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 40 | if (typeId == TypeId::PLDM_SENSOR_ID) |
| 41 | { |
| 42 | sensorDbusObjMaps.emplace(id, dbusObj); |
| 43 | } |
| 44 | else |
| 45 | { |
| 46 | effecterDbusObjMaps.emplace(id, dbusObj); |
| 47 | } |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 48 | } |
| 49 | |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 50 | const std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>& |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 51 | Handler::getDbusObjMaps(uint16_t id, TypeId typeId) const |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 52 | { |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 53 | if (typeId == TypeId::PLDM_SENSOR_ID) |
| 54 | { |
| 55 | return sensorDbusObjMaps.at(id); |
| 56 | } |
| 57 | else |
| 58 | { |
| 59 | return effecterDbusObjMaps.at(id); |
| 60 | } |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 61 | } |
| 62 | |
George Liu | 36e8135 | 2020-07-01 14:40:30 +0800 | [diff] [blame] | 63 | void Handler::generate(const pldm::utils::DBusHandler& dBusIntf, |
| 64 | const std::string& dir, Repo& repo) |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 65 | { |
Deepak Kodihalli | c6e49c4 | 2020-07-01 03:39:27 -0500 | [diff] [blame] | 66 | if (!fs::exists(dir)) |
| 67 | { |
| 68 | return; |
| 69 | } |
| 70 | |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 71 | // A map of PDR type to a lambda that handles creation of that PDR type. |
| 72 | // The lambda essentially would parse the platform specific PDR JSONs to |
| 73 | // generate the PDR structures. This function iterates through the map to |
| 74 | // invoke all lambdas, so that all PDR types can be created. |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 75 | |
| 76 | const std::map<Type, generatePDR> generateHandlers = { |
| 77 | {PLDM_STATE_EFFECTER_PDR, |
George Liu | 36e8135 | 2020-07-01 14:40:30 +0800 | [diff] [blame] | 78 | [this](const DBusHandler& dBusIntf, const auto& json, |
| 79 | RepoInterface& repo) { |
| 80 | pdr_state_effecter::generateStateEffecterPDR< |
| 81 | pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this, |
| 82 | repo); |
George Liu | 456c9a2 | 2020-01-13 11:36:22 +0800 | [diff] [blame] | 83 | }}, |
| 84 | {PLDM_NUMERIC_EFFECTER_PDR, |
George Liu | 36e8135 | 2020-07-01 14:40:30 +0800 | [diff] [blame] | 85 | [this](const DBusHandler& dBusIntf, const auto& json, |
| 86 | RepoInterface& repo) { |
| 87 | pdr_numeric_effecter::generateNumericEffecterPDR< |
| 88 | pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this, |
| 89 | repo); |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 90 | }}, |
| 91 | {PLDM_STATE_SENSOR_PDR, [this](const DBusHandler& dBusIntf, |
| 92 | const auto& json, RepoInterface& repo) { |
| 93 | pdr_state_sensor::generateStateSensorPDR<pldm::utils::DBusHandler, |
| 94 | Handler>(dBusIntf, json, |
| 95 | *this, repo); |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 96 | }}}; |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 97 | |
| 98 | Type pdrType{}; |
| 99 | for (const auto& dirEntry : fs::directory_iterator(dir)) |
| 100 | { |
| 101 | try |
| 102 | { |
| 103 | auto json = readJson(dirEntry.path().string()); |
| 104 | if (!json.empty()) |
| 105 | { |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 106 | auto effecterPDRs = json.value("effecterPDRs", empty); |
| 107 | for (const auto& effecter : effecterPDRs) |
| 108 | { |
| 109 | pdrType = effecter.value("pdrType", 0); |
George Liu | 36e8135 | 2020-07-01 14:40:30 +0800 | [diff] [blame] | 110 | generateHandlers.at(pdrType)(dBusIntf, effecter, repo); |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 111 | } |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 112 | |
| 113 | auto sensorPDRs = json.value("sensorPDRs", empty); |
| 114 | for (const auto& sensor : sensorPDRs) |
| 115 | { |
| 116 | pdrType = sensor.value("pdrType", 0); |
| 117 | generateHandlers.at(pdrType)(dBusIntf, sensor, repo); |
| 118 | } |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | catch (const InternalFailure& e) |
| 122 | { |
| 123 | std::cerr << "PDR config directory does not exist or empty, TYPE= " |
| 124 | << pdrType << "PATH= " << dirEntry |
| 125 | << " ERROR=" << e.what() << "\n"; |
| 126 | } |
| 127 | catch (const Json::exception& e) |
| 128 | { |
| 129 | std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType |
| 130 | << " ERROR=" << e.what() << "\n"; |
| 131 | pldm::utils::reportError( |
| 132 | "xyz.openbmc_project.bmc.pldm.InternalFailure"); |
| 133 | } |
| 134 | catch (const std::exception& e) |
| 135 | { |
| 136 | std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType |
| 137 | << " ERROR=" << e.what() << "\n"; |
| 138 | pldm::utils::reportError( |
| 139 | "xyz.openbmc_project.bmc.pldm.InternalFailure"); |
| 140 | } |
| 141 | } |
| 142 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 143 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 144 | Response Handler::getPDR(const pldm_msg* request, size_t payloadLength) |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 145 | { |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 146 | // Build FRU table if not built, since entity association PDR's are built |
| 147 | // when the FRU table is constructed. |
| 148 | if (fruHandler) |
| 149 | { |
| 150 | fruHandler->buildFRUTable(); |
| 151 | } |
| 152 | |
George Liu | d680ae0 | 2020-07-17 09:11:14 +0800 | [diff] [blame] | 153 | if (!pdrCreated) |
| 154 | { |
| 155 | generateTerminusLocatorPDR(pdrRepo); |
| 156 | generate(*dBusIntf, pdrJsonsDir, pdrRepo); |
Sagar Srinivas | 78a225a | 2020-08-27 00:52:20 -0500 | [diff] [blame] | 157 | if (oemPlatformHandler != nullptr) |
| 158 | { |
| 159 | oemPlatformHandler->buildOEMPDR(pdrRepo); |
| 160 | } |
| 161 | |
George Liu | d680ae0 | 2020-07-17 09:11:14 +0800 | [diff] [blame] | 162 | pdrCreated = true; |
George Liu | 5eed8e5 | 2020-12-18 11:24:37 +0800 | [diff] [blame] | 163 | |
| 164 | if (dbusToPLDMEventHandler) |
| 165 | { |
Sampa Misra | 5fb37d5 | 2021-03-06 07:26:00 -0600 | [diff] [blame] | 166 | deferredGetPDREvent = std::make_unique<sdeventplus::source::Defer>( |
| 167 | event, |
| 168 | std::bind(std::mem_fn(&pldm::responder::platform::Handler:: |
| 169 | _processPostGetPDRActions), |
| 170 | this, std::placeholders::_1)); |
George Liu | 5eed8e5 | 2020-12-18 11:24:37 +0800 | [diff] [blame] | 171 | } |
George Liu | d680ae0 | 2020-07-17 09:11:14 +0800 | [diff] [blame] | 172 | } |
| 173 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 174 | Response response(sizeof(pldm_msg_hdr) + PLDM_GET_PDR_MIN_RESP_BYTES, 0); |
| 175 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 176 | |
| 177 | if (payloadLength != PLDM_GET_PDR_REQ_BYTES) |
| 178 | { |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 179 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | uint32_t recordHandle{}; |
| 183 | uint32_t dataTransferHandle{}; |
| 184 | uint8_t transferOpFlag{}; |
| 185 | uint16_t reqSizeBytes{}; |
| 186 | uint16_t recordChangeNum{}; |
| 187 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 188 | auto rc = decode_get_pdr_req(request, payloadLength, &recordHandle, |
| 189 | &dataTransferHandle, &transferOpFlag, |
| 190 | &reqSizeBytes, &recordChangeNum); |
| 191 | if (rc != PLDM_SUCCESS) |
| 192 | { |
| 193 | return CmdHandler::ccOnlyResponse(request, rc); |
| 194 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 195 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 196 | uint16_t respSizeBytes{}; |
| 197 | uint8_t* recordData = nullptr; |
| 198 | try |
| 199 | { |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 200 | pdr_utils::PdrEntry e; |
| 201 | auto record = pdr::getRecordByHandle(pdrRepo, recordHandle, e); |
| 202 | if (record == NULL) |
| 203 | { |
| 204 | return CmdHandler::ccOnlyResponse( |
| 205 | request, PLDM_PLATFORM_INVALID_RECORD_HANDLE); |
| 206 | } |
| 207 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 208 | if (reqSizeBytes) |
| 209 | { |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 210 | respSizeBytes = e.size; |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 211 | if (respSizeBytes > reqSizeBytes) |
| 212 | { |
| 213 | respSizeBytes = reqSizeBytes; |
| 214 | } |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 215 | recordData = e.data; |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 216 | } |
| 217 | response.resize(sizeof(pldm_msg_hdr) + PLDM_GET_PDR_MIN_RESP_BYTES + |
| 218 | respSizeBytes, |
| 219 | 0); |
| 220 | responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
Deepak Kodihalli | 22b5a7d | 2020-03-17 23:28:41 -0500 | [diff] [blame] | 221 | rc = encode_get_pdr_resp( |
| 222 | request->hdr.instance_id, PLDM_SUCCESS, e.handle.nextRecordHandle, |
| 223 | 0, PLDM_START_AND_END, respSizeBytes, recordData, 0, responsePtr); |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 224 | if (rc != PLDM_SUCCESS) |
| 225 | { |
| 226 | return ccOnlyResponse(request, rc); |
| 227 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 228 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 229 | catch (const std::exception& e) |
| 230 | { |
Sampa Misra | aa8ae72 | 2019-12-12 03:20:40 -0600 | [diff] [blame] | 231 | std::cerr << "Error accessing PDR, HANDLE=" << recordHandle |
| 232 | << " ERROR=" << e.what() << "\n"; |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 233 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR); |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 234 | } |
| 235 | return response; |
| 236 | } |
| 237 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 238 | Response Handler::setStateEffecterStates(const pldm_msg* request, |
| 239 | size_t payloadLength) |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 240 | { |
| 241 | Response response( |
| 242 | sizeof(pldm_msg_hdr) + PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES, 0); |
| 243 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 244 | uint16_t effecterId; |
| 245 | uint8_t compEffecterCnt; |
| 246 | constexpr auto maxCompositeEffecterCnt = 8; |
| 247 | std::vector<set_effecter_state_field> stateField(maxCompositeEffecterCnt, |
| 248 | {0, 0}); |
| 249 | |
| 250 | if ((payloadLength > PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES) || |
| 251 | (payloadLength < sizeof(effecterId) + sizeof(compEffecterCnt) + |
| 252 | sizeof(set_effecter_state_field))) |
| 253 | { |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 254 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | int rc = decode_set_state_effecter_states_req(request, payloadLength, |
| 258 | &effecterId, &compEffecterCnt, |
| 259 | stateField.data()); |
| 260 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 261 | if (rc != PLDM_SUCCESS) |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 262 | { |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 263 | return CmdHandler::ccOnlyResponse(request, rc); |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 264 | } |
| 265 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 266 | stateField.resize(compEffecterCnt); |
| 267 | const pldm::utils::DBusHandler dBusIntf; |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 268 | uint16_t entityType{}; |
| 269 | uint16_t entityInstance{}; |
| 270 | uint16_t stateSetId{}; |
| 271 | |
| 272 | if (isOemStateEffecter(*this, effecterId, compEffecterCnt, entityType, |
| 273 | entityInstance, stateSetId) && |
| 274 | oemPlatformHandler != nullptr) |
| 275 | { |
Sampa Misra | 3a0e3b9 | 2020-10-21 05:58:00 -0500 | [diff] [blame] | 276 | rc = oemPlatformHandler->oemSetStateEffecterStatesHandler( |
Varsha Kaverappa | 3fbd39e | 2020-09-28 01:40:22 -0500 | [diff] [blame] | 277 | entityType, entityInstance, stateSetId, compEffecterCnt, stateField, |
| 278 | effecterId); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 279 | } |
| 280 | else |
| 281 | { |
| 282 | rc = platform_state_effecter::setStateEffecterStatesHandler< |
| 283 | pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId, |
| 284 | stateField); |
| 285 | } |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 286 | if (rc != PLDM_SUCCESS) |
| 287 | { |
| 288 | return CmdHandler::ccOnlyResponse(request, rc); |
| 289 | } |
| 290 | |
| 291 | rc = encode_set_state_effecter_states_resp(request->hdr.instance_id, rc, |
| 292 | responsePtr); |
| 293 | if (rc != PLDM_SUCCESS) |
| 294 | { |
| 295 | return ccOnlyResponse(request, rc); |
| 296 | } |
| 297 | |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 298 | return response; |
| 299 | } |
| 300 | |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 301 | Response Handler::platformEventMessage(const pldm_msg* request, |
| 302 | size_t payloadLength) |
| 303 | { |
| 304 | uint8_t formatVersion{}; |
| 305 | uint8_t tid{}; |
| 306 | uint8_t eventClass{}; |
| 307 | size_t offset{}; |
| 308 | |
| 309 | auto rc = decode_platform_event_message_req( |
| 310 | request, payloadLength, &formatVersion, &tid, &eventClass, &offset); |
| 311 | if (rc != PLDM_SUCCESS) |
| 312 | { |
| 313 | return CmdHandler::ccOnlyResponse(request, rc); |
| 314 | } |
| 315 | |
| 316 | try |
| 317 | { |
| 318 | const auto& handlers = eventHandlers.at(eventClass); |
| 319 | for (const auto& handler : handlers) |
| 320 | { |
| 321 | auto rc = |
| 322 | handler(request, payloadLength, formatVersion, tid, offset); |
| 323 | if (rc != PLDM_SUCCESS) |
| 324 | { |
| 325 | return CmdHandler::ccOnlyResponse(request, rc); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | catch (const std::out_of_range& e) |
| 330 | { |
| 331 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_DATA); |
| 332 | } |
| 333 | |
| 334 | Response response( |
| 335 | sizeof(pldm_msg_hdr) + PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES, 0); |
| 336 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 337 | |
| 338 | rc = encode_platform_event_message_resp(request->hdr.instance_id, rc, |
| 339 | PLDM_EVENT_NO_LOGGING, responsePtr); |
| 340 | if (rc != PLDM_SUCCESS) |
| 341 | { |
| 342 | return ccOnlyResponse(request, rc); |
| 343 | } |
| 344 | |
| 345 | return response; |
| 346 | } |
| 347 | |
| 348 | int Handler::sensorEvent(const pldm_msg* request, size_t payloadLength, |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 349 | uint8_t /*formatVersion*/, uint8_t tid, |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 350 | size_t eventDataOffset) |
| 351 | { |
| 352 | uint16_t sensorId{}; |
| 353 | uint8_t eventClass{}; |
| 354 | size_t eventClassDataOffset{}; |
| 355 | auto eventData = |
| 356 | reinterpret_cast<const uint8_t*>(request->payload) + eventDataOffset; |
| 357 | auto eventDataSize = payloadLength - eventDataOffset; |
| 358 | |
| 359 | auto rc = decode_sensor_event_data(eventData, eventDataSize, &sensorId, |
| 360 | &eventClass, &eventClassDataOffset); |
| 361 | if (rc != PLDM_SUCCESS) |
| 362 | { |
| 363 | return rc; |
| 364 | } |
| 365 | |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 366 | auto eventClassData = reinterpret_cast<const uint8_t*>(request->payload) + |
| 367 | eventDataOffset + eventClassDataOffset; |
| 368 | auto eventClassDataSize = |
| 369 | payloadLength - eventDataOffset - eventClassDataOffset; |
| 370 | |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 371 | if (eventClass == PLDM_STATE_SENSOR_STATE) |
| 372 | { |
| 373 | uint8_t sensorOffset{}; |
| 374 | uint8_t eventState{}; |
| 375 | uint8_t previousEventState{}; |
| 376 | |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 377 | rc = decode_state_sensor_data(eventClassData, eventClassDataSize, |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 378 | &sensorOffset, &eventState, |
| 379 | &previousEventState); |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 380 | if (rc != PLDM_SUCCESS) |
| 381 | { |
| 382 | return PLDM_ERROR; |
| 383 | } |
| 384 | |
Chicago Duan | fe4d88b | 2020-06-12 16:44:13 +0800 | [diff] [blame] | 385 | // Emitting state sensor event signal |
| 386 | emitStateSensorEventSignal(tid, sensorId, sensorOffset, eventState, |
| 387 | previousEventState); |
| 388 | |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 389 | // If there are no HOST PDR's, there is no further action |
| 390 | if (hostPDRHandler == NULL) |
| 391 | { |
| 392 | return PLDM_SUCCESS; |
| 393 | } |
| 394 | |
| 395 | // Handle PLDM events for which PDR is available |
| 396 | SensorEntry sensorEntry{tid, sensorId}; |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 397 | |
| 398 | pldm::pdr::EntityInfo entityInfo{}; |
| 399 | pldm::pdr::CompositeSensorStates compositeSensorStates{}; |
| 400 | |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 401 | try |
| 402 | { |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 403 | std::tie(entityInfo, compositeSensorStates) = |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 404 | hostPDRHandler->lookupSensorInfo(sensorEntry); |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 405 | } |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 406 | catch (const std::out_of_range& e) |
| 407 | { |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 408 | // If there is no mapping for tid, sensorId combination, try |
| 409 | // PLDM_TID_RESERVED, sensorId for terminus that is yet to |
| 410 | // implement TL PDR. |
| 411 | try |
| 412 | { |
| 413 | sensorEntry.terminusID = PLDM_TID_RESERVED; |
| 414 | std::tie(entityInfo, compositeSensorStates) = |
| 415 | hostPDRHandler->lookupSensorInfo(sensorEntry); |
| 416 | } |
| 417 | // If there is no mapping for events return PLDM_SUCCESS |
| 418 | catch (const std::out_of_range& e) |
| 419 | { |
| 420 | return PLDM_SUCCESS; |
| 421 | } |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 422 | } |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 423 | |
| 424 | if (sensorOffset >= compositeSensorStates.size()) |
| 425 | { |
| 426 | return PLDM_ERROR_INVALID_DATA; |
| 427 | } |
| 428 | |
| 429 | const auto& possibleStates = compositeSensorStates[sensorOffset]; |
| 430 | if (possibleStates.find(eventState) == possibleStates.end()) |
| 431 | { |
| 432 | return PLDM_ERROR_INVALID_DATA; |
| 433 | } |
| 434 | |
| 435 | const auto& [containerId, entityType, entityInstance] = entityInfo; |
| 436 | events::StateSensorEntry stateSensorEntry{containerId, entityType, |
| 437 | entityInstance, sensorOffset}; |
Pavithra Barithaya | 3aec997 | 2020-12-14 01:55:44 -0600 | [diff] [blame] | 438 | return hostPDRHandler->handleStateSensorEvent(stateSensorEntry, |
| 439 | eventState); |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 440 | } |
| 441 | else |
| 442 | { |
| 443 | return PLDM_ERROR_INVALID_DATA; |
| 444 | } |
| 445 | |
| 446 | return PLDM_SUCCESS; |
| 447 | } |
| 448 | |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 449 | int Handler::pldmPDRRepositoryChgEvent(const pldm_msg* request, |
| 450 | size_t payloadLength, |
| 451 | uint8_t /*formatVersion*/, |
| 452 | uint8_t /*tid*/, size_t eventDataOffset) |
| 453 | { |
| 454 | uint8_t eventDataFormat{}; |
| 455 | uint8_t numberOfChangeRecords{}; |
| 456 | size_t dataOffset{}; |
| 457 | |
| 458 | auto eventData = |
| 459 | reinterpret_cast<const uint8_t*>(request->payload) + eventDataOffset; |
| 460 | auto eventDataSize = payloadLength - eventDataOffset; |
| 461 | |
| 462 | auto rc = decode_pldm_pdr_repository_chg_event_data( |
| 463 | eventData, eventDataSize, &eventDataFormat, &numberOfChangeRecords, |
| 464 | &dataOffset); |
| 465 | if (rc != PLDM_SUCCESS) |
| 466 | { |
| 467 | return rc; |
| 468 | } |
| 469 | |
| 470 | PDRRecordHandles pdrRecordHandles; |
Deepak Kodihalli | 7246e0c | 2020-07-08 06:40:18 -0500 | [diff] [blame] | 471 | |
| 472 | if (eventDataFormat == FORMAT_IS_PDR_TYPES) |
| 473 | { |
| 474 | return PLDM_ERROR_INVALID_DATA; |
| 475 | } |
| 476 | |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 477 | if (eventDataFormat == FORMAT_IS_PDR_HANDLES) |
| 478 | { |
| 479 | uint8_t eventDataOperation{}; |
| 480 | uint8_t numberOfChangeEntries{}; |
| 481 | |
| 482 | auto changeRecordData = eventData + dataOffset; |
| 483 | auto changeRecordDataSize = eventDataSize - dataOffset; |
| 484 | |
| 485 | while (changeRecordDataSize) |
| 486 | { |
| 487 | rc = decode_pldm_pdr_repository_change_record_data( |
| 488 | changeRecordData, changeRecordDataSize, &eventDataOperation, |
| 489 | &numberOfChangeEntries, &dataOffset); |
| 490 | |
| 491 | if (rc != PLDM_SUCCESS) |
| 492 | { |
| 493 | return rc; |
| 494 | } |
| 495 | |
| 496 | if (eventDataOperation == PLDM_RECORDS_ADDED) |
| 497 | { |
| 498 | rc = getPDRRecordHandles( |
| 499 | reinterpret_cast<const ChangeEntry*>(changeRecordData + |
| 500 | dataOffset), |
| 501 | changeRecordDataSize - dataOffset, |
| 502 | static_cast<size_t>(numberOfChangeEntries), |
| 503 | pdrRecordHandles); |
| 504 | |
| 505 | if (rc != PLDM_SUCCESS) |
| 506 | { |
| 507 | return rc; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | changeRecordData += |
| 512 | dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry)); |
| 513 | changeRecordDataSize -= |
| 514 | dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry)); |
| 515 | } |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 516 | } |
Deepak Kodihalli | 7246e0c | 2020-07-08 06:40:18 -0500 | [diff] [blame] | 517 | if (hostPDRHandler) |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 518 | { |
Deepak Kodihalli | 7246e0c | 2020-07-08 06:40:18 -0500 | [diff] [blame] | 519 | hostPDRHandler->fetchPDR(std::move(pdrRecordHandles)); |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | return PLDM_SUCCESS; |
| 523 | } |
| 524 | |
| 525 | int Handler::getPDRRecordHandles(const ChangeEntry* changeEntryData, |
| 526 | size_t changeEntryDataSize, |
| 527 | size_t numberOfChangeEntries, |
| 528 | PDRRecordHandles& pdrRecordHandles) |
| 529 | { |
| 530 | if (numberOfChangeEntries > (changeEntryDataSize / sizeof(ChangeEntry))) |
| 531 | { |
| 532 | return PLDM_ERROR_INVALID_DATA; |
| 533 | } |
| 534 | for (size_t i = 0; i < numberOfChangeEntries; i++) |
| 535 | { |
| 536 | pdrRecordHandles.push_back(changeEntryData[i]); |
| 537 | } |
| 538 | return PLDM_SUCCESS; |
| 539 | } |
| 540 | |
George Liu | eccb0c5 | 2020-01-14 11:09:56 +0800 | [diff] [blame] | 541 | Response Handler::setNumericEffecterValue(const pldm_msg* request, |
| 542 | size_t payloadLength) |
| 543 | { |
| 544 | Response response(sizeof(pldm_msg_hdr) + |
| 545 | PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES); |
| 546 | uint16_t effecterId{}; |
| 547 | uint8_t effecterDataSize{}; |
| 548 | uint8_t effecterValue[4] = {}; |
| 549 | |
| 550 | if ((payloadLength > sizeof(effecterId) + sizeof(effecterDataSize) + |
| 551 | sizeof(union_effecter_data_size)) || |
| 552 | (payloadLength < sizeof(effecterId) + sizeof(effecterDataSize) + 1)) |
| 553 | { |
| 554 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 555 | } |
| 556 | |
| 557 | int rc = decode_set_numeric_effecter_value_req( |
| 558 | request, payloadLength, &effecterId, &effecterDataSize, |
| 559 | reinterpret_cast<uint8_t*>(&effecterValue)); |
| 560 | |
| 561 | if (rc == PLDM_SUCCESS) |
| 562 | { |
| 563 | const pldm::utils::DBusHandler dBusIntf; |
| 564 | rc = platform_numeric_effecter::setNumericEffecterValueHandler< |
| 565 | pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId, |
| 566 | effecterDataSize, effecterValue, |
| 567 | sizeof(effecterValue)); |
| 568 | } |
| 569 | |
| 570 | return ccOnlyResponse(request, rc); |
| 571 | } |
| 572 | |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 573 | void Handler::generateTerminusLocatorPDR(Repo& repo) |
| 574 | { |
| 575 | std::vector<uint8_t> pdrBuffer(sizeof(pldm_terminus_locator_pdr)); |
| 576 | |
| 577 | auto pdr = reinterpret_cast<pldm_terminus_locator_pdr*>(pdrBuffer.data()); |
| 578 | |
| 579 | pdr->hdr.record_handle = 0; |
| 580 | pdr->hdr.version = 1; |
| 581 | pdr->hdr.type = PLDM_TERMINUS_LOCATOR_PDR; |
| 582 | pdr->hdr.record_change_num = 0; |
| 583 | pdr->hdr.length = sizeof(pldm_terminus_locator_pdr) - sizeof(pldm_pdr_hdr); |
| 584 | pdr->terminus_handle = BmcPldmTerminusHandle; |
| 585 | pdr->validity = PLDM_TL_PDR_VALID; |
| 586 | pdr->tid = BmcTerminusId; |
| 587 | pdr->container_id = 0x0; |
| 588 | pdr->terminus_locator_type = PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID; |
| 589 | pdr->terminus_locator_value_size = |
| 590 | sizeof(pldm_terminus_locator_type_mctp_eid); |
| 591 | auto locatorValue = reinterpret_cast<pldm_terminus_locator_type_mctp_eid*>( |
| 592 | pdr->terminus_locator_value); |
| 593 | locatorValue->eid = BmcMctpEid; |
| 594 | |
| 595 | PdrEntry pdrEntry{}; |
| 596 | pdrEntry.data = pdrBuffer.data(); |
| 597 | pdrEntry.size = pdrBuffer.size(); |
| 598 | repo.addRecord(pdrEntry); |
| 599 | } |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 600 | |
| 601 | Response Handler::getStateSensorReadings(const pldm_msg* request, |
| 602 | size_t payloadLength) |
| 603 | { |
| 604 | uint16_t sensorId{}; |
| 605 | bitfield8_t sensorRearm{}; |
| 606 | uint8_t reserved{}; |
| 607 | |
| 608 | if (payloadLength != PLDM_GET_SENSOR_READING_REQ_BYTES) |
| 609 | { |
| 610 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 611 | } |
| 612 | |
| 613 | int rc = decode_get_state_sensor_readings_req( |
| 614 | request, payloadLength, &sensorId, &sensorRearm, &reserved); |
| 615 | |
| 616 | if (rc != PLDM_SUCCESS) |
| 617 | { |
| 618 | return ccOnlyResponse(request, rc); |
| 619 | } |
| 620 | |
| 621 | // 0x01 to 0x08 |
George Liu | c1230ca | 2021-08-03 16:06:50 +0800 | [diff] [blame] | 622 | uint8_t sensorRearmCount = std::popcount(sensorRearm.byte); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 623 | std::vector<get_sensor_state_field> stateField(sensorRearmCount); |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 624 | uint8_t comSensorCnt{}; |
| 625 | const pldm::utils::DBusHandler dBusIntf; |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 626 | |
| 627 | uint16_t entityType{}; |
| 628 | uint16_t entityInstance{}; |
| 629 | uint16_t stateSetId{}; |
| 630 | |
| 631 | if (isOemStateSensor(*this, sensorId, sensorRearmCount, comSensorCnt, |
| 632 | entityType, entityInstance, stateSetId) && |
| 633 | oemPlatformHandler != nullptr) |
| 634 | { |
| 635 | rc = oemPlatformHandler->getOemStateSensorReadingsHandler( |
| 636 | entityType, entityInstance, stateSetId, comSensorCnt, stateField); |
| 637 | } |
| 638 | else |
| 639 | { |
| 640 | rc = platform_state_sensor::getStateSensorReadingsHandler< |
| 641 | pldm::utils::DBusHandler, Handler>(dBusIntf, *this, sensorId, |
| 642 | sensorRearmCount, comSensorCnt, |
| 643 | stateField); |
| 644 | } |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 645 | |
| 646 | if (rc != PLDM_SUCCESS) |
| 647 | { |
| 648 | return ccOnlyResponse(request, rc); |
| 649 | } |
| 650 | |
| 651 | Response response(sizeof(pldm_msg_hdr) + |
| 652 | PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES + |
| 653 | sizeof(get_sensor_state_field) * comSensorCnt); |
| 654 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 655 | rc = encode_get_state_sensor_readings_resp(request->hdr.instance_id, rc, |
| 656 | comSensorCnt, stateField.data(), |
| 657 | responsePtr); |
| 658 | if (rc != PLDM_SUCCESS) |
| 659 | { |
| 660 | return ccOnlyResponse(request, rc); |
| 661 | } |
| 662 | |
| 663 | return response; |
| 664 | } |
| 665 | |
Sampa Misra | 5fb37d5 | 2021-03-06 07:26:00 -0600 | [diff] [blame] | 666 | void Handler::_processPostGetPDRActions( |
| 667 | sdeventplus::source::EventBase& /*source */) |
| 668 | { |
| 669 | deferredGetPDREvent.reset(); |
| 670 | dbusToPLDMEventHandler->listenSensorEvent(pdrRepo, sensorDbusObjMaps); |
| 671 | } |
| 672 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 673 | bool isOemStateSensor(Handler& handler, uint16_t sensorId, |
| 674 | uint8_t sensorRearmCount, uint8_t& compSensorCnt, |
| 675 | uint16_t& entityType, uint16_t& entityInstance, |
| 676 | uint16_t& stateSetId) |
| 677 | { |
| 678 | pldm_state_sensor_pdr* pdr = nullptr; |
| 679 | |
| 680 | std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)> stateSensorPdrRepo( |
| 681 | pldm_pdr_init(), pldm_pdr_destroy); |
| 682 | Repo stateSensorPDRs(stateSensorPdrRepo.get()); |
| 683 | getRepoByType(handler.getRepo(), stateSensorPDRs, PLDM_STATE_SENSOR_PDR); |
| 684 | if (stateSensorPDRs.empty()) |
| 685 | { |
| 686 | std::cerr << "Failed to get record by PDR type\n"; |
| 687 | return false; |
| 688 | } |
| 689 | |
| 690 | PdrEntry pdrEntry{}; |
| 691 | auto pdrRecord = stateSensorPDRs.getFirstRecord(pdrEntry); |
| 692 | while (pdrRecord) |
| 693 | { |
| 694 | pdr = reinterpret_cast<pldm_state_sensor_pdr*>(pdrEntry.data); |
| 695 | assert(pdr != NULL); |
| 696 | if (pdr->sensor_id != sensorId) |
| 697 | { |
| 698 | pdr = nullptr; |
| 699 | pdrRecord = stateSensorPDRs.getNextRecord(pdrRecord, pdrEntry); |
| 700 | continue; |
| 701 | } |
| 702 | auto tmpEntityType = pdr->entity_type; |
| 703 | auto tmpEntityInstance = pdr->entity_instance; |
| 704 | auto tmpCompSensorCnt = pdr->composite_sensor_count; |
| 705 | auto tmpPossibleStates = |
| 706 | reinterpret_cast<state_sensor_possible_states*>( |
| 707 | pdr->possible_states); |
| 708 | auto tmpStateSetId = tmpPossibleStates->state_set_id; |
| 709 | |
| 710 | if (sensorRearmCount > tmpCompSensorCnt) |
| 711 | { |
| 712 | std::cerr << "The requester sent wrong sensorRearm" |
| 713 | << " count for the sensor, SENSOR_ID=" << sensorId |
| 714 | << "SENSOR_REARM_COUNT=" << (uint16_t)sensorRearmCount |
| 715 | << "\n"; |
| 716 | break; |
| 717 | } |
| 718 | |
| 719 | if ((tmpEntityType >= PLDM_OEM_ENTITY_TYPE_START && |
| 720 | tmpEntityType <= PLDM_OEM_ENTITY_TYPE_END) || |
| 721 | (tmpStateSetId >= PLDM_OEM_STATE_SET_ID_START && |
| 722 | tmpStateSetId < PLDM_OEM_STATE_SET_ID_END)) |
| 723 | { |
| 724 | entityType = tmpEntityType; |
| 725 | entityInstance = tmpEntityInstance; |
| 726 | stateSetId = tmpStateSetId; |
| 727 | compSensorCnt = tmpCompSensorCnt; |
| 728 | return true; |
| 729 | } |
| 730 | else |
| 731 | { |
| 732 | return false; |
| 733 | } |
| 734 | } |
| 735 | return false; |
| 736 | } |
| 737 | |
| 738 | bool isOemStateEffecter(Handler& handler, uint16_t effecterId, |
| 739 | uint8_t compEffecterCnt, uint16_t& entityType, |
| 740 | uint16_t& entityInstance, uint16_t& stateSetId) |
| 741 | { |
| 742 | pldm_state_effecter_pdr* pdr = nullptr; |
| 743 | |
| 744 | std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)> stateEffecterPdrRepo( |
| 745 | pldm_pdr_init(), pldm_pdr_destroy); |
| 746 | Repo stateEffecterPDRs(stateEffecterPdrRepo.get()); |
| 747 | getRepoByType(handler.getRepo(), stateEffecterPDRs, |
| 748 | PLDM_STATE_EFFECTER_PDR); |
| 749 | if (stateEffecterPDRs.empty()) |
| 750 | { |
| 751 | std::cerr << "Failed to get record by PDR type\n"; |
| 752 | return false; |
| 753 | } |
| 754 | |
| 755 | PdrEntry pdrEntry{}; |
| 756 | auto pdrRecord = stateEffecterPDRs.getFirstRecord(pdrEntry); |
| 757 | while (pdrRecord) |
| 758 | { |
| 759 | pdr = reinterpret_cast<pldm_state_effecter_pdr*>(pdrEntry.data); |
| 760 | assert(pdr != NULL); |
| 761 | if (pdr->effecter_id != effecterId) |
| 762 | { |
| 763 | pdr = nullptr; |
| 764 | pdrRecord = stateEffecterPDRs.getNextRecord(pdrRecord, pdrEntry); |
| 765 | continue; |
| 766 | } |
| 767 | |
| 768 | auto tmpEntityType = pdr->entity_type; |
| 769 | auto tmpEntityInstance = pdr->entity_instance; |
| 770 | auto tmpPossibleStates = |
| 771 | reinterpret_cast<state_effecter_possible_states*>( |
| 772 | pdr->possible_states); |
| 773 | auto tmpStateSetId = tmpPossibleStates->state_set_id; |
| 774 | |
| 775 | if (compEffecterCnt > pdr->composite_effecter_count) |
| 776 | { |
| 777 | std::cerr << "The requester sent wrong composite effecter" |
| 778 | << " count for the effecter, EFFECTER_ID=" << effecterId |
| 779 | << "COMP_EFF_CNT=" << (uint16_t)compEffecterCnt << "\n"; |
| 780 | return false; |
| 781 | } |
| 782 | |
| 783 | if ((tmpEntityType >= PLDM_OEM_ENTITY_TYPE_START && |
| 784 | tmpEntityType <= PLDM_OEM_ENTITY_TYPE_END) || |
| 785 | (tmpStateSetId >= PLDM_OEM_STATE_SET_ID_START && |
| 786 | tmpStateSetId < PLDM_OEM_STATE_SET_ID_END)) |
| 787 | { |
| 788 | entityType = tmpEntityType; |
| 789 | entityInstance = tmpEntityInstance; |
| 790 | stateSetId = tmpStateSetId; |
| 791 | return true; |
| 792 | } |
| 793 | else |
| 794 | { |
| 795 | return false; |
| 796 | } |
| 797 | } |
| 798 | return false; |
| 799 | } |
| 800 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 801 | } // namespace platform |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 802 | } // namespace responder |
| 803 | } // namespace pldm |