1178784Skmacy/*
2178784Skmacy * Copyright (c) 2004, 2005 Intel Corporation.  All rights reserved.
3178784Skmacy * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
4178784Skmacy * Copyright (c) 2004 Voltaire Corporation.  All rights reserved.
5178784Skmacy * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
6178784Skmacy *
7178784Skmacy * This software is available to you under a choice of one of two
8178784Skmacy * licenses.  You may choose to be licensed under the terms of the GNU
9178784Skmacy * General Public License (GPL) Version 2, available from the file
10178784Skmacy * COPYING in the main directory of this source tree, or the
11178784Skmacy * OpenIB.org BSD license below:
12178784Skmacy *
13178784Skmacy *     Redistribution and use in source and binary forms, with or
14178784Skmacy *     without modification, are permitted provided that the following
15178784Skmacy *     conditions are met:
16178784Skmacy *
17178784Skmacy *      - Redistributions of source code must retain the above
18178784Skmacy *        copyright notice, this list of conditions and the following
19178784Skmacy *        disclaimer.
20178784Skmacy *
21178784Skmacy *      - Redistributions in binary form must reproduce the above
22178784Skmacy *        copyright notice, this list of conditions and the following
23178784Skmacy *        disclaimer in the documentation and/or other materials
24178784Skmacy *        provided with the distribution.
25178784Skmacy *
26178784Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27178784Skmacy * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28178784Skmacy * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29178784Skmacy * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30178784Skmacy * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31178784Skmacy * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32178784Skmacy * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33178784Skmacy * SOFTWARE.
34178784Skmacy *
35178784Skmacy * $Id: ib_cm.h 4311 2005-12-05 18:42:01Z sean.hefty $
36178784Skmacy *
37178784Skmacy * $FreeBSD$
38178784Skmacy */
39178784Skmacy
40178784Skmacy
41178784Skmacy#if !defined(IB_CM_H)
42178784Skmacy#define IB_CM_H
43178784Skmacy
44178784Skmacy#include <contrib/rdma/ib_mad.h>
45178784Skmacy#include <contrib/rdma/ib_sa.h>
46178784Skmacy
47178784Skmacyenum ib_cm_state {
48178784Skmacy	IB_CM_IDLE,
49178784Skmacy	IB_CM_LISTEN,
50178784Skmacy	IB_CM_REQ_SENT,
51178784Skmacy	IB_CM_REQ_RCVD,
52178784Skmacy	IB_CM_MRA_REQ_SENT,
53178784Skmacy	IB_CM_MRA_REQ_RCVD,
54178784Skmacy	IB_CM_REP_SENT,
55178784Skmacy	IB_CM_REP_RCVD,
56178784Skmacy	IB_CM_MRA_REP_SENT,
57178784Skmacy	IB_CM_MRA_REP_RCVD,
58178784Skmacy	IB_CM_ESTABLISHED,
59178784Skmacy	IB_CM_DREQ_SENT,
60178784Skmacy	IB_CM_DREQ_RCVD,
61178784Skmacy	IB_CM_TIMEWAIT,
62178784Skmacy	IB_CM_SIDR_REQ_SENT,
63178784Skmacy	IB_CM_SIDR_REQ_RCVD
64178784Skmacy};
65178784Skmacy
66178784Skmacyenum ib_cm_lap_state {
67178784Skmacy	IB_CM_LAP_UNINIT,
68178784Skmacy	IB_CM_LAP_IDLE,
69178784Skmacy	IB_CM_LAP_SENT,
70178784Skmacy	IB_CM_LAP_RCVD,
71178784Skmacy	IB_CM_MRA_LAP_SENT,
72178784Skmacy	IB_CM_MRA_LAP_RCVD,
73178784Skmacy};
74178784Skmacy
75178784Skmacyenum ib_cm_event_type {
76178784Skmacy	IB_CM_REQ_ERROR,
77178784Skmacy	IB_CM_REQ_RECEIVED,
78178784Skmacy	IB_CM_REP_ERROR,
79178784Skmacy	IB_CM_REP_RECEIVED,
80178784Skmacy	IB_CM_RTU_RECEIVED,
81178784Skmacy	IB_CM_USER_ESTABLISHED,
82178784Skmacy	IB_CM_DREQ_ERROR,
83178784Skmacy	IB_CM_DREQ_RECEIVED,
84178784Skmacy	IB_CM_DREP_RECEIVED,
85178784Skmacy	IB_CM_TIMEWAIT_EXIT,
86178784Skmacy	IB_CM_MRA_RECEIVED,
87178784Skmacy	IB_CM_REJ_RECEIVED,
88178784Skmacy	IB_CM_LAP_ERROR,
89178784Skmacy	IB_CM_LAP_RECEIVED,
90178784Skmacy	IB_CM_APR_RECEIVED,
91178784Skmacy	IB_CM_SIDR_REQ_ERROR,
92178784Skmacy	IB_CM_SIDR_REQ_RECEIVED,
93178784Skmacy	IB_CM_SIDR_REP_RECEIVED
94178784Skmacy};
95178784Skmacy
96178784Skmacyenum ib_cm_data_size {
97178784Skmacy	IB_CM_REQ_PRIVATE_DATA_SIZE	 = 92,
98178784Skmacy	IB_CM_MRA_PRIVATE_DATA_SIZE	 = 222,
99178784Skmacy	IB_CM_REJ_PRIVATE_DATA_SIZE	 = 148,
100178784Skmacy	IB_CM_REP_PRIVATE_DATA_SIZE	 = 196,
101178784Skmacy	IB_CM_RTU_PRIVATE_DATA_SIZE	 = 224,
102178784Skmacy	IB_CM_DREQ_PRIVATE_DATA_SIZE	 = 220,
103178784Skmacy	IB_CM_DREP_PRIVATE_DATA_SIZE	 = 224,
104178784Skmacy	IB_CM_REJ_ARI_LENGTH		 = 72,
105178784Skmacy	IB_CM_LAP_PRIVATE_DATA_SIZE	 = 168,
106178784Skmacy	IB_CM_APR_PRIVATE_DATA_SIZE	 = 148,
107178784Skmacy	IB_CM_APR_INFO_LENGTH		 = 72,
108178784Skmacy	IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
109178784Skmacy	IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
110178784Skmacy	IB_CM_SIDR_REP_INFO_LENGTH	 = 72,
111178784Skmacy	IB_CM_COMPARE_SIZE		 = 64
112178784Skmacy};
113178784Skmacy
114178784Skmacystruct ib_cm_id;
115178784Skmacy
116178784Skmacystruct ib_cm_req_event_param {
117178784Skmacy	struct ib_cm_id		*listen_id;
118178784Skmacy	u8			port;
119178784Skmacy
120178784Skmacy	struct ib_sa_path_rec	*primary_path;
121178784Skmacy	struct ib_sa_path_rec	*alternate_path;
122178784Skmacy
123178784Skmacy	__be64			remote_ca_guid;
124178784Skmacy	u32			remote_qkey;
125178784Skmacy	u32			remote_qpn;
126178784Skmacy	enum ib_qp_type		qp_type;
127178784Skmacy
128178784Skmacy	u32			starting_psn;
129178784Skmacy	u8			responder_resources;
130178784Skmacy	u8			initiator_depth;
131178784Skmacy	unsigned int		local_cm_response_timeout:5;
132178784Skmacy	unsigned int		flow_control:1;
133178784Skmacy	unsigned int		remote_cm_response_timeout:5;
134178784Skmacy	unsigned int		retry_count:3;
135178784Skmacy	unsigned int		rnr_retry_count:3;
136178784Skmacy	unsigned int		srq:1;
137178784Skmacy};
138178784Skmacy
139178784Skmacystruct ib_cm_rep_event_param {
140178784Skmacy	__be64			remote_ca_guid;
141178784Skmacy	u32			remote_qkey;
142178784Skmacy	u32			remote_qpn;
143178784Skmacy	u32			starting_psn;
144178784Skmacy	u8			responder_resources;
145178784Skmacy	u8			initiator_depth;
146178784Skmacy	unsigned int		target_ack_delay:5;
147178784Skmacy	unsigned int		failover_accepted:2;
148178784Skmacy	unsigned int		flow_control:1;
149178784Skmacy	unsigned int		rnr_retry_count:3;
150178784Skmacy	unsigned int		srq:1;
151178784Skmacy};
152178784Skmacy
153178784Skmacyenum ib_cm_rej_reason {
154178784Skmacy	IB_CM_REJ_NO_QP				= 1,
155178784Skmacy	IB_CM_REJ_NO_EEC			= 2,
156178784Skmacy	IB_CM_REJ_NO_RESOURCES			= 3,
157178784Skmacy	IB_CM_REJ_TIMEOUT			= 4,
158178784Skmacy	IB_CM_REJ_UNSUPPORTED			= 5,
159178784Skmacy	IB_CM_REJ_INVALID_COMM_ID		= 6,
160178784Skmacy	IB_CM_REJ_INVALID_COMM_INSTANCE		= 7,
161178784Skmacy	IB_CM_REJ_INVALID_SERVICE_ID		= 8,
162178784Skmacy	IB_CM_REJ_INVALID_TRANSPORT_TYPE	= 9,
163178784Skmacy	IB_CM_REJ_STALE_CONN			= 10,
164178784Skmacy	IB_CM_REJ_RDC_NOT_EXIST			= 11,
165178784Skmacy	IB_CM_REJ_INVALID_GID			= 12,
166178784Skmacy	IB_CM_REJ_INVALID_LID			= 13,
167178784Skmacy	IB_CM_REJ_INVALID_SL			= 14,
168178784Skmacy	IB_CM_REJ_INVALID_TRAFFIC_CLASS		= 15,
169178784Skmacy	IB_CM_REJ_INVALID_HOP_LIMIT		= 16,
170178784Skmacy	IB_CM_REJ_INVALID_PACKET_RATE		= 17,
171178784Skmacy	IB_CM_REJ_INVALID_ALT_GID		= 18,
172178784Skmacy	IB_CM_REJ_INVALID_ALT_LID		= 19,
173178784Skmacy	IB_CM_REJ_INVALID_ALT_SL		= 20,
174178784Skmacy	IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS	= 21,
175178784Skmacy	IB_CM_REJ_INVALID_ALT_HOP_LIMIT		= 22,
176178784Skmacy	IB_CM_REJ_INVALID_ALT_PACKET_RATE	= 23,
177178784Skmacy	IB_CM_REJ_PORT_CM_REDIRECT		= 24,
178178784Skmacy	IB_CM_REJ_PORT_REDIRECT			= 25,
179178784Skmacy	IB_CM_REJ_INVALID_MTU			= 26,
180178784Skmacy	IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES	= 27,
181178784Skmacy	IB_CM_REJ_CONSUMER_DEFINED		= 28,
182178784Skmacy	IB_CM_REJ_INVALID_RNR_RETRY		= 29,
183178784Skmacy	IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID	= 30,
184178784Skmacy	IB_CM_REJ_INVALID_CLASS_VERSION		= 31,
185178784Skmacy	IB_CM_REJ_INVALID_FLOW_LABEL		= 32,
186178784Skmacy	IB_CM_REJ_INVALID_ALT_FLOW_LABEL	= 33
187178784Skmacy};
188178784Skmacy
189178784Skmacystruct ib_cm_rej_event_param {
190178784Skmacy	enum ib_cm_rej_reason	reason;
191178784Skmacy	void			*ari;
192178784Skmacy	u8			ari_length;
193178784Skmacy};
194178784Skmacy
195178784Skmacystruct ib_cm_mra_event_param {
196178784Skmacy	u8	service_timeout;
197178784Skmacy};
198178784Skmacy
199178784Skmacystruct ib_cm_lap_event_param {
200178784Skmacy	struct ib_sa_path_rec	*alternate_path;
201178784Skmacy};
202178784Skmacy
203178784Skmacyenum ib_cm_apr_status {
204178784Skmacy	IB_CM_APR_SUCCESS,
205178784Skmacy	IB_CM_APR_INVALID_COMM_ID,
206178784Skmacy	IB_CM_APR_UNSUPPORTED,
207178784Skmacy	IB_CM_APR_REJECT,
208178784Skmacy	IB_CM_APR_REDIRECT,
209178784Skmacy	IB_CM_APR_IS_CURRENT,
210178784Skmacy	IB_CM_APR_INVALID_QPN_EECN,
211178784Skmacy	IB_CM_APR_INVALID_LID,
212178784Skmacy	IB_CM_APR_INVALID_GID,
213178784Skmacy	IB_CM_APR_INVALID_FLOW_LABEL,
214178784Skmacy	IB_CM_APR_INVALID_TCLASS,
215178784Skmacy	IB_CM_APR_INVALID_HOP_LIMIT,
216178784Skmacy	IB_CM_APR_INVALID_PACKET_RATE,
217178784Skmacy	IB_CM_APR_INVALID_SL
218178784Skmacy};
219178784Skmacy
220178784Skmacystruct ib_cm_apr_event_param {
221178784Skmacy	enum ib_cm_apr_status	ap_status;
222178784Skmacy	void			*apr_info;
223178784Skmacy	u8			info_len;
224178784Skmacy};
225178784Skmacy
226178784Skmacystruct ib_cm_sidr_req_event_param {
227178784Skmacy	struct ib_cm_id		*listen_id;
228178784Skmacy	u8			port;
229178784Skmacy	u16			pkey;
230178784Skmacy};
231178784Skmacy
232178784Skmacyenum ib_cm_sidr_status {
233178784Skmacy	IB_SIDR_SUCCESS,
234178784Skmacy	IB_SIDR_UNSUPPORTED,
235178784Skmacy	IB_SIDR_REJECT,
236178784Skmacy	IB_SIDR_NO_QP,
237178784Skmacy	IB_SIDR_REDIRECT,
238178784Skmacy	IB_SIDR_UNSUPPORTED_VERSION
239178784Skmacy};
240178784Skmacy
241178784Skmacystruct ib_cm_sidr_rep_event_param {
242178784Skmacy	enum ib_cm_sidr_status	status;
243178784Skmacy	u32			qkey;
244178784Skmacy	u32			qpn;
245178784Skmacy	void			*info;
246178784Skmacy	u8			info_len;
247178784Skmacy};
248178784Skmacy
249178784Skmacystruct ib_cm_event {
250178784Skmacy	enum ib_cm_event_type	event;
251178784Skmacy	union {
252178784Skmacy		struct ib_cm_req_event_param	req_rcvd;
253178784Skmacy		struct ib_cm_rep_event_param	rep_rcvd;
254178784Skmacy		/* No data for RTU received events. */
255178784Skmacy		struct ib_cm_rej_event_param	rej_rcvd;
256178784Skmacy		struct ib_cm_mra_event_param	mra_rcvd;
257178784Skmacy		struct ib_cm_lap_event_param	lap_rcvd;
258178784Skmacy		struct ib_cm_apr_event_param	apr_rcvd;
259178784Skmacy		/* No data for DREQ/DREP received events. */
260178784Skmacy		struct ib_cm_sidr_req_event_param sidr_req_rcvd;
261178784Skmacy		struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
262178784Skmacy		enum ib_wc_status		send_status;
263178784Skmacy	} param;
264178784Skmacy
265178784Skmacy	void			*private_data;
266178784Skmacy};
267178784Skmacy
268178784Skmacy/**
269178784Skmacy * ib_cm_handler - User-defined callback to process communication events.
270178784Skmacy * @cm_id: Communication identifier associated with the reported event.
271178784Skmacy * @event: Information about the communication event.
272178784Skmacy *
273178784Skmacy * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
274178784Skmacy * generated as a result of listen requests result in the allocation of a
275178784Skmacy * new @cm_id.  The new @cm_id is returned to the user through this callback.
276178784Skmacy * Clients are responsible for destroying the new @cm_id.  For peer-to-peer
277178784Skmacy * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
278178784Skmacy * to a user's existing communication identifier.
279178784Skmacy *
280178784Skmacy * Users may not call ib_destroy_cm_id while in the context of this callback;
281178784Skmacy * however, returning a non-zero value instructs the communication manager to
282178784Skmacy * destroy the @cm_id after the callback completes.
283178784Skmacy */
284178784Skmacytypedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
285178784Skmacy			     struct ib_cm_event *event);
286178784Skmacy
287178784Skmacystruct ib_cm_id {
288178784Skmacy	ib_cm_handler		cm_handler;
289178784Skmacy	void			*context;
290178784Skmacy	struct ib_device	*device;
291178784Skmacy	__be64			service_id;
292178784Skmacy	__be64			service_mask;
293178784Skmacy	enum ib_cm_state	state;		/* internal CM/debug use */
294178784Skmacy	enum ib_cm_lap_state	lap_state;	/* internal CM/debug use */
295178784Skmacy	__be32			local_id;
296178784Skmacy	__be32			remote_id;
297178784Skmacy	u32			remote_cm_qpn;  /* 1 unless redirected */
298178784Skmacy};
299178784Skmacy
300178784Skmacy/**
301178784Skmacy * ib_create_cm_id - Allocate a communication identifier.
302178784Skmacy * @device: Device associated with the cm_id.  All related communication will
303178784Skmacy * be associated with the specified device.
304178784Skmacy * @cm_handler: Callback invoked to notify the user of CM events.
305178784Skmacy * @context: User specified context associated with the communication
306178784Skmacy *   identifier.
307178784Skmacy *
308178784Skmacy * Communication identifiers are used to track connection states, service
309178784Skmacy * ID resolution requests, and listen requests.
310178784Skmacy */
311178784Skmacystruct ib_cm_id *ib_create_cm_id(struct ib_device *device,
312178784Skmacy				 ib_cm_handler cm_handler,
313178784Skmacy				 void *context);
314178784Skmacy
315178784Skmacy/**
316178784Skmacy * ib_destroy_cm_id - Destroy a connection identifier.
317178784Skmacy * @cm_id: Connection identifier to destroy.
318178784Skmacy *
319178784Skmacy * This call blocks until the connection identifier is destroyed.
320178784Skmacy */
321178784Skmacyvoid ib_destroy_cm_id(struct ib_cm_id *cm_id);
322178784Skmacy
323178784Skmacy#define IB_SERVICE_ID_AGN_MASK	__constant_cpu_to_be64(0xFF00000000000000ULL)
324178784Skmacy#define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL)
325178784Skmacy#define IB_CMA_SERVICE_ID	__constant_cpu_to_be64(0x0000000001000000ULL)
326178784Skmacy#define IB_CMA_SERVICE_ID_MASK	__constant_cpu_to_be64(0xFFFFFFFFFF000000ULL)
327178784Skmacy#define IB_SDP_SERVICE_ID	__constant_cpu_to_be64(0x0000000000010000ULL)
328178784Skmacy#define IB_SDP_SERVICE_ID_MASK	__constant_cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
329178784Skmacy
330178784Skmacystruct ib_cm_compare_data {
331178784Skmacy	u8  data[IB_CM_COMPARE_SIZE];
332178784Skmacy	u8  mask[IB_CM_COMPARE_SIZE];
333178784Skmacy};
334178784Skmacy
335178784Skmacy/**
336178784Skmacy * ib_cm_listen - Initiates listening on the specified service ID for
337178784Skmacy *   connection and service ID resolution requests.
338178784Skmacy * @cm_id: Connection identifier associated with the listen request.
339178784Skmacy * @service_id: Service identifier matched against incoming connection
340178784Skmacy *   and service ID resolution requests.  The service ID should be specified
341178784Skmacy *   network-byte order.  If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
342178784Skmacy *   assign a service ID to the caller.
343178784Skmacy * @service_mask: Mask applied to service ID used to listen across a
344178784Skmacy *   range of service IDs.  If set to 0, the service ID is matched
345178784Skmacy *   exactly.  This parameter is ignored if %service_id is set to
346178784Skmacy *   IB_CM_ASSIGN_SERVICE_ID.
347178784Skmacy * @compare_data: This parameter is optional.  It specifies data that must
348178784Skmacy *   appear in the private data of a connection request for the specified
349178784Skmacy *   listen request.
350178784Skmacy */
351178784Skmacyint ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
352178784Skmacy		 struct ib_cm_compare_data *compare_data);
353178784Skmacy
354178784Skmacystruct ib_cm_req_param {
355178784Skmacy	struct ib_sa_path_rec	*primary_path;
356178784Skmacy	struct ib_sa_path_rec	*alternate_path;
357178784Skmacy	__be64			service_id;
358178784Skmacy	u32			qp_num;
359178784Skmacy	enum ib_qp_type		qp_type;
360178784Skmacy	u32			starting_psn;
361178784Skmacy	const void		*private_data;
362178784Skmacy	u8			private_data_len;
363178784Skmacy	u8			peer_to_peer;
364178784Skmacy	u8			responder_resources;
365178784Skmacy	u8			initiator_depth;
366178784Skmacy	u8			remote_cm_response_timeout;
367178784Skmacy	u8			flow_control;
368178784Skmacy	u8			local_cm_response_timeout;
369178784Skmacy	u8			retry_count;
370178784Skmacy	u8			rnr_retry_count;
371178784Skmacy	u8			max_cm_retries;
372178784Skmacy	u8			srq;
373178784Skmacy};
374178784Skmacy
375178784Skmacy/**
376178784Skmacy * ib_send_cm_req - Sends a connection request to the remote node.
377178784Skmacy * @cm_id: Connection identifier that will be associated with the
378178784Skmacy *   connection request.
379178784Skmacy * @param: Connection request information needed to establish the
380178784Skmacy *   connection.
381178784Skmacy */
382178784Skmacyint ib_send_cm_req(struct ib_cm_id *cm_id,
383178784Skmacy		   struct ib_cm_req_param *param);
384178784Skmacy
385178784Skmacystruct ib_cm_rep_param {
386178784Skmacy	u32		qp_num;
387178784Skmacy	u32		starting_psn;
388178784Skmacy	const void	*private_data;
389178784Skmacy	u8		private_data_len;
390178784Skmacy	u8		responder_resources;
391178784Skmacy	u8		initiator_depth;
392178784Skmacy	u8		target_ack_delay;
393178784Skmacy	u8		failover_accepted;
394178784Skmacy	u8		flow_control;
395178784Skmacy	u8		rnr_retry_count;
396178784Skmacy	u8		srq;
397178784Skmacy};
398178784Skmacy
399178784Skmacy/**
400178784Skmacy * ib_send_cm_rep - Sends a connection reply in response to a connection
401178784Skmacy *   request.
402178784Skmacy * @cm_id: Connection identifier that will be associated with the
403178784Skmacy *   connection request.
404178784Skmacy * @param: Connection reply information needed to establish the
405178784Skmacy *   connection.
406178784Skmacy */
407178784Skmacyint ib_send_cm_rep(struct ib_cm_id *cm_id,
408178784Skmacy		   struct ib_cm_rep_param *param);
409178784Skmacy
410178784Skmacy/**
411178784Skmacy * ib_send_cm_rtu - Sends a connection ready to use message in response
412178784Skmacy *   to a connection reply message.
413178784Skmacy * @cm_id: Connection identifier associated with the connection request.
414178784Skmacy * @private_data: Optional user-defined private data sent with the
415178784Skmacy *   ready to use message.
416178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
417178784Skmacy */
418178784Skmacyint ib_send_cm_rtu(struct ib_cm_id *cm_id,
419178784Skmacy		   const void *private_data,
420178784Skmacy		   u8 private_data_len);
421178784Skmacy
422178784Skmacy/**
423178784Skmacy * ib_send_cm_dreq - Sends a disconnection request for an existing
424178784Skmacy *   connection.
425178784Skmacy * @cm_id: Connection identifier associated with the connection being
426178784Skmacy *   released.
427178784Skmacy * @private_data: Optional user-defined private data sent with the
428178784Skmacy *   disconnection request message.
429178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
430178784Skmacy */
431178784Skmacyint ib_send_cm_dreq(struct ib_cm_id *cm_id,
432178784Skmacy		    const void *private_data,
433178784Skmacy		    u8 private_data_len);
434178784Skmacy
435178784Skmacy/**
436178784Skmacy * ib_send_cm_drep - Sends a disconnection reply to a disconnection request.
437178784Skmacy * @cm_id: Connection identifier associated with the connection being
438178784Skmacy *   released.
439178784Skmacy * @private_data: Optional user-defined private data sent with the
440178784Skmacy *   disconnection reply message.
441178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
442178784Skmacy *
443178784Skmacy * If the cm_id is in the correct state, the CM will transition the connection
444178784Skmacy * to the timewait state, even if an error occurs sending the DREP message.
445178784Skmacy */
446178784Skmacyint ib_send_cm_drep(struct ib_cm_id *cm_id,
447178784Skmacy		    const void *private_data,
448178784Skmacy		    u8 private_data_len);
449178784Skmacy
450178784Skmacy/**
451178784Skmacy * ib_cm_notify - Notifies the CM of an event reported to the consumer.
452178784Skmacy * @cm_id: Connection identifier to transition to established.
453178784Skmacy * @event: Type of event.
454178784Skmacy *
455178784Skmacy * This routine should be invoked by users to notify the CM of relevant
456178784Skmacy * communication events.  Events that should be reported to the CM and
457178784Skmacy * when to report them are:
458178784Skmacy *
459178784Skmacy * IB_EVENT_COMM_EST - Used when a message is received on a connected
460178784Skmacy *    QP before an RTU has been received.
461178784Skmacy * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
462178784Skmacy *   to the alternate path.
463178784Skmacy */
464178784Skmacyint ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
465178784Skmacy
466178784Skmacy/**
467178784Skmacy * ib_send_cm_rej - Sends a connection rejection message to the
468178784Skmacy *   remote node.
469178784Skmacy * @cm_id: Connection identifier associated with the connection being
470178784Skmacy *   rejected.
471178784Skmacy * @reason: Reason for the connection request rejection.
472178784Skmacy * @ari: Optional additional rejection information.
473178784Skmacy * @ari_length: Size of the additional rejection information, in bytes.
474178784Skmacy * @private_data: Optional user-defined private data sent with the
475178784Skmacy *   rejection message.
476178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
477178784Skmacy */
478178784Skmacyint ib_send_cm_rej(struct ib_cm_id *cm_id,
479178784Skmacy		   enum ib_cm_rej_reason reason,
480178784Skmacy		   void *ari,
481178784Skmacy		   u8 ari_length,
482178784Skmacy		   const void *private_data,
483178784Skmacy		   u8 private_data_len);
484178784Skmacy
485178784Skmacy/**
486178784Skmacy * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection
487178784Skmacy *   message.
488178784Skmacy * @cm_id: Connection identifier associated with the connection message.
489178784Skmacy * @service_timeout: The maximum time required for the sender to reply to
490178784Skmacy *   to the connection message.
491178784Skmacy * @private_data: Optional user-defined private data sent with the
492178784Skmacy *   message receipt acknowledgement.
493178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
494178784Skmacy */
495178784Skmacyint ib_send_cm_mra(struct ib_cm_id *cm_id,
496178784Skmacy		   u8 service_timeout,
497178784Skmacy		   const void *private_data,
498178784Skmacy		   u8 private_data_len);
499178784Skmacy
500178784Skmacy/**
501178784Skmacy * ib_send_cm_lap - Sends a load alternate path request.
502178784Skmacy * @cm_id: Connection identifier associated with the load alternate path
503178784Skmacy *   message.
504178784Skmacy * @alternate_path: A path record that identifies the alternate path to
505178784Skmacy *   load.
506178784Skmacy * @private_data: Optional user-defined private data sent with the
507178784Skmacy *   load alternate path message.
508178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
509178784Skmacy */
510178784Skmacyint ib_send_cm_lap(struct ib_cm_id *cm_id,
511178784Skmacy		   struct ib_sa_path_rec *alternate_path,
512178784Skmacy		   const void *private_data,
513178784Skmacy		   u8 private_data_len);
514178784Skmacy
515178784Skmacy/**
516178784Skmacy * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
517178784Skmacy *   to a specified QP state.
518178784Skmacy * @cm_id: Communication identifier associated with the QP attributes to
519178784Skmacy *   initialize.
520178784Skmacy * @qp_attr: On input, specifies the desired QP state.  On output, the
521178784Skmacy *   mandatory and desired optional attributes will be set in order to
522178784Skmacy *   modify the QP to the specified state.
523178784Skmacy * @qp_attr_mask: The QP attribute mask that may be used to transition the
524178784Skmacy *   QP to the specified state.
525178784Skmacy *
526178784Skmacy * Users must set the @qp_attr->qp_state to the desired QP state.  This call
527178784Skmacy * will set all required attributes for the given transition, along with
528178784Skmacy * known optional attributes.  Users may override the attributes returned from
529178784Skmacy * this call before calling ib_modify_qp.
530178784Skmacy */
531178784Skmacyint ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
532178784Skmacy		       struct ib_qp_attr *qp_attr,
533178784Skmacy		       int *qp_attr_mask);
534178784Skmacy
535178784Skmacy/**
536178784Skmacy * ib_send_cm_apr - Sends an alternate path response message in response to
537178784Skmacy *   a load alternate path request.
538178784Skmacy * @cm_id: Connection identifier associated with the alternate path response.
539178784Skmacy * @status: Reply status sent with the alternate path response.
540178784Skmacy * @info: Optional additional information sent with the alternate path
541178784Skmacy *   response.
542178784Skmacy * @info_length: Size of the additional information, in bytes.
543178784Skmacy * @private_data: Optional user-defined private data sent with the
544178784Skmacy *   alternate path response message.
545178784Skmacy * @private_data_len: Size of the private data buffer, in bytes.
546178784Skmacy */
547178784Skmacyint ib_send_cm_apr(struct ib_cm_id *cm_id,
548178784Skmacy		   enum ib_cm_apr_status status,
549178784Skmacy		   void *info,
550178784Skmacy		   u8 info_length,
551178784Skmacy		   const void *private_data,
552178784Skmacy		   u8 private_data_len);
553178784Skmacy
554178784Skmacystruct ib_cm_sidr_req_param {
555178784Skmacy	struct ib_sa_path_rec	*path;
556178784Skmacy	__be64			service_id;
557178784Skmacy	int			timeout_ms;
558178784Skmacy	const void		*private_data;
559178784Skmacy	u8			private_data_len;
560178784Skmacy	u8			max_cm_retries;
561178784Skmacy};
562178784Skmacy
563178784Skmacy/**
564178784Skmacy * ib_send_cm_sidr_req - Sends a service ID resolution request to the
565178784Skmacy *   remote node.
566178784Skmacy * @cm_id: Communication identifier that will be associated with the
567178784Skmacy *   service ID resolution request.
568178784Skmacy * @param: Service ID resolution request information.
569178784Skmacy */
570178784Skmacyint ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
571178784Skmacy			struct ib_cm_sidr_req_param *param);
572178784Skmacy
573178784Skmacystruct ib_cm_sidr_rep_param {
574178784Skmacy	u32			qp_num;
575178784Skmacy	u32			qkey;
576178784Skmacy	enum ib_cm_sidr_status	status;
577178784Skmacy	const void		*info;
578178784Skmacy	u8			info_length;
579178784Skmacy	const void		*private_data;
580178784Skmacy	u8			private_data_len;
581178784Skmacy};
582178784Skmacy
583178784Skmacy/**
584178784Skmacy * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
585178784Skmacy *   remote node.
586178784Skmacy * @cm_id: Communication identifier associated with the received service ID
587178784Skmacy *   resolution request.
588178784Skmacy * @param: Service ID resolution reply information.
589178784Skmacy */
590178784Skmacyint ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
591178784Skmacy			struct ib_cm_sidr_rep_param *param);
592178784Skmacy
593178784Skmacy#endif /* IB_CM_H */
594