rdma_user_cm.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. __u32 ibdev_index;
  149. __u32 reserved1;
  150. };
  151. struct rdma_ucm_query_addr_resp {
  152. __aligned_u64 node_guid;
  153. __u8 port_num;
  154. __u8 reserved;
  155. __u16 pkey;
  156. __u16 src_size;
  157. __u16 dst_size;
  158. struct __kernel_sockaddr_storage src_addr;
  159. struct __kernel_sockaddr_storage dst_addr;
  160. __u32 ibdev_index;
  161. __u32 reserved1;
  162. };
  163. struct rdma_ucm_query_path_resp {
  164. __u32 num_paths;
  165. __u32 reserved;
  166. struct ib_path_rec_data path_data[];
  167. };
  168. struct rdma_ucm_conn_param {
  169. __u32 qp_num;
  170. __u32 qkey;
  171. __u8 private_data[RDMA_MAX_PRIVATE_DATA];
  172. __u8 private_data_len;
  173. __u8 srq;
  174. __u8 responder_resources;
  175. __u8 initiator_depth;
  176. __u8 flow_control;
  177. __u8 retry_count;
  178. __u8 rnr_retry_count;
  179. __u8 valid;
  180. };
  181. struct rdma_ucm_ud_param {
  182. __u32 qp_num;
  183. __u32 qkey;
  184. struct ib_uverbs_ah_attr ah_attr;
  185. __u8 private_data[RDMA_MAX_PRIVATE_DATA];
  186. __u8 private_data_len;
  187. __u8 reserved[7];
  188. };
  189. struct rdma_ucm_ece {
  190. __u32 vendor_id;
  191. __u32 attr_mod;
  192. };
  193. struct rdma_ucm_connect {
  194. struct rdma_ucm_conn_param conn_param;
  195. __u32 id;
  196. __u32 reserved;
  197. struct rdma_ucm_ece ece;
  198. };
  199. struct rdma_ucm_listen {
  200. __u32 id;
  201. __u32 backlog;
  202. };
  203. struct rdma_ucm_accept {
  204. __aligned_u64 uid;
  205. struct rdma_ucm_conn_param conn_param;
  206. __u32 id;
  207. __u32 reserved;
  208. struct rdma_ucm_ece ece;
  209. };
  210. struct rdma_ucm_reject {
  211. __u32 id;
  212. __u8 private_data_len;
  213. __u8 reason;
  214. __u8 reserved[2];
  215. __u8 private_data[RDMA_MAX_PRIVATE_DATA];
  216. };
  217. struct rdma_ucm_disconnect {
  218. __u32 id;
  219. };
  220. struct rdma_ucm_init_qp_attr {
  221. __aligned_u64 response;
  222. __u32 id;
  223. __u32 qp_state;
  224. };
  225. struct rdma_ucm_notify {
  226. __u32 id;
  227. __u32 event;
  228. };
  229. struct rdma_ucm_join_ip_mcast {
  230. __aligned_u64 response; /* rdma_ucm_create_id_resp */
  231. __aligned_u64 uid;
  232. struct sockaddr_in6 addr;
  233. __u32 id;
  234. };
  235. /* Multicast join flags */
  236. enum {
  237. RDMA_MC_JOIN_FLAG_FULLMEMBER,
  238. RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER,
  239. RDMA_MC_JOIN_FLAG_RESERVED,
  240. };
  241. struct rdma_ucm_join_mcast {
  242. __aligned_u64 response; /* rdma_ucma_create_id_resp */
  243. __aligned_u64 uid;
  244. __u32 id;
  245. __u16 addr_size;
  246. __u16 join_flags;
  247. struct __kernel_sockaddr_storage addr;
  248. };
  249. struct rdma_ucm_get_event {
  250. __aligned_u64 response;
  251. };
  252. struct rdma_ucm_event_resp {
  253. __aligned_u64 uid;
  254. __u32 id;
  255. __u32 event;
  256. __u32 status;
  257. /*
  258. * NOTE: This union is not aligned to 8 bytes so none of the union
  259. * members may contain a u64 or anything with higher alignment than 4.
  260. */
  261. union {
  262. struct rdma_ucm_conn_param conn;
  263. struct rdma_ucm_ud_param ud;
  264. } param;
  265. __u32 reserved;
  266. struct rdma_ucm_ece ece;
  267. };
  268. /* Option levels */
  269. enum {
  270. RDMA_OPTION_ID = 0,
  271. RDMA_OPTION_IB = 1
  272. };
  273. /* Option details */
  274. enum {
  275. RDMA_OPTION_ID_TOS = 0,
  276. RDMA_OPTION_ID_REUSEADDR = 1,
  277. RDMA_OPTION_ID_AFONLY = 2,
  278. RDMA_OPTION_ID_ACK_TIMEOUT = 3
  279. };
  280. enum {
  281. RDMA_OPTION_IB_PATH = 1
  282. };
  283. struct rdma_ucm_set_option {
  284. __aligned_u64 optval;
  285. __u32 id;
  286. __u32 level;
  287. __u32 optname;
  288. __u32 optlen;
  289. };
  290. struct rdma_ucm_migrate_id {
  291. __aligned_u64 response;
  292. __u32 id;
  293. __u32 fd;
  294. };
  295. struct rdma_ucm_migrate_resp {
  296. __u32 events_reported;
  297. };
  298. #endif /* RDMA_USER_CM_H */