1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
3 * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
4 * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
11 #include <rdma/ib_cm.h>
15 enum 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 */
24 enum iw_cm_event_type event;
26 struct sockaddr_storage local_addr;
27 struct sockaddr_storage remote_addr;
36 * iw_cm_handler - Function to be called by the IW CM when delivering events
39 * @cm_id: The IW CM identifier associated with the event.
40 * @event: Pointer to the event structure.
42 typedef int (*iw_cm_handler)(struct iw_cm_id *cm_id,
43 struct iw_cm_event *event);
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.
50 * @cm_id: The IW CM identifier associated with the event.
51 * @event: Pointer to the event structure.
53 typedef int (*iw_event_handler)(struct iw_cm_id *cm_id,
54 struct iw_cm_event *event);
57 iw_cm_handler cm_handler; /* client callback function */
58 void *context; /* client cb context */
59 struct ib_device *device;
60 struct sockaddr_storage local_addr; /* local addr */
61 struct sockaddr_storage remote_addr;
62 struct sockaddr_storage m_local_addr; /* nmapped local addr */
63 struct sockaddr_storage m_remote_addr; /* nmapped rem addr */
64 void *provider_data; /* provider private data */
65 iw_event_handler event_handler; /* cb for provider
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 *);
76 struct iw_cm_conn_param {
77 const void *private_data;
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.
93 IW_F_NO_PORT_MAP = (1 << 0),
97 * iw_create_cm_id - Create an IW CM identifier.
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.
104 struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
105 iw_cm_handler cm_handler, void *context);
108 * iw_destroy_cm_id - Destroy an IW CM identifier.
110 * @cm_id: The previously created IW CM identifier to destroy.
112 * The client can assume that no events will be delivered for the CM ID after
113 * this function returns.
115 void iw_destroy_cm_id(struct iw_cm_id *cm_id);
118 * iw_cm_listen - Listen for incoming connection requests on the
119 * specified IW CM id.
121 * @cm_id: The IW CM identifier.
122 * @backlog: The maximum number of outstanding un-accepted inbound listen
125 * The source address and port number are specified in the IW CM identifier
128 int iw_cm_listen(struct iw_cm_id *cm_id, int backlog);
131 * iw_cm_accept - Called to accept an incoming connect request.
133 * @cm_id: The IW CM identifier associated with the connection request.
134 * @iw_param: Pointer to a structure containing connection establishment
137 * The specified cm_id will have been provided in the event data for a
138 * CONNECT_REQUEST event. Subsequent events related to this connection will be
139 * delivered to the specified IW CM identifier prior and may occur prior to
140 * the return of this function. If this function returns a non-zero value, the
141 * client can assume that no events will be delivered to the specified IW CM
144 int iw_cm_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
147 * iw_cm_reject - Reject an incoming connection request.
149 * @cm_id: Connection identifier associated with the request.
150 * @private_daa: Pointer to data to deliver to the remote peer as part of the
152 * @private_data_len: The number of bytes in the private_data parameter.
154 * The client can assume that no events will be delivered to the specified IW
155 * CM identifier following the return of this function. The private_data
156 * buffer is available for reuse when this function returns.
158 int iw_cm_reject(struct iw_cm_id *cm_id, const void *private_data,
159 u8 private_data_len);
162 * iw_cm_connect - Called to request a connection to a remote peer.
164 * @cm_id: The IW CM identifier for the connection.
165 * @iw_param: Pointer to a structure containing connection establishment
168 * Events may be delivered to the specified IW CM identifier prior to the
169 * return of this function. If this function returns a non-zero value, the
170 * client can assume that no events will be delivered to the specified IW CM
173 int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
176 * iw_cm_disconnect - Close the specified connection.
178 * @cm_id: The IW CM identifier to close.
179 * @abrupt: If 0, the connection will be closed gracefully, otherwise, the
180 * connection will be reset.
182 * The IW CM identifier is still active until the IW_CM_EVENT_CLOSE event is
185 int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt);
188 * iw_cm_init_qp_attr - Called to initialize the attributes of the QP
189 * associated with a IW CM identifier.
191 * @cm_id: The IW CM identifier associated with the QP
192 * @qp_attr: Pointer to the QP attributes structure.
193 * @qp_attr_mask: Pointer to a bit vector specifying which QP attributes are
196 int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr,
200 * iwcm_reject_msg - return a pointer to a reject message string.
201 * @reason: Value returned in the REJECT event status field.
203 const char *__attribute_const__ iwcm_reject_msg(int reason);