From patchwork Tue Aug 29 09:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1827163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=SPNB4cXa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZhpQ6GrHz1yfy for ; Tue, 29 Aug 2023 19:24:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=SPNB4cXa; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZhpQ5BMcz3bhp for ; Tue, 29 Aug 2023 19:24:46 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=SPNB4cXa; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=clombard@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RZhnH6853z300q for ; Tue, 29 Aug 2023 19:23:47 +1000 (AEST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37T9Bmwg026355 for ; Tue, 29 Aug 2023 09:23:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=CT7aDYdcikBSMgxvXAB2WLBBGfDRV3pwnDh3cDgJ7+0=; b=SPNB4cXa46gsglHhRQImWo12lgLCtIJl+F9XizQHYd5W89qMrIGgxsvg/CzU418u4tGN 0b/JRRnYqcKh39h4KvQd4T6nvumQq3G8W2VCkm0OZF5pOphbR+BxnCse6pEuk0KFDrXC hUPYF9dmyypQtQkc/8jUOWJODfeHZGVooD/6Cm+zZh+mQqdS9mHkVtFJ2pnyNnaHpM2m UkM8i7/k6DpO/P0z96EhMS6qicrOXzJEAx6t9tDUNEWB95Qtf1nxSE3x2WMCqudRJ/fs NOiUUuDcujf/TmT6cZ/tFERhzPMRLFP+H++iS60DyI6hokdUEtsqu0wlDBAJnRHJk8Sn 8w== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3srv501fuw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:23:45 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37T7JLGi014349 for ; Tue, 29 Aug 2023 09:23:44 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sqvqn2926-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:23:44 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37T9NgMJ54264210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 29 Aug 2023 09:23:42 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18A0920043 for ; Tue, 29 Aug 2023 09:23:42 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D012420040 for ; Tue, 29 Aug 2023 09:23:41 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.home (unknown [9.171.88.232]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Tue, 29 Aug 2023 09:23:41 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 29 Aug 2023 11:23:23 +0200 Message-ID: <20230829092338.75785-7-clombard@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230829092338.75785-1-clombard@linux.ibm.com> References: <20230829092338.75785-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: kj3GcuUsEvg0VD-aGpGDm4rzit1Z6IML X-Proofpoint-GUID: kj3GcuUsEvg0VD-aGpGDm4rzit1Z6IML X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_06,2023-08-28_04,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 clxscore=1015 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290078 Subject: [Skiboot] [PATCH V10 06/21] core/pldm: Encode GetPLDMTypes response X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 061b5c3fa..33f9b17f1 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -173,6 +173,67 @@ 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 *rx) +{ + size_t data_size = PLDM_MSG_SIZE(struct pldm_get_types_resp); + bitmap_elem_t type_map[BITMAP_ELEMS(PLDM_MAX_TYPES)]; + struct pldm_tx_data *tx; + 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(PLDM_MAX_TYPES); i++) + type_map[i] = cpu_to_le64(type_map[i]); + + /* create a PLDM response message for GetPLDMTypes */ + tx = zalloc(sizeof(struct pldm_tx_data) + data_size); + if (!tx) + return OPAL_NO_MEM; + tx->data_size = data_size; + tx->tag_owner = true; + tx->msg_tag = rx->msg_tag; + + rc = encode_get_types_resp(rx->hdrinf.instance, + PLDM_SUCCESS, + (bitfield8_t *)type_map, + (struct pldm_msg *)tx->data); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetPLDMTypes Error, rc: %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + free(tx); + return OPAL_PARAMETER; + } + + rc = pldm_mctp_message_tx(tx); + if (rc) { + prlog(PR_ERR, "Failed to send GetPLDMTypes response, rc = %d\n", rc); + free(tx); + return OPAL_HARDWARE; + } + + free(tx); + 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; @@ -209,6 +270,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; }