xref: /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaDeviceDiscovery.hpp (revision 4ecdfaaaf39039bd6d73ee67aa44830672675a81)
1*4ecdfaaaSHarshit Aghera /*
2*4ecdfaaaSHarshit Aghera  * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION &
3*4ecdfaaaSHarshit Aghera  * AFFILIATES. All rights reserved.
4*4ecdfaaaSHarshit Aghera  * SPDX-License-Identifier: Apache-2.0
5*4ecdfaaaSHarshit Aghera  */
6*4ecdfaaaSHarshit Aghera 
7*4ecdfaaaSHarshit Aghera #pragma once
8*4ecdfaaaSHarshit Aghera 
9*4ecdfaaaSHarshit Aghera #include "MctpRequester.hpp"
10*4ecdfaaaSHarshit Aghera 
11*4ecdfaaaSHarshit Aghera #include <boost/asio/io_context.hpp>
12*4ecdfaaaSHarshit Aghera #include <boost/container/flat_map.hpp>
13*4ecdfaaaSHarshit Aghera #include <sdbusplus/asio/connection.hpp>
14*4ecdfaaaSHarshit Aghera #include <sdbusplus/asio/object_server.hpp>
15*4ecdfaaaSHarshit Aghera #include <sdbusplus/message.hpp>
16*4ecdfaaaSHarshit Aghera 
17*4ecdfaaaSHarshit Aghera #include <cstdint>
18*4ecdfaaaSHarshit Aghera #include <memory>
19*4ecdfaaaSHarshit Aghera #include <string>
20*4ecdfaaaSHarshit Aghera 
21*4ecdfaaaSHarshit Aghera constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
22*4ecdfaaaSHarshit Aghera constexpr const char* deviceType = "NvidiaMctpVdm";
23*4ecdfaaaSHarshit Aghera 
24*4ecdfaaaSHarshit Aghera struct SensorConfigs
25*4ecdfaaaSHarshit Aghera {
26*4ecdfaaaSHarshit Aghera     std::string name;
27*4ecdfaaaSHarshit Aghera     uint64_t pollRate{};
28*4ecdfaaaSHarshit Aghera };
29*4ecdfaaaSHarshit Aghera 
30*4ecdfaaaSHarshit Aghera class GpuDevice;
31*4ecdfaaaSHarshit Aghera 
32*4ecdfaaaSHarshit Aghera void createSensors(
33*4ecdfaaaSHarshit Aghera     boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer,
34*4ecdfaaaSHarshit Aghera     boost::container::flat_map<std::string, std::shared_ptr<GpuDevice>>&
35*4ecdfaaaSHarshit Aghera         gpuDevices,
36*4ecdfaaaSHarshit Aghera     const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
37*4ecdfaaaSHarshit Aghera     mctp::MctpRequester& mctpRequester);
38*4ecdfaaaSHarshit Aghera 
39*4ecdfaaaSHarshit Aghera void interfaceRemoved(
40*4ecdfaaaSHarshit Aghera     sdbusplus::message_t& message,
41*4ecdfaaaSHarshit Aghera     boost::container::flat_map<std::string, std::shared_ptr<GpuDevice>>&
42*4ecdfaaaSHarshit Aghera         gpuDevices);
43