Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/nvme/nvme_ctrlr_cmd.c
Show All 36 Lines | |||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_vaddr(payload, | req = nvme_allocate_request_vaddr(payload, | ||||
sizeof(struct nvme_controller_data), cb_fn, cb_arg); | sizeof(struct nvme_controller_data), cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_IDENTIFY); | cmd->opc = NVME_OPC_IDENTIFY; | ||||
/* | /* | ||||
* TODO: create an identify command data structure, which | * TODO: create an identify command data structure, which | ||||
* includes this CNS bit in cdw10. | * includes this CNS bit in cdw10. | ||||
*/ | */ | ||||
cmd->cdw10 = htole32(1); | cmd->cdw10 = htole32(1); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_identify_namespace(struct nvme_controller *ctrlr, uint32_t nsid, | nvme_ctrlr_cmd_identify_namespace(struct nvme_controller *ctrlr, uint32_t nsid, | ||||
void *payload, nvme_cb_fn_t cb_fn, void *cb_arg) | void *payload, nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_vaddr(payload, | req = nvme_allocate_request_vaddr(payload, | ||||
sizeof(struct nvme_namespace_data), cb_fn, cb_arg); | sizeof(struct nvme_namespace_data), cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_IDENTIFY); | cmd->opc = NVME_OPC_IDENTIFY; | ||||
/* | /* | ||||
* TODO: create an identify command data structure | * TODO: create an identify command data structure | ||||
*/ | */ | ||||
cmd->nsid = htole32(nsid); | cmd->nsid = htole32(nsid); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_create_io_cq(struct nvme_controller *ctrlr, | nvme_ctrlr_cmd_create_io_cq(struct nvme_controller *ctrlr, | ||||
struct nvme_qpair *io_que, uint16_t vector, nvme_cb_fn_t cb_fn, | struct nvme_qpair *io_que, uint16_t vector, nvme_cb_fn_t cb_fn, | ||||
void *cb_arg) | void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_CREATE_IO_CQ); | cmd->opc = NVME_OPC_CREATE_IO_CQ; | ||||
/* | /* | ||||
* TODO: create a create io completion queue command data | * TODO: create a create io completion queue command data | ||||
* structure. | * structure. | ||||
*/ | */ | ||||
cmd->cdw10 = htole32(((io_que->num_entries-1) << 16) | io_que->id); | cmd->cdw10 = htole32(((io_que->num_entries-1) << 16) | io_que->id); | ||||
/* 0x3 = interrupts enabled | physically contiguous */ | /* 0x3 = interrupts enabled | physically contiguous */ | ||||
cmd->cdw11 = htole32((vector << 16) | 0x3); | cmd->cdw11 = htole32((vector << 16) | 0x3); | ||||
cmd->prp1 = htole64(io_que->cpl_bus_addr); | cmd->prp1 = htole64(io_que->cpl_bus_addr); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_create_io_sq(struct nvme_controller *ctrlr, | nvme_ctrlr_cmd_create_io_sq(struct nvme_controller *ctrlr, | ||||
struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) | struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_CREATE_IO_SQ); | cmd->opc = NVME_OPC_CREATE_IO_SQ; | ||||
/* | /* | ||||
* TODO: create a create io submission queue command data | * TODO: create a create io submission queue command data | ||||
* structure. | * structure. | ||||
*/ | */ | ||||
cmd->cdw10 = htole32(((io_que->num_entries-1) << 16) | io_que->id); | cmd->cdw10 = htole32(((io_que->num_entries-1) << 16) | io_que->id); | ||||
/* 0x1 = physically contiguous */ | /* 0x1 = physically contiguous */ | ||||
cmd->cdw11 = htole32((io_que->id << 16) | 0x1); | cmd->cdw11 = htole32((io_que->id << 16) | 0x1); | ||||
cmd->prp1 = htole64(io_que->cmd_bus_addr); | cmd->prp1 = htole64(io_que->cmd_bus_addr); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_delete_io_cq(struct nvme_controller *ctrlr, | nvme_ctrlr_cmd_delete_io_cq(struct nvme_controller *ctrlr, | ||||
struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) | struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_DELETE_IO_CQ); | cmd->opc = NVME_OPC_DELETE_IO_CQ; | ||||
/* | /* | ||||
* TODO: create a delete io completion queue command data | * TODO: create a delete io completion queue command data | ||||
* structure. | * structure. | ||||
*/ | */ | ||||
cmd->cdw10 = htole32(io_que->id); | cmd->cdw10 = htole32(io_que->id); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_delete_io_sq(struct nvme_controller *ctrlr, | nvme_ctrlr_cmd_delete_io_sq(struct nvme_controller *ctrlr, | ||||
struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) | struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_DELETE_IO_SQ); | cmd->opc = NVME_OPC_DELETE_IO_SQ; | ||||
/* | /* | ||||
* TODO: create a delete io submission queue command data | * TODO: create a delete io submission queue command data | ||||
* structure. | * structure. | ||||
*/ | */ | ||||
cmd->cdw10 = htole32(io_que->id); | cmd->cdw10 = htole32(io_que->id); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr, uint8_t feature, | nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr, uint8_t feature, | ||||
uint32_t cdw11, void *payload, uint32_t payload_size, | uint32_t cdw11, void *payload, uint32_t payload_size, | ||||
nvme_cb_fn_t cb_fn, void *cb_arg) | nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_SET_FEATURES); | cmd->opc = NVME_OPC_SET_FEATURES; | ||||
cmd->cdw10 = htole32(feature); | cmd->cdw10 = htole32(feature); | ||||
cmd->cdw11 = htole32(cdw11); | cmd->cdw11 = htole32(cdw11); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, uint8_t feature, | nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, uint8_t feature, | ||||
uint32_t cdw11, void *payload, uint32_t payload_size, | uint32_t cdw11, void *payload, uint32_t payload_size, | ||||
nvme_cb_fn_t cb_fn, void *cb_arg) | nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_GET_FEATURES); | cmd->opc = NVME_OPC_GET_FEATURES; | ||||
cmd->cdw10 = htole32(feature); | cmd->cdw10 = htole32(feature); | ||||
cmd->cdw11 = htole32(cdw11); | cmd->cdw11 = htole32(cdw11); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
void | void | ||||
nvme_ctrlr_cmd_set_num_queues(struct nvme_controller *ctrlr, | nvme_ctrlr_cmd_set_num_queues(struct nvme_controller *ctrlr, | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | nvme_ctrlr_cmd_get_log_page(struct nvme_controller *ctrlr, uint8_t log_page, | ||||
void *cb_arg) | void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_vaddr(payload, payload_size, cb_fn, cb_arg); | req = nvme_allocate_request_vaddr(payload, payload_size, cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_GET_LOG_PAGE); | cmd->opc = NVME_OPC_GET_LOG_PAGE; | ||||
cmd->nsid = htole32(nsid); | cmd->nsid = htole32(nsid); | ||||
cmd->cdw10 = ((payload_size/sizeof(uint32_t)) - 1) << 16; | cmd->cdw10 = ((payload_size/sizeof(uint32_t)) - 1) << 16; | ||||
cmd->cdw10 |= log_page; | cmd->cdw10 |= log_page; | ||||
cmd->cdw10 = htole32(cmd->cdw10); | cmd->cdw10 = htole32(cmd->cdw10); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, | ||||
uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg) | uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg) | ||||
{ | { | ||||
struct nvme_request *req; | struct nvme_request *req; | ||||
struct nvme_command *cmd; | struct nvme_command *cmd; | ||||
req = nvme_allocate_request_null(cb_fn, cb_arg); | req = nvme_allocate_request_null(cb_fn, cb_arg); | ||||
cmd = &req->cmd; | cmd = &req->cmd; | ||||
cmd->opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_ABORT); | cmd->opc = NVME_OPC_ABORT; | ||||
cmd->cdw10 = htole32((cid << 16) | sqid); | cmd->cdw10 = htole32((cid << 16) | sqid); | ||||
nvme_ctrlr_submit_admin_request(ctrlr, req); | nvme_ctrlr_submit_admin_request(ctrlr, req); | ||||
} | } |