summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-07-10 22:00:27 -0400
committerIan Moffett <ian@osmora.org>2024-07-10 22:04:21 -0400
commit26e17c070f845e4d93bff080eead9f5d22253319 (patch)
tree69a64015f8fc00d16c73c109d4304bea6af2617b /sys/dev/ic
parent67f9d3c5e58f1a958a2b1b7a102a71e3ce252fc4 (diff)
kernel: nvme: Improve nvme_identify()
Require an NSID and CNS value to be passed to the nvme_identify() function. This enables the caller to control what type of data is returned by the NVMe controller. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/nvme.c13
1 files changed, 7 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;
}