diff --git a/sys/dev/nvme/nvme_ctrlr_cmd.c b/sys/dev/nvme/nvme_ctrlr_cmd.c index 225d12befb6e..f41e1eb1a771 100644 --- a/sys/dev/nvme/nvme_ctrlr_cmd.c +++ b/sys/dev/nvme/nvme_ctrlr_cmd.c @@ -281,3 +281,19 @@ nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr, nvme_ctrlr_submit_admin_request(ctrlr, req); } + +void +nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, + uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg) +{ + struct nvme_request *req; + struct nvme_command *cmd; + + req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + + cmd = &req->cmd; + cmd->opc = NVME_OPC_ABORT; + cmd->cdw10 = (cid << 16) | sqid; + + nvme_ctrlr_submit_admin_request(ctrlr, req); +} diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index a74b876779f1..69024ba35383 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -348,6 +348,8 @@ void nvme_ctrlr_cmd_set_asynchronous_event_config(struct nvme_controller *ctrlr, void nvme_ctrlr_cmd_asynchronous_event_request(struct nvme_controller *ctrlr, nvme_cb_fn_t cb_fn, void *cb_arg); +void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, + uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg); void nvme_payload_map(void *arg, bus_dma_segment_t *seg, int nseg, int error); diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 7fafb7c88c84..6954830da03d 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -49,6 +49,8 @@ nvme_completion_check_retry(const struct nvme_completion *cpl) switch (cpl->sf_sct) { case NVME_SCT_GENERIC: switch (cpl->sf_sc) { + case NVME_SC_ABORTED_BY_REQUEST: + return (1); case NVME_SC_NAMESPACE_NOT_READY: if (cpl->sf_dnr) return (0); @@ -60,7 +62,6 @@ nvme_completion_check_retry(const struct nvme_completion *cpl) case NVME_SC_DATA_TRANSFER_ERROR: case NVME_SC_ABORTED_POWER_LOSS: case NVME_SC_INTERNAL_DEVICE_ERROR: - case NVME_SC_ABORTED_BY_REQUEST: case NVME_SC_ABORTED_SQ_DELETION: case NVME_SC_ABORTED_FAILED_FUSED: case NVME_SC_ABORTED_MISSING_FUSED: @@ -378,10 +379,10 @@ nvme_io_qpair_destroy(struct nvme_qpair *qpair) static void nvme_timeout(void *arg) { - /* - * TODO: Add explicit abort operation here, once nvme(4) supports - * abort commands. - */ + struct nvme_tracker *tr = arg; + + nvme_ctrlr_cmd_abort(tr->qpair->ctrlr, tr->cid, tr->qpair->id, + NULL, NULL); } void