From nobody Tue Aug 27 01:06:25 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wt8WP5kXLz5TjJJ; Tue, 27 Aug 2024 01:06:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wt8WP4vt4z4lN0; Tue, 27 Aug 2024 01:06:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pQDkyTq+ZxrSOk5og2y69r0zY+JLE+tMegRzzG2Qn+w=; b=JwqiPrtnf2YcM50dR+T8ZSSRPV3O93sdKkAsOQ17MyMV3GlCRNjKD+A7gYckTiGUk5cUZy WO+CsQzow7bgblHW05xwFjG1yD+YBSQe2lE4asNCXfmVwwU/9Vx4EgG9FItq5EcRip9s2C sIg1gZob+SE84brycCKGIa832NqhQcSAcbfaSsHomZDOMyKpMQBqcNFLtu1tm7gwO566P3 iCnsUcASuWsnOzzPLFtawd4afnthrM4BPAd9eknapPou8RRXaeixRKBMLsHQyb3hWB+G0b z1cv3VV23ejOp7kLKLX+81ziwp6sbTYf/+R08urQE8lHUSRx5KaDNS8SdM++ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724720785; a=rsa-sha256; cv=none; b=rUOoxfPOAyVt0g253rvJcMeKcJ946jVe5zSZuiJlyg6qijvZfu8Q4Ltii556UxDx0TX8Bq NvxTRl4zj11iRomVvhDblI2Vu/w3LlIRzvj4MU2+3j94YHiYvSoWytDZndn7PVxjJ0uI2Y Kurj4LdqzGEPQHXvK6eItO55DjCZCQoKuWWhBRvxS1V//TLt/sEH442Nqng2ZVYnsbJhfN 8rCe5SRTf8CMgjD6ob0JL0YOiZVHH62cxjOK+ANxEsdMSNZpCh8T0l+0eW8IDN3kgh8nIy OjMuGLTM0V+QG7YTynGF9MZrcj3PTPUxcHolHxwgET6PX9U0yzcRU+nP/rEe6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pQDkyTq+ZxrSOk5og2y69r0zY+JLE+tMegRzzG2Qn+w=; b=U9XMkd6XWsNuLSE9zyUp64KLg/p5Ya7FnLEd/hDLMFSps4xU8OwatF+4d9p5WDmmRSrO5w HLzksPWotinLhGx6nwsL6D8phUosKp/lJfLHyMYO4ilgw8f6WETCWL6hi/SXCFDbK+g7RW DUk0xj1nce7jgl8xaVky+iD7VVcLCqYC/qUkyqcm5k9t7giEH8Ar41Gxo5Wh1wwP0X4G6r SeyWV1TAwhSO8ld6kyQOfQt4+Tbannik14XbCoXDHEK5YUlRUDR4QnAyPJ90skSu8zkneU MYoRMEe0xj/dx6Mqkm7RYL2h2aRRdV8isM/DEdY6QyO7/X5Fe1wZKO4zs1HqoA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wt8WP4Q5ZzTjY; Tue, 27 Aug 2024 01:06:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47R16PIh056428; Tue, 27 Aug 2024 01:06:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47R16PSA056425; Tue, 27 Aug 2024 01:06:25 GMT (envelope-from git) Date: Tue, 27 Aug 2024 01:06:25 GMT Message-Id: <202408270106.47R16PSA056425@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 1e066e460403 - stable/14 - nvme: Add SGL structure and constants for use in NVMe commands List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1e066e46040354f244561894911e0938c9ef4df7 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=1e066e46040354f244561894911e0938c9ef4df7 commit 1e066e46040354f244561894911e0938c9ef4df7 Author: John Baldwin AuthorDate: 2024-03-23 00:23:09 +0000 Commit: John Baldwin CommitDate: 2024-08-26 18:27:28 +0000 nvme: Add SGL structure and constants for use in NVMe commands Fabrics capsules use an SGL structure instead of prp1/2 addresses to describe the data buffer used for a command. The SGL structure is added to a union with the existing prp1/2 fields. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44442 (cherry picked from commit f21a54d19080510bce279183f4bf07d5315bd179) --- sys/dev/nvme/nvme.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index ee387d54985e..f00090731dff 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -433,6 +433,25 @@ #define NVME_CTRLR_DATA_VWC_ALL_NO (2) #define NVME_CTRLR_DATA_VWC_ALL_YES (3) +/** SGL Support */ +/* NVM command set SGL support */ +#define NVME_CTRLR_DATA_SGLS_NVM_COMMAND_SET_SHIFT (0) +#define NVME_CTRLR_DATA_SGLS_NVM_COMMAND_SET_MASK (0x3) +#define NVME_CTRLR_DATA_SGLS_KEYED_DATA_BLOCK_SHIFT (2) +#define NVME_CTRLR_DATA_SGLS_KEYED_DATA_BLOCK_MASK (0x1) +#define NVME_CTRLR_DATA_SGLS_BIT_BUCKET_SHIFT (16) +#define NVME_CTRLR_DATA_SGLS_BIT_BUCKET_MASK (0x1) +#define NVME_CTRLR_DATA_SGLS_CONTIG_MPTR_SHIFT (17) +#define NVME_CTRLR_DATA_SGLS_CONTIG_MPTR_MASK (0x1) +#define NVME_CTRLR_DATA_SGLS_OVERSIZED_SHIFT (18) +#define NVME_CTRLR_DATA_SGLS_OVERSIZED_MASK (0x1) +#define NVME_CTRLR_DATA_SGLS_MPTR_SGL_SHIFT (19) +#define NVME_CTRLR_DATA_SGLS_MPTR_SGL_MASK (0x1) +#define NVME_CTRLR_DATA_SGLS_ADDRESS_AS_OFFSET_SHIFT (20) +#define NVME_CTRLR_DATA_SGLS_ADDRESS_AS_OFFSET_MASK (0x1) +#define NVME_CTRLR_DATA_SGLS_TRANSPORT_DATA_BLOCK_SHIFT (21) +#define NVME_CTRLR_DATA_SGLS_TRANSPORT_DATA_BLOCK_MASK (0x1) + /** namespace features */ /* thin provisioning */ #define NVME_NS_DATA_NSFEAT_THIN_PROV_SHIFT (0) @@ -674,6 +693,38 @@ struct nvme_registers { _Static_assert(sizeof(struct nvme_registers) == 0x1008, "bad size for nvme_registers"); +#define NVME_SGL_SUBTYPE_SHIFT (0) +#define NVME_SGL_SUBTYPE_MASK (0xF) +#define NVME_SGL_TYPE_SHIFT (4) +#define NVME_SGL_TYPE_MASK (0xF) + +#define NVME_SGL_TYPE(type, subtype) \ + ((subtype) << NVME_SGL_SUBTYPE_SHIFT | (type) << NVME_SGL_TYPE_SHIFT) + +enum nvme_sgl_type { + NVME_SGL_TYPE_DATA_BLOCK = 0x0, + NVME_SGL_TYPE_BIT_BUCKET = 0x1, + NVME_SGL_TYPE_SEGMENT = 0x2, + NVME_SGL_TYPE_LAST_SEGMENT = 0x3, + NVME_SGL_TYPE_KEYED_DATA_BLOCK = 0x4, + NVME_SGL_TYPE_TRANSPORT_DATA_BLOCK = 0x5, +}; + +enum nvme_sgl_subtype { + NVME_SGL_SUBTYPE_ADDRESS = 0x0, + NVME_SGL_SUBTYPE_OFFSET = 0x1, + NVME_SGL_SUBTYPE_TRANSPORT = 0xa, +}; + +struct nvme_sgl_descriptor { + uint64_t address; + uint32_t length; + uint8_t reserved[3]; + uint8_t type; +}; + +_Static_assert(sizeof(struct nvme_sgl_descriptor) == 16, "bad size for nvme_sgl_descriptor"); + struct nvme_command { /* dword 0 */ uint8_t opc; /* opcode */ @@ -690,11 +741,14 @@ struct nvme_command { /* dword 4-5 */ uint64_t mptr; /* metadata pointer */ - /* dword 6-7 */ - uint64_t prp1; /* prp entry 1 */ - - /* dword 8-9 */ - uint64_t prp2; /* prp entry 2 */ + /* dword 6-9 */ + union { + struct { + uint64_t prp1; /* prp entry 1 */ + uint64_t prp2; /* prp entry 2 */ + }; + struct nvme_sgl_descriptor sgl; + }; /* dword 10-15 */ uint32_t cdw10; /* command-specific */