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.

qib7322.h 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. #ifndef _QIB7322_H
  2. #define _QIB7322_H
  3. /*
  4. * Copyright (C) 2009 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 QIB7322 Infiniband HCA
  26. *
  27. */
  28. #define BITOPS_LITTLE_ENDIAN
  29. #include <ipxe/bitops.h>
  30. #include "qib_7322_regs.h"
  31. /** A QIB7322 GPIO register */
  32. struct QIB_7322_GPIO_pb {
  33. pseudo_bit_t GPIO[16];
  34. pseudo_bit_t Reserved[48];
  35. };
  36. struct QIB_7322_GPIO {
  37. PSEUDO_BIT_STRUCT ( struct QIB_7322_GPIO_pb );
  38. };
  39. /** A QIB7322 general scalar register */
  40. struct QIB_7322_scalar_pb {
  41. pseudo_bit_t Value[64];
  42. };
  43. struct QIB_7322_scalar {
  44. PSEUDO_BIT_STRUCT ( struct QIB_7322_scalar_pb );
  45. };
  46. /** QIB7322 feature mask */
  47. struct QIB_7322_feature_mask_pb {
  48. pseudo_bit_t Port0_Link_Speed_Supported[3];
  49. pseudo_bit_t Port1_Link_Speed_Supported[3];
  50. pseudo_bit_t _unused_0[58];
  51. };
  52. struct QIB_7322_feature_mask {
  53. PSEUDO_BIT_STRUCT ( struct QIB_7322_feature_mask_pb );
  54. };
  55. /** QIB7322 send per-buffer control word */
  56. struct QIB_7322_SendPbc_pb {
  57. pseudo_bit_t LengthP1_toibc[11];
  58. pseudo_bit_t Reserved1[4];
  59. pseudo_bit_t LengthP1_trigger[11];
  60. pseudo_bit_t Reserved2[3];
  61. pseudo_bit_t TestEbp[1];
  62. pseudo_bit_t Test[1];
  63. pseudo_bit_t Intr[1];
  64. pseudo_bit_t StaticRateControlCnt[14];
  65. pseudo_bit_t Reserved3[12];
  66. pseudo_bit_t Port[1];
  67. pseudo_bit_t VLane[3];
  68. pseudo_bit_t Reserved4[1];
  69. pseudo_bit_t VL15[1];
  70. };
  71. struct QIB_7322_SendPbc {
  72. PSEUDO_BIT_STRUCT ( struct QIB_7322_SendPbc_pb );
  73. };
  74. /** QIB7322 send buffer availability */
  75. struct QIB_7322_SendBufAvail_pb {
  76. pseudo_bit_t InUseCheck[162][2];
  77. pseudo_bit_t Reserved[60];
  78. };
  79. struct QIB_7322_SendBufAvail {
  80. PSEUDO_BIT_STRUCT ( struct QIB_7322_SendBufAvail_pb );
  81. };
  82. /** DMA alignment for send buffer availability */
  83. #define QIB7322_SENDBUFAVAIL_ALIGN 64
  84. /** QIB7322 port-specific receive control */
  85. struct QIB_7322_RcvCtrl_P_pb {
  86. pseudo_bit_t ContextEnable[18];
  87. pseudo_bit_t _unused_1[21];
  88. pseudo_bit_t RcvIBPortEnable[1];
  89. pseudo_bit_t RcvQPMapEnable[1];
  90. pseudo_bit_t RcvPartitionKeyDisable[1];
  91. pseudo_bit_t RcvResetCredit[1];
  92. pseudo_bit_t _unused_2[21];
  93. };
  94. struct QIB_7322_RcvCtrl_P {
  95. PSEUDO_BIT_STRUCT ( struct QIB_7322_RcvCtrl_P_pb );
  96. };
  97. /** A QIB7322 eager receive descriptor */
  98. struct QIB_7322_RcvEgr_pb {
  99. pseudo_bit_t Addr[37];
  100. pseudo_bit_t BufSize[3];
  101. pseudo_bit_t Reserved[24];
  102. };
  103. struct QIB_7322_RcvEgr {
  104. PSEUDO_BIT_STRUCT ( struct QIB_7322_RcvEgr_pb );
  105. };
  106. /** QIB7322 receive header flags */
  107. struct QIB_7322_RcvHdrFlags_pb {
  108. pseudo_bit_t PktLen[11];
  109. pseudo_bit_t RcvType[3];
  110. pseudo_bit_t SoftB[1];
  111. pseudo_bit_t SoftA[1];
  112. pseudo_bit_t EgrIndex[12];
  113. pseudo_bit_t Reserved1[3];
  114. pseudo_bit_t UseEgrBfr[1];
  115. pseudo_bit_t RcvSeq[4];
  116. pseudo_bit_t HdrqOffset[11];
  117. pseudo_bit_t Reserved2[8];
  118. pseudo_bit_t IBErr[1];
  119. pseudo_bit_t MKErr[1];
  120. pseudo_bit_t TIDErr[1];
  121. pseudo_bit_t KHdrErr[1];
  122. pseudo_bit_t MTUErr[1];
  123. pseudo_bit_t LenErr[1];
  124. pseudo_bit_t ParityErr[1];
  125. pseudo_bit_t VCRCErr[1];
  126. pseudo_bit_t ICRCErr[1];
  127. };
  128. struct QIB_7322_RcvHdrFlags {
  129. PSEUDO_BIT_STRUCT ( struct QIB_7322_RcvHdrFlags_pb );
  130. };
  131. /** QIB7322 DDS tuning parameters */
  132. struct QIB_7322_IBSD_DDS_MAP_TABLE_pb {
  133. pseudo_bit_t Pre[3];
  134. pseudo_bit_t PreXtra[2];
  135. pseudo_bit_t Post[4];
  136. pseudo_bit_t Main[5];
  137. pseudo_bit_t Amp[4];
  138. pseudo_bit_t _unused_0[46];
  139. };
  140. struct QIB_7322_IBSD_DDS_MAP_TABLE {
  141. PSEUDO_BIT_STRUCT ( struct QIB_7322_IBSD_DDS_MAP_TABLE_pb );
  142. };
  143. /** QIB7322 memory BAR size */
  144. #define QIB7322_BAR0_SIZE 0x400000
  145. /** QIB7322 base port number */
  146. #define QIB7322_PORT_BASE 1
  147. /** QIB7322 maximum number of ports */
  148. #define QIB7322_MAX_PORTS 2
  149. /** QIB7322 maximum width */
  150. #define QIB7322_MAX_WIDTH 4
  151. /** QIB7322 board identifiers */
  152. enum qib7322_board_id {
  153. QIB7322_BOARD_QLE7342_EMULATION = 0,
  154. QIB7322_BOARD_QLE7340 = 1,
  155. QIB7322_BOARD_QLE7342 = 2,
  156. QIB7322_BOARD_QMI7342 = 3,
  157. QIB7322_BOARD_QMH7342_UNSUPPORTED = 4,
  158. QIB7322_BOARD_QME7342 = 5,
  159. QIB7322_BOARD_QMH7342 = 6,
  160. QIB7322_BOARD_QLE7342_TEST = 15,
  161. };
  162. /** QIB7322 I2C SCL line GPIO number */
  163. #define QIB7322_GPIO_SCL 0
  164. /** QIB7322 I2C SDA line GPIO number */
  165. #define QIB7322_GPIO_SDA 1
  166. /** GUID offset within EEPROM */
  167. #define QIB7322_EEPROM_GUID_OFFSET 3
  168. /** GUID size within EEPROM */
  169. #define QIB7322_EEPROM_GUID_SIZE 8
  170. /** Board serial number offset within EEPROM */
  171. #define QIB7322_EEPROM_SERIAL_OFFSET 12
  172. /** Board serial number size within EEPROM */
  173. #define QIB7322_EEPROM_SERIAL_SIZE 12
  174. /** QIB7322 small send buffer size */
  175. #define QIB7322_SMALL_SEND_BUF_SIZE 4096
  176. /** QIB7322 small send buffer starting index */
  177. #define QIB7322_SMALL_SEND_BUF_START 0
  178. /** QIB7322 small send buffer count */
  179. #define QIB7322_SMALL_SEND_BUF_COUNT 128
  180. /** QIB7322 large send buffer size */
  181. #define QIB7322_LARGE_SEND_BUF_SIZE 8192
  182. /** QIB7322 large send buffer starting index */
  183. #define QIB7322_LARGE_SEND_BUF_START 128
  184. /** QIB7322 large send buffer count */
  185. #define QIB7322_LARGE_SEND_BUF_COUNT 32
  186. /** QIB7322 VL15 port 0 send buffer starting index */
  187. #define QIB7322_VL15_PORT0_SEND_BUF_START 160
  188. /** QIB7322 VL15 port 0 send buffer count */
  189. #define QIB7322_VL15_PORT0_SEND_BUF_COUNT 1
  190. /** QIB7322 VL15 port 0 send buffer size */
  191. #define QIB7322_VL15_PORT0_SEND_BUF_SIZE 8192
  192. /** QIB7322 VL15 port 0 send buffer starting index */
  193. #define QIB7322_VL15_PORT1_SEND_BUF_START 161
  194. /** QIB7322 VL15 port 0 send buffer count */
  195. #define QIB7322_VL15_PORT1_SEND_BUF_COUNT 1
  196. /** QIB7322 VL15 port 0 send buffer size */
  197. #define QIB7322_VL15_PORT1_SEND_BUF_SIZE 8192
  198. /** Number of small send buffers used
  199. *
  200. * This is a policy decision. Must be less than or equal to the total
  201. * number of small send buffers supported by the hardware
  202. * (QIB7322_SMALL_SEND_BUF_COUNT).
  203. */
  204. #define QIB7322_SMALL_SEND_BUF_USED 32
  205. /** Number of contexts (including kernel context)
  206. *
  207. * This is a policy decision. Must be 6, 10 or 18.
  208. */
  209. #define QIB7322_NUM_CONTEXTS 6
  210. /** ContextCfg values for different numbers of contexts */
  211. enum qib7322_contextcfg {
  212. QIB7322_CONTEXTCFG_6CTX = 0,
  213. QIB7322_CONTEXTCFG_10CTX = 1,
  214. QIB7322_CONTEXTCFG_18CTX = 2,
  215. };
  216. /** ContextCfg values for different numbers of contexts */
  217. #define QIB7322_EAGER_ARRAY_SIZE_6CTX_KERNEL 1024
  218. #define QIB7322_EAGER_ARRAY_SIZE_6CTX_USER 4096
  219. #define QIB7322_EAGER_ARRAY_SIZE_10CTX_KERNEL 1024
  220. #define QIB7322_EAGER_ARRAY_SIZE_10CTX_USER 2048
  221. #define QIB7322_EAGER_ARRAY_SIZE_18CTX_KERNEL 1024
  222. #define QIB7322_EAGER_ARRAY_SIZE_18CTX_USER 1024
  223. /** Eager buffer required alignment */
  224. #define QIB7322_EAGER_BUFFER_ALIGN 2048
  225. /** Eager buffer size encodings */
  226. enum qib7322_eager_buffer_size {
  227. QIB7322_EAGER_BUFFER_NONE = 0,
  228. QIB7322_EAGER_BUFFER_2K = 1,
  229. QIB7322_EAGER_BUFFER_4K = 2,
  230. QIB7322_EAGER_BUFFER_8K = 3,
  231. QIB7322_EAGER_BUFFER_16K = 4,
  232. QIB7322_EAGER_BUFFER_32K = 5,
  233. QIB7322_EAGER_BUFFER_64K = 6,
  234. };
  235. /** Number of RX headers per context
  236. *
  237. * This is a policy decision.
  238. */
  239. #define QIB7322_RECV_HEADER_COUNT 8
  240. /** Maximum size of each RX header
  241. *
  242. * This is a policy decision. Must be divisible by 4.
  243. */
  244. #define QIB7322_RECV_HEADER_SIZE 96
  245. /** Total size of an RX header ring */
  246. #define QIB7322_RECV_HEADERS_SIZE \
  247. ( QIB7322_RECV_HEADER_SIZE * QIB7322_RECV_HEADER_COUNT )
  248. /** RX header alignment */
  249. #define QIB7322_RECV_HEADERS_ALIGN 64
  250. /** RX payload size
  251. *
  252. * This is a policy decision. Must be a valid eager buffer size.
  253. */
  254. #define QIB7322_RECV_PAYLOAD_SIZE 2048
  255. /** Maximum number of credits per port
  256. *
  257. * 64kB of internal RX buffer space, in units of 64 bytes, split
  258. * between two ports.
  259. */
  260. #define QIB7322_MAX_CREDITS ( ( 65536 / 64 ) / QIB7322_MAX_PORTS )
  261. /** Number of credits to advertise for VL15
  262. *
  263. * This is a policy decision. Using 9 credits allows for 9*64=576
  264. * bytes, which is enough for two MADs.
  265. */
  266. #define QIB7322_MAX_CREDITS_VL15 9
  267. /** Number of credits to advertise for VL0
  268. *
  269. * This is a policy decision.
  270. */
  271. #define QIB7322_MAX_CREDITS_VL0 \
  272. ( QIB7322_MAX_CREDITS - QIB7322_MAX_CREDITS_VL15 )
  273. /** QPN used for Infinipath Packets
  274. *
  275. * This is a policy decision. Must have bit 0 clear. Must not be a
  276. * QPN that we will use.
  277. */
  278. #define QIB7322_QP_IDETH 0xdead0
  279. /** Maximum time for wait for AHB, in us */
  280. #define QIB7322_AHB_MAX_WAIT_US 500
  281. /** QIB7322 AHB locations */
  282. #define QIB7322_AHB_LOC_ADDRESS( _location ) ( (_location) & 0xffff )
  283. #define QIB7322_AHB_LOC_TARGET( _location ) ( (_location) >> 16 )
  284. #define QIB7322_AHB_CHAN_0 0
  285. #define QIB7322_AHB_CHAN_1 1
  286. #define QIB7322_AHB_PLL 2
  287. #define QIB7322_AHB_CHAN_2 3
  288. #define QIB7322_AHB_CHAN_3 4
  289. #define QIB7322_AHB_SUBSYS 5
  290. #define QIB7322_AHB_CHAN( _channel ) ( (_channel) + ( (_channel) >> 1 ) )
  291. #define QIB7322_AHB_TARGET_0 2
  292. #define QIB7322_AHB_TARGET_1 3
  293. #define QIB7322_AHB_TARGET( _port ) ( (_port) + 2 )
  294. #define QIB7322_AHB_LOCATION( _port, _channel, _register ) \
  295. ( ( QIB7322_AHB_TARGET(_port) << 16 ) | \
  296. ( QIB7322_AHB_CHAN(_channel) << 7 ) | \
  297. ( (_register) << 1 ) )
  298. /** QIB7322 link states */
  299. enum qib7322_link_state {
  300. QIB7322_LINK_STATE_DOWN = 0,
  301. QIB7322_LINK_STATE_INIT = 1,
  302. QIB7322_LINK_STATE_ARM = 2,
  303. QIB7322_LINK_STATE_ACTIVE = 3,
  304. QIB7322_LINK_STATE_ACT_DEFER = 4,
  305. };
  306. /** Maximum time to wait for link state changes, in us */
  307. #define QIB7322_LINK_STATE_MAX_WAIT_US 20
  308. #endif /* _QIB7322_H */