dsp: base: add encode_pldm_header_only_errno()
Currently, `encode_pldm_header_only()` returns PLDM Completion Code,
which is deprecated, but most of this API's use case were internally
inside libpldm itself, therefore, add `encode_pldm_header_only_errno()`
as an internal API.
Change-Id: I87822a4f6afe8aa8eb87034179c37341d7ca4190
Signed-off-by: Unive Tien <unive.tien.wiwynn@gmail.com>
diff --git a/src/dsp/base.c b/src/dsp/base.c
index 67c4e68..f33b9b2 100644
--- a/src/dsp/base.c
+++ b/src/dsp/base.c
@@ -579,13 +579,12 @@
return PLDM_SUCCESS;
}
-LIBPLDM_ABI_STABLE
-int encode_pldm_header_only(uint8_t msg_type, uint8_t instance_id,
- uint8_t pldm_type, uint8_t command,
- struct pldm_msg *msg)
+int encode_pldm_header_only_errno(uint8_t msg_type, uint8_t instance_id,
+ uint8_t pldm_type, uint8_t command,
+ struct pldm_msg *msg)
{
if (msg == NULL) {
- return PLDM_ERROR_INVALID_DATA;
+ return -EINVAL;
}
struct pldm_header_info header = { 0 };
@@ -593,5 +592,18 @@
header.instance = instance_id;
header.pldm_type = pldm_type;
header.command = command;
- return pack_pldm_header(&header, &(msg->hdr));
+ return pack_pldm_header_errno(&header, &(msg->hdr));
+}
+
+LIBPLDM_ABI_STABLE
+int encode_pldm_header_only(uint8_t msg_type, uint8_t instance_id,
+ uint8_t pldm_type, uint8_t command,
+ struct pldm_msg *msg)
+{
+ int rc = encode_pldm_header_only_errno(msg_type, instance_id, pldm_type,
+ command, msg);
+ if (rc) {
+ return pldm_xlate_errno(rc);
+ }
+ return PLDM_SUCCESS;
}
diff --git a/src/dsp/base.h b/src/dsp/base.h
index 1124b00..babdae0 100644
--- a/src/dsp/base.h
+++ b/src/dsp/base.h
@@ -13,6 +13,10 @@
int unpack_pldm_header_errno(const struct pldm_msg_hdr *msg,
struct pldm_header_info *hdr);
+int encode_pldm_header_only_errno(uint8_t msg_type, uint8_t instance_id,
+ uint8_t pldm_type, uint8_t command,
+ struct pldm_msg *msg);
+
LIBPLDM_CC_ALWAYS_INLINE
int pldm_msg_has_error(const struct pldm_msg *msg, size_t payload_length)
{