xref: /openbmc/pldm/pldmtool/README.md (revision 4cc1f7cf)
1## Overview of pldmtool
2
3pldmtool is a client tool that acts as a PLDM requester which runs on the BMC.
4pldmtool sends the request message and displays the response message also
5provides flexibility to parse the response message and display it in readable
6format.
7
8pldmtool supports the subcommands for PLDM types such as base, platform, bios,
9fru, and oem-ibm.
10
11- Source files are implemented in C++.
12- Consumes pldm/libpldm encode and decode functions.
13- Communicates with pldmd daemon running on BMC.
14- Enables writing functional test cases for PLDM stack.
15
16please refer the DMTF PLDM specifications with respect to the pldm types.
17https://www.dmtf.org/
18
19## Code organization
20
21Source files in pldmtool repository are named with respect to the PLDM type.
22
23Example:
24
25```
26pldm_base_cmd.[hpp/cpp], pldm_fru_cmd.[hpp/cpp]
27```
28
29pldmtool commands for corresponding PLDM type is constructed with the help of
30encode request and decode response APIs which are implemented in pldm/libpldm.
31
32Example:
33
34Given a PLDM command "foo" of PLDM type "base" the pldmtool should consume
35following API from the libpldm.
36
37```
38- encode_foo_req()  - Send the required input parameters in the request message.
39- decode_foo_resp() - Decode the response message.
40```
41
42If PLDM commands are not yet supported in the pldmtool repository user can
43directly send the request message with the help of **pldmtool raw -d <data>**
44option.
45
46## Usage
47
48User can see the pldmtool supported PLDM types in the usage output available
49with the **-h** help option as shown below:
50
51```
52pldmtool -h
53PLDM requester tool for OpenBMC
54Usage: pldmtool [OPTIONS] SUBCOMMAND
55
56Options:
57  -h,--help                   Print this help message and exit
58
59Subcommands:
60  raw                         send a raw request and print response
61  base                        base type command
62  bios                        bios type command
63  platform                    platform type command
64  fru                         FRU type command
65  oem-ibm                     oem type command
66
67```
68
69pldmtool command prompt expects a PLDM type to display the list of supported
70commands that are already implemented for that particular PLDM type.
71
72```
73Command format: pldmtool <pldmType> -h
74```
75
76Example:
77
78```
79$ pldmtool base -h
80
81base type command
82Usage: pldmtool base [OPTIONS] SUBCOMMAND
83
84Options:
85  -h,--help                   Print this help message and exit
86
87Subcommands:
88  GetPLDMTypes                get pldm supported types
89  GetPLDMVersion              get version of a certain type
90  GetTID                      get Terminus ID (TID)
91  GetPLDMCommands             get supported commands of pldm type
92
93```
94
95More help on the command usage can be found by specifying the PLDM type and the
96command name with **-h** argument as shown below.
97
98```
99Command format: pldmtool <pldmType> <commandName> -h
100```
101
102Example:
103
104```
105$ pldmtool base GetPLDMTypes -h
106
107get pldm supported types
108Usage: pldmtool base GetPLDMTypes [OPTIONS]
109
110Options:
111  -h,--help                   Print this help message and exit
112  -m,--mctp_eid UINT          MCTP endpoint ID
113  -v,--verbose
114```
115
116## pldmtool raw command usage
117
118pldmtool raw command option accepts request message in the hexadecimal bytes and
119send the response message in hexadecimal bytes.
120
121```
122$ pldmtool raw -h
123send a raw request and print response
124Usage: pldmtool raw [OPTIONS]
125
126Options:
127  -h,--help                   Print this help message and exit
128  -m,--mctp_eid UINT          MCTP endpoint ID
129  -v,--verbose
130  -d,--data UINT              REQUIRED raw data
131```
132
133**pldmtool request message format:**
134
135```
136pldmtool raw --data 0x80 <pldmType> <cmdType> <payloadReq>
137
138payloadReq - stream of bytes constructed based on the request message format
139             defined for the command type as per the spec.
140```
141
142**pldmtool response message format:**
143
144```
145<instanceId> <hdrVersion> <pldmType> <cmdType> <completionCode> <payloadResp>
146
147payloadResp - stream of bytes displayed based on the response message format
148              defined for the command type as per the spec.
149```
150
151Example:
152
153```
154$ pldmtool raw -d 0x80 0x00 0x04 0x00 0x00
155
156Request Message:
15708 01 80 00 04 00 00
158Response Message:
15908 01 00 00 04 00 1d 00 00 00 00 00 00 80
160
161```
162
163## pldmtool output format
164
165In the current pldmtool implementation response message from pldmtool is parsed
166and displayed in the JSON format.
167
168Example:
169
170```
171$ pldmtool base GetPLDMTypes
172[
173    {
174        "PLDM Type": "base",
175        "PLDM Type Code": 0
176    },
177    {
178        "PLDM Type": "platform",
179        "PLDM Type Code": 2
180    },
181    {
182        "PLDM Type": "bios",
183        "PLDM Type Code": 3
184    },
185    {
186        "PLDM Type": "fru",
187        "PLDM Type Code": 4
188    },
189    {
190        "PLDM Type": "oem-ibm",
191        "PLDM Type Code": 63
192    }
193]
194```
195
196## Understanding pldmtool output error scenario
197
198When the pldmtool receives the wrong response for the request sent it errors out
199with a response code and completion code. The completion code represents the
200type of error and is defined in every pldm type `pldm_<type>_completion_codes`
201enum values.
202
203Example:
204
205This is a platform command and the completion code can be understood from
206[`libpldm/platform.h`](https://github.com/openbmc/libpldm/blob/a98814fc37a5d59207163cb2fa81f4162eaf69cd/include/libpldm/platform.h#L204)
207file.
208
209```
210$ pldmtool platform getpdr -d 17
211Response Message Error: rc=0 , cc=130
212```
213
214## pldmtool with mctp_eid option
215
216Use **-m** or **--mctp_eid** option to send pldm request message to remote mctp
217end point and by default pldmtool consider mctp_eid value as **'08'**.
218
219```
220Command format:
221
222pldmtool <pldmType> <cmdType> -m <mctpId>
223pldmtool raw -d 0x80 <pldmType> <cmdType> <payloadReq> -m <mctpId>
224```
225
226Example:
227
228```
229$ pldmtool base GetPLDMTypes -m 8
230
231$ pldmtool raw -d 0x80 0x00 0x04 0x00 0x00 -m 0x08
232
233```
234
235## pldmtool verbosity
236
237By default verbose flag is disabled on the pldmtool.
238
239Enable verbosity with **-v** flag as shown below.
240
241Example:
242
243```
244pldmtool base GetPLDMTypes -v
245```
246