Blame view

include/rdma/rdma_cm.h 11.7 KB
e51060f08   Sean Hefty   IB: IP address ba...
1
2
3
4
  /*
   * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
   * Copyright (c) 2005 Intel Corporation.  All rights reserved.
   *
a94749170   Sean Hefty   RDMA: Fix license...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
   * This software is available to you under a choice of one of two
   * licenses.  You may choose to be licensed under the terms of the GNU
   * General Public License (GPL) Version 2, available from the file
   * COPYING in the main directory of this source tree, or the
   * OpenIB.org BSD license below:
   *
   *     Redistribution and use in source and binary forms, with or
   *     without modification, are permitted provided that the following
   *     conditions are met:
   *
   *      - Redistributions of source code must retain the above
   *        copyright notice, this list of conditions and the following
   *        disclaimer.
   *
   *      - Redistributions in binary form must reproduce the above
   *        copyright notice, this list of conditions and the following
   *        disclaimer in the documentation and/or other materials
   *        provided with the distribution.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   * SOFTWARE.
e51060f08   Sean Hefty   IB: IP address ba...
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
   */
  
  #if !defined(RDMA_CM_H)
  #define RDMA_CM_H
  
  #include <linux/socket.h>
  #include <linux/in6.h>
  #include <rdma/ib_addr.h>
  #include <rdma/ib_sa.h>
  
  /*
   * Upon receiving a device removal event, users must destroy the associated
   * RDMA identifier and release all resources allocated with the device.
   */
  enum rdma_cm_event_type {
  	RDMA_CM_EVENT_ADDR_RESOLVED,
  	RDMA_CM_EVENT_ADDR_ERROR,
  	RDMA_CM_EVENT_ROUTE_RESOLVED,
  	RDMA_CM_EVENT_ROUTE_ERROR,
  	RDMA_CM_EVENT_CONNECT_REQUEST,
  	RDMA_CM_EVENT_CONNECT_RESPONSE,
  	RDMA_CM_EVENT_CONNECT_ERROR,
  	RDMA_CM_EVENT_UNREACHABLE,
  	RDMA_CM_EVENT_REJECTED,
  	RDMA_CM_EVENT_ESTABLISHED,
  	RDMA_CM_EVENT_DISCONNECTED,
  	RDMA_CM_EVENT_DEVICE_REMOVAL,
c8f6a362b   Sean Hefty   RDMA/cma: Add mul...
59
  	RDMA_CM_EVENT_MULTICAST_JOIN,
dd5bdff83   Or Gerlitz   RDMA/cma: Add RDM...
60
  	RDMA_CM_EVENT_MULTICAST_ERROR,
38ca83a58   Amir Vadai   RDMA/cma: Add RDM...
61
62
  	RDMA_CM_EVENT_ADDR_CHANGE,
  	RDMA_CM_EVENT_TIMEWAIT_EXIT
e51060f08   Sean Hefty   IB: IP address ba...
63
64
65
  };
  
  enum rdma_port_space {
4deccd6d9   Dotan Barak   RDMA: Improve inc...
66
67
  	RDMA_PS_SDP   = 0x0001,
  	RDMA_PS_IPOIB = 0x0002,
2d2e94152   Sean Hefty   RDMA/cm: Define n...
68
  	RDMA_PS_IB    = 0x013F,
4deccd6d9   Dotan Barak   RDMA: Improve inc...
69
70
  	RDMA_PS_TCP   = 0x0106,
  	RDMA_PS_UDP   = 0x0111,
e51060f08   Sean Hefty   IB: IP address ba...
71
72
73
  };
  
  struct rdma_addr {
3f4467543   Roland Dreier   RDMA/cma: Remove ...
74
75
  	struct sockaddr_storage src_addr;
  	struct sockaddr_storage dst_addr;
e51060f08   Sean Hefty   IB: IP address ba...
76
77
78
79
80
81
82
83
  	struct rdma_dev_addr dev_addr;
  };
  
  struct rdma_route {
  	struct rdma_addr addr;
  	struct ib_sa_path_rec *path_rec;
  	int num_paths;
  };
a1b1b61f8   Sean Hefty   RDMA/cma: Report ...
84
85
86
87
88
89
90
91
92
93
94
95
  struct rdma_conn_param {
  	const void *private_data;
  	u8 private_data_len;
  	u8 responder_resources;
  	u8 initiator_depth;
  	u8 flow_control;
  	u8 retry_count;		/* ignored when accepting */
  	u8 rnr_retry_count;
  	/* Fields below ignored if a QP is created on the rdma_cm_id. */
  	u8 srq;
  	u32 qp_num;
  };
628e5f6d3   Sean Hefty   RDMA/cma: Add sup...
96
97
98
99
100
101
102
  struct rdma_ud_param {
  	const void *private_data;
  	u8 private_data_len;
  	struct ib_ah_attr ah_attr;
  	u32 qp_num;
  	u32 qkey;
  };
e51060f08   Sean Hefty   IB: IP address ba...
103
104
105
  struct rdma_cm_event {
  	enum rdma_cm_event_type	 event;
  	int			 status;
a1b1b61f8   Sean Hefty   RDMA/cma: Report ...
106
107
  	union {
  		struct rdma_conn_param	conn;
628e5f6d3   Sean Hefty   RDMA/cma: Add sup...
108
  		struct rdma_ud_param	ud;
a1b1b61f8   Sean Hefty   RDMA/cma: Report ...
109
  	} param;
e51060f08   Sean Hefty   IB: IP address ba...
110
  };
550e5ca77   Nir Muchtar   RDMA/cma: Export ...
111
112
113
114
115
116
117
118
119
120
121
122
123
  enum rdma_cm_state {
  	RDMA_CM_IDLE,
  	RDMA_CM_ADDR_QUERY,
  	RDMA_CM_ADDR_RESOLVED,
  	RDMA_CM_ROUTE_QUERY,
  	RDMA_CM_ROUTE_RESOLVED,
  	RDMA_CM_CONNECT,
  	RDMA_CM_DISCONNECT,
  	RDMA_CM_ADDR_BOUND,
  	RDMA_CM_LISTEN,
  	RDMA_CM_DEVICE_REMOVAL,
  	RDMA_CM_DESTROYING
  };
e51060f08   Sean Hefty   IB: IP address ba...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  struct rdma_cm_id;
  
  /**
   * rdma_cm_event_handler - Callback used to report user events.
   *
   * Notes: Users may not call rdma_destroy_id from this callback to destroy
   *   the passed in id, or a corresponding listen id.  Returning a
   *   non-zero value from the callback will destroy the passed in id.
   */
  typedef int (*rdma_cm_event_handler)(struct rdma_cm_id *id,
  				     struct rdma_cm_event *event);
  
  struct rdma_cm_id {
  	struct ib_device	*device;
  	void			*context;
  	struct ib_qp		*qp;
  	rdma_cm_event_handler	 event_handler;
  	struct rdma_route	 route;
  	enum rdma_port_space	 ps;
b26f9b994   Sean Hefty   RDMA/cma: Pass QP...
143
  	enum ib_qp_type		 qp_type;
e51060f08   Sean Hefty   IB: IP address ba...
144
145
146
147
148
149
150
151
152
153
  	u8			 port_num;
  };
  
  /**
   * rdma_create_id - Create an RDMA identifier.
   *
   * @event_handler: User callback invoked to report events associated with the
   *   returned rdma_id.
   * @context: User specified context associated with the id.
   * @ps: RDMA port space.
b26f9b994   Sean Hefty   RDMA/cma: Pass QP...
154
   * @qp_type: type of queue pair associated with the id.
e51060f08   Sean Hefty   IB: IP address ba...
155
156
   */
  struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
b26f9b994   Sean Hefty   RDMA/cma: Pass QP...
157
158
  				  void *context, enum rdma_port_space ps,
  				  enum ib_qp_type qp_type);
e51060f08   Sean Hefty   IB: IP address ba...
159

07eeec062   Or Gerlitz   RDMA/cma: Documen...
160
161
162
163
164
165
166
167
  /**
    * rdma_destroy_id - Destroys an RDMA identifier.
    *
    * @id: RDMA identifier.
    *
    * Note: calling this function has the effect of canceling in-flight
    * asynchronous operations associated with the id.
    */
e51060f08   Sean Hefty   IB: IP address ba...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
  void rdma_destroy_id(struct rdma_cm_id *id);
  
  /**
   * rdma_bind_addr - Bind an RDMA identifier to a source address and
   *   associated RDMA device, if needed.
   *
   * @id: RDMA identifier.
   * @addr: Local address information.  Wildcard values are permitted.
   *
   * This associates a source address with the RDMA identifier before calling
   * rdma_listen.  If a specific local address is given, the RDMA identifier will
   * be bound to a local RDMA device.
   */
  int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
  
  /**
   * rdma_resolve_addr - Resolve destination and optional source addresses
   *   from IP addresses to an RDMA address.  If successful, the specified
   *   rdma_cm_id will be bound to a local device.
   *
   * @id: RDMA identifier.
   * @src_addr: Source address information.  This parameter may be NULL.
   * @dst_addr: Destination address information.
   * @timeout_ms: Time to wait for resolution to complete.
   */
  int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
  		      struct sockaddr *dst_addr, int timeout_ms);
  
  /**
   * rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier
   *   into route information needed to establish a connection.
   *
   * This is called on the client side of a connection.
   * Users must have first called rdma_resolve_addr to resolve a dst_addr
   * into an RDMA address before calling this routine.
   */
  int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);
  
  /**
   * rdma_create_qp - Allocate a QP and associate it with the specified RDMA
   * identifier.
   *
   * QPs allocated to an rdma_cm_id will automatically be transitioned by the CMA
   * through their states.
   */
  int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
  		   struct ib_qp_init_attr *qp_init_attr);
  
  /**
   * rdma_destroy_qp - Deallocate the QP associated with the specified RDMA
   * identifier.
   *
   * Users must destroy any QP associated with an RDMA identifier before
   * destroying the RDMA ID.
   */
  void rdma_destroy_qp(struct rdma_cm_id *id);
  
  /**
   * rdma_init_qp_attr - Initializes the QP attributes for use in transitioning
   *   to a specified QP state.
   * @id: Communication identifier associated with the QP attributes to
   *   initialize.
   * @qp_attr: On input, specifies the desired QP state.  On output, the
   *   mandatory and desired optional attributes will be set in order to
   *   modify the QP to the specified state.
   * @qp_attr_mask: The QP attribute mask that may be used to transition the
   *   QP to the specified state.
   *
   * Users must set the @qp_attr->qp_state to the desired QP state.  This call
   * will set all required attributes for the given transition, along with
   * known optional attributes.  Users may override the attributes returned from
   * this call before calling ib_modify_qp.
   *
   * Users that wish to have their QP automatically transitioned through its
   * states can associate a QP with the rdma_cm_id by calling rdma_create_qp().
   */
  int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
  		       int *qp_attr_mask);
e51060f08   Sean Hefty   IB: IP address ba...
246
247
  /**
   * rdma_connect - Initiate an active connection request.
628e5f6d3   Sean Hefty   RDMA/cma: Add sup...
248
249
   * @id: Connection identifier to connect.
   * @conn_param: Connection information used for connected QPs.
e51060f08   Sean Hefty   IB: IP address ba...
250
251
252
   *
   * Users must have resolved a route for the rdma_cm_id to connect with
   * by having called rdma_resolve_route before calling this routine.
628e5f6d3   Sean Hefty   RDMA/cma: Add sup...
253
254
255
256
   *
   * This call will either connect to a remote QP or obtain remote QP
   * information for unconnected rdma_cm_id's.  The actual operation is
   * based on the rdma_cm_id's port space.
e51060f08   Sean Hefty   IB: IP address ba...
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
   */
  int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
  
  /**
   * rdma_listen - This function is called by the passive side to
   *   listen for incoming connection requests.
   *
   * Users must have bound the rdma_cm_id to a local address by calling
   * rdma_bind_addr before calling this routine.
   */
  int rdma_listen(struct rdma_cm_id *id, int backlog);
  
  /**
   * rdma_accept - Called to accept a connection request or response.
   * @id: Connection identifier associated with the request.
   * @conn_param: Information needed to establish the connection.  This must be
   *   provided if accepting a connection request.  If accepting a connection
   *   response, this parameter must be NULL.
   *
   * Typically, this routine is only called by the listener to accept a connection
   * request.  It must also be called on the active side of a connection if the
   * user is performing their own QP transitions.
951f7fc13   Or Gerlitz   RDMA/cma: Documen...
279
280
281
282
   *
   * In the case of error, a reject message is sent to the remote side and the
   * state of the qp associated with the id is modified to error, such that any
   * previously posted receive buffers would be flushed.
e51060f08   Sean Hefty   IB: IP address ba...
283
284
285
286
   */
  int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
  
  /**
0fe313b00   Sean Hefty   RDMA/cma: Allow e...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
   * rdma_notify - Notifies the RDMA CM of an asynchronous event that has
   * occurred on the connection.
   * @id: Connection identifier to transition to established.
   * @event: Asynchronous event.
   *
   * This routine should be invoked by users to notify the CM of relevant
   * communication events.  Events that should be reported to the CM and
   * when to report them are:
   *
   * IB_EVENT_COMM_EST - Used when a message is received on a connected
   *    QP before an RTU has been received.
   */
  int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event);
  
  /**
e51060f08   Sean Hefty   IB: IP address ba...
302
303
304
305
306
307
308
309
310
311
   * rdma_reject - Called to reject a connection request or response.
   */
  int rdma_reject(struct rdma_cm_id *id, const void *private_data,
  		u8 private_data_len);
  
  /**
   * rdma_disconnect - This function disconnects the associated QP and
   *   transitions it into the error state.
   */
  int rdma_disconnect(struct rdma_cm_id *id);
c8f6a362b   Sean Hefty   RDMA/cma: Add mul...
312
313
314
315
316
317
318
319
320
321
  /**
   * rdma_join_multicast - Join the multicast group specified by the given
   *   address.
   * @id: Communication identifier associated with the request.
   * @addr: Multicast address identifying the group to join.
   * @context: User-defined context associated with the join request, returned
   * to the user through the private_data pointer in multicast events.
   */
  int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
  			void *context);
e51060f08   Sean Hefty   IB: IP address ba...
322

c8f6a362b   Sean Hefty   RDMA/cma: Add mul...
323
324
325
326
327
  /**
   * rdma_leave_multicast - Leave the multicast group specified by the given
   *   address.
   */
  void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
a81c994d5   Sean Hefty   RDMA/cma: Add abi...
328
329
330
331
332
333
334
335
336
337
338
339
340
  /**
   * rdma_set_service_type - Set the type of service associated with a
   *   connection identifier.
   * @id: Communication identifier to associated with service type.
   * @tos: Type of service.
   *
   * The type of service is interpretted as a differentiated service
   * field (RFC 2474).  The service type should be specified before
   * performing route resolution, as existing communication on the
   * connection identifier may be unaffected.  The type of service
   * requested may not be supported by the network to all destinations.
   */
  void rdma_set_service_type(struct rdma_cm_id *id, int tos);
a9bb79128   Hefty, Sean   RDMA/cma: Add an ...
341
342
343
344
345
346
347
348
349
  /**
   * rdma_set_reuseaddr - Allow the reuse of local addresses when binding
   *    the rdma_cm_id.
   * @id: Communication identifier to configure.
   * @reuse: Value indicating if the bound address is reusable.
   *
   * Reuse must be set before an address is bound to the id.
   */
  int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse);
c8f6a362b   Sean Hefty   RDMA/cma: Add mul...
350
  #endif /* RDMA_CM_H */