Linux 4.16.11
[linux/fpc-iii.git] / drivers / scsi / lpfc / lpfc_nvmet.h
blob5b32c9e4d4ef97e658554377c08f2932a53c833d
1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
8 * www.broadcom.com *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
10 * *
11 * This program is free software; you can redistribute it and/or *
12 * modify it under the terms of version 2 of the GNU General *
13 * Public License as published by the Free Software Foundation. *
14 * This program is distributed in the hope that it will be useful. *
15 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
16 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
18 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
19 * TO BE LEGALLY INVALID. See the GNU General Public License for *
20 * more details, a copy of which can be found in the file COPYING *
21 * included with this package. *
22 ********************************************************************/
24 #define LPFC_NVMET_DEFAULT_SEGS (64 + 1) /* 256K IOs */
25 #define LPFC_NVMET_RQE_DEF_COUNT 512
26 #define LPFC_NVMET_SUCCESS_LEN 12
28 #define LPFC_NVMET_MRQ_OFF 0xffff
29 #define LPFC_NVMET_MRQ_AUTO 0
30 #define LPFC_NVMET_MRQ_MAX 16
32 /* Used for NVME Target */
33 struct lpfc_nvmet_tgtport {
34 struct lpfc_hba *phba;
35 struct completion tport_unreg_done;
37 /* Stats counters - lpfc_nvmet_unsol_ls_buffer */
38 atomic_t rcv_ls_req_in;
39 atomic_t rcv_ls_req_out;
40 atomic_t rcv_ls_req_drop;
41 atomic_t xmt_ls_abort;
42 atomic_t xmt_ls_abort_cmpl;
44 /* Stats counters - lpfc_nvmet_xmt_ls_rsp */
45 atomic_t xmt_ls_rsp;
46 atomic_t xmt_ls_drop;
48 /* Stats counters - lpfc_nvmet_xmt_ls_rsp_cmp */
49 atomic_t xmt_ls_rsp_error;
50 atomic_t xmt_ls_rsp_aborted;
51 atomic_t xmt_ls_rsp_xb_set;
52 atomic_t xmt_ls_rsp_cmpl;
54 /* Stats counters - lpfc_nvmet_unsol_fcp_buffer */
55 atomic_t rcv_fcp_cmd_in;
56 atomic_t rcv_fcp_cmd_out;
57 atomic_t rcv_fcp_cmd_drop;
58 atomic_t rcv_fcp_cmd_defer;
59 atomic_t xmt_fcp_release;
61 /* Stats counters - lpfc_nvmet_xmt_fcp_op */
62 atomic_t xmt_fcp_drop;
63 atomic_t xmt_fcp_read_rsp;
64 atomic_t xmt_fcp_read;
65 atomic_t xmt_fcp_write;
66 atomic_t xmt_fcp_rsp;
68 /* Stats counters - lpfc_nvmet_xmt_fcp_op_cmp */
69 atomic_t xmt_fcp_rsp_xb_set;
70 atomic_t xmt_fcp_rsp_cmpl;
71 atomic_t xmt_fcp_rsp_error;
72 atomic_t xmt_fcp_rsp_aborted;
73 atomic_t xmt_fcp_rsp_drop;
76 /* Stats counters - lpfc_nvmet_xmt_fcp_abort */
77 atomic_t xmt_fcp_xri_abort_cqe;
78 atomic_t xmt_fcp_abort;
79 atomic_t xmt_fcp_abort_cmpl;
80 atomic_t xmt_abort_sol;
81 atomic_t xmt_abort_unsol;
82 atomic_t xmt_abort_rsp;
83 atomic_t xmt_abort_rsp_error;
86 struct lpfc_nvmet_ctx_info {
87 struct list_head nvmet_ctx_list;
88 spinlock_t nvmet_ctx_list_lock; /* lock per CPU */
89 struct lpfc_nvmet_ctx_info *nvmet_ctx_next_cpu;
90 struct lpfc_nvmet_ctx_info *nvmet_ctx_start_cpu;
91 uint16_t nvmet_ctx_list_cnt;
92 char pad[16]; /* pad to a cache-line */
95 /* This retrieves the context info associated with the specified cpu / mrq */
96 #define lpfc_get_ctx_list(phba, cpu, mrq) \
97 (phba->sli4_hba.nvmet_ctx_info + ((cpu * phba->cfg_nvmet_mrq) + mrq))
99 struct lpfc_nvmet_rcv_ctx {
100 union {
101 struct nvmefc_tgt_ls_req ls_req;
102 struct nvmefc_tgt_fcp_req fcp_req;
103 } ctx;
104 struct list_head list;
105 struct lpfc_hba *phba;
106 struct lpfc_iocbq *wqeq;
107 struct lpfc_iocbq *abort_wqeq;
108 dma_addr_t txrdy_phys;
109 spinlock_t ctxlock; /* protect flag access */
110 uint32_t *txrdy;
111 uint32_t sid;
112 uint32_t offset;
113 uint16_t oxid;
114 uint16_t size;
115 uint16_t entry_cnt;
116 uint16_t cpu;
117 uint16_t idx;
118 uint16_t state;
119 /* States */
120 #define LPFC_NVMET_STE_LS_RCV 1
121 #define LPFC_NVMET_STE_LS_ABORT 2
122 #define LPFC_NVMET_STE_LS_RSP 3
123 #define LPFC_NVMET_STE_RCV 4
124 #define LPFC_NVMET_STE_DATA 5
125 #define LPFC_NVMET_STE_ABORT 6
126 #define LPFC_NVMET_STE_DONE 7
127 #define LPFC_NVMET_STE_FREE 0xff
128 uint16_t flag;
129 #define LPFC_NVMET_IO_INP 0x1 /* IO is in progress on exchange */
130 #define LPFC_NVMET_ABORT_OP 0x2 /* Abort WQE issued on exchange */
131 #define LPFC_NVMET_XBUSY 0x4 /* XB bit set on IO cmpl */
132 #define LPFC_NVMET_CTX_RLS 0x8 /* ctx free requested */
133 #define LPFC_NVMET_ABTS_RCV 0x10 /* ABTS received on exchange */
134 #define LPFC_NVMET_DEFER_RCV_REPOST 0x20 /* repost to RQ on defer rcv */
135 struct rqb_dmabuf *rqb_buffer;
136 struct lpfc_nvmet_ctxbuf *ctxbuf;
138 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
139 uint64_t ts_isr_cmd;
140 uint64_t ts_cmd_nvme;
141 uint64_t ts_nvme_data;
142 uint64_t ts_data_wqput;
143 uint64_t ts_isr_data;
144 uint64_t ts_data_nvme;
145 uint64_t ts_nvme_status;
146 uint64_t ts_status_wqput;
147 uint64_t ts_isr_status;
148 uint64_t ts_status_nvme;
149 #endif