1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
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_MIN_POST 128
26 #define LPFC_NVMET_RQE_DEF_POST 512
27 #define LPFC_NVMET_RQE_DEF_COUNT 2048
28 #define LPFC_NVMET_SUCCESS_LEN 12
30 #define LPFC_NVMET_MRQ_OFF 0xffff
31 #define LPFC_NVMET_MRQ_AUTO 0
32 #define LPFC_NVMET_MRQ_MAX 16
34 /* Used for NVME Target */
35 struct lpfc_nvmet_tgtport
{
36 struct lpfc_hba
*phba
;
37 struct completion tport_unreg_done
;
39 /* Stats counters - lpfc_nvmet_unsol_ls_buffer */
40 atomic_t rcv_ls_req_in
;
41 atomic_t rcv_ls_req_out
;
42 atomic_t rcv_ls_req_drop
;
43 atomic_t xmt_ls_abort
;
44 atomic_t xmt_ls_abort_cmpl
;
46 /* Stats counters - lpfc_nvmet_xmt_ls_rsp */
50 /* Stats counters - lpfc_nvmet_xmt_ls_rsp_cmp */
51 atomic_t xmt_ls_rsp_error
;
52 atomic_t xmt_ls_rsp_aborted
;
53 atomic_t xmt_ls_rsp_xb_set
;
54 atomic_t xmt_ls_rsp_cmpl
;
56 /* Stats counters - lpfc_nvmet_unsol_fcp_buffer */
57 atomic_t rcv_fcp_cmd_in
;
58 atomic_t rcv_fcp_cmd_out
;
59 atomic_t rcv_fcp_cmd_drop
;
60 atomic_t rcv_fcp_cmd_defer
;
61 atomic_t xmt_fcp_release
;
63 /* Stats counters - lpfc_nvmet_xmt_fcp_op */
64 atomic_t xmt_fcp_drop
;
65 atomic_t xmt_fcp_read_rsp
;
66 atomic_t xmt_fcp_read
;
67 atomic_t xmt_fcp_write
;
70 /* Stats counters - lpfc_nvmet_xmt_fcp_op_cmp */
71 atomic_t xmt_fcp_rsp_xb_set
;
72 atomic_t xmt_fcp_rsp_cmpl
;
73 atomic_t xmt_fcp_rsp_error
;
74 atomic_t xmt_fcp_rsp_aborted
;
75 atomic_t xmt_fcp_rsp_drop
;
77 /* Stats counters - lpfc_nvmet_xmt_fcp_abort */
78 atomic_t xmt_fcp_xri_abort_cqe
;
79 atomic_t xmt_fcp_abort
;
80 atomic_t xmt_fcp_abort_cmpl
;
81 atomic_t xmt_abort_sol
;
82 atomic_t xmt_abort_unsol
;
83 atomic_t xmt_abort_rsp
;
84 atomic_t xmt_abort_rsp_error
;
86 /* Stats counters - defer IO */
89 atomic_t defer_wqfull
;
92 struct lpfc_nvmet_ctx_info
{
93 struct list_head nvmet_ctx_list
;
94 spinlock_t nvmet_ctx_list_lock
; /* lock per CPU */
95 struct lpfc_nvmet_ctx_info
*nvmet_ctx_next_cpu
;
96 struct lpfc_nvmet_ctx_info
*nvmet_ctx_start_cpu
;
97 uint16_t nvmet_ctx_list_cnt
;
98 char pad
[16]; /* pad to a cache-line */
101 /* This retrieves the context info associated with the specified cpu / mrq */
102 #define lpfc_get_ctx_list(phba, cpu, mrq) \
103 (phba->sli4_hba.nvmet_ctx_info + ((cpu * phba->cfg_nvmet_mrq) + mrq))
105 struct lpfc_nvmet_rcv_ctx
{
107 struct nvmefc_tgt_ls_req ls_req
;
108 struct nvmefc_tgt_fcp_req fcp_req
;
110 struct list_head list
;
111 struct lpfc_hba
*phba
;
112 struct lpfc_iocbq
*wqeq
;
113 struct lpfc_iocbq
*abort_wqeq
;
114 dma_addr_t txrdy_phys
;
115 spinlock_t ctxlock
; /* protect flag access */
126 #define LPFC_NVMET_STE_LS_RCV 1
127 #define LPFC_NVMET_STE_LS_ABORT 2
128 #define LPFC_NVMET_STE_LS_RSP 3
129 #define LPFC_NVMET_STE_RCV 4
130 #define LPFC_NVMET_STE_DATA 5
131 #define LPFC_NVMET_STE_ABORT 6
132 #define LPFC_NVMET_STE_DONE 7
133 #define LPFC_NVMET_STE_FREE 0xff
135 #define LPFC_NVMET_IO_INP 0x1 /* IO is in progress on exchange */
136 #define LPFC_NVMET_ABORT_OP 0x2 /* Abort WQE issued on exchange */
137 #define LPFC_NVMET_XBUSY 0x4 /* XB bit set on IO cmpl */
138 #define LPFC_NVMET_CTX_RLS 0x8 /* ctx free requested */
139 #define LPFC_NVMET_ABTS_RCV 0x10 /* ABTS received on exchange */
140 #define LPFC_NVMET_DEFER_WQFULL 0x40 /* Waiting on a free WQE */
141 struct rqb_dmabuf
*rqb_buffer
;
142 struct lpfc_nvmet_ctxbuf
*ctxbuf
;
144 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
146 uint64_t ts_cmd_nvme
;
147 uint64_t ts_nvme_data
;
148 uint64_t ts_data_wqput
;
149 uint64_t ts_isr_data
;
150 uint64_t ts_data_nvme
;
151 uint64_t ts_nvme_status
;
152 uint64_t ts_status_wqput
;
153 uint64_t ts_isr_status
;
154 uint64_t ts_status_nvme
;