blob: 2c81287318e5f6217def460917250845f91b3375 [file] [log] [blame]
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +05301/*
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 Aghera902c6492025-05-08 15:57:42 +053011#include "NvidiaGpuPowerSensor.hpp"
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053012#include "NvidiaGpuSensor.hpp"
13
Harshit Aghera775199d2025-05-27 14:20:24 +053014#include <NvidiaGpuEnergySensor.hpp>
Harshit Agherabef4d412025-05-27 14:53:56 +053015#include <NvidiaGpuVoltageSensor.hpp>
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053016#include <boost/asio/io_context.hpp>
17#include <boost/asio/steady_timer.hpp>
18#include <sdbusplus/asio/connection.hpp>
19#include <sdbusplus/asio/object_server.hpp>
20
21#include <chrono>
22#include <cstdint>
23#include <memory>
24#include <string>
Harshit Aghera5e7decc2025-05-07 16:20:16 +053025#include <vector>
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053026
27class GpuDevice
28{
29 public:
30 GpuDevice(const SensorConfigs& configs, const std::string& name,
31 const std::string& path,
32 const std::shared_ptr<sdbusplus::asio::connection>& conn,
33 uint8_t eid, boost::asio::io_context& io,
34 mctp::MctpRequester& mctpRequester,
35 sdbusplus::asio::object_server& objectServer);
36
37 const std::string& getPath() const
38 {
39 return path;
40 }
41
42 private:
43 void makeSensors();
44
45 void read();
46
Harshit Aghera5e7decc2025-05-07 16:20:16 +053047 void processTLimitThresholds(uint8_t rc,
48 const std::vector<int32_t>& thresholds);
49
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053050 uint8_t eid{};
51
52 std::chrono::milliseconds sensorPollMs;
53
54 boost::asio::steady_timer waitTimer;
55
56 mctp::MctpRequester& mctpRequester;
57
58 std::shared_ptr<sdbusplus::asio::connection> conn;
59
60 sdbusplus::asio::object_server& objectServer;
61
62 std::shared_ptr<NvidiaGpuTempSensor> tempSensor;
Harshit Agheraba138da2025-05-05 12:26:35 +053063 std::shared_ptr<NvidiaGpuTempSensor> tLimitSensor;
Harshit Aghera902c6492025-05-08 15:57:42 +053064 std::shared_ptr<NvidiaGpuPowerSensor> powerSensor;
Harshit Aghera775199d2025-05-27 14:20:24 +053065 std::shared_ptr<NvidiaGpuEnergySensor> energySensor;
Harshit Agherabef4d412025-05-27 14:53:56 +053066 std::shared_ptr<NvidiaGpuVoltageSensor> voltageSensor;
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053067
68 SensorConfigs configs;
69
70 std::string name;
71
72 std::string path;
73};