vmw_pvrdma-abi.h 7.8 KB

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