blob: e730cf5b0318371bce774dcb3394ea1a0f6e703e [file] [log] [blame]
Harshit Agherad837b562025-04-21 19:50:10 +05301/*
Ed Tanousb5e823f2025-10-09 20:28:42 -04002 * SPDX-FileCopyrightText: Copyright OpenBMC Authors
Harshit Aghera560e6af2025-04-21 20:04:56 +05303 * SPDX-License-Identifier: Apache-2.0
Harshit Agherad837b562025-04-21 19:50:10 +05304 */
5
6#pragma once
7
Harshit Aghera560e6af2025-04-21 20:04:56 +05308#include "MctpRequester.hpp"
Harshit Agherad837b562025-04-21 19:50:10 +05309#include "Thresholds.hpp"
Harshit Agherad837b562025-04-21 19:50:10 +053010#include "sensor.hpp"
11
Harshit Aghera560e6af2025-04-21 20:04:56 +053012#include <NvidiaGpuMctpVdm.hpp>
Harshit Agherad837b562025-04-21 19:50:10 +053013#include <sdbusplus/asio/connection.hpp>
14#include <sdbusplus/asio/object_server.hpp>
Harshit Agherad837b562025-04-21 19:50:10 +053015
Harshit Aghera560e6af2025-04-21 20:04:56 +053016#include <array>
Harshit Aghera560e6af2025-04-21 20:04:56 +053017#include <cstdint>
Harshit Agherad837b562025-04-21 19:50:10 +053018#include <memory>
19#include <string>
20#include <vector>
21
Harshit Agheraba138da2025-05-05 12:26:35 +053022constexpr uint8_t gpuTempSensorId{0};
23constexpr uint8_t gpuTLimitSensorId{2};
Harshit Agherab10a67b2025-05-27 12:19:29 +053024constexpr uint8_t gpuDramTempSensorId{1};
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:
Marc Olberdingd0125c92025-10-08 14:37:19 -070046 void processResponse(const std::error_code& ec,
47 std::span<const uint8_t> buffer);
Harshit Aghera560e6af2025-04-21 20:04:56 +053048
Harshit Aghera560e6af2025-04-21 20:04:56 +053049 uint8_t eid{};
50
51 uint8_t sensorId;
52
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053053 std::shared_ptr<sdbusplus::asio::connection> conn;
Harshit Agherad837b562025-04-21 19:50:10 +053054
Harshit Aghera560e6af2025-04-21 20:04:56 +053055 mctp::MctpRequester& mctpRequester;
56
Harshit Agherad837b562025-04-21 19:50:10 +053057 sdbusplus::asio::object_server& objectServer;
Harshit Aghera560e6af2025-04-21 20:04:56 +053058
Harshit Aghera4ecdfaa2025-05-22 11:35:39 +053059 std::array<uint8_t, sizeof(gpu::GetTemperatureReadingRequest)>
Harshit Aghera560e6af2025-04-21 20:04:56 +053060 getTemperatureReadingRequest{};
Harshit Aghera3f6bc732025-07-23 14:22:01 +053061
62 std::shared_ptr<sdbusplus::asio::dbus_interface> sensorTypeInterface;
Harshit Agherad837b562025-04-21 19:50:10 +053063};