vmw_pvrdma-abi.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*
  2. * Copyright (c) 2012-2016 VMware, Inc. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of EITHER the GNU General Public License
  6. * version 2 as published by the Free Software Foundation or the BSD
  7. * 2-Clause License. This program is distributed in the hope that it
  8. * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
  9. * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  10. * See the GNU General Public License version 2 for more details at
  11. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program available in the file COPYING in the main
  15. * directory of this source tree.
  16. *
  17. * The BSD 2-Clause License
  18. *
  19. * Redistribution and use in source and binary forms, with or
  20. * without modification, are permitted provided that the following
  21. * conditions are met:
  22. *
  23. * - Redistributions of source code must retain the above
  24. * copyright notice, this list of conditions and the following
  25. * disclaimer.
  26. *
  27. * - Redistributions in binary form must reproduce the above
  28. * copyright notice, this list of conditions and the following
  29. * disclaimer in the documentation and/or other materials
  30. * provided with the distribution.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  34. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  35. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  36. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  37. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  38. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  39. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  40. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  41. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  42. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  43. * OF THE POSSIBILITY OF SUCH DAMAGE.
  44. */
  45. #ifndef __VMW_PVRDMA_ABI_H__
  46. #define __VMW_PVRDMA_ABI_H__
  47. #include <linux/types.h>
  48. #define PVRDMA_UVERBS_ABI_VERSION 3 /* ABI Version. */
  49. #define PVRDMA_UAR_HANDLE_MASK 0x00FFFFFF /* Bottom 24 bits. */
  50. #define PVRDMA_UAR_QP_OFFSET 0 /* QP doorbell. */
  51. #define PVRDMA_UAR_QP_SEND BIT(30) /* Send bit. */
  52. #define PVRDMA_UAR_QP_RECV BIT(31) /* Recv bit. */
  53. #define PVRDMA_UAR_CQ_OFFSET 4 /* CQ doorbell. */
  54. #define PVRDMA_UAR_CQ_ARM_SOL BIT(29) /* Arm solicited bit. */
  55. #define PVRDMA_UAR_CQ_ARM BIT(30) /* Arm bit. */
  56. #define PVRDMA_UAR_CQ_POLL BIT(31) /* Poll bit. */
  57. enum pvrdma_wr_opcode {
  58. PVRDMA_WR_RDMA_WRITE,
  59. PVRDMA_WR_RDMA_WRITE_WITH_IMM,
  60. PVRDMA_WR_SEND,
  61. PVRDMA_WR_SEND_WITH_IMM,
  62. PVRDMA_WR_RDMA_READ,
  63. PVRDMA_WR_ATOMIC_CMP_AND_SWP,
  64. PVRDMA_WR_ATOMIC_FETCH_AND_ADD,
  65. PVRDMA_WR_LSO,
  66. PVRDMA_WR_SEND_WITH_INV,
  67. PVRDMA_WR_RDMA_READ_WITH_INV,
  68. PVRDMA_WR_LOCAL_INV,
  69. PVRDMA_WR_FAST_REG_MR,
  70. PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP,
  71. PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD,
  72. PVRDMA_WR_BIND_MW,
  73. PVRDMA_WR_REG_SIG_MR,
  74. };
  75. enum pvrdma_wc_status {
  76. PVRDMA_WC_SUCCESS,
  77. PVRDMA_WC_LOC_LEN_ERR,
  78. PVRDMA_WC_LOC_QP_OP_ERR,
  79. PVRDMA_WC_LOC_EEC_OP_ERR,
  80. PVRDMA_WC_LOC_PROT_ERR,
  81. PVRDMA_WC_WR_FLUSH_ERR,
  82. PVRDMA_WC_MW_BIND_ERR,
  83. PVRDMA_WC_BAD_RESP_ERR,
  84. PVRDMA_WC_LOC_ACCESS_ERR,
  85. PVRDMA_WC_REM_INV_REQ_ERR,
  86. PVRDMA_WC_REM_ACCESS_ERR,
  87. PVRDMA_WC_REM_OP_ERR,
  88. PVRDMA_WC_RETRY_EXC_ERR,
  89. PVRDMA_WC_RNR_RETRY_EXC_ERR,
  90. PVRDMA_WC_LOC_RDD_VIOL_ERR,
  91. PVRDMA_WC_REM_INV_RD_REQ_ERR,
  92. PVRDMA_WC_REM_ABORT_ERR,
  93. PVRDMA_WC_INV_EECN_ERR,
  94. PVRDMA_WC_INV_EEC_STATE_ERR,
  95. PVRDMA_WC_FATAL_ERR,
  96. PVRDMA_WC_RESP_TIMEOUT_ERR,
  97. PVRDMA_WC_GENERAL_ERR,
  98. };
  99. enum pvrdma_wc_opcode {
  100. PVRDMA_WC_SEND,
  101. PVRDMA_WC_RDMA_WRITE,
  102. PVRDMA_WC_RDMA_READ,
  103. PVRDMA_WC_COMP_SWAP,
  104. PVRDMA_WC_FETCH_ADD,
  105. PVRDMA_WC_BIND_MW,
  106. PVRDMA_WC_LSO,
  107. PVRDMA_WC_LOCAL_INV,
  108. PVRDMA_WC_FAST_REG_MR,
  109. PVRDMA_WC_MASKED_COMP_SWAP,
  110. PVRDMA_WC_MASKED_FETCH_ADD,
  111. PVRDMA_WC_RECV = 1 << 7,
  112. PVRDMA_WC_RECV_RDMA_WITH_IMM,
  113. };
  114. enum pvrdma_wc_flags {
  115. PVRDMA_WC_GRH = 1 << 0,
  116. PVRDMA_WC_WITH_IMM = 1 << 1,
  117. PVRDMA_WC_WITH_INVALIDATE = 1 << 2,
  118. PVRDMA_WC_IP_CSUM_OK = 1 << 3,
  119. PVRDMA_WC_WITH_SMAC = 1 << 4,
  120. PVRDMA_WC_WITH_VLAN = 1 << 5,
  121. PVRDMA_WC_FLAGS_MAX = PVRDMA_WC_WITH_VLAN,
  122. };
  123. struct pvrdma_alloc_ucontext_resp {
  124. __u32 qp_tab_size;
  125. __u32 reserved;
  126. };
  127. struct pvrdma_alloc_pd_resp {
  128. __u32 pdn;
  129. __u32 reserved;
  130. };
  131. struct pvrdma_create_cq {
  132. __u64 buf_addr;
  133. __u32 buf_size;
  134. __u32 reserved;
  135. };
  136. struct pvrdma_create_cq_resp {
  137. __u32 cqn;
  138. __u32 reserved;
  139. };
  140. struct pvrdma_resize_cq {
  141. __u64 buf_addr;
  142. __u32 buf_size;
  143. __u32 reserved;
  144. };
  145. struct pvrdma_create_srq {
  146. __u64 buf_addr;
  147. };
  148. struct pvrdma_create_srq_resp {
  149. __u32 srqn;
  150. __u32 reserved;
  151. };
  152. struct pvrdma_create_qp {
  153. __u64 rbuf_addr;
  154. __u64 sbuf_addr;
  155. __u32 rbuf_size;
  156. __u32 sbuf_size;
  157. __u64 qp_addr;
  158. };
  159. /* PVRDMA masked atomic compare and swap */
  160. struct pvrdma_ex_cmp_swap {
  161. __u64 swap_val;
  162. __u64 compare_val;
  163. __u64 swap_mask;
  164. __u64 compare_mask;
  165. };
  166. /* PVRDMA masked atomic fetch and add */
  167. struct pvrdma_ex_fetch_add {
  168. __u64 add_val;
  169. __u64 field_boundary;
  170. };
  171. /* PVRDMA address vector. */
  172. struct pvrdma_av {
  173. __u32 port_pd;
  174. __u32 sl_tclass_flowlabel;
  175. __u8 dgid[16];
  176. __u8 src_path_bits;
  177. __u8 gid_index;
  178. __u8 stat_rate;
  179. __u8 hop_limit;
  180. __u8 dmac[6];
  181. __u8 reserved[6];
  182. };
  183. /* PVRDMA scatter/gather entry */
  184. struct pvrdma_sge {
  185. __u64 addr;
  186. __u32 length;
  187. __u32 lkey;
  188. };
  189. /* PVRDMA receive queue work request */
  190. struct pvrdma_rq_wqe_hdr {
  191. __u64 wr_id; /* wr id */
  192. __u32 num_sge; /* size of s/g array */
  193. __u32 total_len; /* reserved */
  194. };
  195. /* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */
  196. /* PVRDMA send queue work request */
  197. struct pvrdma_sq_wqe_hdr {
  198. __u64 wr_id; /* wr id */
  199. __u32 num_sge; /* size of s/g array */
  200. __u32 total_len; /* reserved */
  201. __u32 opcode; /* operation type */
  202. __u32 send_flags; /* wr flags */
  203. union {
  204. __u32 imm_data;
  205. __u32 invalidate_rkey;
  206. } ex;
  207. __u32 reserved;
  208. union {
  209. struct {
  210. __u64 remote_addr;
  211. __u32 rkey;
  212. __u8 reserved[4];
  213. } rdma;
  214. struct {
  215. __u64 remote_addr;
  216. __u64 compare_add;
  217. __u64 swap;
  218. __u32 rkey;
  219. __u32 reserved;
  220. } atomic;
  221. struct {
  222. __u64 remote_addr;
  223. __u32 log_arg_sz;
  224. __u32 rkey;
  225. union {
  226. struct pvrdma_ex_cmp_swap cmp_swap;
  227. struct pvrdma_ex_fetch_add fetch_add;
  228. } wr_data;
  229. } masked_atomics;
  230. struct {
  231. __u64 iova_start;
  232. __u64 pl_pdir_dma;
  233. __u32 page_shift;
  234. __u32 page_list_len;
  235. __u32 length;
  236. __u32 access_flags;
  237. __u32 rkey;
  238. } fast_reg;
  239. struct {
  240. __u32 remote_qpn;
  241. __u32 remote_qkey;
  242. struct pvrdma_av av;
  243. } ud;
  244. } wr;
  245. };
  246. /* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */
  247. /* Completion queue element. */
  248. struct pvrdma_cqe {
  249. __u64 wr_id;
  250. __u64 qp;
  251. __u32 opcode;
  252. __u32 status;
  253. __u32 byte_len;
  254. __u32 imm_data;
  255. __u32 src_qp;
  256. __u32 wc_flags;
  257. __u32 vendor_err;
  258. __u16 pkey_index;
  259. __u16 slid;
  260. __u8 sl;
  261. __u8 dlid_path_bits;
  262. __u8 port_num;
  263. __u8 smac[6];
  264. __u8 reserved2[7]; /* Pad to next power of 2 (64). */
  265. };
  266. #endif /* __VMW_PVRDMA_ABI_H__ */