Sfoglia il codice sorgente

[infiniband] Return status code from ib_create_mi()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 anni fa
parent
commit
c26c1fd07c
3 ha cambiato i file con 19 aggiunte e 16 eliminazioni
  1. 3
    2
      src/include/ipxe/ib_mi.h
  2. 6
    8
      src/net/infiniband.c
  3. 10
    6
      src/net/infiniband/ib_mi.c

+ 3
- 2
src/include/ipxe/ib_mi.h Vedi File

@@ -127,8 +127,9 @@ ib_create_madx ( struct ib_device *ibdev, struct ib_mad_interface *mi,
127 127
 extern void ib_destroy_madx ( struct ib_device *ibdev,
128 128
 			      struct ib_mad_interface *mi,
129 129
 			      struct ib_mad_transaction *madx );
130
-extern struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev,
131
-						enum ib_queue_pair_type type );
130
+extern int ib_create_mi ( struct ib_device *ibdev,
131
+			  enum ib_queue_pair_type type,
132
+			  struct ib_mad_interface **new_mi );
132 133
 extern void ib_destroy_mi ( struct ib_device *ibdev,
133 134
 			    struct ib_mad_interface *mi );
134 135
 

+ 6
- 8
src/net/infiniband.c Vedi File

@@ -666,10 +666,9 @@ int ib_open ( struct ib_device *ibdev ) {
666 666
 	}
667 667
 
668 668
 	/* Create subnet management interface */
669
-	ibdev->smi = ib_create_mi ( ibdev, IB_QPT_SMI );
670
-	if ( ! ibdev->smi ) {
671
-		DBGC ( ibdev, "IBDEV %s could not create SMI\n", ibdev->name );
672
-		rc = -ENOMEM;
669
+	if ( ( rc = ib_create_mi ( ibdev, IB_QPT_SMI, &ibdev->smi ) ) != 0 ) {
670
+		DBGC ( ibdev, "IBDEV %s could not create SMI: %s\n",
671
+		       ibdev->name, strerror ( rc ) );
673 672
 		goto err_create_smi;
674 673
 	}
675 674
 
@@ -681,10 +680,9 @@ int ib_open ( struct ib_device *ibdev ) {
681 680
 	}
682 681
 
683 682
 	/* Create general services interface */
684
-	ibdev->gsi = ib_create_mi ( ibdev, IB_QPT_GSI );
685
-	if ( ! ibdev->gsi ) {
686
-		DBGC ( ibdev, "IBDEV %s could not create GSI\n", ibdev->name );
687
-		rc = -ENOMEM;
683
+	if ( ( rc = ib_create_mi ( ibdev, IB_QPT_GSI, &ibdev->gsi ) ) != 0 ) {
684
+		DBGC ( ibdev, "IBDEV %s could not create GSI: %s\n",
685
+		       ibdev->name, strerror ( rc ) );
688 686
 		goto err_create_gsi;
689 687
 	}
690 688
 

+ 10
- 6
src/net/infiniband/ib_mi.c Vedi File

@@ -341,18 +341,21 @@ void ib_destroy_madx ( struct ib_device *ibdev __unused,
341 341
  *
342 342
  * @v ibdev		Infiniband device
343 343
  * @v type		Queue pair type
344
- * @ret mi		Management agent, or NULL
344
+ * @v new_mi		New management interface to fill in
345
+ * @ret rc		Return status code
345 346
  */
346
-struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev,
347
-					 enum ib_queue_pair_type type ) {
347
+int ib_create_mi ( struct ib_device *ibdev, enum ib_queue_pair_type type,
348
+		   struct ib_mad_interface **new_mi ) {
348 349
 	struct ib_mad_interface *mi;
349 350
 	const char *name;
350 351
 	int rc;
351 352
 
352 353
 	/* Allocate and initialise fields */
353 354
 	mi = zalloc ( sizeof ( *mi ) );
354
-	if ( ! mi )
355
+	if ( ! mi ) {
356
+		rc = -ENOMEM;
355 357
 		goto err_alloc;
358
+	}
356 359
 	mi->ibdev = ibdev;
357 360
 	INIT_LIST_HEAD ( &mi->madx );
358 361
 
@@ -387,7 +390,8 @@ struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev,
387 390
 
388 391
 	/* Fill receive ring */
389 392
 	ib_refill_recv ( ibdev, mi->qp );
390
-	return mi;
393
+	*new_mi = mi;
394
+	return 0;
391 395
 
392 396
  err_modify_qp:
393 397
 	ib_destroy_qp ( ibdev, mi->qp );
@@ -396,7 +400,7 @@ struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev,
396 400
  err_create_cq:
397 401
 	free ( mi );
398 402
  err_alloc:
399
-	return NULL;
403
+	return rc;
400 404
 }
401 405
 
402 406
 /**

Loading…
Annulla
Salva