From 7ba33f78263ba17633cf6c264e99b4a4140abfcb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 2 Jul 2009 12:54:36 +0100 Subject: [infiniband] Provide ib_get_hca_info() as a commonly-available function --- src/net/infiniband.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/net/infiniband.c') diff --git a/src/net/infiniband.c b/src/net/infiniband.c index 1c584d830..1c19fada4 100644 --- a/src/net/infiniband.c +++ b/src/net/infiniband.c @@ -488,6 +488,32 @@ void ib_mcast_detach ( struct ib_device *ibdev, struct ib_queue_pair *qp, } } +/** + * Get Infiniband HCA information + * + * @v ibdev Infiniband device + * @ret hca_guid HCA GUID + * @ret num_ports Number of ports + */ +int ib_get_hca_info ( struct ib_device *ibdev, + struct ib_gid_half *hca_guid ) { + struct ib_device *tmp; + int num_ports = 0; + + /* Search for IB devices with the same physical device to + * identify port count and a suitable Node GUID. + */ + for_each_ibdev ( tmp ) { + if ( tmp->dev != ibdev->dev ) + continue; + if ( num_ports == 0 ) { + memcpy ( hca_guid, &tmp->gid.u.half[1], + sizeof ( *hca_guid ) ); + } + num_ports++; + } + return num_ports; +} /*************************************************************************** * -- cgit v1.2.3-55-g7522