xref: /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaSmaDevice.hpp (revision 8951c87e8fca6ba57f78344119ab42866c190c80)
1*8951c87eSHarshit Aghera /*
2*8951c87eSHarshit Aghera  * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION &
3*8951c87eSHarshit Aghera  * AFFILIATES. All rights reserved.
4*8951c87eSHarshit Aghera  * SPDX-License-Identifier: Apache-2.0
5*8951c87eSHarshit Aghera  */
6*8951c87eSHarshit Aghera 
7*8951c87eSHarshit Aghera #pragma once
8*8951c87eSHarshit Aghera 
9*8951c87eSHarshit Aghera #include "MctpRequester.hpp"
10*8951c87eSHarshit Aghera #include "NvidiaDeviceDiscovery.hpp"
11*8951c87eSHarshit Aghera #include "NvidiaGpuSensor.hpp"
12*8951c87eSHarshit Aghera 
13*8951c87eSHarshit Aghera #include <boost/asio/io_context.hpp>
14*8951c87eSHarshit Aghera #include <boost/asio/steady_timer.hpp>
15*8951c87eSHarshit Aghera #include <sdbusplus/asio/connection.hpp>
16*8951c87eSHarshit Aghera #include <sdbusplus/asio/object_server.hpp>
17*8951c87eSHarshit Aghera 
18*8951c87eSHarshit Aghera #include <chrono>
19*8951c87eSHarshit Aghera #include <cstdint>
20*8951c87eSHarshit Aghera #include <memory>
21*8951c87eSHarshit Aghera #include <string>
22*8951c87eSHarshit Aghera 
23*8951c87eSHarshit Aghera class SmaDevice
24*8951c87eSHarshit Aghera {
25*8951c87eSHarshit Aghera   public:
26*8951c87eSHarshit Aghera     SmaDevice(const SensorConfigs& configs, const std::string& name,
27*8951c87eSHarshit Aghera               const std::string& path,
28*8951c87eSHarshit Aghera               const std::shared_ptr<sdbusplus::asio::connection>& conn,
29*8951c87eSHarshit Aghera               uint8_t eid, boost::asio::io_context& io,
30*8951c87eSHarshit Aghera               mctp::MctpRequester& mctpRequester,
31*8951c87eSHarshit Aghera               sdbusplus::asio::object_server& objectServer);
32*8951c87eSHarshit Aghera 
getPath() const33*8951c87eSHarshit Aghera     const std::string& getPath() const
34*8951c87eSHarshit Aghera     {
35*8951c87eSHarshit Aghera         return path;
36*8951c87eSHarshit Aghera     }
37*8951c87eSHarshit Aghera 
38*8951c87eSHarshit Aghera   private:
39*8951c87eSHarshit Aghera     void makeSensors();
40*8951c87eSHarshit Aghera 
41*8951c87eSHarshit Aghera     void read();
42*8951c87eSHarshit Aghera 
43*8951c87eSHarshit Aghera     uint8_t eid{};
44*8951c87eSHarshit Aghera 
45*8951c87eSHarshit Aghera     std::chrono::milliseconds sensorPollMs;
46*8951c87eSHarshit Aghera 
47*8951c87eSHarshit Aghera     boost::asio::steady_timer waitTimer;
48*8951c87eSHarshit Aghera 
49*8951c87eSHarshit Aghera     mctp::MctpRequester& mctpRequester;
50*8951c87eSHarshit Aghera 
51*8951c87eSHarshit Aghera     std::shared_ptr<sdbusplus::asio::connection> conn;
52*8951c87eSHarshit Aghera 
53*8951c87eSHarshit Aghera     sdbusplus::asio::object_server& objectServer;
54*8951c87eSHarshit Aghera 
55*8951c87eSHarshit Aghera     std::shared_ptr<NvidiaGpuTempSensor> tempSensor;
56*8951c87eSHarshit Aghera 
57*8951c87eSHarshit Aghera     SensorConfigs configs;
58*8951c87eSHarshit Aghera 
59*8951c87eSHarshit Aghera     std::string name;
60*8951c87eSHarshit Aghera 
61*8951c87eSHarshit Aghera     std::string path;
62*8951c87eSHarshit Aghera };
63