How openbmc/dbus-sensors works
Project Type and Purpose
• This is a collection of sensor applications – essentially, many small “sensor daemons” – that provide DBus interfaces for sensor values and threshold information.
• Each sensor type (ADC, external, fan, hwmon-temp, intel-cpu, intrusion, IPMB, MCTP, MCU, NVMe, PSU, etc.) is implemented as its own standalone daemon. This modular design increases isolation (so that faults in one sensor have minimal impact on others) and simplifies individual updates.
• The project integrates with DBus (using sdbusplus with Asio for asynchronous event handling) to publish sensor updates and allow runtime configuration through an entity manager and other DBus consumers (like Redfish or IPMI SDR).
Analyzing the File Structure
• Top-Level Directories:
• “src”: Contains source code for each sensor type. Each subdirectory (e.g., src/adc, src/fan, src/intel-cpu, etc.) encapsulates the logic for a specific sensor.
• “include”: Contains common header files, including OS-specific ones (e.g., include/linux/peci-ioctl.h) that might be used by the sensor implementations.
• “service_files”: Contains service configuration files (likely for systemd) that map each sensor daemon to its corresponding DBus service (e.g., xyz.openbmc_project.adcsensor.service).
• “subprojects”: Bundles third-party dependencies (e.g., Boost, googletest, sdbusplus wraps) necessary for building and running the project.
• Build system files: “meson.build” and “meson.options” both at the root and in sensor-specific directories imply a well-structured build process to compile each sensor daemon independently.
• Testing: The “src/tests” directory shows that unit testing is part of the project architecture.
Key Architectural Components
a. Sensor Daemons – One for each sensor type (ADC, external, fan, hwmon-temp, etc.). Each of these is an isolated component with its own main function (for example, ADCSensorMain, FanMain, etc.).
b. Common Core Libraries and Utilities – Code in src/ such as DeviceMgmt, FileHandle, SensorPaths, and Thresholds provide shared functionality across sensor types.
c. DBus Communication Layer – The use of sdbusplus/asio bindings for asynchronous DBus interaction. Illustrate how sensor daemons publish their sensor readings and thresholds under the xyz.openbmc_project.Sensor hierarchy.
d. External Inputs and Hardware Interfaces – The sensors collect data from various platforms (hwmon sysfs, direct driver access, and D-Bus inputs), which should be drawn as data sources feeding into each sensor daemon.
Summary of Elements the Principal Software Engineer Should Include
• Labels for each sensor daemon component with their corresponding sensor types.
• A DBus bus component that aggregates sensor information.
• Data flow from hardware/OS interfaces (hwmon, GPIO, direct driver calls) to sensor processing.
• Configuration data flow from an external configuration (entity manager) into each sensor daemon.
• Sensor value and status updates sent from the sensor daemons to the DBus layer.
• Sensor daemons
• External data sources (hardware drivers, configuration systems)
• Consumers of DBus sensor data (e.g., Redfish, IPMI SDR)
• Annotations highlighting the usage of asynchronous event handling (via sdbusplus and asio), the modular design (isolated sensor daemons), and the reactor pattern used for sensor updates.