Browse Source

[infiniband] Assign names to CMRC connections

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
174bf6b569
3 changed files with 53 additions and 40 deletions
  1. 3
    4
      src/include/ipxe/ib_cmrc.h
  2. 49
    35
      src/net/infiniband/ib_cmrc.c
  3. 1
    1
      src/net/infiniband/ib_srp.c

+ 3
- 4
src/include/ipxe/ib_cmrc.h View File

@@ -12,9 +12,8 @@ FILE_LICENCE ( BSD2 );
12 12
 #include <ipxe/infiniband.h>
13 13
 #include <ipxe/xfer.h>
14 14
 
15
-extern int ib_cmrc_open ( struct interface *xfer,
16
-			  struct ib_device *ibdev,
17
-			  union ib_gid *dgid,
18
-			  union ib_guid *service_id );
15
+extern int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
16
+			  union ib_gid *dgid, union ib_guid *service_id,
17
+			  const char *name );
19 18
 
20 19
 #endif /* _IPXE_IB_CMRC_H */

+ 49
- 35
src/net/infiniband/ib_cmrc.c View File

@@ -69,6 +69,8 @@ FILE_LICENCE ( BSD2 );
69 69
 struct ib_cmrc_connection {
70 70
 	/** Reference count */
71 71
 	struct refcnt refcnt;
72
+	/** Name */
73
+	const char *name;
72 74
 	/** Data transfer interface */
73 75
 	struct interface xfer;
74 76
 	/** Infiniband device */
@@ -108,14 +110,16 @@ struct ib_cmrc_connection {
108 110
  * shutdown process has run.
109 111
  */
110 112
 static void ib_cmrc_shutdown ( struct ib_cmrc_connection *cmrc ) {
113
+	struct ib_device *ibdev = cmrc->ibdev;
111 114
 
112
-	DBGC ( cmrc, "CMRC %p shutting down\n", cmrc );
115
+	DBGC ( cmrc, "CMRC %s %s shutting down\n",
116
+	       ibdev->name, cmrc->name );
113 117
 
114 118
 	/* Shut down Infiniband interface */
115
-	ib_destroy_conn ( cmrc->ibdev, cmrc->qp, cmrc->conn );
116
-	ib_destroy_qp ( cmrc->ibdev, cmrc->qp );
117
-	ib_destroy_cq ( cmrc->ibdev, cmrc->cq );
118
-	ib_close ( cmrc->ibdev );
119
+	ib_destroy_conn ( ibdev, cmrc->qp, cmrc->conn );
120
+	ib_destroy_qp ( ibdev, cmrc->qp );
121
+	ib_destroy_cq ( ibdev, cmrc->cq );
122
+	ib_close ( ibdev );
119 123
 
120 124
 	/* Cancel any pending shutdown */
121 125
 	process_del ( &cmrc->shutdown );
@@ -149,7 +153,7 @@ static void ib_cmrc_close ( struct ib_cmrc_connection *cmrc, int rc ) {
149 153
  * @v private_data	Private data, if available
150 154
  * @v private_data_len	Length of private data
151 155
  */
152
-static void ib_cmrc_changed ( struct ib_device *ibdev __unused,
156
+static void ib_cmrc_changed ( struct ib_device *ibdev,
153 157
 			      struct ib_queue_pair *qp,
154 158
 			      struct ib_connection *conn __unused, int rc_cm,
155 159
 			      void *private_data, size_t private_data_len ) {
@@ -158,22 +162,24 @@ static void ib_cmrc_changed ( struct ib_device *ibdev __unused,
158 162
 
159 163
 	/* Record connection status */
160 164
 	if ( rc_cm == 0 ) {
161
-		DBGC ( cmrc, "CMRC %p connected\n", cmrc );
165
+		DBGC ( cmrc, "CMRC %s %s connected\n",
166
+		       ibdev->name, cmrc->name );
162 167
 		cmrc->connected = 1;
163 168
 	} else {
164
-		DBGC ( cmrc, "CMRC %p disconnected: %s\n",
165
-		       cmrc, strerror ( rc_cm ) );
169
+		DBGC ( cmrc, "CMRC %s %s disconnected: %s\n",
170
+		       ibdev->name, cmrc->name, strerror ( rc_cm ) );
166 171
 		cmrc->connected = 0;
167 172
 	}
168 173
 
169 174
 	/* Pass up any private data */
170
-	DBGC2 ( cmrc, "CMRC %p received private data:\n", cmrc );
175
+	DBGC2 ( cmrc, "CMRC %s %s received private data:\n",
176
+		ibdev->name, cmrc->name );
171 177
 	DBGC2_HDA ( cmrc, 0, private_data, private_data_len );
172 178
 	if ( private_data &&
173 179
 	     ( rc_xfer = xfer_deliver_raw ( &cmrc->xfer, private_data,
174 180
 					    private_data_len ) ) != 0 ) {
175
-		DBGC ( cmrc, "CMRC %p could not deliver private data: %s\n",
176
-		       cmrc, strerror ( rc_xfer ) );
181
+		DBGC ( cmrc, "CMRC %s %s could not deliver private data: %s\n",
182
+		       ibdev->name, cmrc->name, strerror ( rc_xfer ) );
177 183
 		ib_cmrc_close ( cmrc, rc_xfer );
178 184
 		return;
179 185
 	}
@@ -201,7 +207,7 @@ static struct ib_connection_operations ib_cmrc_conn_op = {
201 207
  * @v iobuf		I/O buffer
202 208
  * @v rc		Completion status code
203 209
  */
204
-static void ib_cmrc_complete_send ( struct ib_device *ibdev __unused,
210
+static void ib_cmrc_complete_send ( struct ib_device *ibdev,
205 211
 				    struct ib_queue_pair *qp,
206 212
 				    struct io_buffer *iobuf, int rc ) {
207 213
 	struct ib_cmrc_connection *cmrc = ib_qp_get_ownerdata ( qp );
@@ -211,8 +217,8 @@ static void ib_cmrc_complete_send ( struct ib_device *ibdev __unused,
211 217
 
212 218
 	/* Close the connection on any send errors */
213 219
 	if ( rc != 0 ) {
214
-		DBGC ( cmrc, "CMRC %p send error: %s\n",
215
-		       cmrc, strerror ( rc ) );
220
+		DBGC ( cmrc, "CMRC %s %s send error: %s\n",
221
+		       ibdev->name, cmrc->name, strerror ( rc ) );
216 222
 		ib_cmrc_close ( cmrc, rc );
217 223
 		return;
218 224
 	}
@@ -228,7 +234,7 @@ static void ib_cmrc_complete_send ( struct ib_device *ibdev __unused,
228 234
  * @v iobuf		I/O buffer
229 235
  * @v rc		Completion status code
230 236
  */
231
-static void ib_cmrc_complete_recv ( struct ib_device *ibdev __unused,
237
+static void ib_cmrc_complete_recv ( struct ib_device *ibdev,
232 238
 				    struct ib_queue_pair *qp,
233 239
 				    struct ib_address_vector *dest __unused,
234 240
 				    struct ib_address_vector *source __unused,
@@ -237,20 +243,20 @@ static void ib_cmrc_complete_recv ( struct ib_device *ibdev __unused,
237 243
 
238 244
 	/* Close the connection on any receive errors */
239 245
 	if ( rc != 0 ) {
240
-		DBGC ( cmrc, "CMRC %p receive error: %s\n",
241
-		       cmrc, strerror ( rc ) );
246
+		DBGC ( cmrc, "CMRC %s %s receive error: %s\n",
247
+		       ibdev->name, cmrc->name, strerror ( rc ) );
242 248
 		free_iob ( iobuf );
243 249
 		ib_cmrc_close ( cmrc, rc );
244 250
 		return;
245 251
 	}
246 252
 
247
-	DBGC2 ( cmrc, "CMRC %p received:\n", cmrc );
253
+	DBGC2 ( cmrc, "CMRC %s %s received:\n", ibdev->name, cmrc->name );
248 254
 	DBGC2_HDA ( cmrc, 0, iobuf->data, iob_len ( iobuf ) );
249 255
 
250 256
 	/* Pass up data */
251 257
 	if ( ( rc = xfer_deliver_iob ( &cmrc->xfer, iobuf ) ) != 0 ) {
252
-		DBGC ( cmrc, "CMRC %p could not deliver data: %s\n",
253
-		       cmrc, strerror ( rc ) );
258
+		DBGC ( cmrc, "CMRC %s %s could not deliver data: %s\n",
259
+		       ibdev->name, cmrc->name, strerror ( rc ) );
254 260
 		ib_cmrc_close ( cmrc, rc );
255 261
 		return;
256 262
 	}
@@ -278,6 +284,7 @@ static struct ib_queue_pair_operations ib_cmrc_queue_pair_ops = {
278 284
 static int ib_cmrc_xfer_deliver ( struct ib_cmrc_connection *cmrc,
279 285
 				  struct io_buffer *iobuf,
280 286
 				  struct xfer_metadata *meta __unused ) {
287
+	struct ib_device *ibdev = cmrc->ibdev;
281 288
 	int rc;
282 289
 
283 290
 	/* If no connection has yet been attempted, send this datagram
@@ -287,8 +294,9 @@ static int ib_cmrc_xfer_deliver ( struct ib_cmrc_connection *cmrc,
287 294
 
288 295
 		/* Abort if we have already sent a CM connection request */
289 296
 		if ( cmrc->conn ) {
290
-			DBGC ( cmrc, "CMRC %p attempt to send before "
291
-			       "connection is complete\n", cmrc );
297
+			DBGC ( cmrc, "CMRC %s %s attempt to send before "
298
+			       "connection is complete\n",
299
+			       ibdev->name, cmrc->name );
292 300
 			rc = -EIO;
293 301
 			goto out;
294 302
 		}
@@ -299,20 +307,21 @@ static int ib_cmrc_xfer_deliver ( struct ib_cmrc_connection *cmrc,
299 307
 					      iobuf->data, iob_len ( iobuf ),
300 308
 					      &ib_cmrc_conn_op );
301 309
 		if ( ! cmrc->conn ) {
302
-			DBGC ( cmrc, "CMRC %p could not connect\n", cmrc );
310
+			DBGC ( cmrc, "CMRC %s %s could not connect\n",
311
+			       ibdev->name, cmrc->name );
303 312
 			rc = -ENOMEM;
304 313
 			goto out;
305 314
 		}
306
-		DBGC ( cmrc, "CMRC %p using CM %08x\n",
307
-		       cmrc, cmrc->conn->local_id );
315
+		DBGC ( cmrc, "CMRC %s %s using CM %08x\n",
316
+		       ibdev->name, cmrc->name, cmrc->conn->local_id );
308 317
 
309 318
 	} else {
310 319
 
311 320
 		/* Send via QP */
312 321
 		if ( ( rc = ib_post_send ( cmrc->ibdev, cmrc->qp, NULL,
313 322
 					   iob_disown ( iobuf ) ) ) != 0 ) {
314
-			DBGC ( cmrc, "CMRC %p could not send: %s\n",
315
-			       cmrc, strerror ( rc ) );
323
+			DBGC ( cmrc, "CMRC %s %s could not send: %s\n",
324
+			       ibdev->name, cmrc->name, strerror ( rc ) );
316 325
 			goto out;
317 326
 		}
318 327
 
@@ -382,10 +391,12 @@ static struct process_descriptor ib_cmrc_shutdown_desc =
382 391
  * @v ibdev		Infiniband device
383 392
  * @v dgid		Destination GID
384 393
  * @v service_id	Service ID
394
+ * @v name		Connection name
385 395
  * @ret rc		Returns status code
386 396
  */
387 397
 int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
388
-		   union ib_gid *dgid, union ib_guid *service_id ) {
398
+		   union ib_gid *dgid, union ib_guid *service_id,
399
+		   const char *name ) {
389 400
 	struct ib_cmrc_connection *cmrc;
390 401
 	int rc;
391 402
 
@@ -396,6 +407,7 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
396 407
 		goto err_alloc;
397 408
 	}
398 409
 	ref_init ( &cmrc->refcnt, NULL );
410
+	cmrc->name = name;
399 411
 	intf_init ( &cmrc->xfer, &ib_cmrc_xfer_desc, &cmrc->refcnt );
400 412
 	cmrc->ibdev = ibdev;
401 413
 	memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
@@ -405,8 +417,8 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
405 417
 
406 418
 	/* Open Infiniband device */
407 419
 	if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
408
-		DBGC ( cmrc, "CMRC %p could not open device: %s\n",
409
-		       cmrc, strerror ( rc ) );
420
+		DBGC ( cmrc, "CMRC %s %s could not open device: %s\n",
421
+		       ibdev->name, cmrc->name, strerror ( rc ) );
410 422
 		goto err_open;
411 423
 	}
412 424
 
@@ -414,8 +426,8 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
414 426
 	cmrc->cq = ib_create_cq ( ibdev, IB_CMRC_NUM_CQES,
415 427
 				  &ib_cmrc_completion_ops );
416 428
 	if ( ! cmrc->cq ) {
417
-		DBGC ( cmrc, "CMRC %p could not create completion queue\n",
418
-		       cmrc );
429
+		DBGC ( cmrc, "CMRC %s %s could not create completion queue\n",
430
+		       ibdev->name, cmrc->name );
419 431
 		rc = -ENOMEM;
420 432
 		goto err_create_cq;
421 433
 	}
@@ -425,12 +437,14 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
425 437
 				  cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq,
426 438
 				  &ib_cmrc_queue_pair_ops );
427 439
 	if ( ! cmrc->qp ) {
428
-		DBGC ( cmrc, "CMRC %p could not create queue pair\n", cmrc );
440
+		DBGC ( cmrc, "CMRC %s %s could not create queue pair\n",
441
+		       ibdev->name, cmrc->name );
429 442
 		rc = -ENOMEM;
430 443
 		goto err_create_qp;
431 444
 	}
432 445
 	ib_qp_set_ownerdata ( cmrc->qp, cmrc );
433
-	DBGC ( cmrc, "CMRC %p using QPN %#lx\n", cmrc, cmrc->qp->qpn );
446
+	DBGC ( cmrc, "CMRC %s %s using QPN %#lx\n",
447
+	       ibdev->name, cmrc->name, cmrc->qp->qpn );
434 448
 
435 449
 	/* Attach to parent interface, transfer reference (implicitly)
436 450
 	 * to our shutdown process, and return.

+ 1
- 1
src/net/infiniband/ib_srp.c View File

@@ -210,7 +210,7 @@ static int ib_srp_open ( struct interface *block, struct ib_device *ibdev,
210 210
 
211 211
 	/* Open CMRC socket */
212 212
 	if ( ( rc = ib_cmrc_open ( &ib_srp->cmrc, ibdev, dgid,
213
-				   service_id ) ) != 0 ) {
213
+				   service_id, "SRP" ) ) != 0 ) {
214 214
 		DBGC ( ib_srp, "IBSRP %p could not open CMRC socket: %s\n",
215 215
 		       ib_srp, strerror ( rc ) );
216 216
 		goto err_cmrc_open;

Loading…
Cancel
Save