diff mbox series

[V2,06/21] core/pldm: Encode GetPLDMTypes response

Message ID 20220304131154.58409-7-clombard@linux.vnet.ibm.com
State Superseded
Headers show
Series Implement MCTP and PLDM features | expand

Commit Message

Christophe Lombard March 4, 2022, 1:11 p.m. UTC
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@linux.vnet.ibm.com>
---
 core/pldm/pldm-responder.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

Comments

Abhishek Singh Tomar March 16, 2022, 11:19 a.m. UTC | #1
On Fri, Mar 04, 2022 at 02:11:39PM +0100, Christophe Lombard wrote:
> 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@linux.vnet.ibm.com>
Reviewed-by: Abhishek Singh Tomar <abhishek at linux.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
> 
> _______________________________________________
> Skiboot mailing list
> Skiboot@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot
diff mbox series

Patch

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;
 }