From patchwork Tue Aug 29 09:24:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1827194 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=qYMOFgIL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; 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 [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (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 4RZhvg5b6kz1yhC for ; Tue, 29 Aug 2023 19:29:19 +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=qYMOFgIL; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZhvg4TJJz3c67 for ; Tue, 29 Aug 2023 19:29:19 +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=qYMOFgIL; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=clombard@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 4RZhnv3rmWz3c1R for ; Tue, 29 Aug 2023 19:24:19 +1000 (AEST) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37T9ERBf016216 for ; Tue, 29 Aug 2023 09:24:17 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=nMsrKKAJocSQ1THNlQbpg2kgM4LQc1j/eZZ0nSwCMxE=; b=qYMOFgIL+OVNbdepOD4YIgVcG7lvrNWEMox7RDu3UM59Ud7g5xGTFuCaQkX0ggH2V5sR OliprGyVNgx07/EHplGrBgv+uTV7WkBuymOlP2LyKVI0PMhK8vikD6A4PkrDqS8PYjmt 00Uc2QCpt7wEih5fBpoqKPxWZQLoUIh8Zab+i/JTaMC9oc7bbo3aFDy0fZz1YmduzTTO LvjVAnnhkaFJg30jTz5+d4proy1PUuthFUduh2pFj4QLG2eFt9sA3wbUjl3/ketarj/D p5ziz1imQeuUq8gf6MuXqD8QiNhV5EsvrYuevt3B+BPV9JIpL6HOT3KZc/mVJz+VyEwH pg== 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 3ssdqgrt4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:17 +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 37T76Rw3014416 for ; Tue, 29 Aug 2023 09:24:16 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sqvqn295w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:16 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37T9OErG33948360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 29 Aug 2023 09:24:14 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64A022004D for ; Tue, 29 Aug 2023 09:24:14 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A95520043 for ; Tue, 29 Aug 2023 09:24:14 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.home (unknown [9.171.88.232]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Tue, 29 Aug 2023 09:24:14 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 29 Aug 2023 11:24:05 +0200 Message-ID: <20230829092409.75899-12-clombard@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230829092409.75899-1-clombard@linux.ibm.com> References: <20230829092409.75899-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5d7KLCsgCKb2wI1b47ojT1mqzuqRuMui X-Proofpoint-ORIG-GUID: 5d7KLCsgCKb2wI1b47ojT1mqzuqRuMui 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 bulkscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 spamscore=0 adultscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290078 Subject: [Skiboot] [PATCH V6 11/15] core/pldm: Decode the GetFruRecordTable request 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 GetFRURecordTable command is used to get the FRU Record Table data. This command is defined to allow the FRU Record Table data to be transferred using a sequence of one or more command/response messages. Signed-off-by: Christophe Lombard --- core/pldm/pldm-fru-requests.c | 12 +++++ core/pldm/pldm-responder.c | 82 +++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 2 + 3 files changed, 96 insertions(+) diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c index fa4764b17..a29a80ae4 100644 --- a/core/pldm/pldm-fru-requests.c +++ b/core/pldm/pldm-fru-requests.c @@ -269,6 +269,18 @@ void pldm_fru_set_local_table(uint32_t *table_length, local_fru_table_length = *table_length; } +int pldm_fru_get_local_table(void **fru_record_table_bytes, + uint32_t *fru_record_table_size) +{ + if (!local_fru_record_table) + return OPAL_PARAMETER; + + *fru_record_table_bytes = local_fru_record_table; + *fru_record_table_size = local_fru_table_length; + + return OPAL_SUCCESS; +} + int pldm_fru_init(void) { int rc; diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 3ab813f36..d42d9f52a 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -1038,6 +1038,87 @@ static struct pldm_cmd pldm_fru_get_record_table_metadata = { .handler = fru_get_record_table_metadata_handler, }; +/* + * GetFRURecordTable (0X02) + * The GetFRURecordTable command is used to get the FRU Record Table + * data. This command is defined to allow the FRU Record Table data to + * be transferred using a sequence of one or more command/response + * messages. + */ +static int fru_get_record_table_handler(const struct pldm_rx_data *rx) +{ + struct pldm_get_fru_record_table_resp *resp; + void *fru_record_table_bytes; + uint32_t fru_record_table_size; + struct pldm_tx_data *tx; + struct pldm_msg *msg; + size_t data_size; + int rc; + + /* The getFruRecordTable requests do have request data, but it's + * only related to multi-part transfers which we don't support + * and which the BMC will not send us. + */ + + /* get local fru record table */ + rc = pldm_fru_get_local_table(&fru_record_table_bytes, &fru_record_table_size); + if (rc) { + prlog(PR_ERR, "Failed to get Fru Record Table\n"); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + /* create a PLDM response message for GetFRURecordTable */ + data_size = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_fru_record_table_resp) + + fru_record_table_size; + + tx = zalloc(sizeof(struct pldm_tx_data) + data_size); + if (!tx) + return OPAL_NO_MEM; + tx->data_size = data_size - 1; + tx->tag_owner = true; + tx->msg_tag = rx->msg_tag; + + rc = encode_get_fru_record_table_resp( + rx->hdrinf.instance, + PLDM_SUCCESS, + 0, // No next transfer handle + PLDM_START_AND_END, + (struct pldm_msg *)tx->data); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetFruRecordTable Error, rc: %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + free(tx); + return OPAL_PARAMETER; + } + + msg = (struct pldm_msg *)tx->data; + resp = (struct pldm_get_fru_record_table_resp *)(msg->payload); + memcpy(resp->fru_record_table_data, + fru_record_table_bytes, + fru_record_table_size); + + /* send PLDM message over MCTP */ + rc = pldm_mctp_message_tx(tx); + if (rc) { + prlog(PR_ERR, "Failed to send GetFruRecordTable response, rc = %d\n", rc); + free(tx); + return OPAL_HARDWARE; + } + + free(tx); + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_fru_get_record_table = { + .name = "PLDM_GET_FRU_RECORD_TABLE", + .pldm_cmd_id = PLDM_GET_FRU_RECORD_TABLE, + .handler = fru_get_record_table_handler, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type; @@ -1089,6 +1170,7 @@ int pldm_responder_init(void) /* Register fru commands we'll respond to - DSP0257 */ add_type(&pldm_fru_type); add_cmd(&pldm_fru_type, &pldm_fru_get_record_table_metadata); + add_cmd(&pldm_fru_type, &pldm_fru_get_record_table); return OPAL_SUCCESS; } diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index bc8782466..fb837bfc5 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -83,6 +83,8 @@ int pldm_fru_get_bmc_version(void *bv, int len); void pldm_fru_set_local_table(uint32_t *table_length, uint16_t *total_record_set_identifiers, uint16_t *total_table_records); +int pldm_fru_get_local_table(void **fru_record_table_bytes, + uint32_t *fru_record_table_size); int pldm_fru_init(void); int pldm_bios_find_lid_by_attr_name(const char *name, char **lid);