xref: /openbmc/linux/drivers/scsi/lpfc/lpfc_nvme.h (revision add9d6be)
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  ********************************************************************/
23 
24 #define LPFC_NVME_DEFAULT_SEGS		(64 + 1)	/* 256K IOs */
25 #define LPFC_NVME_WQSIZE		1024
26 #define LPFC_NVME_CQSIZE		4096
27 
28 #define LPFC_NVME_ERSP_LEN		0x20
29 
30 #define LPFC_NVME_WAIT_TMO              10
31 
32 struct lpfc_nvme_qhandle {
33 	uint32_t index;		/* WQ index to use */
34 	uint32_t qidx;		/* queue index passed to create */
35 	uint32_t cpu_id;	/* current cpu id at time of create */
36 };
37 
38 /* Declare nvme-based local and remote port definitions. */
39 struct lpfc_nvme_lport {
40 	struct lpfc_vport *vport;
41 	struct completion lport_unreg_done;
42 	/* Add sttats counters here */
43 };
44 
45 struct lpfc_nvme_rport {
46 	struct lpfc_nvme_lport *lport;
47 	struct nvme_fc_remote_port *remoteport;
48 	struct lpfc_nodelist *ndlp;
49 	struct completion rport_unreg_done;
50 };
51 
52 struct lpfc_nvme_buf {
53 	struct list_head list;
54 	struct nvmefc_fcp_req *nvmeCmd;
55 	struct lpfc_nvme_rport *nrport;
56 	struct lpfc_nodelist *ndlp;
57 
58 	uint32_t timeout;
59 
60 	uint16_t flags;  /* TBD convert exch_busy to flags */
61 #define LPFC_SBUF_XBUSY         0x1     /* SLI4 hba reported XB on WCQE cmpl */
62 	uint16_t exch_busy;     /* SLI4 hba reported XB on complete WCQE */
63 	uint16_t status;	/* From IOCB Word 7- ulpStatus */
64 	uint16_t cpu;
65 	uint16_t qidx;
66 	uint16_t sqid;
67 	uint32_t result;	/* From IOCB Word 4. */
68 
69 	uint32_t   seg_cnt;	/* Number of scatter-gather segments returned by
70 				 * dma_map_sg.  The driver needs this for calls
71 				 * to dma_unmap_sg.
72 				 */
73 	dma_addr_t nonsg_phys;	/* Non scatter-gather physical address. */
74 
75 	/*
76 	 * data and dma_handle are the kernel virtual and bus address of the
77 	 * dma-able buffer containing the fcp_cmd, fcp_rsp and a scatter
78 	 * gather bde list that supports the sg_tablesize value.
79 	 */
80 	void *data;
81 	dma_addr_t dma_handle;
82 
83 	struct sli4_sge *nvme_sgl;
84 	dma_addr_t dma_phys_sgl;
85 
86 	/* cur_iocbq has phys of the dma-able buffer.
87 	 * Iotag is in here
88 	 */
89 	struct lpfc_iocbq cur_iocbq;
90 
91 	wait_queue_head_t *waitq;
92 	unsigned long start_time;
93 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
94 	uint64_t ts_cmd_start;
95 	uint64_t ts_last_cmd;
96 	uint64_t ts_cmd_wqput;
97 	uint64_t ts_isr_cmpl;
98 	uint64_t ts_data_nvme;
99 #endif
100 };
101 
102 struct lpfc_nvme_fcpreq_priv {
103 	struct lpfc_nvme_buf *nvme_buf;
104 };
105