Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 1 | #include "platform.hpp" |
| 2 | |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 3 | #include "common/types.hpp" |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 4 | #include "common/utils.hpp" |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 5 | #include "event_parser.hpp" |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 6 | #include "pdr.hpp" |
George Liu | 456c9a2 | 2020-01-13 11:36:22 +0800 | [diff] [blame] | 7 | #include "pdr_numeric_effecter.hpp" |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 8 | #include "pdr_state_effecter.hpp" |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 9 | #include "pdr_state_sensor.hpp" |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 10 | #include "pdr_utils.hpp" |
George Liu | eccb0c5 | 2020-01-14 11:09:56 +0800 | [diff] [blame] | 11 | #include "platform_numeric_effecter.hpp" |
George Liu | 0d7aca8 | 2020-03-30 15:01:36 +0800 | [diff] [blame] | 12 | #include "platform_state_effecter.hpp" |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 13 | #include "platform_state_sensor.hpp" |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 14 | #include "pldmd/dbus_impl_requester.hpp" |
| 15 | #include "pldmd/handler.hpp" |
| 16 | #include "requester/handler.hpp" |
George Liu | 8340957 | 2019-12-24 18:42:54 +0800 | [diff] [blame] | 17 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 18 | #include <libpldm/entity.h> |
| 19 | #include <libpldm/state_set.h> |
Manojkiran Eda | cc5f158 | 2021-09-29 17:03:06 +0530 | [diff] [blame] | 20 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 21 | #include <phosphor-logging/lg2.hpp> |
| 22 | |
| 23 | PHOSPHOR_LOG2_USING; |
| 24 | |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 25 | using namespace pldm::utils; |
| 26 | using namespace pldm::responder::pdr; |
| 27 | using namespace pldm::responder::pdr_utils; |
| 28 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 29 | namespace pldm |
| 30 | { |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 31 | namespace responder |
| 32 | { |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 33 | namespace platform |
| 34 | { |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 35 | using InternalFailure = |
| 36 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 37 | |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 38 | static const Json empty{}; |
| 39 | |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 40 | void Handler::addDbusObjMaps( |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 41 | uint16_t id, |
| 42 | std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj, |
| 43 | TypeId typeId) |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 44 | { |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 45 | if (typeId == TypeId::PLDM_SENSOR_ID) |
| 46 | { |
| 47 | sensorDbusObjMaps.emplace(id, dbusObj); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | effecterDbusObjMaps.emplace(id, dbusObj); |
| 52 | } |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 53 | } |
| 54 | |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 55 | const std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>& |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 56 | Handler::getDbusObjMaps(uint16_t id, TypeId typeId) const |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 57 | { |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 58 | if (typeId == TypeId::PLDM_SENSOR_ID) |
| 59 | { |
| 60 | return sensorDbusObjMaps.at(id); |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | return effecterDbusObjMaps.at(id); |
| 65 | } |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 66 | } |
| 67 | |
George Liu | 36e8135 | 2020-07-01 14:40:30 +0800 | [diff] [blame] | 68 | void Handler::generate(const pldm::utils::DBusHandler& dBusIntf, |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 69 | const std::vector<fs::path>& dir, Repo& repo) |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 70 | { |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 71 | for (const auto& directory : dir) |
Deepak Kodihalli | c6e49c4 | 2020-07-01 03:39:27 -0500 | [diff] [blame] | 72 | { |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 73 | info("Checking if directory '{DIRECTORY}' exists", "DIRECTORY", |
| 74 | directory); |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 75 | if (!fs::exists(directory)) |
| 76 | { |
| 77 | return; |
| 78 | } |
Deepak Kodihalli | c6e49c4 | 2020-07-01 03:39:27 -0500 | [diff] [blame] | 79 | } |
| 80 | |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 81 | // A map of PDR type to a lambda that handles creation of that PDR type. |
| 82 | // The lambda essentially would parse the platform specific PDR JSONs to |
| 83 | // generate the PDR structures. This function iterates through the map to |
| 84 | // invoke all lambdas, so that all PDR types can be created. |
George Liu | a287072 | 2020-02-11 11:09:30 +0800 | [diff] [blame] | 85 | |
Patrick Williams | a675662 | 2023-10-20 11:19:15 -0500 | [diff] [blame] | 86 | const std::map<Type, generatePDR> generateHandlers = { |
| 87 | {PLDM_STATE_EFFECTER_PDR, |
| 88 | [this](const DBusHandler& dBusIntf, const auto& json, |
| 89 | RepoInterface& repo) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 90 | pdr_state_effecter::generateStateEffecterPDR<pldm::utils::DBusHandler, |
| 91 | Handler>(dBusIntf, json, |
| 92 | *this, repo); |
Patrick Williams | a675662 | 2023-10-20 11:19:15 -0500 | [diff] [blame] | 93 | }}, |
| 94 | {PLDM_NUMERIC_EFFECTER_PDR, |
| 95 | [this](const DBusHandler& dBusIntf, const auto& json, |
| 96 | RepoInterface& repo) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 97 | pdr_numeric_effecter::generateNumericEffecterPDR< |
| 98 | pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this, repo); |
Patrick Williams | a675662 | 2023-10-20 11:19:15 -0500 | [diff] [blame] | 99 | }}, |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 100 | {PLDM_STATE_SENSOR_PDR, [this](const DBusHandler& dBusIntf, |
| 101 | const auto& json, RepoInterface& repo) { |
Patrick Williams | a675662 | 2023-10-20 11:19:15 -0500 | [diff] [blame] | 102 | pdr_state_sensor::generateStateSensorPDR<pldm::utils::DBusHandler, |
| 103 | Handler>(dBusIntf, json, *this, |
| 104 | repo); |
| 105 | }}}; |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 106 | |
| 107 | Type pdrType{}; |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 108 | for (const auto& directory : dir) |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 109 | { |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 110 | for (const auto& dirEntry : fs::directory_iterator(directory)) |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 111 | { |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 112 | try |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 113 | { |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 114 | if (fs::is_regular_file(dirEntry.path().string())) |
George Liu | 1ec85d4 | 2020-02-12 16:05:32 +0800 | [diff] [blame] | 115 | { |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 116 | auto json = readJson(dirEntry.path().string()); |
| 117 | if (!json.empty()) |
| 118 | { |
| 119 | auto effecterPDRs = json.value("effecterPDRs", empty); |
| 120 | for (const auto& effecter : effecterPDRs) |
| 121 | { |
| 122 | pdrType = effecter.value("pdrType", 0); |
| 123 | generateHandlers.at(pdrType)(dBusIntf, effecter, |
| 124 | repo); |
| 125 | } |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 126 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 127 | auto sensorPDRs = json.value("sensorPDRs", empty); |
| 128 | for (const auto& sensor : sensorPDRs) |
| 129 | { |
| 130 | pdrType = sensor.value("pdrType", 0); |
| 131 | generateHandlers.at(pdrType)(dBusIntf, sensor, |
| 132 | repo); |
| 133 | } |
| 134 | } |
George Liu | adbe172 | 2020-05-09 19:20:19 +0800 | [diff] [blame] | 135 | } |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 136 | } |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 137 | catch (const InternalFailure& e) |
| 138 | { |
| 139 | error( |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 140 | "PDR config directory '{PATH}' does not exist or empty for '{TYPE}' pdr, error - {ERROR}", |
| 141 | "PATH", dirEntry.path(), "TYPE", pdrType, "ERROR", e); |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 142 | } |
| 143 | catch (const Json::exception& e) |
| 144 | { |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 145 | error( |
| 146 | "Failed to parse PDR JSON file for '{TYPE}' pdr, error - {ERROR}", |
| 147 | "TYPE", pdrType, "ERROR", e); |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 148 | pldm::utils::reportError( |
| 149 | "xyz.openbmc_project.PLDM.Error.Generate.PDRJsonFileParseFail"); |
| 150 | } |
| 151 | catch (const std::exception& e) |
| 152 | { |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 153 | error( |
| 154 | "Failed to parse PDR JSON file for '{TYPE}' pdr, error - {ERROR}", |
| 155 | "TYPE", pdrType, "ERROR", e); |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 156 | pldm::utils::reportError( |
| 157 | "xyz.openbmc_project.PLDM.Error.Generate.PDRJsonFileParseFail"); |
| 158 | } |
Deepak Kodihalli | c682fe2 | 2020-03-04 00:42:54 -0600 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | } |
Manojkiran Eda | 92fb0b5 | 2024-04-17 10:48:17 +0530 | [diff] [blame] | 162 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 163 | Response Handler::getPDR(const pldm_msg* request, size_t payloadLength) |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 164 | { |
Pavithra Barithaya | 99854a7 | 2021-09-29 06:58:11 -0500 | [diff] [blame] | 165 | if (hostPDRHandler) |
| 166 | { |
| 167 | if (hostPDRHandler->isHostUp() && oemPlatformHandler != nullptr) |
| 168 | { |
| 169 | auto rc = oemPlatformHandler->checkBMCState(); |
| 170 | if (rc != PLDM_SUCCESS) |
| 171 | { |
| 172 | return ccOnlyResponse(request, PLDM_ERROR_NOT_READY); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // Build FRU table if not built, since entity association PDR's |
| 178 | // are built when the FRU table is constructed. |
Tom Joseph | 33e9c7e | 2020-06-11 22:09:52 +0530 | [diff] [blame] | 179 | if (fruHandler) |
| 180 | { |
| 181 | fruHandler->buildFRUTable(); |
| 182 | } |
| 183 | |
George Liu | d680ae0 | 2020-07-17 09:11:14 +0800 | [diff] [blame] | 184 | if (!pdrCreated) |
| 185 | { |
| 186 | generateTerminusLocatorPDR(pdrRepo); |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 187 | if (platformConfigHandler) |
| 188 | { |
| 189 | auto systemType = platformConfigHandler->getPlatformName(); |
| 190 | if (systemType.has_value()) |
| 191 | { |
| 192 | // In case of normal poweron , the system type would have been |
| 193 | // already filled by entity manager when ever BMC reaches Ready |
| 194 | // state. If this is not filled by time we get a getpdr request |
| 195 | // we can assume that the entity manager service is not present |
| 196 | // on this system & continue to build the common PDR's. |
| 197 | pdrJsonsDir.push_back(pdrJsonDir / systemType.value()); |
| 198 | } |
| 199 | } |
| 200 | |
Sagar Srinivas | 78a225a | 2020-08-27 00:52:20 -0500 | [diff] [blame] | 201 | if (oemPlatformHandler != nullptr) |
| 202 | { |
| 203 | oemPlatformHandler->buildOEMPDR(pdrRepo); |
| 204 | } |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 205 | generate(*dBusIntf, pdrJsonsDir, pdrRepo); |
Sagar Srinivas | 78a225a | 2020-08-27 00:52:20 -0500 | [diff] [blame] | 206 | |
George Liu | d680ae0 | 2020-07-17 09:11:14 +0800 | [diff] [blame] | 207 | pdrCreated = true; |
George Liu | 5eed8e5 | 2020-12-18 11:24:37 +0800 | [diff] [blame] | 208 | |
| 209 | if (dbusToPLDMEventHandler) |
| 210 | { |
Sampa Misra | 5fb37d5 | 2021-03-06 07:26:00 -0600 | [diff] [blame] | 211 | deferredGetPDREvent = std::make_unique<sdeventplus::source::Defer>( |
| 212 | event, |
| 213 | std::bind(std::mem_fn(&pldm::responder::platform::Handler:: |
| 214 | _processPostGetPDRActions), |
| 215 | this, std::placeholders::_1)); |
George Liu | 5eed8e5 | 2020-12-18 11:24:37 +0800 | [diff] [blame] | 216 | } |
George Liu | d680ae0 | 2020-07-17 09:11:14 +0800 | [diff] [blame] | 217 | } |
| 218 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 219 | Response response(sizeof(pldm_msg_hdr) + PLDM_GET_PDR_MIN_RESP_BYTES, 0); |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 220 | |
| 221 | if (payloadLength != PLDM_GET_PDR_REQ_BYTES) |
| 222 | { |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 223 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | uint32_t recordHandle{}; |
| 227 | uint32_t dataTransferHandle{}; |
| 228 | uint8_t transferOpFlag{}; |
| 229 | uint16_t reqSizeBytes{}; |
| 230 | uint16_t recordChangeNum{}; |
| 231 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 232 | auto rc = decode_get_pdr_req(request, payloadLength, &recordHandle, |
| 233 | &dataTransferHandle, &transferOpFlag, |
| 234 | &reqSizeBytes, &recordChangeNum); |
| 235 | if (rc != PLDM_SUCCESS) |
| 236 | { |
| 237 | return CmdHandler::ccOnlyResponse(request, rc); |
| 238 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 239 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 240 | uint16_t respSizeBytes{}; |
| 241 | uint8_t* recordData = nullptr; |
| 242 | try |
| 243 | { |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 244 | pdr_utils::PdrEntry e; |
| 245 | auto record = pdr::getRecordByHandle(pdrRepo, recordHandle, e); |
| 246 | if (record == NULL) |
| 247 | { |
| 248 | return CmdHandler::ccOnlyResponse( |
| 249 | request, PLDM_PLATFORM_INVALID_RECORD_HANDLE); |
| 250 | } |
| 251 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 252 | if (reqSizeBytes) |
| 253 | { |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 254 | respSizeBytes = e.size; |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 255 | if (respSizeBytes > reqSizeBytes) |
| 256 | { |
| 257 | respSizeBytes = reqSizeBytes; |
| 258 | } |
George Liu | e53193f | 2020-02-24 09:23:26 +0800 | [diff] [blame] | 259 | recordData = e.data; |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 260 | } |
| 261 | response.resize(sizeof(pldm_msg_hdr) + PLDM_GET_PDR_MIN_RESP_BYTES + |
| 262 | respSizeBytes, |
| 263 | 0); |
Manojkiran Eda | 31a7844 | 2021-09-12 15:18:25 +0530 | [diff] [blame] | 264 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
Deepak Kodihalli | 22b5a7d | 2020-03-17 23:28:41 -0500 | [diff] [blame] | 265 | rc = encode_get_pdr_resp( |
| 266 | request->hdr.instance_id, PLDM_SUCCESS, e.handle.nextRecordHandle, |
| 267 | 0, PLDM_START_AND_END, respSizeBytes, recordData, 0, responsePtr); |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 268 | if (rc != PLDM_SUCCESS) |
| 269 | { |
| 270 | return ccOnlyResponse(request, rc); |
| 271 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 272 | } |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 273 | catch (const std::exception& e) |
| 274 | { |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 275 | error( |
| 276 | "Failed to access PDR record handle '{RECORD_HANDLE}', error - {ERROR}", |
| 277 | "RECORD_HANDLE", recordHandle, "ERROR", e); |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 278 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR); |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 279 | } |
| 280 | return response; |
| 281 | } |
| 282 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 283 | Response Handler::setStateEffecterStates(const pldm_msg* request, |
| 284 | size_t payloadLength) |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 285 | { |
| 286 | Response response( |
| 287 | sizeof(pldm_msg_hdr) + PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES, 0); |
| 288 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 289 | uint16_t effecterId; |
| 290 | uint8_t compEffecterCnt; |
| 291 | constexpr auto maxCompositeEffecterCnt = 8; |
| 292 | std::vector<set_effecter_state_field> stateField(maxCompositeEffecterCnt, |
| 293 | {0, 0}); |
| 294 | |
| 295 | if ((payloadLength > PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES) || |
| 296 | (payloadLength < sizeof(effecterId) + sizeof(compEffecterCnt) + |
| 297 | sizeof(set_effecter_state_field))) |
| 298 | { |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 299 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | int rc = decode_set_state_effecter_states_req(request, payloadLength, |
| 303 | &effecterId, &compEffecterCnt, |
| 304 | stateField.data()); |
| 305 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 306 | if (rc != PLDM_SUCCESS) |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 307 | { |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 308 | return CmdHandler::ccOnlyResponse(request, rc); |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 309 | } |
| 310 | |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 311 | stateField.resize(compEffecterCnt); |
| 312 | const pldm::utils::DBusHandler dBusIntf; |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 313 | uint16_t entityType{}; |
| 314 | uint16_t entityInstance{}; |
| 315 | uint16_t stateSetId{}; |
| 316 | |
| 317 | if (isOemStateEffecter(*this, effecterId, compEffecterCnt, entityType, |
| 318 | entityInstance, stateSetId) && |
Manojkiran Eda | 321804e | 2022-03-03 12:36:54 +0530 | [diff] [blame] | 319 | oemPlatformHandler != nullptr && |
| 320 | !effecterDbusObjMaps.contains(effecterId)) |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 321 | { |
Sampa Misra | 3a0e3b9 | 2020-10-21 05:58:00 -0500 | [diff] [blame] | 322 | rc = oemPlatformHandler->oemSetStateEffecterStatesHandler( |
Varsha Kaverappa | 3fbd39e | 2020-09-28 01:40:22 -0500 | [diff] [blame] | 323 | entityType, entityInstance, stateSetId, compEffecterCnt, stateField, |
| 324 | effecterId); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 325 | } |
| 326 | else |
| 327 | { |
| 328 | rc = platform_state_effecter::setStateEffecterStatesHandler< |
| 329 | pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId, |
| 330 | stateField); |
| 331 | } |
George Liu | fb8611d | 2019-12-06 10:14:15 +0800 | [diff] [blame] | 332 | if (rc != PLDM_SUCCESS) |
| 333 | { |
| 334 | return CmdHandler::ccOnlyResponse(request, rc); |
| 335 | } |
| 336 | |
| 337 | rc = encode_set_state_effecter_states_resp(request->hdr.instance_id, rc, |
| 338 | responsePtr); |
| 339 | if (rc != PLDM_SUCCESS) |
| 340 | { |
| 341 | return ccOnlyResponse(request, rc); |
| 342 | } |
| 343 | |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 344 | return response; |
| 345 | } |
| 346 | |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 347 | Response Handler::platformEventMessage(const pldm_msg* request, |
| 348 | size_t payloadLength) |
| 349 | { |
| 350 | uint8_t formatVersion{}; |
| 351 | uint8_t tid{}; |
| 352 | uint8_t eventClass{}; |
| 353 | size_t offset{}; |
| 354 | |
| 355 | auto rc = decode_platform_event_message_req( |
| 356 | request, payloadLength, &formatVersion, &tid, &eventClass, &offset); |
| 357 | if (rc != PLDM_SUCCESS) |
| 358 | { |
| 359 | return CmdHandler::ccOnlyResponse(request, rc); |
| 360 | } |
| 361 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 362 | if (eventClass == PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT) |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 363 | { |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 364 | rc = PLDM_SUCCESS; |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 365 | if (oemPlatformHandler) |
| 366 | { |
Sagar Srinivas | 18145f7 | 2022-04-11 07:38:26 -0500 | [diff] [blame] | 367 | if (oemPlatformHandler->watchDogRunning()) |
| 368 | { |
| 369 | oemPlatformHandler->resetWatchDogTimer(); |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | oemPlatformHandler->setSurvTimer(tid, true); |
| 374 | } |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 375 | } |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 376 | } |
| 377 | else |
| 378 | { |
| 379 | try |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 380 | { |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 381 | const auto& handlers = eventHandlers.at(eventClass); |
| 382 | for (const auto& handler : handlers) |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 383 | { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 384 | auto rc = handler(request, payloadLength, formatVersion, tid, |
| 385 | offset); |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 386 | if (rc != PLDM_SUCCESS) |
| 387 | { |
| 388 | return CmdHandler::ccOnlyResponse(request, rc); |
| 389 | } |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 390 | } |
| 391 | } |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 392 | catch (const std::out_of_range& e) |
| 393 | { |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 394 | error("Failed to handle platform event msg, error - {ERROR}", |
| 395 | "ERROR", e); |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 396 | return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_DATA); |
| 397 | } |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 398 | } |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 399 | Response response( |
| 400 | sizeof(pldm_msg_hdr) + PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES, 0); |
| 401 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 402 | |
| 403 | rc = encode_platform_event_message_resp(request->hdr.instance_id, rc, |
| 404 | PLDM_EVENT_NO_LOGGING, responsePtr); |
| 405 | if (rc != PLDM_SUCCESS) |
| 406 | { |
| 407 | return ccOnlyResponse(request, rc); |
| 408 | } |
| 409 | |
| 410 | return response; |
| 411 | } |
| 412 | |
| 413 | int Handler::sensorEvent(const pldm_msg* request, size_t payloadLength, |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 414 | uint8_t /*formatVersion*/, uint8_t tid, |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 415 | size_t eventDataOffset) |
| 416 | { |
| 417 | uint16_t sensorId{}; |
| 418 | uint8_t eventClass{}; |
| 419 | size_t eventClassDataOffset{}; |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 420 | auto eventData = reinterpret_cast<const uint8_t*>(request->payload) + |
| 421 | eventDataOffset; |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 422 | auto eventDataSize = payloadLength - eventDataOffset; |
| 423 | |
| 424 | auto rc = decode_sensor_event_data(eventData, eventDataSize, &sensorId, |
| 425 | &eventClass, &eventClassDataOffset); |
| 426 | if (rc != PLDM_SUCCESS) |
| 427 | { |
| 428 | return rc; |
| 429 | } |
| 430 | |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 431 | auto eventClassData = reinterpret_cast<const uint8_t*>(request->payload) + |
| 432 | eventDataOffset + eventClassDataOffset; |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 433 | auto eventClassDataSize = payloadLength - eventDataOffset - |
| 434 | eventClassDataOffset; |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 435 | |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 436 | if (eventClass == PLDM_STATE_SENSOR_STATE) |
| 437 | { |
| 438 | uint8_t sensorOffset{}; |
| 439 | uint8_t eventState{}; |
| 440 | uint8_t previousEventState{}; |
| 441 | |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 442 | rc = decode_state_sensor_data(eventClassData, eventClassDataSize, |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 443 | &sensorOffset, &eventState, |
| 444 | &previousEventState); |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 445 | if (rc != PLDM_SUCCESS) |
| 446 | { |
| 447 | return PLDM_ERROR; |
| 448 | } |
| 449 | |
Chicago Duan | fe4d88b | 2020-06-12 16:44:13 +0800 | [diff] [blame] | 450 | // Emitting state sensor event signal |
| 451 | emitStateSensorEventSignal(tid, sensorId, sensorOffset, eventState, |
| 452 | previousEventState); |
| 453 | |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 454 | // If there are no HOST PDR's, there is no further action |
| 455 | if (hostPDRHandler == NULL) |
| 456 | { |
| 457 | return PLDM_SUCCESS; |
| 458 | } |
| 459 | |
| 460 | // Handle PLDM events for which PDR is available |
| 461 | SensorEntry sensorEntry{tid, sensorId}; |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 462 | |
| 463 | pldm::pdr::EntityInfo entityInfo{}; |
| 464 | pldm::pdr::CompositeSensorStates compositeSensorStates{}; |
Sagar Srinivas | e3607a3 | 2024-02-16 03:50:53 -0600 | [diff] [blame] | 465 | std::vector<pldm::pdr::StateSetId> stateSetIds{}; |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 466 | |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 467 | try |
| 468 | { |
Sagar Srinivas | e3607a3 | 2024-02-16 03:50:53 -0600 | [diff] [blame] | 469 | std::tie(entityInfo, compositeSensorStates, stateSetIds) = |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 470 | hostPDRHandler->lookupSensorInfo(sensorEntry); |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 471 | } |
Kamalkumar Patel | 58cbcaf | 2023-10-06 03:48:25 -0500 | [diff] [blame] | 472 | catch (const std::out_of_range&) |
Tom Joseph | c4959c3 | 2020-04-20 19:50:16 +0530 | [diff] [blame] | 473 | { |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 474 | // If there is no mapping for tid, sensorId combination, try |
| 475 | // PLDM_TID_RESERVED, sensorId for terminus that is yet to |
| 476 | // implement TL PDR. |
| 477 | try |
| 478 | { |
| 479 | sensorEntry.terminusID = PLDM_TID_RESERVED; |
Sagar Srinivas | e3607a3 | 2024-02-16 03:50:53 -0600 | [diff] [blame] | 480 | std::tie(entityInfo, compositeSensorStates, stateSetIds) = |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 481 | hostPDRHandler->lookupSensorInfo(sensorEntry); |
| 482 | } |
| 483 | // If there is no mapping for events return PLDM_SUCCESS |
Kamalkumar Patel | 58cbcaf | 2023-10-06 03:48:25 -0500 | [diff] [blame] | 484 | catch (const std::out_of_range&) |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 485 | { |
| 486 | return PLDM_SUCCESS; |
| 487 | } |
Zahed Hossain | 75330f3 | 2020-03-24 02:15:03 -0500 | [diff] [blame] | 488 | } |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 489 | |
| 490 | if (sensorOffset >= compositeSensorStates.size()) |
| 491 | { |
| 492 | return PLDM_ERROR_INVALID_DATA; |
| 493 | } |
| 494 | |
| 495 | const auto& possibleStates = compositeSensorStates[sensorOffset]; |
Sagar Srinivas | 06f9b29 | 2024-03-31 11:35:28 -0500 | [diff] [blame] | 496 | if (!possibleStates.contains(eventState)) |
Tom Joseph | b70a196 | 2020-07-13 12:56:31 +0530 | [diff] [blame] | 497 | { |
| 498 | return PLDM_ERROR_INVALID_DATA; |
| 499 | } |
| 500 | |
| 501 | const auto& [containerId, entityType, entityInstance] = entityInfo; |
Manojkiran Eda | fa08470 | 2024-05-27 10:20:30 +0530 | [diff] [blame] | 502 | events::StateSensorEntry stateSensorEntry{containerId, |
| 503 | entityType, |
| 504 | entityInstance, |
| 505 | sensorOffset, |
| 506 | stateSetIds[sensorOffset], |
| 507 | false}; |
Pavithra Barithaya | 3aec997 | 2020-12-14 01:55:44 -0600 | [diff] [blame] | 508 | return hostPDRHandler->handleStateSensorEvent(stateSensorEntry, |
| 509 | eventState); |
Tom Joseph | 56e45c5 | 2020-03-16 10:01:45 +0530 | [diff] [blame] | 510 | } |
| 511 | else |
| 512 | { |
| 513 | return PLDM_ERROR_INVALID_DATA; |
| 514 | } |
| 515 | |
| 516 | return PLDM_SUCCESS; |
| 517 | } |
| 518 | |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 519 | int Handler::pldmPDRRepositoryChgEvent(const pldm_msg* request, |
| 520 | size_t payloadLength, |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 521 | uint8_t /*formatVersion*/, uint8_t tid, |
| 522 | size_t eventDataOffset) |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 523 | { |
| 524 | uint8_t eventDataFormat{}; |
| 525 | uint8_t numberOfChangeRecords{}; |
| 526 | size_t dataOffset{}; |
| 527 | |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 528 | auto eventData = reinterpret_cast<const uint8_t*>(request->payload) + |
| 529 | eventDataOffset; |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 530 | auto eventDataSize = payloadLength - eventDataOffset; |
| 531 | |
| 532 | auto rc = decode_pldm_pdr_repository_chg_event_data( |
| 533 | eventData, eventDataSize, &eventDataFormat, &numberOfChangeRecords, |
| 534 | &dataOffset); |
| 535 | if (rc != PLDM_SUCCESS) |
| 536 | { |
| 537 | return rc; |
| 538 | } |
| 539 | |
| 540 | PDRRecordHandles pdrRecordHandles; |
Deepak Kodihalli | 7246e0c | 2020-07-08 06:40:18 -0500 | [diff] [blame] | 541 | |
| 542 | if (eventDataFormat == FORMAT_IS_PDR_TYPES) |
| 543 | { |
| 544 | return PLDM_ERROR_INVALID_DATA; |
| 545 | } |
| 546 | |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 547 | if (eventDataFormat == FORMAT_IS_PDR_HANDLES) |
| 548 | { |
| 549 | uint8_t eventDataOperation{}; |
| 550 | uint8_t numberOfChangeEntries{}; |
| 551 | |
| 552 | auto changeRecordData = eventData + dataOffset; |
| 553 | auto changeRecordDataSize = eventDataSize - dataOffset; |
| 554 | |
| 555 | while (changeRecordDataSize) |
| 556 | { |
| 557 | rc = decode_pldm_pdr_repository_change_record_data( |
| 558 | changeRecordData, changeRecordDataSize, &eventDataOperation, |
| 559 | &numberOfChangeEntries, &dataOffset); |
| 560 | |
| 561 | if (rc != PLDM_SUCCESS) |
| 562 | { |
| 563 | return rc; |
| 564 | } |
| 565 | |
Pavithra Barithaya | ae5c97e | 2022-08-29 02:57:59 -0500 | [diff] [blame] | 566 | if (eventDataOperation == PLDM_RECORDS_ADDED || |
| 567 | eventDataOperation == PLDM_RECORDS_MODIFIED) |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 568 | { |
Pavithra Barithaya | ae5c97e | 2022-08-29 02:57:59 -0500 | [diff] [blame] | 569 | if (eventDataOperation == PLDM_RECORDS_MODIFIED) |
| 570 | { |
| 571 | hostPDRHandler->isHostPdrModified = true; |
| 572 | } |
| 573 | |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 574 | rc = getPDRRecordHandles( |
| 575 | reinterpret_cast<const ChangeEntry*>(changeRecordData + |
| 576 | dataOffset), |
| 577 | changeRecordDataSize - dataOffset, |
| 578 | static_cast<size_t>(numberOfChangeEntries), |
| 579 | pdrRecordHandles); |
| 580 | |
| 581 | if (rc != PLDM_SUCCESS) |
| 582 | { |
| 583 | return rc; |
| 584 | } |
| 585 | } |
| 586 | |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 587 | changeRecordData += dataOffset + |
| 588 | (numberOfChangeEntries * sizeof(ChangeEntry)); |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 589 | changeRecordDataSize -= |
| 590 | dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry)); |
| 591 | } |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 592 | } |
Deepak Kodihalli | 7246e0c | 2020-07-08 06:40:18 -0500 | [diff] [blame] | 593 | if (hostPDRHandler) |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 594 | { |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 595 | // if we get a Repository change event with the eventDataFormat |
| 596 | // as REFRESH_ENTIRE_REPOSITORY, then delete all the PDR's that |
| 597 | // have the matched Terminus handle |
| 598 | if (eventDataFormat == REFRESH_ENTIRE_REPOSITORY) |
| 599 | { |
| 600 | // We cannot get the Repo change event from the Terminus |
| 601 | // that is not already added to the BMC repository |
| 602 | |
Pavithra Barithaya | 52aad39 | 2022-08-02 04:18:52 -0500 | [diff] [blame] | 603 | for (auto it = hostPDRHandler->tlPDRInfo.cbegin(); |
| 604 | it != hostPDRHandler->tlPDRInfo.cend();) |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 605 | { |
Pavithra Barithaya | 52aad39 | 2022-08-02 04:18:52 -0500 | [diff] [blame] | 606 | if (std::get<0>(it->second) == tid) |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 607 | { |
| 608 | pldm_pdr_remove_pdrs_by_terminus_handle(pdrRepo.getPdr(), |
Pavithra Barithaya | 52aad39 | 2022-08-02 04:18:52 -0500 | [diff] [blame] | 609 | it->first); |
| 610 | hostPDRHandler->tlPDRInfo.erase(it++); |
| 611 | } |
| 612 | else |
| 613 | { |
| 614 | ++it; |
Manojkiran Eda | 3ca4045 | 2021-10-04 22:51:37 +0530 | [diff] [blame] | 615 | } |
| 616 | } |
| 617 | } |
Deepak Kodihalli | 7246e0c | 2020-07-08 06:40:18 -0500 | [diff] [blame] | 618 | hostPDRHandler->fetchPDR(std::move(pdrRecordHandles)); |
Deepak Kodihalli | 8cb6f66 | 2020-04-10 02:55:43 -0500 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | return PLDM_SUCCESS; |
| 622 | } |
| 623 | |
| 624 | int Handler::getPDRRecordHandles(const ChangeEntry* changeEntryData, |
| 625 | size_t changeEntryDataSize, |
| 626 | size_t numberOfChangeEntries, |
| 627 | PDRRecordHandles& pdrRecordHandles) |
| 628 | { |
| 629 | if (numberOfChangeEntries > (changeEntryDataSize / sizeof(ChangeEntry))) |
| 630 | { |
| 631 | return PLDM_ERROR_INVALID_DATA; |
| 632 | } |
| 633 | for (size_t i = 0; i < numberOfChangeEntries; i++) |
| 634 | { |
| 635 | pdrRecordHandles.push_back(changeEntryData[i]); |
| 636 | } |
| 637 | return PLDM_SUCCESS; |
| 638 | } |
| 639 | |
Archana Kakani | 6ece21fb | 2023-10-10 08:21:52 -0500 | [diff] [blame] | 640 | Response Handler::getNumericEffecterValue(const pldm_msg* request, |
| 641 | size_t payloadLength) |
| 642 | { |
| 643 | if (payloadLength != PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES) |
| 644 | { |
| 645 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 646 | } |
| 647 | |
| 648 | uint16_t effecterId{}; |
| 649 | auto rc = decode_get_numeric_effecter_value_req(request, payloadLength, |
| 650 | &effecterId); |
| 651 | if (rc != PLDM_SUCCESS) |
| 652 | { |
| 653 | return ccOnlyResponse(request, rc); |
| 654 | } |
| 655 | |
| 656 | const pldm::utils::DBusHandler dBusIntf; |
| 657 | uint8_t effecterDataSize{}; |
| 658 | pldm::utils::PropertyValue dbusValue; |
| 659 | std::string propertyType; |
| 660 | using effecterOperationalState = uint8_t; |
| 661 | using completionCode = uint8_t; |
| 662 | |
| 663 | rc = platform_numeric_effecter::getNumericEffecterData< |
| 664 | pldm::utils::DBusHandler, Handler>( |
| 665 | dBusIntf, *this, effecterId, effecterDataSize, propertyType, dbusValue); |
| 666 | |
| 667 | if (rc != PLDM_SUCCESS) |
| 668 | { |
| 669 | return ccOnlyResponse(request, rc); |
| 670 | } |
| 671 | |
| 672 | // Refer DSP0248_1.2.0.pdf (section 22.3, Table 48) |
| 673 | // Completion Code (uint8), Effecter Data Size(uint8), Effecter Operational |
| 674 | // State(uint8), PendingValue (uint8|sint8|uint16|sint16|uint32|sint32 ) |
| 675 | // PresentValue (uint8|sint8|uint16|sint16|uint32|sint32 ) |
| 676 | // Size of PendingValue and PresentValue calculated based on size is |
| 677 | // provided in effecter data size |
| 678 | size_t responsePayloadLength = sizeof(completionCode) + |
| 679 | sizeof(effecterDataSize) + |
| 680 | sizeof(effecterOperationalState) + |
| 681 | getEffecterDataSize(effecterDataSize) + |
| 682 | getEffecterDataSize(effecterDataSize); |
| 683 | |
| 684 | Response response(responsePayloadLength + sizeof(pldm_msg_hdr)); |
| 685 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 686 | |
| 687 | rc = platform_numeric_effecter::getNumericEffecterValueHandler( |
| 688 | propertyType, dbusValue, effecterDataSize, responsePtr, |
| 689 | responsePayloadLength, request->hdr.instance_id); |
| 690 | |
| 691 | if (rc != PLDM_SUCCESS) |
| 692 | { |
| 693 | error( |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 694 | "Failed to get response of GetNumericEffecterValue for effecter ID '{EFFECTERID}', response code '{RC}'.", |
| 695 | "EFFECTERID", effecterId, "RC", rc); |
Archana Kakani | 6ece21fb | 2023-10-10 08:21:52 -0500 | [diff] [blame] | 696 | return ccOnlyResponse(request, rc); |
| 697 | } |
| 698 | return response; |
| 699 | } |
| 700 | |
George Liu | eccb0c5 | 2020-01-14 11:09:56 +0800 | [diff] [blame] | 701 | Response Handler::setNumericEffecterValue(const pldm_msg* request, |
| 702 | size_t payloadLength) |
| 703 | { |
| 704 | Response response(sizeof(pldm_msg_hdr) + |
| 705 | PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES); |
| 706 | uint16_t effecterId{}; |
| 707 | uint8_t effecterDataSize{}; |
| 708 | uint8_t effecterValue[4] = {}; |
| 709 | |
| 710 | if ((payloadLength > sizeof(effecterId) + sizeof(effecterDataSize) + |
| 711 | sizeof(union_effecter_data_size)) || |
| 712 | (payloadLength < sizeof(effecterId) + sizeof(effecterDataSize) + 1)) |
| 713 | { |
| 714 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 715 | } |
| 716 | |
| 717 | int rc = decode_set_numeric_effecter_value_req( |
Andrew Jeffery | 8fbf3cc | 2023-04-12 13:42:29 +0930 | [diff] [blame] | 718 | request, payloadLength, &effecterId, &effecterDataSize, effecterValue); |
George Liu | eccb0c5 | 2020-01-14 11:09:56 +0800 | [diff] [blame] | 719 | |
| 720 | if (rc == PLDM_SUCCESS) |
| 721 | { |
| 722 | const pldm::utils::DBusHandler dBusIntf; |
| 723 | rc = platform_numeric_effecter::setNumericEffecterValueHandler< |
| 724 | pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId, |
| 725 | effecterDataSize, effecterValue, |
| 726 | sizeof(effecterValue)); |
| 727 | } |
| 728 | |
| 729 | return ccOnlyResponse(request, rc); |
| 730 | } |
| 731 | |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 732 | void Handler::generateTerminusLocatorPDR(Repo& repo) |
| 733 | { |
| 734 | std::vector<uint8_t> pdrBuffer(sizeof(pldm_terminus_locator_pdr)); |
| 735 | |
| 736 | auto pdr = reinterpret_cast<pldm_terminus_locator_pdr*>(pdrBuffer.data()); |
| 737 | |
| 738 | pdr->hdr.record_handle = 0; |
| 739 | pdr->hdr.version = 1; |
| 740 | pdr->hdr.type = PLDM_TERMINUS_LOCATOR_PDR; |
| 741 | pdr->hdr.record_change_num = 0; |
| 742 | pdr->hdr.length = sizeof(pldm_terminus_locator_pdr) - sizeof(pldm_pdr_hdr); |
Manojkiran Eda | cc5f158 | 2021-09-29 17:03:06 +0530 | [diff] [blame] | 743 | pdr->terminus_handle = TERMINUS_HANDLE; |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 744 | pdr->validity = PLDM_TL_PDR_VALID; |
Manojkiran Eda | cc5f158 | 2021-09-29 17:03:06 +0530 | [diff] [blame] | 745 | pdr->tid = TERMINUS_ID; |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 746 | pdr->container_id = 0x0; |
| 747 | pdr->terminus_locator_type = PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID; |
| 748 | pdr->terminus_locator_value_size = |
| 749 | sizeof(pldm_terminus_locator_type_mctp_eid); |
| 750 | auto locatorValue = reinterpret_cast<pldm_terminus_locator_type_mctp_eid*>( |
| 751 | pdr->terminus_locator_value); |
| 752 | locatorValue->eid = BmcMctpEid; |
| 753 | |
| 754 | PdrEntry pdrEntry{}; |
| 755 | pdrEntry.data = pdrBuffer.data(); |
| 756 | pdrEntry.size = pdrBuffer.size(); |
| 757 | repo.addRecord(pdrEntry); |
Manojkiran Eda | 60e1fe9 | 2021-10-08 15:58:16 +0530 | [diff] [blame] | 758 | if (hostPDRHandler) |
| 759 | { |
| 760 | hostPDRHandler->tlPDRInfo.insert_or_assign( |
| 761 | pdr->terminus_handle, |
| 762 | std::make_tuple(pdr->tid, locatorValue->eid, pdr->validity)); |
| 763 | } |
Sampa Misra | 12afe11 | 2020-05-25 11:40:44 -0500 | [diff] [blame] | 764 | } |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 765 | |
| 766 | Response Handler::getStateSensorReadings(const pldm_msg* request, |
| 767 | size_t payloadLength) |
| 768 | { |
| 769 | uint16_t sensorId{}; |
| 770 | bitfield8_t sensorRearm{}; |
| 771 | uint8_t reserved{}; |
| 772 | |
Pavithra Barithaya | 87083f2 | 2023-04-17 01:27:49 -0500 | [diff] [blame] | 773 | if (payloadLength != PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES) |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 774 | { |
| 775 | return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH); |
| 776 | } |
| 777 | |
| 778 | int rc = decode_get_state_sensor_readings_req( |
| 779 | request, payloadLength, &sensorId, &sensorRearm, &reserved); |
| 780 | |
| 781 | if (rc != PLDM_SUCCESS) |
| 782 | { |
| 783 | return ccOnlyResponse(request, rc); |
| 784 | } |
| 785 | |
| 786 | // 0x01 to 0x08 |
George Liu | c1230ca | 2021-08-03 16:06:50 +0800 | [diff] [blame] | 787 | uint8_t sensorRearmCount = std::popcount(sensorRearm.byte); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 788 | std::vector<get_sensor_state_field> stateField(sensorRearmCount); |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 789 | uint8_t comSensorCnt{}; |
| 790 | const pldm::utils::DBusHandler dBusIntf; |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 791 | |
| 792 | uint16_t entityType{}; |
| 793 | uint16_t entityInstance{}; |
| 794 | uint16_t stateSetId{}; |
| 795 | |
| 796 | if (isOemStateSensor(*this, sensorId, sensorRearmCount, comSensorCnt, |
| 797 | entityType, entityInstance, stateSetId) && |
Manojkiran Eda | 321804e | 2022-03-03 12:36:54 +0530 | [diff] [blame] | 798 | oemPlatformHandler != nullptr && !sensorDbusObjMaps.contains(sensorId)) |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 799 | { |
| 800 | rc = oemPlatformHandler->getOemStateSensorReadingsHandler( |
| 801 | entityType, entityInstance, stateSetId, comSensorCnt, stateField); |
| 802 | } |
| 803 | else |
| 804 | { |
| 805 | rc = platform_state_sensor::getStateSensorReadingsHandler< |
Manojkiran Eda | ae933cc | 2024-02-21 17:19:21 +0530 | [diff] [blame] | 806 | pldm::utils::DBusHandler, Handler>( |
| 807 | dBusIntf, *this, sensorId, sensorRearmCount, comSensorCnt, |
| 808 | stateField, dbusToPLDMEventHandler->getSensorCache()); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 809 | } |
George Liu | 362c18d | 2020-05-14 09:46:36 +0800 | [diff] [blame] | 810 | |
| 811 | if (rc != PLDM_SUCCESS) |
| 812 | { |
| 813 | return ccOnlyResponse(request, rc); |
| 814 | } |
| 815 | |
| 816 | Response response(sizeof(pldm_msg_hdr) + |
| 817 | PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES + |
| 818 | sizeof(get_sensor_state_field) * comSensorCnt); |
| 819 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 820 | rc = encode_get_state_sensor_readings_resp(request->hdr.instance_id, rc, |
| 821 | comSensorCnt, stateField.data(), |
| 822 | responsePtr); |
| 823 | if (rc != PLDM_SUCCESS) |
| 824 | { |
| 825 | return ccOnlyResponse(request, rc); |
| 826 | } |
| 827 | |
| 828 | return response; |
| 829 | } |
| 830 | |
Pavithra Barithaya | 99854a7 | 2021-09-29 06:58:11 -0500 | [diff] [blame] | 831 | void Handler::_processPostGetPDRActions(sdeventplus::source::EventBase& |
| 832 | /*source */) |
Sampa Misra | 5fb37d5 | 2021-03-06 07:26:00 -0600 | [diff] [blame] | 833 | { |
| 834 | deferredGetPDREvent.reset(); |
| 835 | dbusToPLDMEventHandler->listenSensorEvent(pdrRepo, sensorDbusObjMaps); |
| 836 | } |
| 837 | |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 838 | bool isOemStateSensor(Handler& handler, uint16_t sensorId, |
| 839 | uint8_t sensorRearmCount, uint8_t& compSensorCnt, |
| 840 | uint16_t& entityType, uint16_t& entityInstance, |
| 841 | uint16_t& stateSetId) |
| 842 | { |
| 843 | pldm_state_sensor_pdr* pdr = nullptr; |
| 844 | |
| 845 | std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)> stateSensorPdrRepo( |
| 846 | pldm_pdr_init(), pldm_pdr_destroy); |
Andrew Jeffery | acb2029 | 2023-06-30 11:47:44 +0930 | [diff] [blame] | 847 | if (!stateSensorPdrRepo) |
| 848 | { |
| 849 | error("Failed to instantiate state sensor PDR repository"); |
| 850 | return false; |
| 851 | } |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 852 | Repo stateSensorPDRs(stateSensorPdrRepo.get()); |
| 853 | getRepoByType(handler.getRepo(), stateSensorPDRs, PLDM_STATE_SENSOR_PDR); |
| 854 | if (stateSensorPDRs.empty()) |
| 855 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 856 | error("Failed to get record by PDR type"); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 857 | return false; |
| 858 | } |
| 859 | |
| 860 | PdrEntry pdrEntry{}; |
| 861 | auto pdrRecord = stateSensorPDRs.getFirstRecord(pdrEntry); |
| 862 | while (pdrRecord) |
| 863 | { |
| 864 | pdr = reinterpret_cast<pldm_state_sensor_pdr*>(pdrEntry.data); |
| 865 | assert(pdr != NULL); |
| 866 | if (pdr->sensor_id != sensorId) |
| 867 | { |
| 868 | pdr = nullptr; |
| 869 | pdrRecord = stateSensorPDRs.getNextRecord(pdrRecord, pdrEntry); |
| 870 | continue; |
| 871 | } |
| 872 | auto tmpEntityType = pdr->entity_type; |
| 873 | auto tmpEntityInstance = pdr->entity_instance; |
| 874 | auto tmpCompSensorCnt = pdr->composite_sensor_count; |
| 875 | auto tmpPossibleStates = |
| 876 | reinterpret_cast<state_sensor_possible_states*>( |
| 877 | pdr->possible_states); |
| 878 | auto tmpStateSetId = tmpPossibleStates->state_set_id; |
| 879 | |
| 880 | if (sensorRearmCount > tmpCompSensorCnt) |
| 881 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 882 | error( |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 883 | "The requester sent wrong sensor rearm count '{SENSOR_REARM_COUNT}' for the sensor ID '{SENSORID}'.", |
| 884 | "SENSOR_REARM_COUNT", (uint16_t)sensorRearmCount, "SENSORID", |
| 885 | sensorId); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 886 | break; |
| 887 | } |
| 888 | |
| 889 | if ((tmpEntityType >= PLDM_OEM_ENTITY_TYPE_START && |
| 890 | tmpEntityType <= PLDM_OEM_ENTITY_TYPE_END) || |
| 891 | (tmpStateSetId >= PLDM_OEM_STATE_SET_ID_START && |
| 892 | tmpStateSetId < PLDM_OEM_STATE_SET_ID_END)) |
| 893 | { |
| 894 | entityType = tmpEntityType; |
| 895 | entityInstance = tmpEntityInstance; |
| 896 | stateSetId = tmpStateSetId; |
| 897 | compSensorCnt = tmpCompSensorCnt; |
| 898 | return true; |
| 899 | } |
| 900 | else |
| 901 | { |
| 902 | return false; |
| 903 | } |
| 904 | } |
| 905 | return false; |
| 906 | } |
| 907 | |
| 908 | bool isOemStateEffecter(Handler& handler, uint16_t effecterId, |
| 909 | uint8_t compEffecterCnt, uint16_t& entityType, |
| 910 | uint16_t& entityInstance, uint16_t& stateSetId) |
| 911 | { |
| 912 | pldm_state_effecter_pdr* pdr = nullptr; |
| 913 | |
| 914 | std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)> stateEffecterPdrRepo( |
| 915 | pldm_pdr_init(), pldm_pdr_destroy); |
Andrew Jeffery | acb2029 | 2023-06-30 11:47:44 +0930 | [diff] [blame] | 916 | if (!stateEffecterPdrRepo) |
| 917 | { |
| 918 | error("Failed to instantiate state effecter PDR repository"); |
| 919 | return false; |
| 920 | } |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 921 | Repo stateEffecterPDRs(stateEffecterPdrRepo.get()); |
| 922 | getRepoByType(handler.getRepo(), stateEffecterPDRs, |
| 923 | PLDM_STATE_EFFECTER_PDR); |
| 924 | if (stateEffecterPDRs.empty()) |
| 925 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 926 | error("Failed to get record by PDR type"); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 927 | return false; |
| 928 | } |
| 929 | |
| 930 | PdrEntry pdrEntry{}; |
| 931 | auto pdrRecord = stateEffecterPDRs.getFirstRecord(pdrEntry); |
| 932 | while (pdrRecord) |
| 933 | { |
| 934 | pdr = reinterpret_cast<pldm_state_effecter_pdr*>(pdrEntry.data); |
| 935 | assert(pdr != NULL); |
| 936 | if (pdr->effecter_id != effecterId) |
| 937 | { |
| 938 | pdr = nullptr; |
| 939 | pdrRecord = stateEffecterPDRs.getNextRecord(pdrRecord, pdrEntry); |
| 940 | continue; |
| 941 | } |
| 942 | |
| 943 | auto tmpEntityType = pdr->entity_type; |
| 944 | auto tmpEntityInstance = pdr->entity_instance; |
| 945 | auto tmpPossibleStates = |
| 946 | reinterpret_cast<state_effecter_possible_states*>( |
| 947 | pdr->possible_states); |
| 948 | auto tmpStateSetId = tmpPossibleStates->state_set_id; |
| 949 | |
| 950 | if (compEffecterCnt > pdr->composite_effecter_count) |
| 951 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 952 | error( |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 953 | "The requester sent wrong composite effecter count '{COMPOSITE_EFFECTER_COUNT}' for the effecter ID '{EFFECTERID}'.", |
Riya Dixit | 1e5c81e | 2024-05-03 07:54:00 -0500 | [diff] [blame] | 954 | "COMPOSITE_EFFECTER_COUNT", compEffecterCnt, "EFFECTERID", |
| 955 | effecterId); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 956 | return false; |
| 957 | } |
| 958 | |
| 959 | if ((tmpEntityType >= PLDM_OEM_ENTITY_TYPE_START && |
| 960 | tmpEntityType <= PLDM_OEM_ENTITY_TYPE_END) || |
| 961 | (tmpStateSetId >= PLDM_OEM_STATE_SET_ID_START && |
| 962 | tmpStateSetId < PLDM_OEM_STATE_SET_ID_END)) |
| 963 | { |
| 964 | entityType = tmpEntityType; |
| 965 | entityInstance = tmpEntityInstance; |
| 966 | stateSetId = tmpStateSetId; |
| 967 | return true; |
| 968 | } |
| 969 | else |
| 970 | { |
| 971 | return false; |
| 972 | } |
| 973 | } |
| 974 | return false; |
| 975 | } |
| 976 | |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 977 | void Handler::setEventReceiver() |
| 978 | { |
| 979 | std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) + |
| 980 | PLDM_SET_EVENT_RECEIVER_REQ_BYTES); |
| 981 | auto request = reinterpret_cast<pldm_msg*>(requestMsg.data()); |
| 982 | auto instanceId = instanceIdDb->next(eid); |
| 983 | uint8_t eventMessageGlobalEnable = |
| 984 | PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE; |
| 985 | uint8_t transportProtocolType = PLDM_TRANSPORT_PROTOCOL_TYPE_MCTP; |
| 986 | uint8_t eventReceiverAddressInfo = pldm::responder::pdr::BmcMctpEid; |
| 987 | uint16_t heartbeatTimer = HEARTBEAT_TIMEOUT; |
| 988 | |
| 989 | auto rc = encode_set_event_receiver_req( |
| 990 | instanceId, eventMessageGlobalEnable, transportProtocolType, |
| 991 | eventReceiverAddressInfo, heartbeatTimer, request); |
| 992 | if (rc != PLDM_SUCCESS) |
| 993 | { |
| 994 | instanceIdDb->free(eid, instanceId); |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 995 | error( |
| 996 | "Failed to encode set event receiver request, response code '{RC}'", |
| 997 | "RC", lg2::hex, rc); |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 998 | return; |
| 999 | } |
| 1000 | |
| 1001 | auto processSetEventReceiverResponse = |
| 1002 | [](mctp_eid_t /*eid*/, const pldm_msg* response, size_t respMsgLen) { |
| 1003 | if (response == nullptr || !respMsgLen) |
| 1004 | { |
| 1005 | error("Failed to receive response for setEventReceiver command"); |
| 1006 | return; |
| 1007 | } |
| 1008 | |
| 1009 | uint8_t completionCode{}; |
| 1010 | auto rc = decode_set_event_receiver_resp(response, respMsgLen, |
| 1011 | &completionCode); |
| 1012 | if (rc || completionCode) |
| 1013 | { |
| 1014 | error( |
Riya Dixit | 8964444 | 2024-03-31 05:39:59 -0500 | [diff] [blame] | 1015 | "Failed to decode setEventReceiver command, response code '{RC}' and completion code '{CC}'", |
Riya Dixit | 1e5c81e | 2024-05-03 07:54:00 -0500 | [diff] [blame] | 1016 | "RC", rc, "CC", completionCode); |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 1017 | pldm::utils::reportError( |
Manojkiran Eda | 92fb0b5 | 2024-04-17 10:48:17 +0530 | [diff] [blame] | 1018 | "xyz.openbmc_project.bmc.pldm.InternalFailure"); |
Sagar Srinivas | 90314a3 | 2023-10-17 10:38:03 -0500 | [diff] [blame] | 1019 | } |
| 1020 | }; |
| 1021 | rc = handler->registerRequest( |
| 1022 | eid, instanceId, PLDM_PLATFORM, PLDM_SET_EVENT_RECEIVER, |
| 1023 | std::move(requestMsg), std::move(processSetEventReceiverResponse)); |
| 1024 | |
| 1025 | if (rc != PLDM_SUCCESS) |
| 1026 | { |
| 1027 | error("Failed to send the setEventReceiver request"); |
| 1028 | } |
| 1029 | |
| 1030 | if (oemPlatformHandler) |
| 1031 | { |
| 1032 | oemPlatformHandler->countSetEventReceiver(); |
| 1033 | oemPlatformHandler->checkAndDisableWatchDog(); |
| 1034 | } |
| 1035 | } |
| 1036 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 1037 | } // namespace platform |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 1038 | } // namespace responder |
| 1039 | } // namespace pldm |