Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/ofed/include/rdma/iw_cm.h
39482 views
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3
*
4
* Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
5
* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
6
*
7
* This software is available to you under a choice of one of two
8
* licenses. You may choose to be licensed under the terms of the GNU
9
* General Public License (GPL) Version 2, available from the file
10
* COPYING in the main directory of this source tree, or the
11
* OpenIB.org BSD license below:
12
*
13
* Redistribution and use in source and binary forms, with or
14
* without modification, are permitted provided that the following
15
* conditions are met:
16
*
17
* - Redistributions of source code must retain the above
18
* copyright notice, this list of conditions and the following
19
* disclaimer.
20
*
21
* - Redistributions in binary form must reproduce the above
22
* copyright notice, this list of conditions and the following
23
* disclaimer in the documentation and/or other materials
24
* provided with the distribution.
25
*
26
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
* SOFTWARE.
34
*/
35
36
#ifndef IW_CM_H
37
#define IW_CM_H
38
39
#include <linux/in.h>
40
#include <rdma/ib_cm.h>
41
42
struct iw_cm_id;
43
44
enum iw_cm_event_type {
45
IW_CM_EVENT_CONNECT_REQUEST = 1, /* connect request received */
46
IW_CM_EVENT_CONNECT_REPLY, /* reply from active connect request */
47
IW_CM_EVENT_ESTABLISHED, /* passive side accept successful */
48
IW_CM_EVENT_DISCONNECT, /* orderly shutdown */
49
IW_CM_EVENT_CLOSE /* close complete */
50
};
51
52
struct iw_cm_event {
53
enum iw_cm_event_type event;
54
int status;
55
struct sockaddr_storage local_addr;
56
struct sockaddr_storage remote_addr;
57
void *private_data;
58
void *provider_data;
59
u8 private_data_len;
60
u8 ord;
61
u8 ird;
62
};
63
64
/**
65
* iw_cm_handler - Function to be called by the IW CM when delivering events
66
* to the client.
67
*
68
* @cm_id: The IW CM identifier associated with the event.
69
* @event: Pointer to the event structure.
70
*/
71
typedef int (*iw_cm_handler)(struct iw_cm_id *cm_id,
72
struct iw_cm_event *event);
73
74
/**
75
* iw_event_handler - Function called by the provider when delivering provider
76
* events to the IW CM. Returns either 0 indicating the event was processed
77
* or -errno if the event could not be processed.
78
*
79
* @cm_id: The IW CM identifier associated with the event.
80
* @event: Pointer to the event structure.
81
*/
82
typedef int (*iw_event_handler)(struct iw_cm_id *cm_id,
83
struct iw_cm_event *event);
84
85
struct iw_cm_id {
86
iw_cm_handler cm_handler; /* client callback function */
87
void *context; /* client cb context */
88
struct ib_device *device;
89
struct sockaddr_storage local_addr; /* local addr */
90
struct sockaddr_storage remote_addr;
91
struct sockaddr_storage m_local_addr; /* nmapped local addr */
92
struct sockaddr_storage m_remote_addr; /* nmapped rem addr */
93
void *provider_data; /* provider private data */
94
iw_event_handler event_handler; /* cb for provider
95
events */
96
/* Used by provider to add and remove refs on IW cm_id */
97
void (*add_ref)(struct iw_cm_id *);
98
void (*rem_ref)(struct iw_cm_id *);
99
u8 tos;
100
};
101
102
struct iw_cm_conn_param {
103
const void *private_data;
104
u16 private_data_len;
105
u32 ord;
106
u32 ird;
107
u32 qpn;
108
};
109
110
struct iw_cm_verbs {
111
void (*add_ref)(struct ib_qp *qp);
112
113
void (*rem_ref)(struct ib_qp *qp);
114
115
struct ib_qp * (*get_qp)(struct ib_device *device,
116
int qpn);
117
118
int (*connect)(struct iw_cm_id *cm_id,
119
struct iw_cm_conn_param *conn_param);
120
121
int (*accept)(struct iw_cm_id *cm_id,
122
struct iw_cm_conn_param *conn_param);
123
124
int (*reject)(struct iw_cm_id *cm_id,
125
const void *pdata, u8 pdata_len);
126
127
int (*create_listen)(struct iw_cm_id *cm_id,
128
int backlog);
129
130
int (*destroy_listen)(struct iw_cm_id *cm_id);
131
char ifname[IFNAMSIZ];
132
};
133
134
/**
135
* iw_create_cm_id - Create an IW CM identifier.
136
*
137
* @device: The IB device on which to create the IW CM identier.
138
* @event_handler: User callback invoked to report events associated with the
139
* returned IW CM identifier.
140
* @context: User specified context associated with the id.
141
*/
142
struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
143
iw_cm_handler cm_handler, void *context);
144
145
/**
146
* iw_destroy_cm_id - Destroy an IW CM identifier.
147
*
148
* @cm_id: The previously created IW CM identifier to destroy.
149
*
150
* The client can assume that no events will be delivered for the CM ID after
151
* this function returns.
152
*/
153
void iw_destroy_cm_id(struct iw_cm_id *cm_id);
154
155
/**
156
* iw_cm_bind_qp - Unbind the specified IW CM identifier and QP
157
*
158
* @cm_id: The IW CM idenfier to unbind from the QP.
159
* @qp: The QP
160
*
161
* This is called by the provider when destroying the QP to ensure
162
* that any references held by the IWCM are released. It may also
163
* be called by the IWCM when destroying a CM_ID to that any
164
* references held by the provider are released.
165
*/
166
void iw_cm_unbind_qp(struct iw_cm_id *cm_id, struct ib_qp *qp);
167
168
/**
169
* iw_cm_get_qp - Return the ib_qp associated with a QPN
170
*
171
* @ib_device: The IB device
172
* @qpn: The queue pair number
173
*/
174
struct ib_qp *iw_cm_get_qp(struct ib_device *device, int qpn);
175
176
/**
177
* iw_cm_listen - Listen for incoming connection requests on the
178
* specified IW CM id.
179
*
180
* @cm_id: The IW CM identifier.
181
* @backlog: The maximum number of outstanding un-accepted inbound listen
182
* requests to queue.
183
*
184
* The source address and port number are specified in the IW CM identifier
185
* structure.
186
*/
187
int iw_cm_listen(struct iw_cm_id *cm_id, int backlog);
188
189
/**
190
* iw_cm_accept - Called to accept an incoming connect request.
191
*
192
* @cm_id: The IW CM identifier associated with the connection request.
193
* @iw_param: Pointer to a structure containing connection establishment
194
* parameters.
195
*
196
* The specified cm_id will have been provided in the event data for a
197
* CONNECT_REQUEST event. Subsequent events related to this connection will be
198
* delivered to the specified IW CM identifier prior and may occur prior to
199
* the return of this function. If this function returns a non-zero value, the
200
* client can assume that no events will be delivered to the specified IW CM
201
* identifier.
202
*/
203
int iw_cm_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
204
205
/**
206
* iw_cm_reject - Reject an incoming connection request.
207
*
208
* @cm_id: Connection identifier associated with the request.
209
* @private_daa: Pointer to data to deliver to the remote peer as part of the
210
* reject message.
211
* @private_data_len: The number of bytes in the private_data parameter.
212
*
213
* The client can assume that no events will be delivered to the specified IW
214
* CM identifier following the return of this function. The private_data
215
* buffer is available for reuse when this function returns.
216
*/
217
int iw_cm_reject(struct iw_cm_id *cm_id, const void *private_data,
218
u8 private_data_len);
219
220
/**
221
* iw_cm_connect - Called to request a connection to a remote peer.
222
*
223
* @cm_id: The IW CM identifier for the connection.
224
* @iw_param: Pointer to a structure containing connection establishment
225
* parameters.
226
*
227
* Events may be delivered to the specified IW CM identifier prior to the
228
* return of this function. If this function returns a non-zero value, the
229
* client can assume that no events will be delivered to the specified IW CM
230
* identifier.
231
*/
232
int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
233
234
/**
235
* iw_cm_disconnect - Close the specified connection.
236
*
237
* @cm_id: The IW CM identifier to close.
238
* @abrupt: If 0, the connection will be closed gracefully, otherwise, the
239
* connection will be reset.
240
*
241
* The IW CM identifier is still active until the IW_CM_EVENT_CLOSE event is
242
* delivered.
243
*/
244
int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt);
245
246
/**
247
* iw_cm_init_qp_attr - Called to initialize the attributes of the QP
248
* associated with a IW CM identifier.
249
*
250
* @cm_id: The IW CM identifier associated with the QP
251
* @qp_attr: Pointer to the QP attributes structure.
252
* @qp_attr_mask: Pointer to a bit vector specifying which QP attributes are
253
* valid.
254
*/
255
int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr,
256
int *qp_attr_mask);
257
258
/**
259
* iwcm_reject_msg - return a pointer to a reject message string.
260
* @reason: Value returned in the REJECT event status field.
261
*/
262
const char *__attribute_const__ iwcm_reject_msg(int reason);
263
264
#endif /* IW_CM_H */
265
266