storage_common.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015-2017 QLogic Corporation
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and /or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef __STORAGE_COMMON__
  33. #define __STORAGE_COMMON__
  34. /*********************/
  35. /* SCSI CONSTANTS */
  36. /*********************/
  37. #define SCSI_MAX_NUM_OF_CMDQS (NUM_OF_GLOBAL_QUEUES / 2)
  38. #define BDQ_NUM_RESOURCES (4)
  39. #define BDQ_ID_RQ (0)
  40. #define BDQ_ID_IMM_DATA (1)
  41. #define BDQ_ID_TQ (2)
  42. #define BDQ_NUM_IDS (3)
  43. #define SCSI_NUM_SGES_SLOW_SGL_THR 8
  44. #define BDQ_MAX_EXTERNAL_RING_SIZE BIT(15)
  45. /* SCSI op codes */
  46. #define SCSI_OPCODE_COMPARE_AND_WRITE (0x89)
  47. #define SCSI_OPCODE_READ_10 (0x28)
  48. #define SCSI_OPCODE_WRITE_6 (0x0A)
  49. #define SCSI_OPCODE_WRITE_10 (0x2A)
  50. #define SCSI_OPCODE_WRITE_12 (0xAA)
  51. #define SCSI_OPCODE_WRITE_16 (0x8A)
  52. #define SCSI_OPCODE_WRITE_AND_VERIFY_10 (0x2E)
  53. #define SCSI_OPCODE_WRITE_AND_VERIFY_12 (0xAE)
  54. #define SCSI_OPCODE_WRITE_AND_VERIFY_16 (0x8E)
  55. /* iSCSI Drv opaque */
  56. struct iscsi_drv_opaque {
  57. __le16 reserved_zero[3];
  58. __le16 opaque;
  59. };
  60. /* Scsi 2B/8B opaque union */
  61. union scsi_opaque {
  62. struct regpair fcoe_opaque;
  63. struct iscsi_drv_opaque iscsi_opaque;
  64. };
  65. /* SCSI buffer descriptor */
  66. struct scsi_bd {
  67. struct regpair address;
  68. union scsi_opaque opaque;
  69. };
  70. /* Scsi Drv BDQ struct */
  71. struct scsi_bdq_ram_drv_data {
  72. __le16 external_producer;
  73. __le16 reserved0[3];
  74. };
  75. /* SCSI SGE entry */
  76. struct scsi_sge {
  77. struct regpair sge_addr;
  78. __le32 sge_len;
  79. __le32 reserved;
  80. };
  81. /* Cached SGEs section */
  82. struct scsi_cached_sges {
  83. struct scsi_sge sge[4];
  84. };
  85. /* Scsi Drv CMDQ struct */
  86. struct scsi_drv_cmdq {
  87. __le16 cmdq_cons;
  88. __le16 reserved0;
  89. __le32 reserved1;
  90. };
  91. /* Common SCSI init params passed by driver to FW in function init ramrod */
  92. struct scsi_init_func_params {
  93. __le16 num_tasks;
  94. u8 log_page_size;
  95. u8 debug_mode;
  96. u8 reserved2[12];
  97. };
  98. /* SCSI RQ/CQ/CMDQ firmware function init parameters */
  99. struct scsi_init_func_queues {
  100. struct regpair glbl_q_params_addr;
  101. __le16 rq_buffer_size;
  102. __le16 cq_num_entries;
  103. __le16 cmdq_num_entries;
  104. u8 bdq_resource_id;
  105. u8 q_validity;
  106. #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_MASK 0x1
  107. #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_SHIFT 0
  108. #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_MASK 0x1
  109. #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_SHIFT 1
  110. #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_MASK 0x1
  111. #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_SHIFT 2
  112. #define SCSI_INIT_FUNC_QUEUES_TQ_VALID_MASK 0x1
  113. #define SCSI_INIT_FUNC_QUEUES_TQ_VALID_SHIFT 3
  114. #define SCSI_INIT_FUNC_QUEUES_SOC_EN_MASK 0x1
  115. #define SCSI_INIT_FUNC_QUEUES_SOC_EN_SHIFT 4
  116. #define SCSI_INIT_FUNC_QUEUES_SOC_NUM_OF_BLOCKS_LOG_MASK 0x7
  117. #define SCSI_INIT_FUNC_QUEUES_SOC_NUM_OF_BLOCKS_LOG_SHIFT 5
  118. __le16 cq_cmdq_sb_num_arr[SCSI_MAX_NUM_OF_CMDQS];
  119. u8 num_queues;
  120. u8 queue_relative_offset;
  121. u8 cq_sb_pi;
  122. u8 cmdq_sb_pi;
  123. u8 bdq_pbl_num_entries[BDQ_NUM_IDS];
  124. u8 reserved1;
  125. struct regpair bdq_pbl_base_address[BDQ_NUM_IDS];
  126. __le16 bdq_xoff_threshold[BDQ_NUM_IDS];
  127. __le16 cmdq_xoff_threshold;
  128. __le16 bdq_xon_threshold[BDQ_NUM_IDS];
  129. __le16 cmdq_xon_threshold;
  130. };
  131. /* Scsi Drv BDQ Data struct (2 BDQ IDs: 0 - RQ, 1 - Immediate Data) */
  132. struct scsi_ram_per_bdq_resource_drv_data {
  133. struct scsi_bdq_ram_drv_data drv_data_per_bdq_id[BDQ_NUM_IDS];
  134. };
  135. /* SCSI SGL types */
  136. enum scsi_sgl_mode {
  137. SCSI_TX_SLOW_SGL,
  138. SCSI_FAST_SGL,
  139. MAX_SCSI_SGL_MODE
  140. };
  141. /* SCSI SGL parameters */
  142. struct scsi_sgl_params {
  143. struct regpair sgl_addr;
  144. __le32 sgl_total_length;
  145. __le32 sge_offset;
  146. __le16 sgl_num_sges;
  147. u8 sgl_index;
  148. u8 reserved;
  149. };
  150. /* SCSI terminate connection params */
  151. struct scsi_terminate_extra_params {
  152. __le16 unsolicited_cq_count;
  153. __le16 cmdq_count;
  154. u8 reserved[4];
  155. };
  156. /* SCSI Task Queue Element */
  157. struct scsi_tqe {
  158. __le16 itid;
  159. };
  160. #endif /* __STORAGE_COMMON__ */