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

Christophe Lombard clombard at linux.vnet.ibm.com
Sat Feb 26 01:28:35 AEDT 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.

Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
---
 core/pldm/pldm-responder.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c
index 76ccaab1..2bd6fd07 100644
--- a/core/pldm/pldm-responder.c
+++ b/core/pldm/pldm-responder.c
@@ -125,6 +125,44 @@ static struct pldm_cmd base_get_tid = {
 	.handler = 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 get_types_handler(const struct pldm_rx_data *req)
+{
+	char resp_buf[PKT_SIZE(struct pldm_get_types_resp)];
+	bitmap_elem_t type_map[BITMAP_ELEMS(32)];
+	struct pldm_type *iter;
+
+	/*
+	 * 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(resp_buf, 0, sizeof(resp_buf));
+	encode_get_types_resp(req->hdrinf.instance,
+			      PLDM_SUCCESS,
+			      (bitfield8_t *)type_map,
+			      (void *) resp_buf);
+	pldm_send(resp_buf, sizeof(resp_buf));
+
+	return OPAL_SUCCESS;
+}
+static struct pldm_cmd base_get_types = {
+	.name = "GetPLDMTypes",
+	.pldm_cmd_id = PLDM_GET_PLDM_TYPES,
+	.handler = get_types_handler,
+};
+
 int pldm_rx_handle_request(struct pldm_rx_data *rx)
 {
 	const struct pldm_type *t;
@@ -151,6 +189,7 @@ int pldm_mctp_responder_init(void)
 	pldm_add_type(&pldm_base_type);
 
 	pldm_add_cmd(&pldm_base_type, &base_get_tid);
+	pldm_add_cmd(&pldm_base_type, &base_get_types);
 
 	return OPAL_SUCCESS;
 }
-- 
2.35.1



More information about the Skiboot mailing list