user.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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_IB_USER_H
  33. #define MLX5_IB_USER_H
  34. #include <linux/types.h>
  35. #include "mlx5_ib.h"
  36. enum {
  37. MLX5_QP_FLAG_SIGNATURE = 1 << 0,
  38. MLX5_QP_FLAG_SCATTER_CQE = 1 << 1,
  39. };
  40. enum {
  41. MLX5_SRQ_FLAG_SIGNATURE = 1 << 0,
  42. };
  43. enum {
  44. MLX5_WQ_FLAG_SIGNATURE = 1 << 0,
  45. };
  46. /* Increment this value if any changes that break userspace ABI
  47. * compatibility are made.
  48. */
  49. #define MLX5_IB_UVERBS_ABI_VERSION 1
  50. /* Make sure that all structs defined in this file remain laid out so
  51. * that they pack the same way on 32-bit and 64-bit architectures (to
  52. * avoid incompatibility between 32-bit userspace and 64-bit kernels).
  53. * In particular do not use pointer types -- pass pointers in __u64
  54. * instead.
  55. */
  56. struct mlx5_ib_alloc_ucontext_req {
  57. __u32 total_num_uuars;
  58. __u32 num_low_latency_uuars;
  59. };
  60. struct mlx5_ib_alloc_ucontext_req_v2 {
  61. __u32 total_num_uuars;
  62. __u32 num_low_latency_uuars;
  63. __u32 flags;
  64. __u32 comp_mask;
  65. __u8 max_cqe_version;
  66. __u8 reserved0;
  67. __u16 reserved1;
  68. __u32 reserved2;
  69. };
  70. enum mlx5_ib_alloc_ucontext_resp_mask {
  71. MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET = 1UL << 0,
  72. };
  73. enum mlx5_user_cmds_supp_uhw {
  74. MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE = 1 << 0,
  75. };
  76. struct mlx5_ib_alloc_ucontext_resp {
  77. __u32 qp_tab_size;
  78. __u32 bf_reg_size;
  79. __u32 tot_uuars;
  80. __u32 cache_line_size;
  81. __u16 max_sq_desc_sz;
  82. __u16 max_rq_desc_sz;
  83. __u32 max_send_wqebb;
  84. __u32 max_recv_wr;
  85. __u32 max_srq_recv_wr;
  86. __u16 num_ports;
  87. __u16 reserved1;
  88. __u32 comp_mask;
  89. __u32 response_length;
  90. __u8 cqe_version;
  91. __u8 cmds_supp_uhw;
  92. __u16 reserved2;
  93. __u64 hca_core_clock_offset;
  94. };
  95. struct mlx5_ib_alloc_pd_resp {
  96. __u32 pdn;
  97. };
  98. struct mlx5_ib_tso_caps {
  99. __u32 max_tso; /* Maximum tso payload size in bytes */
  100. /* Corresponding bit will be set if qp type from
  101. * 'enum ib_qp_type' is supported, e.g.
  102. * supported_qpts |= 1 << IB_QPT_UD
  103. */
  104. __u32 supported_qpts;
  105. };
  106. struct mlx5_ib_query_device_resp {
  107. __u32 comp_mask;
  108. __u32 response_length;
  109. struct mlx5_ib_tso_caps tso_caps;
  110. };
  111. struct mlx5_ib_create_cq {
  112. __u64 buf_addr;
  113. __u64 db_addr;
  114. __u32 cqe_size;
  115. __u32 reserved; /* explicit padding (optional on i386) */
  116. };
  117. struct mlx5_ib_create_cq_resp {
  118. __u32 cqn;
  119. __u32 reserved;
  120. };
  121. struct mlx5_ib_resize_cq {
  122. __u64 buf_addr;
  123. __u16 cqe_size;
  124. __u16 reserved0;
  125. __u32 reserved1;
  126. };
  127. struct mlx5_ib_create_srq {
  128. __u64 buf_addr;
  129. __u64 db_addr;
  130. __u32 flags;
  131. __u32 reserved0; /* explicit padding (optional on i386) */
  132. __u32 uidx;
  133. __u32 reserved1;
  134. };
  135. struct mlx5_ib_create_srq_resp {
  136. __u32 srqn;
  137. __u32 reserved;
  138. };
  139. struct mlx5_ib_create_qp {
  140. __u64 buf_addr;
  141. __u64 db_addr;
  142. __u32 sq_wqe_count;
  143. __u32 rq_wqe_count;
  144. __u32 rq_wqe_shift;
  145. __u32 flags;
  146. __u32 uidx;
  147. __u32 reserved0;
  148. __u64 sq_buf_addr;
  149. };
  150. /* RX Hash function flags */
  151. enum mlx5_rx_hash_function_flags {
  152. MLX5_RX_HASH_FUNC_TOEPLITZ = 1 << 0,
  153. };
  154. /*
  155. * RX Hash flags, these flags allows to set which incoming packet's field should
  156. * participates in RX Hash. Each flag represent certain packet's field,
  157. * when the flag is set the field that is represented by the flag will
  158. * participate in RX Hash calculation.
  159. * Note: *IPV4 and *IPV6 flags can't be enabled together on the same QP
  160. * and *TCP and *UDP flags can't be enabled together on the same QP.
  161. */
  162. enum mlx5_rx_hash_fields {
  163. MLX5_RX_HASH_SRC_IPV4 = 1 << 0,
  164. MLX5_RX_HASH_DST_IPV4 = 1 << 1,
  165. MLX5_RX_HASH_SRC_IPV6 = 1 << 2,
  166. MLX5_RX_HASH_DST_IPV6 = 1 << 3,
  167. MLX5_RX_HASH_SRC_PORT_TCP = 1 << 4,
  168. MLX5_RX_HASH_DST_PORT_TCP = 1 << 5,
  169. MLX5_RX_HASH_SRC_PORT_UDP = 1 << 6,
  170. MLX5_RX_HASH_DST_PORT_UDP = 1 << 7
  171. };
  172. struct mlx5_ib_create_qp_rss {
  173. __u64 rx_hash_fields_mask; /* enum mlx5_rx_hash_fields */
  174. __u8 rx_hash_function; /* enum mlx5_rx_hash_function_flags */
  175. __u8 rx_key_len; /* valid only for Toeplitz */
  176. __u8 reserved[6];
  177. __u8 rx_hash_key[128]; /* valid only for Toeplitz */
  178. __u32 comp_mask;
  179. __u32 reserved1;
  180. };
  181. struct mlx5_ib_create_qp_resp {
  182. __u32 uuar_index;
  183. };
  184. struct mlx5_ib_alloc_mw {
  185. __u32 comp_mask;
  186. __u8 num_klms;
  187. __u8 reserved1;
  188. __u16 reserved2;
  189. };
  190. struct mlx5_ib_create_wq {
  191. __u64 buf_addr;
  192. __u64 db_addr;
  193. __u32 rq_wqe_count;
  194. __u32 rq_wqe_shift;
  195. __u32 user_index;
  196. __u32 flags;
  197. __u32 comp_mask;
  198. __u32 reserved;
  199. };
  200. struct mlx5_ib_create_wq_resp {
  201. __u32 response_length;
  202. __u32 reserved;
  203. };
  204. struct mlx5_ib_create_rwq_ind_tbl_resp {
  205. __u32 response_length;
  206. __u32 reserved;
  207. };
  208. struct mlx5_ib_modify_wq {
  209. __u32 comp_mask;
  210. __u32 reserved;
  211. };
  212. static inline int get_qp_user_index(struct mlx5_ib_ucontext *ucontext,
  213. struct mlx5_ib_create_qp *ucmd,
  214. int inlen,
  215. u32 *user_index)
  216. {
  217. u8 cqe_version = ucontext->cqe_version;
  218. if (field_avail(struct mlx5_ib_create_qp, uidx, inlen) &&
  219. !cqe_version && (ucmd->uidx == MLX5_IB_DEFAULT_UIDX))
  220. return 0;
  221. if (!!(field_avail(struct mlx5_ib_create_qp, uidx, inlen) !=
  222. !!cqe_version))
  223. return -EINVAL;
  224. return verify_assign_uidx(cqe_version, ucmd->uidx, user_index);
  225. }
  226. static inline int get_srq_user_index(struct mlx5_ib_ucontext *ucontext,
  227. struct mlx5_ib_create_srq *ucmd,
  228. int inlen,
  229. u32 *user_index)
  230. {
  231. u8 cqe_version = ucontext->cqe_version;
  232. if (field_avail(struct mlx5_ib_create_srq, uidx, inlen) &&
  233. !cqe_version && (ucmd->uidx == MLX5_IB_DEFAULT_UIDX))
  234. return 0;
  235. if (!!(field_avail(struct mlx5_ib_create_srq, uidx, inlen) !=
  236. !!cqe_version))
  237. return -EINVAL;
  238. return verify_assign_uidx(cqe_version, ucmd->uidx, user_index);
  239. }
  240. #endif /* MLX5_IB_USER_H */