iPXE
Functions | Variables
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 <ipxe/settings.h>
#include <ipxe/infiniband.h>
#include <ipxe/iobuf.h>
#include <ipxe/ib_mi.h>
#include <ipxe/ib_sma.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
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. More...
 
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. More...
 
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. More...
 
static int ib_sma_set_port_info (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad)
 Set port information. More...
 
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. More...
 
static int ib_sma_set_pkey_table (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad)
 Set partition key table. More...
 
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. More...
 
int ib_create_sma (struct ib_device *ibdev, struct ib_mad_interface *mi)
 Create subnet management agent and interface. More...
 
void ib_destroy_sma (struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused)
 Destroy subnet management agent and interface. More...
 

Variables

struct ib_mad_agent ib_sma_agent [] __ib_mad_agent
 Subnet management agent. More...
 

Detailed Description

Infiniband Subnet Management Agent.

Definition in file ib_sma.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ib_sma_node_info()

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
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector

Definition at line 54 of file ib_sma.c.

57  {
59  int rc;
60 
61  /* Fill in information */
62  memset ( node_info, 0, sizeof ( *node_info ) );
66  node_info->num_ports = ibdev->ports;
67  memcpy ( &node_info->sys_guid, &ibdev->node_guid,
68  sizeof ( node_info->sys_guid ) );
69  memcpy ( &node_info->node_guid, &ibdev->node_guid,
70  sizeof ( node_info->node_guid ) );
71  memcpy ( &node_info->port_guid, &ibdev->gid.s.guid,
72  sizeof ( node_info->port_guid ) );
73  node_info->partition_cap = htons ( 1 );
74  node_info->local_port_num = ibdev->port;
75 
76  /* Send GetResponse */
78  if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
79  DBGC ( mi, "SMA %p could not send NodeInfo GetResponse: %s\n",
80  mi, strerror ( rc ) );
81  return;
82  }
83 }
struct ib_node_info node_info
Definition: ib_mad.h:182
uint8_t method
Definition: ib_mad.h:542
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t num_ports
Definition: ib_mad.h:77
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
#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
uint8_t node_type
Definition: ib_mad.h:76
uint8_t base_version
Definition: ib_mad.h:74
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t local_port_num
Definition: ib_mad.h:84
#define IB_SMP_CLASS_VERSION
Subnet management class version.
Definition: ib_mad.h:34
A Node Information attribute.
Definition: ib_mad.h:73
struct ib_gid::@559 s
#define IB_NODE_TYPE_HCA
Definition: ib_mad.h:88
#define IB_MGMT_METHOD_GET_RESP
Definition: ib_mad.h:571
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
struct ib_node_info node_info
Definition: ib_mad.h:12
union ib_guid node_guid
Node GUID.
Definition: infiniband.h:439
unsigned int ports
Total ports on device.
Definition: infiniband.h:420
uint8_t class_version
Definition: ib_mad.h:75
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
union ib_guid port_guid
Definition: ib_mad.h:80
#define IB_MGMT_BASE_VERSION
Definition: ib_mad.h:552
uint16_t partition_cap
Definition: ib_mad.h:81
union ib_guid sys_guid
Definition: ib_mad.h:78
#define htons(value)
Definition: byteswap.h:135
int ib_mi_send(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Transmit MAD.
Definition: ib_mi.c:187
union ib_mad mad
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull

References ib_node_info::base_version, ib_node_info::class_version, DBGC, ib_device::gid, ib_gid::guid, ib_mad::hdr, htons, 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, mad, memcpy(), memset(), ib_mad_hdr::method, ib_node_info::node_guid, ib_device::node_guid, ib_smp_data::node_info, 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_device::ports, rc, ib_gid::s, ib_mad::smp, ib_mad_smp::smp_data, strerror(), and ib_node_info::sys_guid.

◆ ib_sma_node_desc()

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
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector

Definition at line 93 of file ib_sma.c.

96  {
98  union ib_guid *guid = &ibdev->node_guid;
99  char hostname[ sizeof ( node_desc->node_string ) ];
100  int hostname_len;
101  int rc;
102 
103  /* Fill in information */
104  memset ( node_desc, 0, sizeof ( *node_desc ) );
105  hostname_len = fetch_string_setting ( NULL, &hostname_setting,
106  hostname, sizeof ( hostname ) );
108  "iPXE %s%s%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x (%s)",
109  hostname, ( ( hostname_len >= 0 ) ? " " : "" ),
110  guid->bytes[0], guid->bytes[1], guid->bytes[2],
111  guid->bytes[3], guid->bytes[4], guid->bytes[5],
112  guid->bytes[6], guid->bytes[7], ibdev->dev->name );
113 
114  /* Send GetResponse */
116  if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
117  DBGC ( mi, "SMA %p could not send NodeDesc GetResponse: %s\n",
118  mi, strerror ( rc ) );
119  return;
120  }
121 }
uint8_t method
Definition: ib_mad.h:542
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:75
union ib_smp_data smp_data
Definition: ib_mad.h:590
struct device * dev
Underlying device.
Definition: infiniband.h:410
A Node Description attribute.
Definition: ib_mad.h:65
int fetch_string_setting(struct settings *settings, const struct setting *setting, char *data, size_t len)
Fetch value of string setting.
Definition: settings.c:841
#define IB_MGMT_METHOD_GET_RESP
Definition: ib_mad.h:571
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
struct ib_node_desc node_desc
Definition: ib_mad.h:11
An Infiniband Globally Unique Identifier.
Definition: ib_packet.h:18
char node_string[64]
Definition: ib_mad.h:66
union ib_guid node_guid
Node GUID.
Definition: infiniband.h:439
uint64_t guid
GUID.
Definition: edd.h:30
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
struct ib_node_desc node_desc
Definition: ib_mad.h:181
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int ib_mi_send(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Transmit MAD.
Definition: ib_mi.c:187
union ib_mad mad
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, ib_device::dev, fetch_string_setting(), guid, ib_mad::hdr, IB_MGMT_METHOD_GET_RESP, ib_mi_send(), mad, memset(), ib_mad_hdr::method, device::name, ib_smp_data::node_desc, node_desc, ib_device::node_guid, ib_node_desc::node_string, NULL, rc, ib_mad::smp, ib_mad_smp::smp_data, snprintf(), and strerror().

◆ ib_sma_guid_info()

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
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector

Definition at line 131 of file ib_sma.c.

134  {
136  int rc;
137 
138  /* Fill in information */
139  memset ( guid_info, 0, sizeof ( *guid_info ) );
140  memcpy ( guid_info->guid[0], &ibdev->gid.s.guid,
141  sizeof ( guid_info->guid[0] ) );
142 
143  /* Send GetResponse */
145  if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
146  DBGC ( mi, "SMA %p could not send GuidInfo GetResponse: %s\n",
147  mi, strerror ( rc ) );
148  return;
149  }
150 }
uint8_t method
Definition: ib_mad.h:542
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
#define DBGC(...)
Definition: compiler.h:505
union ib_smp_data smp_data
Definition: ib_mad.h:590
uint8_t guid[8][8]
Definition: ib_mad.h:97
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct ib_gid::@559 s
#define IB_MGMT_METHOD_GET_RESP
Definition: ib_mad.h:571
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
struct ib_guid_info guid_info
Definition: ib_mad.h:183
A GUID Information attribute.
Definition: ib_mad.h:96
int ib_mi_send(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Transmit MAD.
Definition: ib_mi.c:187
union ib_mad mad
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull
struct ib_guid_info guid_info
Definition: ib_mad.h:13

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

◆ ib_sma_set_port_info()

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
ibdevInfiniband device
miManagement interface
madReceived MAD
Return values
rcReturn status code

Definition at line 160 of file ib_sma.c.

162  {
163  const struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
164  unsigned int link_width_enabled;
165  unsigned int link_speed_enabled;
166  int rc;
167 
168  /* Set parameters */
169  memcpy ( &ibdev->gid.s.prefix, port_info->gid_prefix,
170  sizeof ( ibdev->gid.s.prefix ) );
171  ibdev->lid = ntohs ( port_info->lid );
172  ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
175  if ( ( link_speed_enabled =
177  ibdev->link_speed_enabled = link_speed_enabled;
178  ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );
179  DBGC ( mi, "SMA %p set LID %d SMLID %d link width %d speed %d\n",
180  mi, ibdev->lid, ibdev->sm_lid, ibdev->link_width_enabled,
181  ibdev->link_speed_enabled );
182 
183  /* Update parameters on device */
184  if ( ( rc = ib_set_port_info ( ibdev, mad ) ) != 0 ) {
185  DBGC ( mi, "SMA %p could not set port information: %s\n",
186  mi, strerror ( rc ) );
187  return rc;
188  }
189 
190  return 0;
191 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
uint8_t link_width_enabled
Definition: ib_mad.h:113
uint16_t lid
Port LID.
Definition: infiniband.h:443
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
int ib_set_port_info(struct ib_device *ibdev, union ib_mad *mad)
Set port information.
Definition: infiniband.c:822
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:435
uint8_t link_width_enabled
Link width enabled.
Definition: infiniband.h:429
uint8_t link_speed_active__link_speed_enabled
Definition: ib_mad.h:119
struct ib_port_info port_info
Definition: ib_mad.h:14
struct ib_port_info port_info
Definition: ib_mad.h:184
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint16_t sm_lid
Subnet manager LID.
Definition: infiniband.h:445
struct ib_gid::@559 s
uint8_t link_width_enabled
Definition: ib_mad.h:19
uint8_t sm_sl
Subnet manager SL.
Definition: infiniband.h:447
union ib_guid prefix
Definition: ib_packet.h:39
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
uint8_t neighbour_mtu__mastersm_sl
Definition: ib_mad.h:120
uint8_t gid_prefix[8]
Definition: ib_mad.h:106
A Port Information attribute.
Definition: ib_mad.h:104
union ib_mad mad
Definition: arbel.h:12

References DBGC, ib_device::gid, ib_port_info::gid_prefix, 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, link_width_enabled, ib_port_info::link_width_enabled, ib_device::link_width_enabled, mad, ib_port_info::mastersm_lid, memcpy(), ib_port_info::neighbour_mtu__mastersm_sl, ntohs, ib_smp_data::port_info, port_info, ib_gid::prefix, rc, ib_gid::s, ib_device::sm_lid, ib_device::sm_sl, ib_mad::smp, ib_mad_smp::smp_data, and strerror().

Referenced by ib_sma_port_info().

◆ ib_sma_port_info()

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
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector

Definition at line 201 of file ib_sma.c.

204  {
206  int rc;
207 
208  /* Set parameters if applicable */
209  if ( mad->hdr.method == IB_MGMT_METHOD_SET ) {
210  if ( ( rc = ib_sma_set_port_info ( ibdev, mi, mad ) ) != 0 ) {
211  mad->hdr.status =
213  /* Fall through to generate GetResponse */
214  }
215  }
216 
217  /* Fill in information */
218  memset ( port_info, 0, sizeof ( *port_info ) );
219  memcpy ( port_info->gid_prefix, &ibdev->gid.s.prefix,
220  sizeof ( port_info->gid_prefix ) );
221  port_info->lid = ntohs ( ibdev->lid );
222  port_info->mastersm_lid = ntohs ( ibdev->sm_lid );
223  port_info->local_port_num = ibdev->port;
228  ( ( ibdev->link_speed_supported << 4 ) | ibdev->port_state );
230  ( ( IB_PORT_PHYS_STATE_POLLING << 4 ) |
233  ( ( ibdev->link_speed_active << 4 ) |
234  ibdev->link_speed_enabled );
236  ( ( IB_MTU_2048 << 4 ) | ibdev->sm_sl );
237  port_info->vl_cap__init_type = ( IB_VL_0 << 4 );
240  port_info->guid_cap = 1;
241 
242  /* Send GetResponse */
244  if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
245  DBGC ( mi, "SMA %p could not send PortInfo GetResponse: %s\n",
246  mi, strerror ( rc ) );
247  return;
248  }
249 }
uint8_t method
Definition: ib_mad.h:542
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define IB_PORT_PHYS_STATE_POLLING
Definition: ib_mad.h:157
#define IB_MTU_2048
Definition: ib_mad.h:162
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
uint8_t link_width_enabled
Definition: ib_mad.h:113
uint8_t port_phys_state__link_down_def_state
Definition: ib_mad.h:117
uint8_t link_width_active
Definition: ib_mad.h:115
uint16_t lid
Port LID.
Definition: infiniband.h:443
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
uint16_t lid
Definition: ib_mad.h:107
#define ntohs(value)
Definition: byteswap.h:136
#define IB_MGMT_METHOD_SET
Definition: ib_mad.h:570
uint8_t link_speed_enabled
Link speed enabled.
Definition: infiniband.h:435
uint8_t link_width_enabled
Link width enabled.
Definition: infiniband.h:429
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:427
struct ib_port_info port_info
Definition: ib_mad.h:184
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t link_speed_supported__port_state
Definition: ib_mad.h:116
uint16_t sm_lid
Subnet manager LID.
Definition: infiniband.h:445
struct ib_gid::@559 s
#define IB_MGMT_METHOD_GET_RESP
Definition: ib_mad.h:571
uint8_t sm_sl
Subnet manager SL.
Definition: infiniband.h:447
union ib_guid prefix
Definition: ib_packet.h:39
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
uint8_t neighbour_mtu__mastersm_sl
Definition: ib_mad.h:120
uint8_t guid_cap
Definition: ib_mad.h:131
uint8_t link_width_active
Link width active.
Definition: infiniband.h:431
uint8_t gid_prefix[8]
Definition: ib_mad.h:106
#define IB_VL_0
Definition: ib_mad.h:165
uint8_t link_width_supported
Definition: ib_mad.h:114
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
uint8_t link_speed_active
Link speed active.
Definition: infiniband.h:437
uint8_t port_state
Port state.
Definition: infiniband.h:425
#define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR
Definition: ib_mad.h:583
uint8_t link_speed_supported
Link speed supported.
Definition: infiniband.h:433
uint8_t local_port_num
Definition: ib_mad.h:112
uint8_t init_type_reply__mtu_cap
Definition: ib_mad.h:125
uint8_t operational_vls__enforcement
Definition: ib_mad.h:127
A Port Information attribute.
Definition: ib_mad.h:104
uint8_t vl_cap__init_type
Definition: ib_mad.h:121
#define htons(value)
Definition: byteswap.h:135
int ib_mi_send(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Transmit MAD.
Definition: ib_mi.c:187
union ib_mad mad
Definition: arbel.h:12
uint16_t status
Definition: ib_mad.h:543
static int ib_sma_set_port_info(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad)
Set port information.
Definition: ib_sma.c:160
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, ib_device::gid, ib_port_info::gid_prefix, ib_port_info::guid_cap, 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_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::local_port_num, mad, 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, port_info, ib_port_info::port_phys_state__link_down_def_state, ib_device::port_state, ib_gid::prefix, rc, ib_gid::s, ib_device::sm_lid, ib_device::sm_sl, ib_mad::smp, ib_mad_smp::smp_data, ib_mad_hdr::status, strerror(), and ib_port_info::vl_cap__init_type.

◆ ib_sma_set_pkey_table()

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
ibdevInfiniband device
miManagement interface
madReceived MAD
Return values
rcReturn status code

Definition at line 259 of file ib_sma.c.

261  {
263  int rc;
264 
265  /* Set parameters */
266  ibdev->pkey = ntohs ( pkey_table->pkey[0] );
267  DBGC ( mi, "SMA %p set pkey %04x\n", mi, ibdev->pkey );
268 
269  /* Update parameters on device */
270  if ( ( rc = ib_set_pkey_table ( ibdev, mad ) ) != 0 ) {
271  DBGC ( mi, "SMA %p could not set pkey table: %s\n",
272  mi, strerror ( rc ) );
273  return rc;
274  }
275 
276  return 0;
277 }
int ib_set_pkey_table(struct ib_device *ibdev, union ib_mad *mad)
Set partition key table.
Definition: infiniband.c:847
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
union ib_smp_data smp_data
Definition: ib_mad.h:590
#define ntohs(value)
Definition: byteswap.h:136
uint16_t pkey[32]
Definition: ib_mad.h:176
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
struct ib_pkey_table pkey_table
Definition: ib_mad.h:15
struct ib_pkey_table pkey_table
Definition: ib_mad.h:185
uint16_t pkey
Partition key.
Definition: infiniband.h:449
A Partition Key Table attribute.
Definition: ib_mad.h:175
union ib_mad mad
Definition: arbel.h:12

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

Referenced by ib_sma_pkey_table().

◆ ib_sma_pkey_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 
)
static

Partition key table.

Parameters
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector

Definition at line 287 of file ib_sma.c.

290  {
292  int rc;
293 
294  /* Set parameters, if applicable */
295  if ( mad->hdr.method == IB_MGMT_METHOD_SET ) {
296  if ( ( rc = ib_sma_set_pkey_table ( ibdev, mi, mad ) ) != 0 ) {
297  mad->hdr.status =
299  /* Fall through to generate GetResponse */
300  }
301  }
302 
303  /* Fill in information */
305  memset ( pkey_table, 0, sizeof ( *pkey_table ) );
306  pkey_table->pkey[0] = htons ( ibdev->pkey );
307 
308  /* Send GetResponse */
310  if ( ( rc = ib_mi_send ( ibdev, mi, mad, av ) ) != 0 ) {
311  DBGC ( mi, "SMA %p could not send PKeyTable GetResponse: %s\n",
312  mi, strerror ( rc ) );
313  return;
314  }
315 }
uint8_t method
Definition: ib_mad.h:542
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int ib_sma_set_pkey_table(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad)
Set partition key table.
Definition: ib_sma.c:259
#define DBGC(...)
Definition: compiler.h:505
union ib_smp_data smp_data
Definition: ib_mad.h:590
#define IB_MGMT_METHOD_SET
Definition: ib_mad.h:570
uint16_t pkey[32]
Definition: ib_mad.h:176
#define IB_MGMT_METHOD_GET_RESP
Definition: ib_mad.h:571
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_smp smp
Definition: ib_mad.h:612
struct ib_pkey_table pkey_table
Definition: ib_mad.h:15
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
#define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR
Definition: ib_mad.h:583
struct ib_pkey_table pkey_table
Definition: ib_mad.h:185
uint16_t pkey
Partition key.
Definition: infiniband.h:449
A Partition Key Table attribute.
Definition: ib_mad.h:175
#define htons(value)
Definition: byteswap.h:135
int ib_mi_send(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Transmit MAD.
Definition: ib_mi.c:187
union ib_mad mad
Definition: arbel.h:12
uint16_t status
Definition: ib_mad.h:543
void * memset(void *dest, int character, size_t len) __nonnull

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(), mad, memset(), ib_mad_hdr::method, ib_pkey_table::pkey, ib_device::pkey, ib_smp_data::pkey_table, pkey_table, rc, ib_mad::smp, ib_mad_smp::smp_data, ib_mad_hdr::status, and strerror().

◆ ib_create_sma()

int ib_create_sma ( struct ib_device ibdev,
struct ib_mad_interface mi 
)

Create subnet management agent and interface.

Parameters
ibdevInfiniband device
miManagement interface
Return values
rcReturn status code

Definition at line 358 of file ib_sma.c.

358  {
359 
360  /* Nothing to do */
361  DBGC ( ibdev, "IBDEV %s SMA using SMI %p\n", ibdev->name, mi );
362 
363  return 0;
364 }
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505

References DBGC, and ib_device::name.

Referenced by ib_open().

◆ ib_destroy_sma()

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

Destroy subnet management agent and interface.

Parameters
ibdevInfiniband device
miManagement interface

Definition at line 372 of file ib_sma.c.

373  {
374  /* Nothing to do */
375 }

Referenced by ib_close(), and ib_open().

Variable Documentation

◆ __ib_mad_agent

struct ib_mad_agent ib_sma_agent [] __ib_mad_agent

Subnet management agent.

Definition at line 318 of file ib_sma.c.