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 */