Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[infiniband] Expose supported and enabled link speeds and widths
  • Loading branch information
Michael Brown committed Jul 17, 2009
1 parent 773028d commit 0095e18
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 23 deletions.
14 changes: 11 additions & 3 deletions src/drivers/infiniband/linda.c
Expand Up @@ -231,9 +231,9 @@ static void linda_link_state_changed ( struct ib_device *ibdev ) {

/* Notify Infiniband core of link state change */
ibdev->port_state = ( link_state + 1 );
ibdev->link_width =
ibdev->link_width_active =
( link_width ? IB_LINK_WIDTH_4X : IB_LINK_WIDTH_1X );
ibdev->link_speed =
ibdev->link_speed_active =
( link_speed ? IB_LINK_SPEED_DDR : IB_LINK_SPEED_SDR );
ib_link_state_changed ( ibdev );
}
Expand Down Expand Up @@ -2213,7 +2213,7 @@ static int linda_init_ib_serdes ( struct linda *linda ) {
linda_writeq ( linda, &ibcctrl, QIB_7220_IBCCtrl_offset );

/* Force SDR only to avoid needing all the DDR tuning,
* Mellanox compatibiltiy hacks etc. SDR is plenty for
* Mellanox compatibility hacks etc. SDR is plenty for
* boot-time operation.
*/
linda_readq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset );
Expand Down Expand Up @@ -2311,6 +2311,14 @@ static int linda_probe ( struct pci_device *pci,
BIT_GET ( &revision, R_ChipRevMajor ),
BIT_GET ( &revision, R_ChipRevMinor ) );

/* Record link capabilities. Note that we force SDR only to
* avoid having to carry extra code for DDR tuning etc.
*/
ibdev->link_width_enabled = ibdev->link_width_supported =
( IB_LINK_WIDTH_4X | IB_LINK_WIDTH_1X );
ibdev->link_speed_enabled = ibdev->link_speed_supported =
IB_LINK_SPEED_SDR;

/* Initialise I2C subsystem */
if ( ( rc = linda_init_i2c ( linda ) ) != 0 )
goto err_init_i2c;
Expand Down
16 changes: 12 additions & 4 deletions src/include/gpxe/infiniband.h
Expand Up @@ -376,10 +376,18 @@ struct ib_device {

/** Port state */
uint8_t port_state;
/** Link width */
uint8_t link_width;
/** Link speed */
uint8_t link_speed;
/** Link width supported */
uint8_t link_width_supported;
/** Link width enabled */
uint8_t link_width_enabled;
/** Link width active */
uint8_t link_width_active;
/** Link speed supported */
uint8_t link_speed_supported;
/** Link speed enabled */
uint8_t link_speed_enabled;
/** Link speed active */
uint8_t link_speed_active;
/** Port GID */
struct ib_gid gid;
/** Port LID */
Expand Down
25 changes: 18 additions & 7 deletions src/net/infiniband/ib_gma.c
Expand Up @@ -204,16 +204,17 @@ static union ib_mad * ib_sma_get_port_info ( struct ib_gma *gma,
port_info->lid = ntohs ( ibdev->lid );
port_info->mastersm_lid = ntohs ( ibdev->sm_lid );
port_info->local_port_num = ibdev->port;
port_info->link_width_enabled = ibdev->link_width;
port_info->link_width_supported = ibdev->link_width;
port_info->link_width_active = ibdev->link_width;
port_info->link_width_enabled = ibdev->link_width_enabled;
port_info->link_width_supported = ibdev->link_width_supported;
port_info->link_width_active = ibdev->link_width_active;
port_info->link_speed_supported__port_state =
( ( ibdev->link_speed << 4 ) | ibdev->port_state );
( ( ibdev->link_speed_supported << 4 ) | ibdev->port_state );
port_info->port_phys_state__link_down_def_state =
( ( IB_PORT_PHYS_STATE_POLLING << 4 ) |
IB_PORT_PHYS_STATE_POLLING );
port_info->link_speed_active__link_speed_enabled =
( ( ibdev->link_speed << 4 ) | ibdev->link_speed );
( ( ibdev->link_speed_active << 4 ) |
ibdev->link_speed_enabled );
port_info->neighbour_mtu__mastersm_sl =
( ( IB_MTU_2048 << 4 ) | ibdev->sm_sl );
port_info->vl_cap__init_type = ( IB_VL_0 << 4 );
Expand All @@ -236,17 +237,27 @@ static union ib_mad * ib_sma_set_port_info ( struct ib_gma *gma,
union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev;
const struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
unsigned int link_width_enabled;
unsigned int link_speed_enabled;
int rc;

memcpy ( &ibdev->gid.u.half[0], port_info->gid_prefix,
sizeof ( ibdev->gid.u.half[0] ) );
ibdev->lid = ntohs ( port_info->lid );
ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
if ( ( link_width_enabled = port_info->link_width_enabled ) )
ibdev->link_width_enabled = link_width_enabled;
if ( ( link_speed_enabled =
( port_info->link_speed_active__link_speed_enabled & 0xf ) ) )
ibdev->link_speed_enabled = link_speed_enabled;
ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );
DBGC ( gma, "GMA %p set LID %04x SMLID %04x link width %02x speed "
"%02x\n", gma, ibdev->lid, ibdev->sm_lid,
ibdev->link_width_enabled, ibdev->link_speed_enabled );

if ( ( rc = ib_set_port_info ( ibdev, port_info ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not set port information: %s\n",
ibdev, strerror ( rc ) );
DBGC ( gma, "GMA %p could not set port information: %s\n",
gma, strerror ( rc ) );
mad->hdr.status =
htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
}
Expand Down
29 changes: 20 additions & 9 deletions src/net/infiniband/ib_smc.c
Expand Up @@ -131,32 +131,43 @@ static int ib_smc_get_pkey_table ( struct ib_device *ibdev,
*/
int ib_smc_update ( struct ib_device *ibdev, ib_local_mad_t local_mad ) {
union ib_mad mad;
union ib_smp_data *smp = &mad.smp.smp_data;
struct ib_port_info *port_info = &mad.smp.smp_data.port_info;
struct ib_guid_info *guid_info = &mad.smp.smp_data.guid_info;
struct ib_pkey_table *pkey_table = &mad.smp.smp_data.pkey_table;
int rc;

/* Port info gives us the link state, the first half of the
* port GID and the SM LID.
*/
if ( ( rc = ib_smc_get_port_info ( ibdev, local_mad, &mad ) ) != 0 )
return rc;
ibdev->port_state =
( smp->port_info.link_speed_supported__port_state & 0x0f );
memcpy ( &ibdev->gid.u.half[0], smp->port_info.gid_prefix,
memcpy ( &ibdev->gid.u.half[0], port_info->gid_prefix,
sizeof ( ibdev->gid.u.half[0] ) );
ibdev->lid = ntohs ( smp->port_info.lid );
ibdev->sm_lid = ntohs ( smp->port_info.mastersm_lid );
ibdev->sm_sl = ( smp->port_info.neighbour_mtu__mastersm_sl & 0xf );
ibdev->lid = ntohs ( port_info->lid );
ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
ibdev->link_width_enabled = port_info->link_width_enabled;
ibdev->link_width_supported = port_info->link_width_supported;
ibdev->link_width_active = port_info->link_width_active;
ibdev->link_speed_supported =
( port_info->link_speed_supported__port_state >> 4 );
ibdev->port_state =
( port_info->link_speed_supported__port_state & 0xf );
ibdev->link_speed_active =
( port_info->link_speed_active__link_speed_enabled >> 4 );
ibdev->link_speed_enabled =
( port_info->link_speed_active__link_speed_enabled & 0xf );
ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );

/* GUID info gives us the second half of the port GID */
if ( ( rc = ib_smc_get_guid_info ( ibdev, local_mad, &mad ) ) != 0 )
return rc;
memcpy ( &ibdev->gid.u.half[1], smp->guid_info.guid[0],
memcpy ( &ibdev->gid.u.half[1], guid_info->guid[0],
sizeof ( ibdev->gid.u.half[1] ) );

/* Get partition key */
if ( ( rc = ib_smc_get_pkey_table ( ibdev, local_mad, &mad ) ) != 0 )
return rc;
ibdev->pkey = ntohs ( smp->pkey_table.pkey[0] );
ibdev->pkey = ntohs ( pkey_table->pkey[0] );

DBGC ( ibdev, "IBDEV %p port GID is %08x:%08x:%08x:%08x\n", ibdev,
htonl ( ibdev->gid.u.dwords[0] ),
Expand Down

0 comments on commit 0095e18

Please sign in to comment.