Correcting the request parameter for type-2 multi-pcie commands

Changes:
1. Correct the request parameter required for multi pcie port related
commands, it does not have device index as input parameter.
2. Correct the encoding for port info, bit 7 is for port type not bit 0.
3. Cosmetic change, multi pcie telemetry commands are v2 not v1.

Tested on HW:
```
root@hgxb300:~# nsmtool telemetry QueryMultiportScalarGroupTelemetry -d 0 -m 54 -u 0 -i 0 -v -t 0 -g 1
nsmtool: <6> EID: 36, TAG: 0b, Tx: 10 de 80 89 02 24 03 00 00 01
Success in creating the socket : RC = 5
Success in connecting to socket : RC = 0
Success in sending message type as VDM to mctp demux daemon : RC = 4
nsmtool: <6> EID: 36, TAG: 03, Rx: 10 de 00 89 02 24 00 00 00 14 00 05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00
{
    "Completion Code": 0,
    "NegotiatedLinkSpeed": 5,
    "NegotiatedLinkWidth": 5,
    "maxLinkSpeed": 5,
    "maxLinkWidth": 5
}
root@hgxb300:~# nsmtool telemetry QueryMultiportScalarGroupTelemetry -d 0 -m 54 -u 0 -i 0 -v -t 1 -g 1
nsmtool: <6> EID: 36, TAG: 0b, Tx: 10 de 80 89 02 24 03 80 00 01
Success in creating the socket : RC = 5
Success in connecting to socket : RC = 0
Success in sending message type as VDM to mctp demux daemon : RC = 4
nsmtool: <6> EID: 36, TAG: 03, Rx: 10 de 00 89 02 24 00 00 00 14 00 06 00 00 00 05 00 00 00 06 00 00 00 06 00 00 00 05 00 00 00
{
    "Completion Code": 0,
    "NegotiatedLinkSpeed": 6,
    "NegotiatedLinkWidth": 5,
    "maxLinkSpeed": 6,
    "maxLinkWidth": 5
}
root@hgxb300:~# busctl introspect xyz.openbmc_project.NSM /xyz/openbmc_project/inventory/system/fabrics/HGX_PCIeTopology_0/Switches/ConnectX_Switch_0/Ports/UP_0
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 "parent_device" "all_states" "/xyz/... emits-change writable
xyz.openbmc_project.Inventory.Decorator.PortInfo  interface -         -                                        -
.CurrentSpeed                                     property  d         32                                       emits-change writable
.MaxSpeed                                         property  d         32                                       emits-change writable
.Protocol                                         property  s         "xyz.openbmc_project.Inventory.Decora... emits-change writable
.Type                                             property  s         "xyz.openbmc_project.Inventory.Decora... emits-change writable
xyz.openbmc_project.Inventory.Decorator.PortWidth interface -         -                                        -
.ActiveWidth                                      property  u         16                                       emits-change writable
.Width                                            property  u         16                                       emits-change writable
xyz.openbmc_project.Inventory.Item.Port           interface -         -                                        -
.PortNumber                                       property  u         0                                        emits-change
xyz.openbmc_project.PCIe.PCIeECC                  interface -         -                                        -
.L0ToRecoveryCount                                property  d         4                                        emits-change writable
.LanesInUse                                       property  u         4294967295                               emits-change writable
.MaxLanes                                         property  u         0                                        emits-change writable
.NAKReceivedCount                                 property  d         0                                        emits-change writable
.NAKSentCount                                     property  d         0                                        emits-change writable
.PCIeType                                         property  s         "xyz.openbmc_project.PCIe.PCIeECC.PCI... emits-change writable
.ReplayCount                                      property  d         0                                        emits-change writable
.ReplayRolloverCount                              property  d         0                                        emits-change writable
.UnsupportedRequestCount                          property  d         0                                        emits-change writable
.ceCount                                          property  d         0                                        emits-change writable
.feCount                                          property  d         0                                        emits-change writable
.nonfeCount                                       property  d         0                                        emits-change writable
.ueCount                                          property  u         0                                        emits-change writable
xyz.openbmc_project.PCIe.PCIeTransactionCounter   interface -         -                                        -
.OutboundReadPktCount                             property  t         0                                        emits-change writable
.OutboundReadTransfer                             property  t         0                                        emits-change writable
.OutboundTLPCount                                 property  t         0                                        emits-change writable
.OutboundTLPsTransfer                             property  t         0                                        emits-change writable
.OutboundWritePktCount                            property  t         0                                        emits-change writable
.OutboundWriteTransfer                            property  t         0                                        emits-change writable
.ReqDroppedCreditCompletion                       property  t         0                                        emits-change writable
.ReqDroppedNonPostCredit                          property  t         0                                        emits-change writable
.ReqDroppedTag                                    property  t         0                                        emits-change writable
root@hgxb300:~#

root@hgxb300:~# busctl introspect xyz.openbmc_project.NSM /xyz/openbmc_project/inventory/system/fabrics/HGX_PCIeTopology_0/Switches/ConnectX_Switch_0/Ports/DOWN_0
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 "parent_device" "all_states" "/xyz/... emits-change writable
xyz.openbmc_project.Inventory.Decorator.PortInfo  interface -         -                                        -
.CurrentSpeed                                     property  d         64                                       emits-change writable
.MaxSpeed                                         property  d         64                                       emits-change writable
.Protocol                                         property  s         "xyz.openbmc_project.Inventory.Decora... emits-change writable
.Type                                             property  s         "xyz.openbmc_project.Inventory.Decora... emits-change writable
xyz.openbmc_project.Inventory.Decorator.PortWidth interface -         -                                        -
.ActiveWidth                                      property  u         16                                       emits-change writable
.Width                                            property  u         16                                       emits-change writable
xyz.openbmc_project.Inventory.Item.Port           interface -         -                                        -
.PortNumber                                       property  u         0                                        emits-change
xyz.openbmc_project.PCIe.LTSSMState               interface -         -                                        -
.LTSSMState                                       property  s         "xyz.openbmc_project.PCIe.LTSSMState.... emits-change
xyz.openbmc_project.PCIe.PCIeECC                  interface -         -                                        -
.L0ToRecoveryCount                                property  d         5                                        emits-change writable
.LanesInUse                                       property  u         4294967295                               emits-change writable
.MaxLanes                                         property  u         0                                        emits-change writable
.NAKReceivedCount                                 property  d         0                                        emits-change writable
.NAKSentCount                                     property  d         0                                        emits-change writable
.PCIeType                                         property  s         "xyz.openbmc_project.PCIe.PCIeECC.PCI... emits-change writable
.ReplayCount                                      property  d         0                                        emits-change writable
.ReplayRolloverCount                              property  d         0                                        emits-change writable
.UnsupportedRequestCount                          property  d         0                                        emits-change writable
.ceCount                                          property  d         0                                        emits-change writable
.feCount                                          property  d         0                                        emits-change writable
.nonfeCount                                       property  d         0                                        emits-change writable
.ueCount                                          property  u         0                                        emits-change writable
xyz.openbmc_project.PCIe.PCIeTransactionCounter   interface -         -                                        -
.OutboundReadPktCount                             property  t         0                                        emits-change writable
.OutboundReadTransfer                             property  t         0                                        emits-change writable
.OutboundTLPCount                                 property  t         0                                        emits-change writable
.OutboundTLPsTransfer                             property  t         0                                        emits-change writable
.OutboundWritePktCount                            property  t         0                                        emits-change writable
.OutboundWriteTransfer                            property  t         0                                        emits-change writable
.ReqDroppedCreditCompletion                       property  t         0                                        emits-change writable
.ReqDroppedNonPostCredit                          property  t         0                                        emits-change writable
.ReqDroppedTag                                    property  t         0                                        emits-change writable
root@hgxb300:~#

```

Fixes NvBug https://nvbugspro.nvidia.com/bug/5301683
Signed-off-by: Utkarsh Yadav <uyadav@nvidia.com>
10 files changed
tree: 7dd143fbfc0319893635992d17bb5da62fbb9fd0
  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.