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 <gpxe/infiniband.h>
#include <gpxe/ib_smc.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
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.
int ib_smc_update (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Get MAD parameters.


Detailed Description

Infiniband Subnet Management Client.

Definition in file ib_smc.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

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:
ibdev Infiniband device
local_mad Method for issuing local MADs
mad Management datagram to fill in
Return values:
rc Return status code

Definition at line 45 of file ib_smc.c.

References ib_mad_hdr::attr_id, ib_mad_hdr::attr_mod, ib_mad_hdr::base_version, ib_mad_hdr::class_version, DBGC, ib_mad::hdr, htonl, htons, IB_MGMT_BASE_VERSION, IB_MGMT_CLASS_SUBN_LID_ROUTED, IB_MGMT_METHOD_GET, IB_SMP_ATTR_PORT_INFO, memset(), ib_mad_hdr::method, ib_mad_hdr::mgmt_class, ib_device::port, and strerror().

Referenced by ib_smc_update().

00047                                                       {
00048         int rc;
00049 
00050         /* Construct MAD */
00051         memset ( mad, 0, sizeof ( *mad ) );
00052         mad->hdr.base_version = IB_MGMT_BASE_VERSION;
00053         mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
00054         mad->hdr.class_version = 1;
00055         mad->hdr.method = IB_MGMT_METHOD_GET;
00056         mad->hdr.attr_id = htons ( IB_SMP_ATTR_PORT_INFO );
00057         mad->hdr.attr_mod = htonl ( ibdev->port );
00058 
00059         if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
00060                 DBGC ( ibdev, "IBDEV %p could not get port info: %s\n",
00061                        ibdev, strerror ( rc ) );
00062                 return rc;
00063         }
00064         return 0;
00065 }

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:
ibdev Infiniband device
local_mad Method for issuing local MADs
mad Management datagram to fill in
Return values:
rc Return status code

Definition at line 75 of file ib_smc.c.

References ib_mad_hdr::attr_id, ib_mad_hdr::base_version, ib_mad_hdr::class_version, DBGC, ib_mad::hdr, htons, IB_MGMT_BASE_VERSION, IB_MGMT_CLASS_SUBN_LID_ROUTED, IB_MGMT_METHOD_GET, IB_SMP_ATTR_GUID_INFO, memset(), ib_mad_hdr::method, ib_mad_hdr::mgmt_class, and strerror().

Referenced by ib_smc_update().

00077                                                       {
00078         int rc;
00079 
00080         /* Construct MAD */
00081         memset ( mad, 0, sizeof ( *mad ) );
00082         mad->hdr.base_version = IB_MGMT_BASE_VERSION;
00083         mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
00084         mad->hdr.class_version = 1;
00085         mad->hdr.method = IB_MGMT_METHOD_GET;
00086         mad->hdr.attr_id = htons ( IB_SMP_ATTR_GUID_INFO );
00087 
00088         if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
00089                 DBGC ( ibdev, "IBDEV %p could not get GUID info: %s\n",
00090                        ibdev, strerror ( rc ) );
00091                 return rc;
00092         }
00093         return 0;
00094 }

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:
ibdev Infiniband device
local_mad Method for issuing local MADs
mad Management datagram to fill in
Return values:
rc Return status code

Definition at line 104 of file ib_smc.c.

References ib_mad_hdr::attr_id, ib_mad_hdr::base_version, ib_mad_hdr::class_version, DBGC, ib_mad::hdr, htons, IB_MGMT_BASE_VERSION, IB_MGMT_CLASS_SUBN_LID_ROUTED, IB_MGMT_METHOD_GET, IB_SMP_ATTR_PKEY_TABLE, memset(), ib_mad_hdr::method, ib_mad_hdr::mgmt_class, and strerror().

Referenced by ib_smc_update().

00106                                                        {
00107         int rc;
00108 
00109         /* Construct MAD */
00110         memset ( mad, 0, sizeof ( *mad ) );
00111         mad->hdr.base_version = IB_MGMT_BASE_VERSION;
00112         mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
00113         mad->hdr.class_version = 1;
00114         mad->hdr.method = IB_MGMT_METHOD_GET;
00115         mad->hdr.attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE );
00116 
00117         if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
00118                 DBGC ( ibdev, "IBDEV %p could not get pkey table: %s\n",
00119                        ibdev, strerror ( rc ) );
00120                 return rc;
00121         }
00122         return 0;
00123 }

int ib_smc_update ( struct ib_device ibdev,
ib_local_mad_t  local_mad 
)

Get MAD parameters.

Parameters:
ibdev Infiniband device
local_mad Method for issuing local MADs
Return values:
rc Return status code

Definition at line 132 of file ib_smc.c.

References DBGC, ib_gid::dwords, ib_device::gid, ib_port_info::gid_prefix, ib_guid_info::guid, ib_smp_data::guid_info, ib_gid::half, htonl, ib_smc_get_guid_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_port_info::neighbour_mtu__mastersm_sl, ntohs, ib_pkey_table::pkey, ib_device::pkey, ib_smp_data::pkey_table, ib_smp_data::port_info, ib_device::port_state, ib_device::sm_lid, ib_device::sm_sl, ib_mad::smp, ib_mad_smp::smp_data, and ib_gid::u.

Referenced by arbel_event_port_state_change(), arbel_open(), arbel_probe(), hermon_event_port_state_change(), hermon_inform_sma(), hermon_open(), and hermon_probe().

00132                                                                         {
00133         union ib_mad mad;
00134         struct ib_port_info *port_info = &mad.smp.smp_data.port_info;
00135         struct ib_guid_info *guid_info = &mad.smp.smp_data.guid_info;
00136         struct ib_pkey_table *pkey_table = &mad.smp.smp_data.pkey_table;
00137         int rc;
00138 
00139         /* Port info gives us the link state, the first half of the
00140          * port GID and the SM LID.
00141          */
00142         if ( ( rc = ib_smc_get_port_info ( ibdev, local_mad, &mad ) ) != 0 )
00143                 return rc;
00144         memcpy ( &ibdev->gid.u.half[0], port_info->gid_prefix,
00145                  sizeof ( ibdev->gid.u.half[0] ) );
00146         ibdev->lid = ntohs ( port_info->lid );
00147         ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
00148         ibdev->link_width_enabled = port_info->link_width_enabled;
00149         ibdev->link_width_supported = port_info->link_width_supported;
00150         ibdev->link_width_active = port_info->link_width_active;
00151         ibdev->link_speed_supported =
00152                 ( port_info->link_speed_supported__port_state >> 4 );
00153         ibdev->port_state =
00154                 ( port_info->link_speed_supported__port_state & 0xf );
00155         ibdev->link_speed_active =
00156                 ( port_info->link_speed_active__link_speed_enabled >> 4 );
00157         ibdev->link_speed_enabled =
00158                 ( port_info->link_speed_active__link_speed_enabled & 0xf );
00159         ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );
00160 
00161         /* GUID info gives us the second half of the port GID */
00162         if ( ( rc = ib_smc_get_guid_info ( ibdev, local_mad, &mad ) ) != 0 )
00163                 return rc;
00164         memcpy ( &ibdev->gid.u.half[1], guid_info->guid[0],
00165                  sizeof ( ibdev->gid.u.half[1] ) );
00166 
00167         /* Get partition key */
00168         if ( ( rc = ib_smc_get_pkey_table ( ibdev, local_mad, &mad ) ) != 0 )
00169                 return rc;
00170         ibdev->pkey = ntohs ( pkey_table->pkey[0] );
00171 
00172         DBGC ( ibdev, "IBDEV %p port GID is %08x:%08x:%08x:%08x\n", ibdev,
00173                htonl ( ibdev->gid.u.dwords[0] ),
00174                htonl ( ibdev->gid.u.dwords[1] ),
00175                htonl ( ibdev->gid.u.dwords[2] ),
00176                htonl ( ibdev->gid.u.dwords[3] ) );
00177 
00178         return 0;
00179 }


Generated on Tue Apr 6 20:01:55 2010 for gPXE by  doxygen 1.5.7.1