| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 1 | /* |
| Ed Tanous | b5e823f | 2025-10-09 20:28:42 -0400 | [diff] [blame^] | 2 | * SPDX-FileCopyrightText: Copyright OpenBMC Authors |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 3 | * SPDX-License-Identifier: Apache-2.0 |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #pragma once |
| 7 | |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 8 | #include "MctpRequester.hpp" |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 9 | #include "Thresholds.hpp" |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 10 | #include "sensor.hpp" |
| 11 | |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 12 | #include <NvidiaGpuMctpVdm.hpp> |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 13 | #include <sdbusplus/asio/connection.hpp> |
| 14 | #include <sdbusplus/asio/object_server.hpp> |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 15 | |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 16 | #include <array> |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 17 | #include <cstdint> |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 18 | #include <memory> |
| 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
| Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 22 | constexpr uint8_t gpuTempSensorId{0}; |
| 23 | constexpr uint8_t gpuTLimitSensorId{2}; |
| Harshit Aghera | b10a67b | 2025-05-27 12:19:29 +0530 | [diff] [blame] | 24 | constexpr uint8_t gpuDramTempSensorId{1}; |
| Harshit Aghera | 8951c87 | 2025-06-25 15:25:33 +0530 | [diff] [blame] | 25 | constexpr uint8_t smaTempSensorId{5}; |
| Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 26 | |
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 27 | struct NvidiaGpuTempSensor : |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 28 | public Sensor, |
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 29 | public std::enable_shared_from_this<NvidiaGpuTempSensor> |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 30 | { |
| 31 | public: |
| Harshit Aghera | ba138da | 2025-05-05 12:26:35 +0530 | [diff] [blame] | 32 | NvidiaGpuTempSensor( |
| 33 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 34 | mctp::MctpRequester& mctpRequester, const std::string& name, |
| 35 | const std::string& sensorConfiguration, uint8_t eid, uint8_t sensorId, |
| 36 | sdbusplus::asio::object_server& objectServer, |
| 37 | std::vector<thresholds::Threshold>&& thresholdData); |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 38 | |
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 39 | ~NvidiaGpuTempSensor() override; |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 40 | |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 41 | void checkThresholds() override; |
| 42 | |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 43 | void update(); |
| 44 | |
| Harshit Aghera | 4ecdfaa | 2025-05-22 11:35:39 +0530 | [diff] [blame] | 45 | private: |
| Marc Olberding | d0125c9 | 2025-10-08 14:37:19 -0700 | [diff] [blame] | 46 | void processResponse(const std::error_code& ec, |
| 47 | std::span<const uint8_t> buffer); |
| Harshit Aghera | 560e6af | 2025-04-21 20:04:56 +0530 | [diff] [blame] | 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{}; |
| Harshit Aghera | 3f6bc73 | 2025-07-23 14:22:01 +0530 | [diff] [blame] | 61 | |
| 62 | std::shared_ptr<sdbusplus::asio::dbus_interface> sensorTypeInterface; |
| Harshit Aghera | d837b56 | 2025-04-21 19:50:10 +0530 | [diff] [blame] | 63 | }; |