[Skiboot] [PATCH V4 06/21] core/pldm: Encode GetPLDMTypes response

Christophe Lombard clombard at linux.vnet.ibm.com
Thu Apr 14 23:43:49 AEST 2022


The GetPLDMTypes command can be used to discover the PLDM type capabilities
supported by a PLDM terminus and to get a list of the PLDM types that are
supported.

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 | 52 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c
index 3ac9126d..9e44efc8 100644
--- a/core/pldm/pldm-responder.c
+++ b/core/pldm/pldm-responder.c
@@ -145,6 +145,57 @@ static struct pldm_cmd pldm_base_get_tid = {
 	.handler = base_get_tid_handler,
 };
 
+/*
+ * GetPLDMTypes (0x04)
+ * The GetPLDMTypes command can be used to discover the PLDM type
+ * capabilities supported by a PLDM terminus and to get a list of the
+ * PLDM types that are supported.
+ */
+static int base_get_types_handler(const struct pldm_rx_data *req)
+{
+	char response_msg[PKT_SIZE(struct pldm_get_types_resp)];
+	bitmap_elem_t type_map[BITMAP_ELEMS(32)];
+	struct pldm_type *iter;
+	int rc;
+
+	/*
+	 * build the supported type list from the registered type
+	 * handlers
+	 */
+	memset(type_map, 0, sizeof(type_map));
+	list_for_each(&pldm_type_list, iter, link)
+		bitmap_set_bit(type_map, iter->pldm_type_id);
+
+	for (int i = 0; i < BITMAP_ELEMS(32); i++)
+		type_map[i] = cpu_to_le64(type_map[i]);
+
+	memset(response_msg, 0, sizeof(response_msg));
+	rc = encode_get_types_resp(req->hdrinf.instance,
+				   PLDM_SUCCESS,
+				   (bitfield8_t *)type_map,
+				   (struct pldm_msg *)response_msg);
+	if (rc != PLDM_SUCCESS) {
+		prlog(PR_ERR, "Encode GetPLDMTypes Error, rc: %d\n", rc);
+		pldm_cc_resp(req, req->hdrinf.pldm_type,
+			     req->hdrinf.command, PLDM_ERROR);
+		return OPAL_PARAMETER;
+	}
+
+	rc = pldm_send(req->source_eid, response_msg, sizeof(response_msg));
+	if (rc) {
+		prlog(PR_ERR, "Failed to send GetPLDMTypes response, rc = %d\n", rc);
+		return OPAL_HARDWARE;
+	}
+
+	return OPAL_SUCCESS;
+}
+
+static struct pldm_cmd pldm_base_get_types = {
+	.name = "PLDM_GET_PLDM_TYPES",
+	.pldm_cmd_id = PLDM_GET_PLDM_TYPES,
+	.handler = base_get_types_handler,
+};
+
 int pldm_rx_handle_request(struct pldm_rx_data *rx)
 {
 	const struct pldm_type *t;
@@ -181,6 +232,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, &pldm_base_get_tid);
+	pldm_add_cmd(&pldm_base_type, &pldm_base_get_types);
 
 	return OPAL_SUCCESS;
 }
-- 
2.35.1



More information about the Skiboot mailing list