How nvidia/nsmd works
Project type and purpose
• This is a system-level management suite for Nvidia hardware on a BMC (Baseboard Management Controller).
• It consists of three main binaries:
– nsmd: the long-running daemon that discovers NSM endpoints over MCTP, gathers telemetry, and publishes via D-Bus.
– nsmtool: a CLI requester that sends NSM commands, receives responses, and formats them for human consumption.
– nsmMockupResponder: a mock endpoint for development/testing that simulates NSM hardware over a UNIX socket.
File structure
• Top-level directories:
– common: shared C++ utilities (coroutines, logging, timers, DBus helpers).
– libnsm: a C library implementing PLDM-over-MCTP commands (device discovery, configuration, diagnostics, firmware utils).
– requester: helpers for building and managing MCTP requests/timeouts.
– nsmd: the main daemon broken into many modules (deviceManager, eventManager, sensorManager, plus per-feature subdirectories like nsmChassis, nsmNumericSensor, etc.).
– nsmtool: the command-line client.
– mockupResponder: a test daemon that implements/responds to NSM requests for emulated endpoints.
– services: D-Bus service files.
– subprojects: vendored dependencies (sdbusplus, phosphor-logging, etc.).
– tools: offline JSON/XLSX processors for sensor/port topology and correlation.
– tracepoints: eBPF/tracing instrumentation.
README for additional insights
• Describes build via Meson/Ninja.
• Emphasizes the three artifacts and their role.
• Mentions D-Bus interfaces (sdbusplus) for publishing telemetry.
• Highlights MCTP-PLDM as underlying transport.
Main components & relationships
a. Components
1. CLI Client (nsmtool)
2. Daemon (nsmd), which itself contains:
– Core managers (deviceManager, eventManager, sensorManager, asyncOperationManager)
– Feature plugins (nsmChassis, nsmNumericSensor, nsmEvent, nsmFirmwareUtils, etc.)
– IPC handlers (socket_handler for MCTP demux, responder_handler for DBus introspection)
– Shared libraries: common (C++ utilities), libnsm (PLDM-over-MCTP logic), requester (MCTP endpoint)
– Systemd service file (services/nsmd.service)
3. Mockup Responder (nsmMockupResponder)
4. Underlying transports:
– MCTP control daemon & demux over UNIX socket
– sdbusplus-based D-Bus for publishing telemetry & control
5. Consumers
– bmcweb or other D-Bus subscribers
b. Interactions
– nsmtool sends a request over the MCTP socket → nsmd’s socket_handler demuxes it → it goes through requester/libnsm → feature modules handle it → nsmd writes back via socket → nsmtool prints it.
– nsmd periodically polls endpoints (via libnsm PLDM commands) → sensorManager aggregates results → publishes properties over D-Bus → external consumers (bmcweb) read them.
– mockupResponder binds to the same MCTP socket for development → responds to PLDM commands with prerecorded JSON chassis definitions.
c. Architectural patterns / design principles
– Modular plugin architecture: each NSM feature lives in its own directory with its own Meson target and tests.
– Layered IPC: transport (MCTP), protocol (PLDM in libnsm), business logic (nsmd modules), presentation (D-Bus interfaces).
– Test-driven: nearly every module has a corresponding test directory.
– Shared utilities for concurrency (common/coroutineSemaphore.hpp), timing, and logging.
d. Key technologies / frameworks
– Meson + Ninja for builds
– CMake-style module separation by Meson subdirectories
– sdbusplus (D-Bus binding)
– MCTP over UNIX domain sockets
– PLDM command library (libnsm)
– C++17 concurrency primitives
– Systemd service file for daemon management
Detailed capture
• Drill into one feature module (e.g., nsmNumericSensor):
– Show how sensorManager invokes the factory (nsmNumericSensorFactory) → individual sensors → aggregator → D-Bus.
• Build dependencies:
– subprojects → common/libnsm → nsmd/nsmtool/mockupResponder.
• Call out test harnesses: