From patchwork Thu May 11 16:24:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1780172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=JWQ/WjdS; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QHHND1lkHz213w for ; Fri, 12 May 2023 02:26:52 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4QHHND0dJcz3fbH for ; Fri, 12 May 2023 02:26:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=JWQ/WjdS; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=clombard@linux.ibm.com; receiver=) 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=JWQ/WjdS; 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 4QHHL01BVyz3fM8 for ; Fri, 12 May 2023 02:24:55 +1000 (AEST) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34BGOGvt018615 for ; Thu, 11 May 2023 16:24:54 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=xdpeBo2t7Swbecm+z48GGufXQ5jFOHC3g8mO9AmXM60=; b=JWQ/WjdS4CtTklyuPH0IvERwoWR3nqRxPps+FlvOpVWnelKtJbXhGxJHXGq1jE4N+FsU I5wMh6YIJg6KC1uFCNouK2q8AJ4oz/7iSlQdzfhv982YWQoY+VsGDx4aj85oTYQ3rS19 gHGp5Ne9lxskqWlRY+WcLsDVeRLT2Jok97cZsub6uBAG5gHSSm8jmJyawtCDV6DEKRIz PAdb3S7Cm13VPn6cEnpLYPB4lwGEivJCBNKBnoFPewL4yYVrlw+se8DKuyYxAV04Q7r7 uTCSDphB4zjOPtcCOBMAiKMd8iUwESXzItZbR4ofZU84UJ6/4wzXPeZCTMKc7+mRVtOp Qg== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qh3umg0a8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 May 2023 16:24:53 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 34BD8I4j026361 for ; Thu, 11 May 2023 16:24:51 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3qf7d1sghy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 May 2023 16:24:51 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 34BGOmqi17695410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 11 May 2023 16:24:48 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C1B3620049 for ; Thu, 11 May 2023 16:24:48 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 836C920040 for ; Thu, 11 May 2023 16:24:48 +0000 (GMT) Received: from li-ac0ca24c-3330-11b2-a85c-93224c50ad7a.home (unknown [9.179.3.92]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Thu, 11 May 2023 16:24:48 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Thu, 11 May 2023 18:24:30 +0200 Message-Id: <20230511162446.10457-6-clombard@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511162446.10457-1-clombard@linux.ibm.com> References: <20230511162446.10457-1-clombard@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OnCYaT76YHwPpS0ByLnBCzhTgTH-nTIa X-Proofpoint-ORIG-GUID: OnCYaT76YHwPpS0ByLnBCzhTgTH-nTIa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-11_13,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 clxscore=1015 mlxlogscore=954 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305110139 Subject: [Skiboot] [PATCH V7 05/21] core/pldm: Encode GetTID response X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" A PLDM Terminus is defined as the point of communication termination for PLDM messages and the PLDM functions associated with those messages. Given a PLDM terminus, a mechanism is required that can uniquely identify each terminus so that the semantic information can be bound to that identification. The Terminus ID (TID) is a value that identifies a PLDM terminus. TIDs are used in PLDM messages when it is necessary to identify the PLDM terminus that is the source of the PLDM Message. The GetTID command is used to retrieve the present Terminus ID (TID) setting for a PLDM Terminus. Reviewed-by: Abhishek Singh Tomar Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 58 ++++++++++++++++++++++++++++++++++++++ include/ast.h | 6 ++++ 2 files changed, 64 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 9a99a5a4..76ef020a 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -103,6 +103,17 @@ static void add_type(struct pldm_type *new_type) new_type->name, new_type->pldm_type_id); } +static void add_cmd(struct pldm_type *type, struct pldm_cmd *new_cmd) +{ + assert(new_cmd->pldm_cmd_id < 256); /* limited by GetPLDMCommands */ + assert(new_cmd->handler); + assert(!find_cmd(type, new_cmd->pldm_cmd_id)); + + list_add_tail(&type->commands, &new_cmd->link); + prlog(PR_DEBUG, "Registered command %s (%d) under %s\n", + new_cmd->name, new_cmd->pldm_cmd_id, type->name); +} + /* * PLDM Base commands support */ @@ -112,6 +123,52 @@ static struct pldm_type pldm_base_type = { .version = { 0xF1, 0xF0, 0xF0, 0x00 }, }; +/* + * GetTID command (0x02) + * The GetTID command is used to retrieve the present Terminus ID (TID) + * setting for a PLDM Terminus. + */ +static int base_get_tid_handler(const struct pldm_rx_data *rx) +{ + size_t data_size = PLDM_MSG_SIZE(struct pldm_get_tid_resp); + struct pldm_tx_data *tx; + int rc; + + /* create a PLDM response message for GetTID */ + tx = zalloc(sizeof(struct pldm_tx_data) + data_size); + if (!tx) + return OPAL_NO_MEM; + tx->data_size = data_size; + + rc = encode_get_tid_resp(rx->hdrinf.instance, + PLDM_SUCCESS, + HOST_TID, + (struct pldm_msg *)tx->data); + if (rc != PLDM_SUCCESS) { + prlog(PR_ERR, "Encode GetTID Error, rc: %d\n", rc); + cc_resp(rx, rx->hdrinf.pldm_type, + rx->hdrinf.command, PLDM_ERROR); + free(tx); + return OPAL_PARAMETER; + } + + rc = pldm_mctp_message_tx(tx); + if (rc) { + prlog(PR_ERR, "Failed to send GetTID response, rc = %d\n", rc); + free(tx); + return OPAL_HARDWARE; + } + + free(tx); + return OPAL_SUCCESS; +} + +static struct pldm_cmd pldm_base_get_tid = { + .name = "PLDM_GET_TID", + .pldm_cmd_id = PLDM_GET_TID, + .handler = base_get_tid_handler, +}; + int pldm_responder_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *type; @@ -147,6 +204,7 @@ int pldm_responder_init(void) { /* Register mandatory commands we'll respond to - DSP0240 */ add_type(&pldm_base_type); + add_cmd(&pldm_base_type, &pldm_base_get_tid); return OPAL_SUCCESS; } diff --git a/include/ast.h b/include/ast.h index 50e3b932..e9c39c6d 100644 --- a/include/ast.h +++ b/include/ast.h @@ -101,6 +101,12 @@ void ast_setup_sio_mbox(uint16_t io_base, uint8_t irq); #define BMC_EID 8 #define HOST_EID 9 +/* + * Skiboot's PLDM Terminus ID. + * BMC TID is 1, HB is 2, Skiboot is 3. + */ +#define HOST_TID 3 + enum mctp_msg_type { MCTP_MSG_TYPE_CONTROL = 0x00, MCTP_MSG_TYPE_PLDM = 0x01,