diff options
-rw-r--r-- | sys/dev/ic/nvme.c | 13 | ||||
-rw-r--r-- | sys/include/dev/ic/nvmevar.h | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index 5f92d0e..9eb302b 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -244,19 +244,19 @@ nvme_poll_submit_cmd(struct nvme_queue *q, struct nvme_cmd cmd) } static int -nvme_identify(struct nvme_ctrl *ctrl, struct nvme_id *id) +nvme_identify(struct nvme_ctrl *ctrl, void *buf, uint32_t nsid, uint8_t cns) { struct nvme_cmd cmd = {0}; struct nvme_identify_cmd *idcmd = &cmd.identify; - if (!is_4k_aligned(id)) { + if (!is_4k_aligned(buf)) { return -1; } idcmd->opcode = NVME_OP_IDENTIFY; - idcmd->nsid = 0; - idcmd->cns = 1; /* Identify controller */ - idcmd->prp1 = VIRT_TO_PHYS(id); + idcmd->nsid = nsid; + idcmd->cns = cns; /* Identify controller */ + idcmd->prp1 = VIRT_TO_PHYS(buf); idcmd->prp2 = 0; return nvme_poll_submit_cmd(&ctrl->adminq, cmd); } @@ -338,8 +338,9 @@ nvme_init_ctrl(struct nvme_bar *bar) return -ENOMEM; } - nvme_identify(&ctrl, id); + nvme_identify(&ctrl, id, 0, ID_CNS_CTRL); nvme_log_ctrl_id(id); + dynfree(id); return 0; } diff --git a/sys/include/dev/ic/nvmevar.h b/sys/include/dev/ic/nvmevar.h index aa68331..355abd8 100644 --- a/sys/include/dev/ic/nvmevar.h +++ b/sys/include/dev/ic/nvmevar.h @@ -37,6 +37,10 @@ #define NVME_OP_CREATE_IOCQ 0x05 #define NVME_OP_IDENTIFY 0x06 +/* Identify CNS values */ +#define ID_CNS_CTRL 0x01 /* Identify controller */ +#define ID_CNS_NSID_LIST 0x07 /* Active NSID list */ + struct nvme_identify_cmd { uint8_t opcode; uint8_t flags; |