summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2016-03-20 10:22:55 +0100
committerMichael Brown2016-03-20 10:22:55 +0100
commit750a2efeb2814623e1355885874e93cb7578ef73 (patch)
treed39c9d7699a9ee3a4c398d9fdd812649f724c41e
parent[libc] Allow container_of() to be used on volatile pointers (diff)
downloadipxe-750a2efeb2814623e1355885874e93cb7578ef73.tar.gz
ipxe-750a2efeb2814623e1355885874e93cb7578ef73.tar.xz
ipxe-750a2efeb2814623e1355885874e93cb7578ef73.zip
[ipoib] Allow external code to identify IPoIB network devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/drivers/net/ipoib.c18
-rw-r--r--src/include/ipxe/ipoib.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/net/ipoib.c b/src/drivers/net/ipoib.c
index 4106c208c..a245cce1b 100644
--- a/src/drivers/net/ipoib.c
+++ b/src/drivers/net/ipoib.c
@@ -1027,3 +1027,21 @@ struct ib_driver ipoib_driver __ib_driver = {
.notify = ipoib_notify,
.remove = ipoib_remove,
};
+
+/**
+ * Find IPoIB network device
+ *
+ * @v ibdev Infiniband device
+ * @ret netdev IPoIB network device, or NULL if not found
+ */
+struct net_device * ipoib_netdev ( struct ib_device *ibdev ) {
+ struct ipoib_device *ipoib;
+
+ /* Find matching IPoIB device */
+ list_for_each_entry ( ipoib, &ipoib_devices, list ) {
+ if ( ipoib->ibdev != ibdev )
+ continue;
+ return ipoib->netdev;
+ }
+ return NULL;
+}
diff --git a/src/include/ipxe/ipoib.h b/src/include/ipxe/ipoib.h
index b34dd32d0..065eeabb7 100644
--- a/src/include/ipxe/ipoib.h
+++ b/src/include/ipxe/ipoib.h
@@ -62,5 +62,6 @@ struct ipoib_remac {
extern const char * ipoib_ntoa ( const void *ll_addr );
extern struct net_device * alloc_ipoibdev ( size_t priv_size );
+extern struct net_device * ipoib_netdev ( struct ib_device *ibdev );
#endif /* _IPXE_IPOIB_H */