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