iPXE
ib_cm.c File Reference

Infiniband communication management. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_mi.h>
#include <ipxe/ib_pathrec.h>
#include <ipxe/ib_cm.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static LIST_HEAD (ib_cm_conns)
 List of connections.
static struct ib_connectionib_cm_find (uint32_t local_id)
 Find connection by local communication ID.
static int ib_cm_send_rtu (struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_tid *tid, struct ib_address_vector *av, uint32_t local_id, uint32_t remote_id)
 Send "ready to use" response.
static void ib_cm_recv_rep (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Handle duplicate connection replies.
static int ib_cm_send_drep (struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_tid *tid, struct ib_address_vector *av, uint32_t local_id, uint32_t remote_id)
 Send reply to disconnection request.
static void ib_cm_recv_dreq (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Handle disconnection requests.
static int ib_cm_rejection_reason_to_rc (uint16_t reason)
 Convert connection rejection reason to return status code.
static void ib_cm_req_complete (struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av)
 Handle connection request transaction completion.
static void ib_cm_path_complete (struct ib_device *ibdev, struct ib_path *path, int rc, struct ib_address_vector *av)
 Handle connection path transaction completion.
struct ib_connectionib_create_conn (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *dgid, union ib_guid *service_id, void *private_data, size_t private_data_len, struct ib_connection_operations *op)
 Create connection to remote QP.
void ib_destroy_conn (struct ib_device *ibdev, struct ib_queue_pair *qp __unused, struct ib_connection *conn)
 Destroy connection to remote QP.

Variables

struct ib_mad_agent ib_cm_agent[] __ib_mad_agent
 Communication management agents.
static struct ib_mad_transaction_operations ib_cm_req_op
 Connection request operations.
static struct ib_path_operations ib_cm_path_op
 Connection path operations.

Detailed Description

Infiniband communication management.

Definition in file ib_cm.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ LIST_HEAD()

LIST_HEAD ( ib_cm_conns )
static

List of connections.

◆ ib_cm_find()

struct ib_connection * ib_cm_find ( uint32_t local_id)
static

Find connection by local communication ID.

Parameters
local_idLocal communication ID
Return values
connConnection, or NULL

Definition at line 53 of file ib_cm.c.

53 {
54 struct ib_connection *conn;
55
56 list_for_each_entry ( conn, &ib_cm_conns, list ) {
57 if ( conn->local_id == local_id )
58 return conn;
59 }
60 return NULL;
61}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
uint32_t local_id
Local communication ID.
Definition ib_mad.h:1
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
An Infiniband connection.
Definition ib_cm.h:35
uint32_t local_id
Local communication ID.
Definition ib_cm.h:41
struct list_head list
List of connections.
Definition ib_cm.h:50

References ib_connection::list, list_for_each_entry, ib_connection::local_id, local_id, and NULL.

Referenced by ib_cm_recv_dreq(), and ib_cm_recv_rep().

◆ ib_cm_send_rtu()

int ib_cm_send_rtu ( struct ib_device * ibdev,
struct ib_mad_interface * mi,
struct ib_mad_tid * tid,
struct ib_address_vector * av,
uint32_t local_id,
uint32_t remote_id )
static

Send "ready to use" response.

Parameters
ibdevInfiniband device
miManagement interface
tidTransaction identifier
avAddress vector
local_idLocal communication ID
remote_idRemote communication ID
Return values
rcReturn status code

Definition at line 74 of file ib_cm.c.

78 {
79 union ib_mad mad;
80 struct ib_cm_ready_to_use *rtu = &mad.cm.cm_data.ready_to_use;
81 int rc;
82
83 /* Construct "ready to use" response */
84 memset ( &mad, 0, sizeof ( mad ) );
85 mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
86 mad.hdr.class_version = IB_CM_CLASS_VERSION;
87 mad.hdr.method = IB_MGMT_METHOD_SEND;
88 memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
89 mad.hdr.attr_id = htons ( IB_CM_ATTR_READY_TO_USE );
90 rtu->local_id = htonl ( local_id );
91 rtu->remote_id = htonl ( remote_id );
92 if ( ( rc = ib_mi_send ( ibdev, mi, &mad, av ) ) != 0 ) {
93 DBGC ( local_id, "CM %08x could not send RTU: %s\n",
94 local_id, strerror ( rc ) );
95 return rc;
96 }
97
98 return 0;
99}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
union ib_mad mad
Definition arbel.h:1
#define DBGC(...)
Definition compiler.h:505
#define IB_MGMT_METHOD_SEND
Definition ib_mad.h:573
struct ib_mad_tid tid
Definition ib_mad.h:6
#define IB_CM_CLASS_VERSION
Communication management class version.
Definition ib_mad.h:312
#define IB_MGMT_CLASS_CM
Definition ib_mad.h:562
#define IB_CM_ATTR_READY_TO_USE
Definition ib_mad.h:320
uint32_t remote_id
Remote communication ID.
Definition ib_mad.h:3
int ib_mi_send(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Transmit MAD.
Definition ib_mi.c:187
#define htonl(value)
Definition byteswap.h:134
#define htons(value)
Definition byteswap.h:136
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
A communication management ready to use reply.
Definition ib_mad.h:467
uint32_t local_id
Local communication ID.
Definition ib_mad.h:469
uint32_t remote_id
Remote communication ID.
Definition ib_mad.h:471
A management datagram.
Definition ib_mad.h:611

References DBGC, htonl, htons, IB_CM_ATTR_READY_TO_USE, IB_CM_CLASS_VERSION, IB_MGMT_CLASS_CM, IB_MGMT_METHOD_SEND, ib_mi_send(), ib_cm_ready_to_use::local_id, local_id, mad, memcpy(), memset(), rc, ib_cm_ready_to_use::remote_id, remote_id, strerror(), and tid.

Referenced by ib_cm_recv_rep(), and ib_cm_req_complete().

◆ ib_cm_recv_rep()

void ib_cm_recv_rep ( struct ib_device * ibdev,
struct ib_mad_interface * mi,
union ib_mad * mad,
struct ib_address_vector * av )
static

Handle duplicate connection replies.

Parameters
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector
Return values
rcReturn status code

If a "ready to use" MAD is lost, the peer may resend the connection reply. We have to respond to these with duplicate "ready to use" MADs, otherwise the peer may time out and drop the connection.

Definition at line 114 of file ib_cm.c.

117 {
118 struct ib_cm_connect_reply *rep = &mad->cm.cm_data.connect_reply;
119 struct ib_connection *conn;
120 uint32_t local_id = ntohl ( rep->remote_id );
121 int rc;
122
123 /* Identify connection */
124 conn = ib_cm_find ( local_id );
125 if ( conn ) {
126 /* Try to send "ready to use" reply */
127 if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
128 conn->local_id,
129 conn->remote_id ) ) != 0 ) {
130 /* Ignore errors; the remote end will retry */
131 }
132 } else {
133 DBGC ( local_id, "CM %08x unexpected REP\n", local_id );
134 }
135}
unsigned int uint32_t
Definition stdint.h:12
static int ib_cm_send_rtu(struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_tid *tid, struct ib_address_vector *av, uint32_t local_id, uint32_t remote_id)
Send "ready to use" response.
Definition ib_cm.c:74
static struct ib_connection * ib_cm_find(uint32_t local_id)
Find connection by local communication ID.
Definition ib_cm.c:53
#define ntohl(value)
Definition byteswap.h:135
A communication management connection reply.
Definition ib_mad.h:436
uint32_t remote_id
Remote communication ID.
Definition ib_mad.h:440
struct ib_device * ibdev
Infiniband device.
Definition ib_cm.h:37
uint32_t remote_id
Remote communication ID.
Definition ib_cm.h:43

References DBGC, ib_cm_find(), ib_cm_send_rtu(), ib_connection::ibdev, ib_connection::local_id, local_id, mad, ntohl, rc, ib_cm_connect_reply::remote_id, and ib_connection::remote_id.

◆ ib_cm_send_drep()

int ib_cm_send_drep ( struct ib_device * ibdev,
struct ib_mad_interface * mi,
struct ib_mad_tid * tid,
struct ib_address_vector * av,
uint32_t local_id,
uint32_t remote_id )
static

Send reply to disconnection request.

Parameters
ibdevInfiniband device
miManagement interface
tidTransaction identifier
avAddress vector
local_idLocal communication ID
remote_idRemote communication ID
Return values
rcReturn status code

Definition at line 148 of file ib_cm.c.

152 {
153 union ib_mad mad;
154 struct ib_cm_disconnect_reply *drep = &mad.cm.cm_data.disconnect_reply;
155 int rc;
156
157 /* Construct reply to disconnection request */
158 memset ( &mad, 0, sizeof ( mad ) );
159 mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
160 mad.hdr.class_version = IB_CM_CLASS_VERSION;
161 mad.hdr.method = IB_MGMT_METHOD_SEND;
162 memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
163 mad.hdr.attr_id = htons ( IB_CM_ATTR_DISCONNECT_REPLY );
164 drep->local_id = htonl ( local_id );
165 drep->remote_id = htonl ( remote_id );
166 if ( ( rc = ib_mi_send ( ibdev, mi, &mad, av ) ) != 0 ) {
167 DBGC ( local_id, "CM %08x could not send DREP: %s\n",
168 local_id, strerror ( rc ) );
169 return rc;
170 }
171
172 return 0;
173}
#define IB_CM_ATTR_DISCONNECT_REPLY
Definition ib_mad.h:322
A communication management disconnection reply.
Definition ib_mad.h:495
uint32_t local_id
Local communication ID.
Definition ib_mad.h:497
uint32_t remote_id
Remote communication ID.
Definition ib_mad.h:499

References DBGC, htonl, htons, IB_CM_ATTR_DISCONNECT_REPLY, IB_CM_CLASS_VERSION, IB_MGMT_CLASS_CM, IB_MGMT_METHOD_SEND, ib_mi_send(), ib_cm_disconnect_reply::local_id, local_id, mad, memcpy(), memset(), rc, ib_cm_disconnect_reply::remote_id, remote_id, strerror(), and tid.

Referenced by ib_cm_recv_dreq().

◆ ib_cm_recv_dreq()

void ib_cm_recv_dreq ( struct ib_device * ibdev,
struct ib_mad_interface * mi,
union ib_mad * mad,
struct ib_address_vector * av )
static

Handle disconnection requests.

Parameters
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector
Return values
rcReturn status code

Definition at line 184 of file ib_cm.c.

187 {
188 struct ib_cm_disconnect_request *dreq =
189 &mad->cm.cm_data.disconnect_request;
190 struct ib_connection *conn;
191 uint32_t local_id = ntohl ( dreq->remote_id );
192 uint32_t remote_id = ntohl ( dreq->local_id );
193 int rc;
194
195 /* Identify connection */
196 conn = ib_cm_find ( local_id );
197 if ( conn ) {
198 /* Notify upper layer */
199 conn->op->changed ( ibdev, conn->qp, conn, -ENOTCONN,
200 &dreq->private_data,
201 sizeof ( dreq->private_data ) );
202 } else {
203 DBGC ( local_id, "CM %08x unexpected DREQ\n", local_id );
204 }
205
206 /* Send reply */
207 if ( ( rc = ib_cm_send_drep ( ibdev, mi, &mad->hdr.tid, av, local_id,
208 remote_id ) ) != 0 ) {
209 /* Ignore errors; the remote end will retry */
210 }
211};
#define ENOTCONN
The socket is not connected.
Definition errno.h:570
static int ib_cm_send_drep(struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_tid *tid, struct ib_address_vector *av, uint32_t local_id, uint32_t remote_id)
Send reply to disconnection request.
Definition ib_cm.c:148
A communication management disconnection request.
Definition ib_mad.h:480
uint32_t local_id
Local communication ID.
Definition ib_mad.h:482
uint32_t remote_id
Remote communication ID.
Definition ib_mad.h:484
uint8_t private_data[220]
Private data.
Definition ib_mad.h:488
void(* changed)(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_connection *conn, int rc, void *private_data, size_t private_data_len)
Handle change of connection status.
Definition ib_cm.h:29
struct ib_connection_operations * op
Connection operations.
Definition ib_cm.h:47
struct ib_queue_pair * qp
Queue pair.
Definition ib_cm.h:39

References ib_connection_operations::changed, DBGC, ENOTCONN, ib_cm_find(), ib_cm_send_drep(), ib_connection::ibdev, ib_cm_disconnect_request::local_id, local_id, mad, ntohl, ib_connection::op, ib_cm_disconnect_request::private_data, ib_connection::qp, rc, ib_cm_disconnect_request::remote_id, and remote_id.

◆ ib_cm_rejection_reason_to_rc()

int ib_cm_rejection_reason_to_rc ( uint16_t reason)
static

Convert connection rejection reason to return status code.

Parameters
reasonRejection reason (in network byte order)
Return values
rcReturn status code

Definition at line 235 of file ib_cm.c.

235 {
236 switch ( reason ) {
238 return -ENODEV;
242 return -ENOTTY;
243 default:
244 return -EPERM;
245 }
246}
#define EALREADY
Connection already in progress.
Definition errno.h:324
#define ENODEV
No such device.
Definition errno.h:510
#define ENOTTY
Inappropriate I/O control operation.
Definition errno.h:595
#define EPERM
Operation not permitted.
Definition errno.h:615
#define IB_CM_REJECT_BAD_SERVICE_ID
CM rejection reasons.
Definition ib_mad.h:428
#define IB_CM_REJECT_CONSUMER
Definition ib_mad.h:430
uint16_t reason
Rejection reason.
Definition ib_mad.h:9
#define IB_CM_REJECT_STALE_CONN
Definition ib_mad.h:429
return
Definition natsemi.h:326

References EALREADY, ENODEV, ENOTTY, EPERM, htons, IB_CM_REJECT_BAD_SERVICE_ID, IB_CM_REJECT_CONSUMER, IB_CM_REJECT_STALE_CONN, and reason.

Referenced by ib_cm_req_complete().

◆ ib_cm_req_complete()

void ib_cm_req_complete ( struct ib_device * ibdev,
struct ib_mad_interface * mi,
struct ib_mad_transaction * madx,
int rc,
union ib_mad * mad,
struct ib_address_vector * av )
static

Handle connection request transaction completion.

Parameters
ibdevInfiniband device
miManagement interface
madxManagement transaction
rcStatus code
madReceived MAD (or NULL on error)
avSource address vector (or NULL on error)

Definition at line 258 of file ib_cm.c.

262 {
263 struct ib_connection *conn = ib_madx_get_ownerdata ( madx );
264 struct ib_queue_pair *qp = conn->qp;
265 struct ib_cm_common *common = &mad->cm.cm_data.common;
266 struct ib_cm_connect_reply *rep = &mad->cm.cm_data.connect_reply;
267 struct ib_cm_connect_reject *rej = &mad->cm.cm_data.connect_reject;
268 uint32_t local_id = conn->local_id;
269 void *private_data = NULL;
270 size_t private_data_len = 0;
271
272 /* Report failures */
273 if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ))
274 rc = -EIO;
275 if ( rc != 0 ) {
276 DBGC ( local_id, "CM %08x connection request failed: %s\n",
277 local_id, strerror ( rc ) );
278 goto out;
279 }
280
281 /* Record remote communication ID */
282 conn->remote_id = ntohl ( common->local_id );
283
284 /* Handle response */
285 switch ( mad->hdr.attr_id ) {
286
288 /* Extract fields */
289 qp->av.qpn = ( ntohl ( rep->local_qpn ) >> 8 );
290 qp->send.psn = ( ntohl ( rep->starting_psn ) >> 8 );
292 private_data_len = sizeof ( rep->private_data );
293 DBGC ( local_id, "CM %08x connected to QPN %#lx PSN %#x\n",
294 local_id, qp->av.qpn, qp->send.psn );
295
296 /* Modify queue pair */
297 if ( ( rc = ib_modify_qp ( ibdev, qp ) ) != 0 ) {
298 DBGC ( local_id, "CM %08x could not modify queue "
299 "pair: %s\n", local_id, strerror ( rc ) );
300 goto out;
301 }
302
303 /* Send "ready to use" reply */
304 if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
305 conn->local_id,
306 conn->remote_id ) ) != 0 ) {
307 /* Treat as non-fatal */
308 rc = 0;
309 }
310 break;
311
313 /* Extract fields */
314 DBGC ( local_id, "CM %08x connection rejected (reason %d)\n",
315 local_id, ntohs ( rej->reason ) );
316 /* Private data is valid only for a Consumer Reject */
317 if ( rej->reason == htons ( IB_CM_REJECT_CONSUMER ) ) {
319 private_data_len = sizeof ( rej->private_data );
320 }
322 break;
323
324 default:
325 DBGC ( local_id, "CM %08x unexpected response (attribute "
326 "%04x)\n", local_id, ntohs ( mad->hdr.attr_id ) );
327 rc = -ENOTSUP;
328 break;
329 }
330
331 out:
332 /* Destroy the completed transaction */
333 ib_destroy_madx ( ibdev, ibdev->gsi, madx );
334 conn->madx = NULL;
335
336 /* Hand off to the upper completion handler */
337 conn->op->changed ( ibdev, qp, conn, rc, private_data,
338 private_data_len );
339}
__be32 qpn
Definition CIB_PRM.h:1
__be32 out[4]
Definition CIB_PRM.h:8
struct arbelprm_qp_db_record qp
Definition arbel.h:2
#define EIO
Input/output error.
Definition errno.h:434
#define ENOTSUP
Operation not supported.
Definition errno.h:590
static int ib_cm_rejection_reason_to_rc(uint16_t reason)
Convert connection rejection reason to return status code.
Definition ib_cm.c:235
#define IB_CM_ATTR_CONNECT_REPLY
Definition ib_mad.h:319
struct ib_cm_common common
Definition ib_mad.h:0
#define IB_MGMT_STATUS_OK
Definition ib_mad.h:581
uint8_t private_data[92]
Private data.
Definition ib_mad.h:33
#define IB_CM_ATTR_CONNECT_REJECT
Definition ib_mad.h:318
uint32_t local_qpn
Local QPN.
Definition ib_mad.h:7
void ib_destroy_madx(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
Destroy management transaction.
Definition ib_mi.c:327
static __always_inline void * ib_madx_get_ownerdata(struct ib_mad_transaction *madx)
Get Infiniband management transaction owner-private data.
Definition ib_mi.h:117
#define ntohs(value)
Definition byteswap.h:137
int ib_modify_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition infiniband.c:294
Communication management common fields.
Definition ib_mad.h:329
A communication management connection rejection.
Definition ib_mad.h:410
uint8_t private_data[148]
Private data.
Definition ib_mad.h:424
uint16_t reason
Rejection reason.
Definition ib_mad.h:420
uint32_t starting_psn
Starting PSN.
Definition ib_mad.h:448
uint8_t private_data[196]
Private data.
Definition ib_mad.h:460
struct ib_mad_transaction * madx
Connection request management transaction.
Definition ib_cm.h:55
struct ib_mad_interface * gsi
General services interface.
Definition infiniband.h:462
An Infiniband Queue Pair.
Definition infiniband.h:158

References ib_connection_operations::changed, common, DBGC, EIO, ENOTSUP, ib_device::gsi, htons, IB_CM_ATTR_CONNECT_REJECT, IB_CM_ATTR_CONNECT_REPLY, IB_CM_REJECT_CONSUMER, ib_cm_rejection_reason_to_rc(), ib_cm_send_rtu(), ib_destroy_madx(), ib_madx_get_ownerdata(), IB_MGMT_STATUS_OK, ib_modify_qp(), ib_connection::local_id, local_id, ib_cm_connect_reply::local_qpn, mad, ib_connection::madx, ntohl, ntohs, NULL, ib_connection::op, out, ib_cm_connect_reject::private_data, ib_cm_connect_reply::private_data, private_data, ib_connection::qp, qp, rc, ib_cm_connect_reject::reason, ib_connection::remote_id, ib_cm_connect_reply::starting_psn, and strerror().

◆ ib_cm_path_complete()

void ib_cm_path_complete ( struct ib_device * ibdev,
struct ib_path * path,
int rc,
struct ib_address_vector * av )
static

Handle connection path transaction completion.

Parameters
ibdevInfiniband device
pathPath
rcStatus code
avAddress vector, or NULL on error

Definition at line 354 of file ib_cm.c.

356 {
357 struct ib_connection *conn = ib_path_get_ownerdata ( path );
358 struct ib_queue_pair *qp = conn->qp;
359 union ib_mad mad;
360 struct ib_cm_connect_request *req = &mad.cm.cm_data.connect_request;
361 uint32_t local_id = conn->local_id;
362 size_t private_data_len;
363
364 /* Report failures */
365 if ( rc != 0 ) {
366 DBGC ( local_id, "CM %08x path lookup failed: %s\n",
367 local_id, strerror ( rc ) );
368 conn->op->changed ( ibdev, qp, conn, rc, NULL, 0 );
369 goto out;
370 }
371
372 /* Update queue pair peer path */
373 memcpy ( &qp->av, av, sizeof ( qp->av ) );
374
375 /* Construct connection request */
376 memset ( &mad, 0, sizeof ( mad ) );
377 mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
378 mad.hdr.class_version = IB_CM_CLASS_VERSION;
379 mad.hdr.method = IB_MGMT_METHOD_SEND;
380 mad.hdr.attr_id = htons ( IB_CM_ATTR_CONNECT_REQUEST );
381 req->local_id = htonl ( conn->local_id );
382 memcpy ( &req->service_id, &conn->service_id,
383 sizeof ( req->service_id ) );
384 memcpy ( &req->local_ca, &ibdev->node_guid, sizeof ( req->local_ca ) );
385 req->local_qpn__responder_resources = htonl ( ( qp->qpn << 8 ) | 1 );
386 req->local_eecn__initiator_depth = htonl ( ( 0 << 8 ) | 1 );
388 htonl ( ( 0x14 << 3 ) | ( IB_CM_TRANSPORT_RC << 1 ) |
389 ( 0 << 0 ) );
391 htonl ( ( qp->recv.psn << 8 ) | ( 0x14 << 3 ) |
392 ( 0x07 << 0 ) );
393 req->pkey = htons ( ibdev->pkey );
395 ( ( IB_MTU_2048 << 4 ) | ( 1 << 3 ) | ( 0x07 << 0 ) );
396 req->max_cm_retries__srq = ( ( 0x0f << 4 ) | ( 0 << 3 ) );
397 req->primary.local_lid = htons ( ibdev->lid );
398 req->primary.remote_lid = htons ( conn->qp->av.lid );
399 memcpy ( &req->primary.local_gid, &ibdev->gid,
400 sizeof ( req->primary.local_gid ) );
401 memcpy ( &req->primary.remote_gid, &conn->qp->av.gid,
402 sizeof ( req->primary.remote_gid ) );
404 htonl ( ( 0 << 12 ) | ( conn->qp->av.rate << 0 ) );
405 req->primary.hop_limit = 0;
407 ( ( conn->qp->av.sl << 4 ) | ( 1 << 3 ) );
408 req->primary.local_ack_timeout = ( 0x13 << 3 );
409 private_data_len = conn->private_data_len;
410 if ( private_data_len > sizeof ( req->private_data ) )
411 private_data_len = sizeof ( req->private_data );
412 memcpy ( &req->private_data, &conn->private_data, private_data_len );
413
414 /* Create connection request */
415 av->qpn = IB_QPN_GSI;
416 av->qkey = IB_QKEY_GSI;
417 conn->madx = ib_create_madx ( ibdev, ibdev->gsi, &mad, av,
418 &ib_cm_req_op );
419 if ( ! conn->madx ) {
420 DBGC ( local_id, "CM %08x could not create connection "
421 "request\n", local_id );
422 conn->op->changed ( ibdev, qp, conn, rc, NULL, 0 );
423 goto out;
424 }
425 ib_madx_set_ownerdata ( conn->madx, conn );
426
427 out:
428 /* Destroy the completed transaction */
429 ib_destroy_path ( ibdev, path );
430 conn->path = NULL;
431}
static struct ib_mad_transaction_operations ib_cm_req_op
Connection request operations.
Definition ib_cm.c:342
#define IB_CM_ATTR_CONNECT_REQUEST
Definition ib_mad.h:316
#define IB_CM_TRANSPORT_RC
CM transport types.
Definition ib_mad.h:402
#define IB_MTU_2048
Definition ib_mad.h:163
struct ib_mad_transaction * ib_create_madx(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av, struct ib_mad_transaction_operations *op)
Create management transaction.
Definition ib_mi.c:287
static __always_inline void ib_madx_set_ownerdata(struct ib_mad_transaction *madx, void *priv)
Set Infiniband management transaction owner-private data.
Definition ib_mi.h:106
void ib_destroy_path(struct ib_device *ibdev, struct ib_path *path)
Destroy path.
Definition ib_pathrec.c:156
static __always_inline void * ib_path_get_ownerdata(struct ib_path *path)
Get Infiniband path owner-private data.
Definition ib_pathrec.h:63
#define IB_QPN_GSI
General service interface QPN.
Definition infiniband.h:28
#define IB_QKEY_GSI
General service interface queue key.
Definition infiniband.h:31
unsigned int sl
Service level.
Definition infiniband.h:89
unsigned long qkey
Queue key.
Definition infiniband.h:80
unsigned int lid
Local ID.
Definition infiniband.h:82
enum ib_rate rate
Rate.
Definition infiniband.h:87
union ib_gid gid
GID, if present.
Definition infiniband.h:93
unsigned long qpn
Queue Pair Number.
Definition infiniband.h:75
A communication management connection request.
Definition ib_mad.h:364
uint8_t max_cm_retries__srq
Max CM retries and SRQ.
Definition ib_mad.h:392
union ib_guid service_id
Service ID.
Definition ib_mad.h:370
uint32_t local_eecn__initiator_depth
Local EECN and initiator depth.
Definition ib_mad.h:380
struct ib_cm_path primary
Primary path.
Definition ib_mad.h:394
union ib_guid local_ca
Local CA GUID.
Definition ib_mad.h:372
uint16_t pkey
Partition key.
Definition ib_mad.h:388
uint32_t local_qpn__responder_resources
Local QPN and responder resources.
Definition ib_mad.h:378
uint32_t starting_psn__local_timeout__retry_count
Starting PSN, local CM response timeout and retry count.
Definition ib_mad.h:386
uint32_t remote_eecn__remote_timeout__service_type__ee_flow_ctrl
Remote EECN, remote CM response timeout, transport service type, EE flow control.
Definition ib_mad.h:384
uint32_t local_id
Local communication ID.
Definition ib_mad.h:366
uint8_t payload_mtu__rdc_exists__rnr_retry
Path packet payload MTU, RDC exists, RNR retry count.
Definition ib_mad.h:390
uint8_t private_data[92]
Private data.
Definition ib_mad.h:398
union ib_gid remote_gid
Remote port GID.
Definition ib_mad.h:347
uint8_t hop_limit
Hop limit.
Definition ib_mad.h:353
uint16_t local_lid
Local port LID.
Definition ib_mad.h:341
union ib_gid local_gid
Local port GID.
Definition ib_mad.h:345
uint8_t sl__subnet_local
SL and subnet local.
Definition ib_mad.h:355
uint8_t local_ack_timeout
Local ACK timeout.
Definition ib_mad.h:357
uint32_t flow_label__rate
Flow label and rate.
Definition ib_mad.h:349
uint16_t remote_lid
Remote port LID.
Definition ib_mad.h:343
union ib_guid service_id
Target service ID.
Definition ib_cm.h:45
size_t private_data_len
Length of connection request private data.
Definition ib_cm.h:58
uint8_t private_data[0]
Connection request private data.
Definition ib_cm.h:60
struct ib_path * path
Path to target.
Definition ib_cm.h:53
union ib_guid node_guid
Node GUID.
Definition infiniband.h:440
uint16_t pkey
Partition key.
Definition infiniband.h:450
uint16_t lid
Port LID.
Definition infiniband.h:444
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition infiniband.h:442
struct ib_address_vector av
Address vector.
Definition infiniband.h:185

References ib_queue_pair::av, ib_connection_operations::changed, DBGC, ib_cm_path::flow_label__rate, ib_address_vector::gid, ib_device::gid, ib_device::gsi, ib_cm_path::hop_limit, htonl, htons, IB_CM_ATTR_CONNECT_REQUEST, IB_CM_CLASS_VERSION, ib_cm_req_op, IB_CM_TRANSPORT_RC, ib_create_madx(), ib_destroy_path(), ib_madx_set_ownerdata(), IB_MGMT_CLASS_CM, IB_MGMT_METHOD_SEND, IB_MTU_2048, ib_path_get_ownerdata(), IB_QKEY_GSI, IB_QPN_GSI, ib_address_vector::lid, ib_device::lid, ib_cm_path::local_ack_timeout, ib_cm_connect_request::local_ca, ib_cm_connect_request::local_eecn__initiator_depth, ib_cm_path::local_gid, ib_cm_connect_request::local_id, ib_connection::local_id, local_id, ib_cm_path::local_lid, ib_cm_connect_request::local_qpn__responder_resources, mad, ib_connection::madx, ib_cm_connect_request::max_cm_retries__srq, memcpy(), memset(), ib_device::node_guid, NULL, ib_connection::op, out, ib_connection::path, ib_cm_connect_request::payload_mtu__rdc_exists__rnr_retry, ib_cm_connect_request::pkey, ib_device::pkey, ib_cm_connect_request::primary, ib_cm_connect_request::private_data, ib_connection::private_data, ib_connection::private_data_len, ib_address_vector::qkey, ib_connection::qp, qp, ib_address_vector::qpn, ib_address_vector::rate, rc, ib_cm_connect_request::remote_eecn__remote_timeout__service_type__ee_flow_ctrl, ib_cm_path::remote_gid, ib_cm_path::remote_lid, ib_cm_connect_request::service_id, ib_connection::service_id, ib_address_vector::sl, ib_cm_path::sl__subnet_local, ib_cm_connect_request::starting_psn__local_timeout__retry_count, and strerror().

◆ ib_create_conn()

struct ib_connection * ib_create_conn ( struct ib_device * ibdev,
struct ib_queue_pair * qp,
union ib_gid * dgid,
union ib_guid * service_id,
void * private_data,
size_t private_data_len,
struct ib_connection_operations * op )

Create connection to remote QP.

Parameters
ibdevInfiniband device
qpQueue pair
dgidTarget GID
service_idTarget service ID
private_dataConnection request private data
private_data_lenLength of connection request private data
opConnection operations
Return values
connConnection

Definition at line 451 of file ib_cm.c.

454 {
455 struct ib_connection *conn;
457
458 /* Allocate and initialise request */
459 conn = zalloc ( sizeof ( *conn ) + private_data_len );
460 if ( ! conn )
461 goto err_alloc_conn;
462 conn->ibdev = ibdev;
463 conn->qp = qp;
464 memset ( &qp->av, 0, sizeof ( qp->av ) );
465 qp->av.gid_present = 1;
466 memcpy ( &qp->av.gid, dgid, sizeof ( qp->av.gid ) );
467 conn->local_id = local_id = random();
468 memcpy ( &conn->service_id, service_id, sizeof ( conn->service_id ) );
469 conn->op = op;
472
473 /* Create path */
474 conn->path = ib_create_path ( ibdev, &qp->av, &ib_cm_path_op );
475 if ( ! conn->path )
476 goto err_create_path;
477 ib_path_set_ownerdata ( conn->path, conn );
478
479 /* Add to list of connections */
480 list_add ( &conn->list, &ib_cm_conns );
481
482 DBGC ( local_id, "CM %08x created for IBDEV %s QPN %#lx\n",
483 local_id, ibdev->name, qp->qpn );
484 DBGC ( local_id, "CM %08x connecting to " IB_GID_FMT " "
487
488 return conn;
489
490 ib_destroy_path ( ibdev, conn->path );
491 err_create_path:
492 free ( conn );
493 err_alloc_conn:
494 return NULL;
495}
static struct ib_path_operations ib_cm_path_op
Connection path operations.
Definition ib_cm.c:434
union ib_gid dgid
Definition ib_mad.h:1
union ib_guid service_id
Service ID.
Definition ib_mad.h:5
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition ib_packet.h:49
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition ib_packet.h:46
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition ib_packet.h:27
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition ib_packet.h:30
struct ib_path * ib_create_path(struct ib_device *ibdev, struct ib_address_vector *av, struct ib_path_operations *op)
Create path.
Definition ib_pathrec.c:107
static __always_inline void ib_path_set_ownerdata(struct ib_path *path, void *priv)
Set Infiniband path owner-private data.
Definition ib_pathrec.h:52
#define list_add(new, head)
Add a new entry to the head of a list.
Definition list.h:70
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition random.c:32
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition infiniband.h:409

References DBGC, dgid, free, ib_cm_path_op, ib_create_path(), ib_destroy_path(), IB_GID_ARGS, IB_GID_FMT, IB_GUID_ARGS, IB_GUID_FMT, ib_path_set_ownerdata(), ib_connection::ibdev, ib_connection::list, list_add, ib_connection::local_id, local_id, memcpy(), memset(), ib_device::name, NULL, ib_connection::op, op, ib_connection::path, ib_connection::private_data, private_data, ib_connection::private_data_len, ib_connection::qp, qp, random(), ib_connection::service_id, service_id, and zalloc().

Referenced by ib_cmrc_xfer_deliver().

◆ ib_destroy_conn()

void ib_destroy_conn ( struct ib_device * ibdev,
struct ib_queue_pair *qp __unused,
struct ib_connection * conn )

Destroy connection to remote QP.

Parameters
ibdevInfiniband device
qpQueue pair
connConnection

Definition at line 504 of file ib_cm.c.

506 {
507
508 list_del ( &conn->list );
509 if ( conn->madx )
510 ib_destroy_madx ( ibdev, ibdev->gsi, conn->madx );
511 if ( conn->path )
512 ib_destroy_path ( ibdev, conn->path );
513 free ( conn );
514}
#define list_del(list)
Delete an entry from a list.
Definition list.h:120

References __unused, free, ib_device::gsi, ib_destroy_madx(), ib_destroy_path(), ib_connection::ibdev, ib_connection::list, list_del, ib_connection::madx, ib_connection::path, and qp.

Referenced by ib_cmrc_shutdown().

Variable Documentation

◆ __ib_mad_agent

struct ib_mad_agent ib_cm_agent [] __ib_mad_agent
Initial value:
= {
{
.mgmt_class = IB_MGMT_CLASS_CM,
.class_version = IB_CM_CLASS_VERSION,
.handle = ib_cm_recv_rep,
},
{
.mgmt_class = IB_MGMT_CLASS_CM,
.class_version = IB_CM_CLASS_VERSION,
.handle = ib_cm_recv_dreq,
},
}
static void ib_cm_recv_rep(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Handle duplicate connection replies.
Definition ib_cm.c:114
static void ib_cm_recv_dreq(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Handle disconnection requests.
Definition ib_cm.c:184
#define IB_CM_ATTR_DISCONNECT_REQUEST
Definition ib_mad.h:321

Communication management agents.

Definition at line 214 of file ib_cm.c.

214 {
215 {
216 .mgmt_class = IB_MGMT_CLASS_CM,
217 .class_version = IB_CM_CLASS_VERSION,
218 .attr_id = htons ( IB_CM_ATTR_CONNECT_REPLY ),
219 .handle = ib_cm_recv_rep,
220 },
221 {
222 .mgmt_class = IB_MGMT_CLASS_CM,
223 .class_version = IB_CM_CLASS_VERSION,
225 .handle = ib_cm_recv_dreq,
226 },
227};

◆ ib_cm_req_op

struct ib_mad_transaction_operations ib_cm_req_op
static
Initial value:
= {
.complete = ib_cm_req_complete,
}
static void ib_cm_req_complete(struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av)
Handle connection request transaction completion.
Definition ib_cm.c:258

Connection request operations.

Definition at line 342 of file ib_cm.c.

342 {
343 .complete = ib_cm_req_complete,
344};

Referenced by ib_cm_path_complete().

◆ ib_cm_path_op

struct ib_path_operations ib_cm_path_op
static
Initial value:
= {
.complete = ib_cm_path_complete,
}
static void ib_cm_path_complete(struct ib_device *ibdev, struct ib_path *path, int rc, struct ib_address_vector *av)
Handle connection path transaction completion.
Definition ib_cm.c:354

Connection path operations.

Definition at line 434 of file ib_cm.c.

434 {
435 .complete = ib_cm_path_complete,
436};

Referenced by ib_create_conn().