From patchwork Fri Mar 18 14:36:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1607081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=XbkVOmBK; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KKmpK3cWCz9s3q for ; Sat, 19 Mar 2022 01:38:17 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KKmpK2PJqz3bWX for ; Sat, 19 Mar 2022 01:38:17 +1100 (AEDT) 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=XbkVOmBK; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=clombard@linux.vnet.ibm.com; receiver=) 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=XbkVOmBK; dkim-atps=neutral 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 4KKmmJ12jZz30NC for ; Sat, 19 Mar 2022 01:36:31 +1100 (AEDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22ICntg2004707 for ; Fri, 18 Mar 2022 14:36:30 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=qKe5/wBiaeNayXDUZ/CkuWtprVad5rBu3GPhVgWzbfg=; b=XbkVOmBK+ldC1agtfVO+pdQf3RKWG4O7tiHPcZMZxM+vtE+d4UcLDtE8KPtTjRTxURCW V3UAn7ZDsnGmUknLWdrFSvfuwEOlFgcMEBvpAOHyIIrIu2BQ4jq0tw+fgEaWqRzkIWj+ 0f5Ww/rtq+mqUMfnzFsLgRxAMu9qvqKpcQizYyVi5rOc5sAq9griPvrTxoGr9wxJ7ep8 RxSFXTZN5oJGniPwSXgTB3WeMs2Z59PtpKYfEEB5/zuzcU197PW5EE1RtkSxsM5kNPQh 8LW5KnRwqoq8K67kgfq7yd8BFL40FMTo4zlbz5Wzn/2lNkd/GIlabYAdEWI+H6P1JSft ow== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3ev04qrvgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Mar 2022 14:36:29 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 22IEIi7r027459 for ; Fri, 18 Mar 2022 14:36:27 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06fra.de.ibm.com with ESMTP id 3erjshuruj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Mar 2022 14:36:27 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22IEaOZv49086912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Mar 2022 14:36:24 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79F6511C04A for ; Fri, 18 Mar 2022 14:36:24 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4912611C050 for ; Fri, 18 Mar 2022 14:36:24 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.ibm.com.com (unknown [9.171.63.232]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Fri, 18 Mar 2022 14:36:24 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Fri, 18 Mar 2022 15:36:14 +0100 Message-Id: <20220318143619.83489-17-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220318143619.83489-1-clombard@linux.vnet.ibm.com> References: <20220318143619.83489-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: G6X6U0iPZLOaCtrRd3r0_JwRzfJHrgQV X-Proofpoint-ORIG-GUID: G6X6U0iPZLOaCtrRd3r0_JwRzfJHrgQV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-18_10,2022-03-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203180080 Subject: [Skiboot] [PATCH V3 16/21] core/pldm: PLDM for FRU data Specification 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" Specification, defines a FRU data format that provides platform asset information including part number, serial number and manufacturer. Use the GetFruRecordByOptionReq command to get specific FRU (Field Replaceable Unit) record according the Record Set Identifier, the Record Type and the field Type. Signed-off-by: Christophe Lombard --- core/pldm/Makefile.inc | 1 + core/pldm/pldm-fru-requests.c | 112 ++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 6 ++ 3 files changed, 119 insertions(+) create mode 100644 core/pldm/pldm-fru-requests.c diff --git a/core/pldm/Makefile.inc b/core/pldm/Makefile.inc index fcd97a0a..d615a012 100644 --- a/core/pldm/Makefile.inc +++ b/core/pldm/Makefile.inc @@ -12,6 +12,7 @@ CFLAGS_$(PLDM_DIR)/pldm-bios-requests.o = -Wno-strict-prototypes PLDM_OBJS = pldm-common.o pldm-responder.o pldm-requester.o PLDM_OBJS += pldm-platform-requests.o pldm-bios-requests.o +PLDM_OBJS += pldm-fru-requests.o PLDM = $(PLDM_DIR)/built-in.a $(PLDM): $(PLDM_OBJS:%=$(PLDM_DIR)/%) diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c new file mode 100644 index 00000000..a2665c41 --- /dev/null +++ b/core/pldm/pldm-fru-requests.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +// Copyright 2022 IBM Corp. + +#define pr_fmt(fmt) "PLDM: " fmt + +#include +#include +#include +#include +#include +#include +#include "pldm.h" + +static int get_fru_record_by_option_req(uint16_t fru_table_handle, + uint16_t record_set_identifier, + uint8_t record_type, + uint8_t field_type, + struct variable_field *fru_structure_data) +{ + char request_msg[PKT_SIZE(struct pldm_get_fru_record_by_option_req)]; + size_t response_len, payload_len; + uint8_t transfer_flag, completion_code; + uint32_t next_transfer_handle; + struct variable_field fsdata; + void *response_msg; + int rc; + + struct pldm_get_fru_record_by_option_req fru_record_by_option_req = { + .data_transfer_handle = 0, /* (0 if operation op is FIRSTPART) */ + .fru_table_handle = fru_table_handle, + .record_set_identifier = record_set_identifier, + .record_type = record_type, + .field_type = field_type, + .transfer_op_flag = PLDM_GET_FIRSTPART, + }; + payload_len = sizeof(struct pldm_get_fru_record_by_option_req); + + prlog(PR_DEBUG, "%s - handle: 0x%x, record id: 0x%x, record type: 0x%x, " + "field type: 0x%x\n", + __func__, fru_table_handle, record_set_identifier, + record_type, field_type); + + /* Encode the file table request */ + rc = encode_get_fru_record_by_option_req( + DEFAULT_INSTANCE_ID, + fru_record_by_option_req.data_transfer_handle, + fru_record_by_option_req.fru_table_handle, + fru_record_by_option_req.record_set_identifier, + fru_record_by_option_req.record_type, + fru_record_by_option_req.field_type, + fru_record_by_option_req.transfer_op_flag, + (struct pldm_msg *)request_msg, + payload_len); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetFruRecordByOptionReq Error (rc: %d)\n", rc); + return OPAL_PARAMETER; + } + + /* Send and get the response message bytes */ + rc = pldm_do_request(BMC_EID, request_msg, sizeof(request_msg), + &response_msg, &response_len); + if (rc) { + prlog(PR_ERR, "PLDM: Communication Error (req:" + "GetFruRecordByOptionReq, rc: %d)\n", rc); + return OPAL_PARAMETER; + } + + /* Decode the message */ + payload_len = response_len - sizeof(struct pldm_msg_hdr); + rc = decode_get_fru_record_by_option_resp( + response_msg, + payload_len, + &completion_code, + &next_transfer_handle, + &transfer_flag, + &fsdata); + if (rc != PLDM_SUCCESS || completion_code != PLDM_SUCCESS) { + prlog(PR_ERR, "Decode GetFruRecordByOptionReq Error (rc: %d, cc: %d)\n", + rc, completion_code); + return OPAL_PARAMETER; + } + + /* we do not support multipart transfer */ + if ((next_transfer_handle != PLDM_GET_NEXTPART) || + (transfer_flag != PLDM_START_AND_END)) { + prlog(PR_ERR, "Transfert GetFileResp not complete, " + "transfer_hndl: %d, transfer_flag: %d\n", + next_transfer_handle, + transfer_flag); + } + + fru_structure_data->length = fsdata.length; + fru_structure_data->ptr = malloc(fsdata.length); + memcpy((void *)fru_structure_data->ptr, fsdata.ptr, fsdata.length); + + free(response_msg); + + return OPAL_SUCCESS; +} + +int pldm_fru_get_record_by_option(uint16_t fru_table_handle, + uint16_t record_set_identifier, + uint8_t record_type, + uint8_t field_type, + struct variable_field *fru_structure_data) +{ + return get_fru_record_by_option_req(fru_table_handle, + record_set_identifier, + record_type, + field_type, + fru_structure_data); +} diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index 52b19f03..e75b69ab 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -49,6 +49,12 @@ int pldm_rx_handle_request(struct pldm_rx_data *rx); int pldm_mctp_responder_init(void); /* Requester support */ +int pldm_fru_get_record_by_option(uint16_t fru_table_handle, + uint16_t record_set_identifier, + uint8_t record_type, + uint8_t field_type, + struct variable_field *fru_structure_data); + int pldm_bios_find_lid_by_attr_name(const char *name, char **lid); int pldm_bios_get_lids_id(char **lid_ids_string); int pldm_bios_init(void);