lpfc_nvmet.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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_NVMET_DEFAULT_SEGS (64 + 1) /* 256K IOs */
  24. #define LPFC_NVMET_RQE_MIN_POST 128
  25. #define LPFC_NVMET_RQE_DEF_POST 512
  26. #define LPFC_NVMET_RQE_DEF_COUNT 2048
  27. #define LPFC_NVMET_SUCCESS_LEN 12
  28. #define LPFC_NVMET_MRQ_OFF 0xffff
  29. #define LPFC_NVMET_MRQ_AUTO 0
  30. #define LPFC_NVMET_MRQ_MAX 16
  31. #define LPFC_NVMET_WAIT_TMO (5 * MSEC_PER_SEC)
  32. /* Used for NVME Target */
  33. struct lpfc_nvmet_tgtport {
  34. struct lpfc_hba *phba;
  35. struct completion *tport_unreg_cmp;
  36. /* Stats counters - lpfc_nvmet_unsol_ls_buffer */
  37. atomic_t rcv_ls_req_in;
  38. atomic_t rcv_ls_req_out;
  39. atomic_t rcv_ls_req_drop;
  40. atomic_t xmt_ls_abort;
  41. atomic_t xmt_ls_abort_cmpl;
  42. /* Stats counters - lpfc_nvmet_xmt_ls_rsp */
  43. atomic_t xmt_ls_rsp;
  44. atomic_t xmt_ls_drop;
  45. /* Stats counters - lpfc_nvmet_xmt_ls_rsp_cmp */
  46. atomic_t xmt_ls_rsp_error;
  47. atomic_t xmt_ls_rsp_aborted;
  48. atomic_t xmt_ls_rsp_xb_set;
  49. atomic_t xmt_ls_rsp_cmpl;
  50. /* Stats counters - lpfc_nvmet_unsol_fcp_buffer */
  51. atomic_t rcv_fcp_cmd_in;
  52. atomic_t rcv_fcp_cmd_out;
  53. atomic_t rcv_fcp_cmd_drop;
  54. atomic_t rcv_fcp_cmd_defer;
  55. atomic_t xmt_fcp_release;
  56. /* Stats counters - lpfc_nvmet_xmt_fcp_op */
  57. atomic_t xmt_fcp_drop;
  58. atomic_t xmt_fcp_read_rsp;
  59. atomic_t xmt_fcp_read;
  60. atomic_t xmt_fcp_write;
  61. atomic_t xmt_fcp_rsp;
  62. /* Stats counters - lpfc_nvmet_xmt_fcp_op_cmp */
  63. atomic_t xmt_fcp_rsp_xb_set;
  64. atomic_t xmt_fcp_rsp_cmpl;
  65. atomic_t xmt_fcp_rsp_error;
  66. atomic_t xmt_fcp_rsp_aborted;
  67. atomic_t xmt_fcp_rsp_drop;
  68. /* Stats counters - lpfc_nvmet_xmt_fcp_abort */
  69. atomic_t xmt_fcp_xri_abort_cqe;
  70. atomic_t xmt_fcp_abort;
  71. atomic_t xmt_fcp_abort_cmpl;
  72. atomic_t xmt_abort_sol;
  73. atomic_t xmt_abort_unsol;
  74. atomic_t xmt_abort_rsp;
  75. atomic_t xmt_abort_rsp_error;
  76. /* Stats counters - defer IO */
  77. atomic_t defer_ctx;
  78. atomic_t defer_fod;
  79. atomic_t defer_wqfull;
  80. };
  81. struct lpfc_nvmet_ctx_info {
  82. struct list_head nvmet_ctx_list;
  83. spinlock_t nvmet_ctx_list_lock; /* lock per CPU */
  84. struct lpfc_nvmet_ctx_info *nvmet_ctx_next_cpu;
  85. struct lpfc_nvmet_ctx_info *nvmet_ctx_start_cpu;
  86. uint16_t nvmet_ctx_list_cnt;
  87. char pad[16]; /* pad to a cache-line */
  88. };
  89. /* This retrieves the context info associated with the specified cpu / mrq */
  90. #define lpfc_get_ctx_list(phba, cpu, mrq) \
  91. (phba->sli4_hba.nvmet_ctx_info + ((cpu * phba->cfg_nvmet_mrq) + mrq))
  92. struct lpfc_nvmet_rcv_ctx {
  93. union {
  94. struct nvmefc_tgt_ls_req ls_req;
  95. struct nvmefc_tgt_fcp_req fcp_req;
  96. } ctx;
  97. struct list_head list;
  98. struct lpfc_hba *phba;
  99. struct lpfc_iocbq *wqeq;
  100. struct lpfc_iocbq *abort_wqeq;
  101. dma_addr_t txrdy_phys;
  102. spinlock_t ctxlock; /* protect flag access */
  103. uint32_t *txrdy;
  104. uint32_t sid;
  105. uint32_t offset;
  106. uint16_t oxid;
  107. uint16_t size;
  108. uint16_t entry_cnt;
  109. uint16_t cpu;
  110. uint16_t idx;
  111. uint16_t state;
  112. /* States */
  113. #define LPFC_NVMET_STE_LS_RCV 1
  114. #define LPFC_NVMET_STE_LS_ABORT 2
  115. #define LPFC_NVMET_STE_LS_RSP 3
  116. #define LPFC_NVMET_STE_RCV 4
  117. #define LPFC_NVMET_STE_DATA 5
  118. #define LPFC_NVMET_STE_ABORT 6
  119. #define LPFC_NVMET_STE_DONE 7
  120. #define LPFC_NVMET_STE_FREE 0xff
  121. uint16_t flag;
  122. #define LPFC_NVMET_IO_INP 0x1 /* IO is in progress on exchange */
  123. #define LPFC_NVMET_ABORT_OP 0x2 /* Abort WQE issued on exchange */
  124. #define LPFC_NVMET_XBUSY 0x4 /* XB bit set on IO cmpl */
  125. #define LPFC_NVMET_CTX_RLS 0x8 /* ctx free requested */
  126. #define LPFC_NVMET_ABTS_RCV 0x10 /* ABTS received on exchange */
  127. #define LPFC_NVMET_DEFER_WQFULL 0x40 /* Waiting on a free WQE */
  128. struct rqb_dmabuf *rqb_buffer;
  129. struct lpfc_nvmet_ctxbuf *ctxbuf;
  130. #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
  131. uint64_t ts_isr_cmd;
  132. uint64_t ts_cmd_nvme;
  133. uint64_t ts_nvme_data;
  134. uint64_t ts_data_wqput;
  135. uint64_t ts_isr_data;
  136. uint64_t ts_data_nvme;
  137. uint64_t ts_nvme_status;
  138. uint64_t ts_status_wqput;
  139. uint64_t ts_isr_status;
  140. uint64_t ts_status_nvme;
  141. #endif
  142. };