xref: /openbmc/pldm/pldmtool/README.md (revision c453e164)
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## pldmtool with mctp_eid option
197
198Use **-m** or **--mctp_eid** option to send pldm request message to remote mctp
199end point and by default pldmtool consider mctp_eid value as **'08'**.
200
201```
202Command format:
203
204pldmtool <pldmType> <cmdType> -m <mctpId>
205pldmtool raw -d 0x80 <pldmType> <cmdType> <payloadReq> -m <mctpId>
206```
207
208Example:
209
210```
211$ pldmtool base GetPLDMTypes -m 8
212
213$ pldmtool raw -d 0x80 0x00 0x04 0x00 0x00 -m 0x08
214
215```
216
217## pldmtool verbosity
218
219By default verbose flag is disabled on the pldmtool.
220
221Enable verbosity with **-v** flag as shown below.
222
223Example:
224
225```
226pldmtool base GetPLDMTypes -v
227```
228