rdma_user_cm.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
  2. /*
  3. * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #ifndef RDMA_USER_CM_H
  34. #define RDMA_USER_CM_H
  35. #include <linux/types.h>
  36. #include <linux/socket.h>
  37. #include <linux/in6.h>
  38. #include <rdma/ib_user_verbs.h>
  39. #include <rdma/ib_user_sa.h>
  40. #define RDMA_USER_CM_ABI_VERSION 4
  41. #define RDMA_MAX_PRIVATE_DATA 256
  42. enum {
  43. RDMA_USER_CM_CMD_CREATE_ID,
  44. RDMA_USER_CM_CMD_DESTROY_ID,
  45. RDMA_USER_CM_CMD_BIND_IP,
  46. RDMA_USER_CM_CMD_RESOLVE_IP,
  47. RDMA_USER_CM_CMD_RESOLVE_ROUTE,
  48. RDMA_USER_CM_CMD_QUERY_ROUTE,
  49. RDMA_USER_CM_CMD_CONNECT,
  50. RDMA_USER_CM_CMD_LISTEN,
  51. RDMA_USER_CM_CMD_ACCEPT,
  52. RDMA_USER_CM_CMD_REJECT,
  53. RDMA_USER_CM_CMD_DISCONNECT,
  54. RDMA_USER_CM_CMD_INIT_QP_ATTR,
  55. RDMA_USER_CM_CMD_GET_EVENT,
  56. RDMA_USER_CM_CMD_GET_OPTION,
  57. RDMA_USER_CM_CMD_SET_OPTION,
  58. RDMA_USER_CM_CMD_NOTIFY,
  59. RDMA_USER_CM_CMD_JOIN_IP_MCAST,
  60. RDMA_USER_CM_CMD_LEAVE_MCAST,
  61. RDMA_USER_CM_CMD_MIGRATE_ID,
  62. RDMA_USER_CM_CMD_QUERY,
  63. RDMA_USER_CM_CMD_BIND,
  64. RDMA_USER_CM_CMD_RESOLVE_ADDR,
  65. RDMA_USER_CM_CMD_JOIN_MCAST
  66. };
  67. /* See IBTA Annex A11, servies ID bytes 4 & 5 */
  68. enum rdma_ucm_port_space {
  69. RDMA_PS_IPOIB = 0x0002,
  70. RDMA_PS_IB = 0x013F,
  71. RDMA_PS_TCP = 0x0106,
  72. RDMA_PS_UDP = 0x0111,
  73. };
  74. /*
  75. * command ABI structures.
  76. */
  77. struct rdma_ucm_cmd_hdr {
  78. __u32 cmd;
  79. __u16 in;
  80. __u16 out;
  81. };
  82. struct rdma_ucm_create_id {
  83. __aligned_u64 uid;
  84. __aligned_u64 response;
  85. __u16 ps; /* use enum rdma_ucm_port_space */
  86. __u8 qp_type;
  87. __u8 reserved[5];
  88. };
  89. struct rdma_ucm_create_id_resp {
  90. __u32 id;
  91. };
  92. struct rdma_ucm_destroy_id {
  93. __aligned_u64 response;
  94. __u32 id;
  95. __u32 reserved;
  96. };
  97. struct rdma_ucm_destroy_id_resp {
  98. __u32 events_reported;
  99. };
  100. struct rdma_ucm_bind_ip {
  101. __aligned_u64 response;
  102. struct sockaddr_in6 addr;
  103. __u32 id;
  104. };
  105. struct rdma_ucm_bind {
  106. __u32 id;
  107. __u16 addr_size;
  108. __u16 reserved;
  109. struct __kernel_sockaddr_storage addr;
  110. };
  111. struct rdma_ucm_resolve_ip {
  112. struct sockaddr_in6 src_addr;
  113. struct sockaddr_in6 dst_addr;
  114. __u32 id;
  115. __u32 timeout_ms;
  116. };
  117. struct rdma_ucm_resolve_addr {
  118. __u32 id;
  119. __u32 timeout_ms;
  120. __u16 src_size;
  121. __u16 dst_size;
  122. __u32 reserved;
  123. struct __kernel_sockaddr_storage src_addr;
  124. struct __kernel_sockaddr_storage dst_addr;
  125. };
  126. struct rdma_ucm_resolve_route {
  127. __u32 id;
  128. __u32 timeout_ms;
  129. };
  130. enum {
  131. RDMA_USER_CM_QUERY_ADDR,
  132. RDMA_USER_CM_QUERY_PATH,
  133. RDMA_USER_CM_QUERY_GID
  134. };
  135. struct rdma_ucm_query {
  136. __aligned_u64 response;
  137. __u32 id;
  138. __u32 option;
  139. };
  140. struct rdma_ucm_query_route_resp {
  141. __aligned_u64 node_guid;
  142. struct ib_user_path_rec ib_route[2];
  143. struct sockaddr_in6 src_addr;
  144. struct sockaddr_in6 dst_addr;
  145. __u32 num_paths;
  146. __u8 port_num;
  147. __u8 reserved[3];
  148. };
  149. struct rdma_ucm_query_addr_resp {
  150. __aligned_u64 node_guid;
  151. __u8 port_num;
  152. __u8 reserved;
  153. __u16 pkey;
  154. __u16 src_size;
  155. __u16 dst_size;
  156. struct __kernel_sockaddr_storage src_addr;
  157. struct __kernel_sockaddr_storage dst_addr;
  158. };
  159. struct rdma_ucm_query_path_resp {
  160. __u32 num_paths;
  161. __u32 reserved;
  162. struct ib_path_rec_data path_data[0];
  163. };
  164. struct rdma_ucm_conn_param {
  165. __u32 qp_num;
  166. __u32 qkey;
  167. __u8 private_data[RDMA_MAX_PRIVATE_DATA];
  168. __u8 private_data_len;
  169. __u8 srq;
  170. __u8 responder_resources;
  171. __u8 initiator_depth;
  172. __u8 flow_control;
  173. __u8 retry_count;
  174. __u8 rnr_retry_count;
  175. __u8 valid;
  176. };
  177. struct rdma_ucm_ud_param {
  178. __u32 qp_num;
  179. __u32 qkey;
  180. struct ib_uverbs_ah_attr ah_attr;
  181. __u8 private_data[RDMA_MAX_PRIVATE_DATA];
  182. __u8 private_data_len;
  183. __u8 reserved[7];
  184. };
  185. struct rdma_ucm_connect {
  186. struct rdma_ucm_conn_param conn_param;
  187. __u32 id;
  188. __u32 reserved;
  189. };
  190. struct rdma_ucm_listen {
  191. __u32 id;
  192. __u32 backlog;
  193. };
  194. struct rdma_ucm_accept {
  195. __aligned_u64 uid;
  196. struct rdma_ucm_conn_param conn_param;
  197. __u32 id;
  198. __u32 reserved;
  199. };
  200. struct rdma_ucm_reject {
  201. __u32 id;
  202. __u8 private_data_len;
  203. __u8 reserved[3];
  204. __u8 private_data[RDMA_MAX_PRIVATE_DATA];
  205. };
  206. struct rdma_ucm_disconnect {
  207. __u32 id;
  208. };
  209. struct rdma_ucm_init_qp_attr {
  210. __aligned_u64 response;
  211. __u32 id;
  212. __u32 qp_state;
  213. };
  214. struct rdma_ucm_notify {
  215. __u32 id;
  216. __u32 event;
  217. };
  218. struct rdma_ucm_join_ip_mcast {
  219. __aligned_u64 response; /* rdma_ucm_create_id_resp */
  220. __aligned_u64 uid;
  221. struct sockaddr_in6 addr;
  222. __u32 id;
  223. };
  224. /* Multicast join flags */
  225. enum {
  226. RDMA_MC_JOIN_FLAG_FULLMEMBER,
  227. RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER,
  228. RDMA_MC_JOIN_FLAG_RESERVED,
  229. };
  230. struct rdma_ucm_join_mcast {
  231. __aligned_u64 response; /* rdma_ucma_create_id_resp */
  232. __aligned_u64 uid;
  233. __u32 id;
  234. __u16 addr_size;
  235. __u16 join_flags;
  236. struct __kernel_sockaddr_storage addr;
  237. };
  238. struct rdma_ucm_get_event {
  239. __aligned_u64 response;
  240. };
  241. struct rdma_ucm_event_resp {
  242. __aligned_u64 uid;
  243. __u32 id;
  244. __u32 event;
  245. __u32 status;
  246. /*
  247. * NOTE: This union is not aligned to 8 bytes so none of the union
  248. * members may contain a u64 or anything with higher alignment than 4.
  249. */
  250. union {
  251. struct rdma_ucm_conn_param conn;
  252. struct rdma_ucm_ud_param ud;
  253. } param;
  254. __u32 reserved;
  255. };
  256. /* Option levels */
  257. enum {
  258. RDMA_OPTION_ID = 0,
  259. RDMA_OPTION_IB = 1
  260. };
  261. /* Option details */
  262. enum {
  263. RDMA_OPTION_ID_TOS = 0,
  264. RDMA_OPTION_ID_REUSEADDR = 1,
  265. RDMA_OPTION_ID_AFONLY = 2,
  266. RDMA_OPTION_IB_PATH = 1
  267. };
  268. struct rdma_ucm_set_option {
  269. __aligned_u64 optval;
  270. __u32 id;
  271. __u32 level;
  272. __u32 optname;
  273. __u32 optlen;
  274. };
  275. struct rdma_ucm_migrate_id {
  276. __aligned_u64 response;
  277. __u32 id;
  278. __u32 fd;
  279. };
  280. struct rdma_ucm_migrate_resp {
  281. __u32 events_reported;
  282. };
  283. #endif /* RDMA_USER_CM_H */