From nobody Sun Apr 6 03:49:37 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1736989121; cv=none; d=zohomail.com; s=zohoarc; b=LUrQTQUUHJyxu8R0AdemVCCtFoAfClsa9fJTMvUv392/xHKiABrWgOsuZepTri9gjmr2xvcABAoyWj0gNO7pWu81/OMzTP1Wxcp4SsrukRwSl5tTg+EHmFWhXo8Of9XYUJ26/koeFzdm7sIpFs2xiqNSFJLxU8P29i0GoXPMLF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736989121; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=RoxwgWFBH3ErsB1Spj8z2dgrvHTo6Auq7Q7UWe8PolQ=; b=Sf0uGBUKrkVyC/+gY9QiC763v0+00Hz1kZV7QqS6zGxr4yxoLmkfPNv4WLyC+BFY1mQXitAgfla81xDiVROVgf2MEwC+qYZ2j9rLpChWvOy7ILvtpY/gWaUPdWFgHImGWzCKDmPNfNcxI2mZaK5wWaGSE72mjN2vdX6tQX6iqMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1736989121779451.19206130258397; Wed, 15 Jan 2025 16:58:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYECx-000232-Fp; Wed, 15 Jan 2025 19:58:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYECv-00022b-7k for qemu-devel@nongnu.org; Wed, 15 Jan 2025 19:58:01 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYECs-0002G8-UY for qemu-devel@nongnu.org; Wed, 15 Jan 2025 19:58:01 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 16 Jan 2025 08:57:53 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 15 Jan 2025 15:54:33 -0800 Received: from unknown (HELO fedora.wdc.com) ([10.225.165.91]) by uls-op-cesaip02.wdc.com with ESMTP; 15 Jan 2025 16:57:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1736989078; x=1768525078; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=IpcM5q81RbzsvoU4Wyq4VsouVZyy9mVMBxcb1Tk10nI=; b=Ml1BkMd+7nznN+spN8w4dQ0xN8M4bypOOdI+8QfXithFRsXlGfvoPMRm 9h/kMI+X00bSATziPKNnMxq8zi2Xunc6g8aw3GTLWtU1CP9k1z1sRJ7A8 7jYKFs/4NuLPIoqZTLGYPEvRC2QnAEAAARxYUKcytCjB3W59ryDnmzTFr /11tcsEc+XGZPMqdoKvjDKgyS7lPNrXrHNatvheDZzB7tDrV/ELVFMyOS jtTnm6BJ6ufeRqXs8SCH92Mdpx7EA4nViD1YphW+JIxYwJIUX3U9Y0bL5 Kg3a+TWa1jZKlHcQ8RTE6BS7yd5vvxX3ss7OdIGuPlyfqs9azNNtCb1Uu w==; X-CSE-ConnectionGUID: TZYvUHxrRw668bPh5LwvcA== X-CSE-MsgGUID: 4S7FOGl8T66/pvU8zezCLg== X-IronPort-AV: E=Sophos;i="6.13,207,1732550400"; d="scan'208";a="36550480" IronPort-SDR: 67884ab9_TbUXEgGYyGJAHrJ1uL99wBueo7jE7fWqfrMl3YlIBWvS4t/ 2VEOqA9wTgS7z9odvgeA2k068TVXpWHnaME2tLQ== WDCIronportException: Internal To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, Wilfred Mallawa Subject: [PATCH] spdm-socket: add seperate send/recv functions Date: Thu, 16 Jan 2025 10:57:49 +1000 Message-ID: <20250116005749.92030-1-wilfred.mallawa@wdc.com> X-Mailer: git-send-email 2.48.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=104bc4e84=wilfred.mallawa@wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Wilfred Mallawa From: Wilfred Mallawa via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736989122702019000 Content-Type: text/plain; charset="utf-8" This is to support uni-directional transports such as SPDM over Storage. As specified by the DMTF DSP0286. Signed-off-by: Wilfred Mallawa --- backends/spdm-socket.c | 27 ++++++++++++++++++++++++--- include/system/spdm-socket.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/backends/spdm-socket.c b/backends/spdm-socket.c index 2c709c68c8..bab1b512c8 100644 --- a/backends/spdm-socket.c +++ b/backends/spdm-socket.c @@ -184,6 +184,29 @@ int spdm_socket_connect(uint16_t port, Error **errp) return client_socket; } =20 +uint32_t spdm_socket_receive(const int socket, uint32_t transport_type, + void *rsp, uint32_t rsp_len) +{ + uint32_t command; + bool result; + + result =3D receive_platform_data(socket, transport_type, &command, + (uint8_t *)rsp, &rsp_len); + + if (!result || command =3D=3D 0) { + return 0; + } + + return rsp_len; +} + +bool spdm_socket_send(const int socket, uint32_t socket_cmd, + uint32_t transport_type, void *req, uint32_t req_len) +{ + return send_platform_data(socket, transport_type, + socket_cmd, req, req_len); +} + uint32_t spdm_socket_rsp(const int socket, uint32_t transport_type, void *req, uint32_t req_len, void *rsp, uint32_t rsp_len) @@ -200,12 +223,10 @@ uint32_t spdm_socket_rsp(const int socket, uint32_t t= ransport_type, =20 result =3D receive_platform_data(socket, transport_type, &command, (uint8_t *)rsp, &rsp_len); - if (!result) { + if (!result || command =3D=3D 0) { return 0; } =20 - assert(command !=3D 0); - return rsp_len; } =20 diff --git a/include/system/spdm-socket.h b/include/system/spdm-socket.h index 5d8bd9aa4e..2b7d03f82d 100644 --- a/include/system/spdm-socket.h +++ b/include/system/spdm-socket.h @@ -50,6 +50,35 @@ uint32_t spdm_socket_rsp(const int socket, uint32_t tran= sport_type, void *req, uint32_t req_len, void *rsp, uint32_t rsp_len); =20 +/** + * spdm_socket_rsp: Receive a message from an SPDM server + * @socket: socket returned from spdm_socket_connect() + * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro + * @rsp: response buffer + * @rsp_len: response buffer length + * + * Receives a message from the SPDM server and returns the number of bytes + * received or 0 on failure. This can be used to receive a message from th= e SPDM + * server without sending anything first. + */ +uint32_t spdm_socket_receive(const int socket, uint32_t transport_type, + void *rsp, uint32_t rsp_len); + +/** + * spdm_socket_rsp: Sends a message to an SPDM server + * @socket: socket returned from spdm_socket_connect() + * @socket_cmd: socket command type (normal/if_recv/if_send etc...) + * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro + * @req: request buffer + * @req_len: request buffer length + * + * Sends platform data to a SPDM server on socket, returns true on success. + * The response from the server must then be fetched by using + * spdm_socket_receive(). + */ +bool spdm_socket_send(const int socket, uint32_t socket_cmd, + uint32_t transport_type, void *req, uint32_t req_len= ); + /** * spdm_socket_close: send a shutdown command to the server * @socket: socket returned from spdm_socket_connect() @@ -60,6 +89,9 @@ uint32_t spdm_socket_rsp(const int socket, uint32_t trans= port_type, void spdm_socket_close(const int socket, uint32_t transport_type); =20 #define SPDM_SOCKET_COMMAND_NORMAL 0x0001 +#define SPDM_SOCKET_STORAGE_CMD_IF_SEND 0x0002 +#define SPDM_SOCKET_STORAGE_CMD_IF_RECV 0x0003 +#define SOCKET_SPDM_STORAGE_ACK_STATUS 0x0004 #define SPDM_SOCKET_COMMAND_OOB_ENCAP_KEY_UPDATE 0x8001 #define SPDM_SOCKET_COMMAND_CONTINUE 0xFFFD #define SPDM_SOCKET_COMMAND_SHUTDOWN 0xFFFE @@ -68,7 +100,10 @@ void spdm_socket_close(const int socket, uint32_t trans= port_type); =20 #define SPDM_SOCKET_TRANSPORT_TYPE_MCTP 0x01 #define SPDM_SOCKET_TRANSPORT_TYPE_PCI_DOE 0x02 +#define SPDM_SOCKET_TRANSPORT_TYPE_SCSI 0x03 +#define SPDM_SOCKET_TRANSPORT_TYPE_NVME 0x04 =20 #define SPDM_SOCKET_MAX_MESSAGE_BUFFER_SIZE 0x1200 +#define SPDM_SOCKET_MAX_MSG_STATUS_LEN 0x02 =20 #endif --=20 2.48.0