blob: af89a945f12cdc72e5520c67cdafa496a3c3cb3c [file] [log] [blame]
Deepak Kodihalli557dfb02019-05-12 13:11:17 +05301
2#include "platform.hpp"
3
Deepak Kodihallid130e1a2020-06-17 05:55:32 -05004#include "common/utils.hpp"
Tom Josephc4959c32020-04-20 19:50:16 +05305#include "event_parser.hpp"
George Liu456c9a22020-01-13 11:36:22 +08006#include "pdr_numeric_effecter.hpp"
George Liua2870722020-02-11 11:09:30 +08007#include "pdr_state_effecter.hpp"
George Liueccb0c52020-01-14 11:09:56 +08008#include "platform_numeric_effecter.hpp"
George Liu0d7aca82020-03-30 15:01:36 +08009#include "platform_state_effecter.hpp"
George Liu83409572019-12-24 18:42:54 +080010
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053011namespace pldm
12{
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053013namespace responder
14{
Sampa Misraa2fa0702019-05-31 01:28:55 -050015namespace platform
16{
17
Deepak Kodihallic682fe22020-03-04 00:42:54 -060018using InternalFailure =
19 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
20
George Liu1ec85d42020-02-12 16:05:32 +080021static const Json empty{};
22
Zahed Hossain75330f32020-03-24 02:15:03 -050023using EventEntryMap = std::map<EventEntry, DBusInfo>;
24
25const EventEntryMap eventEntryMap = {
26 {
27 0x01010007, // SensorID for VMI Port 0 ipv4 = 7, SensorOffset for the
28 // State Set ID 15 = 1 & PLDM State Set Enumeration List = 1
29 // (Valid Configuration)
30 {"/xyz/openbmc_project/network/vmi/intf0/ipv4/addr0",
31 "xyz.openbmc_project.Object.Enable", "Enabled", "bool", true},
32 },
33 {
34 0x02010007, // SensorID for VMI Port 0 ipv4 = 7, SensorOffset for the
35 // State Set ID 15 = 1 & PLDM State Set Enumeration List = 2
36 // (Invalid Configuration)
37 {"/xyz/openbmc_project/network/vmi/intf0/ipv4/addr0",
38 "xyz.openbmc_project.Object.Enable", "Enabled", "bool", false},
39 },
40 {
41 0x01010008, // SensorID for VMI Port 1 ipv4 = 8, SensorOffset for the
42 // State Set ID 15 = 1 & PLDM State Set Enumeration List = 1
43 // (Valid Configuration)
44 {"/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0",
45 "xyz.openbmc_project.Object.Enable", "Enabled", "bool", true},
46 },
47 {
48 0x02010008, // SensorID for VMI Port 1 ipv4 = 8, SensorOffset for the
49 // State Set ID 15 = 1 & PLDM State Set Enumeration List = 2
50 // (Invalid Configuration)
51 {"/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0",
52 "xyz.openbmc_project.Object.Enable", "Enabled", "bool", false},
53 }};
54
George Liua2870722020-02-11 11:09:30 +080055void Handler::addDbusObjMaps(
56 uint16_t effecterId,
57 std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj)
George Liu1ec85d42020-02-12 16:05:32 +080058{
59 dbusObjMaps.emplace(effecterId, dbusObj);
60}
61
George Liua2870722020-02-11 11:09:30 +080062const std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>&
George Liu1ec85d42020-02-12 16:05:32 +080063 Handler::getDbusObjMaps(uint16_t effecterId) const
64{
65 return dbusObjMaps.at(effecterId);
66}
67
Deepak Kodihallic682fe22020-03-04 00:42:54 -060068void Handler::generate(const std::string& dir, Repo& repo)
69{
70 // A map of PDR type to a lambda that handles creation of that PDR type.
71 // The lambda essentially would parse the platform specific PDR JSONs to
72 // generate the PDR structures. This function iterates through the map to
73 // invoke all lambdas, so that all PDR types can be created.
George Liua2870722020-02-11 11:09:30 +080074
75 const std::map<Type, generatePDR> generateHandlers = {
76 {PLDM_STATE_EFFECTER_PDR,
77 [this](const auto& json, RepoInterface& repo) {
78 pdr_state_effecter::generateStateEffecterPDR<Handler>(json, *this,
79 repo);
George Liu456c9a22020-01-13 11:36:22 +080080 }},
81 {PLDM_NUMERIC_EFFECTER_PDR,
82 [this](const auto& json, RepoInterface& repo) {
83 pdr_numeric_effecter::generateNumericEffecterPDR<Handler>(
84 json, *this, repo);
George Liua2870722020-02-11 11:09:30 +080085 }}};
Deepak Kodihallic682fe22020-03-04 00:42:54 -060086
87 Type pdrType{};
88 for (const auto& dirEntry : fs::directory_iterator(dir))
89 {
90 try
91 {
92 auto json = readJson(dirEntry.path().string());
93 if (!json.empty())
94 {
George Liu1ec85d42020-02-12 16:05:32 +080095 auto effecterPDRs = json.value("effecterPDRs", empty);
96 for (const auto& effecter : effecterPDRs)
97 {
98 pdrType = effecter.value("pdrType", 0);
George Liua2870722020-02-11 11:09:30 +080099 generateHandlers.at(pdrType)(effecter, repo);
George Liu1ec85d42020-02-12 16:05:32 +0800100 }
Deepak Kodihallic682fe22020-03-04 00:42:54 -0600101 }
102 }
103 catch (const InternalFailure& e)
104 {
105 std::cerr << "PDR config directory does not exist or empty, TYPE= "
106 << pdrType << "PATH= " << dirEntry
107 << " ERROR=" << e.what() << "\n";
108 }
109 catch (const Json::exception& e)
110 {
111 std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType
112 << " ERROR=" << e.what() << "\n";
113 pldm::utils::reportError(
114 "xyz.openbmc_project.bmc.pldm.InternalFailure");
115 }
116 catch (const std::exception& e)
117 {
118 std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType
119 << " ERROR=" << e.what() << "\n";
120 pldm::utils::reportError(
121 "xyz.openbmc_project.bmc.pldm.InternalFailure");
122 }
123 }
124}
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530125
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600126Response Handler::getPDR(const pldm_msg* request, size_t payloadLength)
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530127{
Tom Joseph33e9c7e2020-06-11 22:09:52 +0530128 // Build FRU table if not built, since entity association PDR's are built
129 // when the FRU table is constructed.
130 if (fruHandler)
131 {
132 fruHandler->buildFRUTable();
133 }
134
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530135 Response response(sizeof(pldm_msg_hdr) + PLDM_GET_PDR_MIN_RESP_BYTES, 0);
136 auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
137
138 if (payloadLength != PLDM_GET_PDR_REQ_BYTES)
139 {
George Liufb8611d2019-12-06 10:14:15 +0800140 return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530141 }
142
143 uint32_t recordHandle{};
144 uint32_t dataTransferHandle{};
145 uint8_t transferOpFlag{};
146 uint16_t reqSizeBytes{};
147 uint16_t recordChangeNum{};
148
George Liufb8611d2019-12-06 10:14:15 +0800149 auto rc = decode_get_pdr_req(request, payloadLength, &recordHandle,
150 &dataTransferHandle, &transferOpFlag,
151 &reqSizeBytes, &recordChangeNum);
152 if (rc != PLDM_SUCCESS)
153 {
154 return CmdHandler::ccOnlyResponse(request, rc);
155 }
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530156
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530157 uint16_t respSizeBytes{};
158 uint8_t* recordData = nullptr;
159 try
160 {
George Liue53193f2020-02-24 09:23:26 +0800161 pdr_utils::PdrEntry e;
162 auto record = pdr::getRecordByHandle(pdrRepo, recordHandle, e);
163 if (record == NULL)
164 {
165 return CmdHandler::ccOnlyResponse(
166 request, PLDM_PLATFORM_INVALID_RECORD_HANDLE);
167 }
168
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530169 if (reqSizeBytes)
170 {
George Liue53193f2020-02-24 09:23:26 +0800171 respSizeBytes = e.size;
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530172 if (respSizeBytes > reqSizeBytes)
173 {
174 respSizeBytes = reqSizeBytes;
175 }
George Liue53193f2020-02-24 09:23:26 +0800176 recordData = e.data;
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530177 }
178 response.resize(sizeof(pldm_msg_hdr) + PLDM_GET_PDR_MIN_RESP_BYTES +
179 respSizeBytes,
180 0);
181 responsePtr = reinterpret_cast<pldm_msg*>(response.data());
Deepak Kodihalli22b5a7d2020-03-17 23:28:41 -0500182 rc = encode_get_pdr_resp(
183 request->hdr.instance_id, PLDM_SUCCESS, e.handle.nextRecordHandle,
184 0, PLDM_START_AND_END, respSizeBytes, recordData, 0, responsePtr);
George Liufb8611d2019-12-06 10:14:15 +0800185 if (rc != PLDM_SUCCESS)
186 {
187 return ccOnlyResponse(request, rc);
188 }
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530189 }
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530190 catch (const std::exception& e)
191 {
Sampa Misraaa8ae722019-12-12 03:20:40 -0600192 std::cerr << "Error accessing PDR, HANDLE=" << recordHandle
193 << " ERROR=" << e.what() << "\n";
George Liufb8611d2019-12-06 10:14:15 +0800194 return CmdHandler::ccOnlyResponse(request, PLDM_ERROR);
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530195 }
196 return response;
197}
198
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600199Response Handler::setStateEffecterStates(const pldm_msg* request,
200 size_t payloadLength)
Sampa Misraa2fa0702019-05-31 01:28:55 -0500201{
202 Response response(
203 sizeof(pldm_msg_hdr) + PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES, 0);
204 auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
205 uint16_t effecterId;
206 uint8_t compEffecterCnt;
207 constexpr auto maxCompositeEffecterCnt = 8;
208 std::vector<set_effecter_state_field> stateField(maxCompositeEffecterCnt,
209 {0, 0});
210
211 if ((payloadLength > PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES) ||
212 (payloadLength < sizeof(effecterId) + sizeof(compEffecterCnt) +
213 sizeof(set_effecter_state_field)))
214 {
George Liufb8611d2019-12-06 10:14:15 +0800215 return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
Sampa Misraa2fa0702019-05-31 01:28:55 -0500216 }
217
218 int rc = decode_set_state_effecter_states_req(request, payloadLength,
219 &effecterId, &compEffecterCnt,
220 stateField.data());
221
George Liufb8611d2019-12-06 10:14:15 +0800222 if (rc != PLDM_SUCCESS)
Sampa Misraa2fa0702019-05-31 01:28:55 -0500223 {
George Liufb8611d2019-12-06 10:14:15 +0800224 return CmdHandler::ccOnlyResponse(request, rc);
Sampa Misraa2fa0702019-05-31 01:28:55 -0500225 }
226
George Liufb8611d2019-12-06 10:14:15 +0800227 stateField.resize(compEffecterCnt);
228 const pldm::utils::DBusHandler dBusIntf;
George Liu0d7aca82020-03-30 15:01:36 +0800229 rc = platform_state_effecter::setStateEffecterStatesHandler<
230 pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId,
231 stateField);
George Liufb8611d2019-12-06 10:14:15 +0800232 if (rc != PLDM_SUCCESS)
233 {
234 return CmdHandler::ccOnlyResponse(request, rc);
235 }
236
237 rc = encode_set_state_effecter_states_resp(request->hdr.instance_id, rc,
238 responsePtr);
239 if (rc != PLDM_SUCCESS)
240 {
241 return ccOnlyResponse(request, rc);
242 }
243
Sampa Misraa2fa0702019-05-31 01:28:55 -0500244 return response;
245}
246
Tom Joseph56e45c52020-03-16 10:01:45 +0530247Response Handler::platformEventMessage(const pldm_msg* request,
248 size_t payloadLength)
249{
250 uint8_t formatVersion{};
251 uint8_t tid{};
252 uint8_t eventClass{};
253 size_t offset{};
254
255 auto rc = decode_platform_event_message_req(
256 request, payloadLength, &formatVersion, &tid, &eventClass, &offset);
257 if (rc != PLDM_SUCCESS)
258 {
259 return CmdHandler::ccOnlyResponse(request, rc);
260 }
261
262 try
263 {
264 const auto& handlers = eventHandlers.at(eventClass);
265 for (const auto& handler : handlers)
266 {
267 auto rc =
268 handler(request, payloadLength, formatVersion, tid, offset);
269 if (rc != PLDM_SUCCESS)
270 {
271 return CmdHandler::ccOnlyResponse(request, rc);
272 }
273 }
274 }
275 catch (const std::out_of_range& e)
276 {
277 return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_DATA);
278 }
279
280 Response response(
281 sizeof(pldm_msg_hdr) + PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES, 0);
282 auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
283
284 rc = encode_platform_event_message_resp(request->hdr.instance_id, rc,
285 PLDM_EVENT_NO_LOGGING, responsePtr);
286 if (rc != PLDM_SUCCESS)
287 {
288 return ccOnlyResponse(request, rc);
289 }
290
291 return response;
292}
293
294int Handler::sensorEvent(const pldm_msg* request, size_t payloadLength,
Tom Josephc4959c32020-04-20 19:50:16 +0530295 uint8_t /*formatVersion*/, uint8_t tid,
Tom Joseph56e45c52020-03-16 10:01:45 +0530296 size_t eventDataOffset)
297{
298 uint16_t sensorId{};
299 uint8_t eventClass{};
300 size_t eventClassDataOffset{};
301 auto eventData =
302 reinterpret_cast<const uint8_t*>(request->payload) + eventDataOffset;
303 auto eventDataSize = payloadLength - eventDataOffset;
304
305 auto rc = decode_sensor_event_data(eventData, eventDataSize, &sensorId,
306 &eventClass, &eventClassDataOffset);
307 if (rc != PLDM_SUCCESS)
308 {
309 return rc;
310 }
311
Zahed Hossain75330f32020-03-24 02:15:03 -0500312 auto eventClassData = reinterpret_cast<const uint8_t*>(request->payload) +
313 eventDataOffset + eventClassDataOffset;
314 auto eventClassDataSize =
315 payloadLength - eventDataOffset - eventClassDataOffset;
316
Tom Joseph56e45c52020-03-16 10:01:45 +0530317 if (eventClass == PLDM_STATE_SENSOR_STATE)
318 {
319 uint8_t sensorOffset{};
320 uint8_t eventState{};
321 uint8_t previousEventState{};
322
Zahed Hossain75330f32020-03-24 02:15:03 -0500323 rc = decode_state_sensor_data(eventClassData, eventClassDataSize,
Tom Joseph56e45c52020-03-16 10:01:45 +0530324 &sensorOffset, &eventState,
325 &previousEventState);
Zahed Hossain75330f32020-03-24 02:15:03 -0500326 if (rc != PLDM_SUCCESS)
327 {
328 return PLDM_ERROR;
329 }
330
Chicago Duanfe4d88b2020-06-12 16:44:13 +0800331 // Emitting state sensor event signal
332 emitStateSensorEventSignal(tid, sensorId, sensorOffset, eventState,
333 previousEventState);
334
Tom Josephc4959c32020-04-20 19:50:16 +0530335 // Handle PLDM events for which PDR is not available, setSensorEventData
336 // will return PLDM_ERROR_INVALID_DATA if the sensorID is not found in
337 // the hardcoded sensor list.
Zahed Hossain75330f32020-03-24 02:15:03 -0500338 rc = setSensorEventData(sensorId, sensorOffset, eventState);
Tom Josephc4959c32020-04-20 19:50:16 +0530339 if (rc != PLDM_ERROR_INVALID_DATA)
Zahed Hossain75330f32020-03-24 02:15:03 -0500340 {
Tom Josephc4959c32020-04-20 19:50:16 +0530341 return rc;
342 }
343
344 // If there are no HOST PDR's, there is no further action
345 if (hostPDRHandler == NULL)
346 {
347 return PLDM_SUCCESS;
348 }
349
350 // Handle PLDM events for which PDR is available
351 SensorEntry sensorEntry{tid, sensorId};
352 try
353 {
354 const auto& [entityInfo, compositeSensorStates] =
355 hostPDRHandler->lookupSensorInfo(sensorEntry);
356 if (sensorOffset >= compositeSensorStates.size())
357 {
358 return PLDM_ERROR_INVALID_DATA;
359 }
360
361 const auto& possibleStates = compositeSensorStates[sensorOffset];
362 if (possibleStates.find(eventState) == possibleStates.end())
363 {
364 return PLDM_ERROR_INVALID_DATA;
365 }
366
367 const auto& [containerId, entityType, entityInstance] = entityInfo;
368 events::StateSensorEntry stateSensorEntry{
369 containerId, entityType, entityInstance, sensorOffset};
370 return stateSensorHandler.eventAction(stateSensorEntry, eventState);
371 }
372 // If there is no mapping for events return PLDM_SUCCESS
373 catch (const std::out_of_range& e)
374 {
375 return PLDM_SUCCESS;
Zahed Hossain75330f32020-03-24 02:15:03 -0500376 }
Tom Joseph56e45c52020-03-16 10:01:45 +0530377 }
378 else
379 {
380 return PLDM_ERROR_INVALID_DATA;
381 }
382
383 return PLDM_SUCCESS;
384}
385
Zahed Hossain75330f32020-03-24 02:15:03 -0500386int Handler::setSensorEventData(uint16_t sensorId, uint8_t sensorOffset,
387 uint8_t eventState)
388{
389 EventEntry eventEntry = ((static_cast<uint32_t>(eventState)) << 24) +
390 ((static_cast<uint32_t>(sensorOffset)) << 16) +
391 sensorId;
392 auto iter = eventEntryMap.find(eventEntry);
393 if (iter == eventEntryMap.end())
394 {
Tom Josephc4959c32020-04-20 19:50:16 +0530395 return PLDM_ERROR_INVALID_DATA;
Zahed Hossain75330f32020-03-24 02:15:03 -0500396 }
397
398 const auto& dBusInfo = iter->second;
399 try
400 {
401 pldm::utils::DBusMapping dbusMapping{
402 dBusInfo.dBusValues.objectPath, dBusInfo.dBusValues.interface,
403 dBusInfo.dBusValues.propertyName, dBusInfo.dBusValues.propertyType};
404 pldm::utils::DBusHandler().setDbusProperty(dbusMapping,
405 dBusInfo.dBusPropertyValue);
406 }
407 catch (std::exception& e)
408 {
Zahed Hossain75330f32020-03-24 02:15:03 -0500409 std::cerr
410 << "Error Setting dbus property,SensorID=" << eventEntry
411 << "DBusInfo=" << dBusInfo.dBusValues.objectPath
412 << dBusInfo.dBusValues.interface << dBusInfo.dBusValues.propertyName
413 << "ERROR=" << e.what() << "\n";
414 return PLDM_ERROR;
415 }
416 return PLDM_SUCCESS;
417}
418
Deepak Kodihalli8cb6f662020-04-10 02:55:43 -0500419int Handler::pldmPDRRepositoryChgEvent(const pldm_msg* request,
420 size_t payloadLength,
421 uint8_t /*formatVersion*/,
422 uint8_t /*tid*/, size_t eventDataOffset)
423{
424 uint8_t eventDataFormat{};
425 uint8_t numberOfChangeRecords{};
426 size_t dataOffset{};
427
428 auto eventData =
429 reinterpret_cast<const uint8_t*>(request->payload) + eventDataOffset;
430 auto eventDataSize = payloadLength - eventDataOffset;
431
432 auto rc = decode_pldm_pdr_repository_chg_event_data(
433 eventData, eventDataSize, &eventDataFormat, &numberOfChangeRecords,
434 &dataOffset);
435 if (rc != PLDM_SUCCESS)
436 {
437 return rc;
438 }
439
440 PDRRecordHandles pdrRecordHandles;
441 if (eventDataFormat == FORMAT_IS_PDR_HANDLES)
442 {
443 uint8_t eventDataOperation{};
444 uint8_t numberOfChangeEntries{};
445
446 auto changeRecordData = eventData + dataOffset;
447 auto changeRecordDataSize = eventDataSize - dataOffset;
448
449 while (changeRecordDataSize)
450 {
451 rc = decode_pldm_pdr_repository_change_record_data(
452 changeRecordData, changeRecordDataSize, &eventDataOperation,
453 &numberOfChangeEntries, &dataOffset);
454
455 if (rc != PLDM_SUCCESS)
456 {
457 return rc;
458 }
459
460 if (eventDataOperation == PLDM_RECORDS_ADDED)
461 {
462 rc = getPDRRecordHandles(
463 reinterpret_cast<const ChangeEntry*>(changeRecordData +
464 dataOffset),
465 changeRecordDataSize - dataOffset,
466 static_cast<size_t>(numberOfChangeEntries),
467 pdrRecordHandles);
468
469 if (rc != PLDM_SUCCESS)
470 {
471 return rc;
472 }
473 }
474
475 changeRecordData +=
476 dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry));
477 changeRecordDataSize -=
478 dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry));
479 }
480
481 if (hostPDRHandler && !pdrRecordHandles.empty())
482 {
483 hostPDRHandler->fetchPDR(std::move(pdrRecordHandles));
484 }
485 }
486 else
487 {
488 return PLDM_ERROR_INVALID_DATA;
489 }
490
491 return PLDM_SUCCESS;
492}
493
494int Handler::getPDRRecordHandles(const ChangeEntry* changeEntryData,
495 size_t changeEntryDataSize,
496 size_t numberOfChangeEntries,
497 PDRRecordHandles& pdrRecordHandles)
498{
499 if (numberOfChangeEntries > (changeEntryDataSize / sizeof(ChangeEntry)))
500 {
501 return PLDM_ERROR_INVALID_DATA;
502 }
503 for (size_t i = 0; i < numberOfChangeEntries; i++)
504 {
505 pdrRecordHandles.push_back(changeEntryData[i]);
506 }
507 return PLDM_SUCCESS;
508}
509
George Liueccb0c52020-01-14 11:09:56 +0800510Response Handler::setNumericEffecterValue(const pldm_msg* request,
511 size_t payloadLength)
512{
513 Response response(sizeof(pldm_msg_hdr) +
514 PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES);
515 uint16_t effecterId{};
516 uint8_t effecterDataSize{};
517 uint8_t effecterValue[4] = {};
518
519 if ((payloadLength > sizeof(effecterId) + sizeof(effecterDataSize) +
520 sizeof(union_effecter_data_size)) ||
521 (payloadLength < sizeof(effecterId) + sizeof(effecterDataSize) + 1))
522 {
523 return ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
524 }
525
526 int rc = decode_set_numeric_effecter_value_req(
527 request, payloadLength, &effecterId, &effecterDataSize,
528 reinterpret_cast<uint8_t*>(&effecterValue));
529
530 if (rc == PLDM_SUCCESS)
531 {
532 const pldm::utils::DBusHandler dBusIntf;
533 rc = platform_numeric_effecter::setNumericEffecterValueHandler<
534 pldm::utils::DBusHandler, Handler>(dBusIntf, *this, effecterId,
535 effecterDataSize, effecterValue,
536 sizeof(effecterValue));
537 }
538
539 return ccOnlyResponse(request, rc);
540}
541
Deepak Kodihallibc669f12019-11-28 08:52:07 -0600542} // namespace platform
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530543} // namespace responder
544} // namespace pldm