2017-02-13 05:52:34 +08:00
|
|
|
/*******************************************************************
|
|
|
|
* This file is part of the Emulex Linux Device Driver for *
|
|
|
|
* Fibre Channel Host Bus Adapters. *
|
2019-01-29 03:14:41 +08:00
|
|
|
* Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term *
|
2018-06-26 23:24:31 +08:00
|
|
|
* “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
|
2017-02-13 05:52:34 +08:00
|
|
|
* Copyright (C) 2004-2016 Emulex. All rights reserved. *
|
|
|
|
* EMULEX and SLI are trademarks of Emulex. *
|
2017-02-13 05:52:39 +08:00
|
|
|
* www.broadcom.com *
|
2017-02-13 05:52:34 +08:00
|
|
|
* Portions Copyright (C) 2004-2005 Christoph Hellwig *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of version 2 of the GNU General *
|
|
|
|
* Public License as published by the Free Software Foundation. *
|
|
|
|
* This program is distributed in the hope that it will be useful. *
|
|
|
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
|
|
|
|
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
|
|
|
|
* DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
|
|
|
|
* TO BE LEGALLY INVALID. See the GNU General Public License for *
|
|
|
|
* more details, a copy of which can be found in the file COPYING *
|
|
|
|
* included with this package. *
|
|
|
|
********************************************************************/
|
|
|
|
|
2017-04-22 07:04:45 +08:00
|
|
|
#define LPFC_NVMET_DEFAULT_SEGS (64 + 1) /* 256K IOs */
|
2018-04-10 05:24:24 +08:00
|
|
|
#define LPFC_NVMET_RQE_MIN_POST 128
|
|
|
|
#define LPFC_NVMET_RQE_DEF_POST 512
|
|
|
|
#define LPFC_NVMET_RQE_DEF_COUNT 2048
|
|
|
|
#define LPFC_NVMET_SUCCESS_LEN 12
|
2017-02-13 05:52:34 +08:00
|
|
|
|
2017-11-21 08:00:36 +08:00
|
|
|
#define LPFC_NVMET_MRQ_AUTO 0
|
|
|
|
#define LPFC_NVMET_MRQ_MAX 16
|
|
|
|
|
2019-03-13 07:30:16 +08:00
|
|
|
#define LPFC_NVMET_WAIT_TMO (5 * MSEC_PER_SEC)
|
|
|
|
|
2017-02-13 05:52:34 +08:00
|
|
|
/* Used for NVME Target */
|
|
|
|
struct lpfc_nvmet_tgtport {
|
|
|
|
struct lpfc_hba *phba;
|
2019-01-18 00:14:45 +08:00
|
|
|
struct completion *tport_unreg_cmp;
|
2017-02-13 05:52:34 +08:00
|
|
|
|
|
|
|
/* Stats counters - lpfc_nvmet_unsol_ls_buffer */
|
|
|
|
atomic_t rcv_ls_req_in;
|
|
|
|
atomic_t rcv_ls_req_out;
|
|
|
|
atomic_t rcv_ls_req_drop;
|
|
|
|
atomic_t xmt_ls_abort;
|
2017-05-16 06:20:40 +08:00
|
|
|
atomic_t xmt_ls_abort_cmpl;
|
2017-02-13 05:52:34 +08:00
|
|
|
|
|
|
|
/* Stats counters - lpfc_nvmet_xmt_ls_rsp */
|
|
|
|
atomic_t xmt_ls_rsp;
|
|
|
|
atomic_t xmt_ls_drop;
|
|
|
|
|
|
|
|
/* Stats counters - lpfc_nvmet_xmt_ls_rsp_cmp */
|
|
|
|
atomic_t xmt_ls_rsp_error;
|
2017-12-09 09:18:10 +08:00
|
|
|
atomic_t xmt_ls_rsp_aborted;
|
|
|
|
atomic_t xmt_ls_rsp_xb_set;
|
2017-02-13 05:52:34 +08:00
|
|
|
atomic_t xmt_ls_rsp_cmpl;
|
|
|
|
|
|
|
|
/* Stats counters - lpfc_nvmet_unsol_fcp_buffer */
|
|
|
|
atomic_t rcv_fcp_cmd_in;
|
|
|
|
atomic_t rcv_fcp_cmd_out;
|
|
|
|
atomic_t rcv_fcp_cmd_drop;
|
2017-08-02 06:12:40 +08:00
|
|
|
atomic_t rcv_fcp_cmd_defer;
|
2017-05-16 06:20:40 +08:00
|
|
|
atomic_t xmt_fcp_release;
|
2017-02-13 05:52:34 +08:00
|
|
|
|
|
|
|
/* Stats counters - lpfc_nvmet_xmt_fcp_op */
|
|
|
|
atomic_t xmt_fcp_drop;
|
|
|
|
atomic_t xmt_fcp_read_rsp;
|
|
|
|
atomic_t xmt_fcp_read;
|
|
|
|
atomic_t xmt_fcp_write;
|
|
|
|
atomic_t xmt_fcp_rsp;
|
|
|
|
|
|
|
|
/* Stats counters - lpfc_nvmet_xmt_fcp_op_cmp */
|
2017-12-09 09:18:10 +08:00
|
|
|
atomic_t xmt_fcp_rsp_xb_set;
|
2017-02-13 05:52:34 +08:00
|
|
|
atomic_t xmt_fcp_rsp_cmpl;
|
|
|
|
atomic_t xmt_fcp_rsp_error;
|
2017-12-09 09:18:10 +08:00
|
|
|
atomic_t xmt_fcp_rsp_aborted;
|
2017-02-13 05:52:34 +08:00
|
|
|
atomic_t xmt_fcp_rsp_drop;
|
|
|
|
|
2017-05-16 06:20:40 +08:00
|
|
|
/* Stats counters - lpfc_nvmet_xmt_fcp_abort */
|
2017-12-09 09:18:10 +08:00
|
|
|
atomic_t xmt_fcp_xri_abort_cqe;
|
2017-05-16 06:20:40 +08:00
|
|
|
atomic_t xmt_fcp_abort;
|
|
|
|
atomic_t xmt_fcp_abort_cmpl;
|
|
|
|
atomic_t xmt_abort_sol;
|
|
|
|
atomic_t xmt_abort_unsol;
|
2017-02-13 05:52:34 +08:00
|
|
|
atomic_t xmt_abort_rsp;
|
|
|
|
atomic_t xmt_abort_rsp_error;
|
2018-01-31 07:58:52 +08:00
|
|
|
|
|
|
|
/* Stats counters - defer IO */
|
|
|
|
atomic_t defer_ctx;
|
|
|
|
atomic_t defer_fod;
|
|
|
|
atomic_t defer_wqfull;
|
2017-02-13 05:52:34 +08:00
|
|
|
};
|
|
|
|
|
2017-08-24 07:55:42 +08:00
|
|
|
struct lpfc_nvmet_ctx_info {
|
|
|
|
struct list_head nvmet_ctx_list;
|
|
|
|
spinlock_t nvmet_ctx_list_lock; /* lock per CPU */
|
|
|
|
struct lpfc_nvmet_ctx_info *nvmet_ctx_next_cpu;
|
|
|
|
struct lpfc_nvmet_ctx_info *nvmet_ctx_start_cpu;
|
|
|
|
uint16_t nvmet_ctx_list_cnt;
|
|
|
|
char pad[16]; /* pad to a cache-line */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This retrieves the context info associated with the specified cpu / mrq */
|
|
|
|
#define lpfc_get_ctx_list(phba, cpu, mrq) \
|
|
|
|
(phba->sli4_hba.nvmet_ctx_info + ((cpu * phba->cfg_nvmet_mrq) + mrq))
|
|
|
|
|
2017-02-13 05:52:34 +08:00
|
|
|
struct lpfc_nvmet_rcv_ctx {
|
|
|
|
union {
|
|
|
|
struct nvmefc_tgt_ls_req ls_req;
|
|
|
|
struct nvmefc_tgt_fcp_req fcp_req;
|
|
|
|
} ctx;
|
Update ABORT processing for NVMET.
The driver with nvme had this routine stubbed.
Right now XRI_ABORTED_CQE is not handled and the FC NVMET
Transport has a new API for the driver.
Missing code path, new NVME abort API
Update ABORT processing for NVMET
There are 3 new FC NVMET Transport API/ template routines for NVMET:
lpfc_nvmet_xmt_fcp_release
This NVMET template callback routine called to release context
associated with an IO This routine is ALWAYS called last, even
if the IO was aborted or completed in error.
lpfc_nvmet_xmt_fcp_abort
This NVMET template callback routine called to abort an exchange that
has an IO in progress
nvmet_fc_rcv_fcp_req
When the lpfc driver receives an ABTS, this NVME FC transport layer
callback routine is called. For this case there are 2 paths thru the
driver: the driver either has an outstanding exchange / context for the
XRI to be aborted or not. If not, a BA_RJT is issued otherwise a BA_ACC
NVMET Driver abort paths:
There are 2 paths for aborting an IO. The first one is we receive an IO and
decide not to process it because of lack of resources. An unsolicated ABTS
is immediately sent back to the initiator as a response.
lpfc_nvmet_unsol_fcp_buffer
lpfc_nvmet_unsol_issue_abort (XMIT_SEQUENCE_WQE)
The second one is we sent the IO up to the NVMET transport layer to
process, and for some reason the NVME Transport layer decided to abort the
IO before it completes all its phases. For this case there are 2 paths
thru the driver:
the driver either has an outstanding TSEND/TRECEIVE/TRSP WQE or no
outstanding WQEs are present for the exchange / context.
lpfc_nvmet_xmt_fcp_abort
if (LPFC_NVMET_IO_INP)
lpfc_nvmet_sol_fcp_issue_abort (ABORT_WQE)
lpfc_nvmet_sol_fcp_abort_cmp
else
lpfc_nvmet_unsol_fcp_issue_abort
lpfc_nvmet_unsol_issue_abort (XMIT_SEQUENCE_WQE)
lpfc_nvmet_unsol_fcp_abort_cmp
Context flags:
LPFC_NVMET_IOP - his flag signifies an IO is in progress on the exchange.
LPFC_NVMET_XBUSY - this flag indicates the IO completed but the firmware
is still busy with the corresponding exchange. The exchange should not be
reused until after a XRI_ABORTED_CQE is received for that exchange.
LPFC_NVMET_ABORT_OP - this flag signifies an ABORT_WQE was issued on the
exchange.
LPFC_NVMET_CTX_RLS - this flag signifies a context free was requested,
but we are deferring it due to an XBUSY or ABORT in progress.
A ctxlock is added to the context structure that is used whenever these
flags are set/read within the context of an IO.
The LPFC_NVMET_CTX_RLS flag is only set in the defer_relase routine when
the transport has resolved all IO associated with the buffer. The flag is
cleared when the CTX is associated with a new IO.
An exchange can has both an LPFC_NVMET_XBUSY and a LPFC_NVMET_ABORT_OP
condition active simultaneously. Both conditions must complete before the
exchange is freed.
When the abort callback (lpfc_nvmet_xmt_fcp_abort) is envoked:
If there is an outstanding IO, the driver will issue an ABORT_WQE. This
should result in 3 completions for the exchange:
1) IO cmpl with XB bit set
2) Abort WQE cmpl
3) XRI_ABORTED_CQE cmpl
For this scenerio, after completion #1, the NVMET Transport IO rsp
callback is called. After completion #2, no action is taken with respect
to the exchange / context. After completion #3, the exchange context is
free for re-use on another IO.
If there is no outstanding activity on the exchange, the driver will send a
ABTS to the Initiator. Upon completion of this WQE, the exchange / context
is freed for re-use on another IO.
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
2017-04-22 07:05:04 +08:00
|
|
|
struct list_head list;
|
2017-02-13 05:52:34 +08:00
|
|
|
struct lpfc_hba *phba;
|
|
|
|
struct lpfc_iocbq *wqeq;
|
|
|
|
struct lpfc_iocbq *abort_wqeq;
|
|
|
|
dma_addr_t txrdy_phys;
|
2017-04-12 02:32:29 +08:00
|
|
|
spinlock_t ctxlock; /* protect flag access */
|
2017-02-13 05:52:34 +08:00
|
|
|
uint32_t *txrdy;
|
|
|
|
uint32_t sid;
|
|
|
|
uint32_t offset;
|
|
|
|
uint16_t oxid;
|
|
|
|
uint16_t size;
|
|
|
|
uint16_t entry_cnt;
|
|
|
|
uint16_t cpu;
|
2017-08-24 07:55:42 +08:00
|
|
|
uint16_t idx;
|
2017-02-13 05:52:34 +08:00
|
|
|
uint16_t state;
|
|
|
|
/* States */
|
2017-06-02 12:06:58 +08:00
|
|
|
#define LPFC_NVMET_STE_LS_RCV 1
|
|
|
|
#define LPFC_NVMET_STE_LS_ABORT 2
|
|
|
|
#define LPFC_NVMET_STE_LS_RSP 3
|
|
|
|
#define LPFC_NVMET_STE_RCV 4
|
|
|
|
#define LPFC_NVMET_STE_DATA 5
|
|
|
|
#define LPFC_NVMET_STE_ABORT 6
|
|
|
|
#define LPFC_NVMET_STE_DONE 7
|
|
|
|
#define LPFC_NVMET_STE_FREE 0xff
|
2017-02-13 05:52:34 +08:00
|
|
|
uint16_t flag;
|
Update ABORT processing for NVMET.
The driver with nvme had this routine stubbed.
Right now XRI_ABORTED_CQE is not handled and the FC NVMET
Transport has a new API for the driver.
Missing code path, new NVME abort API
Update ABORT processing for NVMET
There are 3 new FC NVMET Transport API/ template routines for NVMET:
lpfc_nvmet_xmt_fcp_release
This NVMET template callback routine called to release context
associated with an IO This routine is ALWAYS called last, even
if the IO was aborted or completed in error.
lpfc_nvmet_xmt_fcp_abort
This NVMET template callback routine called to abort an exchange that
has an IO in progress
nvmet_fc_rcv_fcp_req
When the lpfc driver receives an ABTS, this NVME FC transport layer
callback routine is called. For this case there are 2 paths thru the
driver: the driver either has an outstanding exchange / context for the
XRI to be aborted or not. If not, a BA_RJT is issued otherwise a BA_ACC
NVMET Driver abort paths:
There are 2 paths for aborting an IO. The first one is we receive an IO and
decide not to process it because of lack of resources. An unsolicated ABTS
is immediately sent back to the initiator as a response.
lpfc_nvmet_unsol_fcp_buffer
lpfc_nvmet_unsol_issue_abort (XMIT_SEQUENCE_WQE)
The second one is we sent the IO up to the NVMET transport layer to
process, and for some reason the NVME Transport layer decided to abort the
IO before it completes all its phases. For this case there are 2 paths
thru the driver:
the driver either has an outstanding TSEND/TRECEIVE/TRSP WQE or no
outstanding WQEs are present for the exchange / context.
lpfc_nvmet_xmt_fcp_abort
if (LPFC_NVMET_IO_INP)
lpfc_nvmet_sol_fcp_issue_abort (ABORT_WQE)
lpfc_nvmet_sol_fcp_abort_cmp
else
lpfc_nvmet_unsol_fcp_issue_abort
lpfc_nvmet_unsol_issue_abort (XMIT_SEQUENCE_WQE)
lpfc_nvmet_unsol_fcp_abort_cmp
Context flags:
LPFC_NVMET_IOP - his flag signifies an IO is in progress on the exchange.
LPFC_NVMET_XBUSY - this flag indicates the IO completed but the firmware
is still busy with the corresponding exchange. The exchange should not be
reused until after a XRI_ABORTED_CQE is received for that exchange.
LPFC_NVMET_ABORT_OP - this flag signifies an ABORT_WQE was issued on the
exchange.
LPFC_NVMET_CTX_RLS - this flag signifies a context free was requested,
but we are deferring it due to an XBUSY or ABORT in progress.
A ctxlock is added to the context structure that is used whenever these
flags are set/read within the context of an IO.
The LPFC_NVMET_CTX_RLS flag is only set in the defer_relase routine when
the transport has resolved all IO associated with the buffer. The flag is
cleared when the CTX is associated with a new IO.
An exchange can has both an LPFC_NVMET_XBUSY and a LPFC_NVMET_ABORT_OP
condition active simultaneously. Both conditions must complete before the
exchange is freed.
When the abort callback (lpfc_nvmet_xmt_fcp_abort) is envoked:
If there is an outstanding IO, the driver will issue an ABORT_WQE. This
should result in 3 completions for the exchange:
1) IO cmpl with XB bit set
2) Abort WQE cmpl
3) XRI_ABORTED_CQE cmpl
For this scenerio, after completion #1, the NVMET Transport IO rsp
callback is called. After completion #2, no action is taken with respect
to the exchange / context. After completion #3, the exchange context is
free for re-use on another IO.
If there is no outstanding activity on the exchange, the driver will send a
ABTS to the Initiator. Upon completion of this WQE, the exchange / context
is freed for re-use on another IO.
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
2017-04-22 07:05:04 +08:00
|
|
|
#define LPFC_NVMET_IO_INP 0x1 /* IO is in progress on exchange */
|
|
|
|
#define LPFC_NVMET_ABORT_OP 0x2 /* Abort WQE issued on exchange */
|
|
|
|
#define LPFC_NVMET_XBUSY 0x4 /* XB bit set on IO cmpl */
|
|
|
|
#define LPFC_NVMET_CTX_RLS 0x8 /* ctx free requested */
|
|
|
|
#define LPFC_NVMET_ABTS_RCV 0x10 /* ABTS received on exchange */
|
2019-01-29 03:14:39 +08:00
|
|
|
#define LPFC_NVMET_CTX_REUSE_WQ 0x20 /* ctx reused via WQ */
|
2018-01-31 07:58:49 +08:00
|
|
|
#define LPFC_NVMET_DEFER_WQFULL 0x40 /* Waiting on a free WQE */
|
2017-02-13 05:52:34 +08:00
|
|
|
struct rqb_dmabuf *rqb_buffer;
|
2017-05-16 06:20:45 +08:00
|
|
|
struct lpfc_nvmet_ctxbuf *ctxbuf;
|
2019-01-29 03:14:26 +08:00
|
|
|
struct lpfc_sli4_hdw_queue *hdwq;
|
2017-02-13 05:52:38 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
|
|
|
|
uint64_t ts_isr_cmd;
|
|
|
|
uint64_t ts_cmd_nvme;
|
|
|
|
uint64_t ts_nvme_data;
|
|
|
|
uint64_t ts_data_wqput;
|
|
|
|
uint64_t ts_isr_data;
|
|
|
|
uint64_t ts_data_nvme;
|
|
|
|
uint64_t ts_nvme_status;
|
|
|
|
uint64_t ts_status_wqput;
|
|
|
|
uint64_t ts_isr_status;
|
|
|
|
uint64_t ts_status_nvme;
|
|
|
|
#endif
|
2017-02-13 05:52:34 +08:00
|
|
|
};
|