blob: c74c57e5f25283f5f3148c6cc61cd6eb2b79f312 [file] [log] [blame]
Harshit Agheraacd375a2025-04-21 19:50:10 +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
Harshit Agheraa3f24f42025-04-21 20:04:56 +05308#include "MctpRequester.hpp"
Harshit Agheraacd375a2025-04-21 19:50:10 +05309#include "Thresholds.hpp"
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053010#include "UpdatableSensor.hpp"
Harshit Agheraacd375a2025-04-21 19:50:10 +053011
Harshit Agheraacd375a2025-04-21 19:50:10 +053012#include <sdbusplus/asio/connection.hpp>
13#include <sdbusplus/asio/object_server.hpp>
Harshit Agheraacd375a2025-04-21 19:50:10 +053014
15#include <cstdint>
Harshit Agheraacd375a2025-04-21 19:50:10 +053016#include <memory>
17#include <string>
Harshit Agheraacd375a2025-04-21 19:50:10 +053018#include <vector>
19
Harshit Agheraacd375a2025-04-21 19:50:10 +053020/**
Harshit Agheraacd375a2025-04-21 19:50:10 +053021 * @struct GpuTempSensor
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 GpuTempSensor :
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053027 public GpuSensor,
Harshit Agheraacd375a2025-04-21 19:50:10 +053028 public std::enable_shared_from_this<GpuTempSensor>
29{
30 public:
31 /**
32 * @brief Constructor for GpuTempSensor
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053033 * @param conn D-Bus connection for system communication
Harshit Agheraacd375a2025-04-21 19:50:10 +053034 * @param mctpRequester MCTP protocol requester for GPU communication
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053035 * @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
Harshit Agheraacd375a2025-04-21 19:50:10 +053042 */
43 GpuTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
Harshit Agheraa3f24f42025-04-21 20:04:56 +053044 mctp::MctpRequester& mctpRequester, const std::string& name,
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053045 const std::string& sensorConfiguration, uint8_t eid,
Harshit Agheraacd375a2025-04-21 19:50:10 +053046 sdbusplus::asio::object_server& objectServer,
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053047 std::vector<thresholds::Threshold>&& thresholdData);
Harshit Agheraacd375a2025-04-21 19:50:10 +053048
49 /**
50 * @brief Destructor
51 */
52 ~GpuTempSensor() 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 /**
Harshit Agheraa3f24f42025-04-21 20:04:56 +053063 * @brief Update the sensor reading
64 */
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053065 void update() final;
Harshit Agheraa3f24f42025-04-21 20:04:56 +053066
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 /**
Harshit Agheraa3f24f42025-04-21 20:04:56 +053078 * @brief Reference to the MCTP requester for communication
79 */
80 mctp::MctpRequester& mctpRequester;
81
82 /**
Harshit Agheraacd375a2025-04-21 19:50:10 +053083 * @brief D-Bus object server
84 */
85 sdbusplus::asio::object_server& objectServer;
86};