| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 1 | /* | 
|  | 2 | * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 3 | * AFFILIATES. All rights reserved. | 
|  | 4 | * SPDX-License-Identifier: Apache-2.0 | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 5 | */ | 
|  | 6 |  | 
|  | 7 | #pragma once | 
|  | 8 |  | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 9 | #include "MctpRequester.hpp" | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 10 | #include "Thresholds.hpp" | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 11 | #include "sensor.hpp" | 
|  | 12 |  | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 13 | #include <NvidiaGpuMctpVdm.hpp> | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 14 | #include <sdbusplus/asio/connection.hpp> | 
|  | 15 | #include <sdbusplus/asio/object_server.hpp> | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 16 |  | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 17 | #include <array> | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 18 | #include <cstdint> | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 19 | #include <memory> | 
|  | 20 | #include <string> | 
|  | 21 | #include <vector> | 
|  | 22 |  | 
| Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 23 | constexpr uint8_t gpuTempSensorId{0}; | 
|  | 24 | constexpr uint8_t gpuTLimitSensorId{2}; | 
| Harshit Aghera | b10a67b | 2025-05-27 12:19:29 +0530 | [diff] [blame] | 25 | constexpr uint8_t gpuDramTempSensorId{1}; | 
| Harshit Aghera | 8951c87 | 2025-06-25 15:25:33 +0530 | [diff] [blame] | 26 | constexpr uint8_t smaTempSensorId{5}; | 
| Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 27 |  | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 28 | struct NvidiaGpuTempSensor : | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 29 | public Sensor, | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 30 | public std::enable_shared_from_this<NvidiaGpuTempSensor> | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 31 | { | 
|  | 32 | public: | 
| Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 33 | NvidiaGpuTempSensor( | 
|  | 34 | std::shared_ptr<sdbusplus::asio::connection>& conn, | 
|  | 35 | mctp::MctpRequester& mctpRequester, const std::string& name, | 
|  | 36 | const std::string& sensorConfiguration, uint8_t eid, uint8_t sensorId, | 
|  | 37 | sdbusplus::asio::object_server& objectServer, | 
|  | 38 | std::vector<thresholds::Threshold>&& thresholdData); | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 39 |  | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 40 | ~NvidiaGpuTempSensor() override; | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 41 |  | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 42 | void checkThresholds() override; | 
|  | 43 |  | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 44 | void update(); | 
|  | 45 |  | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 46 | private: | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 47 | void processResponse(int sendRecvMsgResult); | 
|  | 48 |  | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 49 | uint8_t eid{}; | 
|  | 50 |  | 
|  | 51 | uint8_t sensorId; | 
|  | 52 |  | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 53 | std::shared_ptr<sdbusplus::asio::connection> conn; | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 54 |  | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 55 | mctp::MctpRequester& mctpRequester; | 
|  | 56 |  | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 57 | sdbusplus::asio::object_server& objectServer; | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 58 |  | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 59 | std::array<uint8_t, sizeof(gpu::GetTemperatureReadingRequest)> | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 60 | getTemperatureReadingRequest{}; | 
|  | 61 |  | 
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 62 | std::array<uint8_t, sizeof(gpu::GetTemperatureReadingResponse)> | 
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 63 | getTemperatureReadingResponse{}; | 
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 64 | }; |