History log of /openbmc/dbus-sensors/src/nvidia-gpu/NvidiaSensorUtils.hpp (Results 1 – 1 of 1)
Revision Date Author Comments
# 4c0a0b45 29-Dec-2025 Ender Hsieh <andhsieh@nvidia.com>

nvidia-gpu: implement PhysicalContext interface

This change implements the xyz.openbmc_project.Common.PhysicalContext
interface for NVIDIA GPU sensors (Energy, Power, Temperature, and
Voltage). This

nvidia-gpu: implement PhysicalContext interface

This change implements the xyz.openbmc_project.Common.PhysicalContext
interface for NVIDIA GPU sensors (Energy, Power, Temperature, and
Voltage). This allows sensors to expose their hardware context
information to external interfaces like Redfish.

Instead of hardcoding the PhysicalContext value, this implementation
uses a device type enum (gpu::DeviceIdentification) to determine the
appropriate PhysicalContext. A helper function maps device types to
their corresponding D-Bus PhysicalContext values, ensuring proper
separation of concerns.

For GPU devices, the Type property is set to 'GPU'. For other device
types (SMA, PCIe), no PhysicalContext interface is created, keeping
their D-Bus representation clean.

This implementation follows the interface definition introduced in:
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/86504

Changes:
- src/nvidia-gpu/NvidiaSensorUtils.hpp: New helper file containing
deviceTypeToPhysicalContext() function that maps DeviceIdentification
enum to D-Bus PhysicalContext paths.
- src/nvidia-gpu/*.hpp: Update sensor constructors to accept
gpu::DeviceIdentification deviceType parameter (no default value).
- src/nvidia-gpu/*Sensor.cpp: Use helper function to determine
PhysicalContext. Conditionally create interface only when a valid
context is returned. Register 'Type' property with the mapped value.
- src/nvidia-gpu/NvidiaGpuDevice.cpp: Pass DEVICE_GPU enum for all GPU
sensors. Fix io member initialization in constructor.
- src/nvidia-gpu/NvidiaSmaDevice.cpp: Pass DEVICE_SMA enum for SMA
sensors (no PhysicalContext interface created).

Design rationale:
- GpuDevice class doesn't need to know D-Bus implementation details
- Centralized mapping function makes maintenance easier
- Type-safe enum prevents typos and provides compile-time checking
- Automatic handling for different device types without conditional
logic in device classes

Tested: Build an image for nvl32-obmc machine with the following patch
cherry picked.

https://gerrit.openbmc.org/c/openbmc/openbmc/+/85490

Verified via busctl that the Type property appears under
xyz.openbmc_project.Common.PhysicalContext interface for GPU sensors
only and contains the correct value 'GPU'. SMA device sensors do not
have this interface, as expected.

Depends-On: I83dcbe4810139fb92fddf6b099f5a1a057e7e05e
Change-Id: I1d5abfa5d4416af3565bf315e0f28cb6af56f14c
Signed-off-by: Ender Hsieh <andhsieh@nvidia.com>

show more ...