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 #include "NvidiaDeviceDiscovery.hpp" 10 #include "NvidiaPcieInterface.hpp" 11 12 #include <boost/asio/io_context.hpp> 13 #include <boost/asio/steady_timer.hpp> 14 #include <sdbusplus/asio/connection.hpp> 15 #include <sdbusplus/asio/object_server.hpp> 16 17 #include <chrono> 18 #include <cstdint> 19 #include <memory> 20 #include <string> 21 22 constexpr const char* pcieDevicePathPrefix = 23 "/xyz/openbmc_project/inventory/pcie_devices/"; 24 25 class PcieDevice 26 { 27 public: 28 PcieDevice(const SensorConfigs& configs, const std::string& name, 29 const std::string& path, 30 const std::shared_ptr<sdbusplus::asio::connection>& conn, 31 uint8_t eid, boost::asio::io_context& io, 32 mctp::MctpRequester& mctpRequester, 33 sdbusplus::asio::object_server& objectServer); 34 getPath() const35 const std::string& getPath() const 36 { 37 return path; 38 } 39 40 void init(); 41 42 private: 43 void makeSensors(); 44 45 void read(); 46 47 uint8_t eid{}; 48 49 std::chrono::milliseconds sensorPollMs; 50 51 boost::asio::steady_timer waitTimer; 52 53 mctp::MctpRequester& mctpRequester; 54 55 std::shared_ptr<sdbusplus::asio::connection> conn; 56 57 sdbusplus::asio::object_server& objectServer; 58 59 SensorConfigs configs; 60 61 std::string name; 62 63 std::string path; 64 65 std::shared_ptr<NvidiaPcieInterface> pcieInterface; 66 }; 67