blob: 0e9b7afd154ca62d5aa283e1ca641b2fc1bd9f0d [file] [log] [blame]
Harshit Agherad837b562025-04-21 19:50:10 +05301/*
2 * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION &
Harshit Aghera560e6af2025-04-21 20:04:56 +05303 * AFFILIATES. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
Harshit Agherad837b562025-04-21 19:50:10 +05305 */
6
7#pragma once
8
Harshit Aghera560e6af2025-04-21 20:04:56 +05309#include "MctpRequester.hpp"
Harshit Agherad837b562025-04-21 19:50:10 +053010#include "Thresholds.hpp"
Harshit Agherad837b562025-04-21 19:50:10 +053011#include "sensor.hpp"
12
Harshit Aghera560e6af2025-04-21 20:04:56 +053013#include <NvidiaGpuMctpVdm.hpp>
Harshit Agherad837b562025-04-21 19:50:10 +053014#include <sdbusplus/asio/connection.hpp>
15#include <sdbusplus/asio/object_server.hpp>
Harshit Agherad837b562025-04-21 19:50:10 +053016
Harshit Aghera560e6af2025-04-21 20:04:56 +053017#include <array>
Harshit Aghera560e6af2025-04-21 20:04:56 +053018#include <cstdint>
Harshit Agherad837b562025-04-21 19:50:10 +053019#include <memory>
20#include <string>
21#include <vector>
22
Harshit Agheraba138da2025-05-05 12:26:35 +053023constexpr uint8_t gpuTempSensorId{0};
24constexpr uint8_t gpuTLimitSensorId{2};
Harshit Agherab10a67b2025-05-27 12:19:29 +053025constexpr uint8_t gpuDramTempSensorId{1};
Harshit Aghera8951c872025-06-25 15:25:33 +053026constexpr uint8_t smaTempSensorId{5};
Harshit Agheraba138da2025-05-05 12:26:35 +053027
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053028struct NvidiaGpuTempSensor :
Harshit Agherad837b562025-04-21 19:50:10 +053029 public Sensor,
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053030 public std::enable_shared_from_this<NvidiaGpuTempSensor>
Harshit Agherad837b562025-04-21 19:50:10 +053031{
32 public:
Harshit Agheraba138da2025-05-05 12:26:35 +053033 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 Agherad837b562025-04-21 19:50:10 +053039
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053040 ~NvidiaGpuTempSensor() override;
Harshit Agherad837b562025-04-21 19:50:10 +053041
Harshit Agherad837b562025-04-21 19:50:10 +053042 void checkThresholds() override;
43
Harshit Aghera560e6af2025-04-21 20:04:56 +053044 void update();
45
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053046 private:
Harshit Aghera560e6af2025-04-21 20:04:56 +053047 void processResponse(int sendRecvMsgResult);
48
Harshit Aghera560e6af2025-04-21 20:04:56 +053049 uint8_t eid{};
50
51 uint8_t sensorId;
52
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053053 std::shared_ptr<sdbusplus::asio::connection> conn;
Harshit Agherad837b562025-04-21 19:50:10 +053054
Harshit Aghera560e6af2025-04-21 20:04:56 +053055 mctp::MctpRequester& mctpRequester;
56
Harshit Agherad837b562025-04-21 19:50:10 +053057 sdbusplus::asio::object_server& objectServer;
Harshit Aghera560e6af2025-04-21 20:04:56 +053058
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053059 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingRequest)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053060 getTemperatureReadingRequest{};
61
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053062 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingResponse)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053063 getTemperatureReadingResponse{};
Harshit Agherad837b562025-04-21 19:50:10 +053064};