| Harshit Aghera | 8951c87 | 2025-06-25 15:25:33 +0530 | [diff] [blame] | 1 | /* | 
|  | 2 | * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & | 
|  | 3 | * AFFILIATES. All rights reserved. | 
|  | 4 | * SPDX-License-Identifier: Apache-2.0 | 
|  | 5 | */ | 
|  | 6 |  | 
|  | 7 | #pragma once | 
|  | 8 |  | 
|  | 9 | #include "MctpRequester.hpp" | 
|  | 10 | #include "NvidiaDeviceDiscovery.hpp" | 
|  | 11 | #include "NvidiaGpuSensor.hpp" | 
|  | 12 |  | 
|  | 13 | #include <boost/asio/io_context.hpp> | 
|  | 14 | #include <boost/asio/steady_timer.hpp> | 
|  | 15 | #include <sdbusplus/asio/connection.hpp> | 
|  | 16 | #include <sdbusplus/asio/object_server.hpp> | 
|  | 17 |  | 
|  | 18 | #include <chrono> | 
|  | 19 | #include <cstdint> | 
|  | 20 | #include <memory> | 
|  | 21 | #include <string> | 
|  | 22 |  | 
|  | 23 | class SmaDevice | 
|  | 24 | { | 
|  | 25 | public: | 
|  | 26 | SmaDevice(const SensorConfigs& configs, const std::string& name, | 
|  | 27 | const std::string& path, | 
|  | 28 | const std::shared_ptr<sdbusplus::asio::connection>& conn, | 
|  | 29 | uint8_t eid, boost::asio::io_context& io, | 
|  | 30 | mctp::MctpRequester& mctpRequester, | 
|  | 31 | sdbusplus::asio::object_server& objectServer); | 
|  | 32 |  | 
|  | 33 | const std::string& getPath() const | 
|  | 34 | { | 
|  | 35 | return path; | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | private: | 
|  | 39 | void makeSensors(); | 
|  | 40 |  | 
|  | 41 | void read(); | 
|  | 42 |  | 
|  | 43 | uint8_t eid{}; | 
|  | 44 |  | 
|  | 45 | std::chrono::milliseconds sensorPollMs; | 
|  | 46 |  | 
|  | 47 | boost::asio::steady_timer waitTimer; | 
|  | 48 |  | 
|  | 49 | mctp::MctpRequester& mctpRequester; | 
|  | 50 |  | 
|  | 51 | std::shared_ptr<sdbusplus::asio::connection> conn; | 
|  | 52 |  | 
|  | 53 | sdbusplus::asio::object_server& objectServer; | 
|  | 54 |  | 
|  | 55 | std::shared_ptr<NvidiaGpuTempSensor> tempSensor; | 
|  | 56 |  | 
|  | 57 | SensorConfigs configs; | 
|  | 58 |  | 
|  | 59 | std::string name; | 
|  | 60 |  | 
|  | 61 | std::string path; | 
|  | 62 | }; |