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