Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[infiniband] Provide ib_get_hca_info() as a commonly-available function
  • Loading branch information
Michael Brown committed Jul 17, 2009
1 parent b25a4b6 commit 7ba33f7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/include/gpxe/ib_mad.h
Expand Up @@ -75,9 +75,9 @@ struct ib_node_info {
uint8_t class_version;
uint8_t node_type;
uint8_t num_ports;
uint8_t sys_guid[8];
uint8_t node_guid[8];
uint8_t port_guid[8];
struct ib_gid_half sys_guid;
struct ib_gid_half node_guid;
struct ib_gid_half port_guid;
uint16_t partition_cap;
uint16_t device_id;
uint32_t revision;
Expand Down
2 changes: 2 additions & 0 deletions src/include/gpxe/infiniband.h
Expand Up @@ -374,6 +374,8 @@ extern int ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
struct ib_gid *gid );
extern void ib_mcast_detach ( struct ib_device *ibdev,
struct ib_queue_pair *qp, struct ib_gid *gid );
extern int ib_get_hca_info ( struct ib_device *ibdev,
struct ib_gid_half *hca_guid );
extern struct ib_device * alloc_ibdev ( size_t priv_size );
extern int register_ibdev ( struct ib_device *ibdev );
extern void unregister_ibdev ( struct ib_device *ibdev );
Expand Down
26 changes: 26 additions & 0 deletions src/net/infiniband.c
Expand Up @@ -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;
}

/***************************************************************************
*
Expand Down
20 changes: 4 additions & 16 deletions src/net/infiniband/ib_sma.c
Expand Up @@ -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;
Expand Down

0 comments on commit 7ba33f7

Please sign in to comment.