Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 3 | #include "libpldmresponder/platform.hpp" |
Deepak Kodihalli | 1521f6d | 2020-06-16 08:51:02 -0500 | [diff] [blame] | 4 | #include "pldmd/handler.hpp" |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 5 | #include "requester/handler.hpp" |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 6 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 7 | #include <libpldm/base.h> |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 10 | #include <sdeventplus/source/event.hpp> |
| 11 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 14 | using namespace pldm::responder; |
| 15 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 16 | namespace pldm |
| 17 | { |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 18 | namespace responder |
| 19 | { |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 20 | namespace base |
| 21 | { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 22 | class Handler : public CmdHandler |
| 23 | { |
| 24 | public: |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 25 | Handler(uint8_t eid, pldm::InstanceIdDb& instanceIdDb, |
| 26 | sdeventplus::Event& event, |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 27 | pldm::responder::oem_platform::Handler* oemPlatformHandler, |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 28 | pldm::requester::Handler<pldm::requester::Request>* handler) : |
| 29 | eid(eid), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 30 | instanceIdDb(instanceIdDb), event(event), |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 31 | oemPlatformHandler(oemPlatformHandler), handler(handler) |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 32 | { |
| 33 | handlers.emplace(PLDM_GET_PLDM_TYPES, |
| 34 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 35 | return this->getPLDMTypes(request, payloadLength); |
| 36 | }); |
| 37 | handlers.emplace(PLDM_GET_PLDM_COMMANDS, |
| 38 | [this](const pldm_msg* request, size_t payloadLength) { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 39 | return this->getPLDMCommands(request, payloadLength); |
| 40 | }); |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 41 | handlers.emplace(PLDM_GET_PLDM_VERSION, |
| 42 | [this](const pldm_msg* request, size_t payloadLength) { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 43 | return this->getPLDMVersion(request, payloadLength); |
| 44 | }); |
| 45 | handlers.emplace(PLDM_GET_TID, |
| 46 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 47 | return this->getTID(request, payloadLength); |
| 48 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | /** @brief Handler for getPLDMTypes |
| 52 | * |
| 53 | * @param[in] request - Request message payload |
| 54 | * @param[in] payload_length - Request message payload length |
| 55 | * @param[return] Response - PLDM Response message |
| 56 | */ |
| 57 | Response getPLDMTypes(const pldm_msg* request, size_t payloadLength); |
| 58 | |
| 59 | /** @brief Handler for getPLDMCommands |
| 60 | * |
| 61 | * @param[in] request - Request message payload |
| 62 | * @param[in] payload_length - Request message payload length |
| 63 | * @param[return] Response - PLDM Response message |
| 64 | */ |
| 65 | Response getPLDMCommands(const pldm_msg* request, size_t payloadLength); |
| 66 | |
| 67 | /** @brief Handler for getPLDMCommands |
| 68 | * |
| 69 | * @param[in] request - Request message payload |
| 70 | * @param[in] payload_length - Request message payload length |
| 71 | * @param[return] Response - PLDM Response message |
| 72 | */ |
| 73 | Response getPLDMVersion(const pldm_msg* request, size_t payloadLength); |
| 74 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 75 | /** @brief _processSetEventReceiver does the actual work that needs |
| 76 | * to be carried out for setEventReceiver command. This is deferred |
| 77 | * after sending response for getTID command to the host |
| 78 | * |
| 79 | * @param[in] source - sdeventplus event source |
| 80 | */ |
| 81 | void processSetEventReceiver(sdeventplus::source::EventBase& source); |
| 82 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 83 | /** @brief Handler for getTID |
| 84 | * |
| 85 | * @param[in] request - Request message payload |
| 86 | * @param[in] payload_length - Request message payload length |
| 87 | * @param[return] Response - PLDM Response message |
| 88 | */ |
| 89 | Response getTID(const pldm_msg* request, size_t payloadLength); |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 90 | |
| 91 | private: |
| 92 | /** @brief MCTP EID of host firmware */ |
| 93 | uint8_t eid; |
| 94 | |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 95 | /** @brief An instance ID database for allocating instance IDs. */ |
| 96 | InstanceIdDb& instanceIdDb; |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 97 | |
| 98 | /** @brief reference of main event loop of pldmd, primarily used to schedule |
| 99 | * work |
| 100 | */ |
| 101 | sdeventplus::Event& event; |
| 102 | |
Sagar Srinivas | 79669c9 | 2021-04-28 15:43:30 -0500 | [diff] [blame] | 103 | /** @brief OEM platform handler */ |
| 104 | pldm::responder::oem_platform::Handler* oemPlatformHandler; |
| 105 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 106 | /** @brief PLDM request handler */ |
| 107 | pldm::requester::Handler<pldm::requester::Request>* handler; |
| 108 | |
| 109 | /** @brief sdeventplus event source */ |
| 110 | std::unique_ptr<sdeventplus::source::Defer> survEvent; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 111 | }; |
| 112 | |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 113 | } // namespace base |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 114 | } // namespace responder |
| 115 | } // namespace pldm |