qp.h 14 KB

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