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