Add support for type-2 PCIeDevice group0 telemetry

Added type-2 support for GROUP_ID_0 and GROUP_ID_1 to populate
PCIeDevice telemetry.

Fixes nvbug https://nvbugspro.nvidia.com/bug/5306349

Tested:
```
root@hgxb300:~# busctl introspect "xyz.openbmc_project.NSM" "/xyz/openbmc_project/inventory/system/chassis/HGX_ConnectX_0/PCIeDevices/ConnectX_0" --full
NAME                                          TYPE      SIGNATURE RESULT/VALUE                                                                            FLAGS
org.freedesktop.DBus.Introspectable           interface -         -                                                                                       -
.Introspect                                   method    -         s                                                                                       -
org.freedesktop.DBus.Peer                     interface -         -                                                                                       -
.GetMachineId                                 method    -         s                                                                                       -
.Ping                                         method    -         -                                                                                       -
org.freedesktop.DBus.Properties               interface -         -                                                                                       -
.Get                                          method    ss        v                                                                                       -
.GetAll                                       method    s         a{sv}                                                                                   -
.Set                                          method    ssv       -                                                                                       -
.PropertiesChanged                            signal    sa{sv}as  -                                                                                       -
xyz.openbmc_project.Association.Definitions   interface -         -                                                                                       -
.Associations                                 property  a(sss)    1 "chassis" "pciedevice" "/xyz/openbmc_project/inventory/system/chassis/HGX_ConnectX_0" emits-change writable
xyz.openbmc_project.Common.UUID               interface -         -                                                                                       -
.UUID                                         property  s         "ae0a96c0-cb06-11e5-a837-3c6d669340f0"                                                  emits-change writable
xyz.openbmc_project.Inventory.Decorator.Asset interface -         -                                                                                       -
.BuildDate                                    property  s         "0000-00-00T00:00:00Z"                                                                  emits-change writable
.Manufacturer                                 property  s         "NVIDIA"                                                                                emits-change writable
.Model                                        property  s         "Nvidia ConnectX8 XDR IB/800GBE for Nvidia B300 NVL8 ------- System"                    emits-change writable
.Name                                         property  s         "NA"                                                                                    emits-change writable
.PartNumber                                   property  s         "MLX000647"                                                                             emits-change writable
.SKU                                          property  s         "NA"                                                                                    emits-change writable
.SerialNumber                                 property  s         "1662425750916"                                                                         emits-change writable
.SparePartNumber                              property  s         ""                                                                                      emits-change writable
.SubModel                                     property  s         ""                                                                                      emits-change writable
xyz.openbmc_project.Inventory.Item.PCIeDevice interface -         -                                                                                       -
.DeviceType                                   property  s         "SingleFunction"                                                                        emits-change writable
.Function0ClassCode                           property  s         "0x000000"                                                                              emits-change writable
.Function0DeviceClass                         property  s         "ProcessingAccelerators"                                                                emits-change writable
.Function0DeviceId                            property  s         "0x1023"                                                                                emits-change writable
.Function0FunctionType                        property  s         "Physical"                                                                              emits-change writable
.Function0RevisionId                          property  s         "0x00"                                                                                  emits-change writable
.Function0SubsystemId                         property  s         "0x0101"                                                                                emits-change writable
.Function0SubsystemVendorId                   property  s         "0x15B3"                                                                                emits-change writable
.Function0VendorId                            property  s         "0x15B3"                                                                                emits-change writable
.Function1ClassCode                           property  s         ""                                                                                      emits-change writable
...
...
.Function7VendorId                            property  s         ""                                                                                      emits-change writable
.GenerationInUse                              property  s         "xyz.openbmc_project.Inventory.Item.PCIeSlot.Generations.Gen5"                          emits-change writable
.GenerationSupported                          property  s         "xyz.openbmc_project.Inventory.Item.PCIeSlot.Generations.Unknown"                       emits-change writable
.LanesInUse                                   property  u         16                                                                                      emits-change writable
.MaxLanes                                     property  u         16                                                                                      emits-change writable
.MaxPCIeType                                  property  s         "xyz.openbmc_project.Inventory.Item.PCIeDevice.PCIeTypes.Gen5"                          emits-change writable
.PCIeType                                     property  s         "xyz.openbmc_project.Inventory.Item.PCIeDevice.PCIeTypes.Gen5"                          emits-change writable
xyz.openbmc_project.State.Decorator.Health    interface -         -                                                                                       -
.Health                                       property  s         "xyz.openbmc_project.State.Decorator.Health.HealthType.OK"                              emits-change writable
root@hgxb300:~# busctl introspect "xyz.openbmc_project.NSM" "/xyz/openbmc_project/inventory/system/chassis/HGX_NVLinkManagementNIC_0/PCIeDevices/NVLinkManagementNIC_0" --full
NAME                                                 TYPE      SIGNATURE RESULT/VALUE                                                                                       FLAGS
org.freedesktop.DBus.Introspectable                  interface -         -                                                                                                  -
.Introspect                                          method    -         s                                                                                                  -
org.freedesktop.DBus.Peer                            interface -         -                                                                                                  -
.GetMachineId                                        method    -         s                                                                                                  -
.Ping                                                method    -         -                                                                                                  -
org.freedesktop.DBus.Properties                      interface -         -                                                                                                  -
.Get                                                 method    ss        v                                                                                                  -
.GetAll                                              method    s         a{sv}                                                                                              -
.Set                                                 method    ssv       -                                                                                                  -
.PropertiesChanged                                   signal    sa{sv}as  -                                                                                                  -
xyz.openbmc_project.Association.Definitions          interface -         -                                                                                                  -
.Associations                                        property  a(sss)    1 "chassis" "pciedevice" "/xyz/openbmc_project/inventory/system/chassis/HGX_NVLinkManagementNIC_0" emits-change writable
xyz.openbmc_project.Common.UUID                      interface -         -                                                                                                  -
.UUID                                                property  s         "ae0a96c0-cb06-11e5-a837-3c6d669340ec"                                                             emits-change writable
xyz.openbmc_project.Inventory.Decorator.Asset        interface -         -                                                                                                  -
.BuildDate                                           property  s         "0000-00-00T00:00:00Z"                                                                             emits-change writable
.Manufacturer                                        property  s         "NVIDIA"                                                                                           emits-change writable
.Model                                               property  s         "Nvidia ConnectX7 mezz for Nvidia B300 NVL8 --------System"                                        emits-change writable
.Name                                                property  s         "NA"                                                                                               emits-change writable
.PartNumber                                          property  s         "V000S4N03X"                                                                                       emits-change writable
.SKU                                                 property  s         "NA"                                                                                               emits-change writable
.SerialNumber                                        property  s         "1662425750916"                                                                                    emits-change writable
.SparePartNumber                                     property  s         ""                                                                                                 emits-change writable
.SubModel                                            property  s         ""                                                                                                 emits-change writable
xyz.openbmc_project.Inventory.Decorator.PCIeRefClock interface -         -                                                                                                  -
.PCIeReferenceClockCount                             property  t         0                                                                                                  emits-change
.PCIeReferenceClockEnabled                           property  b         false                                                                                              emits-change
xyz.openbmc_project.Inventory.Item.PCIeDevice        interface -         -                                                                                                  -
.DeviceType                                          property  s         "SingleFunction"                                                                                   emits-change writable
.Function0ClassCode                                  property  s         "0x000000"                                                                                         emits-change writable
.Function0DeviceClass                                property  s         "ProcessingAccelerators"                                                                           emits-change writable
.Function0DeviceId                                   property  s         "0x1021"                                                                                           emits-change writable
.Function0FunctionType                               property  s         "Physical"                                                                                         emits-change writable
.Function0RevisionId                                 property  s         "0x00"                                                                                             emits-change writable
.Function0SubsystemId                                property  s         "0x1113"                                                                                           emits-change writable
.Function0SubsystemVendorId                          property  s         "0x15B3"                                                                                           emits-change writable
.Function0VendorId                                   property  s         "0x15B3"                                                                                           emits-change writable
.Function1ClassCode                                  property  s         ""                                                                                                 emits-change writable
...
...
.Function7VendorId                                   property  s         ""                                                                                                 emits-change writable
.GenerationInUse                                     property  s         "xyz.openbmc_project.Inventory.Item.PCIeSlot.Generations.Gen3"                                     emits-change writable
.GenerationSupported                                 property  s         "xyz.openbmc_project.Inventory.Item.PCIeSlot.Generations.Unknown"                                  emits-change writable
.LanesInUse                                          property  u         2                                                                                                  emits-change writable
.MaxLanes                                            property  u         2                                                                                                  emits-change writable
.MaxPCIeType                                         property  s         "xyz.openbmc_project.Inventory.Item.PCIeDevice.PCIeTypes.Gen4"                                     emits-change writable
.PCIeType                                            property  s         "xyz.openbmc_project.Inventory.Item.PCIeDevice.PCIeTypes.Gen3"                                     emits-change writable
xyz.openbmc_project.State.Chassis                    interface -         -                                                                                                  -
.CurrentPowerState                                   property  s         "xyz.openbmc_project.State.Chassis.PowerState.On"                                                  emits-change writable
.CurrentPowerStatus                                  property  s         "xyz.openbmc_project.State.Chassis.PowerStatus.Undefined"                                          emits-change writable
.LastStateChangeTime                                 property  t         0                                                                                                  emits-change writable
.RequestedPowerTransition                            property  s         "xyz.openbmc_project.State.Chassis.Transition.Off"                                                 emits-change writable
xyz.openbmc_project.State.Decorator.Health           interface -         -                                                                                                  -
.Health                                              property  s         "xyz.openbmc_project.State.Decorator.Health.HealthType.OK"                                         emits-change writable
root@hgxb300:~#
root@hgxb300:~# curl 192.168.31.1/redfish/v1/Chassis/HGX_ConnectX_0/PCIeDevices/ConnectX_0
{
  "@odata.id": "/redfish/v1/Chassis/HGX_ConnectX_0/PCIeDevices/ConnectX_0",
  "@odata.type": "#PCIeDevice.v1_14_0.PCIeDevice",
  "DeviceType": "SingleFunction",
  "Id": "ConnectX_0",
  "Links": {
    "Switch": {
      "@odata.id": "/redfish/v1/Fabrics/HGX_PCIeTopology_0/Switches/ConnectX_Switch_0"
    }
  },
  "Manufacturer": "NVIDIA",
  "Model": "Nvidia ConnectX8 XDR IB/800GBE for Nvidia B300 NVL8 ----- System",
  "Name": "PCIe Device",
  "Oem": {
    "Nvidia": {
      "@odata.type": "#NvidiaPCIeDevice.v1_2_0.NvidiaPCIeDevice"
    }
  },
  "PCIeFunctions": {
    "@odata.id": "/redfish/v1/Chassis/HGX_ConnectX_0/PCIeDevices/ConnectX_0/PCIeFunctions"
  },
  "PCIeInterface": {
    "LanesInUse": 16,
    "MaxLanes": 16,
    "MaxPCIeType": "Gen5",
    "PCIeType": "Gen5"
  },
  "PartNumber": "MLX000647",
  "SerialNumber": "1662425750916",
  "Status": {
    "Conditions": [],
    "Health": "OK",
    "HealthRollup": "OK",
    "State": "Enabled"
  },
  "UUID": "ae0a96c0-cb06-11e5-a837-3c6d669340f0"
}root@hgxb300:~#
root@hgxb300:~# curl 192.168.31.1/redfish/v1/Chassis/HGX_NVLinkManagementNIC_0/PCIeDevices/NVLinkManagementNIC_0
{
  "@odata.id": "/redfish/v1/Chassis/HGX_NVLinkManagementNIC_0/PCIeDevices/NVLinkManagementNIC_0",
  "@odata.type": "#PCIeDevice.v1_14_0.PCIeDevice",
  "DeviceType": "SingleFunction",
  "Id": "NVLinkManagementNIC_0",
  "Manufacturer": "NVIDIA",
  "Model": "Nvidia ConnectX7 mezz for Nvidia B300 NVL8 ---- System",
  "Name": "PCIe Device",
  "Oem": {
    "Nvidia": {
      "@odata.type": "#NvidiaPCIeDevice.v1_2_0.NvidiaPCIeDevice",
      "PCIeReferenceClockEnabled": false
    }
  },
  "PCIeFunctions": {
    "@odata.id": "/redfish/v1/Chassis/HGX_NVLinkManagementNIC_0/PCIeDevices/NVLinkManagementNIC_0/PCIeFunctions"
  },
  "PCIeInterface": {
    "LanesInUse": 2,
    "MaxLanes": 2,
    "MaxPCIeType": "Gen4",
    "PCIeType": "Gen3"
  },
  "PartNumber": "V000S4N03X",
  "SerialNumber": "1662425750916",
  "Status": {
    "Conditions": [],
    "Health": "OK",
    "HealthRollup": "OK",
    "State": "Enabled"
  },
  "UUID": "ae0a96c0-cb06-11e5-a837-3c6d669340ec"
}root@hgxb300:~#
```
```

Signed-off-by: Karthick Sundarrajan <ksundarrajan@nvidia.com>
5 files changed
tree: a2ab5197e970ea8dfd48fd04c1cbc7162d78a11e
  1. common/
  2. example/
  3. libnsm/
  4. mockupResponder/
  5. nsmd/
  6. nsmtool/
  7. requester/
  8. services/
  9. subprojects/
  10. tools/
  11. tracepoints/
  12. .beautysh-ignore
  13. .black-ignore
  14. .clang-format
  15. .eslintignore
  16. .flake8-ignore
  17. .gitignore
  18. .isort-ignore
  19. .markdownlint-ignore
  20. .prettierignore
  21. .shellcheck-ignore
  22. LICENSE
  23. meson.build
  24. meson_options.txt
  25. README.md
README.md

nsmd - Nvidia System Management Daemon

How to build

Source an NvBMC ARM/x86 SDK.

# Meson configure
meson setup --reconfigure -Db_sanitize=address,undefined -Db_lundef=true -Dwerror=true -Dwarning_level=3 -Db_colorout=never --buildtype=debug -Dcpp_args=\"-Wno-error=invalid-constexpr -Wno-invalid-constexpr -Werror=uninitialized -Werror=strict-aliasing\" builddir
# Build all targets
ninja -C builddir
# Run all unit tests
meson test -C builddir

Troubleshooting Build Issues

sdbusplus Version Mismatch

If you encounter sdbusplus build errors, verify that the revision in subprojects/sdbusplus.wrap matches the version specified in the openbmc-build-scripts repository. Version mismatches can cause build failures.

Updating Subproject Dependencies

For other subproject-related errors, you can update all subproject repositories to their latest commits using:

cd subprojects

find -L . -type d -name ".git" | while read gitdir; do
    repo=$(dirname "$gitdir")
    echo "Pulling updates in $repo"
    cd "$repo"
    git pull
    cd - > /dev/null
done

Installing clang-format-17 for CI Usage

To ensure code consistency and formatting standards in the CI pipeline, clang-format-17 needs to be installed. Follow the steps below to install clang-format-17 on your system:

# Update the package list
sudo apt update

# Install wget if not already installed
sudo apt install wget

# Download the LLVM installation script
wget https://apt.llvm.org/llvm.sh

# Make the script executable
sudo chmod +x llvm.sh

# Run the script to install LLVM version 17
sudo ./llvm.sh 17

# Install clang-format-17
sudo apt install clang-format-17

This will install clang-format-17 on your system, enabling it for use in the CI pipeline.

Using clang-format-17 for all changed files before commit

To automatically format your code before each commit, create a pre-commit hook with the following steps:

cat > .git/hooks/pre-commit << EOL
#!/bin/sh

# Get list of staged files that are C/C++ source files
files=$(git diff --cached --name-only --diff-filter=ACMR | grep ".*\.[ch]\(pp\)\?$")

if [ -n "$files" ]; then
    # Format the files
    clang-format-17 -i $files
    
    # Add the formatted files back to staging
    git add $files
    
    # Check if any files were modified after formatting
    if ! git diff --cached --quiet; then
        echo "Formatted C/C++ files were automatically fixed up"
    fi
fi

exit 0
EOL
chmod +x .git/hooks/pre-commit

Artifacts

Successful build should generate three binary artifacts.

  1. nsmd (NSM Daemon)
  2. nsmtool (NSM Requester utility)
  3. nsmMockupResponder (NSM Endpoint Mockup Responder)

nsmd

A Daemon that can discover NSM endpoint, gather telemetry data from the endpoints, and can publish them to D-Bus or similar IPC services, for consumer services like bmcweb.

nsmtool

nsmtool is a client tool that acts as a NSM requester which can be invoked from the BMC. nsmtool sends the request message and parse the response message & display it in readable format.

nsmMockupResponder

A mockup NSM responder that can be used for development purpose. Its primary usage is to test nsmd and nsmtool features on an emulator like QEMU. The mockup NSM responder includes modified MCTP control and demux daemon, user can create a emulated MCTP endpoint by providing a json file to modified MCTP control daemon to expose the emulated MCTP Endpoint to D-Bus.

The mockup NSM responder listens to demux unix socket for the request from nsmd/nsmtool and returns the respond through modified MCTP demux daemon.