1895427bdSJames Smart /******************************************************************* 2895427bdSJames Smart * This file is part of the Emulex Linux Device Driver for * 3895427bdSJames Smart * Fibre Channel Host Bus Adapters. * 4217c55cdSJames Smart * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term * 5d080abe0SJames Smart * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. * 6895427bdSJames Smart * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7895427bdSJames Smart * EMULEX and SLI are trademarks of Emulex. * 8d080abe0SJames Smart * www.broadcom.com * 9895427bdSJames Smart * Portions Copyright (C) 2004-2005 Christoph Hellwig * 10895427bdSJames Smart * * 11895427bdSJames Smart * This program is free software; you can redistribute it and/or * 12895427bdSJames Smart * modify it under the terms of version 2 of the GNU General * 13895427bdSJames Smart * Public License as published by the Free Software Foundation. * 14895427bdSJames Smart * This program is distributed in the hope that it will be useful. * 15895427bdSJames Smart * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * 16895427bdSJames Smart * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * 17895427bdSJames Smart * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * 18895427bdSJames Smart * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * 19895427bdSJames Smart * TO BE LEGALLY INVALID. See the GNU General Public License for * 20895427bdSJames Smart * more details, a copy of which can be found in the file COPYING * 21895427bdSJames Smart * included with this package. * 22895427bdSJames Smart ********************************************************************/ 23895427bdSJames Smart 24a44e4e8bSJames Smart #define LPFC_NVME_DEFAULT_SEGS (64 + 1) /* 256K IOs */ 25895427bdSJames Smart 26895427bdSJames Smart #define LPFC_NVME_ERSP_LEN 0x20 27895427bdSJames Smart 28add9d6beSJames Smart #define LPFC_NVME_WAIT_TMO 10 29cf1a1d3eSJames Smart #define LPFC_NVME_EXPEDITE_XRICNT 8 300709263aSJames Smart #define LPFC_NVME_FB_SHIFT 9 310709263aSJames Smart #define LPFC_NVME_MAX_FB (1 << 20) /* 1M */ 32add9d6beSJames Smart 3301466024SJames Smart #define lpfc_ndlp_get_nrport(ndlp) \ 3401466024SJames Smart ((!ndlp->nrport || (ndlp->upcall_flags & NLP_WAIT_FOR_UNREG)) \ 3501466024SJames Smart ? NULL : ndlp->nrport) 3601466024SJames Smart 3701649561SJames Smart struct lpfc_nvme_qhandle { 3801649561SJames Smart uint32_t index; /* WQ index to use */ 3901649561SJames Smart uint32_t qidx; /* queue index passed to create */ 4001649561SJames Smart uint32_t cpu_id; /* current cpu id at time of create */ 4101649561SJames Smart }; 4201649561SJames Smart 4366a210ffSJames Smart struct lpfc_nvme_ctrl_stat { 4466a210ffSJames Smart atomic_t fc4NvmeInputRequests; 4566a210ffSJames Smart atomic_t fc4NvmeOutputRequests; 4666a210ffSJames Smart atomic_t fc4NvmeControlRequests; 4766a210ffSJames Smart atomic_t fc4NvmeIoCmpls; 4866a210ffSJames Smart }; 4966a210ffSJames Smart 50895427bdSJames Smart /* Declare nvme-based local and remote port definitions. */ 51895427bdSJames Smart struct lpfc_nvme_lport { 52895427bdSJames Smart struct lpfc_vport *vport; 53895427bdSJames Smart struct completion lport_unreg_done; 544b056682SJames Smart /* Add stats counters here */ 5566a210ffSJames Smart struct lpfc_nvme_ctrl_stat *cstat; 5666a210ffSJames Smart atomic_t fc4NvmeLsRequests; 5766a210ffSJames Smart atomic_t fc4NvmeLsCmpls; 584b056682SJames Smart atomic_t xmt_fcp_noxri; 594b056682SJames Smart atomic_t xmt_fcp_bad_ndlp; 604b056682SJames Smart atomic_t xmt_fcp_qdepth; 614b056682SJames Smart atomic_t xmt_fcp_wqerr; 624b056682SJames Smart atomic_t xmt_fcp_abort; 634b056682SJames Smart atomic_t xmt_ls_abort; 644b056682SJames Smart atomic_t xmt_ls_err; 654b056682SJames Smart atomic_t cmpl_fcp_xb; 664b056682SJames Smart atomic_t cmpl_fcp_err; 674b056682SJames Smart atomic_t cmpl_ls_xb; 684b056682SJames Smart atomic_t cmpl_ls_err; 69895427bdSJames Smart }; 70895427bdSJames Smart 71895427bdSJames Smart struct lpfc_nvme_rport { 72895427bdSJames Smart struct lpfc_nvme_lport *lport; 73895427bdSJames Smart struct nvme_fc_remote_port *remoteport; 74895427bdSJames Smart struct lpfc_nodelist *ndlp; 75895427bdSJames Smart struct completion rport_unreg_done; 76895427bdSJames Smart }; 77895427bdSJames Smart 78895427bdSJames Smart struct lpfc_nvme_buf { 79895427bdSJames Smart struct list_head list; 80895427bdSJames Smart struct nvmefc_fcp_req *nvmeCmd; 81895427bdSJames Smart struct lpfc_nvme_rport *nrport; 82318083adSJames Smart struct lpfc_nodelist *ndlp; 83895427bdSJames Smart 84895427bdSJames Smart uint32_t timeout; 85895427bdSJames Smart 86895427bdSJames Smart uint16_t flags; /* TBD convert exch_busy to flags */ 87895427bdSJames Smart #define LPFC_SBUF_XBUSY 0x1 /* SLI4 hba reported XB on WCQE cmpl */ 88895427bdSJames Smart uint16_t exch_busy; /* SLI4 hba reported XB on complete WCQE */ 89895427bdSJames Smart uint16_t status; /* From IOCB Word 7- ulpStatus */ 90895427bdSJames Smart uint16_t cpu; 91895427bdSJames Smart uint16_t qidx; 92895427bdSJames Smart uint16_t sqid; 93895427bdSJames Smart uint32_t result; /* From IOCB Word 4. */ 94895427bdSJames Smart 95895427bdSJames Smart uint32_t seg_cnt; /* Number of scatter-gather segments returned by 96895427bdSJames Smart * dma_map_sg. The driver needs this for calls 97895427bdSJames Smart * to dma_unmap_sg. 98895427bdSJames Smart */ 99895427bdSJames Smart dma_addr_t nonsg_phys; /* Non scatter-gather physical address. */ 100895427bdSJames Smart 101895427bdSJames Smart /* 102895427bdSJames Smart * data and dma_handle are the kernel virtual and bus address of the 103895427bdSJames Smart * dma-able buffer containing the fcp_cmd, fcp_rsp and a scatter 104895427bdSJames Smart * gather bde list that supports the sg_tablesize value. 105895427bdSJames Smart */ 106895427bdSJames Smart void *data; 107895427bdSJames Smart dma_addr_t dma_handle; 108895427bdSJames Smart 109895427bdSJames Smart struct sli4_sge *nvme_sgl; 110895427bdSJames Smart dma_addr_t dma_phys_sgl; 111895427bdSJames Smart 112895427bdSJames Smart /* cur_iocbq has phys of the dma-able buffer. 113895427bdSJames Smart * Iotag is in here 114895427bdSJames Smart */ 115895427bdSJames Smart struct lpfc_iocbq cur_iocbq; 116895427bdSJames Smart 117895427bdSJames Smart wait_queue_head_t *waitq; 118895427bdSJames Smart unsigned long start_time; 119bd2cdd5eSJames Smart #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 120bd2cdd5eSJames Smart uint64_t ts_cmd_start; 121bd2cdd5eSJames Smart uint64_t ts_last_cmd; 122bd2cdd5eSJames Smart uint64_t ts_cmd_wqput; 123bd2cdd5eSJames Smart uint64_t ts_isr_cmpl; 124bd2cdd5eSJames Smart uint64_t ts_data_nvme; 125bd2cdd5eSJames Smart #endif 126895427bdSJames Smart }; 127bbe3012bSJames Smart 128bbe3012bSJames Smart struct lpfc_nvme_fcpreq_priv { 129bbe3012bSJames Smart struct lpfc_nvme_buf *nvme_buf; 130bbe3012bSJames Smart }; 131