xref: /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaGpuDevice.hpp (revision b10a67b252ba8d899b88beb328f040ee9cc1e30f)
14ecdfaaaSHarshit Aghera /*
24ecdfaaaSHarshit Aghera  * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION &
34ecdfaaaSHarshit Aghera  * AFFILIATES. All rights reserved.
44ecdfaaaSHarshit Aghera  * SPDX-License-Identifier: Apache-2.0
54ecdfaaaSHarshit Aghera  */
64ecdfaaaSHarshit Aghera 
74ecdfaaaSHarshit Aghera #pragma once
84ecdfaaaSHarshit Aghera 
94ecdfaaaSHarshit Aghera #include "MctpRequester.hpp"
104ecdfaaaSHarshit Aghera #include "NvidiaDeviceDiscovery.hpp"
11902c649bSHarshit Aghera #include "NvidiaGpuPowerSensor.hpp"
124ecdfaaaSHarshit Aghera #include "NvidiaGpuSensor.hpp"
134ecdfaaaSHarshit Aghera 
14775199d2SHarshit Aghera #include <NvidiaGpuEnergySensor.hpp>
15bef4d418SHarshit Aghera #include <NvidiaGpuVoltageSensor.hpp>
164ecdfaaaSHarshit Aghera #include <boost/asio/io_context.hpp>
174ecdfaaaSHarshit Aghera #include <boost/asio/steady_timer.hpp>
184ecdfaaaSHarshit Aghera #include <sdbusplus/asio/connection.hpp>
194ecdfaaaSHarshit Aghera #include <sdbusplus/asio/object_server.hpp>
204ecdfaaaSHarshit Aghera 
214ecdfaaaSHarshit Aghera #include <chrono>
224ecdfaaaSHarshit Aghera #include <cstdint>
234ecdfaaaSHarshit Aghera #include <memory>
244ecdfaaaSHarshit Aghera #include <string>
255e7deccdSHarshit Aghera #include <vector>
264ecdfaaaSHarshit Aghera 
274ecdfaaaSHarshit Aghera class GpuDevice
284ecdfaaaSHarshit Aghera {
294ecdfaaaSHarshit Aghera   public:
304ecdfaaaSHarshit Aghera     GpuDevice(const SensorConfigs& configs, const std::string& name,
314ecdfaaaSHarshit Aghera               const std::string& path,
324ecdfaaaSHarshit Aghera               const std::shared_ptr<sdbusplus::asio::connection>& conn,
334ecdfaaaSHarshit Aghera               uint8_t eid, boost::asio::io_context& io,
344ecdfaaaSHarshit Aghera               mctp::MctpRequester& mctpRequester,
354ecdfaaaSHarshit Aghera               sdbusplus::asio::object_server& objectServer);
364ecdfaaaSHarshit Aghera 
374ecdfaaaSHarshit Aghera     const std::string& getPath() const
384ecdfaaaSHarshit Aghera     {
394ecdfaaaSHarshit Aghera         return path;
404ecdfaaaSHarshit Aghera     }
414ecdfaaaSHarshit Aghera 
424ecdfaaaSHarshit Aghera   private:
434ecdfaaaSHarshit Aghera     void makeSensors();
444ecdfaaaSHarshit Aghera 
454ecdfaaaSHarshit Aghera     void read();
464ecdfaaaSHarshit Aghera 
475e7deccdSHarshit Aghera     void processTLimitThresholds(uint8_t rc,
485e7deccdSHarshit Aghera                                  const std::vector<int32_t>& thresholds);
495e7deccdSHarshit Aghera 
504ecdfaaaSHarshit Aghera     uint8_t eid{};
514ecdfaaaSHarshit Aghera 
524ecdfaaaSHarshit Aghera     std::chrono::milliseconds sensorPollMs;
534ecdfaaaSHarshit Aghera 
544ecdfaaaSHarshit Aghera     boost::asio::steady_timer waitTimer;
554ecdfaaaSHarshit Aghera 
564ecdfaaaSHarshit Aghera     mctp::MctpRequester& mctpRequester;
574ecdfaaaSHarshit Aghera 
584ecdfaaaSHarshit Aghera     std::shared_ptr<sdbusplus::asio::connection> conn;
594ecdfaaaSHarshit Aghera 
604ecdfaaaSHarshit Aghera     sdbusplus::asio::object_server& objectServer;
614ecdfaaaSHarshit Aghera 
624ecdfaaaSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tempSensor;
63ba138daeSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tLimitSensor;
64*b10a67b2SHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> dramTempSensor;
65902c649bSHarshit Aghera     std::shared_ptr<NvidiaGpuPowerSensor> powerSensor;
66775199d2SHarshit Aghera     std::shared_ptr<NvidiaGpuEnergySensor> energySensor;
67bef4d418SHarshit Aghera     std::shared_ptr<NvidiaGpuVoltageSensor> voltageSensor;
684ecdfaaaSHarshit Aghera 
694ecdfaaaSHarshit Aghera     SensorConfigs configs;
704ecdfaaaSHarshit Aghera 
714ecdfaaaSHarshit Aghera     std::string name;
724ecdfaaaSHarshit Aghera 
734ecdfaaaSHarshit Aghera     std::string path;
744ecdfaaaSHarshit Aghera };
75