[Skiboot] [PATCH V3 05/21] core/pldm: Encode GetTID response

Christophe Lombard clombard at linux.vnet.ibm.com
Sat Mar 19 01:36:03 AEDT 2022


A PLDM Terminus is defined as the point of communication termination for
PLDM messages and the PLDM functions associated with those messages.
Given a PLDM terminus, a mechanism is required that can uniquely identify
each terminus so that the semantic information can be bound to that
identification.
The Terminus ID (TID) is a value that identifies a PLDM terminus.
TIDs are used in PLDM messages when it is necessary to identify the PLDM
terminus that is the source of the PLDM Message.

The GetTID command is used to retrieve the present Terminus ID (TID)
setting for a PLDM Terminus.

Reviewed-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>
Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
---
 core/pldm/pldm-responder.c | 39 ++++++++++++++++++++++++++++++++++++++
 core/pldm/pldm.h           |  1 +
 2 files changed, 40 insertions(+)

diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c
index c1aad7c9..834b8ebf 100644
--- a/core/pldm/pldm-responder.c
+++ b/core/pldm/pldm-responder.c
@@ -78,6 +78,17 @@ static void pldm_add_type(struct pldm_type *new_type)
 	      new_type->name, new_type->pldm_type_id);
 }
 
+static void pldm_add_cmd(struct pldm_type *type, struct pldm_cmd *new_cmd)
+{
+	assert(new_cmd->pldm_cmd_id < 256); /* limited by GetPLDMCommands */
+	assert(new_cmd->handler);
+	assert(!find_cmd(type, new_cmd->pldm_cmd_id));
+
+	list_add_tail(&type->commands, &new_cmd->link);
+	prlog(PR_DEBUG, "Registered command %s (%d) under %s\n",
+		new_cmd->name, new_cmd->pldm_cmd_id, type->name);
+}
+
 /*
  * PLDM Base commands support
  */
@@ -88,6 +99,32 @@ static struct pldm_type pldm_base_type = {
 	.version = { 0xF1, 0xF0, 0xF0, 0x00 },
 };
 
+/*
+ * GetTID command (0x02)
+ * The GetTID command is used to retrieve the present Terminus ID (TID)
+ * setting for a PLDM Terminus.
+ */
+static int get_tid_handler(const struct pldm_rx_data *req)
+{
+	char resp_buf[PKT_SIZE(struct pldm_get_tid_resp)];
+
+	memset(resp_buf, 0, sizeof(resp_buf));
+
+	encode_get_tid_resp(req->hdrinf.instance,
+			    PLDM_SUCCESS,
+			    HOST_TID,
+			    (void *) resp_buf);
+
+	pldm_send(req->source_eid, resp_buf, sizeof(resp_buf));
+
+	return OPAL_SUCCESS;
+}
+static struct pldm_cmd base_get_tid = {
+	.name = "GetTid",
+	.pldm_cmd_id = PLDM_GET_TID,
+	.handler = get_tid_handler,
+};
+
 int pldm_rx_handle_request(struct pldm_rx_data *rx)
 {
 	const struct pldm_type *t;
@@ -113,5 +150,7 @@ int pldm_mctp_responder_init(void)
 	/* Register mandatory commands we'll respond to - DSP0240 */
 	pldm_add_type(&pldm_base_type);
 
+	pldm_add_cmd(&pldm_base_type, &base_get_tid);
+
 	return OPAL_SUCCESS;
 }
diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h
index 52469a0f..21b03463 100644
--- a/core/pldm/pldm.h
+++ b/core/pldm/pldm.h
@@ -17,6 +17,7 @@ void printbuf(const char *name, const char *msg, int len);
  * BMC EID default = 8.
  */
 # define BMC_EID  8
+# define HOST_TID 9
 
 #define PKT_SIZE(x) (sizeof(struct pldm_msg_hdr) + sizeof(x))
 
-- 
2.35.1



More information about the Skiboot mailing list