mthca_cmd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /*
  2. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
  3. * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2006 Cisco Systems. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #ifndef MTHCA_CMD_H
  35. #define MTHCA_CMD_H
  36. #include <rdma/ib_verbs.h>
  37. #define MTHCA_MAILBOX_SIZE 4096
  38. enum {
  39. /* command completed successfully: */
  40. MTHCA_CMD_STAT_OK = 0x00,
  41. /* Internal error (such as a bus error) occurred while processing command: */
  42. MTHCA_CMD_STAT_INTERNAL_ERR = 0x01,
  43. /* Operation/command not supported or opcode modifier not supported: */
  44. MTHCA_CMD_STAT_BAD_OP = 0x02,
  45. /* Parameter not supported or parameter out of range: */
  46. MTHCA_CMD_STAT_BAD_PARAM = 0x03,
  47. /* System not enabled or bad system state: */
  48. MTHCA_CMD_STAT_BAD_SYS_STATE = 0x04,
  49. /* Attempt to access reserved or unallocaterd resource: */
  50. MTHCA_CMD_STAT_BAD_RESOURCE = 0x05,
  51. /* Requested resource is currently executing a command, or is otherwise busy: */
  52. MTHCA_CMD_STAT_RESOURCE_BUSY = 0x06,
  53. /* memory error: */
  54. MTHCA_CMD_STAT_DDR_MEM_ERR = 0x07,
  55. /* Required capability exceeds device limits: */
  56. MTHCA_CMD_STAT_EXCEED_LIM = 0x08,
  57. /* Resource is not in the appropriate state or ownership: */
  58. MTHCA_CMD_STAT_BAD_RES_STATE = 0x09,
  59. /* Index out of range: */
  60. MTHCA_CMD_STAT_BAD_INDEX = 0x0a,
  61. /* FW image corrupted: */
  62. MTHCA_CMD_STAT_BAD_NVMEM = 0x0b,
  63. /* Attempt to modify a QP/EE which is not in the presumed state: */
  64. MTHCA_CMD_STAT_BAD_QPEE_STATE = 0x10,
  65. /* Bad segment parameters (Address/Size): */
  66. MTHCA_CMD_STAT_BAD_SEG_PARAM = 0x20,
  67. /* Memory Region has Memory Windows bound to: */
  68. MTHCA_CMD_STAT_REG_BOUND = 0x21,
  69. /* HCA local attached memory not present: */
  70. MTHCA_CMD_STAT_LAM_NOT_PRE = 0x22,
  71. /* Bad management packet (silently discarded): */
  72. MTHCA_CMD_STAT_BAD_PKT = 0x30,
  73. /* More outstanding CQEs in CQ than new CQ size: */
  74. MTHCA_CMD_STAT_BAD_SIZE = 0x40
  75. };
  76. enum {
  77. MTHCA_TRANS_INVALID = 0,
  78. MTHCA_TRANS_RST2INIT,
  79. MTHCA_TRANS_INIT2INIT,
  80. MTHCA_TRANS_INIT2RTR,
  81. MTHCA_TRANS_RTR2RTS,
  82. MTHCA_TRANS_RTS2RTS,
  83. MTHCA_TRANS_SQERR2RTS,
  84. MTHCA_TRANS_ANY2ERR,
  85. MTHCA_TRANS_RTS2SQD,
  86. MTHCA_TRANS_SQD2SQD,
  87. MTHCA_TRANS_SQD2RTS,
  88. MTHCA_TRANS_ANY2RST,
  89. };
  90. enum {
  91. DEV_LIM_FLAG_RC = 1 << 0,
  92. DEV_LIM_FLAG_UC = 1 << 1,
  93. DEV_LIM_FLAG_UD = 1 << 2,
  94. DEV_LIM_FLAG_RD = 1 << 3,
  95. DEV_LIM_FLAG_RAW_IPV6 = 1 << 4,
  96. DEV_LIM_FLAG_RAW_ETHER = 1 << 5,
  97. DEV_LIM_FLAG_SRQ = 1 << 6,
  98. DEV_LIM_FLAG_IPOIB_CSUM = 1 << 7,
  99. DEV_LIM_FLAG_BAD_PKEY_CNTR = 1 << 8,
  100. DEV_LIM_FLAG_BAD_QKEY_CNTR = 1 << 9,
  101. DEV_LIM_FLAG_MW = 1 << 16,
  102. DEV_LIM_FLAG_AUTO_PATH_MIG = 1 << 17,
  103. DEV_LIM_FLAG_ATOMIC = 1 << 18,
  104. DEV_LIM_FLAG_RAW_MULTI = 1 << 19,
  105. DEV_LIM_FLAG_UD_AV_PORT_ENFORCE = 1 << 20,
  106. DEV_LIM_FLAG_UD_MULTI = 1 << 21,
  107. };
  108. struct mthca_mailbox {
  109. dma_addr_t dma;
  110. void *buf;
  111. };
  112. struct mthca_dev_lim {
  113. int max_srq_sz;
  114. int max_qp_sz;
  115. int reserved_qps;
  116. int max_qps;
  117. int reserved_srqs;
  118. int max_srqs;
  119. int reserved_eecs;
  120. int max_eecs;
  121. int max_cq_sz;
  122. int reserved_cqs;
  123. int max_cqs;
  124. int max_mpts;
  125. int reserved_eqs;
  126. int max_eqs;
  127. int reserved_mtts;
  128. int max_mrw_sz;
  129. int reserved_mrws;
  130. int max_mtt_seg;
  131. int max_requester_per_qp;
  132. int max_responder_per_qp;
  133. int max_rdma_global;
  134. int local_ca_ack_delay;
  135. int max_mtu;
  136. int max_port_width;
  137. int max_vl;
  138. int num_ports;
  139. int max_gids;
  140. u16 stat_rate_support;
  141. int max_pkeys;
  142. u32 flags;
  143. int reserved_uars;
  144. int uar_size;
  145. int min_page_sz;
  146. int max_sg;
  147. int max_desc_sz;
  148. int max_qp_per_mcg;
  149. int reserved_mgms;
  150. int max_mcgs;
  151. int reserved_pds;
  152. int max_pds;
  153. int reserved_rdds;
  154. int max_rdds;
  155. int eec_entry_sz;
  156. int qpc_entry_sz;
  157. int eeec_entry_sz;
  158. int eqpc_entry_sz;
  159. int eqc_entry_sz;
  160. int cqc_entry_sz;
  161. int srq_entry_sz;
  162. int uar_scratch_entry_sz;
  163. int mpt_entry_sz;
  164. union {
  165. struct {
  166. int max_avs;
  167. } tavor;
  168. struct {
  169. int resize_srq;
  170. int max_pbl_sz;
  171. u8 bmme_flags;
  172. u32 reserved_lkey;
  173. int lam_required;
  174. u64 max_icm_sz;
  175. } arbel;
  176. } hca;
  177. };
  178. struct mthca_adapter {
  179. u32 vendor_id;
  180. u32 device_id;
  181. u32 revision_id;
  182. char board_id[MTHCA_BOARD_ID_LEN];
  183. u8 inta_pin;
  184. };
  185. struct mthca_init_hca_param {
  186. u64 qpc_base;
  187. u64 eec_base;
  188. u64 srqc_base;
  189. u64 cqc_base;
  190. u64 eqpc_base;
  191. u64 eeec_base;
  192. u64 eqc_base;
  193. u64 rdb_base;
  194. u64 mc_base;
  195. u64 mpt_base;
  196. u64 mtt_base;
  197. u64 uar_scratch_base;
  198. u64 uarc_base;
  199. u16 log_mc_entry_sz;
  200. u16 mc_hash_sz;
  201. u8 log_num_qps;
  202. u8 log_num_eecs;
  203. u8 log_num_srqs;
  204. u8 log_num_cqs;
  205. u8 log_num_eqs;
  206. u8 log_mc_table_sz;
  207. u8 mtt_seg_sz;
  208. u8 log_mpt_sz;
  209. u8 log_uar_sz;
  210. u8 log_uarc_sz;
  211. };
  212. struct mthca_init_ib_param {
  213. int port_width;
  214. int vl_cap;
  215. int mtu_cap;
  216. u16 gid_cap;
  217. u16 pkey_cap;
  218. int set_guid0;
  219. u64 guid0;
  220. int set_node_guid;
  221. u64 node_guid;
  222. int set_si_guid;
  223. u64 si_guid;
  224. };
  225. struct mthca_set_ib_param {
  226. int set_si_guid;
  227. int reset_qkey_viol;
  228. u64 si_guid;
  229. u32 cap_mask;
  230. };
  231. int mthca_cmd_init(struct mthca_dev *dev);
  232. void mthca_cmd_cleanup(struct mthca_dev *dev);
  233. int mthca_cmd_use_events(struct mthca_dev *dev);
  234. void mthca_cmd_use_polling(struct mthca_dev *dev);
  235. void mthca_cmd_event(struct mthca_dev *dev, u16 token,
  236. u8 status, u64 out_param);
  237. struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
  238. gfp_t gfp_mask);
  239. void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox);
  240. int mthca_SYS_EN(struct mthca_dev *dev);
  241. int mthca_SYS_DIS(struct mthca_dev *dev);
  242. int mthca_MAP_FA(struct mthca_dev *dev, struct mthca_icm *icm);
  243. int mthca_UNMAP_FA(struct mthca_dev *dev);
  244. int mthca_RUN_FW(struct mthca_dev *dev);
  245. int mthca_QUERY_FW(struct mthca_dev *dev);
  246. int mthca_ENABLE_LAM(struct mthca_dev *dev);
  247. int mthca_DISABLE_LAM(struct mthca_dev *dev);
  248. int mthca_QUERY_DDR(struct mthca_dev *dev);
  249. int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
  250. struct mthca_dev_lim *dev_lim);
  251. int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
  252. struct mthca_adapter *adapter);
  253. int mthca_INIT_HCA(struct mthca_dev *dev,
  254. struct mthca_init_hca_param *param);
  255. int mthca_INIT_IB(struct mthca_dev *dev,
  256. struct mthca_init_ib_param *param,
  257. int port);
  258. int mthca_CLOSE_IB(struct mthca_dev *dev, int port);
  259. int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic);
  260. int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
  261. int port);
  262. int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt);
  263. int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt);
  264. int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count);
  265. int mthca_MAP_ICM_AUX(struct mthca_dev *dev, struct mthca_icm *icm);
  266. int mthca_UNMAP_ICM_AUX(struct mthca_dev *dev);
  267. int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages);
  268. int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  269. int mpt_index);
  270. int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  271. int mpt_index);
  272. int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  273. int num_mtt);
  274. int mthca_SYNC_TPT(struct mthca_dev *dev);
  275. int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
  276. int eq_num);
  277. int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  278. int eq_num);
  279. int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  280. int eq_num);
  281. int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  282. int cq_num);
  283. int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  284. int cq_num);
  285. int mthca_RESIZE_CQ(struct mthca_dev *dev, int cq_num, u32 lkey, u8 log_size);
  286. int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  287. int srq_num);
  288. int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  289. int srq_num);
  290. int mthca_QUERY_SRQ(struct mthca_dev *dev, u32 num,
  291. struct mthca_mailbox *mailbox);
  292. int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit);
  293. int mthca_MODIFY_QP(struct mthca_dev *dev, enum ib_qp_state cur,
  294. enum ib_qp_state next, u32 num, int is_ee,
  295. struct mthca_mailbox *mailbox, u32 optmask);
  296. int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
  297. struct mthca_mailbox *mailbox);
  298. int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn);
  299. int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
  300. int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
  301. void *in_mad, void *response_mad);
  302. int mthca_READ_MGM(struct mthca_dev *dev, int index,
  303. struct mthca_mailbox *mailbox);
  304. int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
  305. struct mthca_mailbox *mailbox);
  306. int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
  307. u16 *hash);
  308. int mthca_NOP(struct mthca_dev *dev);
  309. #endif /* MTHCA_CMD_H */