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. *
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_DEF_COUNT 512
26 #define LPFC_NVMET_SUCCESS_LEN 12
28 /* Used for NVME Target */
29 struct lpfc_nvmet_tgtport {
30 struct lpfc_hba *phba;
31 struct completion tport_unreg_done;
33 /* Stats counters - lpfc_nvmet_unsol_ls_buffer */
34 atomic_t rcv_ls_req_in;
35 atomic_t rcv_ls_req_out;
36 atomic_t rcv_ls_req_drop;
37 atomic_t xmt_ls_abort;
38 atomic_t xmt_ls_abort_cmpl;
40 /* Stats counters - lpfc_nvmet_xmt_ls_rsp */
44 /* Stats counters - lpfc_nvmet_xmt_ls_rsp_cmp */
45 atomic_t xmt_ls_rsp_error;
46 atomic_t xmt_ls_rsp_cmpl;
48 /* Stats counters - lpfc_nvmet_unsol_fcp_buffer */
49 atomic_t rcv_fcp_cmd_in;
50 atomic_t rcv_fcp_cmd_out;
51 atomic_t rcv_fcp_cmd_drop;
52 atomic_t rcv_fcp_cmd_defer;
53 atomic_t xmt_fcp_release;
55 /* Stats counters - lpfc_nvmet_xmt_fcp_op */
56 atomic_t xmt_fcp_drop;
57 atomic_t xmt_fcp_read_rsp;
58 atomic_t xmt_fcp_read;
59 atomic_t xmt_fcp_write;
62 /* Stats counters - lpfc_nvmet_xmt_fcp_op_cmp */
63 atomic_t xmt_fcp_rsp_cmpl;
64 atomic_t xmt_fcp_rsp_error;
65 atomic_t xmt_fcp_rsp_drop;
68 /* Stats counters - lpfc_nvmet_xmt_fcp_abort */
69 atomic_t xmt_fcp_abort;
70 atomic_t xmt_fcp_abort_cmpl;
71 atomic_t xmt_abort_sol;
72 atomic_t xmt_abort_unsol;
73 atomic_t xmt_abort_rsp;
74 atomic_t xmt_abort_rsp_error;
77 struct lpfc_nvmet_ctx_info {
78 struct list_head nvmet_ctx_list;
79 spinlock_t nvmet_ctx_list_lock; /* lock per CPU */
80 struct lpfc_nvmet_ctx_info *nvmet_ctx_next_cpu;
81 struct lpfc_nvmet_ctx_info *nvmet_ctx_start_cpu;
82 uint16_t nvmet_ctx_list_cnt;
83 char pad[16]; /* pad to a cache-line */
86 /* This retrieves the context info associated with the specified cpu / mrq */
87 #define lpfc_get_ctx_list(phba, cpu, mrq) \
88 (phba->sli4_hba.nvmet_ctx_info + ((cpu * phba->cfg_nvmet_mrq) + mrq))
90 struct lpfc_nvmet_rcv_ctx {
92 struct nvmefc_tgt_ls_req ls_req;
93 struct nvmefc_tgt_fcp_req fcp_req;
95 struct list_head list;
96 struct lpfc_hba *phba;
97 struct lpfc_iocbq *wqeq;
98 struct lpfc_iocbq *abort_wqeq;
99 dma_addr_t txrdy_phys;
100 spinlock_t ctxlock; /* protect flag access */
111 #define LPFC_NVMET_STE_LS_RCV 1
112 #define LPFC_NVMET_STE_LS_ABORT 2
113 #define LPFC_NVMET_STE_LS_RSP 3
114 #define LPFC_NVMET_STE_RCV 4
115 #define LPFC_NVMET_STE_DATA 5
116 #define LPFC_NVMET_STE_ABORT 6
117 #define LPFC_NVMET_STE_DONE 7
118 #define LPFC_NVMET_STE_FREE 0xff
120 #define LPFC_NVMET_IO_INP 0x1 /* IO is in progress on exchange */
121 #define LPFC_NVMET_ABORT_OP 0x2 /* Abort WQE issued on exchange */
122 #define LPFC_NVMET_XBUSY 0x4 /* XB bit set on IO cmpl */
123 #define LPFC_NVMET_CTX_RLS 0x8 /* ctx free requested */
124 #define LPFC_NVMET_ABTS_RCV 0x10 /* ABTS received on exchange */
125 struct rqb_dmabuf *rqb_buffer;
126 struct lpfc_nvmet_ctxbuf *ctxbuf;
128 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
130 uint64_t ts_cmd_nvme;
131 uint64_t ts_nvme_data;
132 uint64_t ts_data_wqput;
133 uint64_t ts_isr_data;
134 uint64_t ts_data_nvme;
135 uint64_t ts_nvme_status;
136 uint64_t ts_status_wqput;
137 uint64_t ts_isr_status;
138 uint64_t ts_status_nvme;