0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <linux/nvme.h>
0025 #include <linux/nvme-fc-driver.h>
0026 #include <linux/nvme-fc.h>
0027
0028 #define LPFC_NVME_DEFAULT_SEGS (64 + 1)
0029
0030 #define LPFC_NVME_ERSP_LEN 0x20
0031
0032 #define LPFC_NVME_WAIT_TMO 10
0033 #define LPFC_NVME_EXPEDITE_XRICNT 8
0034 #define LPFC_NVME_FB_SHIFT 9
0035 #define LPFC_NVME_MAX_FB (1 << 20)
0036
0037 #define lpfc_ndlp_get_nrport(ndlp) \
0038 ((!ndlp->nrport || (ndlp->fc4_xpt_flags & NVME_XPT_UNREG_WAIT))\
0039 ? NULL : ndlp->nrport)
0040
0041 struct lpfc_nvme_qhandle {
0042 uint32_t index;
0043 uint32_t qidx;
0044 uint32_t cpu_id;
0045 };
0046
0047
0048 struct lpfc_nvme_lport {
0049 struct lpfc_vport *vport;
0050 struct completion *lport_unreg_cmp;
0051
0052 atomic_t fc4NvmeLsRequests;
0053 atomic_t fc4NvmeLsCmpls;
0054 atomic_t xmt_fcp_noxri;
0055 atomic_t xmt_fcp_bad_ndlp;
0056 atomic_t xmt_fcp_qdepth;
0057 atomic_t xmt_fcp_wqerr;
0058 atomic_t xmt_fcp_err;
0059 atomic_t xmt_fcp_abort;
0060 atomic_t xmt_ls_abort;
0061 atomic_t xmt_ls_err;
0062 atomic_t cmpl_fcp_xb;
0063 atomic_t cmpl_fcp_err;
0064 atomic_t cmpl_ls_xb;
0065 atomic_t cmpl_ls_err;
0066 };
0067
0068 struct lpfc_nvme_rport {
0069 struct lpfc_nvme_lport *lport;
0070 struct nvme_fc_remote_port *remoteport;
0071 struct lpfc_nodelist *ndlp;
0072 struct completion rport_unreg_done;
0073 };
0074
0075 struct lpfc_nvme_fcpreq_priv {
0076 struct lpfc_io_buf *nvme_buf;
0077 };
0078
0079
0080
0081
0082
0083 #define LPFC_NVME_LS_TIMEOUT 30
0084
0085
0086 #define LPFC_NVMET_DEFAULT_SEGS (64 + 1)
0087 #define LPFC_NVMET_RQE_MIN_POST 128
0088 #define LPFC_NVMET_RQE_DEF_POST 512
0089 #define LPFC_NVMET_RQE_DEF_COUNT 2048
0090 #define LPFC_NVMET_SUCCESS_LEN 12
0091
0092 #define LPFC_NVMET_MRQ_AUTO 0
0093 #define LPFC_NVMET_MRQ_MAX 16
0094
0095 #define LPFC_NVMET_WAIT_TMO (5 * MSEC_PER_SEC)
0096
0097
0098 #define LPFC_NVMET_INV_HOST_ACTIVE 1
0099
0100 struct lpfc_nvmet_tgtport {
0101 struct lpfc_hba *phba;
0102 struct completion *tport_unreg_cmp;
0103 atomic_t state;
0104
0105
0106 atomic_t rcv_ls_req_in;
0107 atomic_t rcv_ls_req_out;
0108 atomic_t rcv_ls_req_drop;
0109 atomic_t xmt_ls_abort;
0110 atomic_t xmt_ls_abort_cmpl;
0111
0112
0113 atomic_t xmt_ls_rsp;
0114 atomic_t xmt_ls_drop;
0115
0116
0117 atomic_t xmt_ls_rsp_error;
0118 atomic_t xmt_ls_rsp_aborted;
0119 atomic_t xmt_ls_rsp_xb_set;
0120 atomic_t xmt_ls_rsp_cmpl;
0121
0122
0123 atomic_t rcv_fcp_cmd_in;
0124 atomic_t rcv_fcp_cmd_out;
0125 atomic_t rcv_fcp_cmd_drop;
0126 atomic_t rcv_fcp_cmd_defer;
0127 atomic_t xmt_fcp_release;
0128
0129
0130 atomic_t xmt_fcp_drop;
0131 atomic_t xmt_fcp_read_rsp;
0132 atomic_t xmt_fcp_read;
0133 atomic_t xmt_fcp_write;
0134 atomic_t xmt_fcp_rsp;
0135
0136
0137 atomic_t xmt_fcp_rsp_xb_set;
0138 atomic_t xmt_fcp_rsp_cmpl;
0139 atomic_t xmt_fcp_rsp_error;
0140 atomic_t xmt_fcp_rsp_aborted;
0141 atomic_t xmt_fcp_rsp_drop;
0142
0143
0144 atomic_t xmt_fcp_xri_abort_cqe;
0145 atomic_t xmt_fcp_abort;
0146 atomic_t xmt_fcp_abort_cmpl;
0147 atomic_t xmt_abort_sol;
0148 atomic_t xmt_abort_unsol;
0149 atomic_t xmt_abort_rsp;
0150 atomic_t xmt_abort_rsp_error;
0151
0152
0153 atomic_t defer_ctx;
0154 atomic_t defer_fod;
0155 atomic_t defer_wqfull;
0156 };
0157
0158 struct lpfc_nvmet_ctx_info {
0159 struct list_head nvmet_ctx_list;
0160 spinlock_t nvmet_ctx_list_lock;
0161 struct lpfc_nvmet_ctx_info *nvmet_ctx_next_cpu;
0162 struct lpfc_nvmet_ctx_info *nvmet_ctx_start_cpu;
0163 uint16_t nvmet_ctx_list_cnt;
0164 char pad[16];
0165 };
0166
0167
0168 #define lpfc_get_ctx_list(phba, cpu, mrq) \
0169 (phba->sli4_hba.nvmet_ctx_info + ((cpu * phba->cfg_nvmet_mrq) + mrq))
0170
0171
0172 #define LPFC_NVME_STE_LS_RCV 1
0173 #define LPFC_NVME_STE_LS_ABORT 2
0174 #define LPFC_NVME_STE_LS_RSP 3
0175 #define LPFC_NVME_STE_RCV 4
0176 #define LPFC_NVME_STE_DATA 5
0177 #define LPFC_NVME_STE_ABORT 6
0178 #define LPFC_NVME_STE_DONE 7
0179 #define LPFC_NVME_STE_FREE 0xff
0180
0181
0182 #define LPFC_NVME_IO_INP 0x1
0183 #define LPFC_NVME_ABORT_OP 0x2
0184 #define LPFC_NVME_XBUSY 0x4
0185 #define LPFC_NVME_CTX_RLS 0x8
0186 #define LPFC_NVME_ABTS_RCV 0x10
0187 #define LPFC_NVME_CTX_REUSE_WQ 0x20
0188 #define LPFC_NVME_DEFER_WQFULL 0x40
0189 #define LPFC_NVME_TNOTIFY 0x80
0190
0191 struct lpfc_async_xchg_ctx {
0192 union {
0193 struct nvmefc_tgt_fcp_req fcp_req;
0194 } hdlrctx;
0195 struct list_head list;
0196 struct lpfc_hba *phba;
0197 struct lpfc_nodelist *ndlp;
0198 struct nvmefc_ls_req *ls_req;
0199 struct nvmefc_ls_rsp ls_rsp;
0200 struct lpfc_iocbq *wqeq;
0201 struct lpfc_iocbq *abort_wqeq;
0202 spinlock_t ctxlock;
0203 uint32_t sid;
0204 uint32_t offset;
0205 uint16_t oxid;
0206 uint16_t size;
0207 uint16_t entry_cnt;
0208 uint16_t cpu;
0209 uint16_t idx;
0210 uint16_t state;
0211 uint16_t flag;
0212 void *payload;
0213 struct rqb_dmabuf *rqb_buffer;
0214 struct lpfc_nvmet_ctxbuf *ctxbuf;
0215 struct lpfc_sli4_hdw_queue *hdwq;
0216
0217 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
0218 uint64_t ts_isr_cmd;
0219 uint64_t ts_cmd_nvme;
0220 uint64_t ts_nvme_data;
0221 uint64_t ts_data_wqput;
0222 uint64_t ts_isr_data;
0223 uint64_t ts_data_nvme;
0224 uint64_t ts_nvme_status;
0225 uint64_t ts_status_wqput;
0226 uint64_t ts_isr_status;
0227 uint64_t ts_status_nvme;
0228 #endif
0229 };
0230
0231
0232
0233 int __lpfc_nvme_ls_req(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
0234 struct nvmefc_ls_req *pnvme_lsreq,
0235 void (*gen_req_cmp)(struct lpfc_hba *phba,
0236 struct lpfc_iocbq *cmdwqe,
0237 struct lpfc_iocbq *rspwqe));
0238 void __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport,
0239 struct lpfc_iocbq *cmdwqe, struct lpfc_wcqe_complete *wcqe);
0240 int __lpfc_nvme_ls_abort(struct lpfc_vport *vport,
0241 struct lpfc_nodelist *ndlp, struct nvmefc_ls_req *pnvme_lsreq);
0242
0243
0244 int lpfc_nvme_unsol_ls_issue_abort(struct lpfc_hba *phba,
0245 struct lpfc_async_xchg_ctx *ctxp, uint32_t sid,
0246 uint16_t xri);
0247 int __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg,
0248 struct nvmefc_ls_rsp *ls_rsp,
0249 void (*xmt_ls_rsp_cmp)(struct lpfc_hba *phba,
0250 struct lpfc_iocbq *cmdwqe,
0251 struct lpfc_iocbq *rspwqe));
0252 void __lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba,
0253 struct lpfc_iocbq *cmdwqe, struct lpfc_iocbq *rspwqe);