From patchwork Fri Feb 25 14:28:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lombard X-Patchwork-Id: 1597702 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=tk6jGWK4; 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 4K4sc237KVz9sG1 for ; Sat, 26 Feb 2022 01:29:38 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K4sc120h2z3cJS for ; Sat, 26 Feb 2022 01:29:37 +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=tk6jGWK4; 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=tk6jGWK4; 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 4K4sbG1cmhz3bTD for ; Sat, 26 Feb 2022 01:28:57 +1100 (AEDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21PDURSi000704 for ; Fri, 25 Feb 2022 14:28:56 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=pt9GukPkSmcS6J2OJEeeWq+Y+KqNuVCvD0phRdL/gtc=; b=tk6jGWK47EJJFWD8wSVAoQOKtyZyJhw2Jiz5HU5znioNBwftCiaVhjENQtyMuUr0OTLx RGMvLzxYk2Vbfu7ZKxdpiI/sqypGXodhUhLU7X+f+C7Rffp/YA9u8TJWZwQmvKvgLhOv LcW1K6f8wE9oO5pr4rJ4sAmBncN/NFHcent1Rtv7QCUqlv+YbZg/waC7yKvwfEbjwZaG LULwXzzcg8eHKtxD8wcZ2Z5n4ZxGWUJa+mpw2+6k/Gzq1WeLB63JRd6VqVridLBLAQkN nQTa4RBHwR2ajwAqe0b59UcHG3vjdA/SSgyxAPlxcTOq/YEvfjZtNBbQQ1DK/NL/ortK lw== 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 3eeytf1yxw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 25 Feb 2022 14:28:56 +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 21PERwWi012350 for ; Fri, 25 Feb 2022 14:28:54 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma01fra.de.ibm.com with ESMTP id 3eeg2s4ysg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 25 Feb 2022 14:28:53 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21PESpBV56492346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 25 Feb 2022 14:28:51 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 895DB4C04A for ; Fri, 25 Feb 2022 14:28:51 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 643194C040 for ; Fri, 25 Feb 2022 14:28:51 +0000 (GMT) Received: from li-ed209401-43e8-11cb-8043-c0c0b85d70f7.ibm.com (unknown [9.171.0.236]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Fri, 25 Feb 2022 14:28:51 +0000 (GMT) From: Christophe Lombard To: skiboot@lists.ozlabs.org Date: Fri, 25 Feb 2022 15:28:36 +0100 Message-Id: <20220225142848.93747-8-clombard@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220225142848.93747-1-clombard@linux.vnet.ibm.com> References: <20220225142848.93747-1-clombard@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: LFhQU-URUhfXWvfBdRIb3QLQsTJ5DjS3 X-Proofpoint-ORIG-GUID: LFhQU-URUhfXWvfBdRIb3QLQsTJ5DjS3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-02-25_07,2022-02-25_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202250082 Subject: [Skiboot] [PATCH 07/19] core/pldm: Encode GetPLDMCommands 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 GetPLDMCommands command can be used to discover the PLDM command capabilities supported by a PLDM terminus for a specific PLDM Type and version as a responder. Signed-off-by: Christophe Lombard --- core/pldm/pldm-responder.c | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/core/pldm/pldm-responder.c b/core/pldm/pldm-responder.c index 2bd6fd07..3d067134 100644 --- a/core/pldm/pldm-responder.c +++ b/core/pldm/pldm-responder.c @@ -163,6 +163,75 @@ static struct pldm_cmd base_get_types = { .handler = get_types_handler, }; +/* + * Extended error codes defined for the Base command set. + */ +#define INVALID_PLDM_TYPE_IN_REQUEST_DATA 0x83 +#define INVALID_PLDM_VERSION_IN_REQUEST_DATA 0x84 + +/* + * GetPLDMCommands (0x05) + * The GetPLDMCommands command can be used to discover the PLDM command + * capabilities supported by aPLDM terminus for a specific PLDM Type and + * version as a responder. + */ +static int get_commands_handler(const struct pldm_rx_data *req) +{ + char resp_buf[PKT_SIZE(struct pldm_get_commands_resp)]; + bitmap_elem_t cmd_map[BITMAP_ELEMS(256)]; + const struct pldm_type *type; + const struct pldm_cmd *iter; + size_t payload_len; + ver32_t version; + uint8_t type_id; + int rc; + + payload_len = req->msg_len - sizeof(struct pldm_msg_hdr); + rc = decode_get_commands_req(req->msg, payload_len, + &type_id, &version); + if (rc) { + pldm_cc_resp(req, PLDM_ERROR); + return OPAL_INTERNAL_ERROR; + } + + type = find_type(type_id); + if (!type) { + pldm_cc_resp(req, INVALID_PLDM_TYPE_IN_REQUEST_DATA); + return OPAL_PARAMETER; + } + + if (memcmp(&type->version, &version, sizeof(version))) { + pldm_cc_resp(req, INVALID_PLDM_VERSION_IN_REQUEST_DATA); + return OPAL_PARAMETER; + } + + /* + * build the supported type list from the registered type + * handlers + */ + memset(cmd_map, 0, sizeof(cmd_map)); + list_for_each(&type->commands, iter, link) + bitmap_set_bit(cmd_map, iter->pldm_cmd_id); + + /* fix the endian */ + for (int i = 0; i < BITMAP_ELEMS(256); i++) + cmd_map[i] = cpu_to_le64(cmd_map[i]); + + memset(resp_buf, 0, sizeof(resp_buf)); + encode_get_commands_resp(req->hdrinf.instance, + PLDM_SUCCESS, + (bitfield8_t *)cmd_map, + (void *) resp_buf); + pldm_send(resp_buf, sizeof(resp_buf)); + + return 0; +} +static struct pldm_cmd base_get_commands = { + .name = "GetPLDMCommands", + .pldm_cmd_id = PLDM_GET_PLDM_COMMANDS, + .handler = get_commands_handler, +}; + int pldm_rx_handle_request(struct pldm_rx_data *rx) { const struct pldm_type *t; @@ -190,6 +259,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); return OPAL_SUCCESS; }