From patchwork Tue Aug 29 09:24:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1827191 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=a1RCRXUP; 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 4RZhv8142dz1yZs for ; Tue, 29 Aug 2023 19:28:52 +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=a1RCRXUP; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZhv801TFz3c2V for ; Tue, 29 Aug 2023 19:28:52 +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=a1RCRXUP; 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 4RZhnt4wv5z300q for ; Tue, 29 Aug 2023 19:24:18 +1000 (AEST) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37T99qfM030464 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=TXkIZSYwX4JO3m8vxoTtpHhAtkLXtiX/wWeZwdIA7AA=; b=a1RCRXUPzx95yBGZh2JLjOaBu042zcfNZYxSqJYz9UFbGHD2GYNepwtKsOzCprbsO+4u Q/6VRkk/9hA9lzRE8zBV0+8hzOodnyE9SX7FuEHCrifo7A0FXYDZhp7CXMJ1s1j3ST7T 6dSrlfYOuv5tCHHkmf08XOHj3izNAJCr9XPXzgf5aUMWixYPvwh0iytDkQgnT0bF0VBS Cyp9Y5/zxp9VA7JATXuhpEVSIUqTJtlkC+Zj14o2SPEHKPmq7t66pQHVRjJvLWthgigw n2tuBi777OaOnNJxRYflhfDrmasNnYSKQJT8KusphGHsbOaPUYF31YaYHW8ps1cpkv6j mA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sr8s75xr3-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 pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37T8waAV004884 for ; Tue, 29 Aug 2023 09:24:15 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3squqsjk8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Aug 2023 09:24:15 +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 37T9OEIl45089276 (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 0B09C20040 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 C486720043 for ; Tue, 29 Aug 2023 09:24:13 +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:13 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 29 Aug 2023 11:24:04 +0200 Message-ID: <20230829092409.75899-11-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: ov99XPiPe82qSsXBNMWdiMV2IpaLOtSc X-Proofpoint-ORIG-GUID: ov99XPiPe82qSsXBNMWdiMV2IpaLOtSc 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 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290078 Subject: [Skiboot] [PATCH V6 10/15] core/pldm: Decode the GetFRURecordTableMetadata 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 GetFRURecordTableMetadata command is used to get the FRU Record Table metadata information that includes the FRU Record major version, the FRU Record minor version, the size of the largest FRU Record data, total length of the FRU Record Table, total number of FRU Record Data structures, and the integrity checksum on the FRU Record Table data. Add an "IBM, skiboot" FRU Record product requested by the BMC. Signed-off-by: Christophe Lombard --- core/pldm/pldm-fru-requests.c | 58 +++++++++++++++++++++ core/pldm/pldm-responder.c | 96 +++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 3 ++ 3 files changed, 157 insertions(+) diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c index ab517e90f..fa4764b17 100644 --- a/core/pldm/pldm-fru-requests.c +++ b/core/pldm/pldm-fru-requests.c @@ -14,6 +14,9 @@ static void *fru_record_table; static size_t fru_record_length; +static void *local_fru_record_table; +static size_t local_fru_table_length; + static bool fru_ready; static char *bmc_version; @@ -211,6 +214,61 @@ out: return rc; } +#define RECORD_SET_ID 100 + +void pldm_fru_set_local_table(uint32_t *table_length, + uint16_t *total_record_set_identifiers, + uint16_t *total_table_records) +{ + struct pldm_fru_record_data_format *record; + struct pldm_fru_record_tlv *fru_tlv; + size_t fru_table_size, record_size; + char fru_product[] = "IBM, skiboot"; + + if (local_fru_record_table) { + *table_length = local_fru_table_length; + *total_record_set_identifiers = 1; + *total_table_records = 1; + return; + } + + /* allocate fru table */ + fru_table_size = sizeof(struct pldm_fru_record_data_format) + + sizeof(struct pldm_fru_record_tlv) + + strlen(fru_product); + local_fru_record_table = zalloc(fru_table_size); + if (!local_fru_record_table) { + prlog(PR_ERR, "%s: failed to allocate fru record table\n", + __func__); + return; + } + + /* fill fru record data */ + record = (struct pldm_fru_record_data_format *)local_fru_record_table; + record->record_set_id = htole16(RECORD_SET_ID); + record->record_type = PLDM_FRU_RECORD_TYPE_GENERAL; + record->num_fru_fields = 1; + record->encoding_type = PLDM_FRU_ENCODING_ASCII; + + /* to start, set the size as the start of the TLV structs */ + record_size = offsetof(struct pldm_fru_record_data_format, tlvs); + + /* TLVs data */ + fru_tlv = (struct pldm_fru_record_tlv *)(local_fru_record_table + record_size); + fru_tlv->type = PLDM_FRU_FIELD_TYPE_OTHER; + fru_tlv->length = strlen(fru_product); + memcpy(fru_tlv->value, fru_product, fru_tlv->length); + + /* increment record_size by total size of this TLV */ + record_size += (offsetof(struct pldm_fru_record_tlv, value) + fru_tlv->length); + + *table_length = record_size; + *total_record_set_identifiers = 1; + *total_table_records = 1; + + local_fru_table_length = *table_length; +} + int pldm_fru_init(void) { int rc; diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 3eba2e9be..3ab813f36 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -946,6 +947,97 @@ static struct pldm_cmd pldm_platform_get_pdr = { .handler = platform_get_pdr_handle, }; +/* + * PLDM Fru commands support + */ +static struct pldm_type pldm_fru_type = { + .name = "fru", + .pldm_type_id = PLDM_FRU, +}; + +/* currently we support version 1.0 of fru table */ +#define SUPPORTED_FRU_VERSION_MAJOR 1 +#define SUPPORTED_FRU_VERSION_MINOR 0 + +/* Used by the metadata request handler for the value of + * FRUTableMaximumSize + * 0 means SetFRURecordTable command is not supported (see DSP 0257 + * v1.0.0 Table 9) + */ +#define FRU_TABLE_MAX_SIZE_UNSUPPORTED 0 + +/* + * GetFRURecordTableMetadata (0X01) + * The GetFRURecordTableMetadata command is used to get the FRU Record + * Table metadata information that includes the FRU Record major + * version, the FRU Record minor version, the size of the largest FRU + * Record data, total length of the FRU Record Table, total number of + * FRU Record Data structures, and the integrity checksum on the FRU + * Record Table data. + */ +static int fru_get_record_table_metadata_handler(const struct pldm_rx_data *rx) +{ + size_t data_size = PLDM_MSG_SIZE(struct pldm_get_fru_record_table_metadata_resp); + uint16_t total_record_set_identifiers, total_table_records; + uint32_t fru_table_length; + struct pldm_tx_data *tx; + int rc; + + /* + * GetFRURecordTableMetadata requests + * don't have any payload, so no need to decode them + */ + + /* add specific fru record */ + pldm_fru_set_local_table(&fru_table_length, + &total_record_set_identifiers, + &total_table_records); + + /* create a PLDM response message for GetFRURecordTableMetadata */ + 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_fru_record_table_metadata_resp( + rx->hdrinf.instance, + PLDM_SUCCESS, + SUPPORTED_FRU_VERSION_MAJOR, + SUPPORTED_FRU_VERSION_MINOR, + FRU_TABLE_MAX_SIZE_UNSUPPORTED, + fru_table_length, + total_record_set_identifiers, + total_table_records, + 0, // checksum, not calculated + (struct pldm_msg *)tx->data); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetFRURecordTableMetadata Error, rc: %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + free(tx); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_mctp_message_tx(tx); + if (rc) { + prlog(PR_ERR, "Failed to send GetFRURecordTableMetadata response, rc = %d\n", rc); + free(tx); + return OPAL_HARDWARE; + } + + free(tx); + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_fru_get_record_table_metadata = { + .name = "PLDM_GET_FRU_RECORD_TABLE_METADATA", + .pldm_cmd_id = PLDM_GET_FRU_RECORD_TABLE_METADATA, + .handler = fru_get_record_table_metadata_handler, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type; @@ -994,5 +1086,9 @@ int pldm_responder_init(void) add_cmd(&pldm_platform_type, &pldm_platform_set_state_effecter_states); add_cmd(&pldm_platform_type, &pldm_platform_get_pdr); + /* Register fru commands we'll respond to - DSP0257 */ + add_type(&pldm_fru_type); + add_cmd(&pldm_fru_type, &pldm_fru_get_record_table_metadata); + return OPAL_SUCCESS; } diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index df38ce5fb..bc8782466 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -80,6 +80,9 @@ int pldm_file_io_write_file(uint32_t file_handle, uint32_t pos, int pldm_file_io_init(void); 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_init(void); int pldm_bios_find_lid_by_attr_name(const char *name, char **lid);