Lines Matching +full:- +full:sc

3  * SPDX-License-Identifier: Apache-2.0
34 uint16_t sc; member
44 { NVME_SC_ABORTED_POWER_LOSS, "ABORTED - POWER LOSS" },
46 { NVME_SC_ABORTED_BY_REQUEST, "ABORTED - BY REQUEST" },
47 { NVME_SC_ABORTED_SQ_DELETION, "ABORTED - SQ DELETION" },
48 { NVME_SC_ABORTED_FAILED_FUSED, "ABORTED - FAILED FUSED" },
49 { NVME_SC_ABORTED_MISSING_FUSED, "ABORTED - MISSING FUSED" },
109 { NVME_SC_SELF_TEST_IN_PROGRESS, "DEVICE SELF-TEST IN PROGRESS" },
148 static const char *get_status_string(uint16_t sct, uint16_t sc) in get_status_string() argument
171 while (entry->sc != 0xFFFF) { in get_status_string()
172 if (entry->sc == sc) { in get_status_string()
173 return entry->str; in get_status_string()
178 return entry->str; in get_status_string()
183 uint8_t sct, sc, crd, m, dnr, p; in nvme_completion_print() local
185 sct = NVME_STATUS_GET_SCT(cpl->status); in nvme_completion_print()
186 sc = NVME_STATUS_GET_SC(cpl->status); in nvme_completion_print()
187 crd = NVME_STATUS_GET_CRD(cpl->status); in nvme_completion_print()
188 m = NVME_STATUS_GET_M(cpl->status); in nvme_completion_print()
189 dnr = NVME_STATUS_GET_DNR(cpl->status); in nvme_completion_print()
190 p = NVME_STATUS_GET_P(cpl->status); in nvme_completion_print()
194 get_status_string(sct, sc), sct, sc, crd, m, dnr, p, in nvme_completion_print()
195 cpl->sqid, cpl->cid, cpl->cdw0); in nvme_completion_print()
235 sys_dlist_append(&free_prp_list, &prp_list->node); in nvme_prp_list_free()
240 if (sys_dnode_is_linked(&request->node)) { in nvme_cmd_request_free()
241 sys_dlist_remove(&request->node); in nvme_cmd_request_free()
244 if (request->prp_list != NULL) { in nvme_cmd_request_free()
245 nvme_prp_list_free(request->prp_list); in nvme_cmd_request_free()
249 sys_dlist_append(&free_request, &request->node); in nvme_cmd_request_free()
269 sys_dlist_append(&pending_request, &request->node); in nvme_cmd_register_request()
271 request->req_start = k_uptime_get_32(); in nvme_cmd_register_request()
288 if ((int32_t)(request->req_start + in request_timeout()
289 CONFIG_NVME_REQUEST_TIMEOUT - current) > 0) { in request_timeout()
293 LOG_WRN("Request %p CID %u timed-out", in request_timeout()
294 request, request->cmd.cdw0.cid); in request_timeout()
297 * - check CSTS for fatal fault in request_timeout()
298 * - reset hw otherwise if it's the case in request_timeout()
299 * - or check completion for missed interruption in request_timeout()
302 if (request->cb_fn) { in request_timeout()
303 request->cb_fn(request->cb_arg, NULL); in request_timeout()
311 K_SECONDS(request->req_start + in request_timeout()
312 CONFIG_NVME_REQUEST_TIMEOUT - in request_timeout()
319 uint8_t sct, sc, dnr; in nvme_completion_is_retry() local
321 sct = NVME_STATUS_GET_SCT(cpl->status); in nvme_completion_is_retry()
322 sc = NVME_STATUS_GET_SC(cpl->status); in nvme_completion_is_retry()
323 dnr = NVME_STATUS_GET_DNR(cpl->status); in nvme_completion_is_retry()
334 switch (sc) { in nvme_completion_is_retry()
362 switch (sc) { in nvme_completion_is_retry()
386 request->retries < CONFIG_NVME_RETRY_COUNT; in nvme_cmd_request_complete()
390 request->qpair->num_retries++; in nvme_cmd_request_complete()
394 (!retriable || (request->retries >= CONFIG_NVME_RETRY_COUNT))) { in nvme_cmd_request_complete()
396 request->qpair->num_failures++; in nvme_cmd_request_complete()
399 if (cpl->cid != request->cmd.cdw0.cid) { in nvme_cmd_request_complete()
406 sys_dlist_remove(&request->node); in nvme_cmd_request_complete()
407 /* ...and re-submit, thus re-adding to pending */ in nvme_cmd_request_complete()
408 nvme_cmd_qpair_submit_request(request->qpair, request); in nvme_cmd_request_complete()
409 request->retries++; in nvme_cmd_request_complete()
412 request, request->cb_fn, request->cb_arg); in nvme_cmd_request_complete()
414 if (request->cb_fn) { in nvme_cmd_request_complete()
415 request->cb_fn(request->cb_arg, cpl); in nvme_cmd_request_complete()
428 if (qpair->num_intr_handler_calls == 0 && qpair->phase == 0) { in nvme_cmd_qpair_process_completion()
432 qpair->num_intr_handler_calls++; in nvme_cmd_qpair_process_completion()
437 status = sys_le16_to_cpu(qpair->cpl[qpair->cq_head].status); in nvme_cmd_qpair_process_completion()
438 if (NVME_STATUS_GET_P(status) != qpair->phase) { in nvme_cmd_qpair_process_completion()
442 cpl = qpair->cpl[qpair->cq_head]; in nvme_cmd_qpair_process_completion()
458 qpair->sq_head = cpl.sqhd; in nvme_cmd_qpair_process_completion()
463 qpair->cq_head++; in nvme_cmd_qpair_process_completion()
464 if (qpair->cq_head == qpair->num_entries) { in nvme_cmd_qpair_process_completion()
465 qpair->cq_head = 0; in nvme_cmd_qpair_process_completion()
466 qpair->phase = !qpair->phase; in nvme_cmd_qpair_process_completion()
471 mm_reg_t regs = DEVICE_MMIO_GET(qpair->ctrlr->dev); in nvme_cmd_qpair_process_completion()
473 sys_write32(qpair->cq_head, regs + qpair->cq_hdbl_off); in nvme_cmd_qpair_process_completion()
489 ctrlr->dev->config; in nvme_cmd_qpair_setup()
491 qpair->ctrlr = ctrlr; in nvme_cmd_qpair_setup()
492 qpair->id = id; in nvme_cmd_qpair_setup()
493 qpair->vector = qpair->id; in nvme_cmd_qpair_setup()
495 qpair->num_cmds = 0; in nvme_cmd_qpair_setup()
496 qpair->num_intr_handler_calls = 0; in nvme_cmd_qpair_setup()
497 qpair->num_retries = 0; in nvme_cmd_qpair_setup()
498 qpair->num_failures = 0; in nvme_cmd_qpair_setup()
499 qpair->num_ignored = 0; in nvme_cmd_qpair_setup()
501 qpair->cmd_bus_addr = (uintptr_t)qpair->cmd; in nvme_cmd_qpair_setup()
502 qpair->cpl_bus_addr = (uintptr_t)qpair->cpl; in nvme_cmd_qpair_setup()
504 qpair->sq_tdbl_off = nvme_mmio_offsetof(doorbell) + in nvme_cmd_qpair_setup()
505 (qpair->id << (ctrlr->dstrd + 1)); in nvme_cmd_qpair_setup()
506 qpair->cq_hdbl_off = nvme_mmio_offsetof(doorbell) + in nvme_cmd_qpair_setup()
507 (qpair->id << (ctrlr->dstrd + 1)) + (1 << ctrlr->dstrd); in nvme_cmd_qpair_setup()
509 if (!pcie_msi_vector_connect(nvme_ctrlr_cfg->pcie->bdf, in nvme_cmd_qpair_setup()
510 &ctrlr->vectors[qpair->vector], in nvme_cmd_qpair_setup()
512 LOG_ERR("Failed to connect MSI-X vector %u", qpair->id); in nvme_cmd_qpair_setup()
513 return -EIO; in nvme_cmd_qpair_setup()
516 LOG_DBG("CMD Qpair created ID %u, %u entries - cmd/cpl addr " in nvme_cmd_qpair_setup()
517 "0x%lx/0x%lx - sq/cq offsets %u/%u", in nvme_cmd_qpair_setup()
518 qpair->id, qpair->num_entries, qpair->cmd_bus_addr, in nvme_cmd_qpair_setup()
519 qpair->cpl_bus_addr, qpair->sq_tdbl_off, qpair->cq_hdbl_off); in nvme_cmd_qpair_setup()
526 qpair->sq_head = qpair->sq_tail = qpair->cq_head = 0; in nvme_cmd_qpair_reset()
535 qpair->phase = 1; in nvme_cmd_qpair_reset()
537 memset(qpair->cmd, 0, in nvme_cmd_qpair_reset()
538 qpair->num_entries * sizeof(struct nvme_command)); in nvme_cmd_qpair_reset()
539 memset(qpair->cpl, 0, in nvme_cmd_qpair_reset()
540 qpair->num_entries * sizeof(struct nvme_completion)); in nvme_cmd_qpair_reset()
553 return -ENOMEM; in nvme_cmd_qpair_fill_prp_list()
556 p_addr = (uintptr_t)request->payload; in nvme_cmd_qpair_fill_prp_list()
557 request->cmd.dptr.prp1 = in nvme_cmd_qpair_fill_prp_list()
559 request->cmd.dptr.prp2 = in nvme_cmd_qpair_fill_prp_list()
560 (uint64_t)sys_cpu_to_le64(&prp_list->prp); in nvme_cmd_qpair_fill_prp_list()
564 prp_list->prp[idx] = (uint64_t)sys_cpu_to_le64(p_addr); in nvme_cmd_qpair_fill_prp_list()
568 request->prp_list = prp_list; in nvme_cmd_qpair_fill_prp_list()
602 switch (request->type) { in nvme_cmd_qpair_fill_dptr()
608 if (request->payload_size > qpair->ctrlr->max_xfer_size) { in nvme_cmd_qpair_fill_dptr()
610 return -EINVAL; in nvme_cmd_qpair_fill_dptr()
613 n_prp = compute_n_prp((uintptr_t)request->payload, in nvme_cmd_qpair_fill_dptr()
614 request->payload_size); in nvme_cmd_qpair_fill_dptr()
616 request->cmd.dptr.prp1 = in nvme_cmd_qpair_fill_dptr()
617 (uint64_t)sys_cpu_to_le64(request->payload); in nvme_cmd_qpair_fill_dptr()
619 request->cmd.dptr.prp2 = (uint64_t)sys_cpu_to_le64( in nvme_cmd_qpair_fill_dptr()
621 (uintptr_t)request->payload)); in nvme_cmd_qpair_fill_dptr()
623 request->cmd.dptr.prp2 = 0; in nvme_cmd_qpair_fill_dptr()
640 mm_reg_t regs = DEVICE_MMIO_GET(qpair->ctrlr->dev); in nvme_cmd_qpair_submit_request()
643 request->qpair = qpair; in nvme_cmd_qpair_submit_request()
645 request->cmd.cdw0.cid = sys_cpu_to_le16((uint16_t)(request - in nvme_cmd_qpair_submit_request()
656 memcpy(&qpair->cmd[qpair->sq_tail], in nvme_cmd_qpair_submit_request()
657 &request->cmd, sizeof(request->cmd)); in nvme_cmd_qpair_submit_request()
659 qpair->sq_tail++; in nvme_cmd_qpair_submit_request()
660 if (qpair->sq_tail == qpair->num_entries) { in nvme_cmd_qpair_submit_request()
661 qpair->sq_tail = 0; in nvme_cmd_qpair_submit_request()
664 sys_write32(qpair->sq_tail, regs + qpair->sq_tdbl_off); in nvme_cmd_qpair_submit_request()
665 qpair->num_cmds++; in nvme_cmd_qpair_submit_request()
667 LOG_DBG("Request %p %llu submitted: CID %u - sq_tail %u", in nvme_cmd_qpair_submit_request()
668 request, qpair->num_cmds, request->cmd.cdw0.cid, in nvme_cmd_qpair_submit_request()
669 qpair->sq_tail - 1); in nvme_cmd_qpair_submit_request()
679 memcpy(&status->cpl, cpl, sizeof(*cpl)); in nvme_completion_poll_cb()
681 status->status = -ETIMEDOUT; in nvme_completion_poll_cb()
684 k_sem_give(&status->sem); in nvme_completion_poll_cb()