nvme: convert nvme_tracker list to a TAILQ

Change-Id: I822529b28b683f707604c07721040f22689961c4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Isaac Otsiabah 2016-12-10 15:39:54 -07:00 committed by Daniel Verkamp
parent ea3a2772ac
commit a4cc346b17
2 changed files with 32 additions and 32 deletions

View File

@ -111,7 +111,7 @@ struct nvme_pcie_ctrlr {
};
struct nvme_tracker {
LIST_ENTRY(nvme_tracker) list;
TAILQ_ENTRY(nvme_tracker) tq_list;
struct nvme_request *req;
uint16_t cid;
@ -151,8 +151,8 @@ struct nvme_pcie_qpair {
/* Completion queue */
struct spdk_nvme_cpl *cpl;
LIST_HEAD(, nvme_tracker) free_tr;
LIST_HEAD(, nvme_tracker) outstanding_tr;
TAILQ_HEAD(, nvme_tracker) free_tr;
TAILQ_HEAD(nvme_outstanding_tr_head, nvme_tracker) outstanding_tr;
/* Array of trackers indexed by command ID. */
struct nvme_tracker *tr;
@ -806,13 +806,13 @@ nvme_pcie_qpair_construct(struct spdk_nvme_qpair *qpair)
return -ENOMEM;
}
LIST_INIT(&pqpair->free_tr);
LIST_INIT(&pqpair->outstanding_tr);
TAILQ_INIT(&pqpair->free_tr);
TAILQ_INIT(&pqpair->outstanding_tr);
for (i = 0; i < num_trackers; i++) {
tr = &pqpair->tr[i];
nvme_qpair_construct_tracker(tr, i, phys_addr);
LIST_INSERT_HEAD(&pqpair->free_tr, tr, list);
TAILQ_INSERT_HEAD(&pqpair->free_tr, tr, tq_list);
phys_addr += sizeof(struct nvme_tracker);
}
@ -998,8 +998,8 @@ nvme_pcie_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_trac
tr->req = NULL;
LIST_REMOVE(tr, list);
LIST_INSERT_HEAD(&pqpair->free_tr, tr, list);
TAILQ_REMOVE(&pqpair->outstanding_tr, tr, tq_list);
TAILQ_INSERT_HEAD(&pqpair->free_tr, tr, tq_list);
/*
* If the controller is in the middle of resetting, don't
@ -1037,7 +1037,7 @@ nvme_pcie_qpair_abort_trackers(struct spdk_nvme_qpair *qpair, uint32_t dnr)
struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair);
struct nvme_tracker *tr, *temp;
LIST_FOREACH_SAFE(tr, &pqpair->outstanding_tr, list, temp) {
TAILQ_FOREACH_SAFE(tr, &pqpair->outstanding_tr, tq_list, temp) {
SPDK_ERRLOG("aborting outstanding command\n");
nvme_pcie_qpair_manual_complete_tracker(qpair, tr, SPDK_NVME_SCT_GENERIC,
SPDK_NVME_SC_ABORTED_BY_REQUEST, dnr, true);
@ -1050,16 +1050,16 @@ nvme_pcie_admin_qpair_abort_aers(struct spdk_nvme_qpair *qpair)
struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair);
struct nvme_tracker *tr;
tr = LIST_FIRST(&pqpair->outstanding_tr);
tr = TAILQ_FIRST(&pqpair->outstanding_tr);
while (tr != NULL) {
assert(tr->req != NULL);
if (tr->req->cmd.opc == SPDK_NVME_OPC_ASYNC_EVENT_REQUEST) {
nvme_pcie_qpair_manual_complete_tracker(qpair, tr,
SPDK_NVME_SCT_GENERIC, SPDK_NVME_SC_ABORTED_SQ_DELETION, 0,
false);
tr = LIST_FIRST(&pqpair->outstanding_tr);
tr = TAILQ_FIRST(&pqpair->outstanding_tr);
} else {
tr = LIST_NEXT(tr, list);
tr = TAILQ_NEXT(tr, tq_list);
}
}
}
@ -1673,7 +1673,7 @@ nvme_pcie_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_reques
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
}
tr = LIST_FIRST(&pqpair->free_tr);
tr = TAILQ_FIRST(&pqpair->free_tr);
if (tr == NULL || !pqpair->is_enabled) {
/*
@ -1689,8 +1689,8 @@ nvme_pcie_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_reques
goto exit;
}
LIST_REMOVE(tr, list); /* remove tr from free_tr */
LIST_INSERT_HEAD(&pqpair->outstanding_tr, tr, list);
TAILQ_REMOVE(&pqpair->free_tr, tr, tq_list); /* remove tr from free_tr */
TAILQ_INSERT_HEAD(&pqpair->outstanding_tr, tr, tq_list);
tr->req = req;
req->cmd.cid = tr->cid;

View File

@ -251,9 +251,9 @@ ut_insert_cq_entry(struct spdk_nvme_qpair *qpair, uint32_t slot)
SPDK_CU_ASSERT_FATAL(req != NULL);
memset(req, 0, sizeof(*req));
tr = LIST_FIRST(&qpair->free_tr);
LIST_REMOVE(tr, list); /* remove tr from free_tr */
LIST_INSERT_HEAD(&qpair->outstanding_tr, tr, list);
tr = TAILQ_FIRST(&qpair->free_tr);
TAILQ_REMOVE(&qpair->free_tr, tr, tq_list); /* remove tr from free_tr */
TAILQ_INSERT_HEAD(&qpair->outstanding_tr, tr, tq_list);
req->cmd.cid = tr->cid;
tr->req = req;
qpair->tr[tr->cid].active = true;
@ -391,13 +391,13 @@ test_sgl_req(void)
CU_ASSERT(req->cmd.dptr.prp.prp1 == 0);
CU_ASSERT(qpair.sq_tail == 1);
sgl_tr = LIST_FIRST(&qpair.outstanding_tr);
sgl_tr = TAILQ_FIRST(&qpair.outstanding_tr);
if (sgl_tr != NULL) {
for (i = 0; i < NVME_MAX_PRP_LIST_ENTRIES; i++) {
CU_ASSERT(sgl_tr->u.prp[i] == (PAGE_SIZE * (i + 1)));
}
LIST_REMOVE(sgl_tr, list);
TAILQ_REMOVE(&qpair.outstanding_tr, sgl_tr, tq_list);
}
cleanup_submit_request_test(&qpair);
nvme_free_request(req);
@ -430,14 +430,14 @@ test_hw_sgl_req(void)
nvme_qpair_submit_request(&qpair, req);
sgl_tr = LIST_FIRST(&qpair.outstanding_tr);
sgl_tr = TAILQ_FIRST(&qpair.outstanding_tr);
CU_ASSERT(sgl_tr != NULL);
CU_ASSERT(sgl_tr->u.sgl[0].generic.type == SPDK_NVME_SGL_TYPE_DATA_BLOCK);
CU_ASSERT(sgl_tr->u.sgl[0].generic.subtype == 0);
CU_ASSERT(sgl_tr->u.sgl[0].unkeyed.length == 4096);
CU_ASSERT(sgl_tr->u.sgl[0].address == 0);
CU_ASSERT(req->cmd.dptr.sgl1.generic.type == SPDK_NVME_SGL_TYPE_DATA_BLOCK);
LIST_REMOVE(sgl_tr, list);
TAILQ_REMOVE(&qpair.outstanding_tr, sgl_tr, tq_list);
cleanup_submit_request_test(&qpair);
nvme_free_request(req);
@ -452,7 +452,7 @@ test_hw_sgl_req(void)
nvme_qpair_submit_request(&qpair, req);
sgl_tr = LIST_FIRST(&qpair.outstanding_tr);
sgl_tr = TAILQ_FIRST(&qpair.outstanding_tr);
CU_ASSERT(sgl_tr != NULL);
for (i = 0; i < NVME_MAX_SGL_DESCRIPTORS; i++) {
CU_ASSERT(sgl_tr->u.sgl[i].generic.type == SPDK_NVME_SGL_TYPE_DATA_BLOCK);
@ -461,7 +461,7 @@ test_hw_sgl_req(void)
CU_ASSERT(sgl_tr->u.sgl[i].address == i * 4096);
}
CU_ASSERT(req->cmd.dptr.sgl1.generic.type == SPDK_NVME_SGL_TYPE_LAST_SEGMENT);
LIST_REMOVE(sgl_tr, list);
TAILQ_REMOVE(&qpair.outstanding_tr, sgl_tr, tq_list);
cleanup_submit_request_test(&qpair);
nvme_free_request(req);
}
@ -511,16 +511,16 @@ static void test_nvme_qpair_fail(void)
prepare_submit_request_test(&qpair, &ctrlr);
tr_temp = LIST_FIRST(&qpair.free_tr);
tr_temp = TAILQ_FIRST(&qpair.free_tr);
SPDK_CU_ASSERT_FATAL(tr_temp != NULL);
LIST_REMOVE(tr_temp, list);
TAILQ_REMOVE(&qpair.free_tr, tr_temp, tq_list);
tr_temp->req = nvme_allocate_request_null(expected_failure_callback, NULL);
SPDK_CU_ASSERT_FATAL(tr_temp->req != NULL);
tr_temp->req->cmd.cid = tr_temp->cid;
LIST_INSERT_HEAD(&qpair.outstanding_tr, tr_temp, list);
TAILQ_INSERT_HEAD(&qpair.outstanding_tr, tr_temp, tq_list);
nvme_qpair_fail(&qpair);
CU_ASSERT_TRUE(LIST_EMPTY(&qpair.outstanding_tr));
CU_ASSERT_TRUE(TAILQ_EMPTY(&qpair.outstanding_tr));
req = nvme_allocate_request_null(expected_failure_callback, NULL);
SPDK_CU_ASSERT_FATAL(req != NULL);
@ -593,18 +593,18 @@ static void test_nvme_qpair_destroy(void)
nvme_qpair_construct(&qpair, 0, 128, &ctrlr);
tr_temp = LIST_FIRST(&qpair.free_tr);
tr_temp = TAILQ_FIRST(&qpair.free_tr);
SPDK_CU_ASSERT_FATAL(tr_temp != NULL);
LIST_REMOVE(tr_temp, list);
TAILQ_REMOVE(&qpair.free_tr, tr_temp, tq_list);
tr_temp->req = nvme_allocate_request_null(expected_failure_callback, NULL);
SPDK_CU_ASSERT_FATAL(tr_temp->req != NULL);
tr_temp->req->cmd.opc = SPDK_NVME_OPC_ASYNC_EVENT_REQUEST;
tr_temp->req->cmd.cid = tr_temp->cid;
LIST_INSERT_HEAD(&qpair.outstanding_tr, tr_temp, list);
TAILQ_INSERT_HEAD(&qpair.outstanding_tr, tr_temp, tq_list);
nvme_qpair_destroy(&qpair);
CU_ASSERT(LIST_EMPTY(&qpair.outstanding_tr));
CU_ASSERT(TAILQ_EMPTY(&qpair.outstanding_tr));
}
#endif