Commit 71c69ddf authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

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: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I0f04c0d173a7058d4d4f7e59e573ce48130ff024
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6676


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent c4d01aa5
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -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)
{