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