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