Browse Source

[infiniband] Add find_ibdev()

tags/v0.9.8
Michael Brown 14 years ago
parent
commit
419243e7f1
2 changed files with 17 additions and 0 deletions
  1. 1
    0
      src/include/gpxe/infiniband.h
  2. 16
    0
      src/net/infiniband.c

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

@@ -472,6 +472,7 @@ extern int ib_set_pkey_table ( struct ib_device *ibdev, union ib_mad *mad );
472 472
 extern struct ib_device * alloc_ibdev ( size_t priv_size );
473 473
 extern int register_ibdev ( struct ib_device *ibdev );
474 474
 extern void unregister_ibdev ( struct ib_device *ibdev );
475
+extern struct ib_device * find_ibdev ( struct ib_gid *gid );
475 476
 extern void ib_link_state_changed ( struct ib_device *ibdev );
476 477
 extern void ib_poll_eq ( struct ib_device *ibdev );
477 478
 extern struct list_head ib_devices;

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

@@ -882,3 +882,19 @@ void unregister_ibdev ( struct ib_device *ibdev ) {
882 882
 	ibdev_put ( ibdev );
883 883
 	DBGC ( ibdev, "IBDEV %p unregistered\n", ibdev );
884 884
 }
885
+
886
+/**
887
+ * Find Infiniband device by GID
888
+ *
889
+ * @v gid		GID
890
+ * @ret ibdev		Infiniband device, or NULL
891
+ */
892
+struct ib_device * find_ibdev ( struct ib_gid *gid ) {
893
+	struct ib_device *ibdev;
894
+
895
+	for_each_ibdev ( ibdev ) {
896
+		if ( memcmp ( gid, &ibdev->gid, sizeof ( *gid ) ) == 0 )
897
+			return ibdev;
898
+	}
899
+	return NULL;
900
+}

Loading…
Cancel
Save