xref: /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaDeviceDiscovery.hpp (revision 7427aeef4225bf23715539b195a23bce10865265)
1 /*
2  * SPDX-FileCopyrightText: Copyright OpenBMC Authors
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include "MctpRequester.hpp"
9 
10 #include <boost/asio/io_context.hpp>
11 #include <boost/container/flat_map.hpp>
12 #include <sdbusplus/asio/connection.hpp>
13 #include <sdbusplus/asio/object_server.hpp>
14 #include <sdbusplus/message.hpp>
15 
16 #include <cstdint>
17 #include <memory>
18 #include <string>
19 
20 constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
21 constexpr const char* deviceType = "NvidiaMctpVdm";
22 
23 struct SensorConfigs
24 {
25     std::string name;
26     uint64_t pollRate{};
27     uint64_t nicNetworkPortCount{};
28 };
29 
30 class GpuDevice;
31 class SmaDevice;
32 class PcieDevice;
33 
34 void createSensors(
35     boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer,
36     boost::container::flat_map<std::string, std::shared_ptr<GpuDevice>>&
37         gpuDevices,
38     boost::container::flat_map<std::string, std::shared_ptr<SmaDevice>>&
39         smaDevices,
40     boost::container::flat_map<std::string, std::shared_ptr<PcieDevice>>&
41         pcieDevices,
42     const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
43     mctp::MctpRequester& mctpRequester);
44 
45 void interfaceRemoved(
46     sdbusplus::message_t& message,
47     boost::container::flat_map<std::string, std::shared_ptr<GpuDevice>>&
48         gpuDevices,
49     boost::container::flat_map<std::string, std::shared_ptr<SmaDevice>>&
50         smaDevices,
51     boost::container::flat_map<std::string, std::shared_ptr<PcieDevice>>&
52         pcieDevices);
53