ib_sma.c File Reference

Infiniband Subnet Management Agent. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <byteswap.h>
#include <gpxe/settings.h>
#include <gpxe/infiniband.h>
#include <gpxe/iobuf.h>
#include <gpxe/ib_mi.h>
#include <gpxe/ib_sma.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void ib_sma_node_info (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Node information.
static void ib_sma_node_desc (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Node description.
static void ib_sma_guid_info (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 GUID information.
static int ib_sma_set_port_info (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad)
 Set port information.
static void ib_sma_port_info (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Port information.
static int ib_sma_set_pkey_table (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad)
 Set partition key table.
static void ib_sma_pkey_table (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Partition key table.
int ib_create_sma (struct ib_device *ibdev, struct ib_mad_interface *mi)
 Create subnet management agent and interface.
void ib_destroy_sma (struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused)
 Destroy subnet management agent and interface.

Variables

struct ib_mad_agent ib_sma_agent[] __ib_mad_agent
 Subnet management agent.


Detailed Description

Infiniband Subnet Management Agent.

Definition in file ib_sma.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void ib_sma_node_info ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
) [static]

Node information.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
av Source address vector

Definition at line 49 of file ib_sma.c.

References ib_node_info::base_version, ib_node_info::class_version, DBGC, ib_device::gid, ib_gid::half, ib_mad::hdr, htons, ib_get_hca_info(), IB_MGMT_BASE_VERSION, IB_MGMT_METHOD_GET_RESP, ib_mi_send(), IB_NODE_TYPE_HCA, IB_SMP_CLASS_VERSION, ib_node_info::local_port_num, memcpy, memset(), ib_mad_hdr::method, ib_node_info::node_guid, ib_smp_data::node_info, ib_node_info::node_type, ib_node_info::num_ports, ib_node_info::partition_cap, ib_device::port, ib_node_info::port_guid, ib_mad::smp, ib_mad_smp::smp_data, strerror(), ib_node_info::sys_guid, and ib_gid::u.

00052                                                               {
00053         struct ib_node_info *node_info = &mad->smp.smp_data.node_info;
00054         int rc;
00055 
00056         /* Fill in information */
00057         memset ( node_info, 0, sizeof ( *node_info ) );
00058         node_info->base_version = IB_MGMT_BASE_VERSION;
00059         node_info->class_version = IB_SMP_CLASS_VERSION;
00060         node_info->node_type = IB_NODE_TYPE_HCA;
00061         node_info->num_ports = ib_get_hca_info ( ibdev, &node_info->sys_guid );
00062         memcpy ( &node_info->node_guid, &node_info->sys_guid,
00063                  sizeof ( node_info->node_guid ) );
00064         memcpy ( &node_info->port_guid, &ibdev->gid.u.half[1],
00065                  sizeof ( node_info->port_guid ) );
00066         node_info->partition_cap = htons ( 1 );
00067         node_info->local_port_num = ibdev->port;
00068 
00069         /* Send GetResponse */
00070         mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
00071         if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
00072                 DBGC ( mi, "SMA %p could not send NodeInfo GetResponse: %s\n",
00073                        mi, strerror ( rc ) );
00074                 return;
00075         }
00076 }

static void ib_sma_node_desc ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
) [static]

Node description.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
av Source address vector

Definition at line 86 of file ib_sma.c.

References ib_gid_half::bytes, DBGC, ib_device::dev, fetch_string_setting(), ib_mad::hdr, ib_get_hca_info(), IB_MGMT_METHOD_GET_RESP, ib_mi_send(), memset(), ib_mad_hdr::method, device::name, ib_smp_data::node_desc, ib_node_desc::node_string, NULL, ib_mad::smp, ib_mad_smp::smp_data, snprintf(), strerror(), and ib_gid_half::u.

00089                                                               {
00090         struct ib_node_desc *node_desc = &mad->smp.smp_data.node_desc;
00091         struct ib_gid_half guid;
00092         char hostname[ sizeof ( node_desc->node_string ) ];
00093         int hostname_len;
00094         int rc;
00095 
00096         /* Fill in information */
00097         memset ( node_desc, 0, sizeof ( *node_desc ) );
00098         ib_get_hca_info ( ibdev, &guid );
00099         hostname_len = fetch_string_setting ( NULL, &hostname_setting,
00100                                               hostname, sizeof ( hostname ) );
00101         snprintf ( node_desc->node_string, sizeof ( node_desc->node_string ),
00102                    "gPXE %s%s%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x (%s)",
00103                    hostname, ( ( hostname_len >= 0 ) ? " " : "" ),
00104                    guid.u.bytes[0], guid.u.bytes[1], guid.u.bytes[2],
00105                    guid.u.bytes[3], guid.u.bytes[4], guid.u.bytes[5],
00106                    guid.u.bytes[6], guid.u.bytes[7], ibdev->dev->name );
00107 
00108         /* Send GetResponse */
00109         mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
00110         if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
00111                 DBGC ( mi, "SMA %p could not send NodeDesc GetResponse: %s\n",
00112                        mi, strerror ( rc ) );
00113                 return;
00114         }
00115 }

static void ib_sma_guid_info ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
) [static]

GUID information.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
av Source address vector

Definition at line 125 of file ib_sma.c.

References DBGC, ib_device::gid, ib_guid_info::guid, ib_smp_data::guid_info, ib_gid::half, ib_mad::hdr, IB_MGMT_METHOD_GET_RESP, ib_mi_send(), memcpy, memset(), ib_mad_hdr::method, ib_mad::smp, ib_mad_smp::smp_data, strerror(), and ib_gid::u.

00128                                                               {
00129         struct ib_guid_info *guid_info = &mad->smp.smp_data.guid_info;
00130         int rc;
00131 
00132         /* Fill in information */
00133         memset ( guid_info, 0, sizeof ( *guid_info ) );
00134         memcpy ( guid_info->guid[0], &ibdev->gid.u.half[1],
00135                  sizeof ( guid_info->guid[0] ) );
00136 
00137         /* Send GetResponse */
00138         mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
00139         if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
00140                 DBGC ( mi, "SMA %p could not send GuidInfo GetResponse: %s\n",
00141                        mi, strerror ( rc ) );
00142                 return;
00143         }
00144 }

static int ib_sma_set_port_info ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad 
) [static]

Set port information.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
Return values:
rc Return status code

Definition at line 154 of file ib_sma.c.

References DBGC, ib_device::gid, ib_port_info::gid_prefix, ib_gid::half, ib_set_port_info(), ib_port_info::lid, ib_device::lid, ib_port_info::link_speed_active__link_speed_enabled, ib_device::link_speed_enabled, ib_device::link_width_enabled, ib_port_info::link_width_enabled, ib_port_info::mastersm_lid, memcpy, ib_port_info::neighbour_mtu__mastersm_sl, ntohs, ib_smp_data::port_info, ib_device::sm_lid, ib_device::sm_sl, ib_mad::smp, ib_mad_smp::smp_data, strerror(), and ib_gid::u.

Referenced by ib_sma_port_info().

00156                                                       {
00157         const struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
00158         unsigned int link_width_enabled;
00159         unsigned int link_speed_enabled;
00160         int rc;
00161 
00162         /* Set parameters */
00163         memcpy ( &ibdev->gid.u.half[0], port_info->gid_prefix,
00164                  sizeof ( ibdev->gid.u.half[0] ) );
00165         ibdev->lid = ntohs ( port_info->lid );
00166         ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
00167         if ( ( link_width_enabled = port_info->link_width_enabled ) )
00168                 ibdev->link_width_enabled = link_width_enabled;
00169         if ( ( link_speed_enabled =
00170                ( port_info->link_speed_active__link_speed_enabled & 0xf ) ) )
00171                 ibdev->link_speed_enabled = link_speed_enabled;
00172         ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );
00173         DBGC ( mi, "SMA %p set LID %04x SMLID %04x link width %02x speed "
00174                "%02x\n", mi, ibdev->lid, ibdev->sm_lid,
00175                ibdev->link_width_enabled, ibdev->link_speed_enabled );
00176 
00177         /* Update parameters on device */
00178         if ( ( rc = ib_set_port_info ( ibdev, mad ) ) != 0 ) {
00179                 DBGC ( mi, "SMA %p could not set port information: %s\n",
00180                        mi, strerror ( rc ) );
00181                 return rc;
00182         }
00183 
00184         return 0;
00185 }

static void ib_sma_port_info ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
) [static]

Port information.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
av Source address vector

Definition at line 195 of file ib_sma.c.

References DBGC, ib_device::gid, ib_port_info::gid_prefix, ib_port_info::guid_cap, ib_gid::half, ib_mad::hdr, htons, IB_MGMT_METHOD_GET_RESP, IB_MGMT_METHOD_SET, IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR, ib_mi_send(), IB_MTU_2048, IB_PORT_PHYS_STATE_POLLING, ib_sma_set_port_info(), IB_VL_0, ib_port_info::init_type_reply__mtu_cap, ib_device::lid, ib_port_info::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_device::link_width_active, ib_port_info::link_width_active, ib_device::link_width_enabled, ib_port_info::link_width_enabled, ib_device::link_width_supported, ib_port_info::link_width_supported, ib_port_info::local_port_num, ib_port_info::mastersm_lid, memcpy, memset(), ib_mad_hdr::method, ib_port_info::neighbour_mtu__mastersm_sl, ntohs, ib_port_info::operational_vls__enforcement, ib_device::port, ib_smp_data::port_info, ib_port_info::port_phys_state__link_down_def_state, ib_device::port_state, ib_device::sm_lid, ib_device::sm_sl, ib_mad::smp, ib_mad_smp::smp_data, ib_mad_hdr::status, strerror(), ib_gid::u, and ib_port_info::vl_cap__init_type.

00198                                                               {
00199         struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
00200         int rc;
00201 
00202         /* Set parameters if applicable */
00203         if ( mad->hdr.method == IB_MGMT_METHOD_SET ) {
00204                 if ( ( rc = ib_sma_set_port_info ( ibdev, mi, mad ) ) != 0 ) {
00205                         mad->hdr.status =
00206                               htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
00207                         /* Fall through to generate GetResponse */
00208                 }
00209         }
00210 
00211         /* Fill in information */
00212         memset ( port_info, 0, sizeof ( *port_info ) );
00213         memcpy ( port_info->gid_prefix, &ibdev->gid.u.half[0],
00214                  sizeof ( port_info->gid_prefix ) );
00215         port_info->lid = ntohs ( ibdev->lid );
00216         port_info->mastersm_lid = ntohs ( ibdev->sm_lid );
00217         port_info->local_port_num = ibdev->port;
00218         port_info->link_width_enabled = ibdev->link_width_enabled;
00219         port_info->link_width_supported = ibdev->link_width_supported;
00220         port_info->link_width_active = ibdev->link_width_active;
00221         port_info->link_speed_supported__port_state =
00222                 ( ( ibdev->link_speed_supported << 4 ) | ibdev->port_state );
00223         port_info->port_phys_state__link_down_def_state =
00224                 ( ( IB_PORT_PHYS_STATE_POLLING << 4 ) |
00225                   IB_PORT_PHYS_STATE_POLLING );
00226         port_info->link_speed_active__link_speed_enabled =
00227                 ( ( ibdev->link_speed_active << 4 ) |
00228                   ibdev->link_speed_enabled );
00229         port_info->neighbour_mtu__mastersm_sl =
00230                 ( ( IB_MTU_2048 << 4 ) | ibdev->sm_sl );
00231         port_info->vl_cap__init_type = ( IB_VL_0 << 4 );
00232         port_info->init_type_reply__mtu_cap = IB_MTU_2048;
00233         port_info->operational_vls__enforcement = ( IB_VL_0 << 4 );
00234         port_info->guid_cap = 1;
00235 
00236         /* Send GetResponse */
00237         mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
00238         if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
00239                 DBGC ( mi, "SMA %p could not send PortInfo GetResponse: %s\n",
00240                        mi, strerror ( rc ) );
00241                 return;
00242         }
00243 }

static int ib_sma_set_pkey_table ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad 
) [static]

Set partition key table.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
Return values:
rc Return status code

Definition at line 253 of file ib_sma.c.

References DBGC, ib_set_pkey_table(), ntohs, ib_pkey_table::pkey, ib_device::pkey, ib_smp_data::pkey_table, ib_mad::smp, ib_mad_smp::smp_data, and strerror().

Referenced by ib_sma_pkey_table().

00255                                                        {
00256         struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
00257         int rc;
00258 
00259         /* Set parameters */
00260         ibdev->pkey = ntohs ( pkey_table->pkey[0] );
00261         DBGC ( mi, "SMA %p set pkey %04x\n", mi, ibdev->pkey );
00262 
00263         /* Update parameters on device */
00264         if ( ( rc = ib_set_pkey_table ( ibdev, mad ) ) != 0 ) {
00265                 DBGC ( mi, "SMA %p could not set pkey table: %s\n",
00266                        mi, strerror ( rc ) );
00267                 return rc;
00268         }
00269 
00270         return 0;
00271 }

static void ib_sma_pkey_table ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
) [static]

Partition key table.

Parameters:
ibdev Infiniband device
mi Management interface
mad Received MAD
av Source address vector

Definition at line 281 of file ib_sma.c.

References DBGC, ib_mad::hdr, htons, IB_MGMT_METHOD_GET_RESP, IB_MGMT_METHOD_SET, IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR, ib_mi_send(), ib_sma_set_pkey_table(), memset(), ib_mad_hdr::method, ib_device::pkey, ib_pkey_table::pkey, ib_smp_data::pkey_table, ib_mad::smp, ib_mad_smp::smp_data, ib_mad_hdr::status, and strerror().

00284                                                                {
00285         struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
00286         int rc;
00287 
00288         /* Set parameters, if applicable */
00289         if ( mad->hdr.method == IB_MGMT_METHOD_SET ) {
00290                 if ( ( rc = ib_sma_set_pkey_table ( ibdev, mi, mad ) ) != 0 ) {
00291                         mad->hdr.status =
00292                               htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
00293                         /* Fall through to generate GetResponse */
00294                 }
00295         }
00296 
00297         /* Fill in information */
00298         mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
00299         memset ( pkey_table, 0, sizeof ( *pkey_table ) );
00300         pkey_table->pkey[0] = htons ( ibdev->pkey );
00301 
00302         /* Send GetResponse */
00303         mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
00304         if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
00305                 DBGC ( mi, "SMA %p could not send PKeyTable GetResponse: %s\n",
00306                        mi, strerror ( rc ) );
00307                 return;
00308         }
00309 }

int ib_create_sma ( struct ib_device ibdev,
struct ib_mad_interface mi 
)

Create subnet management agent and interface.

Parameters:
ibdev Infiniband device
mi Management interface
Return values:
rc Return status code

Definition at line 352 of file ib_sma.c.

References DBGC.

Referenced by ib_open().

00352                                                                            {
00353 
00354         /* Nothing to do */
00355         DBGC ( ibdev, "IBDEV %p SMA using SMI %p\n", ibdev, mi );
00356 
00357         return 0;
00358 }

void ib_destroy_sma ( struct ib_device *ibdev  __unused,
struct ib_mad_interface *mi  __unused 
)

Destroy subnet management agent and interface.

Parameters:
ibdev Infiniband device
mi Management interface

Definition at line 366 of file ib_sma.c.

Referenced by ib_close(), and ib_open().

00367                                                              {
00368         /* Nothing to do */
00369 }


Variable Documentation

struct ib_mad_agent ib_sma_agent [] __ib_mad_agent

Subnet management agent.

Definition at line 312 of file ib_sma.c.


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