From patchwork Fri Mar 18 14:36:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1607072 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=I6XxFofk; 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 4KKmn36907z9s3q for ; Sat, 19 Mar 2022 01:37:11 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KKmn35LMlz3bWk for ; Sat, 19 Mar 2022 01:37:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=I6XxFofk; 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=I6XxFofk; 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 4KKmmF1k4Gz30Jm for ; Sat, 19 Mar 2022 01:36:28 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22ICnwu4017397 for ; Fri, 18 Mar 2022 14:36:26 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=d8YWs10I6X1MQv/x5wIFGZ5M6QADsdRTr+my2zu65oM=; b=I6XxFofkqMI3EwAfjEsiB15m3L/dnF02CbLP0TC7SndsPSZ8tf/+t0Ocw8w+UwLegNRN 9nWJJ2x13HzKbYlyWTk+Lw6LHDnuXVtmLyVEirQZvdiSPvu1yD/vIAPu7kmSNnFHzr+y OSTfvc7R+2mNHuyWRpCMlRUA8IeiayRZEuNrIj/HXRK8UtPfxW6SWfdF9hbv0Yw5jD7F QIWyi5b9XJUXccsh0hPlhlsQcZ16ukKMrvDitDBM2SYN095C8ivt8KFdnmPAnuBDb9q4 Ud10dJf7EHfBUekvSd0/PCA9C9At58UodXYOD9mipGl/8Rd0uJ8+J49TP0+zHEIWZNgq /g== 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 3evqgxdf0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Mar 2022 14:36:26 +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 22IEJ7Qa004881 for ; Fri, 18 Mar 2022 14:36:24 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 3erk595rer-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Mar 2022 14:36:24 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22IEOoe147776148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Mar 2022 14:24:50 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AE8D11C04C for ; Fri, 18 Mar 2022 14:36:22 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E12E011C04A for ; Fri, 18 Mar 2022 14:36:21 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.ibm.com.com (unknown [9.171.63.232]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Fri, 18 Mar 2022 14:36:21 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Fri, 18 Mar 2022 15:36:06 +0100 Message-Id: <20220318143619.83489-9-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220318143619.83489-1-clombard@linux.vnet.ibm.com> References: <20220318143619.83489-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: GXonW0IWK7yFSPwKJ-fTAK09PBYTGCyn X-Proofpoint-GUID: GXonW0IWK7yFSPwKJ-fTAK09PBYTGCyn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-18_10,2022-03-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203180080 Subject: [Skiboot] [PATCH V3 08/21] core/pldm: Encode GetPLDMVersion 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" The GetPLDMVersion command can be used to retrieve the PLDM base specification versions that the PLDM terminus supports, as well as the PLDM Type specification versions supported for each PLDM Type. The reported version for Type 0 (PLDMbase) shall be encoded as 0xF1F1F000. Reviewed-by: Abhishek Singh Tomar Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 88cf47ba..dd11a05d 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -166,6 +166,7 @@ static struct pldm_cmd base_get_types = { /* * Extended error codes defined for the Base command set. */ +#define INVALID_TRANSFER_OPERATION_FLAG 0x80 #define INVALID_PLDM_TYPE_IN_REQUEST_DATA 0x83 #define INVALID_PLDM_VERSION_IN_REQUEST_DATA 0x84 @@ -232,6 +233,67 @@ static struct pldm_cmd base_get_commands = { .handler = get_commands_handler, }; +/* + * GetPLDMVersion (0x03) + * The GetPLDMVersion command can be used to retrieve the PLDM base + * specification versions that the PLDM terminus supports, as well as + * the PLDM Type specification versions supported for each PLDM Type. + */ +static int get_version_handler(const struct pldm_rx_data *req) +{ + const struct pldm_type *type; + uint32_t tmp[2]; + char resp_buf[PKT_SIZE(struct pldm_get_version_resp) + sizeof(tmp)]; + uint8_t type_id, opflag; + size_t payload_len; + uint32_t xfer_handle; + int rc; + + payload_len = req->msg_len - sizeof(struct pldm_msg_hdr); + rc = decode_get_version_req(req->msg, payload_len, + &xfer_handle, + &opflag, + &type_id); + if (rc) { + pldm_cc_resp(req, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + /* reject multipart requests */ + if (opflag != PLDM_GET_FIRSTPART) { + pldm_cc_resp(req, INVALID_TRANSFER_OPERATION_FLAG); + return OPAL_PARAMETER; + } + + type = find_type(type_id); + if (!type) { + pldm_cc_resp(req, INVALID_PLDM_TYPE_IN_REQUEST_DATA); + return OPAL_PARAMETER; + } + + /* pack a scratch buffer with our version(s) and CRC32 the lot */ + memcpy(&tmp[0], &type->version, 4); + + tmp[1] = cpu_to_le32(pldm_crc32(&type->version, 4)); + + memset(resp_buf, 0, sizeof(resp_buf)); + encode_get_version_resp(req->hdrinf.instance, + PLDM_SUCCESS, + 0x0, /* no handle */ + PLDM_START_AND_END, + (ver32_t *) tmp, + sizeof(tmp), + (void *) resp_buf); + pldm_send(req->source_eid, resp_buf, sizeof(resp_buf)); + + return 0; +} +static struct pldm_cmd base_get_version = { + .name = "GetPLDMVersion", + .pldm_cmd_id = PLDM_GET_PLDM_VERSION, + .handler = get_version_handler, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -260,6 +322,7 @@ int pldm_mctp_responder_init(void) pldm_add_cmd(&pldm_base_type, &base_get_tid); pldm_add_cmd(&pldm_base_type, &base_get_types); pldm_add_cmd(&pldm_base_type, &base_get_commands); + pldm_add_cmd(&pldm_base_type, &base_get_version); return OPAL_SUCCESS; }