xref: /openbmc/linux/drivers/scsi/lpfc/lpfc_nvme.h (revision 895427bd)
1895427bdSJames Smart /*******************************************************************
2895427bdSJames Smart  * This file is part of the Emulex Linux Device Driver for         *
3895427bdSJames Smart  * Fibre Channel Host Bus Adapters.                                *
4895427bdSJames Smart  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
5895427bdSJames Smart  * EMULEX and SLI are trademarks of Emulex.                        *
6895427bdSJames Smart  * www.emulex.com                                                  *
7895427bdSJames Smart  * Portions Copyright (C) 2004-2005 Christoph Hellwig              *
8895427bdSJames Smart  *                                                                 *
9895427bdSJames Smart  * This program is free software; you can redistribute it and/or   *
10895427bdSJames Smart  * modify it under the terms of version 2 of the GNU General       *
11895427bdSJames Smart  * Public License as published by the Free Software Foundation.    *
12895427bdSJames Smart  * This program is distributed in the hope that it will be useful. *
13895427bdSJames Smart  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
14895427bdSJames Smart  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
15895427bdSJames Smart  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
16895427bdSJames Smart  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17895427bdSJames Smart  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
18895427bdSJames Smart  * more details, a copy of which can be found in the file COPYING  *
19895427bdSJames Smart  * included with this package.                                     *
20895427bdSJames Smart  ********************************************************************/
21895427bdSJames Smart 
22895427bdSJames Smart #define LPFC_NVME_MIN_SEGS		16
23895427bdSJames Smart #define LPFC_NVME_DEFAULT_SEGS		66	/* 256K IOs - 64 + 2 */
24895427bdSJames Smart #define LPFC_NVME_MAX_SEGS		510
25895427bdSJames Smart #define LPFC_NVMET_MIN_POSTBUF		16
26895427bdSJames Smart #define LPFC_NVMET_DEFAULT_POSTBUF	1024
27895427bdSJames Smart #define LPFC_NVMET_MAX_POSTBUF		4096
28895427bdSJames Smart #define LPFC_NVME_WQSIZE		256
29895427bdSJames Smart 
30895427bdSJames Smart #define LPFC_NVME_ERSP_LEN		0x20
31895427bdSJames Smart 
32895427bdSJames Smart /* Declare nvme-based local and remote port definitions. */
33895427bdSJames Smart struct lpfc_nvme_lport {
34895427bdSJames Smart 	struct lpfc_vport *vport;
35895427bdSJames Smart 	struct list_head rport_list;
36895427bdSJames Smart 	struct completion lport_unreg_done;
37895427bdSJames Smart 	/* Add sttats counters here */
38895427bdSJames Smart };
39895427bdSJames Smart 
40895427bdSJames Smart struct lpfc_nvme_rport {
41895427bdSJames Smart 	struct list_head list;
42895427bdSJames Smart 	struct lpfc_nvme_lport *lport;
43895427bdSJames Smart 	struct nvme_fc_remote_port *remoteport;
44895427bdSJames Smart 	struct lpfc_nodelist *ndlp;
45895427bdSJames Smart 	struct completion rport_unreg_done;
46895427bdSJames Smart };
47895427bdSJames Smart 
48895427bdSJames Smart struct lpfc_nvme_buf {
49895427bdSJames Smart 	struct list_head list;
50895427bdSJames Smart 	struct nvmefc_fcp_req *nvmeCmd;
51895427bdSJames Smart 	struct lpfc_nvme_rport *nrport;
52895427bdSJames Smart 
53895427bdSJames Smart 	uint32_t timeout;
54895427bdSJames Smart 
55895427bdSJames Smart 	uint16_t flags;  /* TBD convert exch_busy to flags */
56895427bdSJames Smart #define LPFC_SBUF_XBUSY         0x1     /* SLI4 hba reported XB on WCQE cmpl */
57895427bdSJames Smart 	uint16_t exch_busy;     /* SLI4 hba reported XB on complete WCQE */
58895427bdSJames Smart 	uint16_t status;	/* From IOCB Word 7- ulpStatus */
59895427bdSJames Smart 	uint16_t cpu;
60895427bdSJames Smart 	uint16_t qidx;
61895427bdSJames Smart 	uint16_t sqid;
62895427bdSJames Smart 	uint32_t result;	/* From IOCB Word 4. */
63895427bdSJames Smart 
64895427bdSJames Smart 	uint32_t   seg_cnt;	/* Number of scatter-gather segments returned by
65895427bdSJames Smart 				 * dma_map_sg.  The driver needs this for calls
66895427bdSJames Smart 				 * to dma_unmap_sg.
67895427bdSJames Smart 				 */
68895427bdSJames Smart 	dma_addr_t nonsg_phys;	/* Non scatter-gather physical address. */
69895427bdSJames Smart 
70895427bdSJames Smart 	/*
71895427bdSJames Smart 	 * data and dma_handle are the kernel virtual and bus address of the
72895427bdSJames Smart 	 * dma-able buffer containing the fcp_cmd, fcp_rsp and a scatter
73895427bdSJames Smart 	 * gather bde list that supports the sg_tablesize value.
74895427bdSJames Smart 	 */
75895427bdSJames Smart 	void *data;
76895427bdSJames Smart 	dma_addr_t dma_handle;
77895427bdSJames Smart 
78895427bdSJames Smart 	struct sli4_sge *nvme_sgl;
79895427bdSJames Smart 	dma_addr_t dma_phys_sgl;
80895427bdSJames Smart 
81895427bdSJames Smart 	/* cur_iocbq has phys of the dma-able buffer.
82895427bdSJames Smart 	 * Iotag is in here
83895427bdSJames Smart 	 */
84895427bdSJames Smart 	struct lpfc_iocbq cur_iocbq;
85895427bdSJames Smart 
86895427bdSJames Smart 	wait_queue_head_t *waitq;
87895427bdSJames Smart 	unsigned long start_time;
88895427bdSJames Smart };
89