From patchwork Tue Apr 19 13:46:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618949 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=EeMJpt2H; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjQ9l4sfVz9sGZ for ; Tue, 19 Apr 2022 23:48:11 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ9l3g53z3bbn for ; Tue, 19 Apr 2022 23:48:11 +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=EeMJpt2H; 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.158.5; 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=EeMJpt2H; dkim-atps=neutral Received: from mx0a-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 4KjQ8J0SMYz3bbV for ; Tue, 19 Apr 2022 23:46:55 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JD2nDs017709 for ; Tue, 19 Apr 2022 13:46:38 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=9h332whKSvz6SH0m4xDbQTV7cs5vQ49g2iqwfkikg4M=; b=EeMJpt2HJWsdS6y6jXK5UW2nM6epmkzOAqF56N4AkcjAZ7a2k6KuJADnLtpbfkzWtSWZ FvyDN89JwFCb4PC5P30dHZLHVvrDEBJP+UAza3TY31ugy2eczXuYR5VLEC7V3qBt2xXU jaqkQNZeSAMVprR+XB8vyro17kz/v3un6sWlduK0NTEr2W+bt2d0ixrmN1Ktyg6l+3BN aU6exQih2i8lnF2//1kTa/Kljxq+IErKyqRqYlyErvg7AvUNZnMC5kSgK4hfgSHCFean 8uThj4W3rlgOA2Rel6wcq85VjPXa3f/G0CEvJ8lBTQTXpAUnMcz3iMUPt74J2PJnNhk0 zw== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fhr3yrxap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbjpK018024 for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3ffn2hvg85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:36 +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 23JDkXgE51904898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB49411C04C for ; Tue, 19 Apr 2022 13:46:33 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB55611C04A for ; Tue, 19 Apr 2022 13:46:33 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:33 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:20 +0200 Message-Id: <20220419134633.42098-3-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fHATItqzn4xJc11VXs6QUAdlDpjqKN7i X-Proofpoint-ORIG-GUID: fHATItqzn4xJc11VXs6QUAdlDpjqKN7i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 01/14] core/pldm: Handle Watchdog timer. 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" Encode a PLDM platform event message to send the heartbeat to the BMC. Watchdog is "armed" when a PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE is received. Signed-off-by: Christophe Lombard --- core/pldm/Makefile.inc | 2 + core/pldm/pldm-watchdog.c | 125 ++++++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 1 + include/pldm.h | 5 ++ 4 files changed, 133 insertions(+) create mode 100644 core/pldm/pldm-watchdog.c diff --git a/core/pldm/Makefile.inc b/core/pldm/Makefile.inc index 506bf5d7..c6f78822 100644 --- a/core/pldm/Makefile.inc +++ b/core/pldm/Makefile.inc @@ -9,11 +9,13 @@ CPPFLAGS += -I$(SRC)/pldm/ibm/libpldm/ CFLAGS_$(PLDM_DIR)/pldm-platform-requests.o = -Wno-strict-prototypes CFLAGS_$(PLDM_DIR)/pldm-bios-requests.o = -Wno-strict-prototypes +CFLAGS_$(PLDM_DIR)/pldm-watchdog.o = -Wno-strict-prototypes PLDM_OBJS = pldm-common.o pldm-responder.o pldm-requester.o PLDM_OBJS += pldm-base-requests.o pldm-platform-requests.o PLDM_OBJS += pldm-bios-requests.o pldm-fru-requests.o PLDM_OBJS += pldm-file-io-requests.o pldm-lid-files.o +PLDM_OBJS += pldm-watchdog.o PLDM = $(PLDM_DIR)/built-in.a $(PLDM): $(PLDM_OBJS:%=$(PLDM_DIR)/%) diff --git a/core/pldm/pldm-watchdog.c b/core/pldm/pldm-watchdog.c new file mode 100644 index 00000000..863390d6 --- /dev/null +++ b/core/pldm/pldm-watchdog.c @@ -0,0 +1,125 @@ +// 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 +#include "pldm.h" + +#define DEFAULT_WATCHDOG_TIMEOUT_SEC (10 * 60) /* 10 min */ + +/* Whether the watchdog timer is armed and Skiboot should be sending + * regular heartbeats. + */ +bool watchdog_armed; + +/* The period (in seconds) of the PLDM watchdog, as dictated by BMC */ +int watchdog_period_sec = DEFAULT_WATCHDOG_TIMEOUT_SEC; + +static struct lock sequence_lock; +static uint8_t sequence_number; + +int pldm_watchdog_reset_timer(void) +{ + uint8_t heartbeat_elapsed_data[2]; + size_t response_len, payload_len; + uint32_t request_length; + void *response_msg; + char *request_msg; + int rc; + + struct pldm_platform_event_message_req event_message_req = { + .format_version = PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION, + .tid = HOST_TID, + .event_class = PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT, + }; + + struct pldm_platform_event_message_resp response; + + /* watchdog is not armed, so no need to send the heartbeat */ + if (!watchdog_armed) { + prlog(PR_ERR, "%s - PLDM watchdog is not armed; not sending the heartbeat", + __func__); + return OPAL_PARAMETER; + } + + prlog(PR_INFO, "%s - send the heartbeat to the BMC, sequence: %d, peridod: %d\n", + __func__, sequence_number, watchdog_period_sec); + + /* Send the event request */ + heartbeat_elapsed_data[0] = PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION; + + /* We need to make sure that we send the BMC the correct + * sequence number. To prevent possible race conditions for the + * sequence number, lock it while we're incrementing and + * sending it down. + */ + lock(&sequence_lock); + heartbeat_elapsed_data[1] = sequence_number++; + + payload_len = PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + sizeof(heartbeat_elapsed_data); + + request_length = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_platform_event_message_req) + + sizeof(heartbeat_elapsed_data); + request_msg = malloc(request_length); + + /* Encode the platform event message request */ + rc = encode_platform_event_message_req( + DEFAULT_INSTANCE_ID, + event_message_req.format_version, + event_message_req.tid, + event_message_req.event_class, + heartbeat_elapsed_data, + sizeof(heartbeat_elapsed_data), + (struct pldm_msg *)request_msg, + payload_len); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode PlatformEventMessage Error, rc: %d\n", rc); + free(request_msg); + return OPAL_PARAMETER; + } + unlock(&sequence_lock); + + /* Send and get the response message bytes */ + rc = pldm_do_request(BMC_EID, request_msg, request_length - 1, + &response_msg, &response_len); + if (rc) { + prlog(PR_ERR, "Communication Error, req: PlatformEventMessage, rc: %d\n", rc); + free(request_msg); + return rc; + } + free(request_msg); + + /* Decode the message */ + payload_len = response_len - sizeof(struct pldm_msg_hdr); + rc = decode_platform_event_message_resp( + response_msg, + payload_len, + &response.completion_code, + &response.platform_event_status); + if (rc != PLDM_SUCCESS || response.completion_code != PLDM_SUCCESS) { + prlog(PR_ERR, "Decode PlatformEventMessage Error, rc: %d, cc: %d, pes: %d\n", + rc, response.completion_code, + response.platform_event_status); + free(response_msg); + return OPAL_PARAMETER; + } + + free(response_msg); + + return OPAL_SUCCESS; +} + +int pldm_watchdog_init(void) +{ + init_lock(&sequence_lock); + + return pldm_watchdog_reset_timer(); +} diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index 22cf765d..d27220f3 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -50,6 +50,7 @@ struct pldm_type { }; int pldm_send(uint8_t dest_id, uint8_t *buf, int len); +int pldm_watchdog_reset_timer(void); /* Responder support */ int pldm_rx_handle_request(struct pldm_rx_data *rx); diff --git a/include/pldm.h b/include/pldm.h index 5ad724af..01af9a33 100644 --- a/include/pldm.h +++ b/include/pldm.h @@ -42,4 +42,9 @@ int pldm_lid_files_init(struct blocklevel_device **bl); */ bool pldm_lid_files_exit(struct blocklevel_device *bl); +/** + * Initialize and reset the watchdog + */ +int pldm_watchdog_init(void); + #endif /* __PLDM_H__ */ From patchwork Tue Apr 19 13:46:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618947 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=TeTykBZv; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjQ9R120Yz9sGZ for ; Tue, 19 Apr 2022 23:47:54 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ9Q59Y6z3bd7 for ; Tue, 19 Apr 2022 23:47:54 +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=TeTykBZv; 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.158.5; helo=mx0b-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=TeTykBZv; dkim-atps=neutral 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 4KjQ8772Jqz2ywF for ; Tue, 19 Apr 2022 23:46:47 +1000 (AEST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JDY5UQ006000 for ; Tue, 19 Apr 2022 13:46:38 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=JmR83HxqhwMEIOH3rqfUFDmGA2BIDE20f76vrGz/G0I=; b=TeTykBZvDtg+b+vIwM7amAeElvQpZ4dS2/zof1Egrmow+Fj5s3jkaiOLsZv53HJoN/uO xfNmAu+6SuxBbtfp+QC9/76Tz/4kI1f0FtngXCGbhIOyZIFfs9MhJLU3g6NPEuMwkoRW G5MLK9KhPNaa+Ts2OiL6QQnvEoUXEVTNVeqlhVaGGoFoEUapZYmNhdnQriYDzh02AzJy 2XEAS3D2Ud8IdsUS+Qm9eMAS7rRAaWy0PCsoWXhIU/YqYlPwtQ/M/KUT6FreLJR67nor LhVYwiK2tEyC1I2TjtjmG7y/vdIGKjznKq9kcAJRhFyYurw044gK2FNBp+82d/ov+dma 4g== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7rf88wy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbksm018028 for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3ffn2hvg86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:36 +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 23JDkYTF32112908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15E8311C04C for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA2B111C050 for ; Tue, 19 Apr 2022 13:46:33 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:33 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:21 +0200 Message-Id: <20220419134633.42098-4-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: y_WDG1wTXm3ba0aiMVavmH-F4H2lkxs5 X-Proofpoint-ORIG-GUID: y_WDG1wTXm3ba0aiMVavmH-F4H2lkxs5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 02/14] core/pldm: Decode the SetEventReceiver 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 SetEventReceiver command is used to set the address of the Event Receiver into a terminus that generates event messages. It is also used to globally enable or disable whether event messages are generated from the terminus. For the time being, only the following global event message is supported: PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE. The Event Receiver acknowledges receiving the PLDM Event Message in the response to this command. Signed-off-by: Christophe Lombard --- core/pldm/Makefile.inc | 1 + core/pldm/pldm-responder.c | 96 ++++++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 2 + 3 files changed, 99 insertions(+) diff --git a/core/pldm/Makefile.inc b/core/pldm/Makefile.inc index c6f78822..01117680 100644 --- a/core/pldm/Makefile.inc +++ b/core/pldm/Makefile.inc @@ -10,6 +10,7 @@ CPPFLAGS += -I$(SRC)/pldm/ibm/libpldm/ CFLAGS_$(PLDM_DIR)/pldm-platform-requests.o = -Wno-strict-prototypes CFLAGS_$(PLDM_DIR)/pldm-bios-requests.o = -Wno-strict-prototypes CFLAGS_$(PLDM_DIR)/pldm-watchdog.o = -Wno-strict-prototypes +CFLAGS_$(PLDM_DIR)/pldm-responder.o = -Wno-strict-prototypes PLDM_OBJS = pldm-common.o pldm-responder.o pldm-requester.o PLDM_OBJS += pldm-base-requests.o pldm-platform-requests.o diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 16ce6b1f..232447e2 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "pldm.h" @@ -369,6 +370,97 @@ static struct pldm_cmd pldm_base_get_version = { .handler = base_get_version_handler, }; +/* + * PLDM Platform commands support + */ +static struct pldm_type pldm_platform_type = { + .name = "platform", + .pldm_type_id = PLDM_PLATFORM, +}; + +struct event_receiver_req { + uint8_t event_message_global_enable; + uint8_t transport_protocol_type; + uint8_t event_receiver_address_info; + uint16_t heartbeat_timer; +}; + +#define MIN_WATCHDOG_TIMEOUT_SEC 15 + +/* + * SetEventReceiver (0x04) + * The SetEventReceiver command is used to set the address of the Event + * Receiver into a terminus that generates event messages. It is also + * used to globally enable or disable whether event messages are + * generated from the terminus. + */ +static int platform_set_event_receiver_handler(const struct pldm_rx_data *req) +{ + struct event_receiver_req receiver_req; + uint8_t cc = PLDM_SUCCESS; + int rc = OPAL_SUCCESS; + + /* decode SetEventReceiver request data */ + rc = decode_set_event_receiver_req( + req->msg, + PLDM_SET_EVENT_RECEIVER_REQ_BYTES, + &receiver_req.event_message_global_enable, + &receiver_req.transport_protocol_type, + &receiver_req.event_receiver_address_info, + &receiver_req.heartbeat_timer); + if (rc) { + prlog(PR_ERR, "Failed to decode SetEventReceiver request, rc = %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + /* invoke the appropriate callback handler */ + prlog(PR_DEBUG, "%s - event_message_global_enable: %d, " + "transport_protocol_type: %d " + "event_receiver_address_info: %d " + "heartbeat_timer: 0x%x\n", + __func__, + receiver_req.event_message_global_enable, + receiver_req.transport_protocol_type, + receiver_req.event_receiver_address_info, + receiver_req.heartbeat_timer); + + if (receiver_req.event_message_global_enable != + PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE) { + + prlog(PR_ERR, "%s - invalid value for message global enable received: %d\n", + __func__, receiver_req.event_message_global_enable); + cc = PLDM_PLATFORM_ENABLE_METHOD_NOT_SUPPORTED; + } + + if (receiver_req.heartbeat_timer < MIN_WATCHDOG_TIMEOUT_SEC) { + prlog(PR_ERR, "%s - BMC requested watchdog timeout that's too small: %d\n", + __func__, receiver_req.heartbeat_timer); + cc = PLDM_PLATFORM_HEARTBEAT_FREQUENCY_TOO_HIGH; + } else { + /* set the internal watchdog period to what BMC indicated */ + watchdog_period_sec = receiver_req.heartbeat_timer; + } + + /* send the response to BMC */ + pldm_cc_resp(req, PLDM_PLATFORM, PLDM_SET_EVENT_RECEIVER, cc); + + /* no error happened above, so arm the watchdog and set the default timeout */ + if (cc == PLDM_SUCCESS) { + watchdog_armed = true; + pldm_watchdog_reset_timer(); + } + + return rc; +} + +static struct pldm_cmd pldm_platform_set_event_receiver = { + .name = "PLDM_SET_EVENT_RECEIVER", + .pldm_cmd_id = PLDM_SET_EVENT_RECEIVER, + .handler = platform_set_event_receiver_handler, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -409,5 +501,9 @@ int pldm_mctp_responder_init(void) pldm_add_cmd(&pldm_base_type, &pldm_base_get_commands); pldm_add_cmd(&pldm_base_type, &pldm_base_get_version); + /* Register platform commands we'll respond to - DSP0248 */ + pldm_add_type(&pldm_platform_type); + pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver); + return OPAL_SUCCESS; } diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index d27220f3..5b2e6403 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -12,6 +12,8 @@ /* Common support */ void printbuf(const char *name, const char *msg, int len); +extern bool watchdog_armed; +extern int watchdog_period_sec; /* * EID is the MCTP endpoint ID, which aids in routing MCTP packets. From patchwork Tue Apr 19 13:46:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618950 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=tDePAGVM; 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 4KjQ9t5Mvsz9sGZ for ; Tue, 19 Apr 2022 23:48:18 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ9t49t6z3bgS for ; Tue, 19 Apr 2022 23:48:18 +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=tDePAGVM; 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.158.5; 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=tDePAGVM; dkim-atps=neutral Received: from mx0a-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 4KjQ8J1Pl5z3bbk for ; Tue, 19 Apr 2022 23:46:55 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JCHpjf017645 for ; Tue, 19 Apr 2022 13:46:38 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=+fldQe9pQiEKgfh3SJge993T5S92kdiNtSLiQ12o/Kk=; b=tDePAGVMJo/bTPKCVc6tIYx1kMflGDk0dJEJbPUEENopo6CPB9nVTjf2HsJ2UzSkk9eJ tnPog4vLEakKajS+0Ym3EtHhoQQZ2AF48mrblgS20+6Qj2LQIopGfqyTlHRgokL74nMz VzbYNt4yfQyI6VPKtVkL5AcRji+mBehOd+BvZhx760nMo2hM0focxzKPqBU7kNj36MGs 3Uj6WKcRVHbxET5E8rduHtYdnJfELOZcp6gnIUsL3t1KKps1cYdzYME5Q8ja811bpU1V We8oLzZS+o2bE8I3/njMNtxkCigKS0q3tTyPo9bYMiuSeIaWNYwtTvHfC7RdpySx4gdl Ug== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fhr3yrxaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDb4g0007749 for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3ffne8ujyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:36 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkYRm49611146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43EB411C04C for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 24A8211C052 for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:22 +0200 Message-Id: <20220419134633.42098-5-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: eIQ3Hz5noT4EzJ1BTfaTO1EutFHVij8Q X-Proofpoint-ORIG-GUID: eIQ3Hz5noT4EzJ1BTfaTO1EutFHVij8Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 03/14] core/pldm: Decode the PlatformEventMessage 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" PLDM Event Messages are sent as PLDM request messages to the Event Receiver using the PlatformEventMessage command. The Event Receiver acknowledges receiving the PLDM Event Message in the response to this command. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 232447e2..bd1ac6dc 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "pldm.h" @@ -461,6 +462,95 @@ static struct pldm_cmd pldm_platform_set_event_receiver = { .handler = platform_set_event_receiver_handler, }; +struct event_message_req { + uint8_t format_version; + uint8_t tid; + uint8_t event_class; + size_t event_data_offset; +}; + +/* + * PlatformEventMessage (0x10) + * PLDM Event Messages are sent as PLDM request messages to the Event + * Receiver using the PlatformEventMessage command. + */ +static int platform_event_message(const struct pldm_rx_data *req) +{ + char response_msg[PKT_SIZE(struct pldm_platform_event_message_resp)]; + struct event_message_req message_req; + uint8_t cc = PLDM_SUCCESS; + int rc; + + /* decode PlatformEventMessage request data */ + rc = decode_platform_event_message_req( + req->msg, + sizeof(struct event_message_req), + &message_req.format_version, + &message_req.tid, + &message_req.event_class, + &message_req.event_data_offset); + if (rc) { + prlog(PR_ERR, "Failed to decode PlatformEventMessage request, rc = %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + prlog(PR_DEBUG, "%s - format_version: %d, " + "tid: %d " + "event_class: %d " + "event_data_offset: 0x%lx\n", + __func__, + message_req.format_version, + message_req.tid, + message_req.event_class, + message_req.event_data_offset); + + /* we don't support any other event than the PDR Repo Changed event */ + if ((message_req.event_class != PLDM_PDR_REPOSITORY_CHG_EVENT) && + (message_req.event_class != PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE)) { + prlog(PR_ERR, "%s - Invalid event class %d in platform event handler\n", + __func__, message_req.event_class); + cc = PLDM_ERROR; + } + + rc = encode_platform_event_message_resp( + req->hdrinf.instance, + cc, + PLDM_EVENT_NO_LOGGING, + (struct pldm_msg *)response_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode PlatformEventMessage Error, rc: %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_send(req->source_eid, response_msg, sizeof(response_msg)); + if (rc) { + prlog(PR_ERR, "Failed to send PlatformEventMessage response, rc = %d\n", rc); + return OPAL_HARDWARE; + } + + /* invoke the appropriate callback handler */ + if (message_req.event_class != PLDM_PDR_REPOSITORY_CHG_EVENT) { + /* FIXME */ + } + + if (message_req.event_class != PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE) { + /* FIXME */ + } + + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_event_message = { + .name = "PLDM_PLATFORM_EVENT_MESSAGE", + .pldm_cmd_id = PLDM_PLATFORM_EVENT_MESSAGE, + .handler = platform_event_message, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -504,6 +594,7 @@ int pldm_mctp_responder_init(void) /* Register platform commands we'll respond to - DSP0248 */ pldm_add_type(&pldm_platform_type); pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver); + pldm_add_cmd(&pldm_platform_type, &pldm_platform_event_message); return OPAL_SUCCESS; } From patchwork Tue Apr 19 13:46:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618948 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=KLVVpaj9; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjQ9Z509fz9sGZ for ; Tue, 19 Apr 2022 23:48:02 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ9Z3vV0z3bYh for ; Tue, 19 Apr 2022 23:48:02 +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=KLVVpaj9; 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.158.5; 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=KLVVpaj9; dkim-atps=neutral Received: from mx0a-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 4KjQ894DYJz3bWR for ; Tue, 19 Apr 2022 23:46:49 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JDCW45017640 for ; Tue, 19 Apr 2022 13:46:38 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=gS/lsuVh+yNpVr1YR5oqScRVipKWGPxIsha/hBtAuyQ=; b=KLVVpaj98U60p05wdDSE0bLdmC4ueU21TI7Vj43ARHGNCZfgyZP9qQ6tHougRZxA21cW 28KPBFlmQahqaqWnlZ945cCkz7ilPZdqV+N2xa4q4blsxh/j9PaefZa2vdm9mayuT9L8 2P3ZY8QDG/8kVzkmf0rvjLwhaw1aqFJnIQrwpLsI0zv1tdlFqlTu9nMKPWlDt5Po0i6r s0ut0zqfV7to8mx1ukx07M3kCliY/xXATQ10X9KnDtkG8QwfVltD1MCbE4jp1nJrTPuo iFJaCfxeUwl4u/DBtaVE7tw8tSQYN5Ibo6QZNLis9voHwwsnBpTPed88lPBYbhl/LCJd Yg== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fhr3yrxat-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDb2du005418 for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 3ffne93jt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:36 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkYtO52166996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7175611C04C for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 522D311C04A for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:23 +0200 Message-Id: <20220419134633.42098-6-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VsaYAfeJr4Uve1k1jq3_Gw5ivHq_Rv6W X-Proofpoint-ORIG-GUID: VsaYAfeJr4Uve1k1jq3_Gw5ivHq_Rv6W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 04/14] core/pldm: Decode the GetStateSensorReadings 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 GetStateSensorReadings command can return readings for multiple state sensors (a PLDM State Sensor that returns more than one set of state information is called a composite state sensor). The Event Receiver acknowledges receiving the PLDM Event Message in the response to this command. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 80 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index bd1ac6dc..8355df19 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -551,6 +551,85 @@ static struct pldm_cmd pldm_platform_event_message = { .handler = platform_event_message, }; +struct get_state_sensor_readings_req { + uint16_t sensor_id; + bitfield8_t sensor_rearm; + uint8_t reserved; +}; + +/* + * GetStateSensorReadings (0x21) + * The GetStateSensorReadings command can return readings for multiple + * state sensors (a PLDM State Sensor that returns more than one set of + * state information is called a composite state sensor). + */ +static int platform_get_state_sensor_readings(const struct pldm_rx_data *req) +{ + struct get_state_sensor_readings_req readings_req; + size_t response_length; + char *response_msg; + int rc; + + get_sensor_state_field sensor_state = { + .sensor_op_state = PLDM_SENSOR_UNKNOWN, + .present_state = 0, + .previous_state = 0, + .event_state = 0 + }; + + /* decode GetStateSensorReadings request data */ + rc = decode_get_state_sensor_readings_req( + req->msg, + PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES, + &readings_req.sensor_id, + &readings_req.sensor_rearm, + &readings_req.reserved); + if (rc) { + prlog(PR_ERR, "Failed to decode GetStateSensorReadings request, rc = %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + prlog(PR_DEBUG, "%s - sensor_id: %d, sensor_rearm: %x\n", + __func__, readings_req.sensor_id, + readings_req.sensor_rearm.byte); + + /* send state sensor reading response */ + response_length = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_state_sensor_readings_resp) + + (sizeof(get_sensor_state_field) * 1); + response_msg = malloc(response_length); + + rc = encode_get_state_sensor_readings_resp( + req->hdrinf.instance, + PLDM_SUCCESS, + 1, /* sensor count of 1 */ + &sensor_state, + (struct pldm_msg *)response_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetStateSensorReadings response Error, rc: %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_send(req->source_eid, response_msg, sizeof(response_msg)); + if (rc) { + prlog(PR_ERR, "Failed to send GetStateSensorReadings response, rc = %d\n", rc); + return OPAL_HARDWARE; + } + + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_get_state_sensor_readings = { + .name = "PLDM_GET_STATE_SENSOR_READINGS", + .pldm_cmd_id = PLDM_GET_STATE_SENSOR_READINGS, + .handler = platform_get_state_sensor_readings, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -595,6 +674,7 @@ int pldm_mctp_responder_init(void) pldm_add_type(&pldm_platform_type); pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver); pldm_add_cmd(&pldm_platform_type, &pldm_platform_event_message); + pldm_add_cmd(&pldm_platform_type, &pldm_platform_get_state_sensor_readings); return OPAL_SUCCESS; } From patchwork Tue Apr 19 13:46:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618941 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=Hpp2sxwb; 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 4KjQ8Z5sMjz9sGZ for ; Tue, 19 Apr 2022 23:47:10 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ8Z4jzPz3bbj for ; Tue, 19 Apr 2022 23:47:10 +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=Hpp2sxwb; 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=Hpp2sxwb; 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 4KjQ823WWbz2xrb for ; Tue, 19 Apr 2022 23:46:42 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JDgxmI003584 for ; Tue, 19 Apr 2022 13:46:39 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=F6t/2FEoAyDX9cTQfJBHO/WYhuV7GdFUI21kZWDWvng=; b=Hpp2sxwb7JAGs1+WFQOAwcTzs2M8uGX6LjKhRSuSefRtPf09neBTlk4rc3pIp8jvcaQB 0XosTUNtzUZMl1g8ONqv2Mfi58fNoEI2OcLhylzlReI5jZ8mDKzDmXW25Xn2bZYYe2sO cIHSNXtxTtDuUzY1AmBj6rSL3UDiF7Yb3xpdQ4m7mA3ocoUc6vfrdZcGSlN0a57iSMhm c6iQrqt8CzBey3k3+Y5W+2vUu2IGReJ5akF3RifEpU3MElTnChE3hMA6t+2axtqlyN2r IMidAil8eAqcQuWqnIMT9+LtJUTg2h2KojGrcV+4BkEizs8bVLZ+C4uIAOe3R2y+Bxgp ig== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7btqdaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:39 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbD9H012617 for ; Tue, 19 Apr 2022 13:46:37 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3ffne8mft4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkYU752166998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F78711C04C for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F99A11C04A for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:24 +0200 Message-Id: <20220419134633.42098-7-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: S4ohQQKtVuhyGWUT2o4zyH_WJ9sB6GsX X-Proofpoint-ORIG-GUID: S4ohQQKtVuhyGWUT2o4zyH_WJ9sB6GsX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 05/14] core/pldm: Decode the SetStateEffecterStates 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 SetStateEffecterStates command is used to set the state of one or more effecters within a PLDM State Effecter. The field comp_effecter_count indicates the number of individual sets of state effecter information that are accessed by this command. The Event Receiver acknowledges receiving the PLDM Event Message in the response to this command. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 129 +++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 8355df19..9a2624c4 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -8,8 +8,11 @@ #include #include #include +#include +#include #include #include +#include #include #include "pldm.h" @@ -630,6 +633,131 @@ static struct pldm_cmd pldm_platform_get_state_sensor_readings = { .handler = platform_get_state_sensor_readings, }; +#define SOFT_OFF 0x00 +#define SOFT_REBOOT 0x01 +#define CHASSIS_PWR_DOWN 0x00 + +struct effecter_states_req { + uint16_t effecter_id; + uint8_t comp_effecter_count; + set_effecter_state_field field[8]; +}; + +/* + * SetStateEffecterStates (0x39) + * The SetStateEffecterStates command is used to set the state of one + * or more effecters within a PLDM State Effecter. + */ +static int platform_set_state_effecter_states_handler(const struct pldm_rx_data *req) +{ + struct effecter_states_req states_req; + set_effecter_state_field *field; + int rc, i; + + /* decode SetStateEffecterStates request data */ + rc = decode_set_state_effecter_states_req( + req->msg, + PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES, + &states_req.effecter_id, + &states_req.comp_effecter_count, + states_req.field); + if (rc) { + prlog(PR_ERR, "Failed to decode SetStateEffecterStates request, rc = %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + /* invoke the appropriate callback handler */ + prlog(PR_DEBUG, "%s - effecter_id: %d, comp_effecter_count: %d\n", + __func__, + states_req.effecter_id, + states_req.comp_effecter_count); + + for (i = 0; i < states_req.comp_effecter_count; i++) { + field = states_req.field; + + /* other set_request not supported */ + if (field->set_request != PLDM_REQUEST_SET) { + prlog(PR_ERR, "Got invalid set request 0x%x in " + "SetStateEffecterStates request\n", + field->set_request); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_STATE_VALUE); + return OPAL_PARAMETER; + } + + switch (field->effecter_state) { + case PLDM_SW_TERM_GRACEFUL_SHUTDOWN_REQUESTED: + case PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL: + prlog(PR_NOTICE, "Soft shutdown requested\n"); + pldm_cc_resp(req, PLDM_PLATFORM, + PLDM_SET_STATE_EFFECTER_STATES, + PLDM_SUCCESS); + + if (opal_booting() && platform.cec_power_down) { + prlog(PR_NOTICE, "Host not up, shutting down now\n"); + platform.cec_power_down(CHASSIS_PWR_DOWN); + } else { + opal_queue_msg(OPAL_MSG_SHUTDOWN, + NULL, NULL, + cpu_to_be64(SOFT_OFF)); + } + + break; + + case PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED: + prlog(PR_NOTICE, "Soft reboot requested\n"); + pldm_cc_resp(req, PLDM_PLATFORM, + PLDM_SET_STATE_EFFECTER_STATES, + PLDM_SUCCESS); + + if (opal_booting() && platform.cec_reboot) { + prlog(PR_NOTICE, "Host not up, rebooting now\n"); + platform.cec_reboot(); + } else { + opal_queue_msg(OPAL_MSG_SHUTDOWN, + NULL, NULL, + cpu_to_be64(SOFT_REBOOT)); + } + + break; + + case PLDM_STATE_SET_BOOT_RESTART_CAUSE_WARM_RESET: + case PLDM_STATE_SET_BOOT_RESTART_CAUSE_HARD_RESET: + prlog(PR_NOTICE, "OCC reset requested\n"); + pldm_cc_resp(req, PLDM_PLATFORM, + PLDM_SET_STATE_EFFECTER_STATES, + PLDM_SUCCESS); + + /* invoke the appropriate callback handler */ + /* FIXME */ + break; + + default: + prlog(PR_ERR, "Got invalid effecter state 0x%x in " + "SetStateEffecterStates request\n", + field->effecter_state); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_STATE_VALUE); + return OPAL_PARAMETER; + } + + /* next */ + field++; + } + + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_set_state_effecter_states = { + .name = "PLDM_SET_STATE_EFFECTER_STATES", + .pldm_cmd_id = PLDM_SET_STATE_EFFECTER_STATES, + .handler = platform_set_state_effecter_states_handler, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -675,6 +803,7 @@ int pldm_mctp_responder_init(void) pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_event_receiver); pldm_add_cmd(&pldm_platform_type, &pldm_platform_event_message); pldm_add_cmd(&pldm_platform_type, &pldm_platform_get_state_sensor_readings); + pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_state_effecter_states); return OPAL_SUCCESS; } From patchwork Tue Apr 19 13:46:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618944 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=H6PGNZYT; 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 4KjQ912wDvz9sGZ for ; Tue, 19 Apr 2022 23:47:33 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ911l3lz3bbG for ; Tue, 19 Apr 2022 23:47:33 +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=H6PGNZYT; 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.158.5; 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=H6PGNZYT; dkim-atps=neutral Received: from mx0a-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 4KjQ846G04z2yPj for ; Tue, 19 Apr 2022 23:46:44 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JCc2OJ017702 for ; Tue, 19 Apr 2022 13:46:39 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=qaa3ahVb9e/OibTcbYxpepqJm6JTG62h4SssgYVbag0=; b=H6PGNZYTzR/S+yxCU41VB54KWn8Nuc27v0TAwebJ8UQIcd+15SR+T95T1HiuDXVRVOOg 0tWhVbJ56dOOAG40NJ0Nqr+nOxioN1Kdljjgnvw+HUrdO1Q+qUrtNxyKzMKL36nxayfR xd0NZ0G4V6f8ai4vgCn5T6bA26N42zHlyu1MEcF1o+iIiEjNBXFILEuS3PXUgYLbOp2L l6GL/FTfpl/TZn2LGuFrOQmRnkrfblFL79UzFeuZibBm86a/FppIe2FBvjFxAHkP+gCF DYp0Obk1psLWkc3ETfD778v+FRY72lI6O1CSrcRPRpjrrmcuwK7gH6mnBUXulBP4PigY jQ== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fhr3yrxav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +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 23JDbD1h027498 for ; Tue, 19 Apr 2022 13:46:37 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06fra.de.ibm.com with ESMTP id 3ffn2huk23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkYlN52167000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE7C611C04C for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE67F11C04A for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:25 +0200 Message-Id: <20220419134633.42098-8-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6O2lC6FTxZmFpECBllH0vdpBkWgyTarB X-Proofpoint-ORIG-GUID: 6O2lC6FTxZmFpECBllH0vdpBkWgyTarB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 06/14] core/pldm: Find PDR record by record handle 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" Add a wrapper for the libpldm api: pldm_pdr_find_record() Signed-off-by: Christophe Lombard --- core/pldm/pldm-platform-requests.c | 22 ++++++++++++++++++++++ core/pldm/pldm.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c index 223f810a..0d0a6369 100644 --- a/core/pldm/pldm-platform-requests.c +++ b/core/pldm/pldm-platform-requests.c @@ -32,6 +32,28 @@ static void pdr_init_complete(bool success) pdr_ready = true; } +/* + * Find PDR record by record handle. + */ +int pldm_platform_pdr_find_record(uint32_t record_handle, + uint8_t **pdr_data, + uint32_t *pdr_data_size, + uint32_t *next_record_handle) +{ + const pldm_pdr_record *pdr_record; + + pdr_record = pldm_pdr_find_record(repo, + record_handle, + pdr_data, + pdr_data_size, + next_record_handle); + + if (!pdr_record) + return OPAL_PARAMETER; + + return OPAL_SUCCESS; +} + /* * Search the matching record and return the effecter id. * PDR type = PLDM_STATE_EFFECTER_PDR diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index 5b2e6403..c7dd21f5 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -80,6 +80,10 @@ int pldm_bios_init(void); int pldm_base_get_tid_req(void); +int pldm_platform_pdr_find_record(uint32_t record_handle, + uint8_t **pdr_data, + uint32_t *pdr_data_size, + uint32_t *next_record_handle); void pldm_platform_exit(void); int pldm_platform_init(void); From patchwork Tue Apr 19 13:46:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618951 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=FKiEkKRs; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjQB1621gz9sGZ for ; Tue, 19 Apr 2022 23:48:25 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQB14Wr2z3bZd for ; Tue, 19 Apr 2022 23:48:25 +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=FKiEkKRs; 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.158.5; 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=FKiEkKRs; dkim-atps=neutral Received: from mx0a-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 4KjQ8K0Pfdz2ypZ for ; Tue, 19 Apr 2022 23:46:56 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JBelL2009459 for ; Tue, 19 Apr 2022 13:46:39 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=znXupr7IdWKPqcurgzYzYu1kmLULdDvwaosEteTPv2g=; b=FKiEkKRsGgrtga5StvIo3OVEQeP/fIgtht33p8nllnRutZIq5IjnscFD0fSeHWvMEMwe t+7rQoJhaIX9g4GS58/nFWylTICwPKitFQMHkLZmA+D/ywynHshXo/K1JzLXqyyG83vo +acGgU6iZ4+GYkKn3jsNabj6qzG6SsO+DBWbjk0S8J1tqgluIkGmdmifbRQ4Y7SXmhWE hfbFG882sxbc0T9MrRVPuBQt2YMGwpuLBHlWSWgdmNnM/b1RAxQbvQz1Dd76VZaJEYH0 m/nN/jabQ/zsSQoigbox8Nh6PjgYlUZRkcIFmaLRcZ/VFbu8dqTFn2YCWtIMWLqGX3j1 5w== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fg7668qqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:39 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDblBI019034 for ; Tue, 19 Apr 2022 13:46:37 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 3ffvt9b6xn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkZEa52167002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:35 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0858611C04C for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCAED11C04A for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:34 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:26 +0200 Message-Id: <20220419134633.42098-9-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RaOcSzdcia08HRCzUYXjuSz5MVE8w0Yn X-Proofpoint-GUID: RaOcSzdcia08HRCzUYXjuSz5MVE8w0Yn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 07/14] core/pldm: Encode PLDM PDR Repository Change eventData 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" Encode the platform PDR repository change event message request that tells the BMC that a specific PDR entry has changed. Signed-off-by: Christophe Lombard --- core/pldm/pldm-platform-requests.c | 116 +++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c index 0d0a6369..34ec1335 100644 --- a/core/pldm/pldm-platform-requests.c +++ b/core/pldm/pldm-platform-requests.c @@ -54,6 +54,122 @@ int pldm_platform_pdr_find_record(uint32_t record_handle, return OPAL_SUCCESS; } +static int send_repository_changed_event(uint32_t num_changed_pdrs, + uint32_t *record_handle) +{ + size_t actual_change_records_size = 0; + uint8_t number_of_change_entries[1]; + size_t max_change_records_size = 0; + size_t response_len, payload_len; + uint8_t event_data_operation[1]; + uint32_t *change_entries[1]; + uint8_t *event_data = NULL; + uint32_t request_length; + void *response_msg; + char *request_msg; + int rc, i; + + struct pldm_platform_event_message_req event_message_req = { + .format_version = PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION, + .tid = HOST_TID, + .event_class = PLDM_PDR_REPOSITORY_CHG_EVENT, + }; + + struct pldm_platform_event_message_resp response; + + prlog(PR_DEBUG, "%s - num_changed_pdrs: %d, record_handle: %d\n", + __func__, num_changed_pdrs, *record_handle); + + /* encode the platform change event data */ + event_data_operation[0] = PLDM_RECORDS_ADDED; + number_of_change_entries[0] = num_changed_pdrs; + change_entries[0] = record_handle; + + /* + * The first time around this loop, event_data is nullptr which + * instructs the encoder to not actually do the encoding, but + * rather fill out actual_change_records_size with the correct + * size, stop and return PLDM_SUCCESS. Then we allocate the + * proper amount of memory and call the encoder again, which + * will cause it to actually encode the message. + */ + for (i = 0; i < 2; i++) { + rc = encode_pldm_pdr_repository_chg_event_data( + FORMAT_IS_PDR_HANDLES, + 1, /* only one change record (RECORDS_ADDED) */ + event_data_operation, + number_of_change_entries, + (const uint32_t * const*)change_entries, + (struct pldm_pdr_repository_chg_event_data *)event_data, + &actual_change_records_size, + max_change_records_size); + if (rc) { + prlog(PR_ERR, "Encode PldmPdrRepositoryChgEventData Error, rc: %d\n", rc); + return OPAL_PARAMETER; + } + + if (event_data == NULL) { + max_change_records_size = actual_change_records_size; + event_data = malloc(max_change_records_size); + } + } + + /* Send the event request */ + payload_len = PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + max_change_records_size; + + request_length = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_platform_event_message_req) + + max_change_records_size; + request_msg = malloc(request_length); + + /* Encode the platform event message request */ + rc = encode_platform_event_message_req( + DEFAULT_INSTANCE_ID, + event_message_req.format_version, + event_message_req.tid, + event_message_req.event_class, + (const uint8_t *)event_data, + max_change_records_size, + (struct pldm_msg *)request_msg, + payload_len); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode PlatformEventMessage Error, rc: %d\n", rc); + free(event_data); + free(request_msg); + return OPAL_PARAMETER; + } + free(event_data); + + /* Send and get the response message bytes */ + rc = pldm_do_request(BMC_EID, request_msg, request_length - 1, + &response_msg, &response_len); + if (rc) { + prlog(PR_ERR, "Communication Error, req: PlatformEventMessage, rc: %d\n", rc); + free(request_msg); + return rc; + } + free(request_msg); + + /* Decode the message */ + payload_len = response_len - sizeof(struct pldm_msg_hdr); + rc = decode_platform_event_message_resp( + response_msg, + payload_len, + &response.completion_code, + &response.platform_event_status); + if (rc != PLDM_SUCCESS || response.completion_code != PLDM_SUCCESS) { + prlog(PR_ERR, "Decode PlatformEventMessage Error, rc: %d, cc: %d, pes: %d\n", + rc, response.completion_code, + response.platform_event_status); + free(response_msg); + return OPAL_PARAMETER; + } + + free(response_msg); + + return OPAL_SUCCESS; +} + /* * Search the matching record and return the effecter id. * PDR type = PLDM_STATE_EFFECTER_PDR From patchwork Tue Apr 19 13:46:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618940 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=Iv3OlAD/; 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 4KjQ8R5tm0z9sGZ for ; Tue, 19 Apr 2022 23:47:03 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ8R56g2z2ynr for ; Tue, 19 Apr 2022 23:47:03 +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=Iv3OlAD/; 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=Iv3OlAD/; 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 4KjQ823XdRz2yPj for ; Tue, 19 Apr 2022 23:46:42 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JCWBhD023329 for ; Tue, 19 Apr 2022 13:46:40 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=t3HTGsnc3331nCKZ11uq4gC6oSci7a3vcc5Sq2AScbo=; b=Iv3OlAD/YbNC3nCdRwpWlRIYQhtAcqRHpyQ9Um4ZvVPAnDWzKUKP3sOwJ1K6KmjxA7hw uWj4Y3DSSKLiyzbFbRkT2F/q667baCAJDDqIsqQ/W9ogoDK+At5phoyCyuTVJme8KeeF oPwBoXc3KdjvpcrtQUXCb5XkZ55wYRU7koIKx4SWRNHWTet6NT7d+AFCn1VhIP0BIy8T xmgn/qOJJLsvy1O5Q9BLRNjIPon3LVmIngqzzVlcl66F5qtkMA/imk3Kj4QlVHFbEs2j hKw8Pe85KKmM4sXSQoCP+48srdstLudB3aYNbI4BvrXTiXuV7TOleA78KRUq6pTlwoZC YA== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7ct8d5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:39 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDb2Nf006056 for ; Tue, 19 Apr 2022 13:46:37 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma02fra.de.ibm.com with ESMTP id 3fgu6u21qb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkZsp52167004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:35 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 368FB11C04A for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 168C111C050 for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:27 +0200 Message-Id: <20220419134633.42098-10-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zXwGTErDBt5Aeg6JrYmFaXz9uU-nnQj5 X-Proofpoint-ORIG-GUID: zXwGTErDBt5Aeg6JrYmFaXz9uU-nnQj5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 08/14] core/pldm: Update or create terminus locator in the given repo 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 Terminus Locator PDR forms the association between a TID and PLDM Terminus Handle for a terminus. This patch allows to add terminus locator record in the repository. If a record matches with the Host TID, we activate the current terminus locator record, otherwise a new record is created. Signed-off-by: Christophe Lombard --- core/pldm/pldm-platform-requests.c | 121 +++++++++++++++++++++++++++++ include/pldm.h | 5 ++ 2 files changed, 126 insertions(+) diff --git a/core/pldm/pldm-platform-requests.c b/core/pldm/pldm-platform-requests.c index 34ec1335..20715685 100644 --- a/core/pldm/pldm-platform-requests.c +++ b/core/pldm/pldm-platform-requests.c @@ -14,6 +14,8 @@ #include "pldm.h" #define NO_MORE_PDR_HANDLES 0 +#define PDR_AUTO_CALCULATE_RECORD_HANDLE 0 +static bool PDR_IS_NOT_REMOTE; static pldm_pdr *repo; static bool pdr_ready; @@ -54,6 +56,92 @@ int pldm_platform_pdr_find_record(uint32_t record_handle, return OPAL_SUCCESS; } +/* + * The Terminus Locator PDR forms the association between a TID and + * PLDM Terminus Handle for a terminus. + */ +static void generate_terminus_locator_pdr(struct pldm_terminus_locator_pdr *pdr) +{ + uint8_t DEFAULT_CONTAINER_ID = 0; + struct pldm_terminus_locator_type_mctp_eid *locator_value; + + pdr->hdr.record_handle = 0; /* record_handle will be generated for us */ + pdr->hdr.version = 1; + pdr->hdr.type = PLDM_TERMINUS_LOCATOR_PDR; + pdr->hdr.record_change_num = 0; + pdr->hdr.length = htole16(sizeof(struct pldm_terminus_locator_pdr) - + sizeof(struct pldm_pdr_hdr)); + pdr->terminus_handle = htole16(HOST_TID); + pdr->validity = PLDM_TL_PDR_VALID; + pdr->tid = HOST_TID; + pdr->container_id = DEFAULT_CONTAINER_ID; + pdr->terminus_locator_type = PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID; + pdr->terminus_locator_value_size = sizeof(struct pldm_terminus_locator_type_mctp_eid); + locator_value = (struct pldm_terminus_locator_type_mctp_eid *)pdr->terminus_locator_value; + locator_value->eid = HOST_EID; +} + +/* + * Add terminus locator record in the repository. + */ +static uint32_t add_terminus_locator_pdr(pldm_pdr *repo) +{ + struct pldm_terminus_locator_pdr pdr; + uint32_t record_handle, size; + + /* New terminus locator record */ + generate_terminus_locator_pdr(&pdr); + + size = sizeof(struct pldm_terminus_locator_pdr) + + sizeof(struct pldm_terminus_locator_type_mctp_eid); + + record_handle = pldm_pdr_add(repo, + (const uint8_t *)(&pdr), + size, + PDR_AUTO_CALCULATE_RECORD_HANDLE, + PDR_IS_NOT_REMOTE); + + prlog(PR_DEBUG, "Add terminus locator pdr (record handle: %d)\n", record_handle); + return record_handle; +} + +/* + * Search the matching record and return the terminus locator record. + * PDR type = PLDM_TERMINUS_LOCATOR_PDR + */ +static struct pldm_terminus_locator_pdr *find_terminus_locator_pdr(pldm_pdr *repo) +{ + struct pldm_terminus_locator_pdr *terminus_locator_pdr = NULL; + const pldm_pdr_record *record = NULL; + uint16_t terminus_handle; + uint8_t *outData = NULL; + uint32_t size; + + do { + /* Find (first) PDR record by PLDM_STATE_EFFECTER_PDR type + * if record not NULL, then search will begin from this + * record's next record + */ + record = pldm_pdr_find_record_by_type( + repo, /* PDR repo handle */ + PLDM_TERMINUS_LOCATOR_PDR, + record, /* PDR record handle */ + &outData, &size); + + if (record) { + terminus_locator_pdr = (struct pldm_terminus_locator_pdr *)outData; + + terminus_handle = le16_to_cpu(terminus_locator_pdr->terminus_handle); + + if (terminus_handle == HOST_TID) + return terminus_locator_pdr; + } + + } while (record); + + return NULL; +} + static int send_repository_changed_event(uint32_t num_changed_pdrs, uint32_t *record_handle) { @@ -170,6 +258,39 @@ static int send_repository_changed_event(uint32_t num_changed_pdrs, return OPAL_SUCCESS; } +/* + * Update or create terminus locator in the given repo. + */ +int pldm_platform_terminus_locator_pdr(void) +{ + struct pldm_terminus_locator_pdr *terminus_locator_pdr; + uint32_t record_handle; + int rc; + + /* find current terminus locator record */ + terminus_locator_pdr = find_terminus_locator_pdr(repo); + + if (terminus_locator_pdr) { + /* activate the current terminus locator record */ + terminus_locator_pdr->validity = PLDM_TL_PDR_VALID; + record_handle = le32_to_cpu(terminus_locator_pdr->hdr.record_handle); + } else { + /* create a terminus locator record */ + record_handle = add_terminus_locator_pdr(repo); + } + + /* Tell BMC that this PDR has changed */ + prlog(PR_DEBUG, "%s - Tell BMC that this PDR has changed (record handle: %d)\n", + __func__, record_handle); + + rc = send_repository_changed_event(1, &record_handle); + if (rc) + prlog(PR_ERR, "%s - Failed to update terminux locator PRD\n", + __func__); + + return rc; +} + /* * Search the matching record and return the effecter id. * PDR type = PLDM_STATE_EFFECTER_PDR diff --git a/include/pldm.h b/include/pldm.h index 01af9a33..e2904c41 100644 --- a/include/pldm.h +++ b/include/pldm.h @@ -17,6 +17,11 @@ int pldm_mctp_init(void); */ void pldm_mctp_exit(void); +/** + * Update or create terminus locator in the given repo + */ +int pldm_platform_terminus_locator_pdr(void); + /** * Send a system chassis Off-Soft Graceful request */ From patchwork Tue Apr 19 13:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618939 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=RxC0cZxw; 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 4KjQ8L0NRRz9sGZ for ; Tue, 19 Apr 2022 23:46:58 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ8K6QKQz3bcB for ; Tue, 19 Apr 2022 23:46:57 +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=RxC0cZxw; 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.158.5; helo=mx0b-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=RxC0cZxw; dkim-atps=neutral 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 4KjQ8209GXz2xnM for ; Tue, 19 Apr 2022 23:46:41 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JClkWx012668 for ; Tue, 19 Apr 2022 13:46:39 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=IrPcPMEzvO2bAxIWIIeM0mq73OJwJq+Wd2dCtRf3SGY=; b=RxC0cZxw4a+kRXdXouWMGN4l8MA7B6Vs69UTdwFhjlcsFWxOCttsLCb7gTOM1fXiQDm/ szSiNeaSPwec1w1WZVZQim15Jytkg/DmPBic92bnJOrv2lU4RgoeUlJAbC+OIAu+wcH+ dwmJN8gE3xLTBQsoYPaurDPcMmX1fwR8TwQyC8Ymudm0Ti88o9Zs7GEva18wJCkx5tpb TKtTbV6qvriaab9dzJWaSjrHpG1K+w3kqnOLJKJAQqNdSFWnT9wj269xP9YRZ3Uiinay xR7pnpjTvBMe/q/eIN4gO1InepbpQ/hwLqBV6mEs7ksN1dhBw6zg+ohQtb2CGm7fbqy2 Jw== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7kag5fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:39 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbOUP030917 for ; Tue, 19 Apr 2022 13:46:37 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3ffne94fus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkZuW52167006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:35 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6426611C04A for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4504411C04C for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:28 +0200 Message-Id: <20220419134633.42098-11-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: g4OJmK03k7T0waAAqSn7HLptdf6rtf5e X-Proofpoint-GUID: g4OJmK03k7T0waAAqSn7HLptdf6rtf5e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 priorityscore=1501 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 09/14] core/pldm: Decode the GetPDR 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 GetPDR command is used to retrieve individual PDRs from a PDR repository. The record is identified by the PDR recordHandle value that is passed in the request. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 123 +++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 9a2624c4..69d411f9 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -758,6 +758,128 @@ static struct pldm_cmd pldm_platform_set_state_effecter_states = { .handler = platform_set_state_effecter_states_handler, }; +struct get_pdr_req { + uint32_t record_handle; + uint32_t data_transfer_handle; + uint8_t transfer_op_flag; + uint16_t request_count; + uint16_t record_change_number; +}; + +/* + * GetPDR (0x51) + * The GetPDR command is used to retrieve individual PDRs from a PDR + * Repository. The record is identified by the PDR recordHandle value + * that is passed in the request. + */ +static int platform_get_pdr_handle(const struct pldm_rx_data *req) +{ + size_t payload_len, response_length; + uint32_t next_record_handle; + struct get_pdr_req pdr_req; + uint8_t *pdr_data = NULL; + uint32_t pdr_data_size = 0; + char *response_msg; + int rc; + + payload_len = req->msg_len - sizeof(struct pldm_msg_hdr); + rc = decode_get_pdr_req(req->msg, + payload_len, + &pdr_req.record_handle, + &pdr_req.data_transfer_handle, + &pdr_req.transfer_op_flag, + &pdr_req.request_count, + &pdr_req.record_change_number); + if (rc) { + prlog(PR_ERR, "Failed to decode GetPDR request, rc = %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + if (pdr_req.data_transfer_handle != 0) { + /* We don't support multipart transfers */ + prlog(PR_ERR, "Got invalid data transfer handle 0x%x in GetPDR request\n", + pdr_req.data_transfer_handle); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE); + return OPAL_PARAMETER; + } + + if (pdr_req.transfer_op_flag != PLDM_GET_FIRSTPART) { + prlog(PR_ERR, "Got invalid transfer op flag 0x%x in GetPDR request\n", + pdr_req.transfer_op_flag); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG); + return OPAL_PARAMETER; + } + + if (pdr_req.record_change_number != 0) { + prlog(PR_ERR, "Got invalid record change number 0x%x in GetPDR request\n", + pdr_req.record_change_number); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER); + return OPAL_PARAMETER; + } + + /* find PDR record by record handle */ + prlog(PR_INFO, "BMC requesting PDR handle %d\n", pdr_req.record_handle); + + rc = pldm_platform_pdr_find_record(pdr_req.record_handle, + &pdr_data, + &pdr_data_size, + &next_record_handle); + if (rc) { + prlog(PR_ERR, "Got invalid record handle 0x%x in GetPDR request\n", + pdr_req.record_handle); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, + PLDM_PLATFORM_INVALID_RECORD_HANDLE); + return OPAL_PARAMETER; + } + + response_length = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_pdr_resp) + + pdr_data_size; + response_msg = malloc(response_length); + memset(response_msg, 0, response_length); + + /* create a PLDM response message for GetPDR */ + rc = encode_get_pdr_resp(req->hdrinf.instance, + PLDM_SUCCESS, + next_record_handle, + 0, /* No remaining data */ + PLDM_START_AND_END, + pdr_data_size, + pdr_data, + 0, /* CRC not used for START_AND_END */ + (struct pldm_msg *)response_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetPDR Error, rc: %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_send(req->source_eid, response_msg, response_length - 1); + if (rc) { + prlog(PR_ERR, "Failed to send GetPDR response, rc = %d\n", rc); + return OPAL_HARDWARE; + } + + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_platform_get_pdr = { + .name = "PLDM_GET_PDR", + .pldm_cmd_id = PLDM_GET_PDR, + .handler = platform_get_pdr_handle, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -804,6 +926,7 @@ int pldm_mctp_responder_init(void) pldm_add_cmd(&pldm_platform_type, &pldm_platform_event_message); pldm_add_cmd(&pldm_platform_type, &pldm_platform_get_state_sensor_readings); pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_state_effecter_states); + pldm_add_cmd(&pldm_platform_type, &pldm_platform_get_pdr); return OPAL_SUCCESS; } From patchwork Tue Apr 19 13:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618946 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=djaffCqT; 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 4KjQ9H2dNGz9sGf for ; Tue, 19 Apr 2022 23:47:47 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ9H1t40z3bcv for ; Tue, 19 Apr 2022 23:47:47 +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=djaffCqT; 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.158.5; 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=djaffCqT; dkim-atps=neutral Received: from mx0a-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 4KjQ865GLYz2yJ5 for ; Tue, 19 Apr 2022 23:46:46 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JBelL4009459 for ; Tue, 19 Apr 2022 13:46:40 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=iUOnehjmlq2M16G2LLzOHuHp2AWN7R5Wz+7YE6YWEf0=; b=djaffCqT6qmpKZf0cfwlZ+j5omiY0IZ8KOSH8NOFhRvjG3w2I12rVzglBJYinIcZOH0n /GnHN8aGoTyLZE6OxW7WF6hkGB3BurNIE4m6wAj8Aa4GPfzcJTHn+yIXRY3yS42rvOjA hioyV95YKigsY5efJ6mi/s2vyQOJTa+fabMR6Tq6bS8KnqMN9Cxwf6ODNQ1Gzn5lC/Ga b1XseY7Kk2/Csbh87AXxF37TjwvAbHIXAcZhm7DHUVEHgAlldfjOYRahyaPp0RaxylCf dtpg6MoGuwx0GobFM4E08W4Css8DQcwpoDbp1jeTMERA7Zs6828tgWLn/JA8vvQ993t2 rw== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fg7668qr0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:39 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbVMc007808 for ; Tue, 19 Apr 2022 13:46:38 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3ffne8ujyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkZ5T52167008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:35 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9208E11C04A for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71E6E11C050 for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:29 +0200 Message-Id: <20220419134633.42098-12-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bhx0r2a1qo_lTTjFRbwr9tLVlGBFl8Zu X-Proofpoint-GUID: bhx0r2a1qo_lTTjFRbwr9tLVlGBFl8Zu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 10/14] 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 | 53 ++++++++++++++++++++++ core/pldm/pldm-responder.c | 85 +++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 3 ++ 3 files changed, 141 insertions(+) diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c index eda8f939..6da1fb55 100644 --- a/core/pldm/pldm-fru-requests.c +++ b/core/pldm/pldm-fru-requests.c @@ -11,6 +11,9 @@ #include #include "pldm.h" +static void *fru_table; +static size_t fru_table_length; + static int get_fru_record_by_option_req(uint16_t fru_table_handle, uint16_t record_set_identifier, uint8_t record_type, @@ -146,3 +149,53 @@ int pldm_fru_dt_add_bmc_version(void) return OPAL_SUCCESS; } + +#define RECORD_SET_ID 100 + +void pldm_fru_add_record(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 (fru_table) { + *table_length = 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); + fru_table = malloc(fru_table_size); + + /* fill fru record data */ + record = (struct pldm_fru_record_data_format *)fru_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 *)(fru_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; + + fru_table_length = *table_length; +} diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 69d411f9..008f76b6 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -880,6 +881,86 @@ 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 *req) +{ + char response_msg[PKT_SIZE(struct pldm_get_fru_record_table_metadata_resp)]; + uint16_t total_record_set_identifiers, total_table_records; + uint32_t fru_table_length; + int rc; + + /* + * GetFRURecordTableMetadataGetFRURecordTableMetadata requests + * don't have any payload, so no need to decode them + */ + + /* add specific fru record */ + pldm_fru_add_record(&fru_table_length, + &total_record_set_identifiers, + &total_table_records); + + /* create a PLDM response message for GetFRURecordTableMetadata */ + rc = encode_get_fru_record_table_metadata_resp( + req->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 *)response_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetFRURecordTableMetadata Error, rc: %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + /* send PLDM message over MCTP */ + rc = pldm_send(req->source_eid, response_msg, sizeof(response_msg)); + if (rc) { + prlog(PR_ERR, "Failed to send GetFRURecordTableMetadata response, rc = %d\n", rc); + return OPAL_HARDWARE; + } + + 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_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -928,5 +1009,9 @@ int pldm_mctp_responder_init(void) pldm_add_cmd(&pldm_platform_type, &pldm_platform_set_state_effecter_states); pldm_add_cmd(&pldm_platform_type, &pldm_platform_get_pdr); + /* Register platform commands we'll respond to - DSP0257 */ + pldm_add_type(&pldm_fru_type); + pldm_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 c7dd21f5..fa2a1f94 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -73,6 +73,9 @@ int pldm_fru_get_record_by_option(uint16_t fru_table_handle, uint8_t record_type, uint8_t field_type, struct variable_field *fru_structure_data); +void pldm_fru_add_record(uint32_t *fru_table_length, + uint16_t *total_record_set_identifiers, + uint16_t *total_table_records); int pldm_bios_find_lid_by_attr_name(const char *name, char **lid); int pldm_bios_get_lids_id(char **lid_ids_string); From patchwork Tue Apr 19 13:46:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618945 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=PiGlPoum; 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 4KjQ981s7fz9sGZ for ; Tue, 19 Apr 2022 23:47:40 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ981M9Nz3bcX for ; Tue, 19 Apr 2022 23:47:40 +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=PiGlPoum; 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.158.5; 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=PiGlPoum; dkim-atps=neutral Received: from mx0a-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 4KjQ8555dnz2yPj for ; Tue, 19 Apr 2022 23:46:45 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JDjtar020307 for ; Tue, 19 Apr 2022 13:46:40 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=NExu0hQPrTEQnmV5/9N9c9aVcEzFH9TDUUmHYOeMlY4=; b=PiGlPoumkNEbsrt8zRSsq3Qh9FvKQQkPlJd0yptoVscZdV+elm9omRhbiGBENkrA9pSt T1meYIFKdYSPms6D8ZN92AZ/QAaOk++NAzFeZcsgHVirpRZHhNdcXqt0iTVw3QggAAou behr1cWSJgbt6aucNurEkao37O24Zbu3rgIOb4eXTCwIfHnz+3etqjx1BgMPO2mXYokt DIvcyqOWe3lqNYBaDyT6H4+Pi07QIti6fHJUF0Xytnx+HaysWCju+q5FzdWipB9oQR9c V1G2YhqwpL9Ys1Ckvq97tBPSXYXV9srFeRJ3BOjssHP2TdlEbhbcaZT0T1jDtalm8S0O 7w== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fg75qgfmg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:39 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbJ60005842 for ; Tue, 19 Apr 2022 13:46:38 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 3ffne93jt6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkZeX49611164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:35 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C076711C04A for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A080111C04C for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:30 +0200 Message-Id: <20220419134633.42098-13-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: al_nyrx2cWX9N5IAdrCKxaT8iZKjXGNR X-Proofpoint-GUID: al_nyrx2cWX9N5IAdrCKxaT8iZKjXGNR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 11/14] 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 | 74 +++++++++++++++++++++++++++++++++++ core/pldm/pldm.h | 2 + 3 files changed, 88 insertions(+) diff --git a/core/pldm/pldm-fru-requests.c b/core/pldm/pldm-fru-requests.c index 6da1fb55..863d94f9 100644 --- a/core/pldm/pldm-fru-requests.c +++ b/core/pldm/pldm-fru-requests.c @@ -199,3 +199,15 @@ void pldm_fru_add_record(uint32_t *table_length, fru_table_length = *table_length; } + +int pldm_fru_get_table(void **fru_record_table_bytes, + uint32_t *fru_record_table_size) +{ + if (!fru_table) + return OPAL_PARAMETER; + + *fru_record_table_bytes = fru_table; + *fru_record_table_size = fru_table_length; + + return OPAL_SUCCESS; +} diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 008f76b6..42d90d96 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -961,6 +961,79 @@ 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 *req) +{ + struct pldm_get_fru_record_table_resp *resp; + void *fru_record_table_bytes; + uint32_t fru_record_table_size; + size_t response_length; + struct pldm_msg *msg; + char *response_msg; + 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 fru record table */ + rc = pldm_fru_get_table(&fru_record_table_bytes, &fru_record_table_size); + if (rc) { + prlog(PR_ERR, "Failed to get Fru Record Table\n"); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + /* create a PLDM response message for GetFRURecordTable */ + response_length = sizeof(struct pldm_msg_hdr) + + sizeof(struct pldm_get_fru_record_table_resp) + + fru_record_table_size; + response_msg = malloc(response_length); + memset(response_msg, 0, response_length); + + rc = encode_get_fru_record_table_resp( + req->hdrinf.instance, + PLDM_SUCCESS, + 0, // No next transfer handle + PLDM_START_AND_END, + (struct pldm_msg *)response_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetFruRecordTable Error, rc: %d\n", rc); + pldm_cc_resp(req, req->hdrinf.pldm_type, + req->hdrinf.command, PLDM_ERROR); + return OPAL_PARAMETER; + } + + msg = (struct pldm_msg *)response_msg; + 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_send(req->source_eid, response_msg, response_length - 1); + if (rc) { + prlog(PR_ERR, "Failed to send GetFruRecordTable response, rc = %d\n", rc); + return OPAL_HARDWARE; + } + + 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_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -1012,6 +1085,7 @@ int pldm_mctp_responder_init(void) /* Register platform commands we'll respond to - DSP0257 */ pldm_add_type(&pldm_fru_type); pldm_add_cmd(&pldm_fru_type, &pldm_fru_get_record_table_metadata); + pldm_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 fa2a1f94..1273cd8a 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -76,6 +76,8 @@ int pldm_fru_get_record_by_option(uint16_t fru_table_handle, void pldm_fru_add_record(uint32_t *fru_table_length, uint16_t *total_record_set_identifiers, uint16_t *total_table_records); +int pldm_fru_get_table(void **fru_record_table_bytes, + uint32_t *fru_record_table_size); int pldm_bios_find_lid_by_attr_name(const char *name, char **lid); int pldm_bios_get_lids_id(char **lid_ids_string); From patchwork Tue Apr 19 13:46:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618952 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=FZvCoZbB; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjQB95gbkz9sGZ for ; Tue, 19 Apr 2022 23:48:33 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQB94wwbz3bmV for ; Tue, 19 Apr 2022 23:48:33 +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=FZvCoZbB; 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.158.5; helo=mx0b-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=FZvCoZbB; dkim-atps=neutral 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 4KjQ8L08BJz3bbB for ; Tue, 19 Apr 2022 23:46:57 +1000 (AEST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JCDVxW030474 for ; Tue, 19 Apr 2022 13:46:40 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=C/U4EEcD6Cfzd4LpSehrdwEYteHRlBt6vvlxHwi2tUE=; b=FZvCoZbBaHv8xn9x9XaoZC1bVTdow3jEKdokMFGVarmw2YGzypMasD9VW5evYs0R+7P4 NZ2BPmQvOIpE9N2eNFCHcRWR4on/Km7KxaA/pC/DM3u1As0V+wpmF1iAo0qfJYYcsKUe +TjvOGvkN7DFS0zJAk7C+NqEpretJYiS3pW2ZH20sE9hOMLZ/htxd4F9ZHDR4B2jBwI0 MOXZuO/Xb5srekufrpxkekg68dPCUZ29Q06q+TLFpsTkLkECqZN3VWPR2bkK55L3IbiE S1NQbCBBI3tdhvm4sMZcnCmx5UJMQsFSY7Ywn+EYnJhJGIO63c+lo8CpBQbbG/AUUrG0 7Q== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7rf88xs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:40 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDauip001063 for ; Tue, 19 Apr 2022 13:46:38 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 3ffne8ujq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkail35193140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01C5C11C04A for ; Tue, 19 Apr 2022 13:46:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF7B711C04C for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:31 +0200 Message-Id: <20220419134633.42098-14-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: siwf8vFWigFhOfN_miLy5wJfJh_Tn4Ld X-Proofpoint-ORIG-GUID: siwf8vFWigFhOfN_miLy5wJfJh_Tn4Ld X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 12/14] core/pldm: Register OPAL_RTC_READ/WRITE calls back 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" OPAL_RTC_READ/WRITE are used to retrieve and write the time. PLDM stack provides GetBiosDateTimeReq and SetBiosDateTimeReq commands to exercise. Signed-off-by: Christophe Lombard --- core/pldm/Makefile.inc | 2 +- core/pldm/pldm-bios-requests.c | 134 +++++++++++++++++++++++++++++++++ core/pldm/pldm-rtc.c | 76 +++++++++++++++++++ core/pldm/pldm.h | 3 + include/pldm.h | 5 ++ 5 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 core/pldm/pldm-rtc.c diff --git a/core/pldm/Makefile.inc b/core/pldm/Makefile.inc index 01117680..cf174c86 100644 --- a/core/pldm/Makefile.inc +++ b/core/pldm/Makefile.inc @@ -16,7 +16,7 @@ PLDM_OBJS = pldm-common.o pldm-responder.o pldm-requester.o PLDM_OBJS += pldm-base-requests.o pldm-platform-requests.o PLDM_OBJS += pldm-bios-requests.o pldm-fru-requests.o PLDM_OBJS += pldm-file-io-requests.o pldm-lid-files.o -PLDM_OBJS += pldm-watchdog.o +PLDM_OBJS += pldm-watchdog.o pldm-rtc.o PLDM = $(PLDM_DIR)/built-in.a $(PLDM): $(PLDM_OBJS:%=$(PLDM_DIR)/%) diff --git a/core/pldm/pldm-bios-requests.c b/core/pldm/pldm-bios-requests.c index 66a46bb8..09a30b2b 100644 --- a/core/pldm/pldm-bios-requests.c +++ b/core/pldm/pldm-bios-requests.c @@ -6,9 +6,11 @@ #include #include #include +#include #include #include #include +#include #include "pldm.h" /* @@ -84,6 +86,138 @@ static void bios_init_complete(bool success) bios_ready = true; } +struct get_date_time_resp { + uint8_t completion_code; + uint8_t seconds; + uint8_t minutes; + uint8_t hours; + uint8_t day; + uint8_t month; + uint16_t year; +}; + +/* + * Send/receive a PLDM GetBiosDateTime request message + */ +int pldm_bios_get_date_time_req(struct tm *tm) +{ + char request_msg[PKT_SIZE(0)]; /* the command doesn't have a message payload */ + size_t response_len, payload_len; + void *response_msg; + int rc; + + struct get_date_time_resp response; + + /* Encode the date time request */ + rc = encode_get_date_time_req( + DEFAULT_INSTANCE_ID, + (struct pldm_msg *)request_msg); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetBiosDateTimeReq 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, "Communication Error, req: GetBiosDateTimeReq, rc: %d\n", rc); + return rc; + } + + /* Decode the message */ + payload_len = response_len - sizeof(struct pldm_msg_hdr); + rc = decode_get_date_time_resp( + response_msg, + payload_len, + &response.completion_code, + &response.seconds, + &response.minutes, + &response.hours, + &response.day, + &response.month, + &response.year); + if (rc != PLDM_SUCCESS || response.completion_code != PLDM_SUCCESS) { + prlog(PR_ERR, "Decode GetBiosDateTimeReq Error, rc: %d, cc: %d\n", + rc, response.completion_code); + free(response_msg); + return OPAL_PARAMETER; + } + + /* The data arrives from BMC in BCD format. Convert it to + * decimal for processing + */ + tm->tm_sec = bcd2dec8(response.seconds); + tm->tm_min = bcd2dec8(response.minutes); + tm->tm_hour = bcd2dec8(response.hours); + tm->tm_mday = bcd2dec8(response.day); + tm->tm_mon = bcd2dec8(response.month); + tm->tm_year = bcd2dec16(response.year); + + if (!is_time_legal(tm->tm_sec, tm->tm_min, tm->tm_hour, + tm->tm_mday, tm->tm_mon, tm->tm_year)) { + prlog(PR_ERR, "Invalid date time value\n"); + free(response_msg); + return OPAL_PARAMETER; + } + + free(response_msg); + + return OPAL_SUCCESS; +} + +/* + * Send/receive a PLDM SetBiosDateTime request message + */ +int pldm_bios_set_date_time_req(struct tm *tm) +{ + char request_msg[PKT_SIZE(struct pldm_set_date_time_req)]; + size_t response_len, payload_len; + uint8_t completion_code; + void *response_msg; + int rc; + + /* Encode the date time request */ + rc = encode_set_date_time_req( + DEFAULT_INSTANCE_ID, + tm->tm_sec, tm->tm_min, tm->tm_hour, + tm->tm_mday, tm->tm_mon, tm->tm_year, + (struct pldm_msg *)request_msg, + sizeof(struct pldm_set_date_time_req)); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode SetBiosDateTimeReq 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, "Communication Error, req: SetBiosDateTimeReq, rc: %d\n", rc); + return rc; + } + + /* Decode the message */ + payload_len = response_len - sizeof(struct pldm_msg_hdr); + rc = decode_set_date_time_resp( + response_msg, + payload_len, + &completion_code); + if (rc != PLDM_SUCCESS || (completion_code > PLDM_ERROR)) { + /* FIXME: Time value from OPAL_RTC_WRITE is never correct */ + prlog(PR_ERR, "Decode SetBiosDateTimeReq Error, rc: %d, cc: %d\n", + rc, completion_code); + free(response_msg); + return OPAL_PARAMETER; + } + + free(response_msg); + + return OPAL_SUCCESS; +} + /* * parse a string, format: * =,= diff --git a/core/pldm/pldm-rtc.c b/core/pldm/pldm-rtc.c new file mode 100644 index 00000000..e449b73e --- /dev/null +++ b/core/pldm/pldm-rtc.c @@ -0,0 +1,76 @@ +// 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 +#include "pldm.h" + +static int64_t get_and_cache_date_time(struct tm *tm) +{ + int rc; + + rc = pldm_bios_get_date_time_req(tm); + if (!rc) + rtc_cache_update(tm); + + return rc; +} + +static int64_t pldm_opal_rtc_read(__be32 *__ymd, __be64 *__hmsm) +{ + struct tm tm; + uint32_t ymd; + uint64_t hmsm; + int rc; + + if (!__ymd || !__hmsm) + return OPAL_PARAMETER; + + rc = get_and_cache_date_time(&tm); + if ((rc) && (rc != OPAL_BUSY)) + return OPAL_HARDWARE; + + if (rc == OPAL_BUSY) + return OPAL_BUSY_EVENT; + + rtc_cache_get_datetime(&ymd, &hmsm); + *__ymd = cpu_to_be32(ymd); + *__hmsm = cpu_to_be64(hmsm); + + return OPAL_SUCCESS; +} + +static int64_t pldm_opal_rtc_write(uint32_t year_month_day, + uint64_t hour_minute_second_millisecond) +{ + struct tm tm; + int rc; + + datetime_to_tm(year_month_day, hour_minute_second_millisecond, &tm); + + rc = pldm_bios_set_date_time_req(&tm); + if (rc == OPAL_BUSY) + return OPAL_BUSY_EVENT; + + return OPAL_SUCCESS; +} + +void pldm_rtc_init(void) +{ + struct tm tm; + struct dt_node *np = dt_new(opal_node, "rtc"); + + dt_add_property_strings(np, "compatible", "ibm,opal-rtc"); + + opal_register(OPAL_RTC_READ, pldm_opal_rtc_read, 2); + opal_register(OPAL_RTC_WRITE, pldm_opal_rtc_write, 2); + + get_and_cache_date_time(&tm); +} diff --git a/core/pldm/pldm.h b/core/pldm/pldm.h index 1273cd8a..57f86fa9 100644 --- a/core/pldm/pldm.h +++ b/core/pldm/pldm.h @@ -5,6 +5,7 @@ #ifndef __COREPLDM_H__ #define __COREPLDM_H__ +#include #include #include #include @@ -79,6 +80,8 @@ void pldm_fru_add_record(uint32_t *fru_table_length, int pldm_fru_get_table(void **fru_record_table_bytes, uint32_t *fru_record_table_size); +int pldm_bios_get_date_time_req(struct tm *tm); +int pldm_bios_set_date_time_req(struct tm *tm); 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); diff --git a/include/pldm.h b/include/pldm.h index e2904c41..73db2846 100644 --- a/include/pldm.h +++ b/include/pldm.h @@ -52,4 +52,9 @@ bool pldm_lid_files_exit(struct blocklevel_device *bl); */ int pldm_watchdog_init(void); +/** + * Configure real-time clock + */ +void pldm_rtc_init(void); + #endif /* __PLDM_H__ */ From patchwork Tue Apr 19 13:46:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618942 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=SxHcb0Ia; 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 4KjQ8k2T4Xz9sGZ for ; Tue, 19 Apr 2022 23:47:18 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ8k1Thmz3bWG for ; Tue, 19 Apr 2022 23:47:18 +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=SxHcb0Ia; 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=SxHcb0Ia; 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 4KjQ831KqHz2xrb for ; Tue, 19 Apr 2022 23:46:43 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JD3XJU027973 for ; Tue, 19 Apr 2022 13:46:41 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=JZ4h68Hs9J2t0dNiY4KILvBq21Y9gd2tzbjjnxNJrCg=; b=SxHcb0IaSPMlDWICpes0UmjGzawlhbEIjAS2+dn7cBhxahRyxMbx4rHXfQfrxiAFMrFm UIrQUw8KVuY1sguJfQ1SS/kos04Mn/rtDdNz/iLX5v0kX4REEKMRJK8RbJzQaBYBDiX7 e1vAtX5Y+uj895K6Y7yW9Grw+f7BBZiWA3Q0zRTNCqHWBxpPsJG/8X1R7z355oJ6NHag iDihLkN6hdDF6NIX/OFlR142ZT8xdoBvQPWHB5t86e950L+NlXYT/FcESNJRRDPbwb2a tsvaFTbNbTIuLsbZGHVYpvdgWGf6I04zCxjLpXFGB7E1T52dUryPFsCouzdSPS20hbvw cw== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7ct8d6a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:41 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDbVMd007808 for ; Tue, 19 Apr 2022 13:46:38 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3ffne8uk00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkaO449611168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30A2311C04A for ; Tue, 19 Apr 2022 13:46:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10B1911C052 for ; Tue, 19 Apr 2022 13:46:36 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:35 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:32 +0200 Message-Id: <20220419134633.42098-15-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ubbB3JYwOlasdQbp6JirgE0iAZwxu6fS X-Proofpoint-ORIG-GUID: ubbB3JYwOlasdQbp6JirgE0iAZwxu6fS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 13/14] core/pldm: Register OPAL_IPMI_SEND/RECV calls back 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" Signed-off-by: Christophe Lombard --- core/pldm/Makefile.inc | 2 +- core/pldm/pldm-opal.c | 143 +++++++++++++++++++++++++++++++++++++++++ include/pldm.h | 5 ++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 core/pldm/pldm-opal.c diff --git a/core/pldm/Makefile.inc b/core/pldm/Makefile.inc index cf174c86..ebccb104 100644 --- a/core/pldm/Makefile.inc +++ b/core/pldm/Makefile.inc @@ -16,7 +16,7 @@ PLDM_OBJS = pldm-common.o pldm-responder.o pldm-requester.o PLDM_OBJS += pldm-base-requests.o pldm-platform-requests.o PLDM_OBJS += pldm-bios-requests.o pldm-fru-requests.o PLDM_OBJS += pldm-file-io-requests.o pldm-lid-files.o -PLDM_OBJS += pldm-watchdog.o pldm-rtc.o +PLDM_OBJS += pldm-watchdog.o pldm-rtc.o pldm-opal.o PLDM = $(PLDM_DIR)/built-in.a $(PLDM): $(PLDM_OBJS:%=$(PLDM_DIR)/%) diff --git a/core/pldm/pldm-opal.c b/core/pldm/pldm-opal.c new file mode 100644 index 00000000..8aea0246 --- /dev/null +++ b/core/pldm/pldm-opal.c @@ -0,0 +1,143 @@ +// 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 +#include "pldm.h" + +static struct lock msgq_lock = LOCK_UNLOCKED; +static struct list_head msgq = LIST_HEAD_INIT(msgq); + +/* + * static void opal_send_complete(struct ipmi_msg *msg) + * { + * lock(&msgq_lock); + * list_add_tail(&msgq, &msg->link); + * opal_update_pending_evt(ipmi_backend->opal_event_ipmi_recv, + * ipmi_backend->opal_event_ipmi_recv); + * unlock(&msgq_lock); + * } + */ + +static int64_t opal_ipmi_send(uint64_t interface __unused, + struct opal_ipmi_msg *opal_ipmi_msg, uint64_t msg_len) +{ + int16_t ipmi_code; + + if (opal_ipmi_msg->version != OPAL_IPMI_MSG_FORMAT_VERSION_1) { + prerror("OPAL IPMI: Incorrect version\n"); + return OPAL_UNSUPPORTED; + } + + msg_len -= sizeof(struct opal_ipmi_msg); + if (msg_len > IPMI_MAX_REQ_SIZE) { + prerror("OPAL IPMI: Invalid request length\n"); + return OPAL_PARAMETER; + } + + ipmi_code = IPMI_CODE(opal_ipmi_msg->netfn >> 2, opal_ipmi_msg->cmd); + if ((ipmi_code == IPMI_CHASSIS_GET_SYS_BOOT_OPT_CMD) || + (opal_ipmi_msg->cmd == IPMI_CODE(opal_ipmi_msg->netfn >> 2, 0x1a)) || + (opal_ipmi_msg->cmd == IPMI_CODE(opal_ipmi_msg->netfn >> 2, 0x42))) { + prerror("OPAL IPMI: Command not supported\n"); + return OPAL_UNSUPPORTED; + } + + prlog(PR_TRACE, "%s - cmd: 0x%02x netfn: 0x%02x len: 0x%02llx\n", + __func__, opal_ipmi_msg->cmd, opal_ipmi_msg->netfn >> 2, + msg_len); + + /* FIXME - Send PLDM requests + * IPMI_BMC_GET_DEVICE_ID IPMI_CMD_GET_DEVICE_ID 0x01 + * IPMI_CMD_GET_DEVICE_GUID 0x08 + * IPMI_SET_WDT IPMI_CMD_SET_WATCHDOG_TIMER 0x24 + */ + return OPAL_UNSUPPORTED; +} + +static int64_t opal_ipmi_recv(uint64_t interface, + struct opal_ipmi_msg *opal_ipmi_msg, __be64 *msg_len) +{ + struct ipmi_msg *msg; + int64_t rc; + + lock(&msgq_lock); + msg = list_top(&msgq, struct ipmi_msg, link); + + if (!msg) { + rc = OPAL_EMPTY; + goto out_unlock; + } + + if (opal_ipmi_msg->version != OPAL_IPMI_MSG_FORMAT_VERSION_1) { + prerror("OPAL IPMI: Incorrect version\n"); + rc = OPAL_UNSUPPORTED; + goto out_del_msg; + } + + if (interface != IPMI_DEFAULT_INTERFACE) { + prerror("IPMI: Invalid interface 0x%llx in %s\n", interface, __func__); + rc = OPAL_PARAMETER; + goto out_del_msg; + } + + if (be64_to_cpu(*msg_len) - sizeof(struct opal_ipmi_msg) < msg->resp_size + 1) { + rc = OPAL_RESOURCE; + goto out_del_msg; + } + + list_del(&msg->link); + if (list_empty(&msgq)) + opal_update_pending_evt(ipmi_backend->opal_event_ipmi_recv, 0); + unlock(&msgq_lock); + + opal_ipmi_msg->cmd = msg->cmd; + opal_ipmi_msg->netfn = msg->netfn; + opal_ipmi_msg->data[0] = msg->cc; + memcpy(&opal_ipmi_msg->data[1], msg->data, msg->resp_size); + + prlog(PR_TRACE, "%s - cmd: 0x%02x netfn: 0x%02x resp_size: 0x%02x\n", + __func__, msg->cmd, msg->netfn >> 2, msg->resp_size); + + /* Add one as the completion code is returned in the message data */ + *msg_len = cpu_to_be64(msg->resp_size + sizeof(struct opal_ipmi_msg) + 1); + ipmi_free_msg(msg); + + return OPAL_SUCCESS; + +out_del_msg: + list_del(&msg->link); + if (list_empty(&msgq)) + opal_update_pending_evt(ipmi_backend->opal_event_ipmi_recv, 0); + ipmi_free_msg(msg); +out_unlock: + unlock(&msgq_lock); + return rc; +} + +void pldm_opal_init(void) +{ + struct dt_node *opal_ipmi, *opal_event = NULL; + + opal_ipmi = dt_new(opal_node, "ipmi"); + dt_add_property_strings(opal_ipmi, "compatible", "ibm,opal-ipmi"); + dt_add_property_cells(opal_ipmi, "ibm,ipmi-interface-id", + IPMI_DEFAULT_INTERFACE); + dt_add_property_cells(opal_ipmi, "interrupts", + ilog2(ipmi_backend->opal_event_ipmi_recv)); + + opal_event = dt_find_by_name(opal_node, "event"); + if (opal_event) + dt_add_property_cells(opal_ipmi, "interrupt-parent", + opal_event->phandle); + + opal_register(OPAL_IPMI_SEND, opal_ipmi_send, 3); + opal_register(OPAL_IPMI_RECV, opal_ipmi_recv, 3); +} diff --git a/include/pldm.h b/include/pldm.h index 73db2846..2cd31f2e 100644 --- a/include/pldm.h +++ b/include/pldm.h @@ -57,4 +57,9 @@ int pldm_watchdog_init(void); */ void pldm_rtc_init(void); +/** + * Register ipmi host interface access callbacks + */ +void pldm_opal_init(void); + #endif /* __PLDM_H__ */ From patchwork Tue Apr 19 13:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1618943 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=A38Jl/TT; 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 4KjQ8w1Br3z9sGZ for ; Tue, 19 Apr 2022 23:47:27 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjQ8s5wD8z3bVc for ; Tue, 19 Apr 2022 23:47:25 +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=A38Jl/TT; 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=A38Jl/TT; 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 4KjQ832HY5z2yPj for ; Tue, 19 Apr 2022 23:46:43 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23JC5A0F023050 for ; Tue, 19 Apr 2022 13:46:41 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=NHEWJJraWErpWknHZ63+RSmXTd1knMivfFJdQMl56gQ=; b=A38Jl/TTMgqkNl45cwobbYMKNbjJ/t5zAVSuxctchFDthgl3lsBLeKlvZVOloeTl9b9y GrPX/XxggFRJExovAX2zg+0+T8w6KBoEtxqJjnHZb0aBCkQW2IR8srSn2BxVvcozjuOm 51JjQy+YVMK6VoNGLaig0IS74LFfsMCxqPPDvCL+K46p42FAuw8GfNnz55jG2XNgh1V0 EDXV91GC2fBAmLyRvRvqmspv8y11f2NsM0ijcVdpdTyt0SG/c52yXF28YYXZ9QLVyx2W sVfVSXV4j6m6iZapOPXnqV+iLpVBHxQZfo/Qe1H3JdTIHxCg9OcpuqHTUVb7vSuHV9tG Aw== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg79erw5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:41 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23JDatFD030508 for ; Tue, 19 Apr 2022 13:46:38 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3ffne94fut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Apr 2022 13:46:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23JDkaEU49611170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Apr 2022 13:46:36 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E2C311C04A for ; Tue, 19 Apr 2022 13:46:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F15F11C04C for ; Tue, 19 Apr 2022 13:46:36 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.biot.fr.ibm.com (unknown [9.144.57.92]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Tue, 19 Apr 2022 13:46:36 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Tue, 19 Apr 2022 15:46:33 +0200 Message-Id: <20220419134633.42098-16-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> References: <20220419134633.42098-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Zo4pa0F1cefPA0CmEEn0PKZZxeUbMm46 X-Proofpoint-ORIG-GUID: Zo4pa0F1cefPA0CmEEn0PKZZxeUbMm46 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-19_05,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204190076 Subject: [Skiboot] [PATCH 14/14] platforms/astbmc: Enable PLDM support 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" Last BMC firmware is available with a complete PLDM support on Rainier system. This patch allows initially to: - Initialize the MCTP core. - Enable the mctp binding over LPC bus interface and new wrappers to send and receive PLDM messages over the mctp library. - Retrieve all needed PLDM data. - "Virtualize" the content of a BMC flash based on lid files. Then, others mandatory support (watchdog, opal rtc, opal ipmi) are enabled. Signed-off-by: Christophe Lombard --- core/init.c | 5 +++++ core/pldm/pldm-common.c | 11 ++++++++++ include/pldm.h | 2 ++ platforms/astbmc/astbmc.h | 4 ++++ platforms/astbmc/common.c | 42 ++++++++++++++++++++++++++++++++++++++ platforms/astbmc/pnor.c | 25 +++++++++++++++++++++++ platforms/astbmc/rainier.c | 33 ++++++++++++++++++++++++++---- 7 files changed, 118 insertions(+), 4 deletions(-) diff --git a/core/init.c b/core/init.c index a1fd5f2b..499f7d06 100644 --- a/core/init.c +++ b/core/init.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1372,7 +1373,11 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Setup ibm,firmware-versions if able */ if (platform.bmc) { flash_dt_add_fw_version(); +#ifdef CONFIG_PLDM + pldm_fru_dt_add_bmc_version(); +#else ipmi_dt_add_bmc_info(); +#endif } ipmi_set_fw_progress_sensor(IPMI_FW_PCI_INIT); diff --git a/core/pldm/pldm-common.c b/core/pldm/pldm-common.c index 50f86948..e92170dc 100644 --- a/core/pldm/pldm-common.c +++ b/core/pldm/pldm-common.c @@ -10,6 +10,13 @@ #include #include "pldm.h" +bool pldm_enabled; + +bool pldm_present(void) +{ + return pldm_enabled; +} + /* * Print content of PLDM message in hex mode. * 15 bytes per line. @@ -155,6 +162,8 @@ int pldm_mctp_init(void) if (rc) prlog(PR_ERR, "Failed to retrieve File io data\n"); + pldm_enabled = true; + out: prlog(PR_NOTICE, "%s - done, rc: %d\n", __func__, rc); return rc; @@ -162,6 +171,8 @@ out: void pldm_mctp_exit(void) { + pldm_enabled = false; + pldm_platform_exit(); ast_mctp_exit(); diff --git a/include/pldm.h b/include/pldm.h index 2cd31f2e..5066b39a 100644 --- a/include/pldm.h +++ b/include/pldm.h @@ -7,6 +7,8 @@ #include +bool pldm_present(void); + /** * PLDM over MCTP initialization */ diff --git a/platforms/astbmc/astbmc.h b/platforms/astbmc/astbmc.h index 00f22123..7783fe20 100644 --- a/platforms/astbmc/astbmc.h +++ b/platforms/astbmc/astbmc.h @@ -96,6 +96,10 @@ extern const struct bmc_platform bmc_plat_ast2600_openbmc; extern void astbmc_early_init(void); extern int64_t astbmc_ipmi_reboot(void); extern int64_t astbmc_ipmi_power_down(uint64_t request); +#ifdef CONFIG_PLDM +extern int astbmc_pldm_init(void); +extern int pnor_pldm_init(void); +#endif extern void astbmc_init(void); extern void astbmc_ext_irq_serirq_cpld(unsigned int chip_id); extern int pnor_init(void); diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index 83ef70ad..150b7708 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,43 @@ static int astbmc_fru_init(void) return 0; } +#ifdef CONFIG_PLDM +int astbmc_pldm_init(void) +{ + int rc; + + /* PLDM over MCTP */ + rc = pldm_mctp_init(); + if (rc) + goto err; + + /* Initialize PNOR/NVRAM */ + rc = pnor_pldm_init(); + if (rc) + goto err; + + /* Update or create terminus locator in the given repo */ + rc = pldm_platform_terminus_locator_pdr(); + if (rc) + goto err; + + /* Initialize elog */ + elog_init(); + + pldm_watchdog_init(); + pldm_rtc_init(); + /*pldm_opal_init(); FIXME */ + + /* Setup UART console for use by Linux via OPAL API */ + set_opal_console(&uart_opal_con); + + return OPAL_SUCCESS; + +err: + prlog(PR_WARNING, "Failed to configure PLDM\n"); + return rc; +} +#endif void astbmc_init(void) { @@ -501,6 +539,10 @@ void astbmc_early_init(void) void astbmc_exit(void) { +#ifdef CONFIG_PLDM + if (pldm_present()) + return; +#endif ipmi_wdt_final_reset(); } diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c index 64f2249d..853da467 100644 --- a/platforms/astbmc/pnor.c +++ b/platforms/astbmc/pnor.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,30 @@ static enum ast_flash_style ast_flash_get_fallback_style(void) return raw_mem; } +#ifdef CONFIG_PLDM +int pnor_pldm_init(void) +{ + struct blocklevel_device *bl = NULL; + int rc = 0; + + rc = pldm_lid_files_init(&bl); + if (rc) { + prerror("PLAT: Failed to init PNOR driver\n"); + goto fail; + } + + rc = flash_register(bl); + if (!rc) + return 0; + +fail: + if (bl) + pldm_lid_files_exit(bl); + + return rc; +} +#endif + int pnor_init(void) { struct spi_flash_ctrl *pnor_ctrl = NULL; diff --git a/platforms/astbmc/rainier.c b/platforms/astbmc/rainier.c index 3e21e1b9..26ce6acf 100644 --- a/platforms/astbmc/rainier.c +++ b/platforms/astbmc/rainier.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -321,9 +322,33 @@ static void rainier_pau_create_i2c_bus(void) } } +static int64_t rainier_power_down(uint64_t request) +{ +#ifdef CONFIG_PLDM + /* Issue a PLDM request for a Off-Soft Graceful */ + if (pldm_present()) + return pldm_platform_power_off(); +#endif + return astbmc_ipmi_power_down(request); +} + +static int64_t rainier_reboot(void) +{ +#ifdef CONFIG_PLDM + /* Issue a PLDM request for a graceful restart */ + if (pldm_present()) + return pldm_platform_restart(); +#endif + return astbmc_ipmi_reboot(); +} + static void rainier_init(void) { - astbmc_init(); +#ifdef CONFIG_PLDM + if (astbmc_pldm_init()) +#endif + astbmc_init(); + rainier_init_slot_power(); } @@ -365,9 +390,9 @@ DECLARE_PLATFORM(rainier) = { .start_preload_resource = flash_start_preload_resource, .resource_loaded = flash_resource_loaded, .bmc = &bmc_plat_ast2600_openbmc, - .cec_power_down = astbmc_ipmi_power_down, - .cec_reboot = astbmc_ipmi_reboot, - .elog_commit = ipmi_elog_commit, + .cec_power_down = rainier_power_down, + .cec_reboot = rainier_reboot, + .elog_commit = ipmi_elog_commit, /* FIXME */ .pau_device_detect = rainier_pau_device_detect, .ocapi = &rainier_ocapi, .exit = astbmc_exit,