qp.h 14 KB

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