| Harshit Aghera | 6b71232 | 2025-07-31 19:25:12 +0530 | [diff] [blame] | 1 | /* |
| Ed Tanous | b5e823f | 2025-10-09 20:28:42 -0400 | [diff] [blame^] | 2 | * SPDX-FileCopyrightText: Copyright OpenBMC Authors |
| Harshit Aghera | 6b71232 | 2025-07-31 19:25:12 +0530 | [diff] [blame] | 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | */ |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "MctpRequester.hpp" |
| 9 | |
| 10 | #include <NvidiaGpuMctpVdm.hpp> |
| 11 | #include <sdbusplus/asio/object_server.hpp> |
| 12 | |
| 13 | #include <array> |
| 14 | #include <cstdint> |
| 15 | #include <memory> |
| 16 | #include <string> |
| 17 | #include <tuple> |
| 18 | #include <vector> |
| 19 | |
| 20 | constexpr uint8_t gpuPeakPowerSensorId{0}; |
| 21 | |
| 22 | // GPU Power Sensor Averaging Interval in seconds, 0 implies default |
| 23 | constexpr uint8_t gpuPowerAveragingIntervalInSec{0}; |
| 24 | |
| 25 | struct NvidiaGpuPowerPeakReading |
| 26 | { |
| 27 | public: |
| 28 | NvidiaGpuPowerPeakReading(mctp::MctpRequester& mctpRequester, |
| 29 | const std::string& name, uint8_t eid, |
| 30 | uint8_t sensorId, |
| 31 | sdbusplus::asio::object_server& objectServer); |
| 32 | |
| 33 | ~NvidiaGpuPowerPeakReading(); |
| 34 | |
| 35 | void update(); |
| 36 | |
| 37 | private: |
| Marc Olberding | d0125c9 | 2025-10-08 14:37:19 -0700 | [diff] [blame] | 38 | void processResponse(const std::error_code& ec, |
| 39 | std::span<const uint8_t> buffer); |
| Harshit Aghera | 6b71232 | 2025-07-31 19:25:12 +0530 | [diff] [blame] | 40 | |
| 41 | uint8_t eid{}; |
| 42 | |
| 43 | uint8_t sensorId; |
| 44 | |
| 45 | uint8_t averagingInterval{gpuPowerAveragingIntervalInSec}; |
| 46 | |
| 47 | std::tuple< |
| 48 | uint64_t, |
| 49 | std::vector<std::tuple<std::string, std::string, double, uint64_t>>> |
| 50 | readings; |
| 51 | |
| 52 | mctp::MctpRequester& mctpRequester; |
| 53 | |
| 54 | sdbusplus::asio::object_server& objectServer; |
| 55 | |
| 56 | std::array<uint8_t, sizeof(gpu::GetPowerDrawRequest)> request{}; |
| 57 | |
| Harshit Aghera | 6b71232 | 2025-07-31 19:25:12 +0530 | [diff] [blame] | 58 | std::shared_ptr<sdbusplus::asio::dbus_interface> telemetryReportInterface; |
| 59 | }; |