storage_common.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
  2. /* QLogic qed NIC Driver
  3. * Copyright (c) 2015-2017 QLogic Corporation
  4. * Copyright (c) 2019-2020 Marvell International Ltd.
  5. */
  6. #ifndef __STORAGE_COMMON__
  7. #define __STORAGE_COMMON__
  8. /*********************/
  9. /* SCSI CONSTANTS */
  10. /*********************/
  11. #define SCSI_MAX_NUM_OF_CMDQS (NUM_OF_GLOBAL_QUEUES / 2)
  12. #define BDQ_NUM_RESOURCES (4)
  13. #define BDQ_ID_RQ (0)
  14. #define BDQ_ID_IMM_DATA (1)
  15. #define BDQ_ID_TQ (2)
  16. #define BDQ_NUM_IDS (3)
  17. #define SCSI_NUM_SGES_SLOW_SGL_THR 8
  18. #define BDQ_MAX_EXTERNAL_RING_SIZE BIT(15)
  19. /* SCSI op codes */
  20. #define SCSI_OPCODE_COMPARE_AND_WRITE (0x89)
  21. #define SCSI_OPCODE_READ_10 (0x28)
  22. #define SCSI_OPCODE_WRITE_6 (0x0A)
  23. #define SCSI_OPCODE_WRITE_10 (0x2A)
  24. #define SCSI_OPCODE_WRITE_12 (0xAA)
  25. #define SCSI_OPCODE_WRITE_16 (0x8A)
  26. #define SCSI_OPCODE_WRITE_AND_VERIFY_10 (0x2E)
  27. #define SCSI_OPCODE_WRITE_AND_VERIFY_12 (0xAE)
  28. #define SCSI_OPCODE_WRITE_AND_VERIFY_16 (0x8E)
  29. /* iSCSI Drv opaque */
  30. struct iscsi_drv_opaque {
  31. __le16 reserved_zero[3];
  32. __le16 opaque;
  33. };
  34. /* Scsi 2B/8B opaque union */
  35. union scsi_opaque {
  36. struct regpair fcoe_opaque;
  37. struct iscsi_drv_opaque iscsi_opaque;
  38. };
  39. /* SCSI buffer descriptor */
  40. struct scsi_bd {
  41. struct regpair address;
  42. union scsi_opaque opaque;
  43. };
  44. /* Scsi Drv BDQ struct */
  45. struct scsi_bdq_ram_drv_data {
  46. __le16 external_producer;
  47. __le16 reserved0[3];
  48. };
  49. /* SCSI SGE entry */
  50. struct scsi_sge {
  51. struct regpair sge_addr;
  52. __le32 sge_len;
  53. __le32 reserved;
  54. };
  55. /* Cached SGEs section */
  56. struct scsi_cached_sges {
  57. struct scsi_sge sge[4];
  58. };
  59. /* Scsi Drv CMDQ struct */
  60. struct scsi_drv_cmdq {
  61. __le16 cmdq_cons;
  62. __le16 reserved0;
  63. __le32 reserved1;
  64. };
  65. /* Common SCSI init params passed by driver to FW in function init ramrod */
  66. struct scsi_init_func_params {
  67. __le16 num_tasks;
  68. u8 log_page_size;
  69. u8 log_page_size_conn;
  70. u8 debug_mode;
  71. u8 reserved2[11];
  72. };
  73. /* SCSI RQ/CQ/CMDQ firmware function init parameters */
  74. struct scsi_init_func_queues {
  75. struct regpair glbl_q_params_addr;
  76. __le16 rq_buffer_size;
  77. __le16 cq_num_entries;
  78. __le16 cmdq_num_entries;
  79. u8 bdq_resource_id;
  80. u8 q_validity;
  81. #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_MASK 0x1
  82. #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_SHIFT 0
  83. #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_MASK 0x1
  84. #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_SHIFT 1
  85. #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_MASK 0x1
  86. #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_SHIFT 2
  87. #define SCSI_INIT_FUNC_QUEUES_TQ_VALID_MASK 0x1
  88. #define SCSI_INIT_FUNC_QUEUES_TQ_VALID_SHIFT 3
  89. #define SCSI_INIT_FUNC_QUEUES_SOC_EN_MASK 0x1
  90. #define SCSI_INIT_FUNC_QUEUES_SOC_EN_SHIFT 4
  91. #define SCSI_INIT_FUNC_QUEUES_SOC_NUM_OF_BLOCKS_LOG_MASK 0x7
  92. #define SCSI_INIT_FUNC_QUEUES_SOC_NUM_OF_BLOCKS_LOG_SHIFT 5
  93. __le16 cq_cmdq_sb_num_arr[SCSI_MAX_NUM_OF_CMDQS];
  94. u8 num_queues;
  95. u8 queue_relative_offset;
  96. u8 cq_sb_pi;
  97. u8 cmdq_sb_pi;
  98. u8 bdq_pbl_num_entries[BDQ_NUM_IDS];
  99. u8 reserved1;
  100. struct regpair bdq_pbl_base_address[BDQ_NUM_IDS];
  101. __le16 bdq_xoff_threshold[BDQ_NUM_IDS];
  102. __le16 cmdq_xoff_threshold;
  103. __le16 bdq_xon_threshold[BDQ_NUM_IDS];
  104. __le16 cmdq_xon_threshold;
  105. };
  106. /* Scsi Drv BDQ Data struct (2 BDQ IDs: 0 - RQ, 1 - Immediate Data) */
  107. struct scsi_ram_per_bdq_resource_drv_data {
  108. struct scsi_bdq_ram_drv_data drv_data_per_bdq_id[BDQ_NUM_IDS];
  109. };
  110. /* SCSI SGL types */
  111. enum scsi_sgl_mode {
  112. SCSI_TX_SLOW_SGL,
  113. SCSI_FAST_SGL,
  114. MAX_SCSI_SGL_MODE
  115. };
  116. /* SCSI SGL parameters */
  117. struct scsi_sgl_params {
  118. struct regpair sgl_addr;
  119. __le32 sgl_total_length;
  120. __le32 sge_offset;
  121. __le16 sgl_num_sges;
  122. u8 sgl_index;
  123. u8 reserved;
  124. };
  125. /* SCSI terminate connection params */
  126. struct scsi_terminate_extra_params {
  127. __le16 unsolicited_cq_count;
  128. __le16 cmdq_count;
  129. u8 reserved[4];
  130. };
  131. /* SCSI Task Queue Element */
  132. struct scsi_tqe {
  133. __le16 itid;
  134. };
  135. #endif /* __STORAGE_COMMON__ */