blob: e2ae89afc2047f37824bacf1c49c55fa6f00bb6f [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 Aghera8951c872025-06-25 15:25:33 +053025constexpr uint8_t smaTempSensorId{5};
Harshit Agheraba138da2025-05-05 12:26:35 +053026
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053027struct NvidiaGpuTempSensor :
Harshit Agherad837b562025-04-21 19:50:10 +053028 public Sensor,
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053029 public std::enable_shared_from_this<NvidiaGpuTempSensor>
Harshit Agherad837b562025-04-21 19:50:10 +053030{
31 public:
Harshit Agheraba138da2025-05-05 12:26:35 +053032 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 Agherad837b562025-04-21 19:50:10 +053038
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053039 ~NvidiaGpuTempSensor() override;
Harshit Agherad837b562025-04-21 19:50:10 +053040
Harshit Agherad837b562025-04-21 19:50:10 +053041 void checkThresholds() override;
42
Harshit Aghera560e6af2025-04-21 20:04:56 +053043 void update();
44
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053045 private:
Harshit Aghera560e6af2025-04-21 20:04:56 +053046 void processResponse(int sendRecvMsgResult);
47
Harshit Aghera560e6af2025-04-21 20:04:56 +053048 uint8_t eid{};
49
50 uint8_t sensorId;
51
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053052 std::shared_ptr<sdbusplus::asio::connection> conn;
Harshit Agherad837b562025-04-21 19:50:10 +053053
Harshit Aghera560e6af2025-04-21 20:04:56 +053054 mctp::MctpRequester& mctpRequester;
55
Harshit Agherad837b562025-04-21 19:50:10 +053056 sdbusplus::asio::object_server& objectServer;
Harshit Aghera560e6af2025-04-21 20:04:56 +053057
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053058 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingRequest)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053059 getTemperatureReadingRequest{};
60
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053061 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingResponse)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053062 getTemperatureReadingResponse{};
Harshit Agherad837b562025-04-21 19:50:10 +053063};