blob: 29614047678ee0462e196bde7decda6d7e6dfafd [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/**
21 * @struct DeviceInfo
22 * @brief Contains information about a device
23 */
24struct DeviceInfo
25{
26 uint8_t deviceType;
27 uint8_t instanceId;
28};
29
30/**
31 * @struct GpuTempSensor
32 * @brief Implements a GPU temperature sensor that monitors temperature values
33 * @details Inherits from Sensor base class and enables shared pointer
34 * management via std::enable_shared_from_this
35 */
36struct GpuTempSensor :
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053037 public GpuSensor,
Harshit Agheraacd375a2025-04-21 19:50:10 +053038 public std::enable_shared_from_this<GpuTempSensor>
39{
40 public:
41 /**
42 * @brief Constructor for GpuTempSensor
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053043 * @param conn D-Bus connection for system communication
Harshit Agheraacd375a2025-04-21 19:50:10 +053044 * @param mctpRequester MCTP protocol requester for GPU communication
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053045 * @param name Name of the sensor for identification in the system
46 * @param sensorConfiguration Configuration string for the sensor containing
47 * setup parameters
48 * @param eid EID of the device endpoint
49 * @param objectServer D-Bus object server for exposing sensor interfaces
50 * @param thresholdData Vector of threshold configurations for temperature
51 * monitoring
Harshit Agheraacd375a2025-04-21 19:50:10 +053052 */
53 GpuTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
Harshit Agheraa3f24f42025-04-21 20:04:56 +053054 mctp::MctpRequester& mctpRequester, const std::string& name,
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053055 const std::string& sensorConfiguration, uint8_t eid,
Harshit Agheraacd375a2025-04-21 19:50:10 +053056 sdbusplus::asio::object_server& objectServer,
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053057 std::vector<thresholds::Threshold>&& thresholdData);
Harshit Agheraacd375a2025-04-21 19:50:10 +053058
59 /**
60 * @brief Destructor
61 */
62 ~GpuTempSensor() override;
63
64 /**
65 * @brief Check if any thresholds have been crossed
66 * @details Overrides the base class method to implement GPU-specific
67 * threshold checking
68 */
69 void checkThresholds() override;
70
71 private:
72 /**
Harshit Agheraa3f24f42025-04-21 20:04:56 +053073 * @brief Update the sensor reading
74 */
Harshit Aghera11b9c1a2025-04-29 17:34:25 +053075 void update() final;
Harshit Agheraa3f24f42025-04-21 20:04:56 +053076
77 /**
78 * @brief MCTP endpoint ID
79 */
80 uint8_t eid{};
81
82 /**
83 * @brief The sensor ID
84 */
85 uint8_t sensorId;
86
87 /**
Harshit Agheraa3f24f42025-04-21 20:04:56 +053088 * @brief Reference to the MCTP requester for communication
89 */
90 mctp::MctpRequester& mctpRequester;
91
92 /**
Harshit Agheraacd375a2025-04-21 19:50:10 +053093 * @brief D-Bus object server
94 */
95 sdbusplus::asio::object_server& objectServer;
96};