openbmc / libpldm

Apache License 2.0
6 stars 9 forks source link

Define new set of completion codes for libpldm APIs #6

Open arun-pm opened 1 year ago

arun-pm commented 1 year ago

libpldm uses PLDM spec defined completion codes as return codes for encode/decode APIs. Eg:- https://github.com/openbmc/libpldm/blob/main/src/firmware_update.c#L622

if (PLDM_SUCCESS != resp_data->completion_code) {
    return PLDM_SUCCESS;
}

Which are confusing.

Proposal: Define a new set of return codes as below

enum encode_decode_rc {
    ENCODE_SUCCESS = 0xF0,
    ENCODE_FAILURE = 0xF1,
    DECODE_SUCCESS = 0xF2,
    DECODE_FAILURE = 0xF3
};

Reference to previous discussions: https://github.com/openbmc/openbmc/wiki/OpenBMC-PMCI-WG#minutes-82420 https://gerrit.openbmc.org/c/openbmc/pldm/+/51443/comments/e7ed8335_4e144ce0

amboar commented 1 year ago

Sorry, but I don't think that's what we want at all. Rather, the problem is that the libpldm APIs are conflating errors that it must signal via its APIs with errors defined by the protocol specifications. These are distinct problems and need to be treated as such. For instance, there's no need for a concept of signalling a failure to allocate dynamic memory at the protocol level, but this is something that's likely necessary for the library.

libpldm should not be constrained to returning errors defined in the protocol types through its APIs. We lift that constraint by defining a set of libpldm-specific error codes to return from its APIs that are distinct from the PLDM protocol error codes.