Browse Source

[infiniband] Add last_opened_ibdev(), analogous to last_opened_netdev()

The minimal-surprise behaviour, when no explicit SRP initiator device
is specified, will probably be to use the most recently opened
Infiniband device.  This matches our behaviour with using the most
recently opened net device for PXE, iSCSI, AoE, NBI, etc.
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
8de49af0d2
3 changed files with 27 additions and 1 deletions
  1. 3
    0
      src/include/gpxe/infiniband.h
  2. 23
    0
      src/net/infiniband.c
  3. 1
    1
      src/net/netdevice.c

+ 3
- 0
src/include/gpxe/infiniband.h View File

368
 	struct refcnt refcnt;
368
 	struct refcnt refcnt;
369
 	/** List of Infiniband devices */
369
 	/** List of Infiniband devices */
370
 	struct list_head list;
370
 	struct list_head list;
371
+	/** List of open Infiniband devices */
372
+	struct list_head open_list;
371
 	/** Underlying device */
373
 	/** Underlying device */
372
 	struct device *dev;
374
 	struct device *dev;
373
 	/** List of completion queues */
375
 	/** List of completion queues */
473
 extern int register_ibdev ( struct ib_device *ibdev );
475
 extern int register_ibdev ( struct ib_device *ibdev );
474
 extern void unregister_ibdev ( struct ib_device *ibdev );
476
 extern void unregister_ibdev ( struct ib_device *ibdev );
475
 extern struct ib_device * find_ibdev ( struct ib_gid *gid );
477
 extern struct ib_device * find_ibdev ( struct ib_gid *gid );
478
+extern struct ib_device * last_opened_ibdev ( void );
476
 extern void ib_link_state_changed ( struct ib_device *ibdev );
479
 extern void ib_link_state_changed ( struct ib_device *ibdev );
477
 extern void ib_poll_eq ( struct ib_device *ibdev );
480
 extern void ib_poll_eq ( struct ib_device *ibdev );
478
 extern struct list_head ib_devices;
481
 extern struct list_head ib_devices;

+ 23
- 0
src/net/infiniband.c View File

45
 /** List of Infiniband devices */
45
 /** List of Infiniband devices */
46
 struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices );
46
 struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices );
47
 
47
 
48
+/** List of open Infiniband devices, in reverse order of opening */
49
+static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
50
+
48
 /***************************************************************************
51
 /***************************************************************************
49
  *
52
  *
50
  * Completion queues
53
  * Completion queues
565
 		goto err_open;
568
 		goto err_open;
566
 	}
569
 	}
567
 
570
 
571
+	/* Add to head of open devices list */
572
+	list_add ( &ibdev->open_list, &open_ib_devices );
573
+
568
 	assert ( ibdev->open_count == 1 );
574
 	assert ( ibdev->open_count == 1 );
569
 	return 0;
575
 	return 0;
570
 
576
 
593
 
599
 
594
 	/* Close device if this was the last remaining requested opening */
600
 	/* Close device if this was the last remaining requested opening */
595
 	if ( ibdev->open_count == 0 ) {
601
 	if ( ibdev->open_count == 0 ) {
602
+		list_del ( &ibdev->open_list );
596
 		ib_destroy_mi ( ibdev, ibdev->gsi );
603
 		ib_destroy_mi ( ibdev, ibdev->gsi );
597
 		ib_destroy_sma ( ibdev, ibdev->smi );
604
 		ib_destroy_sma ( ibdev, ibdev->smi );
598
 		ib_destroy_mi ( ibdev, ibdev->smi );
605
 		ib_destroy_mi ( ibdev, ibdev->smi );
898
 	}
905
 	}
899
 	return NULL;
906
 	return NULL;
900
 }
907
 }
908
+
909
+/**
910
+ * Get most recently opened Infiniband device
911
+ *
912
+ * @ret ibdev		Most recently opened Infiniband device, or NULL
913
+ */
914
+struct ib_device * last_opened_ibdev ( void ) {
915
+	struct ib_device *ibdev;
916
+
917
+	list_for_each_entry ( ibdev, &open_ib_devices, open_list ) {
918
+		assert ( ibdev->open_count != 0 );
919
+		return ibdev;
920
+	}
921
+
922
+	return NULL;
923
+}

+ 1
- 1
src/net/netdevice.c View File

43
 struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
43
 struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
44
 
44
 
45
 /** List of open network devices, in reverse order of opening */
45
 /** List of open network devices, in reverse order of opening */
46
-struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
46
+static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
47
 
47
 
48
 /** Default link status code */
48
 /** Default link status code */
49
 #define EUNKNOWN_LINK_STATUS EINPROGRESS
49
 #define EUNKNOWN_LINK_STATUS EINPROGRESS

Loading…
Cancel
Save