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. More...
 
static int ib_smc_get_node_info (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get node information. More...
 
static int ib_smc_get_port_info (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get port information. More...
 
static int ib_smc_get_guid_info (struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
 Get GUID information. More...
 
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. More...
 
static int ib_smc_get (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Get Infiniband parameters using SMC. More...
 
int ib_smc_init (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Initialise Infiniband parameters using SMC. More...
 
int ib_smc_update (struct ib_device *ibdev, ib_local_mad_t local_mad)
 Update Infiniband parameters using SMC. More...
 

Detailed Description

Infiniband Subnet Management Client.

Definition in file ib_smc.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ib_smc_mad()

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.

54  {
55  int rc;
56 
57  /* Construct MAD */
58  memset ( mad, 0, sizeof ( *mad ) );
61  mad->hdr.class_version = 1;
65 
66  /* Issue MAD */
67  if ( ( rc = local_mad ( ibdev, mad ) ) != 0 )
68  return rc;
69 
70  return 0;
71 }
uint8_t method
Definition: ib_mad.h:542
#define IB_MGMT_METHOD_GET
Definition: ib_mad.h:569
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t mgmt_class
Definition: ib_mad.h:540
#define IB_MGMT_CLASS_SUBN_LID_ROUTED
Definition: ib_mad.h:555
uint8_t class_version
Definition: ib_mad.h:541
uint8_t base_version
Definition: ib_mad.h:539
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
uint16_t attr_id
Definition: ib_mad.h:546
#define IB_MGMT_BASE_VERSION
Definition: ib_mad.h:552
uint32_t attr_mod
Definition: ib_mad.h:548
uint32_t attr_mod
Definition: ib_mad.h:20
uint16_t attr_id
Definition: ib_mad.h:18
union ib_mad mad
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull

References attr_id, ib_mad_hdr::attr_id, attr_mod, ib_mad_hdr::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, mad, 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().

◆ ib_smc_get_node_info()

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.

83  {
84  int rc;
85 
86  /* Issue MAD */
87  if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_NODE_INFO ), 0,
88  local_mad, mad ) ) != 0 ) {
89  DBGC ( ibdev, "IBDEV %s could not get node info: %s\n",
90  ibdev->name, strerror ( rc ) );
91  return rc;
92  }
93  return 0;
94 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define IB_SMP_ATTR_NODE_INFO
Definition: ib_mad.h:45
#define DBGC(...)
Definition: compiler.h:505
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.
Definition: ib_smc.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12

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

Referenced by ib_smc_get().

◆ ib_smc_get_port_info()

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.

106  {
107  int rc;
108 
109  /* Issue MAD */
110  if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_PORT_INFO ),
111  htonl ( ibdev->port ), local_mad, mad )) !=0){
112  DBGC ( ibdev, "IBDEV %s could not get port info: %s\n",
113  ibdev->name, strerror ( rc ) );
114  return rc;
115  }
116  return 0;
117 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
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.
Definition: ib_smc.c:52
#define htonl(value)
Definition: byteswap.h:133
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define IB_SMP_ATTR_PORT_INFO
Definition: ib_mad.h:48
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12

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

Referenced by ib_smc_get().

◆ ib_smc_get_guid_info()

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.

129  {
130  int rc;
131 
132  /* Issue MAD */
133  if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_GUID_INFO ), 0,
134  local_mad, mad ) ) != 0 ) {
135  DBGC ( ibdev, "IBDEV %s could not get GUID info: %s\n",
136  ibdev->name, strerror ( rc ) );
137  return rc;
138  }
139  return 0;
140 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
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.
Definition: ib_smc.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define IB_SMP_ATTR_GUID_INFO
Definition: ib_mad.h:47
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12

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

Referenced by ib_smc_get().

◆ ib_smc_get_pkey_table()

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.

152  {
153  int rc;
154 
155  /* Issue MAD */
156  if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_PKEY_TABLE ), 0,
157  local_mad, mad ) ) != 0 ) {
158  DBGC ( ibdev, "IBDEV %s could not get pkey table: %s\n",
159  ibdev->name, strerror ( rc ) );
160  return rc;
161  }
162  return 0;
163 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
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.
Definition: ib_smc.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define IB_SMP_ATTR_PKEY_TABLE
Definition: ib_mad.h:49
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12

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

Referenced by ib_smc_get().

◆ ib_smc_get()

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.

172  {
173  union ib_mad mad;
178  int rc;
179 
180  /* Node info gives us the node GUID */
181  if ( ( rc = ib_smc_get_node_info ( ibdev, local_mad, &mad ) ) != 0 )
182  return rc;
183  memcpy ( &ibdev->node_guid, &node_info->node_guid,
184  sizeof ( ibdev->node_guid ) );
185 
186  /* Port info gives us the link state, the first half of the
187  * port GID and the SM LID.
188  */
189  if ( ( rc = ib_smc_get_port_info ( ibdev, local_mad, &mad ) ) != 0 )
190  return rc;
191  memcpy ( &ibdev->gid.s.prefix, port_info->gid_prefix,
192  sizeof ( ibdev->gid.s.prefix ) );
193  ibdev->lid = ntohs ( port_info->lid );
194  ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
198  ibdev->link_speed_supported =
200  ibdev->port_state =
202  ibdev->link_speed_active =
204  ibdev->link_speed_enabled =
206  ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );
207 
208  /* GUID info gives us the second half of the port GID */
209  if ( ( rc = ib_smc_get_guid_info ( ibdev, local_mad, &mad ) ) != 0 )
210  return rc;
211  memcpy ( &ibdev->gid.s.guid, guid_info->guid[0],
212  sizeof ( ibdev->gid.s.guid ) );
213 
214  /* Get partition key */
215  if ( ( rc = ib_smc_get_pkey_table ( ibdev, local_mad, &mad ) ) != 0 )
216  return rc;
217  ibdev->pkey = ntohs ( pkey_table->pkey[0] );
218 
219  DBGC ( ibdev, "IBDEV %s port GID is " IB_GID_FMT "\n",
220  ibdev->name, IB_GID_ARGS ( &ibdev->gid ) );
221 
222  return 0;
223 }
struct ib_node_info node_info
Definition: ib_mad.h:182
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:439
uint8_t link_width_enabled
Definition: ib_mad.h:113
uint8_t link_width_active
Definition: ib_mad.h:115
uint16_t lid
Port LID.
Definition: infiniband.h:441
uint16_t mastersm_lid
Definition: ib_mad.h:108
#define DBGC(...)
Definition: compiler.h:505
union ib_smp_data smp_data
Definition: ib_mad.h:590
union ib_guid node_guid
Definition: ib_mad.h:79
uint16_t lid
Definition: ib_mad.h:107
#define ntohs(value)
Definition: byteswap.h:136
uint8_t link_speed_enabled
Link speed enabled.
Definition: infiniband.h:433
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.
Definition: ib_smc.c:150
uint8_t link_width_enabled
Link width enabled.
Definition: infiniband.h:427
uint8_t link_speed_active__link_speed_enabled
Definition: ib_mad.h:119
struct ib_port_info port_info
Definition: ib_mad.h:14
uint8_t link_width_supported
Link width supported.
Definition: infiniband.h:425
struct ib_port_info port_info
Definition: ib_mad.h:184
uint8_t guid[8][8]
Definition: ib_mad.h:97
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t link_speed_supported__port_state
Definition: ib_mad.h:116
A Node Information attribute.
Definition: ib_mad.h:73
uint16_t sm_lid
Subnet manager LID.
Definition: infiniband.h:443
uint16_t pkey[32]
Definition: ib_mad.h:176
uint8_t sm_sl
Subnet manager SL.
Definition: infiniband.h:445
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
union ib_guid prefix
Definition: ib_packet.h:39
struct ib_mad_smp smp
Definition: ib_mad.h:612
struct ib_node_info node_info
Definition: ib_mad.h:12
uint8_t neighbour_mtu__mastersm_sl
Definition: ib_mad.h:120
struct ib_pkey_table pkey_table
Definition: ib_mad.h:15
union ib_guid node_guid
Node GUID.
Definition: infiniband.h:437
static int ib_smc_get_port_info(struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
Get port information.
Definition: ib_smc.c:104
uint8_t link_width_active
Link width active.
Definition: infiniband.h:429
uint8_t gid_prefix[8]
Definition: ib_mad.h:106
uint8_t link_width_supported
Definition: ib_mad.h:114
uint8_t link_speed_active
Link speed active.
Definition: infiniband.h:435
struct ib_guid_info guid_info
Definition: ib_mad.h:183
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
uint8_t port_state
Port state.
Definition: infiniband.h:423
static int ib_smc_get_node_info(struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
Get node information.
Definition: ib_smc.c:81
A management datagram.
Definition: ib_mad.h:610
uint8_t link_speed_supported
Link speed supported.
Definition: infiniband.h:431
struct ib_pkey_table pkey_table
Definition: ib_mad.h:185
uint16_t pkey
Partition key.
Definition: infiniband.h:447
A Partition Key Table attribute.
Definition: ib_mad.h:175
A GUID Information attribute.
Definition: ib_mad.h:96
static int ib_smc_get_guid_info(struct ib_device *ibdev, ib_local_mad_t local_mad, union ib_mad *mad)
Get GUID information.
Definition: ib_smc.c:127
A Port Information attribute.
Definition: ib_mad.h:104
union ib_mad mad
Definition: arbel.h:12
struct ib_guid_info guid_info
Definition: ib_mad.h:13
struct ib_gid::@532 s

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, mad, 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().

◆ ib_smc_init()

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.

232  {
233  int rc;
234 
235  /* Get MAD parameters */
236  if ( ( rc = ib_smc_get ( ibdev, local_mad ) ) != 0 )
237  return rc;
238 
239  return 0;
240 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int ib_smc_get(struct ib_device *ibdev, ib_local_mad_t local_mad)
Get Infiniband parameters using SMC.
Definition: ib_smc.c:172

References ib_smc_get(), and rc.

Referenced by arbel_probe(), and hermon_register_ibdev().

◆ ib_smc_update()

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.

249  {
250  int rc;
251 
252  /* Get MAD parameters */
253  if ( ( rc = ib_smc_get ( ibdev, local_mad ) ) != 0 )
254  return rc;
255 
256  /* Notify Infiniband core of potential link state change */
257  ib_link_state_changed ( ibdev );
258 
259  return 0;
260 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void ib_link_state_changed(struct ib_device *ibdev)
Notify of Infiniband link state change.
Definition: infiniband.c:637
static int ib_smc_get(struct ib_device *ibdev, ib_local_mad_t local_mad)
Get Infiniband parameters using SMC.
Definition: ib_smc.c:172

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().