Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
ArchanaKakani | 6c39c7a | 2022-12-05 04:36:35 -0600 | [diff] [blame] | 3 | #include "config.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 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 9 | #include <libpldm/base.h> |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 10 | #include <stdint.h> |
| 11 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 12 | #include <sdeventplus/source/event.hpp> |
| 13 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
Sagar Srinivas | a6a8ccd | 2021-04-01 07:58:33 -0500 | [diff] [blame] | 16 | using namespace pldm::dbus_api; |
| 17 | using namespace pldm::responder; |
| 18 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 19 | namespace pldm |
| 20 | { |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 21 | namespace responder |
| 22 | { |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 23 | namespace base |
| 24 | { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 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 |