xref: /openbmc/pldm/requester/README.md (revision e35963842386105a2ff1fed4d182d13a8405fdd0)
1*e3596384SManojkiran Eda# Overview
274f27c73STom Joseph
33618064eSPatrick WilliamsPLDM requester infrastructure enables the requester code in PLDM daemon to meet
43618064eSPatrick Williamsthe requirements of PLDM requesters. It provides the following features:
574f27c73STom Joseph
674f27c73STom Joseph- Register a PLDM request and the response handler to be invoked on receiving
774f27c73STom Joseph  the response.
874f27c73STom Joseph- The handling of the request and response is asynchronous. This means the PLDM
974f27c73STom Joseph  daemon is not blocked till the response is received for a request.
1074f27c73STom Joseph- Multiple outstanding requests are supported.
1174f27c73STom Joseph- Request retries based on the time-out waiting for a response.
1274f27c73STom Joseph- Instance ID expiration and marking the instance ID free after expiration.
1374f27c73STom Joseph
14*e3596384SManojkiran Eda## Future enhancements
1574f27c73STom Joseph
1674f27c73STom Joseph- A mechanism to queue multiple outstanding requests to the same responder.
1774f27c73STom Joseph- Handle ERROR_NOT_READY completion code and retry the PLDM request after 250ms
1874f27c73STom Joseph  interval.
1974f27c73STom Joseph
2074f27c73STom JosephThe requester code needs to use the `registerRequest` API to register the PLDM
2174f27c73STom Josephrequest. The destination endpoint ID, instance ID, PLDM type, PLDM command code,
2274f27c73STom JosephPLDM request message (PLDM header and payload) and response function handler are
2374f27c73STom Josephpassed as parameters to the registerRequest API.
2474f27c73STom Joseph
25*e3596384SManojkiran Eda```c++
2674f27c73STom Joseph    int registerRequest(mctp_eid_t eid, uint8_t instanceId, uint8_t type,
2774f27c73STom Joseph                        uint8_t command, pldm::Request&& requestMsg,
2874f27c73STom Joseph                        ResponseHandler&& responseHandler)
2974f27c73STom Joseph```
3074f27c73STom Joseph
3174f27c73STom JosephThe signature of the response function handler:
323618064eSPatrick Williams
33*e3596384SManojkiran Eda```c++
3474f27c73STom Josephvoid handler(mctp_eid_t eid, const pldm_msg* response, size_t respMsgLen)
3574f27c73STom Joseph```
3674f27c73STom Joseph
3774f27c73STom Joseph- If the response is received before instance ID expiration:
3874f27c73STom Joseph  - If the response matches with an outstanding request then the response
3974f27c73STom Joseph    handler is invoked.
4074f27c73STom Joseph  - If the response does not match with the PLDM instance ID, PLDM type and PLDM
4174f27c73STom Joseph    command code of an outstanding request, then no action is taken on the
4274f27c73STom Joseph    response.
4374f27c73STom Joseph- Once the instance ID is expired, then the response handler is invoked with
4474f27c73STom Joseph  empty response, so that further action can be taken.
45