[Skiboot] [PATCH V6 06/21] core/pldm: Encode GetPLDMTypes response
Christophe Lombard
clombard at linux.vnet.ibm.com
Tue Sep 13 20:26:50 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 6f11030d..6058af51 100644
--- a/core/pldm/pldm-responder.c
+++ b/core/pldm/pldm-responder.c
@@ -154,6 +154,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);
+ cc_resp(req, req->hdrinf.pldm_type,
+ req->hdrinf.command, PLDM_ERROR);
+ return OPAL_PARAMETER;
+ }
+
+ rc = pldm_mctp_message_tx(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_responder_handle_request(struct pldm_rx_data *rx)
{
const struct pldm_type *type;
@@ -190,6 +241,7 @@ int pldm_responder_init(void)
/* Register mandatory commands we'll respond to - DSP0240 */
add_type(&pldm_base_type);
add_cmd(&pldm_base_type, &pldm_base_get_tid);
+ add_cmd(&pldm_base_type, &pldm_base_get_types);
return OPAL_SUCCESS;
}
--
2.37.3
More information about the Skiboot
mailing list