aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2009-07-02 12:54:36 +0100
committerMichael Brown <mcb30@etherboot.org>2009-07-17 23:06:33 +0100
commit7ba33f78263ba17633cf6c264e99b4a4140abfcb (patch)
tree3ce2ef77e4aef89f705c49219ca5ebda9f80333f /src/net
parentb25a4b6c8a7f311f639bf999050dbad5e50ede4d (diff)
downloadipxe-7ba33f78263ba17633cf6c264e99b4a4140abfcb.zip
ipxe-7ba33f78263ba17633cf6c264e99b4a4140abfcb.tar.gz
ipxe-7ba33f78263ba17633cf6c264e99b4a4140abfcb.tar.bz2
[infiniband] Provide ib_get_hca_info() as a commonly-available function
Diffstat (limited to 'src/net')
-rw-r--r--src/net/infiniband.c26
-rw-r--r--src/net/infiniband/ib_sma.c20
2 files changed, 30 insertions, 16 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c
index 1c584d8..1c19fad 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;
+}
/***************************************************************************
*
diff --git a/src/net/infiniband/ib_sma.c b/src/net/infiniband/ib_sma.c
index 96cc37c..cfc881c 100644
--- a/src/net/infiniband/ib_sma.c
+++ b/src/net/infiniband/ib_sma.c
@@ -47,27 +47,15 @@ static void ib_sma_get_node_info ( struct ib_sma *sma,
union ib_smp_data *get ) {
struct ib_device *ibdev = sma->ibdev;
struct ib_node_info *node_info = &get->node_info;
- struct ib_device *tmp;
memset ( node_info, 0, sizeof ( *node_info ) );
node_info->base_version = IB_MGMT_BASE_VERSION;
node_info->class_version = IB_SMP_CLASS_VERSION;
node_info->node_type = IB_NODE_TYPE_HCA;
- /* 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 ( node_info->num_ports == 0 ) {
- memcpy ( node_info->sys_guid, &tmp->gid.u.half[1],
- sizeof ( node_info->sys_guid ) );
- memcpy ( node_info->node_guid, &tmp->gid.u.half[1],
- sizeof ( node_info->node_guid ) );
- }
- node_info->num_ports++;
- }
- memcpy ( node_info->port_guid, &ibdev->gid.u.half[1],
+ node_info->num_ports = ib_get_hca_info ( ibdev, &node_info->sys_guid );
+ memcpy ( &node_info->node_guid, &node_info->sys_guid,
+ sizeof ( node_info->node_guid ) );
+ memcpy ( &node_info->port_guid, &ibdev->gid.u.half[1],
sizeof ( node_info->port_guid ) );
node_info->partition_cap = htons ( 1 );
node_info->local_port_num = ibdev->port;