Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +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> |
Harshit Aghera | 5e7decc | 2025-05-07 16:20:16 +0530 | [diff] [blame^] | 22 | #include <vector> |
Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 23 | |
| 24 | class GpuDevice |
| 25 | { |
| 26 | public: |
| 27 | GpuDevice(const SensorConfigs& configs, const std::string& name, |
| 28 | const std::string& path, |
| 29 | const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 30 | uint8_t eid, boost::asio::io_context& io, |
| 31 | mctp::MctpRequester& mctpRequester, |
| 32 | sdbusplus::asio::object_server& objectServer); |
| 33 | |
| 34 | const std::string& getPath() const |
| 35 | { |
| 36 | return path; |
| 37 | } |
| 38 | |
| 39 | private: |
| 40 | void makeSensors(); |
| 41 | |
| 42 | void read(); |
| 43 | |
Harshit Aghera | 5e7decc | 2025-05-07 16:20:16 +0530 | [diff] [blame^] | 44 | void processTLimitThresholds(uint8_t rc, |
| 45 | const std::vector<int32_t>& thresholds); |
| 46 | |
Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 47 | uint8_t eid{}; |
| 48 | |
| 49 | std::chrono::milliseconds sensorPollMs; |
| 50 | |
| 51 | boost::asio::steady_timer waitTimer; |
| 52 | |
| 53 | mctp::MctpRequester& mctpRequester; |
| 54 | |
| 55 | std::shared_ptr<sdbusplus::asio::connection> conn; |
| 56 | |
| 57 | sdbusplus::asio::object_server& objectServer; |
| 58 | |
| 59 | std::shared_ptr<NvidiaGpuTempSensor> tempSensor; |
Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 60 | std::shared_ptr<NvidiaGpuTempSensor> tLimitSensor; |
Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 61 | |
| 62 | SensorConfigs configs; |
| 63 | |
| 64 | std::string name; |
| 65 | |
| 66 | std::string path; |
| 67 | }; |