| /* |
| * SPDX-FileCopyrightText: Copyright OpenBMC Authors |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| #pragma once |
| |
| #include "MctpRequester.hpp" |
| #include "NvidiaDriverInformation.hpp" |
| #include "NvidiaGpuMctpVdm.hpp" |
| #include "NvidiaPcieFunction.hpp" |
| #include "NvidiaPcieInterface.hpp" |
| #include "NvidiaSensorConfig.hpp" |
| |
| #include <NvidiaEthPort.hpp> |
| #include <NvidiaPciePort.hpp> |
| #include <NvidiaPciePortMetrics.hpp> |
| #include <boost/asio/io_context.hpp> |
| #include <boost/asio/steady_timer.hpp> |
| #include <sdbusplus/asio/connection.hpp> |
| #include <sdbusplus/asio/object_server.hpp> |
| #include <sdbusplus/message/native_types.hpp> |
| |
| #include <array> |
| #include <chrono> |
| #include <cstdint> |
| #include <memory> |
| #include <span> |
| #include <string> |
| #include <system_error> |
| #include <vector> |
| |
| struct PcieDeviceInfo |
| { |
| uint16_t numUpstreamPorts{}; |
| std::vector<uint8_t> numDownstreamPorts; |
| }; |
| |
| class PcieDevice : public std::enable_shared_from_this<PcieDevice> |
| { |
| public: |
| PcieDevice(const SensorConfigs& configs, const std::string& name, |
| const sdbusplus::object_path& path, |
| const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| uint8_t eid, boost::asio::io_context& io, |
| mctp::MctpRequester& mctpRequester, |
| sdbusplus::asio::object_server& objectServer); |
| |
| ~PcieDevice(); |
| |
| PcieDevice(const PcieDevice&) = delete; |
| PcieDevice& operator=(const PcieDevice&) = delete; |
| PcieDevice(PcieDevice&&) = delete; |
| PcieDevice& operator=(PcieDevice&&) = delete; |
| |
| const sdbusplus::object_path& getPath() const |
| { |
| return path; |
| } |
| |
| void init(); |
| |
| private: |
| void makeSensors(); |
| |
| void read(); |
| |
| void getPciePortCounts(); |
| |
| void processPciePortCountsResponse(const std::error_code& ec, |
| std::span<const uint8_t> response); |
| |
| void getNetworkPortAddresses(uint16_t portNumber); |
| |
| void processGetNetworkPortAddressesResponse( |
| uint16_t portNumber, const std::error_code& ec, |
| std::span<const uint8_t> response); |
| |
| PcieDeviceInfo pcieDeviceInfo; |
| |
| uint8_t eid{}; |
| |
| std::chrono::milliseconds sensorPollMs; |
| |
| boost::asio::steady_timer waitTimer; |
| |
| mctp::MctpRequester& mctpRequester; |
| |
| std::shared_ptr<sdbusplus::asio::connection> conn; |
| |
| sdbusplus::asio::object_server& objectServer; |
| |
| SensorConfigs configs; |
| |
| std::string name; |
| |
| sdbusplus::object_path path; |
| |
| std::array<uint8_t, ocp::accelerator_management::commonRequestSize> |
| getPciePortCountsRequest{}; |
| |
| std::array<uint8_t, gpu::getPortNetworkAddressesRequestSize> |
| getPortNetworkAddressesRequest{}; |
| |
| std::shared_ptr<NvidiaPcieInterface> pcieInterface; |
| std::shared_ptr<NvidiaPcieFunction> pcieFunction; |
| |
| std::shared_ptr<NvidiaDriverInformation> driverInfo; |
| |
| std::vector<std::shared_ptr<NvidiaPciePortInfo>> pciePorts; |
| std::vector<std::shared_ptr<NvidiaPciePortMetrics>> pciePortMetrics; |
| |
| std::shared_ptr<sdbusplus::asio::dbus_interface> networkAdapterInterface; |
| std::shared_ptr<sdbusplus::asio::dbus_interface> |
| networkAdapterAssociationInterface; |
| std::shared_ptr<sdbusplus::asio::dbus_interface> locationCodeInterface; |
| std::shared_ptr<sdbusplus::asio::dbus_interface> embeddedConnectorInterface; |
| |
| std::vector<std::shared_ptr<NvidiaEthPortMetrics>> ethPortMetrics; |
| }; |