1*e3596384SManojkiran Eda# Overview of pldmtool 212c8a661SSridevi Ramesh 312c8a661SSridevi Rameshpldmtool is a client tool that acts as a PLDM requester which runs on the BMC. 412c8a661SSridevi Rameshpldmtool sends the request message and displays the response message also 512c8a661SSridevi Rameshprovides flexibility to parse the response message and display it in readable 612c8a661SSridevi Rameshformat. 712c8a661SSridevi Ramesh 812c8a661SSridevi Rameshpldmtool supports the subcommands for PLDM types such as base, platform, bios, 912c8a661SSridevi Rameshfru, and oem-ibm. 1012c8a661SSridevi Ramesh 1112c8a661SSridevi Ramesh- Source files are implemented in C++. 1212c8a661SSridevi Ramesh- Consumes pldm/libpldm encode and decode functions. 1312c8a661SSridevi Ramesh- Communicates with pldmd daemon running on BMC. 1412c8a661SSridevi Ramesh- Enables writing functional test cases for PLDM stack. 1512c8a661SSridevi Ramesh 16*e3596384SManojkiran Edaplease refer the [DMTF PLDM specifications](https://www.dmtf.org/) with respect 17*e3596384SManojkiran Edato the pldm types. 1812c8a661SSridevi Ramesh 1912c8a661SSridevi Ramesh## Code organization 2012c8a661SSridevi Ramesh 2112c8a661SSridevi RameshSource files in pldmtool repository are named with respect to the PLDM type. 2212c8a661SSridevi Ramesh 2312c8a661SSridevi RameshExample: 243618064eSPatrick Williams 25*e3596384SManojkiran Eda```txt 2612c8a661SSridevi Rameshpldm_base_cmd.[hpp/cpp], pldm_fru_cmd.[hpp/cpp] 2712c8a661SSridevi Ramesh``` 2812c8a661SSridevi Ramesh 2912c8a661SSridevi Rameshpldmtool commands for corresponding PLDM type is constructed with the help of 3012c8a661SSridevi Rameshencode request and decode response APIs which are implemented in pldm/libpldm. 3112c8a661SSridevi Ramesh 3212c8a661SSridevi RameshExample: 3312c8a661SSridevi Ramesh 3412c8a661SSridevi RameshGiven a PLDM command "foo" of PLDM type "base" the pldmtool should consume 3512c8a661SSridevi Rameshfollowing API from the libpldm. 3612c8a661SSridevi Ramesh 37*e3596384SManojkiran Eda```c 3812c8a661SSridevi Ramesh- encode_foo_req() - Send the required input parameters in the request message. 3912c8a661SSridevi Ramesh- decode_foo_resp() - Decode the response message. 4012c8a661SSridevi Ramesh``` 4112c8a661SSridevi Ramesh 4212c8a661SSridevi RameshIf PLDM commands are not yet supported in the pldmtool repository user can 43*e3596384SManojkiran Edadirectly send the request message with the help of **pldmtool raw -d \<data\>** 443618064eSPatrick Williamsoption. 4512c8a661SSridevi Ramesh 4612c8a661SSridevi Ramesh## Usage 4712c8a661SSridevi Ramesh 4812c8a661SSridevi RameshUser can see the pldmtool supported PLDM types in the usage output available 4912c8a661SSridevi Rameshwith the **-h** help option as shown below: 5012c8a661SSridevi Ramesh 51*e3596384SManojkiran Eda```bash 52*e3596384SManojkiran Eda$ pldmtool -h 5312c8a661SSridevi RameshPLDM requester tool for OpenBMC 5412c8a661SSridevi RameshUsage: pldmtool [OPTIONS] SUBCOMMAND 5512c8a661SSridevi Ramesh 5612c8a661SSridevi RameshOptions: 5712c8a661SSridevi Ramesh -h,--help Print this help message and exit 5812c8a661SSridevi Ramesh 5912c8a661SSridevi RameshSubcommands: 6012c8a661SSridevi Ramesh raw send a raw request and print response 6112c8a661SSridevi Ramesh base base type command 6212c8a661SSridevi Ramesh bios bios type command 6312c8a661SSridevi Ramesh platform platform type command 6412c8a661SSridevi Ramesh fru FRU type command 6512c8a661SSridevi Ramesh oem-ibm oem type command 6612c8a661SSridevi Ramesh 6712c8a661SSridevi Ramesh``` 683618064eSPatrick Williams 6912c8a661SSridevi Rameshpldmtool command prompt expects a PLDM type to display the list of supported 7012c8a661SSridevi Rameshcommands that are already implemented for that particular PLDM type. 7112c8a661SSridevi Ramesh 72*e3596384SManojkiran Eda```bash 73*e3596384SManojkiran Eda# command format 74*e3596384SManojkiran Edapldmtool <pldmType> -h 7512c8a661SSridevi Ramesh``` 763618064eSPatrick Williams 7712c8a661SSridevi RameshExample: 7812c8a661SSridevi Ramesh 79*e3596384SManojkiran Eda```bash 8012c8a661SSridevi Ramesh$ pldmtool base -h 8112c8a661SSridevi Ramesh 8212c8a661SSridevi Rameshbase type command 8312c8a661SSridevi RameshUsage: pldmtool base [OPTIONS] SUBCOMMAND 8412c8a661SSridevi Ramesh 8512c8a661SSridevi RameshOptions: 8612c8a661SSridevi Ramesh -h,--help Print this help message and exit 8712c8a661SSridevi Ramesh 8812c8a661SSridevi RameshSubcommands: 8912c8a661SSridevi Ramesh GetPLDMTypes get pldm supported types 9012c8a661SSridevi Ramesh GetPLDMVersion get version of a certain type 9112c8a661SSridevi Ramesh GetTID get Terminus ID (TID) 9212c8a661SSridevi Ramesh GetPLDMCommands get supported commands of pldm type 9312c8a661SSridevi Ramesh 9412c8a661SSridevi Ramesh``` 953618064eSPatrick Williams 9612c8a661SSridevi RameshMore help on the command usage can be found by specifying the PLDM type and the 9712c8a661SSridevi Rameshcommand name with **-h** argument as shown below. 9812c8a661SSridevi Ramesh 99*e3596384SManojkiran Eda```bash 100*e3596384SManojkiran Eda# command format 101*e3596384SManojkiran Edapldmtool <pldmType> <commandName> -h 10212c8a661SSridevi Ramesh``` 10312c8a661SSridevi Ramesh 10412c8a661SSridevi RameshExample: 1053618064eSPatrick Williams 106*e3596384SManojkiran Eda```bash 10712c8a661SSridevi Ramesh$ pldmtool base GetPLDMTypes -h 10812c8a661SSridevi Ramesh 10912c8a661SSridevi Rameshget pldm supported types 11012c8a661SSridevi RameshUsage: pldmtool base GetPLDMTypes [OPTIONS] 11112c8a661SSridevi Ramesh 11212c8a661SSridevi RameshOptions: 11312c8a661SSridevi Ramesh -h,--help Print this help message and exit 11412c8a661SSridevi Ramesh -m,--mctp_eid UINT MCTP endpoint ID 11512c8a661SSridevi Ramesh -v,--verbose 11612c8a661SSridevi Ramesh``` 11712c8a661SSridevi Ramesh 11812c8a661SSridevi Ramesh## pldmtool raw command usage 11912c8a661SSridevi Ramesh 1203618064eSPatrick Williamspldmtool raw command option accepts request message in the hexadecimal bytes and 1213618064eSPatrick Williamssend the response message in hexadecimal bytes. 12212c8a661SSridevi Ramesh 123*e3596384SManojkiran Eda```bash 12412c8a661SSridevi Ramesh$ pldmtool raw -h 12512c8a661SSridevi Rameshsend a raw request and print response 12612c8a661SSridevi RameshUsage: pldmtool raw [OPTIONS] 12712c8a661SSridevi Ramesh 12812c8a661SSridevi RameshOptions: 12912c8a661SSridevi Ramesh -h,--help Print this help message and exit 13012c8a661SSridevi Ramesh -m,--mctp_eid UINT MCTP endpoint ID 13112c8a661SSridevi Ramesh -v,--verbose 13212c8a661SSridevi Ramesh -d,--data UINT REQUIRED raw data 13312c8a661SSridevi Ramesh``` 13412c8a661SSridevi Ramesh 13512c8a661SSridevi Ramesh**pldmtool request message format:** 13612c8a661SSridevi Ramesh 137*e3596384SManojkiran Eda```bash 13812c8a661SSridevi Rameshpldmtool raw --data 0x80 <pldmType> <cmdType> <payloadReq> 13912c8a661SSridevi Ramesh 14012c8a661SSridevi RameshpayloadReq - stream of bytes constructed based on the request message format 14112c8a661SSridevi Ramesh defined for the command type as per the spec. 14212c8a661SSridevi Ramesh``` 14312c8a661SSridevi Ramesh 14412c8a661SSridevi Ramesh**pldmtool response message format:** 14512c8a661SSridevi Ramesh 146*e3596384SManojkiran Eda```txt 14712c8a661SSridevi Ramesh<instanceId> <hdrVersion> <pldmType> <cmdType> <completionCode> <payloadResp> 14812c8a661SSridevi Ramesh 14912c8a661SSridevi RameshpayloadResp - stream of bytes displayed based on the response message format 15012c8a661SSridevi Ramesh defined for the command type as per the spec. 15112c8a661SSridevi Ramesh``` 1523618064eSPatrick Williams 15312c8a661SSridevi RameshExample: 15412c8a661SSridevi Ramesh 155*e3596384SManojkiran Eda```bash 15612c8a661SSridevi Ramesh$ pldmtool raw -d 0x80 0x00 0x04 0x00 0x00 15712c8a661SSridevi Ramesh 15812c8a661SSridevi RameshRequest Message: 15912c8a661SSridevi Ramesh08 01 80 00 04 00 00 16012c8a661SSridevi RameshResponse Message: 16112c8a661SSridevi Ramesh08 01 00 00 04 00 1d 00 00 00 00 00 00 80 16212c8a661SSridevi Ramesh 16312c8a661SSridevi Ramesh``` 1643618064eSPatrick Williams 16512c8a661SSridevi Ramesh## pldmtool output format 16612c8a661SSridevi Ramesh 16712c8a661SSridevi RameshIn the current pldmtool implementation response message from pldmtool is parsed 16812c8a661SSridevi Rameshand displayed in the JSON format. 16912c8a661SSridevi Ramesh 17012c8a661SSridevi RameshExample: 1713618064eSPatrick Williams 172*e3596384SManojkiran Eda```bash 17312c8a661SSridevi Ramesh$ pldmtool base GetPLDMTypes 17412c8a661SSridevi Ramesh[ 17512c8a661SSridevi Ramesh { 17612c8a661SSridevi Ramesh "PLDM Type": "base", 17712c8a661SSridevi Ramesh "PLDM Type Code": 0 17812c8a661SSridevi Ramesh }, 17912c8a661SSridevi Ramesh { 18012c8a661SSridevi Ramesh "PLDM Type": "platform", 18112c8a661SSridevi Ramesh "PLDM Type Code": 2 18212c8a661SSridevi Ramesh }, 18312c8a661SSridevi Ramesh { 18412c8a661SSridevi Ramesh "PLDM Type": "bios", 18512c8a661SSridevi Ramesh "PLDM Type Code": 3 18612c8a661SSridevi Ramesh }, 18712c8a661SSridevi Ramesh { 18812c8a661SSridevi Ramesh "PLDM Type": "fru", 18912c8a661SSridevi Ramesh "PLDM Type Code": 4 19012c8a661SSridevi Ramesh }, 19112c8a661SSridevi Ramesh { 19212c8a661SSridevi Ramesh "PLDM Type": "oem-ibm", 19312c8a661SSridevi Ramesh "PLDM Type Code": 63 19412c8a661SSridevi Ramesh } 19512c8a661SSridevi Ramesh] 19612c8a661SSridevi Ramesh``` 1973618064eSPatrick Williams 1984cc1f7cfSPavithra Barithaya## Understanding pldmtool output error scenario 1994cc1f7cfSPavithra Barithaya 2004cc1f7cfSPavithra BarithayaWhen the pldmtool receives the wrong response for the request sent it errors out 2014cc1f7cfSPavithra Barithayawith a response code and completion code. The completion code represents the 202*e3596384SManojkiran Edatype of error and is defined in every pldm type `pldm_\<type\>_completion_codes` 2034cc1f7cfSPavithra Barithayaenum values. 2044cc1f7cfSPavithra Barithaya 2054cc1f7cfSPavithra BarithayaExample: 2064cc1f7cfSPavithra Barithaya 2074cc1f7cfSPavithra BarithayaThis is a platform command and the completion code can be understood from 2084cc1f7cfSPavithra Barithaya[`libpldm/platform.h`](https://github.com/openbmc/libpldm/blob/a98814fc37a5d59207163cb2fa81f4162eaf69cd/include/libpldm/platform.h#L204) 2094cc1f7cfSPavithra Barithayafile. 2104cc1f7cfSPavithra Barithaya 211*e3596384SManojkiran Eda```bash 2124cc1f7cfSPavithra Barithaya$ pldmtool platform getpdr -d 17 2134cc1f7cfSPavithra BarithayaResponse Message Error: rc=0 , cc=130 2144cc1f7cfSPavithra Barithaya``` 2154cc1f7cfSPavithra Barithaya 21612c8a661SSridevi Ramesh## pldmtool with mctp_eid option 21712c8a661SSridevi Ramesh 21812c8a661SSridevi RameshUse **-m** or **--mctp_eid** option to send pldm request message to remote mctp 21912c8a661SSridevi Rameshend point and by default pldmtool consider mctp_eid value as **'08'**. 22012c8a661SSridevi Ramesh 221*e3596384SManojkiran Eda```bash 222*e3596384SManojkiran Eda# Command format: 22312c8a661SSridevi Rameshpldmtool <pldmType> <cmdType> -m <mctpId> 224*e3596384SManojkiran Eda 225*e3596384SManojkiran Eda# pldmtool raw command format 22612c8a661SSridevi Rameshpldmtool raw -d 0x80 <pldmType> <cmdType> <payloadReq> -m <mctpId> 22712c8a661SSridevi Ramesh``` 22812c8a661SSridevi Ramesh 22912c8a661SSridevi RameshExample: 2303618064eSPatrick Williams 231*e3596384SManojkiran Eda```bash 232*e3596384SManojkiran Eda# Get PLDM Types 233*e3596384SManojkiran Edapldmtool base GetPLDMTypes -m 8 23412c8a661SSridevi Ramesh 235*e3596384SManojkiran Eda# pldmtool raw command 236*e3596384SManojkiran Edapldmtool raw -d 0x80 0x00 0x04 0x00 0x00 -m 0x08 23712c8a661SSridevi Ramesh 23812c8a661SSridevi Ramesh``` 23912c8a661SSridevi Ramesh 24012c8a661SSridevi Ramesh## pldmtool verbosity 24112c8a661SSridevi Ramesh 24212c8a661SSridevi RameshBy default verbose flag is disabled on the pldmtool. 24312c8a661SSridevi Ramesh 24412c8a661SSridevi RameshEnable verbosity with **-v** flag as shown below. 24512c8a661SSridevi Ramesh 24612c8a661SSridevi RameshExample: 24712c8a661SSridevi Ramesh 248*e3596384SManojkiran Eda```bash 24912c8a661SSridevi Rameshpldmtool base GetPLDMTypes -v 25012c8a661SSridevi Ramesh``` 251