commit | 16cd52327217fcaea2e4a26895c5bbf25ccfddf9 | [log] [tgz] |
---|---|---|
author | Thu Nguyen <thu@os.amperecomputing.com> | Wed Aug 23 06:47:19 2023 +0700 |
committer | Thu Nguyen <thu@os.amperecomputing.com> | Wed Aug 23 07:41:50 2023 +0700 |
tree | 8e6ce9832ed5ccb8c6c3897a7cd347fb0c5c6147 | |
parent | f37e4dc8092d2b979f4f77c3ce32237ceb7ad7f2 [diff] |
transport: Match specified metadata in pldm_transport_send_recv_msg() The mctp-demux broadcasts the PLDM RX response messages to all of mctp socket instances. That means the GetSensorReading response from one instance (pldmd) can be received by the other instance (pldmtool) which is waiting for the response of GetPDR request message. When the gap time between the two requests of pldmtool is long enough the number of GetSensorReading response messages can be more than 32. That means the instance ID of new GetPDR command in pldmtool can equal with the used and free one in GetSensorReading. So the `pldm_transport_send_recv_msg()` will match the response of GetSensorReading with the response of GetPDR. So only comparing the instance ID in `pldm_transport_send_recv_msg` is not enough. Section "Requirements for requesters" in DSP0240 version 1.1.0, "A PLDM terminus that issues PLDM requests should be prepared to handle the order of responses that may not match the order in which the requests were sent (that is, it should not automatically assume that a response that it receives is in the order in which the request was sent). It should check to see that the PLDM Type, PLDM Command Code, and Instance ID values in the response match up with a corresponding outstanding command before acting on any parameters returned in the response." Add the PLDM type and command code on matching the response of `pldm_transport_send_recv_msg()`. Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com> Change-Id: I7284bd4ecd8be3786fa078af1eb3f06046e4baa3
This is a library which deals with the encoding and decoding of PLDM messages. It should be possible to use this library by projects other than OpenBMC, and hence certain constraints apply to it:
Source files are named according to the PLDM Type, for eg base.[h/c], fru.[h/c], etc.
Given a PLDM command "foo", the library will provide the following API: For the Requester function:
encode_foo_req() - encode a foo request decode_foo_resp() - decode a response to foo
For the Responder function:
decode_foo_req() - decode a foo request encode_foo_resp() - encode a response to foo
The library also provides API to pack and unpack PLDM headers.
Need meson
and ninja
. Alternatively, source an OpenBMC ARM/x86 SDK.
meson setup builddir && ninja -C builddir
The simplest way of running the tests is as described by the meson man page:
meson setup builddir && meson test -C builddir
libpldm
The ABIs (symbols, generally functions) exposed by the library are separated into three categories:
Applications depending on libpldm
should aim to only use functions from the stable category. However, this may not always be possible. What to do when required functions fall into the deprecated or testing categories is outlined below.
--- title: libpldm symbol lifecycle --- stateDiagram-v2 direction LR [*] --> Testing: Add Testing --> Testing: Change Testing --> [*]: Remove Testing --> Stable: Stabilise Stable --> Deprecated: Deprecate Deprecated --> [*]: Remove
The ABI of the library produced by the build is controlled using the abi
meson option. The following use cases determine how the abi
option should be specified:
Use Case | Meson Configuration |
---|---|
Production | -Dabi=deprecated,stable |
Maintenance | -Dabi=stable |
Development | -Dabi=deprecated,stable,testing |
Applications and libraries that depend on libpldm
can identify how to migrate off of deprecated APIs by constraining the library ABI to the stable category. This will force the compiler identify any call-sites that try to link against deprecated symbols.
Applications and libraries often require functionality that doesn't yet exist in libpldm
. The work is thus in two parts:
libpldm
libpldm
in the dependent application or libraryAdding APIs to a library is a difficult task. Generally, once an API is exposed in the library's ABI, any changes to the API risk breaking applications already making use of it. To make sure we have more than one shot at getting an API right, all new APIs must first be exposed in the testing category. Concretely:
Patches adding new APIs MUST mark them as testing and MUST NOT mark them as stable.
Three macros are provided through config.h
(automatically included for all translation units) to mark functions as testing, stable or deprecated:
LIBPLDM_ABI_TESTING
LIBPLDM_ABI_STABLE
LIBPLDM_ABI_DEPRECATED
These annotations go immediately before your function signature:
LIBPLDM_ABI_TESTING pldm_requester_rc_t pldm_transport_send_msg(struct pldm_transport *transport, pldm_tid_t tid, const void *pldm_req_msg, size_t req_msg_len) { ... }
As mentioned above, all new functions must first be added in the testing category (using the LIBPLDM_ABI_TESTING
annotation).
To move a function from the testing category to the stable category, its required that patches demonstrating use of the function in a dependent application or library be linked in the commit message of the stabilisation change. We require this to demonstrate that the implementer has considered its use in context before preventing us from making changes to the API.
Meson is broadly used in the OpenBMC ecosystem, the historical home of libpldm
. Meson's subprojects are a relatively painless way of managing dependencies for the purpose of developing complex applications and libraries. Use of libpldm
as a subproject is both supported and encouraged.
libpldm
's ABI can be controlled from a parent project through meson's subproject configuration syntax:
$ meson setup ... -Dlibpldm:abi=deprecated,stable,testing ...
This will support OEM or vendor-specific functions and semantic information. Following directory structure has to be used:
libpldm |---- include/libpldm | |---- oem/<oem_name>/libpldm | |----<oem based .h files> |---- src | |---- oem/<oem_name> | |----<oem based .c files> |---- tests | |---- oem/<oem_name> | |----<oem based test files>
<oem_name> - This folder must be created with the name of the OEM/vendor in lower case.
Header files & source files having the oem functionality for the libpldm library should be placed under the respective folder hierarchy as mentioned in the above figure. They must be adhering to the rules mentioned under the libpldm section above.
Once the above is done a meson option has to be created in meson.options
with its mapped compiler flag to enable conditional compilation.
For consistency would recommend using "oem-<oem_name>".
The meson.build
and the corresponding source file(s) will need to incorporate the logic of adding its mapped compiler flag to allow conditional compilation of the code.
The pldm requester API's are present in src/requester
folder and they are intended to provide API's to interact with the desired underlying transport layer to send/receive pldm messages.
NOTE : In the current state, the requester API's in the repository only works with specific transport mechanism & these are going to change in future & probably aren't appropriate to be writing code against.