Skip to content

mctp-client: add a generic mctp client #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

molbear
Copy link

@molbear molbear commented Jun 24, 2025

Adds a generic mctp client to use from the cli. Currently does not support extended addressing.

Testing

control commands

mctp-client type control eid 8 data 0x80 0x02
0x00 0x02 0x00 0x08 0x01 0x00

corner case testing

mctp-client type control eid 10 data 0x80 0x02
mctp-client: sendto(2): No route to host

mctp-client type control eid 8 data
mctp-client: no data to send

mctp-client type control eid data 0x80 0x02
usage:
        mctp-client [net <net>] eid <eid> type <type> data <data>
net defaults to MCTP_NET_ANY, data is space delimited hexadecimal. data must be the last parameter
possible types:
        control: control mctp messages per DSP0236
        pldm: platform level data model per DSP0241
        nc-si: NC-SI traffic over MCTP per DSP0261
        ethernet: Ethernet traffic over MCTP per DSP0261
        nvme: nvme over mctp per DSP0235
        spdm: spdm over mctp per DSP0275
        secured: secured messages using spdm over mctp per DSP0276
        pci: vdm using a pci based vendor id per DSP0236
        iana: vdm using an iana based vendor id per DSP0236

mctp-client type control eid data 0x80 0x02
usage:
        mctp-client [net <net>] eid <eid> type <type> data <data>
net defaults to MCTP_NET_ANY, data is space delimited hexadecimal. data must be the last parameter
possible types:
        control: control mctp messages per DSP0236
        pldm: platform level data model per DSP0241
        nc-si: NC-SI traffic over MCTP per DSP0261
        ethernet: Ethernet traffic over MCTP per DSP0261
        nvme: nvme over mctp per DSP0235
        spdm: spdm over mctp per DSP0275
        secured: secured messages using spdm over mctp per DSP0276
        pci: vdm using a pci based vendor id per DSP0236
        iana: vdm using an iana based vendor id per DSP0236

echo $?
1

mctp-client eid 8 data 0x80 0x02
usage:
        mctp-client [net <net>] eid <eid> type <type> data <data>
net defaults to MCTP_NET_ANY, data is space delimited hexadecimal. data must be the last parameter
possible types:
        control: control mctp messages per DSP0236
        pldm: platform level data model per DSP0241
        nc-si: NC-SI traffic over MCTP per DSP0261
        ethernet: Ethernet traffic over MCTP per DSP0261
        nvme: nvme over mctp per DSP0235
        spdm: spdm over mctp per DSP0275
        secured: secured messages using spdm over mctp per DSP0276
        pci: vdm using a pci based vendor id per DSP0236
        iana: vdm using an iana based vendor id per DSP0236

mctp-client type eid 8 data 0x80 0x02
mctp-client: invalid type: eid

Adds a generic mctp client to use from the cli. Currently
does not support extended addressing.

Testing
---
control commands
```
mctp-client type control eid 8 data 0x80 0x02
0x00 0x02 0x00 0x08 0x01 0x00
```

corner case testing
```
mctp-client type control eid 10 data 0x80 0x02
mctp-client: sendto(2): No route to host

mctp-client type control eid 8 data
mctp-client: no data to send

mctp-client type control eid data 0x80 0x02
usage:
        mctp-client [net <net>] eid <eid> type <type> data <data>
net defaults to MCTP_NET_ANY, data is space delimited hexadecimal. data must be the last parameter
possible types:
        control: control mctp messages per DSP0236
        pldm: platform level data model per DSP0241
        nc-si: NC-SI traffic over MCTP per DSP0261
        ethernet: Ethernet traffic over MCTP per DSP0261
        nvme: nvme over mctp per DSP0235
        spdm: spdm over mctp per DSP0275
        secured: secured messages using spdm over mctp per DSP0276
        pci: vdm using a pci based vendor id per DSP0236
        iana: vdm using an iana based vendor id per DSP0236

mctp-client type control eid data 0x80 0x02
usage:
        mctp-client [net <net>] eid <eid> type <type> data <data>
net defaults to MCTP_NET_ANY, data is space delimited hexadecimal. data must be the last parameter
possible types:
        control: control mctp messages per DSP0236
        pldm: platform level data model per DSP0241
        nc-si: NC-SI traffic over MCTP per DSP0261
        ethernet: Ethernet traffic over MCTP per DSP0261
        nvme: nvme over mctp per DSP0235
        spdm: spdm over mctp per DSP0275
        secured: secured messages using spdm over mctp per DSP0276
        pci: vdm using a pci based vendor id per DSP0236
        iana: vdm using an iana based vendor id per DSP0236

echo $?
1

mctp-client eid 8 data 0x80 0x02
usage:
        mctp-client [net <net>] eid <eid> type <type> data <data>
net defaults to MCTP_NET_ANY, data is space delimited hexadecimal. data must be the last parameter
possible types:
        control: control mctp messages per DSP0236
        pldm: platform level data model per DSP0241
        nc-si: NC-SI traffic over MCTP per DSP0261
        ethernet: Ethernet traffic over MCTP per DSP0261
        nvme: nvme over mctp per DSP0235
        spdm: spdm over mctp per DSP0275
        secured: secured messages using spdm over mctp per DSP0276
        pci: vdm using a pci based vendor id per DSP0236
        iana: vdm using an iana based vendor id per DSP0236

mctp-client type eid 8 data 0x80 0x02
mctp-client: invalid type: eid
```
@jk-ozlabs
Copy link
Member

Looks great! Just a couple of minor things:

Firstly: could you add a Signed-off-by line, to indicate an agreement to the DCO?

Secondly: your usage text mentions:

data is space delimited hexadecimal.

But you're parsing with:

tmp = strtoul(val, &endp, 0);

- with the 0 there, you're accepting decimal by default, requiring the 0x for hex.

Not a huge issue, but I'd suggest we could make things more succinct with:

tmp = strtoul(val, &endp, 16);

and printing with

printf("%02x", recv_buffer[ctr]);

With the fixed two-char format (ie., from the 02 prefix), it should be obvious that the output is not decimal.

@jk-ozlabs
Copy link
Member

But you're parsing with:

tmp = strtoul(val, &endp, 0);

no wait, I'm looking at the wrong parsing there. I see you have 16 for the actual data parsing. All good on that side!

Still, want to make the output the same format (ie, without the 0x prefix?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants