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

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