xref: /openbmc/pldm/pldmtool/README.md (revision 8dd6fa1b)
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
20## Code organization
21
22Source files in pldmtool repository are named with respect to the PLDM type.
23
24Example:
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>** option.
44
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```
68pldmtool command prompt expects a PLDM type to display the list of supported
69commands that are already implemented for that particular PLDM type.
70
71```
72Command format: pldmtool <pldmType> -h
73```
74Example:
75
76```
77$ pldmtool base -h
78
79base type command
80Usage: pldmtool base [OPTIONS] SUBCOMMAND
81
82Options:
83  -h,--help                   Print this help message and exit
84
85Subcommands:
86  GetPLDMTypes                get pldm supported types
87  GetPLDMVersion              get version of a certain type
88  GetTID                      get Terminus ID (TID)
89  GetPLDMCommands             get supported commands of pldm type
90
91```
92More help on the command usage can be found by specifying the PLDM type and the
93command name with **-h** argument as shown below.
94
95```
96Command format: pldmtool <pldmType> <commandName> -h
97```
98
99Example:
100```
101$ pldmtool base GetPLDMTypes -h
102
103get pldm supported types
104Usage: pldmtool base GetPLDMTypes [OPTIONS]
105
106Options:
107  -h,--help                   Print this help message and exit
108  -m,--mctp_eid UINT          MCTP endpoint ID
109  -v,--verbose
110```
111
112
113## pldmtool raw command usage
114
115pldmtool raw command option accepts request message in the hexadecimal
116bytes and send the response message in hexadecimal bytes.
117
118```
119$ pldmtool raw -h
120send a raw request and print response
121Usage: pldmtool raw [OPTIONS]
122
123Options:
124  -h,--help                   Print this help message and exit
125  -m,--mctp_eid UINT          MCTP endpoint ID
126  -v,--verbose
127  -d,--data UINT              REQUIRED raw data
128```
129
130**pldmtool request message format:**
131
132```
133pldmtool raw --data 0x80 <pldmType> <cmdType> <payloadReq>
134
135payloadReq - stream of bytes constructed based on the request message format
136             defined for the command type as per the spec.
137```
138
139**pldmtool response message format:**
140
141```
142<instanceId> <hdrVersion> <pldmType> <cmdType> <completionCode> <payloadResp>
143
144payloadResp - stream of bytes displayed based on the response message format
145              defined for the command type as per the spec.
146```
147Example:
148
149```
150$ pldmtool raw -d 0x80 0x00 0x04 0x00 0x00
151
152Request Message:
15308 01 80 00 04 00 00
154Response Message:
15508 01 00 00 04 00 1d 00 00 00 00 00 00 80
156
157```
158## pldmtool output format
159
160In the current pldmtool implementation response message from pldmtool is parsed
161and displayed in the JSON format.
162
163Example:
164```
165$ pldmtool base GetPLDMTypes
166[
167    {
168        "PLDM Type": "base",
169        "PLDM Type Code": 0
170    },
171    {
172        "PLDM Type": "platform",
173        "PLDM Type Code": 2
174    },
175    {
176        "PLDM Type": "bios",
177        "PLDM Type Code": 3
178    },
179    {
180        "PLDM Type": "fru",
181        "PLDM Type Code": 4
182    },
183    {
184        "PLDM Type": "oem-ibm",
185        "PLDM Type Code": 63
186    }
187]
188```
189## pldmtool with mctp_eid option
190
191Use **-m** or **--mctp_eid** option to send pldm request message to remote mctp
192end point and by default pldmtool consider mctp_eid value as **'08'**.
193
194```
195Command format:
196
197pldmtool <pldmType> <cmdType> -m <mctpId>
198pldmtool raw -d 0x80 <pldmType> <cmdType> <payloadReq> -m <mctpId>
199```
200
201Example:
202```
203$ pldmtool base GetPLDMTypes -m 8
204
205$ pldmtool raw -d 0x80 0x00 0x04 0x00 0x00 -m 0x08
206
207```
208
209## pldmtool verbosity
210
211By default verbose flag is disabled on the pldmtool.
212
213Enable verbosity with **-v** flag as shown below.
214
215Example:
216
217```
218pldmtool base GetPLDMTypes -v
219```
220