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