base: return valid completion code
According to the PLDM base specification, completion code `0x21`
corresponds to `PLDM_ERROR_INVALID_TRANSFER_CONTEXT`. However, the
current implementation in `libpldm` incorrectly maps `0x21` to
`PLDM_INVALID_TRANSFER_OPERATION_FLAG`, which is not aligned with the
specification.
To maintain consistency with the standard, we should instead use
`PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION` (`0x23`) to represent
this error condition more accurately. However, since
`PLDM_INVALID_TRANSFER_OPERATION_FLAG` is currently in use by `libpldm`
clients (such as `pldm`), removing it immediately would introduce
compatibility issues. Therefore, we will first migrate client code to
use `PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION` (`0x23`) before
removing the incorrect definition from `libpldm`.
Change-Id: I7e2130c1f132dc6c8b426dd373b4a8a73507ac22
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 834ec9a..c43c4d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,12 @@
`PLDM_INVALID_TRANSFER_OPERATION_FLAG` in `encode_pass_component_table_req()`
command.
+- base: Return valid completion code from `decode_multipart_receive_req()`
+
+ As per the base specification `PLDM_INVALID_TRANSFER_OPERATION_FLAG` (`0x21`)
+ is inaccurate. Reduce the usage of it by returning
+ `PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION` (code 0x23) instead.
+
### Deprecated
- utils: Deprecate `is_time_legal()`
diff --git a/src/dsp/base.c b/src/dsp/base.c
index 1b16381..c3a5ed9 100644
--- a/src/dsp/base.c
+++ b/src/dsp/base.c
@@ -552,7 +552,7 @@
// Any enum value above PLDM_XFER_CURRENT_PART is invalid.
if (request->transfer_opflag > PLDM_XFER_CURRENT_PART) {
- return PLDM_INVALID_TRANSFER_OPERATION_FLAG;
+ return PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION;
}
// A section offset of 0 is only valid on FIRST_PART or COMPLETE Xfers.
diff --git a/tests/dsp/base.cpp b/tests/dsp/base.cpp
index 25536ec..c544766 100644
--- a/tests/dsp/base.cpp
+++ b/tests/dsp/base.cpp
@@ -686,7 +686,7 @@
&pldm_type, &flag, &transfer_ctx,
&transfer_handle, §ion_offset,
§ion_length),
- PLDM_INVALID_TRANSFER_OPERATION_FLAG);
+ PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION);
}
TEST(MultipartReceive, testDecodeRequestFailBadOffset)