You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

linda.h 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. #ifndef _LINDA_H
  2. #define _LINDA_H
  3. /*
  4. * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of the
  9. * License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. */
  21. FILE_LICENCE ( GPL2_OR_LATER );
  22. /**
  23. * @file
  24. *
  25. * QLogic Linda Infiniband HCA
  26. *
  27. */
  28. #define BITOPS_LITTLE_ENDIAN
  29. #include <ipxe/bitops.h>
  30. #include "qib_7220_regs.h"
  31. struct ib_device;
  32. /** A Linda GPIO register */
  33. struct QIB_7220_GPIO_pb {
  34. pseudo_bit_t GPIO[16];
  35. pseudo_bit_t Reserved[48];
  36. };
  37. struct QIB_7220_GPIO {
  38. PSEUDO_BIT_STRUCT ( struct QIB_7220_GPIO_pb );
  39. };
  40. /** A Linda general scalar register */
  41. struct QIB_7220_scalar_pb {
  42. pseudo_bit_t Value[64];
  43. };
  44. struct QIB_7220_scalar {
  45. PSEUDO_BIT_STRUCT ( struct QIB_7220_scalar_pb );
  46. };
  47. /** Linda send per-buffer control word */
  48. struct QIB_7220_SendPbc_pb {
  49. pseudo_bit_t LengthP1_toibc[11];
  50. pseudo_bit_t Reserved1[4];
  51. pseudo_bit_t LengthP1_trigger[11];
  52. pseudo_bit_t Reserved2[3];
  53. pseudo_bit_t TestEbp[1];
  54. pseudo_bit_t Test[1];
  55. pseudo_bit_t Intr[1];
  56. pseudo_bit_t Reserved3[31];
  57. pseudo_bit_t VL15[1];
  58. };
  59. struct QIB_7220_SendPbc {
  60. PSEUDO_BIT_STRUCT ( struct QIB_7220_SendPbc_pb );
  61. };
  62. /** Linda send buffer availability */
  63. struct QIB_7220_SendBufAvail_pb {
  64. pseudo_bit_t InUseCheck[144][2];
  65. pseudo_bit_t Reserved[32];
  66. };
  67. struct QIB_7220_SendBufAvail {
  68. PSEUDO_BIT_STRUCT ( struct QIB_7220_SendBufAvail_pb );
  69. };
  70. /** DMA alignment for send buffer availability */
  71. #define LINDA_SENDBUFAVAIL_ALIGN 64
  72. /** A Linda eager receive descriptor */
  73. struct QIB_7220_RcvEgr_pb {
  74. pseudo_bit_t Addr[37];
  75. pseudo_bit_t BufSize[3];
  76. pseudo_bit_t Reserved[24];
  77. };
  78. struct QIB_7220_RcvEgr {
  79. PSEUDO_BIT_STRUCT ( struct QIB_7220_RcvEgr_pb );
  80. };
  81. /** Linda receive header flags */
  82. struct QIB_7220_RcvHdrFlags_pb {
  83. pseudo_bit_t PktLen[11];
  84. pseudo_bit_t RcvType[3];
  85. pseudo_bit_t SoftB[1];
  86. pseudo_bit_t SoftA[1];
  87. pseudo_bit_t EgrIndex[12];
  88. pseudo_bit_t Reserved1[3];
  89. pseudo_bit_t UseEgrBfr[1];
  90. pseudo_bit_t RcvSeq[4];
  91. pseudo_bit_t HdrqOffset[11];
  92. pseudo_bit_t Reserved2[8];
  93. pseudo_bit_t IBErr[1];
  94. pseudo_bit_t MKErr[1];
  95. pseudo_bit_t TIDErr[1];
  96. pseudo_bit_t KHdrErr[1];
  97. pseudo_bit_t MTUErr[1];
  98. pseudo_bit_t LenErr[1];
  99. pseudo_bit_t ParityErr[1];
  100. pseudo_bit_t VCRCErr[1];
  101. pseudo_bit_t ICRCErr[1];
  102. };
  103. struct QIB_7220_RcvHdrFlags {
  104. PSEUDO_BIT_STRUCT ( struct QIB_7220_RcvHdrFlags_pb );
  105. };
  106. /** Linda memory BAR size */
  107. #define LINDA_BAR0_SIZE 0x400000
  108. /** Linda I2C SCL line GPIO number */
  109. #define LINDA_GPIO_SCL 0
  110. /** Linda I2C SDA line GPIO number */
  111. #define LINDA_GPIO_SDA 1
  112. /** GUID offset within EEPROM */
  113. #define LINDA_EEPROM_GUID_OFFSET 3
  114. /** GUID size within EEPROM */
  115. #define LINDA_EEPROM_GUID_SIZE 8
  116. /** Board serial number offset within EEPROM */
  117. #define LINDA_EEPROM_SERIAL_OFFSET 12
  118. /** Board serial number size within EEPROM */
  119. #define LINDA_EEPROM_SERIAL_SIZE 12
  120. /** Maximum number of send buffers used
  121. *
  122. * This is a policy decision. Must be less than or equal to the total
  123. * number of send buffers supported by the hardware (128).
  124. */
  125. #define LINDA_MAX_SEND_BUFS 32
  126. /** Linda send buffer size */
  127. #define LINDA_SEND_BUF_SIZE 4096
  128. /** Number of contexts (including kernel context)
  129. *
  130. * This is a policy decision. Must be 5, 9 or 17.
  131. */
  132. #define LINDA_NUM_CONTEXTS 5
  133. /** PortCfg values for different numbers of contexts */
  134. enum linda_portcfg {
  135. LINDA_PORTCFG_5CTX = 0,
  136. LINDA_PORTCFG_9CTX = 1,
  137. LINDA_PORTCFG_17CTX = 2,
  138. };
  139. /** PortCfg values for different numbers of contexts */
  140. #define LINDA_EAGER_ARRAY_SIZE_5CTX_0 2048
  141. #define LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER 4096
  142. #define LINDA_EAGER_ARRAY_SIZE_9CTX_0 2048
  143. #define LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER 2048
  144. #define LINDA_EAGER_ARRAY_SIZE_17CTX_0 2048
  145. #define LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER 1024
  146. /** Eager buffer required alignment */
  147. #define LINDA_EAGER_BUFFER_ALIGN 2048
  148. /** Eager buffer size encodings */
  149. enum linda_eager_buffer_size {
  150. LINDA_EAGER_BUFFER_NONE = 0,
  151. LINDA_EAGER_BUFFER_2K = 1,
  152. LINDA_EAGER_BUFFER_4K = 2,
  153. LINDA_EAGER_BUFFER_8K = 3,
  154. LINDA_EAGER_BUFFER_16K = 4,
  155. LINDA_EAGER_BUFFER_32K = 5,
  156. LINDA_EAGER_BUFFER_64K = 6,
  157. };
  158. /** Number of RX headers per context
  159. *
  160. * This is a policy decision.
  161. */
  162. #define LINDA_RECV_HEADER_COUNT 8
  163. /** Maximum size of each RX header
  164. *
  165. * This is a policy decision. Must be divisible by 4.
  166. */
  167. #define LINDA_RECV_HEADER_SIZE 96
  168. /** Total size of an RX header ring */
  169. #define LINDA_RECV_HEADERS_SIZE \
  170. ( LINDA_RECV_HEADER_SIZE * LINDA_RECV_HEADER_COUNT )
  171. /** RX header alignment */
  172. #define LINDA_RECV_HEADERS_ALIGN 64
  173. /** RX payload size
  174. *
  175. * This is a policy decision. Must be a valid eager buffer size.
  176. */
  177. #define LINDA_RECV_PAYLOAD_SIZE 2048
  178. /** QPN used for Infinipath Packets
  179. *
  180. * This is a policy decision. Must have bit 0 clear. Must not be a
  181. * QPN that we will use.
  182. */
  183. #define LINDA_QP_IDETH 0xdead0
  184. /** Maximum time for wait for external parallel bus request, in us */
  185. #define LINDA_EPB_REQUEST_MAX_WAIT_US 500
  186. /** Maximum time for wait for external parallel bus transaction, in us */
  187. #define LINDA_EPB_XACT_MAX_WAIT_US 500
  188. /** Linda external parallel bus chip selects */
  189. #define LINDA_EPB_CS_SERDES 1
  190. #define LINDA_EPB_CS_UC 2
  191. /** Linda external parallel bus read/write operations */
  192. #define LINDA_EPB_WRITE 0
  193. #define LINDA_EPB_READ 1
  194. /** Linda external parallel bus register addresses */
  195. #define LINDA_EPB_ADDRESS( _channel, _element, _reg ) \
  196. ( (_element) | ( (_channel) << 4 ) | ( (_reg) << 9 ) )
  197. #define LINDA_EPB_ADDRESS_CHANNEL( _address ) ( ( (_address) >> 4 ) & 0x1f )
  198. #define LINDA_EPB_ADDRESS_ELEMENT( _address ) ( ( (_address) >> 0 ) & 0x0f )
  199. #define LINDA_EPB_ADDRESS_REG( _address ) ( ( (_address) >> 9 ) & 0x3f )
  200. /** Linda external parallel bus locations
  201. *
  202. * The location is used by the driver to encode both the chip select
  203. * and the EPB address.
  204. */
  205. #define LINDA_EPB_LOC( _cs, _channel, _element, _reg) \
  206. ( ( (_cs) << 16 ) | LINDA_EPB_ADDRESS ( _channel, _element, _reg ) )
  207. #define LINDA_EPB_LOC_ADDRESS( _loc ) ( (_loc) & 0xffff )
  208. #define LINDA_EPB_LOC_CS( _loc ) ( (_loc) >> 16 )
  209. /** Linda external parallel bus microcontroller register addresses */
  210. #define LINDA_EPB_UC_CHANNEL 6
  211. #define LINDA_EPB_UC_LOC( _reg ) \
  212. LINDA_EPB_LOC ( LINDA_EPB_CS_UC, LINDA_EPB_UC_CHANNEL, 0, (_reg) )
  213. #define LINDA_EPB_UC_CTL LINDA_EPB_UC_LOC ( 0 )
  214. #define LINDA_EPB_UC_CTL_WRITE 1
  215. #define LINDA_EPB_UC_CTL_READ 2
  216. #define LINDA_EPB_UC_ADDR_LO LINDA_EPB_UC_LOC ( 2 )
  217. #define LINDA_EPB_UC_ADDR_HI LINDA_EPB_UC_LOC ( 3 )
  218. #define LINDA_EPB_UC_DATA LINDA_EPB_UC_LOC ( 4 )
  219. #define LINDA_EPB_UC_CHUNK_SIZE 64
  220. extern uint8_t linda_ib_fw[8192];
  221. /** Maximum time to wait for "trim done" signal, in ms */
  222. #define LINDA_TRIM_DONE_MAX_WAIT_MS 1000
  223. /** Linda link states */
  224. enum linda_link_state {
  225. LINDA_LINK_STATE_DOWN = 0,
  226. LINDA_LINK_STATE_INIT = 1,
  227. LINDA_LINK_STATE_ARM = 2,
  228. LINDA_LINK_STATE_ACTIVE = 3,
  229. LINDA_LINK_STATE_ACT_DEFER = 4,
  230. };
  231. /** Maximum time to wait for link state changes, in us */
  232. #define LINDA_LINK_STATE_MAX_WAIT_US 20
  233. #endif /* _LINDA_H */