diff mbox series

core/pldm: Fix pdr handle to add first pdr request

Message ID 20240614072013.18125-1-abhishek@linux.ibm.com
State Accepted
Headers show
Series core/pldm: Fix pdr handle to add first pdr request | expand

Commit Message

Abhishek Singh Tomar June 14, 2024, 7:20 a.m. UTC
As per the specification:
To retrieve the first PDR record, use the
get_pdr_req function with handle 0.

On the BMC side, the first PDR is sent in
response, along with the next_record_hndl which
can be used to access consecutive PDR records.

However, it's important to note that the first
PDR may not necessarily have a handle of 1.

In the current scenario, providing a record_hndl
value of 0 to pldm_pdr_add() will always result
in the addition of a record to the repository
with a PDR handle of 1.

In current fix record handle is extracted from
pdr record data.

Signed-off-by: Abhishek Singh Tomar <abhishek@linux.ibm.com>
---
 core/pldm/pldm-platform-requests.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Reza Arbab Aug. 2, 2024, 6:22 p.m. UTC | #1
On Fri, Jun 14, 2024 at 12:50:13PM +0530, Abhishek Singh Tomar wrote:
>However, it's important to note that the first
>PDR may not necessarily have a handle of 1.
>
>In the current scenario, providing a record_hndl
>value of 0 to pldm_pdr_add() will always result
>in the addition of a record to the repository
>with a PDR handle of 1.
>
>In current fix record handle is extracted from
>pdr record data.

Looks good to me. Applied to master.
diff mbox series

Patch

diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c
index cb0ff9443..01eb12925 100644
--- a/core/pldm/pldm-platform-requests.c
+++ b/core/pldm/pldm-platform-requests.c
@@ -993,6 +993,7 @@  static void get_pdr_req_complete(struct pldm_rx_data *rx,
 	struct pldm_pdrs *pdrs = (struct pldm_pdrs *)data;
 	uint32_t record_hndl = pdrs->record_hndl;
 	struct get_pdr_response response;
+	struct pldm_pdr_hdr *pdr_hdr;
 	size_t payload_len;
 	int rc, i;
 
@@ -1065,6 +1066,8 @@  static void get_pdr_req_complete(struct pldm_rx_data *rx,
 	if (response.transfer_flag != PLDM_START_AND_END)
 		prlog(PR_ERR, "Transfert GetPDRResp not complete, transfer_flag: %d\n",
 			      response.transfer_flag);
+	pdr_hdr = (struct pldm_pdr_hdr *)response.record_data;
+	record_hndl = pdr_hdr->record_handle;
 
 	prlog(PR_DEBUG, "%s - record_hndl: %d, next_record_hndl: %d, resp_cnt: %d\n",
 			__func__, record_hndl,