Browse Source

[infiniband] Return status code from ib_create_mi()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
c26c1fd07c
3 changed files with 19 additions and 16 deletions
  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 View File

127
 extern void ib_destroy_madx ( struct ib_device *ibdev,
127
 extern void ib_destroy_madx ( struct ib_device *ibdev,
128
 			      struct ib_mad_interface *mi,
128
 			      struct ib_mad_interface *mi,
129
 			      struct ib_mad_transaction *madx );
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
 extern void ib_destroy_mi ( struct ib_device *ibdev,
133
 extern void ib_destroy_mi ( struct ib_device *ibdev,
133
 			    struct ib_mad_interface *mi );
134
 			    struct ib_mad_interface *mi );
134
 
135
 

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

666
 	}
666
 	}
667
 
667
 
668
 	/* Create subnet management interface */
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
 		goto err_create_smi;
672
 		goto err_create_smi;
674
 	}
673
 	}
675
 
674
 
681
 	}
680
 	}
682
 
681
 
683
 	/* Create general services interface */
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
 		goto err_create_gsi;
686
 		goto err_create_gsi;
689
 	}
687
 	}
690
 
688
 

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

341
  *
341
  *
342
  * @v ibdev		Infiniband device
342
  * @v ibdev		Infiniband device
343
  * @v type		Queue pair type
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
 	struct ib_mad_interface *mi;
349
 	struct ib_mad_interface *mi;
349
 	const char *name;
350
 	const char *name;
350
 	int rc;
351
 	int rc;
351
 
352
 
352
 	/* Allocate and initialise fields */
353
 	/* Allocate and initialise fields */
353
 	mi = zalloc ( sizeof ( *mi ) );
354
 	mi = zalloc ( sizeof ( *mi ) );
354
-	if ( ! mi )
355
+	if ( ! mi ) {
356
+		rc = -ENOMEM;
355
 		goto err_alloc;
357
 		goto err_alloc;
358
+	}
356
 	mi->ibdev = ibdev;
359
 	mi->ibdev = ibdev;
357
 	INIT_LIST_HEAD ( &mi->madx );
360
 	INIT_LIST_HEAD ( &mi->madx );
358
 
361
 
387
 
390
 
388
 	/* Fill receive ring */
391
 	/* Fill receive ring */
389
 	ib_refill_recv ( ibdev, mi->qp );
392
 	ib_refill_recv ( ibdev, mi->qp );
390
-	return mi;
393
+	*new_mi = mi;
394
+	return 0;
391
 
395
 
392
  err_modify_qp:
396
  err_modify_qp:
393
 	ib_destroy_qp ( ibdev, mi->qp );
397
 	ib_destroy_qp ( ibdev, mi->qp );
396
  err_create_cq:
400
  err_create_cq:
397
 	free ( mi );
401
 	free ( mi );
398
  err_alloc:
402
  err_alloc:
399
-	return NULL;
403
+	return rc;
400
 }
404
 }
401
 
405
 
402
 /**
406
 /**

Loading…
Cancel
Save