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