Browse Source

[ipoib] Allow external code to identify IPoIB network devices

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
750a2efeb2
2 changed files with 19 additions and 0 deletions
  1. 18
    0
      src/drivers/net/ipoib.c
  2. 1
    0
      src/include/ipxe/ipoib.h

+ 18
- 0
src/drivers/net/ipoib.c View File

@@ -1027,3 +1027,21 @@ struct ib_driver ipoib_driver __ib_driver = {
1027 1027
 	.notify = ipoib_notify,
1028 1028
 	.remove = ipoib_remove,
1029 1029
 };
1030
+
1031
+/**
1032
+ * Find IPoIB network device
1033
+ *
1034
+ * @v ibdev		Infiniband device
1035
+ * @ret netdev		IPoIB network device, or NULL if not found
1036
+ */
1037
+struct net_device * ipoib_netdev ( struct ib_device *ibdev ) {
1038
+	struct ipoib_device *ipoib;
1039
+
1040
+	/* Find matching IPoIB device */
1041
+	list_for_each_entry ( ipoib, &ipoib_devices, list ) {
1042
+		if ( ipoib->ibdev != ibdev )
1043
+			continue;
1044
+		return ipoib->netdev;
1045
+	}
1046
+	return NULL;
1047
+}

+ 1
- 0
src/include/ipxe/ipoib.h View File

@@ -62,5 +62,6 @@ struct ipoib_remac {
62 62
 
63 63
 extern const char * ipoib_ntoa ( const void *ll_addr );
64 64
 extern struct net_device * alloc_ipoibdev ( size_t priv_size );
65
+extern struct net_device * ipoib_netdev ( struct ib_device *ibdev );
65 66
 
66 67
 #endif /* _IPXE_IPOIB_H */

Loading…
Cancel
Save