Просмотр исходного кода

[infiniband] Call ib_open() only when opening the IPoIB net device

Defer the call to ib_open() until we want to actually open the device,
rather than when the device is registered.
tags/v0.9.7
Michael Brown 15 лет назад
Родитель
Сommit
53a7dd26cd

+ 4
- 0
src/drivers/infiniband/arbel.c Просмотреть файл

@@ -2175,6 +2175,10 @@ static int arbel_probe ( struct pci_device *pci,
2175 2175
 	if ( ( rc = arbel_create_eq ( arbel ) ) != 0 )
2176 2176
 		goto err_create_eq;
2177 2177
 
2178
+	/* Update MAD parameters */
2179
+	for ( i = 0 ; i < ARBEL_NUM_PORTS ; i++ )
2180
+		ib_smc_update ( arbel->ibdev[i], arbel_mad );
2181
+
2178 2182
 	/* Register Infiniband devices */
2179 2183
 	for ( i = 0 ; i < ARBEL_NUM_PORTS ; i++ ) {
2180 2184
 		if ( ( rc = register_ibdev ( arbel->ibdev[i] ) ) != 0 ) {

+ 4
- 0
src/drivers/infiniband/hermon.c Просмотреть файл

@@ -2244,6 +2244,10 @@ static int hermon_probe ( struct pci_device *pci,
2244 2244
 	if ( ( rc = hermon_create_eq ( hermon ) ) != 0 )
2245 2245
 		goto err_create_eq;
2246 2246
 
2247
+	/* Update MAD parameters */
2248
+	for ( i = 0 ; i < HERMON_NUM_PORTS ; i++ )
2249
+		ib_smc_update ( hermon->ibdev[i], hermon_mad );
2250
+
2247 2251
 	/* Register Infiniband devices */
2248 2252
 	for ( i = 0 ; i < HERMON_NUM_PORTS ; i++ ) {
2249 2253
 		if ( ( rc = register_ibdev ( hermon->ibdev[i] ) ) != 0 ) {

+ 12
- 0
src/drivers/net/ipoib.c Просмотреть файл

@@ -926,6 +926,13 @@ static int ipoib_open ( struct net_device *netdev ) {
926 926
 	struct ipoib_mac *mac = ( ( struct ipoib_mac * ) netdev->ll_addr );
927 927
 	int rc;
928 928
 
929
+	/* Open IB device */
930
+	if ( ( rc = ib_open ( ipoib->ibdev ) ) != 0 ) {
931
+		DBGC ( ipoib, "IPoIB %p could not open device: %s\n",
932
+		       ipoib, strerror ( rc ) );
933
+		goto err_ib_open;
934
+	}
935
+
929 936
 	/* Allocate metadata queue set */
930 937
 	if ( ( rc = ipoib_create_qset ( ipoib, &ipoib->meta,
931 938
 					IPOIB_META_NUM_CQES,
@@ -971,6 +978,8 @@ static int ipoib_open ( struct net_device *netdev ) {
971 978
  err_create_data_qset:
972 979
 	ipoib_destroy_qset ( ipoib, &ipoib->meta );
973 980
  err_create_meta_qset:
981
+	ib_close ( ipoib->ibdev );
982
+ err_ib_open:
974 983
 	return rc;
975 984
 }
976 985
 
@@ -992,6 +1001,9 @@ static void ipoib_close ( struct net_device *netdev ) {
992 1001
 	/* Tear down the queues */
993 1002
 	ipoib_destroy_qset ( ipoib, &ipoib->data );
994 1003
 	ipoib_destroy_qset ( ipoib, &ipoib->meta );
1004
+
1005
+	/* Close IB device */
1006
+	ib_close ( ipoib->ibdev );
995 1007
 }
996 1008
 
997 1009
 /** IPoIB network device operations */

+ 4
- 21
src/include/gpxe/infiniband.h Просмотреть файл

@@ -306,6 +306,8 @@ struct ib_device {
306 306
 	struct ib_device_operations *op;
307 307
 	/** Port number */
308 308
 	unsigned int port;
309
+	/** Port open request counter */
310
+	unsigned int open_count;
309 311
 
310 312
 	/** Port state */
311 313
 	uint8_t port_state;
@@ -364,6 +366,8 @@ extern void ib_complete_recv ( struct ib_device *ibdev,
364 366
 			       struct ib_queue_pair *qp,
365 367
 			       struct ib_address_vector *av,
366 368
 			       struct io_buffer *iobuf, int rc );
369
+extern int ib_open ( struct ib_device *ibdev );
370
+extern void ib_close ( struct ib_device *ibdev );
367 371
 extern int ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
368 372
 			     struct ib_gid *gid );
369 373
 extern void ib_mcast_detach ( struct ib_device *ibdev,
@@ -389,27 +393,6 @@ ib_poll_cq ( struct ib_device *ibdev, struct ib_completion_queue *cq ) {
389 393
 	ibdev->op->poll_cq ( ibdev, cq );
390 394
 }
391 395
 
392
-/**
393
- * Open port
394
- *
395
- * @v ibdev		Infiniband device
396
- * @ret rc		Return status code
397
- */
398
-static inline __always_inline int
399
-ib_open ( struct ib_device *ibdev ) {
400
-	return ibdev->op->open ( ibdev );
401
-}
402
-
403
-/**
404
- * Close port
405
- *
406
- * @v ibdev		Infiniband device
407
- */
408
-static inline __always_inline void
409
-ib_close ( struct ib_device *ibdev ) {
410
-	ibdev->op->close ( ibdev );
411
-}
412
-
413 396
 /**
414 397
  * Check link state
415 398
  *

+ 36
- 7
src/net/infiniband.c Просмотреть файл

@@ -391,6 +391,42 @@ void ib_complete_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
391 391
 	qp->recv.fill--;
392 392
 }
393 393
 
394
+/**
395
+ * Open port
396
+ *
397
+ * @v ibdev		Infiniband device
398
+ * @ret rc		Return status code
399
+ */
400
+int ib_open ( struct ib_device *ibdev ) {
401
+	int rc;
402
+
403
+	/* Open device if this is the first requested opening */
404
+	if ( ibdev->open_count == 0 ) {
405
+		if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 )
406
+			return rc;
407
+	}
408
+
409
+	/* Increment device open request counter */
410
+	ibdev->open_count++;
411
+
412
+	return 0;
413
+}
414
+
415
+/**
416
+ * Close port
417
+ *
418
+ * @v ibdev		Infiniband device
419
+ */
420
+void ib_close ( struct ib_device *ibdev ) {
421
+
422
+	/* Decrement device open request counter */
423
+	ibdev->open_count--;
424
+
425
+	/* Close device if this was the last remaining requested opening */
426
+	if ( ibdev->open_count == 0 )
427
+		ibdev->op->close ( ibdev );
428
+}
429
+
394 430
 /**
395 431
  * Attach to multicast group
396 432
  *
@@ -530,10 +566,6 @@ int register_ibdev ( struct ib_device *ibdev ) {
530 566
 	ibdev_get ( ibdev );
531 567
 	list_add_tail ( &ibdev->list, &ib_devices );
532 568
 
533
-	/* Open link */
534
-	if ( ( rc = ib_open ( ibdev ) ) != 0 )
535
-		goto err_open;
536
-
537 569
 	/* Add IPoIB device */
538 570
 	if ( ( rc = ipoib_probe ( ibdev ) ) != 0 ) {
539 571
 		DBGC ( ibdev, "IBDEV %p could not add IPoIB device: %s\n",
@@ -546,8 +578,6 @@ int register_ibdev ( struct ib_device *ibdev ) {
546 578
 	return 0;
547 579
 
548 580
  err_ipoib_probe:
549
-	ib_close ( ibdev );
550
- err_open:
551 581
 	list_del ( &ibdev->list );
552 582
 	ibdev_put ( ibdev );
553 583
 	return rc;
@@ -562,7 +592,6 @@ void unregister_ibdev ( struct ib_device *ibdev ) {
562 592
 
563 593
 	/* Close device */
564 594
 	ipoib_remove ( ibdev );
565
-	ib_close ( ibdev );
566 595
 
567 596
 	/* Remove from device list */
568 597
 	list_del ( &ibdev->list );

Загрузка…
Отмена
Сохранить