xref: /openbmc/libpldm/README.md (revision 5a706073)
1# libpldm
2
3This is a library which deals with the encoding and decoding of PLDM messages.
4It should be possible to use this library by projects other than OpenBMC, and
5hence certain constraints apply to it:
6
7- keeping it light weight
8- implementation in C
9- minimal dynamic memory allocations
10- endian-safe
11- no OpenBMC specific dependencies
12
13Source files are named according to the PLDM Type, for eg base.[h/c], fru.[h/c],
14etc.
15
16Given a PLDM command "foo", the library will provide the following API: For the
17Requester function:
18
19```c
20encode_foo_req() - encode a foo request
21decode_foo_resp() - decode a response to foo
22```
23
24For the Responder function:
25
26```c
27decode_foo_req() - decode a foo request
28encode_foo_resp() - encode a response to foo
29```
30
31The library also provides API to pack and unpack PLDM headers.
32
33## To Build
34
35Need `meson` and `ninja`. Alternatively, source an OpenBMC ARM/x86 SDK.
36
37```sh
38meson setup builddir && ninja -C builddir
39```
40
41## To run unit tests
42
43The simplest way of running the tests is as described by the meson man page:
44
45```sh
46meson setup builddir && meson test -C builddir
47```
48
49## OEM/vendor-specific functions
50
51This will support OEM or vendor-specific functions and semantic information.
52Following directory structure has to be used:
53
54```text
55 libpldm
56    |---- include/libpldm
57    |        |---- oem/<oem_name>/libpldm
58    |                    |----<oem based .h files>
59    |---- src
60    |        |---- oem/<oem_name>
61    |                    |----<oem based .c files>
62    |---- tests
63    |        |---- oem/<oem_name>
64    |                    |----<oem based test files>
65
66```
67
68<oem_name> - This folder must be created with the name of the OEM/vendor in
69lower case.
70
71Header files & source files having the oem functionality for the libpldm library
72should be placed under the respective folder hierarchy as mentioned in the above
73figure. They must be adhering to the rules mentioned under the libpldm section
74above.
75
76Once the above is done a meson option has to be created in
77`libpldm/meson_options.txt` with its mapped compiler flag to enable conditional
78compilation.
79
80For consistency would recommend using "oem-<oem_name>".
81
82The `libpldm/meson.build` and the corresponding source file(s) will need to
83incorporate the logic of adding its mapped compiler flag to allow conditional
84compilation of the code.
85
86## Requester APIs
87
88The pldm requester API's are present in `src/requester` folder and they are
89intended to provide API's to interact with the desired underlying transport
90layer to send/receive pldm messages.
91
92**NOTE** : In the current state, the requester API's in the repository only
93works with [specific transport mechanism](https://github.com/openbmc/libmctp) &
94these are going to change in future & probably aren't appropriate to be writing
95code against.
96