lpfc_nvme.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. *
  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. #define LPFC_NVME_DEFAULT_SEGS (64 + 1) /* 256K IOs */
  24. #define LPFC_NVME_ERSP_LEN 0x20
  25. #define LPFC_NVME_WAIT_TMO 10
  26. #define LPFC_NVME_EXPEDITE_XRICNT 8
  27. #define LPFC_NVME_FB_SHIFT 9
  28. #define LPFC_NVME_MAX_FB (1 << 20) /* 1M */
  29. #define lpfc_ndlp_get_nrport(ndlp) \
  30. ((!ndlp->nrport || (ndlp->upcall_flags & NLP_WAIT_FOR_UNREG)) \
  31. ? NULL : ndlp->nrport)
  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. struct lpfc_nvme_ctrl_stat {
  38. atomic_t fc4NvmeInputRequests;
  39. atomic_t fc4NvmeOutputRequests;
  40. atomic_t fc4NvmeControlRequests;
  41. atomic_t fc4NvmeIoCmpls;
  42. };
  43. /* Declare nvme-based local and remote port definitions. */
  44. struct lpfc_nvme_lport {
  45. struct lpfc_vport *vport;
  46. struct completion *lport_unreg_cmp;
  47. /* Add stats counters here */
  48. struct lpfc_nvme_ctrl_stat *cstat;
  49. atomic_t fc4NvmeLsRequests;
  50. atomic_t fc4NvmeLsCmpls;
  51. atomic_t xmt_fcp_noxri;
  52. atomic_t xmt_fcp_bad_ndlp;
  53. atomic_t xmt_fcp_qdepth;
  54. atomic_t xmt_fcp_wqerr;
  55. atomic_t xmt_fcp_err;
  56. atomic_t xmt_fcp_abort;
  57. atomic_t xmt_ls_abort;
  58. atomic_t xmt_ls_err;
  59. atomic_t cmpl_fcp_xb;
  60. atomic_t cmpl_fcp_err;
  61. atomic_t cmpl_ls_xb;
  62. atomic_t cmpl_ls_err;
  63. };
  64. struct lpfc_nvme_rport {
  65. struct lpfc_nvme_lport *lport;
  66. struct nvme_fc_remote_port *remoteport;
  67. struct lpfc_nodelist *ndlp;
  68. struct completion rport_unreg_done;
  69. };
  70. struct lpfc_nvme_buf {
  71. struct list_head list;
  72. struct nvmefc_fcp_req *nvmeCmd;
  73. struct lpfc_nvme_rport *nrport;
  74. struct lpfc_nodelist *ndlp;
  75. uint32_t timeout;
  76. uint16_t flags; /* TBD convert exch_busy to flags */
  77. #define LPFC_SBUF_XBUSY 0x1 /* SLI4 hba reported XB on WCQE cmpl */
  78. #define LPFC_BUMP_QDEPTH 0x2 /* bumped queue depth counter */
  79. uint16_t exch_busy; /* SLI4 hba reported XB on complete WCQE */
  80. uint16_t status; /* From IOCB Word 7- ulpStatus */
  81. uint16_t cpu;
  82. uint16_t qidx;
  83. uint16_t sqid;
  84. uint32_t result; /* From IOCB Word 4. */
  85. uint32_t seg_cnt; /* Number of scatter-gather segments returned by
  86. * dma_map_sg. The driver needs this for calls
  87. * to dma_unmap_sg.
  88. */
  89. dma_addr_t nonsg_phys; /* Non scatter-gather physical address. */
  90. /*
  91. * data and dma_handle are the kernel virtual and bus address of the
  92. * dma-able buffer containing the fcp_cmd, fcp_rsp and a scatter
  93. * gather bde list that supports the sg_tablesize value.
  94. */
  95. void *data;
  96. dma_addr_t dma_handle;
  97. struct sli4_sge *nvme_sgl;
  98. dma_addr_t dma_phys_sgl;
  99. /* cur_iocbq has phys of the dma-able buffer.
  100. * Iotag is in here
  101. */
  102. struct lpfc_iocbq cur_iocbq;
  103. wait_queue_head_t *waitq;
  104. unsigned long start_time;
  105. #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
  106. uint64_t ts_cmd_start;
  107. uint64_t ts_last_cmd;
  108. uint64_t ts_cmd_wqput;
  109. uint64_t ts_isr_cmpl;
  110. uint64_t ts_data_nvme;
  111. #endif
  112. };
  113. struct lpfc_nvme_fcpreq_priv {
  114. struct lpfc_nvme_buf *nvme_buf;
  115. };