qp.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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. #define MLX5_SIG_WQE_SIZE (MLX5_SEND_WQE_BB * 5)
  38. #define MLX5_DIF_SIZE 8
  39. #define MLX5_STRIDE_BLOCK_OP 0x400
  40. #define MLX5_CPY_GRD_MASK 0xc0
  41. #define MLX5_CPY_APP_MASK 0x30
  42. #define MLX5_CPY_REF_MASK 0x0f
  43. #define MLX5_BSF_INC_REFTAG (1 << 6)
  44. #define MLX5_BSF_INL_VALID (1 << 15)
  45. #define MLX5_BSF_REFRESH_DIF (1 << 14)
  46. #define MLX5_BSF_REPEAT_BLOCK (1 << 7)
  47. #define MLX5_BSF_APPTAG_ESCAPE 0x1
  48. #define MLX5_BSF_APPREF_ESCAPE 0x2
  49. #define MLX5_QPN_BITS 24
  50. #define MLX5_QPN_MASK ((1 << MLX5_QPN_BITS) - 1)
  51. enum mlx5_qp_optpar {
  52. MLX5_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0,
  53. MLX5_QP_OPTPAR_RRE = 1 << 1,
  54. MLX5_QP_OPTPAR_RAE = 1 << 2,
  55. MLX5_QP_OPTPAR_RWE = 1 << 3,
  56. MLX5_QP_OPTPAR_PKEY_INDEX = 1 << 4,
  57. MLX5_QP_OPTPAR_Q_KEY = 1 << 5,
  58. MLX5_QP_OPTPAR_RNR_TIMEOUT = 1 << 6,
  59. MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7,
  60. MLX5_QP_OPTPAR_SRA_MAX = 1 << 8,
  61. MLX5_QP_OPTPAR_RRA_MAX = 1 << 9,
  62. MLX5_QP_OPTPAR_PM_STATE = 1 << 10,
  63. MLX5_QP_OPTPAR_RETRY_COUNT = 1 << 12,
  64. MLX5_QP_OPTPAR_RNR_RETRY = 1 << 13,
  65. MLX5_QP_OPTPAR_ACK_TIMEOUT = 1 << 14,
  66. MLX5_QP_OPTPAR_PRI_PORT = 1 << 16,
  67. MLX5_QP_OPTPAR_SRQN = 1 << 18,
  68. MLX5_QP_OPTPAR_CQN_RCV = 1 << 19,
  69. MLX5_QP_OPTPAR_DC_HS = 1 << 20,
  70. MLX5_QP_OPTPAR_DC_KEY = 1 << 21,
  71. };
  72. enum mlx5_qp_state {
  73. MLX5_QP_STATE_RST = 0,
  74. MLX5_QP_STATE_INIT = 1,
  75. MLX5_QP_STATE_RTR = 2,
  76. MLX5_QP_STATE_RTS = 3,
  77. MLX5_QP_STATE_SQER = 4,
  78. MLX5_QP_STATE_SQD = 5,
  79. MLX5_QP_STATE_ERR = 6,
  80. MLX5_QP_STATE_SQ_DRAINING = 7,
  81. MLX5_QP_STATE_SUSPENDED = 9,
  82. MLX5_QP_NUM_STATE
  83. };
  84. enum {
  85. MLX5_QP_ST_RC = 0x0,
  86. MLX5_QP_ST_UC = 0x1,
  87. MLX5_QP_ST_UD = 0x2,
  88. MLX5_QP_ST_XRC = 0x3,
  89. MLX5_QP_ST_MLX = 0x4,
  90. MLX5_QP_ST_DCI = 0x5,
  91. MLX5_QP_ST_DCT = 0x6,
  92. MLX5_QP_ST_QP0 = 0x7,
  93. MLX5_QP_ST_QP1 = 0x8,
  94. MLX5_QP_ST_RAW_ETHERTYPE = 0x9,
  95. MLX5_QP_ST_RAW_IPV6 = 0xa,
  96. MLX5_QP_ST_SNIFFER = 0xb,
  97. MLX5_QP_ST_SYNC_UMR = 0xe,
  98. MLX5_QP_ST_PTP_1588 = 0xd,
  99. MLX5_QP_ST_REG_UMR = 0xc,
  100. MLX5_QP_ST_MAX
  101. };
  102. enum {
  103. MLX5_QP_PM_MIGRATED = 0x3,
  104. MLX5_QP_PM_ARMED = 0x0,
  105. MLX5_QP_PM_REARM = 0x1
  106. };
  107. enum {
  108. MLX5_NON_ZERO_RQ = 0 << 24,
  109. MLX5_SRQ_RQ = 1 << 24,
  110. MLX5_CRQ_RQ = 2 << 24,
  111. MLX5_ZERO_LEN_RQ = 3 << 24
  112. };
  113. enum {
  114. /* params1 */
  115. MLX5_QP_BIT_SRE = 1 << 15,
  116. MLX5_QP_BIT_SWE = 1 << 14,
  117. MLX5_QP_BIT_SAE = 1 << 13,
  118. /* params2 */
  119. MLX5_QP_BIT_RRE = 1 << 15,
  120. MLX5_QP_BIT_RWE = 1 << 14,
  121. MLX5_QP_BIT_RAE = 1 << 13,
  122. MLX5_QP_BIT_RIC = 1 << 4,
  123. };
  124. enum {
  125. MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2,
  126. MLX5_WQE_CTRL_SOLICITED = 1 << 1,
  127. };
  128. enum {
  129. MLX5_SEND_WQE_BB = 64,
  130. };
  131. enum {
  132. MLX5_WQE_FMR_PERM_LOCAL_READ = 1 << 27,
  133. MLX5_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28,
  134. MLX5_WQE_FMR_PERM_REMOTE_READ = 1 << 29,
  135. MLX5_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30,
  136. MLX5_WQE_FMR_PERM_ATOMIC = 1 << 31
  137. };
  138. enum {
  139. MLX5_FENCE_MODE_NONE = 0 << 5,
  140. MLX5_FENCE_MODE_INITIATOR_SMALL = 1 << 5,
  141. MLX5_FENCE_MODE_STRONG_ORDERING = 3 << 5,
  142. MLX5_FENCE_MODE_SMALL_AND_FENCE = 4 << 5,
  143. };
  144. enum {
  145. MLX5_QP_LAT_SENSITIVE = 1 << 28,
  146. MLX5_QP_BLOCK_MCAST = 1 << 30,
  147. MLX5_QP_ENABLE_SIG = 1 << 31,
  148. };
  149. enum {
  150. MLX5_RCV_DBR = 0,
  151. MLX5_SND_DBR = 1,
  152. };
  153. enum {
  154. MLX5_FLAGS_INLINE = 1<<7,
  155. MLX5_FLAGS_CHECK_FREE = 1<<5,
  156. };
  157. struct mlx5_wqe_fmr_seg {
  158. __be32 flags;
  159. __be32 mem_key;
  160. __be64 buf_list;
  161. __be64 start_addr;
  162. __be64 reg_len;
  163. __be32 offset;
  164. __be32 page_size;
  165. u32 reserved[2];
  166. };
  167. struct mlx5_wqe_ctrl_seg {
  168. __be32 opmod_idx_opcode;
  169. __be32 qpn_ds;
  170. u8 signature;
  171. u8 rsvd[2];
  172. u8 fm_ce_se;
  173. __be32 imm;
  174. };
  175. #define MLX5_WQE_CTRL_DS_MASK 0x3f
  176. #define MLX5_WQE_CTRL_QPN_MASK 0xffffff00
  177. #define MLX5_WQE_CTRL_QPN_SHIFT 8
  178. #define MLX5_WQE_DS_UNITS 16
  179. #define MLX5_WQE_CTRL_OPCODE_MASK 0xff
  180. #define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00
  181. #define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8
  182. struct mlx5_wqe_xrc_seg {
  183. __be32 xrc_srqn;
  184. u8 rsvd[12];
  185. };
  186. struct mlx5_wqe_masked_atomic_seg {
  187. __be64 swap_add;
  188. __be64 compare;
  189. __be64 swap_add_mask;
  190. __be64 compare_mask;
  191. };
  192. struct mlx5_av {
  193. union {
  194. struct {
  195. __be32 qkey;
  196. __be32 reserved;
  197. } qkey;
  198. __be64 dc_key;
  199. } key;
  200. __be32 dqp_dct;
  201. u8 stat_rate_sl;
  202. u8 fl_mlid;
  203. __be16 rlid;
  204. u8 reserved0[10];
  205. u8 tclass;
  206. u8 hop_limit;
  207. __be32 grh_gid_fl;
  208. u8 rgid[16];
  209. };
  210. struct mlx5_wqe_datagram_seg {
  211. struct mlx5_av av;
  212. };
  213. struct mlx5_wqe_raddr_seg {
  214. __be64 raddr;
  215. __be32 rkey;
  216. u32 reserved;
  217. };
  218. struct mlx5_wqe_atomic_seg {
  219. __be64 swap_add;
  220. __be64 compare;
  221. };
  222. struct mlx5_wqe_data_seg {
  223. __be32 byte_count;
  224. __be32 lkey;
  225. __be64 addr;
  226. };
  227. struct mlx5_wqe_umr_ctrl_seg {
  228. u8 flags;
  229. u8 rsvd0[3];
  230. __be16 klm_octowords;
  231. __be16 bsf_octowords;
  232. __be64 mkey_mask;
  233. u8 rsvd1[32];
  234. };
  235. struct mlx5_seg_set_psv {
  236. __be32 psv_num;
  237. __be16 syndrome;
  238. __be16 status;
  239. __be32 transient_sig;
  240. __be32 ref_tag;
  241. };
  242. struct mlx5_seg_get_psv {
  243. u8 rsvd[19];
  244. u8 num_psv;
  245. __be32 l_key;
  246. __be64 va;
  247. __be32 psv_index[4];
  248. };
  249. struct mlx5_seg_check_psv {
  250. u8 rsvd0[2];
  251. __be16 err_coalescing_op;
  252. u8 rsvd1[2];
  253. __be16 xport_err_op;
  254. u8 rsvd2[2];
  255. __be16 xport_err_mask;
  256. u8 rsvd3[7];
  257. u8 num_psv;
  258. __be32 l_key;
  259. __be64 va;
  260. __be32 psv_index[4];
  261. };
  262. struct mlx5_rwqe_sig {
  263. u8 rsvd0[4];
  264. u8 signature;
  265. u8 rsvd1[11];
  266. };
  267. struct mlx5_wqe_signature_seg {
  268. u8 rsvd0[4];
  269. u8 signature;
  270. u8 rsvd1[11];
  271. };
  272. #define MLX5_WQE_INLINE_SEG_BYTE_COUNT_MASK 0x3ff
  273. struct mlx5_wqe_inline_seg {
  274. __be32 byte_count;
  275. };
  276. enum mlx5_sig_type {
  277. MLX5_DIF_CRC = 0x1,
  278. MLX5_DIF_IPCS = 0x2,
  279. };
  280. struct mlx5_bsf_inl {
  281. __be16 vld_refresh;
  282. __be16 dif_apptag;
  283. __be32 dif_reftag;
  284. u8 sig_type;
  285. u8 rp_inv_seed;
  286. u8 rsvd[3];
  287. u8 dif_inc_ref_guard_check;
  288. __be16 dif_app_bitmask_check;
  289. };
  290. struct mlx5_bsf {
  291. struct mlx5_bsf_basic {
  292. u8 bsf_size_sbs;
  293. u8 check_byte_mask;
  294. union {
  295. u8 copy_byte_mask;
  296. u8 bs_selector;
  297. u8 rsvd_wflags;
  298. } wire;
  299. union {
  300. u8 bs_selector;
  301. u8 rsvd_mflags;
  302. } mem;
  303. __be32 raw_data_size;
  304. __be32 w_bfs_psv;
  305. __be32 m_bfs_psv;
  306. } basic;
  307. struct mlx5_bsf_ext {
  308. __be32 t_init_gen_pro_size;
  309. __be32 rsvd_epi_size;
  310. __be32 w_tfs_psv;
  311. __be32 m_tfs_psv;
  312. } ext;
  313. struct mlx5_bsf_inl w_inl;
  314. struct mlx5_bsf_inl m_inl;
  315. };
  316. struct mlx5_klm {
  317. __be32 bcount;
  318. __be32 key;
  319. __be64 va;
  320. };
  321. struct mlx5_stride_block_entry {
  322. __be16 stride;
  323. __be16 bcount;
  324. __be32 key;
  325. __be64 va;
  326. };
  327. struct mlx5_stride_block_ctrl_seg {
  328. __be32 bcount_per_cycle;
  329. __be32 op;
  330. __be32 repeat_count;
  331. u16 rsvd;
  332. __be16 num_entries;
  333. };
  334. enum mlx5_pagefault_flags {
  335. MLX5_PFAULT_REQUESTOR = 1 << 0,
  336. MLX5_PFAULT_WRITE = 1 << 1,
  337. MLX5_PFAULT_RDMA = 1 << 2,
  338. };
  339. /* Contains the details of a pagefault. */
  340. struct mlx5_pagefault {
  341. u32 bytes_committed;
  342. u8 event_subtype;
  343. enum mlx5_pagefault_flags flags;
  344. union {
  345. /* Initiator or send message responder pagefault details. */
  346. struct {
  347. /* Received packet size, only valid for responders. */
  348. u32 packet_size;
  349. /*
  350. * WQE index. Refers to either the send queue or
  351. * receive queue, according to event_subtype.
  352. */
  353. u16 wqe_index;
  354. } wqe;
  355. /* RDMA responder pagefault details */
  356. struct {
  357. u32 r_key;
  358. /*
  359. * Received packet size, minimal size page fault
  360. * resolution required for forward progress.
  361. */
  362. u32 packet_size;
  363. u32 rdma_op_len;
  364. u64 rdma_va;
  365. } rdma;
  366. };
  367. };
  368. struct mlx5_core_qp {
  369. struct mlx5_core_rsc_common common; /* must be first */
  370. void (*event) (struct mlx5_core_qp *, int);
  371. void (*pfault_handler)(struct mlx5_core_qp *, struct mlx5_pagefault *);
  372. int qpn;
  373. struct mlx5_rsc_debug *dbg;
  374. int pid;
  375. };
  376. struct mlx5_qp_path {
  377. u8 fl;
  378. u8 rsvd3;
  379. u8 free_ar;
  380. u8 pkey_index;
  381. u8 rsvd0;
  382. u8 grh_mlid;
  383. __be16 rlid;
  384. u8 ackto_lt;
  385. u8 mgid_index;
  386. u8 static_rate;
  387. u8 hop_limit;
  388. __be32 tclass_flowlabel;
  389. u8 rgid[16];
  390. u8 rsvd1[4];
  391. u8 sl;
  392. u8 port;
  393. u8 rsvd2[6];
  394. };
  395. struct mlx5_qp_context {
  396. __be32 flags;
  397. __be32 flags_pd;
  398. u8 mtu_msgmax;
  399. u8 rq_size_stride;
  400. __be16 sq_crq_size;
  401. __be32 qp_counter_set_usr_page;
  402. __be32 wire_qpn;
  403. __be32 log_pg_sz_remote_qpn;
  404. struct mlx5_qp_path pri_path;
  405. struct mlx5_qp_path alt_path;
  406. __be32 params1;
  407. u8 reserved2[4];
  408. __be32 next_send_psn;
  409. __be32 cqn_send;
  410. u8 reserved3[8];
  411. __be32 last_acked_psn;
  412. __be32 ssn;
  413. __be32 params2;
  414. __be32 rnr_nextrecvpsn;
  415. __be32 xrcd;
  416. __be32 cqn_recv;
  417. __be64 db_rec_addr;
  418. __be32 qkey;
  419. __be32 rq_type_srqn;
  420. __be32 rmsn;
  421. __be16 hw_sq_wqe_counter;
  422. __be16 sw_sq_wqe_counter;
  423. __be16 hw_rcyclic_byte_counter;
  424. __be16 hw_rq_counter;
  425. __be16 sw_rcyclic_byte_counter;
  426. __be16 sw_rq_counter;
  427. u8 rsvd0[5];
  428. u8 cgs;
  429. u8 cs_req;
  430. u8 cs_res;
  431. __be64 dc_access_key;
  432. u8 rsvd1[24];
  433. };
  434. struct mlx5_create_qp_mbox_in {
  435. struct mlx5_inbox_hdr hdr;
  436. __be32 input_qpn;
  437. u8 rsvd0[4];
  438. __be32 opt_param_mask;
  439. u8 rsvd1[4];
  440. struct mlx5_qp_context ctx;
  441. u8 rsvd3[16];
  442. __be64 pas[0];
  443. };
  444. struct mlx5_create_qp_mbox_out {
  445. struct mlx5_outbox_hdr hdr;
  446. __be32 qpn;
  447. u8 rsvd0[4];
  448. };
  449. struct mlx5_destroy_qp_mbox_in {
  450. struct mlx5_inbox_hdr hdr;
  451. __be32 qpn;
  452. u8 rsvd0[4];
  453. };
  454. struct mlx5_destroy_qp_mbox_out {
  455. struct mlx5_outbox_hdr hdr;
  456. u8 rsvd0[8];
  457. };
  458. struct mlx5_modify_qp_mbox_in {
  459. struct mlx5_inbox_hdr hdr;
  460. __be32 qpn;
  461. u8 rsvd1[4];
  462. __be32 optparam;
  463. u8 rsvd0[4];
  464. struct mlx5_qp_context ctx;
  465. };
  466. struct mlx5_modify_qp_mbox_out {
  467. struct mlx5_outbox_hdr hdr;
  468. u8 rsvd0[8];
  469. };
  470. struct mlx5_query_qp_mbox_in {
  471. struct mlx5_inbox_hdr hdr;
  472. __be32 qpn;
  473. u8 rsvd[4];
  474. };
  475. struct mlx5_query_qp_mbox_out {
  476. struct mlx5_outbox_hdr hdr;
  477. u8 rsvd1[8];
  478. __be32 optparam;
  479. u8 rsvd0[4];
  480. struct mlx5_qp_context ctx;
  481. u8 rsvd2[16];
  482. __be64 pas[0];
  483. };
  484. struct mlx5_conf_sqp_mbox_in {
  485. struct mlx5_inbox_hdr hdr;
  486. __be32 qpn;
  487. u8 rsvd[3];
  488. u8 type;
  489. };
  490. struct mlx5_conf_sqp_mbox_out {
  491. struct mlx5_outbox_hdr hdr;
  492. u8 rsvd[8];
  493. };
  494. struct mlx5_alloc_xrcd_mbox_in {
  495. struct mlx5_inbox_hdr hdr;
  496. u8 rsvd[8];
  497. };
  498. struct mlx5_alloc_xrcd_mbox_out {
  499. struct mlx5_outbox_hdr hdr;
  500. __be32 xrcdn;
  501. u8 rsvd[4];
  502. };
  503. struct mlx5_dealloc_xrcd_mbox_in {
  504. struct mlx5_inbox_hdr hdr;
  505. __be32 xrcdn;
  506. u8 rsvd[4];
  507. };
  508. struct mlx5_dealloc_xrcd_mbox_out {
  509. struct mlx5_outbox_hdr hdr;
  510. u8 rsvd[8];
  511. };
  512. static inline struct mlx5_core_qp *__mlx5_qp_lookup(struct mlx5_core_dev *dev, u32 qpn)
  513. {
  514. return radix_tree_lookup(&dev->priv.qp_table.tree, qpn);
  515. }
  516. static inline struct mlx5_core_mr *__mlx5_mr_lookup(struct mlx5_core_dev *dev, u32 key)
  517. {
  518. return radix_tree_lookup(&dev->priv.mr_table.tree, key);
  519. }
  520. struct mlx5_page_fault_resume_mbox_in {
  521. struct mlx5_inbox_hdr hdr;
  522. __be32 flags_qpn;
  523. u8 reserved[4];
  524. };
  525. struct mlx5_page_fault_resume_mbox_out {
  526. struct mlx5_outbox_hdr hdr;
  527. u8 rsvd[8];
  528. };
  529. int mlx5_core_create_qp(struct mlx5_core_dev *dev,
  530. struct mlx5_core_qp *qp,
  531. struct mlx5_create_qp_mbox_in *in,
  532. int inlen);
  533. int mlx5_core_qp_modify(struct mlx5_core_dev *dev, enum mlx5_qp_state cur_state,
  534. enum mlx5_qp_state new_state,
  535. struct mlx5_modify_qp_mbox_in *in, int sqd_event,
  536. struct mlx5_core_qp *qp);
  537. int mlx5_core_destroy_qp(struct mlx5_core_dev *dev,
  538. struct mlx5_core_qp *qp);
  539. int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
  540. struct mlx5_query_qp_mbox_out *out, int outlen);
  541. int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn);
  542. int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn);
  543. void mlx5_init_qp_table(struct mlx5_core_dev *dev);
  544. void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev);
  545. int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
  546. void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
  547. #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
  548. int mlx5_core_page_fault_resume(struct mlx5_core_dev *dev, u32 qpn,
  549. u8 context, int error);
  550. #endif
  551. static inline const char *mlx5_qp_type_str(int type)
  552. {
  553. switch (type) {
  554. case MLX5_QP_ST_RC: return "RC";
  555. case MLX5_QP_ST_UC: return "C";
  556. case MLX5_QP_ST_UD: return "UD";
  557. case MLX5_QP_ST_XRC: return "XRC";
  558. case MLX5_QP_ST_MLX: return "MLX";
  559. case MLX5_QP_ST_QP0: return "QP0";
  560. case MLX5_QP_ST_QP1: return "QP1";
  561. case MLX5_QP_ST_RAW_ETHERTYPE: return "RAW_ETHERTYPE";
  562. case MLX5_QP_ST_RAW_IPV6: return "RAW_IPV6";
  563. case MLX5_QP_ST_SNIFFER: return "SNIFFER";
  564. case MLX5_QP_ST_SYNC_UMR: return "SYNC_UMR";
  565. case MLX5_QP_ST_PTP_1588: return "PTP_1588";
  566. case MLX5_QP_ST_REG_UMR: return "REG_UMR";
  567. default: return "Invalid transport type";
  568. }
  569. }
  570. static inline const char *mlx5_qp_state_str(int state)
  571. {
  572. switch (state) {
  573. case MLX5_QP_STATE_RST:
  574. return "RST";
  575. case MLX5_QP_STATE_INIT:
  576. return "INIT";
  577. case MLX5_QP_STATE_RTR:
  578. return "RTR";
  579. case MLX5_QP_STATE_RTS:
  580. return "RTS";
  581. case MLX5_QP_STATE_SQER:
  582. return "SQER";
  583. case MLX5_QP_STATE_SQD:
  584. return "SQD";
  585. case MLX5_QP_STATE_ERR:
  586. return "ERR";
  587. case MLX5_QP_STATE_SQ_DRAINING:
  588. return "SQ_DRAINING";
  589. case MLX5_QP_STATE_SUSPENDED:
  590. return "SUSPENDED";
  591. default: return "Invalid QP state";
  592. }
  593. }
  594. #endif /* MLX5_QP_H */