mm: Don't pin ZERO_PAGE in pin_user_pages()
[linux-block.git] / include / rdma / iw_cm.h
CommitLineData
6bf9d8f6 1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
922a8e9f
TT
2/*
3 * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
4 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
922a8e9f 5 */
6bf9d8f6 6
922a8e9f
TT
7#ifndef IW_CM_H
8#define IW_CM_H
9
10#include <linux/in.h>
11#include <rdma/ib_cm.h>
12
13struct iw_cm_id;
14
15enum iw_cm_event_type {
16 IW_CM_EVENT_CONNECT_REQUEST = 1, /* connect request received */
17 IW_CM_EVENT_CONNECT_REPLY, /* reply from active connect request */
18 IW_CM_EVENT_ESTABLISHED, /* passive side accept successful */
19 IW_CM_EVENT_DISCONNECT, /* orderly shutdown */
20 IW_CM_EVENT_CLOSE /* close complete */
21};
22
922a8e9f
TT
23struct iw_cm_event {
24 enum iw_cm_event_type event;
d0c49bf3 25 int status;
24d44a39
SW
26 struct sockaddr_storage local_addr;
27 struct sockaddr_storage remote_addr;
922a8e9f 28 void *private_data;
4deccd6d 29 void *provider_data;
3ebeebc3
KS
30 u8 private_data_len;
31 u8 ord;
32 u8 ird;
922a8e9f
TT
33};
34
35/**
36 * iw_cm_handler - Function to be called by the IW CM when delivering events
37 * to the client.
38 *
39 * @cm_id: The IW CM identifier associated with the event.
40 * @event: Pointer to the event structure.
41 */
42typedef int (*iw_cm_handler)(struct iw_cm_id *cm_id,
43 struct iw_cm_event *event);
44
45/**
46 * iw_event_handler - Function called by the provider when delivering provider
47 * events to the IW CM. Returns either 0 indicating the event was processed
48 * or -errno if the event could not be processed.
49 *
50 * @cm_id: The IW CM identifier associated with the event.
51 * @event: Pointer to the event structure.
52 */
53typedef int (*iw_event_handler)(struct iw_cm_id *cm_id,
54 struct iw_cm_event *event);
55
56struct iw_cm_id {
57 iw_cm_handler cm_handler; /* client callback function */
58 void *context; /* client cb context */
59 struct ib_device *device;
b493d91d 60 struct sockaddr_storage local_addr; /* local addr */
24d44a39 61 struct sockaddr_storage remote_addr;
b493d91d
FL
62 struct sockaddr_storage m_local_addr; /* nmapped local addr */
63 struct sockaddr_storage m_remote_addr; /* nmapped rem addr */
922a8e9f
TT
64 void *provider_data; /* provider private data */
65 iw_event_handler event_handler; /* cb for provider
66 events */
67 /* Used by provider to add and remove refs on IW cm_id */
68 void (*add_ref)(struct iw_cm_id *);
69 void (*rem_ref)(struct iw_cm_id *);
68cdba06 70 u8 tos;
926ba19b
SW
71 bool tos_set:1;
72 bool mapped:1;
e35ecb46 73 bool afonly:1;
922a8e9f
TT
74};
75
76struct iw_cm_conn_param {
77 const void *private_data;
78 u16 private_data_len;
79 u32 ord;
80 u32 ird;
81 u32 qpn;
82};
83
b0bad9ad
SW
84enum iw_flags {
85
86 /*
87 * This flag allows the iwcm and iwpmd to still advertise
88 * mappings but the real and mapped port numbers are the
89 * same. Further, iwpmd will not bind any user socket to
90 * reserve the port. This is required for soft iwarp
91 * to play in the port mapped iwarp space.
92 */
93 IW_F_NO_PORT_MAP = (1 << 0),
94};
95
922a8e9f
TT
96/**
97 * iw_create_cm_id - Create an IW CM identifier.
98 *
99 * @device: The IB device on which to create the IW CM identier.
100 * @event_handler: User callback invoked to report events associated with the
101 * returned IW CM identifier.
102 * @context: User specified context associated with the id.
103 */
104struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
105 iw_cm_handler cm_handler, void *context);
106
107/**
108 * iw_destroy_cm_id - Destroy an IW CM identifier.
109 *
110 * @cm_id: The previously created IW CM identifier to destroy.
111 *
112 * The client can assume that no events will be delivered for the CM ID after
113 * this function returns.
114 */
115void iw_destroy_cm_id(struct iw_cm_id *cm_id);
116
117/**
118 * iw_cm_bind_qp - Unbind the specified IW CM identifier and QP
119 *
120 * @cm_id: The IW CM idenfier to unbind from the QP.
121 * @qp: The QP
122 *
123 * This is called by the provider when destroying the QP to ensure
124 * that any references held by the IWCM are released. It may also
125 * be called by the IWCM when destroying a CM_ID to that any
126 * references held by the provider are released.
127 */
128void iw_cm_unbind_qp(struct iw_cm_id *cm_id, struct ib_qp *qp);
129
130/**
131 * iw_cm_get_qp - Return the ib_qp associated with a QPN
132 *
133 * @ib_device: The IB device
134 * @qpn: The queue pair number
135 */
136struct ib_qp *iw_cm_get_qp(struct ib_device *device, int qpn);
137
138/**
139 * iw_cm_listen - Listen for incoming connection requests on the
140 * specified IW CM id.
141 *
142 * @cm_id: The IW CM identifier.
143 * @backlog: The maximum number of outstanding un-accepted inbound listen
144 * requests to queue.
145 *
146 * The source address and port number are specified in the IW CM identifier
147 * structure.
148 */
149int iw_cm_listen(struct iw_cm_id *cm_id, int backlog);
150
151/**
152 * iw_cm_accept - Called to accept an incoming connect request.
153 *
154 * @cm_id: The IW CM identifier associated with the connection request.
155 * @iw_param: Pointer to a structure containing connection establishment
156 * parameters.
157 *
158 * The specified cm_id will have been provided in the event data for a
159 * CONNECT_REQUEST event. Subsequent events related to this connection will be
160 * delivered to the specified IW CM identifier prior and may occur prior to
161 * the return of this function. If this function returns a non-zero value, the
162 * client can assume that no events will be delivered to the specified IW CM
163 * identifier.
164 */
165int iw_cm_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
166
167/**
168 * iw_cm_reject - Reject an incoming connection request.
169 *
170 * @cm_id: Connection identifier associated with the request.
171 * @private_daa: Pointer to data to deliver to the remote peer as part of the
172 * reject message.
173 * @private_data_len: The number of bytes in the private_data parameter.
174 *
175 * The client can assume that no events will be delivered to the specified IW
176 * CM identifier following the return of this function. The private_data
177 * buffer is available for reuse when this function returns.
178 */
179int iw_cm_reject(struct iw_cm_id *cm_id, const void *private_data,
180 u8 private_data_len);
181
182/**
183 * iw_cm_connect - Called to request a connection to a remote peer.
184 *
185 * @cm_id: The IW CM identifier for the connection.
186 * @iw_param: Pointer to a structure containing connection establishment
187 * parameters.
188 *
189 * Events may be delivered to the specified IW CM identifier prior to the
190 * return of this function. If this function returns a non-zero value, the
191 * client can assume that no events will be delivered to the specified IW CM
192 * identifier.
193 */
194int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
195
196/**
197 * iw_cm_disconnect - Close the specified connection.
198 *
199 * @cm_id: The IW CM identifier to close.
200 * @abrupt: If 0, the connection will be closed gracefully, otherwise, the
201 * connection will be reset.
202 *
203 * The IW CM identifier is still active until the IW_CM_EVENT_CLOSE event is
204 * delivered.
205 */
206int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt);
207
208/**
209 * iw_cm_init_qp_attr - Called to initialize the attributes of the QP
210 * associated with a IW CM identifier.
211 *
212 * @cm_id: The IW CM identifier associated with the QP
213 * @qp_attr: Pointer to the QP attributes structure.
214 * @qp_attr_mask: Pointer to a bit vector specifying which QP attributes are
215 * valid.
216 */
217int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr,
218 int *qp_attr_mask);
219
77a5db13
SW
220/**
221 * iwcm_reject_msg - return a pointer to a reject message string.
222 * @reason: Value returned in the REJECT event status field.
223 */
224const char *__attribute_const__ iwcm_reject_msg(int reason);
225
922a8e9f 226#endif /* IW_CM_H */