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.3KB

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