iPXE
Functions
ib_smc.c File Reference

Infiniband Subnet Management Client. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <byteswap.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_smc.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int ib_smc_mad (struct ib_device *ibdev, uint16_t attr_id, uint32_t attr_mod, ib_local_mad_t local_mad, union ib_mad *mad)
 Issue local MAD.
static int ib_smc_get_node_info (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get node information.
static int ib_smc_get_port_info (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get port information.
static int ib_smc_get_guid_info (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get GUID information.
static int ib_smc_get_pkey_table (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get partition key table.
static int ib_smc_get (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Get Infiniband parameters using SMC.
int ib_smc_init (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Initialise Infiniband parameters using SMC.
int ib_smc_update (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Update Infiniband parameters using SMC.

Detailed Description

Infiniband Subnet Management Client.

Definition in file ib_smc.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int ib_smc_mad ( struct ib_device ibdev,
uint16_t  attr_id,
uint32_t  attr_mod,
ib_local_mad_t  local_mad,
union ib_mad mad 
) [static]

Issue local MAD.

Parameters:
ibdevInfiniband device
attr_idAttribute ID, in network byte order
attr_modAttribute modifier, in network byte order
local_madMethod for issuing local MADs
madManagement datagram to fill in
Return values:
rcReturn status code

Definition at line 52 of file ib_smc.c.

References ib_mad_hdr::attr_id, attr_id, ib_mad_hdr::attr_mod, attr_mod, ib_mad_hdr::base_version, ib_mad_hdr::class_version, ib_mad::hdr, IB_MGMT_BASE_VERSION, IB_MGMT_CLASS_SUBN_LID_ROUTED, IB_MGMT_METHOD_GET, memset(), ib_mad_hdr::method, ib_mad_hdr::mgmt_class, and rc.

Referenced by ib_smc_get_guid_info(), ib_smc_get_node_info(), ib_smc_get_pkey_table(), and ib_smc_get_port_info().

                                            {
        int rc;

        /* Construct MAD */
        memset ( mad, 0, sizeof ( *mad ) );
        mad->hdr.base_version = IB_MGMT_BASE_VERSION;
        mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
        mad->hdr.class_version = 1;
        mad->hdr.method = IB_MGMT_METHOD_GET;
        mad->hdr.attr_id = attr_id;
        mad->hdr.attr_mod = attr_mod;

        /* Issue MAD */
        if ( ( rc = local_mad ( ibdev, mad ) ) != 0 )
                return rc;

        return 0;
}
static int ib_smc_get_node_info ( struct ib_device ibdev,
ib_local_mad_t  local_mad,
union ib_mad mad 
) [static]

Get node information.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
madManagement datagram to fill in
Return values:
rcReturn status code

Definition at line 81 of file ib_smc.c.

References DBGC, htons, ib_smc_mad(), IB_SMP_ATTR_NODE_INFO, ib_device::name, rc, and strerror().

Referenced by ib_smc_get().

                                                      {
        int rc;

        /* Issue MAD */
        if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_NODE_INFO ), 0,
                                 local_mad, mad ) ) != 0 ) {
                DBGC ( ibdev, "IBDEV %s could not get node info: %s\n",
                       ibdev->name, strerror ( rc ) );
                return rc;
        }
        return 0;
}
static int ib_smc_get_port_info ( struct ib_device ibdev,
ib_local_mad_t  local_mad,
union ib_mad mad 
) [static]

Get port information.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
madManagement datagram to fill in
Return values:
rcReturn status code

Definition at line 104 of file ib_smc.c.

References DBGC, htonl, htons, ib_smc_mad(), IB_SMP_ATTR_PORT_INFO, ib_device::name, ib_device::port, rc, and strerror().

Referenced by ib_smc_get().

                                                      {
        int rc;

        /* Issue MAD */
        if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_PORT_INFO ),
                                 htonl ( ibdev->port ), local_mad, mad )) !=0){
                DBGC ( ibdev, "IBDEV %s could not get port info: %s\n",
                       ibdev->name, strerror ( rc ) );
                return rc;
        }
        return 0;
}
static int ib_smc_get_guid_info ( struct ib_device ibdev,
ib_local_mad_t  local_mad,
union ib_mad mad 
) [static]

Get GUID information.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
madManagement datagram to fill in
Return values:
rcReturn status code

Definition at line 127 of file ib_smc.c.

References DBGC, htons, ib_smc_mad(), IB_SMP_ATTR_GUID_INFO, ib_device::name, rc, and strerror().

Referenced by ib_smc_get().

                                                      {
        int rc;

        /* Issue MAD */
        if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_GUID_INFO ), 0,
                                 local_mad, mad ) ) != 0 ) {
                DBGC ( ibdev, "IBDEV %s could not get GUID info: %s\n",
                       ibdev->name, strerror ( rc ) );
                return rc;
        }
        return 0;
}
static int ib_smc_get_pkey_table ( struct ib_device ibdev,
ib_local_mad_t  local_mad,
union ib_mad mad 
) [static]

Get partition key table.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
madManagement datagram to fill in
Return values:
rcReturn status code

Definition at line 150 of file ib_smc.c.

References DBGC, htons, ib_smc_mad(), IB_SMP_ATTR_PKEY_TABLE, ib_device::name, rc, and strerror().

Referenced by ib_smc_get().

                                                       {
        int rc;

        /* Issue MAD */
        if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_PKEY_TABLE ), 0,
                                 local_mad, mad ) ) != 0 ) {
                DBGC ( ibdev, "IBDEV %s could not get pkey table: %s\n",
                       ibdev->name, strerror ( rc ) );
                return rc;
        }
        return 0;
}
static int ib_smc_get ( struct ib_device ibdev,
ib_local_mad_t  local_mad 
) [static]

Get Infiniband parameters using SMC.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
Return values:
rcReturn status code

Definition at line 172 of file ib_smc.c.

References DBGC, ib_device::gid, ib_port_info::gid_prefix, ib_gid::guid, ib_guid_info::guid, ib_smp_data::guid_info, guid_info, IB_GID_ARGS, IB_GID_FMT, ib_smc_get_guid_info(), ib_smc_get_node_info(), ib_smc_get_pkey_table(), ib_smc_get_port_info(), ib_port_info::lid, ib_device::lid, ib_device::link_speed_active, ib_port_info::link_speed_active__link_speed_enabled, ib_device::link_speed_enabled, ib_device::link_speed_supported, ib_port_info::link_speed_supported__port_state, ib_port_info::link_width_active, ib_device::link_width_active, ib_port_info::link_width_enabled, ib_device::link_width_enabled, ib_port_info::link_width_supported, ib_device::link_width_supported, ib_port_info::mastersm_lid, memcpy(), ib_device::name, ib_port_info::neighbour_mtu__mastersm_sl, ib_node_info::node_guid, ib_device::node_guid, ib_smp_data::node_info, node_info, ntohs, ib_pkey_table::pkey, ib_device::pkey, ib_smp_data::pkey_table, pkey_table, ib_smp_data::port_info, port_info, ib_device::port_state, ib_gid::prefix, rc, ib_gid::s, ib_device::sm_lid, ib_device::sm_sl, ib_mad::smp, and ib_mad_smp::smp_data.

Referenced by ib_smc_init(), and ib_smc_update().

                                                                            {
        union ib_mad mad;
        struct ib_node_info *node_info = &mad.smp.smp_data.node_info;
        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;

        /* Node info gives us the node GUID */
        if ( ( rc = ib_smc_get_node_info ( ibdev, local_mad, &mad ) ) != 0 )
                return rc;
        memcpy ( &ibdev->node_guid, &node_info->node_guid,
                 sizeof ( ibdev->node_guid ) );

        /* 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;
        memcpy ( &ibdev->gid.s.prefix, port_info->gid_prefix,
                 sizeof ( ibdev->gid.s.prefix ) );
        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.s.guid, guid_info->guid[0],
                 sizeof ( ibdev->gid.s.guid ) );

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

        DBGC ( ibdev, "IBDEV %s port GID is " IB_GID_FMT "\n",
               ibdev->name, IB_GID_ARGS ( &ibdev->gid ) );

        return 0;
}
int ib_smc_init ( struct ib_device ibdev,
ib_local_mad_t  local_mad 
)

Initialise Infiniband parameters using SMC.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
Return values:
rcReturn status code

Definition at line 232 of file ib_smc.c.

References ib_smc_get(), and rc.

Referenced by arbel_probe(), and hermon_register_ibdev().

                                                                      {
        int rc;

        /* Get MAD parameters */
        if ( ( rc = ib_smc_get ( ibdev, local_mad ) ) != 0 )
                return rc;

        return 0;
}
int ib_smc_update ( struct ib_device ibdev,
ib_local_mad_t  local_mad 
)

Update Infiniband parameters using SMC.

Parameters:
ibdevInfiniband device
local_madMethod for issuing local MADs
Return values:
rcReturn status code

Definition at line 249 of file ib_smc.c.

References ib_link_state_changed(), ib_smc_get(), and rc.

Referenced by arbel_event_port_state_change(), arbel_ib_open(), arbel_inform_sma(), arbel_poll_eq(), hermon_ib_open(), hermon_inform_sma(), hermon_poll_eq(), and hermon_state_change_ibdev().

                                                                        {
        int rc;

        /* Get MAD parameters */
        if ( ( rc = ib_smc_get ( ibdev, local_mad ) ) != 0 )
                return rc;

        /* Notify Infiniband core of potential link state change */
        ib_link_state_changed ( ibdev );

        return 0;
}