blob: 04078143c9ef11680bbd800ab715e82a92473369 [file] [log] [blame]
Harshit Aghera32e3b2b2025-05-05 12:26:35 +05301/*
2 * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION &
3 * AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
8#include "MctpRequester.hpp"
9#include "Thresholds.hpp"
10#include "UpdatableSensor.hpp"
11
12#include <sdbusplus/asio/connection.hpp>
13#include <sdbusplus/asio/object_server.hpp>
14
15#include <cstdint>
16#include <memory>
17#include <string>
18#include <vector>
19
20/**
21 * @struct GpuTLimitSensor
22 * @brief Implements a GPU temperature sensor that monitors temperature values
23 * @details Inherits from Sensor base class and enables shared pointer
24 * management via std::enable_shared_from_this
25 */
26struct GpuTLimitSensor :
27 public GpuSensor,
28 public std::enable_shared_from_this<GpuTLimitSensor>
29{
30 public:
31 /**
32 * @brief Constructor for GpuTLimitSensor
33 * @param conn D-Bus connection for system communication
34 * @param mctpRequester MCTP protocol requester for GPU communication
35 * @param name Name of the sensor for identification in the system
36 * @param sensorConfiguration Configuration string for the sensor containing
37 * setup parameters
38 * @param eid EID of the device endpoint
39 * @param objectServer D-Bus object server for exposing sensor interfaces
40 * @param thresholdData Vector of threshold configurations for temperature
41 * monitoring
42 */
43 GpuTLimitSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
44 mctp::MctpRequester& mctpRequester, const std::string& name,
45 const std::string& sensorConfiguration, uint8_t eid,
46 sdbusplus::asio::object_server& objectServer,
47 std::vector<thresholds::Threshold>&& thresholdData);
48
49 /**
50 * @brief Destructor
51 */
52 ~GpuTLimitSensor() override;
53
54 /**
55 * @brief Check if any thresholds have been crossed
56 * @details Overrides the base class method to implement GPU-specific
57 * threshold checking
58 */
59 void checkThresholds() override;
60
61 private:
62 /**
63 * @brief Update the sensor reading
64 */
65 void update() final;
66
67 /**
68 * @brief MCTP endpoint ID
69 */
70 uint8_t eid{};
71
72 /**
73 * @brief The sensor ID
74 */
75 uint8_t sensorId;
76
77 /**
78 * @brief Reference to the MCTP requester for communication
79 */
80 mctp::MctpRequester& mctpRequester;
81
82 /**
83 * @brief D-Bus object server
84 */
85 sdbusplus::asio::object_server& objectServer;
86};