Commit e96a22b0 authored by James Smart's avatar James Smart Committed by Jens Axboe

lpfc: Refactor Send LS Abort support

Send LS Abort support is needed when Send LS Request is supported.

Currently, the ability to abort an NVME LS request is limited to the nvme
(host) side of the driver.  In preparation of both the nvme and nvmet sides
supporting Send LS Abort, rework the existing ls_req abort routines such
that there is common code that can be used by both sides.

While refactoring it was seen the logic in the abort routine was incorrect.
It attempted to abort all NVME LS's on the indicated port. As such, the
routine was reworked to abort only the NVME LS request that was specified.
Signed-off-by: default avatarPaul Ely <paul.ely@broadcom.com>
Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6514b25d
...@@ -792,83 +792,108 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, ...@@ -792,83 +792,108 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport,
} }
/** /**
* lpfc_nvme_ls_abort - Issue an Link Service request * __lpfc_nvme_ls_abort - Generic service routine to abort a prior
* @lpfc_pnvme: Pointer to the driver's nvme instance data * NVME LS request
* @lpfc_nvme_lport: Pointer to the driver's local port data * @vport: The local port that issued the LS
* @lpfc_nvme_rport: Pointer to the rport getting the @lpfc_nvme_ereq * @ndlp: The remote port the LS was sent to
* @pnvme_lsreq: Pointer to LS request structure from the transport
* *
* Driver registers this routine to handle any link service request * The driver validates the ndlp, looks for the LS, and aborts the
* from the nvme_fc transport to a remote nvme-aware port. * LS if found.
* *
* Return value : * Returns:
* 0 - Success * 0 : if LS found and aborted
* TODO: What are the failure codes. * non-zero: various error conditions in form -Exxx
**/ **/
static void int
lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport, __lpfc_nvme_ls_abort(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
struct nvme_fc_remote_port *pnvme_rport, struct nvmefc_ls_req *pnvme_lsreq)
struct nvmefc_ls_req *pnvme_lsreq)
{ {
struct lpfc_nvme_lport *lport; struct lpfc_hba *phba = vport->phba;
struct lpfc_vport *vport;
struct lpfc_hba *phba;
struct lpfc_nodelist *ndlp;
LIST_HEAD(abort_list);
struct lpfc_sli_ring *pring; struct lpfc_sli_ring *pring;
struct lpfc_iocbq *wqe, *next_wqe; struct lpfc_iocbq *wqe, *next_wqe;
bool foundit = false;
lport = (struct lpfc_nvme_lport *)pnvme_lport->private;
if (unlikely(!lport))
return;
vport = lport->vport;
phba = vport->phba;
if (vport->load_flag & FC_UNLOADING)
return;
ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id);
if (!ndlp) { if (!ndlp) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS, lpfc_printf_log(phba, KERN_ERR,
"6049 Could not find node for DID %x\n", LOG_NVME_DISC | LOG_NODE |
pnvme_rport->port_id); LOG_NVME_IOERR | LOG_NVME_ABTS,
return; "6049 NVMEx LS REQ Abort: Bad NDLP x%px DID "
"x%06x, Failing LS Req\n",
ndlp, ndlp ? ndlp->nlp_DID : 0);
return -EINVAL;
} }
/* Expand print to include key fields. */ lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC | LOG_NVME_ABTS,
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, "6040 NVMEx LS REQ Abort: Issue LS_ABORT for lsreq "
"6040 ENTER. lport x%px, rport x%px lsreq x%px rqstlen:%d " "x%p rqstlen:%d rsplen:%d %pad %pad\n",
"rsplen:%d %pad %pad\n",
pnvme_lport, pnvme_rport,
pnvme_lsreq, pnvme_lsreq->rqstlen, pnvme_lsreq, pnvme_lsreq->rqstlen,
pnvme_lsreq->rsplen, &pnvme_lsreq->rqstdma, pnvme_lsreq->rsplen, &pnvme_lsreq->rqstdma,
&pnvme_lsreq->rspdma); &pnvme_lsreq->rspdma);
/* /*
* Lock the ELS ring txcmplq and build a local list of all ELS IOs * Lock the ELS ring txcmplq and look for the wqe that matches
* that need an ABTS. The IOs need to stay on the txcmplq so that * this ELS. If found, issue an abort on the wqe.
* the abort operation completes them successfully.
*/ */
pring = phba->sli4_hba.nvmels_wq->pring; pring = phba->sli4_hba.nvmels_wq->pring;
spin_lock_irq(&phba->hbalock); spin_lock_irq(&phba->hbalock);
spin_lock(&pring->ring_lock); spin_lock(&pring->ring_lock);
list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) { list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) {
/* Add to abort_list on on NDLP match. */ if (wqe->context2 == pnvme_lsreq) {
if (lpfc_check_sli_ndlp(phba, pring, wqe, ndlp)) {
wqe->iocb_flag |= LPFC_DRIVER_ABORTED; wqe->iocb_flag |= LPFC_DRIVER_ABORTED;
list_add_tail(&wqe->dlist, &abort_list); foundit = true;
break;
} }
} }
spin_unlock(&pring->ring_lock); spin_unlock(&pring->ring_lock);
if (foundit)
lpfc_sli_issue_abort_iotag(phba, pring, wqe);
spin_unlock_irq(&phba->hbalock); spin_unlock_irq(&phba->hbalock);
/* Abort the targeted IOs and remove them from the abort list. */ if (foundit)
list_for_each_entry_safe(wqe, next_wqe, &abort_list, dlist) { return 0;
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC | LOG_NVME_ABTS,
"6213 NVMEx LS REQ Abort: Unable to locate req x%p\n",
pnvme_lsreq);
return 1;
}
/**
* lpfc_nvme_ls_abort - Abort a prior NVME LS request
* @lpfc_nvme_lport: Transport localport that LS is to be issued from.
* @lpfc_nvme_rport: Transport remoteport that LS is to be sent to.
* @pnvme_lsreq - the transport nvme_ls_req structure for the LS
*
* Driver registers this routine to abort a NVME LS request that is
* in progress (from the transports perspective).
**/
static void
lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport,
struct nvme_fc_remote_port *pnvme_rport,
struct nvmefc_ls_req *pnvme_lsreq)
{
struct lpfc_nvme_lport *lport;
struct lpfc_vport *vport;
struct lpfc_hba *phba;
struct lpfc_nodelist *ndlp;
int ret;
lport = (struct lpfc_nvme_lport *)pnvme_lport->private;
if (unlikely(!lport))
return;
vport = lport->vport;
phba = vport->phba;
if (vport->load_flag & FC_UNLOADING)
return;
ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id);
ret = __lpfc_nvme_ls_abort(vport, ndlp, pnvme_lsreq);
if (!ret)
atomic_inc(&lport->xmt_ls_abort); atomic_inc(&lport->xmt_ls_abort);
spin_lock_irq(&phba->hbalock);
list_del_init(&wqe->dlist);
lpfc_sli_issue_abort_iotag(phba, pring, wqe);
spin_unlock_irq(&phba->hbalock);
}
} }
/* Fix up the existing sgls for NVME IO. */ /* Fix up the existing sgls for NVME IO. */
......
...@@ -237,6 +237,8 @@ int __lpfc_nvme_ls_req(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, ...@@ -237,6 +237,8 @@ int __lpfc_nvme_ls_req(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
struct lpfc_wcqe_complete *wcqe)); struct lpfc_wcqe_complete *wcqe));
void __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, void __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport,
struct lpfc_iocbq *cmdwqe, struct lpfc_wcqe_complete *wcqe); struct lpfc_iocbq *cmdwqe, struct lpfc_wcqe_complete *wcqe);
int __lpfc_nvme_ls_abort(struct lpfc_vport *vport,
struct lpfc_nodelist *ndlp, struct nvmefc_ls_req *pnvme_lsreq);
/* routines found in lpfc_nvmet.c */ /* routines found in lpfc_nvmet.c */
int lpfc_nvme_unsol_ls_issue_abort(struct lpfc_hba *phba, int lpfc_nvme_unsol_ls_issue_abort(struct lpfc_hba *phba,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment