1*560e6af7SHarshit Aghera /* 2*560e6af7SHarshit Aghera * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & 3*560e6af7SHarshit Aghera * AFFILIATES. All rights reserved. 4*560e6af7SHarshit Aghera * SPDX-License-Identifier: Apache-2.0 5*560e6af7SHarshit Aghera */ 6*560e6af7SHarshit Aghera 7*560e6af7SHarshit Aghera #pragma once 8*560e6af7SHarshit Aghera 9*560e6af7SHarshit Aghera #include <OcpMctpVdm.hpp> 10*560e6af7SHarshit Aghera #include <boost/asio/generic/datagram_protocol.hpp> 11*560e6af7SHarshit Aghera #include <boost/asio/io_context.hpp> 12*560e6af7SHarshit Aghera #include <boost/asio/steady_timer.hpp> 13*560e6af7SHarshit Aghera 14*560e6af7SHarshit Aghera #include <cstddef> 15*560e6af7SHarshit Aghera #include <cstdint> 16*560e6af7SHarshit Aghera #include <functional> 17*560e6af7SHarshit Aghera #include <span> 18*560e6af7SHarshit Aghera 19*560e6af7SHarshit Aghera namespace mctp 20*560e6af7SHarshit Aghera { 21*560e6af7SHarshit Aghera class MctpRequester 22*560e6af7SHarshit Aghera { 23*560e6af7SHarshit Aghera public: 24*560e6af7SHarshit Aghera MctpRequester() = delete; 25*560e6af7SHarshit Aghera 26*560e6af7SHarshit Aghera MctpRequester(const MctpRequester&) = delete; 27*560e6af7SHarshit Aghera 28*560e6af7SHarshit Aghera MctpRequester(MctpRequester&&) = delete; 29*560e6af7SHarshit Aghera 30*560e6af7SHarshit Aghera MctpRequester& operator=(const MctpRequester&) = delete; 31*560e6af7SHarshit Aghera 32*560e6af7SHarshit Aghera MctpRequester& operator=(MctpRequester&&) = delete; 33*560e6af7SHarshit Aghera 34*560e6af7SHarshit Aghera explicit MctpRequester(boost::asio::io_context& ctx); 35*560e6af7SHarshit Aghera 36*560e6af7SHarshit Aghera void sendRecvMsg(uint8_t eid, std::span<const uint8_t> reqMsg, 37*560e6af7SHarshit Aghera std::span<uint8_t> respMsg, 38*560e6af7SHarshit Aghera std::move_only_function<void(int)> callback); 39*560e6af7SHarshit Aghera 40*560e6af7SHarshit Aghera private: 41*560e6af7SHarshit Aghera void processRecvMsg(uint8_t eid, std::span<const uint8_t> reqMsg, 42*560e6af7SHarshit Aghera std::span<uint8_t> respMsg, 43*560e6af7SHarshit Aghera const boost::system::error_code& ec, size_t length); 44*560e6af7SHarshit Aghera 45*560e6af7SHarshit Aghera void handleSendMsgCompletion(uint8_t eid, std::span<const uint8_t> reqMsg, 46*560e6af7SHarshit Aghera std::span<uint8_t> respMsg, 47*560e6af7SHarshit Aghera const boost::system::error_code& ec, 48*560e6af7SHarshit Aghera size_t length); 49*560e6af7SHarshit Aghera 50*560e6af7SHarshit Aghera boost::asio::generic::datagram_protocol::socket mctpSocket; 51*560e6af7SHarshit Aghera 52*560e6af7SHarshit Aghera static constexpr size_t maxMessageSize = 65536 + 256; 53*560e6af7SHarshit Aghera 54*560e6af7SHarshit Aghera boost::asio::generic::datagram_protocol::endpoint sendEndPoint; 55*560e6af7SHarshit Aghera 56*560e6af7SHarshit Aghera boost::asio::generic::datagram_protocol::endpoint recvEndPoint; 57*560e6af7SHarshit Aghera 58*560e6af7SHarshit Aghera boost::asio::steady_timer expiryTimer; 59*560e6af7SHarshit Aghera 60*560e6af7SHarshit Aghera std::move_only_function<void(int)> completionCallback; 61*560e6af7SHarshit Aghera 62*560e6af7SHarshit Aghera static constexpr uint8_t msgType = ocp::accelerator_management::messageType; 63*560e6af7SHarshit Aghera }; 64*560e6af7SHarshit Aghera } // namespace mctp 65