Deleted Added
full compact
28c28
< __FBSDID("$FreeBSD: head/sys/dev/nvme/nvme_qpair.c 248741 2013-03-26 18:45:16Z jimharris $");
---
> __FBSDID("$FreeBSD: head/sys/dev/nvme/nvme_qpair.c 248746 2013-03-26 19:50:46Z jimharris $");
90,106d89
< static struct nvme_tracker *
< nvme_qpair_find_tracker(struct nvme_qpair *qpair, struct nvme_request *req)
< {
< struct nvme_tracker *tr;
< uint32_t i;
<
< KASSERT(req != NULL, ("%s: called with NULL req\n", __func__));
<
< for (i = 0; i < qpair->num_entries; ++i) {
< tr = qpair->act_tr[i];
< if (tr != NULL && tr->req == req)
< return (tr);
< }
<
< return (NULL);
< }
<
150c133
< nvme_qpair_submit_cmd(qpair, tr);
---
> nvme_qpair_submit_tracker(qpair, tr);
171a155,169
> static void
> nvme_qpair_manual_complete_tracker(struct nvme_qpair *qpair,
> struct nvme_tracker *tr, uint32_t sct, uint32_t sc,
> boolean_t print_on_error)
> {
> struct nvme_completion cpl;
>
> memset(&cpl, 0, sizeof(cpl));
> cpl.sqid = qpair->id;
> cpl.cid = tr->cid;
> cpl.sf_sct = sct;
> cpl.sf_sc = sc;
> nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error);
> }
>
179a178,186
> if (!qpair->is_enabled)
> /*
> * qpair is not enabled, likely because a controller reset is
> * is in progress. Ignore the interrupt - any I/O that was
> * associated with this interrupt will get retried when the
> * reset is complete.
> */
> return;
>
239,247d245
< /*
< * First time through the completion queue, HW will set phase
< * bit on completions to 1. So set this to 1 here, indicating
< * we're looking for a 1 to know which entries have completed.
< * we'll toggle the bit each time when the completion queue
< * rolls over.
< */
< qpair->phase = 1;
<
274d271
< qpair->sq_head = qpair->sq_tail = qpair->cq_head = 0;
343a341,358
> static void
> nvme_admin_qpair_abort_aers(struct nvme_qpair *qpair)
> {
> struct nvme_tracker *tr;
>
> tr = TAILQ_FIRST(&qpair->outstanding_tr);
> while (tr != NULL) {
> if (tr->req->cmd.opc == NVME_OPC_ASYNC_EVENT_REQUEST) {
> nvme_qpair_manual_complete_tracker(qpair, tr,
> NVME_SCT_GENERIC, NVME_SC_ABORTED_SQ_DELETION,
> FALSE);
> tr = TAILQ_FIRST(&qpair->outstanding_tr);
> } else {
> tr = TAILQ_NEXT(tr, tailq);
> }
> }
> }
>
347a363,364
> nvme_admin_qpair_abort_aers(qpair);
>
416,448d432
< nvme_qpair_manual_abort_tracker(struct nvme_qpair *qpair,
< struct nvme_tracker *tr, uint32_t sct, uint32_t sc,
< boolean_t print_on_error)
< {
< struct nvme_completion cpl;
<
< memset(&cpl, 0, sizeof(cpl));
< cpl.sqid = qpair->id;
< cpl.cid = tr->cid;
< cpl.sf_sct = sct;
< cpl.sf_sc = sc;
< nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error);
< }
<
< void
< nvme_qpair_manual_abort_request(struct nvme_qpair *qpair,
< struct nvme_request *req, uint32_t sct, uint32_t sc,
< boolean_t print_on_error)
< {
< struct nvme_tracker *tr;
<
< tr = nvme_qpair_find_tracker(qpair, req);
<
< if (tr == NULL) {
< printf("%s: request not found\n", __func__);
< nvme_dump_command(&req->cmd);
< return;
< }
<
< nvme_qpair_manual_abort_tracker(qpair, tr, sct, sc, print_on_error);
< }
<
< static void
466c450
< nvme_qpair_manual_abort_tracker(tr->qpair, tr,
---
> nvme_qpair_manual_complete_tracker(tr->qpair, tr,
481c465
< nvme_qpair_submit_cmd(struct nvme_qpair *qpair, struct nvme_tracker *tr)
---
> nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr)
484a469,470
> mtx_assert(&qpair->lock, MA_OWNED);
>
520c506
< if (tr == NULL) {
---
> if (tr == NULL || !qpair->is_enabled) {
522,524c508,513
< * No tracker is available. Put the request on the qpair's
< * request queue to be processed when a tracker frees up
< * via a command completion.
---
> * No tracker is available, or the qpair is disabled due to
> * an in-progress controller-level reset.
> *
> * Put the request on the qpair's request queue to be processed
> * when a tracker frees up via a command completion or when
> * the controller reset is completed.
543c532
< nvme_qpair_submit_cmd(tr->qpair, tr);
---
> nvme_qpair_submit_tracker(tr->qpair, tr);
560a550,631
>
> static void
> nvme_qpair_enable(struct nvme_qpair *qpair)
> {
>
> qpair->is_enabled = TRUE;
> qpair->sq_head = qpair->sq_tail = qpair->cq_head = 0;
>
> /*
> * First time through the completion queue, HW will set phase
> * bit on completions to 1. So set this to 1 here, indicating
> * we're looking for a 1 to know which entries have completed.
> * we'll toggle the bit each time when the completion queue
> * rolls over.
> */
> qpair->phase = 1;
>
> memset(qpair->cmd, 0,
> qpair->num_entries * sizeof(struct nvme_command));
> memset(qpair->cpl, 0,
> qpair->num_entries * sizeof(struct nvme_completion));
> }
>
> void
> nvme_admin_qpair_enable(struct nvme_qpair *qpair)
> {
>
> nvme_qpair_enable(qpair);
> }
>
> void
> nvme_io_qpair_enable(struct nvme_qpair *qpair)
> {
> STAILQ_HEAD(, nvme_request) temp;
> struct nvme_tracker *tr;
> struct nvme_request *req;
>
> mtx_lock(&qpair->lock);
>
> nvme_qpair_enable(qpair);
>
> TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq)
> nvme_qpair_submit_tracker(qpair, tr);
>
> STAILQ_INIT(&temp);
> STAILQ_SWAP(&qpair->queued_req, &temp, nvme_request);
>
> while (!STAILQ_EMPTY(&temp)) {
> req = STAILQ_FIRST(&temp);
> STAILQ_REMOVE_HEAD(&temp, stailq);
> _nvme_qpair_submit_request(qpair, req);
> }
>
> mtx_unlock(&qpair->lock);
> }
>
> static void
> nvme_qpair_disable(struct nvme_qpair *qpair)
> {
> struct nvme_tracker *tr;
>
> qpair->is_enabled = FALSE;
> mtx_lock(&qpair->lock);
> TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq)
> callout_stop(&tr->timer);
> mtx_unlock(&qpair->lock);
> }
>
> void
> nvme_admin_qpair_disable(struct nvme_qpair *qpair)
> {
>
> nvme_qpair_disable(qpair);
> nvme_admin_qpair_abort_aers(qpair);
> }
>
> void
> nvme_io_qpair_disable(struct nvme_qpair *qpair)
> {
>
> nvme_qpair_disable(qpair);
> }