]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ipoib] Allow external code to identify IPoIB network devices
authorMichael Brown <mcb30@ipxe.org>
Sun, 20 Mar 2016 09:22:55 +0000 (09:22 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sun, 20 Mar 2016 09:22:55 +0000 (09:22 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/ipoib.c
src/include/ipxe/ipoib.h

index 4106c208c07b8288df68711a6aa708579917d004..a245cce1b89ebd64108dbfc59d1ba69ce8179520 100644 (file)
@@ -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;
+}
index b34dd32d02a4fc742805a524560277743c4c4f67..065eeabb744e123fed56e8668581e19fd37f883f 100644 (file)
@@ -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 */