external_code/nvme: process completion queue
Added function that check the completion queue for completed commands, executes their callbacks, and puts the associated requests back onto the free request queue. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I0f04c0d173a7058d4d4f7e59e573ce48130ff024 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6676 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
c4d01aa5b7
commit
71c69ddfc3
@ -433,6 +433,45 @@ identify_ctrlr(struct nvme_ctrlr *ctrlr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t process_completions(struct nvme_qpair *qpair);
|
||||
|
||||
int32_t
|
||||
process_completions(struct nvme_qpair *qpair)
|
||||
{
|
||||
struct spdk_nvme_cpl *cpl;
|
||||
struct nvme_request *request;
|
||||
int32_t max_completions, num_completions = 0;
|
||||
|
||||
max_completions = qpair->num_entries - 1;
|
||||
while (1) {
|
||||
cpl = &qpair->cpl[qpair->cq_head];
|
||||
|
||||
if (cpl->status.p != qpair->phase) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (spdk_unlikely(++qpair->cq_head == qpair->num_entries)) {
|
||||
qpair->cq_head = 0;
|
||||
qpair->phase = !qpair->phase;
|
||||
}
|
||||
|
||||
qpair->sq_head = cpl->sqhd;
|
||||
request = &qpair->requests[cpl->cid];
|
||||
request->cb_fn(request->cb_arg, cpl);
|
||||
TAILQ_INSERT_TAIL(&qpair->free_requests, request, tailq);
|
||||
|
||||
if (++num_completions == max_completions) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_completions > 0) {
|
||||
spdk_mmio_write_4(qpair->cq_hdbl, qpair->cq_head);
|
||||
}
|
||||
|
||||
return num_completions;
|
||||
}
|
||||
|
||||
static int
|
||||
process_ctrlr_init(struct nvme_ctrlr *ctrlr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user