| 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: | 
|  | 39 | void processResponse(int sendRecvMsgResult); | 
|  | 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 |  | 
|  | 58 | std::array<uint8_t, sizeof(gpu::GetPowerDrawResponse)> response{}; | 
|  | 59 |  | 
|  | 60 | std::shared_ptr<sdbusplus::asio::dbus_interface> telemetryReportInterface; | 
|  | 61 | }; |