xref: /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaGpuDevice.hpp (revision 775199d2599981d2c4460c7c1e91a607829e9f0c)
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 
14*775199d2SHarshit Aghera #include <NvidiaGpuEnergySensor.hpp>
154ecdfaaaSHarshit Aghera #include <boost/asio/io_context.hpp>
164ecdfaaaSHarshit Aghera #include <boost/asio/steady_timer.hpp>
174ecdfaaaSHarshit Aghera #include <sdbusplus/asio/connection.hpp>
184ecdfaaaSHarshit Aghera #include <sdbusplus/asio/object_server.hpp>
194ecdfaaaSHarshit Aghera 
204ecdfaaaSHarshit Aghera #include <chrono>
214ecdfaaaSHarshit Aghera #include <cstdint>
224ecdfaaaSHarshit Aghera #include <memory>
234ecdfaaaSHarshit Aghera #include <string>
245e7deccdSHarshit Aghera #include <vector>
254ecdfaaaSHarshit Aghera 
264ecdfaaaSHarshit Aghera class GpuDevice
274ecdfaaaSHarshit Aghera {
284ecdfaaaSHarshit Aghera   public:
294ecdfaaaSHarshit Aghera     GpuDevice(const SensorConfigs& configs, const std::string& name,
304ecdfaaaSHarshit Aghera               const std::string& path,
314ecdfaaaSHarshit Aghera               const std::shared_ptr<sdbusplus::asio::connection>& conn,
324ecdfaaaSHarshit Aghera               uint8_t eid, boost::asio::io_context& io,
334ecdfaaaSHarshit Aghera               mctp::MctpRequester& mctpRequester,
344ecdfaaaSHarshit Aghera               sdbusplus::asio::object_server& objectServer);
354ecdfaaaSHarshit Aghera 
364ecdfaaaSHarshit Aghera     const std::string& getPath() const
374ecdfaaaSHarshit Aghera     {
384ecdfaaaSHarshit Aghera         return path;
394ecdfaaaSHarshit Aghera     }
404ecdfaaaSHarshit Aghera 
414ecdfaaaSHarshit Aghera   private:
424ecdfaaaSHarshit Aghera     void makeSensors();
434ecdfaaaSHarshit Aghera 
444ecdfaaaSHarshit Aghera     void read();
454ecdfaaaSHarshit Aghera 
465e7deccdSHarshit Aghera     void processTLimitThresholds(uint8_t rc,
475e7deccdSHarshit Aghera                                  const std::vector<int32_t>& thresholds);
485e7deccdSHarshit Aghera 
494ecdfaaaSHarshit Aghera     uint8_t eid{};
504ecdfaaaSHarshit Aghera 
514ecdfaaaSHarshit Aghera     std::chrono::milliseconds sensorPollMs;
524ecdfaaaSHarshit Aghera 
534ecdfaaaSHarshit Aghera     boost::asio::steady_timer waitTimer;
544ecdfaaaSHarshit Aghera 
554ecdfaaaSHarshit Aghera     mctp::MctpRequester& mctpRequester;
564ecdfaaaSHarshit Aghera 
574ecdfaaaSHarshit Aghera     std::shared_ptr<sdbusplus::asio::connection> conn;
584ecdfaaaSHarshit Aghera 
594ecdfaaaSHarshit Aghera     sdbusplus::asio::object_server& objectServer;
604ecdfaaaSHarshit Aghera 
614ecdfaaaSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tempSensor;
62ba138daeSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tLimitSensor;
63902c649bSHarshit Aghera     std::shared_ptr<NvidiaGpuPowerSensor> powerSensor;
64*775199d2SHarshit Aghera     std::shared_ptr<NvidiaGpuEnergySensor> energySensor;
654ecdfaaaSHarshit Aghera 
664ecdfaaaSHarshit Aghera     SensorConfigs configs;
674ecdfaaaSHarshit Aghera 
684ecdfaaaSHarshit Aghera     std::string name;
694ecdfaaaSHarshit Aghera 
704ecdfaaaSHarshit Aghera     std::string path;
714ecdfaaaSHarshit Aghera };
72