xref: /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaGpuDevice.hpp (revision 5e7deccd14dcac790028a6641291cc019c1c4e52)
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"
114ecdfaaaSHarshit Aghera #include "NvidiaGpuSensor.hpp"
124ecdfaaaSHarshit Aghera 
134ecdfaaaSHarshit Aghera #include <boost/asio/io_context.hpp>
144ecdfaaaSHarshit Aghera #include <boost/asio/steady_timer.hpp>
154ecdfaaaSHarshit Aghera #include <sdbusplus/asio/connection.hpp>
164ecdfaaaSHarshit Aghera #include <sdbusplus/asio/object_server.hpp>
174ecdfaaaSHarshit Aghera 
184ecdfaaaSHarshit Aghera #include <chrono>
194ecdfaaaSHarshit Aghera #include <cstdint>
204ecdfaaaSHarshit Aghera #include <memory>
214ecdfaaaSHarshit Aghera #include <string>
22*5e7deccdSHarshit Aghera #include <vector>
234ecdfaaaSHarshit Aghera 
244ecdfaaaSHarshit Aghera class GpuDevice
254ecdfaaaSHarshit Aghera {
264ecdfaaaSHarshit Aghera   public:
274ecdfaaaSHarshit Aghera     GpuDevice(const SensorConfigs& configs, const std::string& name,
284ecdfaaaSHarshit Aghera               const std::string& path,
294ecdfaaaSHarshit Aghera               const std::shared_ptr<sdbusplus::asio::connection>& conn,
304ecdfaaaSHarshit Aghera               uint8_t eid, boost::asio::io_context& io,
314ecdfaaaSHarshit Aghera               mctp::MctpRequester& mctpRequester,
324ecdfaaaSHarshit Aghera               sdbusplus::asio::object_server& objectServer);
334ecdfaaaSHarshit Aghera 
344ecdfaaaSHarshit Aghera     const std::string& getPath() const
354ecdfaaaSHarshit Aghera     {
364ecdfaaaSHarshit Aghera         return path;
374ecdfaaaSHarshit Aghera     }
384ecdfaaaSHarshit Aghera 
394ecdfaaaSHarshit Aghera   private:
404ecdfaaaSHarshit Aghera     void makeSensors();
414ecdfaaaSHarshit Aghera 
424ecdfaaaSHarshit Aghera     void read();
434ecdfaaaSHarshit Aghera 
44*5e7deccdSHarshit Aghera     void processTLimitThresholds(uint8_t rc,
45*5e7deccdSHarshit Aghera                                  const std::vector<int32_t>& thresholds);
46*5e7deccdSHarshit Aghera 
474ecdfaaaSHarshit Aghera     uint8_t eid{};
484ecdfaaaSHarshit Aghera 
494ecdfaaaSHarshit Aghera     std::chrono::milliseconds sensorPollMs;
504ecdfaaaSHarshit Aghera 
514ecdfaaaSHarshit Aghera     boost::asio::steady_timer waitTimer;
524ecdfaaaSHarshit Aghera 
534ecdfaaaSHarshit Aghera     mctp::MctpRequester& mctpRequester;
544ecdfaaaSHarshit Aghera 
554ecdfaaaSHarshit Aghera     std::shared_ptr<sdbusplus::asio::connection> conn;
564ecdfaaaSHarshit Aghera 
574ecdfaaaSHarshit Aghera     sdbusplus::asio::object_server& objectServer;
584ecdfaaaSHarshit Aghera 
594ecdfaaaSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tempSensor;
60ba138daeSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tLimitSensor;
614ecdfaaaSHarshit Aghera 
624ecdfaaaSHarshit Aghera     SensorConfigs configs;
634ecdfaaaSHarshit Aghera 
644ecdfaaaSHarshit Aghera     std::string name;
654ecdfaaaSHarshit Aghera 
664ecdfaaaSHarshit Aghera     std::string path;
674ecdfaaaSHarshit Aghera };
68