xref: /OK3568_Linux_fs/kernel/include/rdma/rdma_cm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
4*4882a593Smuzhiyun  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef RDMA_CM_H
8*4882a593Smuzhiyun #define RDMA_CM_H
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/socket.h>
11*4882a593Smuzhiyun #include <linux/in6.h>
12*4882a593Smuzhiyun #include <rdma/ib_addr.h>
13*4882a593Smuzhiyun #include <rdma/ib_sa.h>
14*4882a593Smuzhiyun #include <uapi/rdma/rdma_user_cm.h>
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /*
17*4882a593Smuzhiyun  * Upon receiving a device removal event, users must destroy the associated
18*4882a593Smuzhiyun  * RDMA identifier and release all resources allocated with the device.
19*4882a593Smuzhiyun  */
20*4882a593Smuzhiyun enum rdma_cm_event_type {
21*4882a593Smuzhiyun 	RDMA_CM_EVENT_ADDR_RESOLVED,
22*4882a593Smuzhiyun 	RDMA_CM_EVENT_ADDR_ERROR,
23*4882a593Smuzhiyun 	RDMA_CM_EVENT_ROUTE_RESOLVED,
24*4882a593Smuzhiyun 	RDMA_CM_EVENT_ROUTE_ERROR,
25*4882a593Smuzhiyun 	RDMA_CM_EVENT_CONNECT_REQUEST,
26*4882a593Smuzhiyun 	RDMA_CM_EVENT_CONNECT_RESPONSE,
27*4882a593Smuzhiyun 	RDMA_CM_EVENT_CONNECT_ERROR,
28*4882a593Smuzhiyun 	RDMA_CM_EVENT_UNREACHABLE,
29*4882a593Smuzhiyun 	RDMA_CM_EVENT_REJECTED,
30*4882a593Smuzhiyun 	RDMA_CM_EVENT_ESTABLISHED,
31*4882a593Smuzhiyun 	RDMA_CM_EVENT_DISCONNECTED,
32*4882a593Smuzhiyun 	RDMA_CM_EVENT_DEVICE_REMOVAL,
33*4882a593Smuzhiyun 	RDMA_CM_EVENT_MULTICAST_JOIN,
34*4882a593Smuzhiyun 	RDMA_CM_EVENT_MULTICAST_ERROR,
35*4882a593Smuzhiyun 	RDMA_CM_EVENT_ADDR_CHANGE,
36*4882a593Smuzhiyun 	RDMA_CM_EVENT_TIMEWAIT_EXIT
37*4882a593Smuzhiyun };
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event);
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define RDMA_IB_IP_PS_MASK   0xFFFFFFFFFFFF0000ULL
42*4882a593Smuzhiyun #define RDMA_IB_IP_PS_TCP    0x0000000001060000ULL
43*4882a593Smuzhiyun #define RDMA_IB_IP_PS_UDP    0x0000000001110000ULL
44*4882a593Smuzhiyun #define RDMA_IB_IP_PS_IB     0x00000000013F0000ULL
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun struct rdma_addr {
47*4882a593Smuzhiyun 	struct sockaddr_storage src_addr;
48*4882a593Smuzhiyun 	struct sockaddr_storage dst_addr;
49*4882a593Smuzhiyun 	struct rdma_dev_addr dev_addr;
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun struct rdma_route {
53*4882a593Smuzhiyun 	struct rdma_addr addr;
54*4882a593Smuzhiyun 	struct sa_path_rec *path_rec;
55*4882a593Smuzhiyun 	int num_paths;
56*4882a593Smuzhiyun };
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun struct rdma_conn_param {
59*4882a593Smuzhiyun 	const void *private_data;
60*4882a593Smuzhiyun 	u8 private_data_len;
61*4882a593Smuzhiyun 	u8 responder_resources;
62*4882a593Smuzhiyun 	u8 initiator_depth;
63*4882a593Smuzhiyun 	u8 flow_control;
64*4882a593Smuzhiyun 	u8 retry_count;		/* ignored when accepting */
65*4882a593Smuzhiyun 	u8 rnr_retry_count;
66*4882a593Smuzhiyun 	/* Fields below ignored if a QP is created on the rdma_cm_id. */
67*4882a593Smuzhiyun 	u8 srq;
68*4882a593Smuzhiyun 	u32 qp_num;
69*4882a593Smuzhiyun 	u32 qkey;
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun struct rdma_ud_param {
73*4882a593Smuzhiyun 	const void *private_data;
74*4882a593Smuzhiyun 	u8 private_data_len;
75*4882a593Smuzhiyun 	struct rdma_ah_attr ah_attr;
76*4882a593Smuzhiyun 	u32 qp_num;
77*4882a593Smuzhiyun 	u32 qkey;
78*4882a593Smuzhiyun };
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun struct rdma_cm_event {
81*4882a593Smuzhiyun 	enum rdma_cm_event_type	 event;
82*4882a593Smuzhiyun 	int			 status;
83*4882a593Smuzhiyun 	union {
84*4882a593Smuzhiyun 		struct rdma_conn_param	conn;
85*4882a593Smuzhiyun 		struct rdma_ud_param	ud;
86*4882a593Smuzhiyun 	} param;
87*4882a593Smuzhiyun 	struct rdma_ucm_ece ece;
88*4882a593Smuzhiyun };
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun struct rdma_cm_id;
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun /**
93*4882a593Smuzhiyun  * rdma_cm_event_handler - Callback used to report user events.
94*4882a593Smuzhiyun  *
95*4882a593Smuzhiyun  * Notes: Users may not call rdma_destroy_id from this callback to destroy
96*4882a593Smuzhiyun  *   the passed in id, or a corresponding listen id.  Returning a
97*4882a593Smuzhiyun  *   non-zero value from the callback will destroy the passed in id.
98*4882a593Smuzhiyun  */
99*4882a593Smuzhiyun typedef int (*rdma_cm_event_handler)(struct rdma_cm_id *id,
100*4882a593Smuzhiyun 				     struct rdma_cm_event *event);
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun struct rdma_cm_id {
103*4882a593Smuzhiyun 	struct ib_device	*device;
104*4882a593Smuzhiyun 	void			*context;
105*4882a593Smuzhiyun 	struct ib_qp		*qp;
106*4882a593Smuzhiyun 	rdma_cm_event_handler	 event_handler;
107*4882a593Smuzhiyun 	struct rdma_route	 route;
108*4882a593Smuzhiyun 	enum rdma_ucm_port_space ps;
109*4882a593Smuzhiyun 	enum ib_qp_type		 qp_type;
110*4882a593Smuzhiyun 	u8			 port_num;
111*4882a593Smuzhiyun };
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun struct rdma_cm_id *
114*4882a593Smuzhiyun __rdma_create_kernel_id(struct net *net, rdma_cm_event_handler event_handler,
115*4882a593Smuzhiyun 			void *context, enum rdma_ucm_port_space ps,
116*4882a593Smuzhiyun 			enum ib_qp_type qp_type, const char *caller);
117*4882a593Smuzhiyun struct rdma_cm_id *rdma_create_user_id(rdma_cm_event_handler event_handler,
118*4882a593Smuzhiyun 				       void *context,
119*4882a593Smuzhiyun 				       enum rdma_ucm_port_space ps,
120*4882a593Smuzhiyun 				       enum ib_qp_type qp_type);
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun /**
123*4882a593Smuzhiyun  * rdma_create_id - Create an RDMA identifier.
124*4882a593Smuzhiyun  *
125*4882a593Smuzhiyun  * @net: The network namespace in which to create the new id.
126*4882a593Smuzhiyun  * @event_handler: User callback invoked to report events associated with the
127*4882a593Smuzhiyun  *   returned rdma_id.
128*4882a593Smuzhiyun  * @context: User specified context associated with the id.
129*4882a593Smuzhiyun  * @ps: RDMA port space.
130*4882a593Smuzhiyun  * @qp_type: type of queue pair associated with the id.
131*4882a593Smuzhiyun  *
132*4882a593Smuzhiyun  * Returns a new rdma_cm_id. The id holds a reference on the network
133*4882a593Smuzhiyun  * namespace until it is destroyed.
134*4882a593Smuzhiyun  *
135*4882a593Smuzhiyun  * The event handler callback serializes on the id's mutex and is
136*4882a593Smuzhiyun  * allowed to sleep.
137*4882a593Smuzhiyun  */
138*4882a593Smuzhiyun #define rdma_create_id(net, event_handler, context, ps, qp_type)               \
139*4882a593Smuzhiyun 	__rdma_create_kernel_id(net, event_handler, context, ps, qp_type,      \
140*4882a593Smuzhiyun 				KBUILD_MODNAME)
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun /**
143*4882a593Smuzhiyun   * rdma_destroy_id - Destroys an RDMA identifier.
144*4882a593Smuzhiyun   *
145*4882a593Smuzhiyun   * @id: RDMA identifier.
146*4882a593Smuzhiyun   *
147*4882a593Smuzhiyun   * Note: calling this function has the effect of canceling in-flight
148*4882a593Smuzhiyun   * asynchronous operations associated with the id.
149*4882a593Smuzhiyun   */
150*4882a593Smuzhiyun void rdma_destroy_id(struct rdma_cm_id *id);
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun /**
153*4882a593Smuzhiyun  * rdma_bind_addr - Bind an RDMA identifier to a source address and
154*4882a593Smuzhiyun  *   associated RDMA device, if needed.
155*4882a593Smuzhiyun  *
156*4882a593Smuzhiyun  * @id: RDMA identifier.
157*4882a593Smuzhiyun  * @addr: Local address information.  Wildcard values are permitted.
158*4882a593Smuzhiyun  *
159*4882a593Smuzhiyun  * This associates a source address with the RDMA identifier before calling
160*4882a593Smuzhiyun  * rdma_listen.  If a specific local address is given, the RDMA identifier will
161*4882a593Smuzhiyun  * be bound to a local RDMA device.
162*4882a593Smuzhiyun  */
163*4882a593Smuzhiyun int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
164*4882a593Smuzhiyun 
165*4882a593Smuzhiyun /**
166*4882a593Smuzhiyun  * rdma_resolve_addr - Resolve destination and optional source addresses
167*4882a593Smuzhiyun  *   from IP addresses to an RDMA address.  If successful, the specified
168*4882a593Smuzhiyun  *   rdma_cm_id will be bound to a local device.
169*4882a593Smuzhiyun  *
170*4882a593Smuzhiyun  * @id: RDMA identifier.
171*4882a593Smuzhiyun  * @src_addr: Source address information.  This parameter may be NULL.
172*4882a593Smuzhiyun  * @dst_addr: Destination address information.
173*4882a593Smuzhiyun  * @timeout_ms: Time to wait for resolution to complete.
174*4882a593Smuzhiyun  */
175*4882a593Smuzhiyun int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
176*4882a593Smuzhiyun 		      const struct sockaddr *dst_addr,
177*4882a593Smuzhiyun 		      unsigned long timeout_ms);
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun /**
180*4882a593Smuzhiyun  * rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier
181*4882a593Smuzhiyun  *   into route information needed to establish a connection.
182*4882a593Smuzhiyun  *
183*4882a593Smuzhiyun  * This is called on the client side of a connection.
184*4882a593Smuzhiyun  * Users must have first called rdma_resolve_addr to resolve a dst_addr
185*4882a593Smuzhiyun  * into an RDMA address before calling this routine.
186*4882a593Smuzhiyun  */
187*4882a593Smuzhiyun int rdma_resolve_route(struct rdma_cm_id *id, unsigned long timeout_ms);
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun /**
190*4882a593Smuzhiyun  * rdma_create_qp - Allocate a QP and associate it with the specified RDMA
191*4882a593Smuzhiyun  * identifier.
192*4882a593Smuzhiyun  *
193*4882a593Smuzhiyun  * QPs allocated to an rdma_cm_id will automatically be transitioned by the CMA
194*4882a593Smuzhiyun  * through their states.
195*4882a593Smuzhiyun  */
196*4882a593Smuzhiyun int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
197*4882a593Smuzhiyun 		   struct ib_qp_init_attr *qp_init_attr);
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun /**
200*4882a593Smuzhiyun  * rdma_destroy_qp - Deallocate the QP associated with the specified RDMA
201*4882a593Smuzhiyun  * identifier.
202*4882a593Smuzhiyun  *
203*4882a593Smuzhiyun  * Users must destroy any QP associated with an RDMA identifier before
204*4882a593Smuzhiyun  * destroying the RDMA ID.
205*4882a593Smuzhiyun  */
206*4882a593Smuzhiyun void rdma_destroy_qp(struct rdma_cm_id *id);
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun /**
209*4882a593Smuzhiyun  * rdma_init_qp_attr - Initializes the QP attributes for use in transitioning
210*4882a593Smuzhiyun  *   to a specified QP state.
211*4882a593Smuzhiyun  * @id: Communication identifier associated with the QP attributes to
212*4882a593Smuzhiyun  *   initialize.
213*4882a593Smuzhiyun  * @qp_attr: On input, specifies the desired QP state.  On output, the
214*4882a593Smuzhiyun  *   mandatory and desired optional attributes will be set in order to
215*4882a593Smuzhiyun  *   modify the QP to the specified state.
216*4882a593Smuzhiyun  * @qp_attr_mask: The QP attribute mask that may be used to transition the
217*4882a593Smuzhiyun  *   QP to the specified state.
218*4882a593Smuzhiyun  *
219*4882a593Smuzhiyun  * Users must set the @qp_attr->qp_state to the desired QP state.  This call
220*4882a593Smuzhiyun  * will set all required attributes for the given transition, along with
221*4882a593Smuzhiyun  * known optional attributes.  Users may override the attributes returned from
222*4882a593Smuzhiyun  * this call before calling ib_modify_qp.
223*4882a593Smuzhiyun  *
224*4882a593Smuzhiyun  * Users that wish to have their QP automatically transitioned through its
225*4882a593Smuzhiyun  * states can associate a QP with the rdma_cm_id by calling rdma_create_qp().
226*4882a593Smuzhiyun  */
227*4882a593Smuzhiyun int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
228*4882a593Smuzhiyun 		       int *qp_attr_mask);
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
231*4882a593Smuzhiyun int rdma_connect_locked(struct rdma_cm_id *id,
232*4882a593Smuzhiyun 			struct rdma_conn_param *conn_param);
233*4882a593Smuzhiyun 
234*4882a593Smuzhiyun int rdma_connect_ece(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
235*4882a593Smuzhiyun 		     struct rdma_ucm_ece *ece);
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun /**
238*4882a593Smuzhiyun  * rdma_listen - This function is called by the passive side to
239*4882a593Smuzhiyun  *   listen for incoming connection requests.
240*4882a593Smuzhiyun  *
241*4882a593Smuzhiyun  * Users must have bound the rdma_cm_id to a local address by calling
242*4882a593Smuzhiyun  * rdma_bind_addr before calling this routine.
243*4882a593Smuzhiyun  */
244*4882a593Smuzhiyun int rdma_listen(struct rdma_cm_id *id, int backlog);
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
247*4882a593Smuzhiyun 
248*4882a593Smuzhiyun void rdma_lock_handler(struct rdma_cm_id *id);
249*4882a593Smuzhiyun void rdma_unlock_handler(struct rdma_cm_id *id);
250*4882a593Smuzhiyun int rdma_accept_ece(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
251*4882a593Smuzhiyun 		    struct rdma_ucm_ece *ece);
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun /**
254*4882a593Smuzhiyun  * rdma_notify - Notifies the RDMA CM of an asynchronous event that has
255*4882a593Smuzhiyun  * occurred on the connection.
256*4882a593Smuzhiyun  * @id: Connection identifier to transition to established.
257*4882a593Smuzhiyun  * @event: Asynchronous event.
258*4882a593Smuzhiyun  *
259*4882a593Smuzhiyun  * This routine should be invoked by users to notify the CM of relevant
260*4882a593Smuzhiyun  * communication events.  Events that should be reported to the CM and
261*4882a593Smuzhiyun  * when to report them are:
262*4882a593Smuzhiyun  *
263*4882a593Smuzhiyun  * IB_EVENT_COMM_EST - Used when a message is received on a connected
264*4882a593Smuzhiyun  *    QP before an RTU has been received.
265*4882a593Smuzhiyun  */
266*4882a593Smuzhiyun int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event);
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun /**
269*4882a593Smuzhiyun  * rdma_reject - Called to reject a connection request or response.
270*4882a593Smuzhiyun  */
271*4882a593Smuzhiyun int rdma_reject(struct rdma_cm_id *id, const void *private_data,
272*4882a593Smuzhiyun 		u8 private_data_len, u8 reason);
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun /**
275*4882a593Smuzhiyun  * rdma_disconnect - This function disconnects the associated QP and
276*4882a593Smuzhiyun  *   transitions it into the error state.
277*4882a593Smuzhiyun  */
278*4882a593Smuzhiyun int rdma_disconnect(struct rdma_cm_id *id);
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun /**
281*4882a593Smuzhiyun  * rdma_join_multicast - Join the multicast group specified by the given
282*4882a593Smuzhiyun  *   address.
283*4882a593Smuzhiyun  * @id: Communication identifier associated with the request.
284*4882a593Smuzhiyun  * @addr: Multicast address identifying the group to join.
285*4882a593Smuzhiyun  * @join_state: Multicast JoinState bitmap requested by port.
286*4882a593Smuzhiyun  *		Bitmap is based on IB_SA_MCMEMBER_REC_JOIN_STATE bits.
287*4882a593Smuzhiyun  * @context: User-defined context associated with the join request, returned
288*4882a593Smuzhiyun  * to the user through the private_data pointer in multicast events.
289*4882a593Smuzhiyun  */
290*4882a593Smuzhiyun int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
291*4882a593Smuzhiyun 			u8 join_state, void *context);
292*4882a593Smuzhiyun 
293*4882a593Smuzhiyun /**
294*4882a593Smuzhiyun  * rdma_leave_multicast - Leave the multicast group specified by the given
295*4882a593Smuzhiyun  *   address.
296*4882a593Smuzhiyun  */
297*4882a593Smuzhiyun void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun /**
300*4882a593Smuzhiyun  * rdma_set_service_type - Set the type of service associated with a
301*4882a593Smuzhiyun  *   connection identifier.
302*4882a593Smuzhiyun  * @id: Communication identifier to associated with service type.
303*4882a593Smuzhiyun  * @tos: Type of service.
304*4882a593Smuzhiyun  *
305*4882a593Smuzhiyun  * The type of service is interpretted as a differentiated service
306*4882a593Smuzhiyun  * field (RFC 2474).  The service type should be specified before
307*4882a593Smuzhiyun  * performing route resolution, as existing communication on the
308*4882a593Smuzhiyun  * connection identifier may be unaffected.  The type of service
309*4882a593Smuzhiyun  * requested may not be supported by the network to all destinations.
310*4882a593Smuzhiyun  */
311*4882a593Smuzhiyun void rdma_set_service_type(struct rdma_cm_id *id, int tos);
312*4882a593Smuzhiyun 
313*4882a593Smuzhiyun /**
314*4882a593Smuzhiyun  * rdma_set_reuseaddr - Allow the reuse of local addresses when binding
315*4882a593Smuzhiyun  *    the rdma_cm_id.
316*4882a593Smuzhiyun  * @id: Communication identifier to configure.
317*4882a593Smuzhiyun  * @reuse: Value indicating if the bound address is reusable.
318*4882a593Smuzhiyun  *
319*4882a593Smuzhiyun  * Reuse must be set before an address is bound to the id.
320*4882a593Smuzhiyun  */
321*4882a593Smuzhiyun int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse);
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun /**
324*4882a593Smuzhiyun  * rdma_set_afonly - Specify that listens are restricted to the
325*4882a593Smuzhiyun  *    bound address family only.
326*4882a593Smuzhiyun  * @id: Communication identifer to configure.
327*4882a593Smuzhiyun  * @afonly: Value indicating if listens are restricted.
328*4882a593Smuzhiyun  *
329*4882a593Smuzhiyun  * Must be set before identifier is in the listening state.
330*4882a593Smuzhiyun  */
331*4882a593Smuzhiyun int rdma_set_afonly(struct rdma_cm_id *id, int afonly);
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout);
334*4882a593Smuzhiyun  /**
335*4882a593Smuzhiyun  * rdma_get_service_id - Return the IB service ID for a specified address.
336*4882a593Smuzhiyun  * @id: Communication identifier associated with the address.
337*4882a593Smuzhiyun  * @addr: Address for the service ID.
338*4882a593Smuzhiyun  */
339*4882a593Smuzhiyun __be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr);
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun /**
342*4882a593Smuzhiyun  * rdma_reject_msg - return a pointer to a reject message string.
343*4882a593Smuzhiyun  * @id: Communication identifier that received the REJECT event.
344*4882a593Smuzhiyun  * @reason: Value returned in the REJECT event status field.
345*4882a593Smuzhiyun  */
346*4882a593Smuzhiyun const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id,
347*4882a593Smuzhiyun 						int reason);
348*4882a593Smuzhiyun /**
349*4882a593Smuzhiyun  * rdma_consumer_reject_data - return the consumer reject private data and
350*4882a593Smuzhiyun  *			       length, if any.
351*4882a593Smuzhiyun  * @id: Communication identifier that received the REJECT event.
352*4882a593Smuzhiyun  * @ev: RDMA CM reject event.
353*4882a593Smuzhiyun  * @data_len: Pointer to the resulting length of the consumer data.
354*4882a593Smuzhiyun  */
355*4882a593Smuzhiyun const void *rdma_consumer_reject_data(struct rdma_cm_id *id,
356*4882a593Smuzhiyun 				      struct rdma_cm_event *ev, u8 *data_len);
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun /**
359*4882a593Smuzhiyun  * rdma_read_gids - Return the SGID and DGID used for establishing
360*4882a593Smuzhiyun  *                  connection. This can be used after rdma_resolve_addr()
361*4882a593Smuzhiyun  *                  on client side. This can be use on new connection
362*4882a593Smuzhiyun  *                  on server side. This is applicable to IB, RoCE, iWarp.
363*4882a593Smuzhiyun  *                  If cm_id is not bound yet to the RDMA device, it doesn't
364*4882a593Smuzhiyun  *                  copy and SGID or DGID to the given pointers.
365*4882a593Smuzhiyun  * @id: Communication identifier whose GIDs are queried.
366*4882a593Smuzhiyun  * @sgid: Pointer to SGID where SGID will be returned. It is optional.
367*4882a593Smuzhiyun  * @dgid: Pointer to DGID where DGID will be returned. It is optional.
368*4882a593Smuzhiyun  * Note: This API should not be used by any new ULPs or new code.
369*4882a593Smuzhiyun  * Instead, users interested in querying GIDs should refer to path record
370*4882a593Smuzhiyun  * of the rdma_cm_id to query the GIDs.
371*4882a593Smuzhiyun  * This API is provided for compatibility for existing users.
372*4882a593Smuzhiyun  */
373*4882a593Smuzhiyun 
374*4882a593Smuzhiyun void rdma_read_gids(struct rdma_cm_id *cm_id, union ib_gid *sgid,
375*4882a593Smuzhiyun 		    union ib_gid *dgid);
376*4882a593Smuzhiyun 
377*4882a593Smuzhiyun struct iw_cm_id *rdma_iw_cm_id(struct rdma_cm_id *cm_id);
378*4882a593Smuzhiyun struct rdma_cm_id *rdma_res_to_id(struct rdma_restrack_entry *res);
379*4882a593Smuzhiyun 
380*4882a593Smuzhiyun #endif /* RDMA_CM_H */
381