From a2f8265e5d437e49244ffeb2926b46c056adb9fb Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 13 Jul 2024 17:39:10 -0400 Subject: kernel: nvme: Add nvme bdevsw + support for reads Signed-off-by: Ian Moffett --- sys/include/dev/ic/nvmevar.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sys/include/dev/ic') diff --git a/sys/include/dev/ic/nvmevar.h b/sys/include/dev/ic/nvmevar.h index b16f51d..ee829dc 100644 --- a/sys/include/dev/ic/nvmevar.h +++ b/sys/include/dev/ic/nvmevar.h @@ -41,6 +41,10 @@ #define ID_CNS_CTRL 0x01 /* Identify controller */ #define ID_CNS_NSID_LIST 0x07 /* Active NSID list */ +/* I/O commands */ +#define NVME_OP_WRITE 0x01 +#define NVME_OP_READ 0x02 + struct nvme_identify_cmd { uint8_t opcode; uint8_t flags; @@ -94,11 +98,32 @@ struct nvme_create_iosq_cmd { uint64_t unused3[2]; }; +/* Read/write */ +struct nvme_rw_cmd { + uint8_t opcode; + uint8_t flags; + uint16_t cid; + uint32_t nsid; + uint64_t unused; + uint64_t metadata; + uint64_t prp1; + uint64_t prp2; + uint64_t slba; + uint16_t len; + uint16_t control; + uint32_t dsmgmt; + uint32_t ref; + uint16_t apptag; + uint16_t appmask; +}; + + struct nvme_cmd { union { struct nvme_identify_cmd identify; struct nvme_create_iocq_cmd create_iocq; struct nvme_create_iosq_cmd create_iosq; + struct nvme_rw_cmd rw; }; }; @@ -203,6 +228,7 @@ struct nvme_ns { struct nvme_queue ioq; /* I/O queue */ struct nvme_lbaf lba_fmt; /* LBA format */ struct nvme_ctrl *ctrl; /* NVMe controller */ + dev_t dev; TAILQ_ENTRY(nvme_ns) link; }; -- cgit v1.2.3