qp.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef MLX5_QP_H
  33. #define MLX5_QP_H
  34. #include <linux/mlx5/device.h>
  35. #include <linux/mlx5/driver.h>
  36. #define MLX5_INVALID_LKEY 0x100
  37. enum mlx5_qp_optpar {
  38. MLX5_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0,
  39. MLX5_QP_OPTPAR_RRE = 1 << 1,
  40. MLX5_QP_OPTPAR_RAE = 1 << 2,
  41. MLX5_QP_OPTPAR_RWE = 1 << 3,
  42. MLX5_QP_OPTPAR_PKEY_INDEX = 1 << 4,
  43. MLX5_QP_OPTPAR_Q_KEY = 1 << 5,
  44. MLX5_QP_OPTPAR_RNR_TIMEOUT = 1 << 6,
  45. MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7,
  46. MLX5_QP_OPTPAR_SRA_MAX = 1 << 8,
  47. MLX5_QP_OPTPAR_RRA_MAX = 1 << 9,
  48. MLX5_QP_OPTPAR_PM_STATE = 1 << 10,
  49. MLX5_QP_OPTPAR_RETRY_COUNT = 1 << 12,
  50. MLX5_QP_OPTPAR_RNR_RETRY = 1 << 13,
  51. MLX5_QP_OPTPAR_ACK_TIMEOUT = 1 << 14,
  52. MLX5_QP_OPTPAR_PRI_PORT = 1 << 16,
  53. MLX5_QP_OPTPAR_SRQN = 1 << 18,
  54. MLX5_QP_OPTPAR_CQN_RCV = 1 << 19,
  55. MLX5_QP_OPTPAR_DC_HS = 1 << 20,
  56. MLX5_QP_OPTPAR_DC_KEY = 1 << 21,
  57. };
  58. enum mlx5_qp_state {
  59. MLX5_QP_STATE_RST = 0,
  60. MLX5_QP_STATE_INIT = 1,
  61. MLX5_QP_STATE_RTR = 2,
  62. MLX5_QP_STATE_RTS = 3,
  63. MLX5_QP_STATE_SQER = 4,
  64. MLX5_QP_STATE_SQD = 5,
  65. MLX5_QP_STATE_ERR = 6,
  66. MLX5_QP_STATE_SQ_DRAINING = 7,
  67. MLX5_QP_STATE_SUSPENDED = 9,
  68. MLX5_QP_NUM_STATE
  69. };
  70. enum {
  71. MLX5_QP_ST_RC = 0x0,
  72. MLX5_QP_ST_UC = 0x1,
  73. MLX5_QP_ST_UD = 0x2,
  74. MLX5_QP_ST_XRC = 0x3,
  75. MLX5_QP_ST_MLX = 0x4,
  76. MLX5_QP_ST_DCI = 0x5,
  77. MLX5_QP_ST_DCT = 0x6,
  78. MLX5_QP_ST_QP0 = 0x7,
  79. MLX5_QP_ST_QP1 = 0x8,
  80. MLX5_QP_ST_RAW_ETHERTYPE = 0x9,
  81. MLX5_QP_ST_RAW_IPV6 = 0xa,
  82. MLX5_QP_ST_SNIFFER = 0xb,
  83. MLX5_QP_ST_SYNC_UMR = 0xe,
  84. MLX5_QP_ST_PTP_1588 = 0xd,
  85. MLX5_QP_ST_REG_UMR = 0xc,
  86. MLX5_QP_ST_MAX
  87. };
  88. enum {
  89. MLX5_QP_PM_MIGRATED = 0x3,
  90. MLX5_QP_PM_ARMED = 0x0,
  91. MLX5_QP_PM_REARM = 0x1
  92. };
  93. enum {
  94. MLX5_NON_ZERO_RQ = 0 << 24,
  95. MLX5_SRQ_RQ = 1 << 24,
  96. MLX5_CRQ_RQ = 2 << 24,
  97. MLX5_ZERO_LEN_RQ = 3 << 24
  98. };
  99. enum {
  100. /* params1 */
  101. MLX5_QP_BIT_SRE = 1 << 15,
  102. MLX5_QP_BIT_SWE = 1 << 14,
  103. MLX5_QP_BIT_SAE = 1 << 13,
  104. /* params2 */
  105. MLX5_QP_BIT_RRE = 1 << 15,
  106. MLX5_QP_BIT_RWE = 1 << 14,
  107. MLX5_QP_BIT_RAE = 1 << 13,
  108. MLX5_QP_BIT_RIC = 1 << 4,
  109. };
  110. enum {
  111. MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2,
  112. MLX5_WQE_CTRL_SOLICITED = 1 << 1,
  113. };
  114. enum {
  115. MLX5_SEND_WQE_BB = 64,
  116. };
  117. enum {
  118. MLX5_WQE_FMR_PERM_LOCAL_READ = 1 << 27,
  119. MLX5_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28,
  120. MLX5_WQE_FMR_PERM_REMOTE_READ = 1 << 29,
  121. MLX5_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30,
  122. MLX5_WQE_FMR_PERM_ATOMIC = 1 << 31
  123. };
  124. enum {
  125. MLX5_FENCE_MODE_NONE = 0 << 5,
  126. MLX5_FENCE_MODE_INITIATOR_SMALL = 1 << 5,
  127. MLX5_FENCE_MODE_STRONG_ORDERING = 3 << 5,
  128. MLX5_FENCE_MODE_SMALL_AND_FENCE = 4 << 5,
  129. };
  130. enum {
  131. MLX5_QP_LAT_SENSITIVE = 1 << 28,
  132. MLX5_QP_ENABLE_SIG = 1 << 31,
  133. };
  134. enum {
  135. MLX5_RCV_DBR = 0,
  136. MLX5_SND_DBR = 1,
  137. };
  138. struct mlx5_wqe_fmr_seg {
  139. __be32 flags;
  140. __be32 mem_key;
  141. __be64 buf_list;
  142. __be64 start_addr;
  143. __be64 reg_len;
  144. __be32 offset;
  145. __be32 page_size;
  146. u32 reserved[2];
  147. };
  148. struct mlx5_wqe_ctrl_seg {
  149. __be32 opmod_idx_opcode;
  150. __be32 qpn_ds;
  151. u8 signature;
  152. u8 rsvd[2];
  153. u8 fm_ce_se;
  154. __be32 imm;
  155. };
  156. struct mlx5_wqe_xrc_seg {
  157. __be32 xrc_srqn;
  158. u8 rsvd[12];
  159. };
  160. struct mlx5_wqe_masked_atomic_seg {
  161. __be64 swap_add;
  162. __be64 compare;
  163. __be64 swap_add_mask;
  164. __be64 compare_mask;
  165. };
  166. struct mlx5_av {
  167. union {
  168. struct {
  169. __be32 qkey;
  170. __be32 reserved;
  171. } qkey;
  172. __be64 dc_key;
  173. } key;
  174. __be32 dqp_dct;
  175. u8 stat_rate_sl;
  176. u8 fl_mlid;
  177. __be16 rlid;
  178. u8 reserved0[10];
  179. u8 tclass;
  180. u8 hop_limit;
  181. __be32 grh_gid_fl;
  182. u8 rgid[16];
  183. };
  184. struct mlx5_wqe_datagram_seg {
  185. struct mlx5_av av;
  186. };
  187. struct mlx5_wqe_raddr_seg {
  188. __be64 raddr;
  189. __be32 rkey;
  190. u32 reserved;
  191. };
  192. struct mlx5_wqe_atomic_seg {
  193. __be64 swap_add;
  194. __be64 compare;
  195. };
  196. struct mlx5_wqe_data_seg {
  197. __be32 byte_count;
  198. __be32 lkey;
  199. __be64 addr;
  200. };
  201. struct mlx5_wqe_umr_ctrl_seg {
  202. u8 flags;
  203. u8 rsvd0[3];
  204. __be16 klm_octowords;
  205. __be16 bsf_octowords;
  206. __be64 mkey_mask;
  207. u8 rsvd1[32];
  208. };
  209. struct mlx5_seg_set_psv {
  210. __be32 psv_num;
  211. __be16 syndrome;
  212. __be16 status;
  213. __be32 transient_sig;
  214. __be32 ref_tag;
  215. };
  216. struct mlx5_seg_get_psv {
  217. u8 rsvd[19];
  218. u8 num_psv;
  219. __be32 l_key;
  220. __be64 va;
  221. __be32 psv_index[4];
  222. };
  223. struct mlx5_seg_check_psv {
  224. u8 rsvd0[2];
  225. __be16 err_coalescing_op;
  226. u8 rsvd1[2];
  227. __be16 xport_err_op;
  228. u8 rsvd2[2];
  229. __be16 xport_err_mask;
  230. u8 rsvd3[7];
  231. u8 num_psv;
  232. __be32 l_key;
  233. __be64 va;
  234. __be32 psv_index[4];
  235. };
  236. struct mlx5_rwqe_sig {
  237. u8 rsvd0[4];
  238. u8 signature;
  239. u8 rsvd1[11];
  240. };
  241. struct mlx5_wqe_signature_seg {
  242. u8 rsvd0[4];
  243. u8 signature;
  244. u8 rsvd1[11];
  245. };
  246. struct mlx5_wqe_inline_seg {
  247. __be32 byte_count;
  248. };
  249. struct mlx5_core_qp {
  250. void (*event) (struct mlx5_core_qp *, int);
  251. int qpn;
  252. atomic_t refcount;
  253. struct completion free;
  254. struct mlx5_rsc_debug *dbg;
  255. int pid;
  256. };
  257. struct mlx5_qp_path {
  258. u8 fl;
  259. u8 rsvd3;
  260. u8 free_ar;
  261. u8 pkey_index;
  262. u8 rsvd0;
  263. u8 grh_mlid;
  264. __be16 rlid;
  265. u8 ackto_lt;
  266. u8 mgid_index;
  267. u8 static_rate;
  268. u8 hop_limit;
  269. __be32 tclass_flowlabel;
  270. u8 rgid[16];
  271. u8 rsvd1[4];
  272. u8 sl;
  273. u8 port;
  274. u8 rsvd2[6];
  275. };
  276. struct mlx5_qp_context {
  277. __be32 flags;
  278. __be32 flags_pd;
  279. u8 mtu_msgmax;
  280. u8 rq_size_stride;
  281. __be16 sq_crq_size;
  282. __be32 qp_counter_set_usr_page;
  283. __be32 wire_qpn;
  284. __be32 log_pg_sz_remote_qpn;
  285. struct mlx5_qp_path pri_path;
  286. struct mlx5_qp_path alt_path;
  287. __be32 params1;
  288. u8 reserved2[4];
  289. __be32 next_send_psn;
  290. __be32 cqn_send;
  291. u8 reserved3[8];
  292. __be32 last_acked_psn;
  293. __be32 ssn;
  294. __be32 params2;
  295. __be32 rnr_nextrecvpsn;
  296. __be32 xrcd;
  297. __be32 cqn_recv;
  298. __be64 db_rec_addr;
  299. __be32 qkey;
  300. __be32 rq_type_srqn;
  301. __be32 rmsn;
  302. __be16 hw_sq_wqe_counter;
  303. __be16 sw_sq_wqe_counter;
  304. __be16 hw_rcyclic_byte_counter;
  305. __be16 hw_rq_counter;
  306. __be16 sw_rcyclic_byte_counter;
  307. __be16 sw_rq_counter;
  308. u8 rsvd0[5];
  309. u8 cgs;
  310. u8 cs_req;
  311. u8 cs_res;
  312. __be64 dc_access_key;
  313. u8 rsvd1[24];
  314. };
  315. struct mlx5_create_qp_mbox_in {
  316. struct mlx5_inbox_hdr hdr;
  317. __be32 input_qpn;
  318. u8 rsvd0[4];
  319. __be32 opt_param_mask;
  320. u8 rsvd1[4];
  321. struct mlx5_qp_context ctx;
  322. u8 rsvd3[16];
  323. __be64 pas[0];
  324. };
  325. struct mlx5_create_qp_mbox_out {
  326. struct mlx5_outbox_hdr hdr;
  327. __be32 qpn;
  328. u8 rsvd0[4];
  329. };
  330. struct mlx5_destroy_qp_mbox_in {
  331. struct mlx5_inbox_hdr hdr;
  332. __be32 qpn;
  333. u8 rsvd0[4];
  334. };
  335. struct mlx5_destroy_qp_mbox_out {
  336. struct mlx5_outbox_hdr hdr;
  337. u8 rsvd0[8];
  338. };
  339. struct mlx5_modify_qp_mbox_in {
  340. struct mlx5_inbox_hdr hdr;
  341. __be32 qpn;
  342. u8 rsvd1[4];
  343. __be32 optparam;
  344. u8 rsvd0[4];
  345. struct mlx5_qp_context ctx;
  346. };
  347. struct mlx5_modify_qp_mbox_out {
  348. struct mlx5_outbox_hdr hdr;
  349. u8 rsvd0[8];
  350. };
  351. struct mlx5_query_qp_mbox_in {
  352. struct mlx5_inbox_hdr hdr;
  353. __be32 qpn;
  354. u8 rsvd[4];
  355. };
  356. struct mlx5_query_qp_mbox_out {
  357. struct mlx5_outbox_hdr hdr;
  358. u8 rsvd1[8];
  359. __be32 optparam;
  360. u8 rsvd0[4];
  361. struct mlx5_qp_context ctx;
  362. u8 rsvd2[16];
  363. __be64 pas[0];
  364. };
  365. struct mlx5_conf_sqp_mbox_in {
  366. struct mlx5_inbox_hdr hdr;
  367. __be32 qpn;
  368. u8 rsvd[3];
  369. u8 type;
  370. };
  371. struct mlx5_conf_sqp_mbox_out {
  372. struct mlx5_outbox_hdr hdr;
  373. u8 rsvd[8];
  374. };
  375. struct mlx5_alloc_xrcd_mbox_in {
  376. struct mlx5_inbox_hdr hdr;
  377. u8 rsvd[8];
  378. };
  379. struct mlx5_alloc_xrcd_mbox_out {
  380. struct mlx5_outbox_hdr hdr;
  381. __be32 xrcdn;
  382. u8 rsvd[4];
  383. };
  384. struct mlx5_dealloc_xrcd_mbox_in {
  385. struct mlx5_inbox_hdr hdr;
  386. __be32 xrcdn;
  387. u8 rsvd[4];
  388. };
  389. struct mlx5_dealloc_xrcd_mbox_out {
  390. struct mlx5_outbox_hdr hdr;
  391. u8 rsvd[8];
  392. };
  393. static inline struct mlx5_core_qp *__mlx5_qp_lookup(struct mlx5_core_dev *dev, u32 qpn)
  394. {
  395. return radix_tree_lookup(&dev->priv.qp_table.tree, qpn);
  396. }
  397. int mlx5_core_create_qp(struct mlx5_core_dev *dev,
  398. struct mlx5_core_qp *qp,
  399. struct mlx5_create_qp_mbox_in *in,
  400. int inlen);
  401. int mlx5_core_qp_modify(struct mlx5_core_dev *dev, enum mlx5_qp_state cur_state,
  402. enum mlx5_qp_state new_state,
  403. struct mlx5_modify_qp_mbox_in *in, int sqd_event,
  404. struct mlx5_core_qp *qp);
  405. int mlx5_core_destroy_qp(struct mlx5_core_dev *dev,
  406. struct mlx5_core_qp *qp);
  407. int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
  408. struct mlx5_query_qp_mbox_out *out, int outlen);
  409. int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn);
  410. int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn);
  411. void mlx5_init_qp_table(struct mlx5_core_dev *dev);
  412. void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev);
  413. int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
  414. void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
  415. #endif /* MLX5_QP_H */