blob: 25fe069141229658822304fe965da4a5312a4f4b [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 Aghera4ecdfaa2025-05-22 11:35:39 +053023struct NvidiaGpuTempSensor :
Harshit Agherad837b562025-04-21 19:50:10 +053024 public Sensor,
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053025 public std::enable_shared_from_this<NvidiaGpuTempSensor>
Harshit Agherad837b562025-04-21 19:50:10 +053026{
27 public:
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053028 NvidiaGpuTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
29 mctp::MctpRequester& mctpRequester,
30 const std::string& name,
31 const std::string& sensorConfiguration, uint8_t eid,
32 sdbusplus::asio::object_server& objectServer,
33 std::vector<thresholds::Threshold>&& thresholdData);
Harshit Agherad837b562025-04-21 19:50:10 +053034
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053035 ~NvidiaGpuTempSensor() override;
Harshit Agherad837b562025-04-21 19:50:10 +053036
Harshit Agherad837b562025-04-21 19:50:10 +053037 void checkThresholds() override;
38
Harshit Aghera560e6af2025-04-21 20:04:56 +053039 void update();
40
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053041 private:
Harshit Aghera560e6af2025-04-21 20:04:56 +053042 void processResponse(int sendRecvMsgResult);
43
Harshit Aghera560e6af2025-04-21 20:04:56 +053044 uint8_t eid{};
45
46 uint8_t sensorId;
47
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053048 std::shared_ptr<sdbusplus::asio::connection> conn;
Harshit Agherad837b562025-04-21 19:50:10 +053049
Harshit Aghera560e6af2025-04-21 20:04:56 +053050 mctp::MctpRequester& mctpRequester;
51
Harshit Agherad837b562025-04-21 19:50:10 +053052 sdbusplus::asio::object_server& objectServer;
Harshit Aghera560e6af2025-04-21 20:04:56 +053053
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053054 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingRequest)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053055 getTemperatureReadingRequest{};
56
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053057 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingResponse)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053058 getTemperatureReadingResponse{};
Harshit Agherad837b562025-04-21 19:50:10 +053059};