iPXE
Macros | Functions | Variables
ib_mi.c File Reference

Infiniband management interfaces. More...

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

Go to the source code of this file.

Macros

#define IB_MI_NUM_SEND_WQES   4
 Management interface number of send WQEs. More...
 
#define IB_MI_NUM_RECV_WQES   2
 Management interface number of receive WQEs. More...
 
#define IB_MI_NUM_CQES   8
 Management interface number of completion queue entries. More...
 
#define IB_MI_TID_MAGIC   ( ( 'i' << 24 ) | ( 'P' << 16 ) | ( 'X' << 8 ) | 'E' )
 TID magic signature. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int ib_mi_handle (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Handle received MAD. More...
 
static void ib_mi_complete_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest __unused, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
 Complete receive via management interface. More...
 
int ib_mi_send (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
 Transmit MAD. More...
 
static void ib_mi_timer_expired (struct retry_timer *timer, int expired)
 Handle management transaction timer expiry. More...
 
struct ib_mad_transactionib_create_madx (struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av, struct ib_mad_transaction_operations *op)
 Create management transaction. More...
 
void ib_destroy_madx (struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
 Destroy management transaction. More...
 
int ib_create_mi (struct ib_device *ibdev, enum ib_queue_pair_type type, struct ib_mad_interface **new_mi)
 Create management interface. More...
 
void ib_destroy_mi (struct ib_device *ibdev, struct ib_mad_interface *mi)
 Destroy management interface. More...
 

Variables

static unsigned int next_tid
 TID to use for next MAD. More...
 
static struct ib_completion_queue_operations ib_mi_completion_ops
 Management interface completion operations. More...
 
static struct ib_queue_pair_operations ib_mi_queue_pair_ops
 Management interface queue pair operations. More...
 

Detailed Description

Infiniband management interfaces.

Definition in file ib_mi.c.

Macro Definition Documentation

◆ IB_MI_NUM_SEND_WQES

#define IB_MI_NUM_SEND_WQES   4

Management interface number of send WQEs.

This is a policy decision.

Definition at line 48 of file ib_mi.c.

◆ IB_MI_NUM_RECV_WQES

#define IB_MI_NUM_RECV_WQES   2

Management interface number of receive WQEs.

This is a policy decision.

Definition at line 54 of file ib_mi.c.

◆ IB_MI_NUM_CQES

#define IB_MI_NUM_CQES   8

Management interface number of completion queue entries.

This is a policy decision

Definition at line 60 of file ib_mi.c.

◆ IB_MI_TID_MAGIC

#define IB_MI_TID_MAGIC   ( ( 'i' << 24 ) | ( 'P' << 16 ) | ( 'X' << 8 ) | 'E' )

TID magic signature.

Definition at line 63 of file ib_mi.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ib_mi_handle()

static int ib_mi_handle ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
)
static

Handle received MAD.

Parameters
ibdevInfiniband device
miManagement interface
madReceived MAD
avSource address vector
Return values
rcReturn status code

Definition at line 77 of file ib_mi.c.

80  {
81  struct ib_mad_hdr *hdr = &mad->hdr;
82  struct ib_mad_transaction *madx;
83  struct ib_mad_agent *agent;
84 
85  /* Look for a matching transaction by TID */
86  list_for_each_entry ( madx, &mi->madx, list ) {
87  if ( memcmp ( &hdr->tid, &madx->mad.hdr.tid,
88  sizeof ( hdr->tid ) ) != 0 )
89  continue;
90  /* Found a matching transaction */
91  madx->op->complete ( ibdev, mi, madx, 0, mad, av );
92  return 0;
93  }
94 
95  /* If there is no matching transaction, look for a listening agent */
97  if ( ( ( agent->mgmt_class & IB_MGMT_CLASS_MASK ) !=
98  ( hdr->mgmt_class & IB_MGMT_CLASS_MASK ) ) ||
99  ( agent->class_version != hdr->class_version ) ||
100  ( agent->attr_id != hdr->attr_id ) )
101  continue;
102  /* Found a matching agent */
103  agent->handle ( ibdev, mi, mad, av );
104  return 0;
105  }
106 
107  /* Otherwise, ignore it */
108  DBGC ( mi, "MI %p RX TID %08x%08x ignored\n",
109  mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
110  return -ENOTSUP;
111 }
#define IB_MAD_AGENTS
Infiniband management agents.
Definition: ib_mi.h:43
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
void(* handle)(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Handle MAD.
Definition: ib_mi.h:36
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
uint16_t attr_id
Attribute (in network byte order)
Definition: ib_mi.h:27
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
An Infiniband management transaction.
Definition: ib_mi.h:70
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
An Infiniband management agent.
Definition: ib_mi.h:21
uint8_t class_version
Class version.
Definition: ib_mi.h:25
A management datagram common header.
Definition: ib_mad.h:538
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
struct ib_mad_transaction_operations * op
Transaction operations.
Definition: ib_mi.h:82
struct ib_mad_tid tid
Definition: ib_mad.h:545
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
uint8_t mgmt_class
Management class.
Definition: ib_mi.h:23
#define IB_MGMT_CLASS_MASK
Definition: ib_mad.h:566
union ib_mad mad
MAD being sent.
Definition: ib_mi.h:80
void(* complete)(struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av)
Handle transaction completion.
Definition: ib_mi.h:62
struct list_head madx
List of management transactions.
Definition: ib_mi.h:96
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
union ib_mad mad
Definition: arbel.h:12

References ib_mad_agent::attr_id, ib_mad_agent::class_version, ib_mad_transaction_operations::complete, DBGC, ENOTSUP, for_each_table_entry, ib_mad_agent::handle, ib_mad::hdr, hdr, IB_MAD_AGENTS, IB_MGMT_CLASS_MASK, list_for_each_entry, mad, ib_mad_transaction::mad, ib_mad_interface::madx, memcmp(), ib_mad_agent::mgmt_class, ntohl, ib_mad_transaction::op, and ib_mad_hdr::tid.

Referenced by ib_mi_complete_recv().

◆ ib_mi_complete_recv()

static void ib_mi_complete_recv ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_address_vector *dest  __unused,
struct ib_address_vector source,
struct io_buffer iobuf,
int  rc 
)
static

Complete receive via management interface.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
sourceSource address vector
iobufI/O buffer
rcCompletion status code

Definition at line 124 of file ib_mi.c.

128  {
129  struct ib_mad_interface *mi = ib_qp_get_ownerdata ( qp );
130  union ib_mad *mad;
131  struct ib_mad_hdr *hdr;
132 
133  /* Ignore errors */
134  if ( rc != 0 ) {
135  DBGC ( mi, "MI %p RX error: %s\n", mi, strerror ( rc ) );
136  goto out;
137  }
138 
139  /* Sanity checks */
140  if ( iob_len ( iobuf ) != sizeof ( *mad ) ) {
141  DBGC ( mi, "MI %p RX bad size (%zd bytes)\n",
142  mi, iob_len ( iobuf ) );
143  DBGC_HDA ( mi, 0, iobuf->data, iob_len ( iobuf ) );
144  goto out;
145  }
146  mad = iobuf->data;
147  hdr = &mad->hdr;
148  if ( hdr->base_version != IB_MGMT_BASE_VERSION ) {
149  DBGC ( mi, "MI %p RX unsupported base version %x\n",
150  mi, hdr->base_version );
151  DBGC_HDA ( mi, 0, mad, sizeof ( *mad ) );
152  goto out;
153  }
154  DBGC ( mi, "MI %p RX TID %08x%08x (%02x,%02x,%02x,%04x) status "
155  "%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
156  hdr->mgmt_class, hdr->class_version, hdr->method,
157  ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
158  DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
159 
160  /* Handle MAD */
161  if ( ( rc = ib_mi_handle ( ibdev, mi, mad, source ) ) != 0 )
162  goto out;
163 
164  out:
165  free_iob ( iobuf );
166 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
#define ntohs(value)
Definition: byteswap.h:136
An Infiniband management interface.
Definition: ib_mi.h:88
#define DBGC_HDA(...)
Definition: compiler.h:506
__be32 out[4]
Definition: CIB_PRM.h:36
#define DBGC2_HDA(...)
Definition: compiler.h:523
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:664
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
A management datagram common header.
Definition: ib_mad.h:538
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
void * data
Start of data.
Definition: iobuf.h:48
A management datagram.
Definition: ib_mad.h:610
#define IB_MGMT_BASE_VERSION
Definition: ib_mad.h:552
static int ib_mi_handle(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av)
Handle received MAD.
Definition: ib_mi.c:77
union ib_mad mad
Definition: arbel.h:12

References io_buffer::data, DBGC, DBGC2_HDA, DBGC_HDA, free_iob(), ib_mad::hdr, hdr, IB_MGMT_BASE_VERSION, ib_mi_handle(), ib_qp_get_ownerdata(), iob_len(), mad, ntohl, ntohs, out, qp, rc, and strerror().

◆ ib_mi_send()

int ib_mi_send ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av 
)

Transmit MAD.

Parameters
ibdevInfiniband device
miManagement interface
madMAD
avDestination address vector
Return values
rcReturn status code

Definition at line 187 of file ib_mi.c.

188  {
189  struct ib_mad_hdr *hdr = &mad->hdr;
190  struct io_buffer *iobuf;
191  int rc;
192 
193  /* Set common fields */
194  hdr->base_version = IB_MGMT_BASE_VERSION;
195  if ( ( hdr->tid.high == 0 ) && ( hdr->tid.low == 0 ) ) {
196  hdr->tid.high = htonl ( IB_MI_TID_MAGIC );
197  hdr->tid.low = htonl ( ++next_tid );
198  }
199  DBGC ( mi, "MI %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
200  "%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
201  hdr->mgmt_class, hdr->class_version, hdr->method,
202  ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
203  DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
204 
205  /* Construct directed route portion of response, if necessary */
206  if ( hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) {
207  struct ib_mad_smp *smp = &mad->smp;
208  unsigned int hop_pointer;
209  unsigned int hop_count;
210 
211  smp->mad_hdr.status |= htons ( IB_SMP_STATUS_D_INBOUND );
212  hop_pointer = smp->mad_hdr.class_specific.smp.hop_pointer;
213  hop_count = smp->mad_hdr.class_specific.smp.hop_count;
215  if ( hop_pointer < ( sizeof ( smp->return_path.hops ) /
216  sizeof ( smp->return_path.hops[0] ) ) ) {
217  smp->return_path.hops[hop_pointer] = ibdev->port;
218  } else {
219  DBGC ( mi, "MI %p TX TID %08x%08x invalid hop pointer "
220  "%d\n", mi, ntohl ( hdr->tid.high ),
221  ntohl ( hdr->tid.low ), hop_pointer );
222  return -EINVAL;
223  }
224  }
225 
226  /* Construct I/O buffer */
227  iobuf = alloc_iob ( sizeof ( *mad ) );
228  if ( ! iobuf ) {
229  DBGC ( mi, "MI %p could not allocate buffer for TID "
230  "%08x%08x\n",
231  mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
232  return -ENOMEM;
233  }
234  memcpy ( iob_put ( iobuf, sizeof ( *mad ) ), mad, sizeof ( *mad ) );
235 
236  /* Send I/O buffer */
237  if ( ( rc = ib_post_send ( ibdev, mi->qp, av, iobuf ) ) != 0 ) {
238  DBGC ( mi, "MI %p TX TID %08x%08x failed: %s\n",
239  mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
240  strerror ( rc ) );
241  free_iob ( iobuf );
242  return rc;
243  }
244 
245  return 0;
246 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:120
struct ib_smp_class_specific smp
Definition: ib_mad.h:12
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define DBGC(...)
Definition: compiler.h:505
A subnet management MAD.
Definition: ib_mad.h:587
#define ntohl(value)
Definition: byteswap.h:134
#define ntohs(value)
Definition: byteswap.h:136
uint8_t hop_pointer
Definition: ib_mad.h:196
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
#define htonl(value)
Definition: byteswap.h:133
struct ib_queue_pair * qp
Queue pair.
Definition: ib_mi.h:94
#define IB_SMP_STATUS_D_INBOUND
Subnet management direction bit.
Definition: ib_mad.h:40
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define DBGC2_HDA(...)
Definition: compiler.h:523
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 hop_pointer
Definition: ib_mad.h:11
A management datagram common header.
Definition: ib_mad.h:538
int ib_post_send(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf)
Post send work queue entry.
Definition: infiniband.c:416
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
#define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
Definition: ib_mad.h:556
#define IB_MI_TID_MAGIC
TID magic signature.
Definition: ib_mi.c:63
#define IB_MGMT_BASE_VERSION
Definition: ib_mad.h:552
uint8_t hop_count
Definition: ib_mad.h:12
static unsigned int next_tid
TID to use for next MAD.
Definition: ib_mi.c:66
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12
A persistent I/O buffer.
Definition: iobuf.h:33

References alloc_iob(), assert(), DBGC, DBGC2_HDA, EINVAL, ENOMEM, free_iob(), ib_mad::hdr, hdr, hop_count, ib_smp_class_specific::hop_count, hop_pointer, ib_smp_class_specific::hop_pointer, htonl, htons, IB_MGMT_BASE_VERSION, IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE, IB_MI_TID_MAGIC, ib_post_send(), IB_SMP_STATUS_D_INBOUND, iob_put, mad, memcpy(), next_tid, ntohl, ntohs, ib_device::port, ib_mad_interface::qp, rc, smp, ib_mad::smp, and strerror().

Referenced by ib_cm_send_drep(), ib_cm_send_rtu(), ib_mcast_leave(), ib_mi_timer_expired(), ib_sma_guid_info(), ib_sma_node_desc(), ib_sma_node_info(), ib_sma_pkey_table(), and ib_sma_port_info().

◆ ib_mi_timer_expired()

static void ib_mi_timer_expired ( struct retry_timer timer,
int  expired 
)
static

Handle management transaction timer expiry.

Parameters
timerRetry timer
expiredFailure indicator

Definition at line 254 of file ib_mi.c.

254  {
255  struct ib_mad_transaction *madx =
257  struct ib_mad_interface *mi = madx->mi;
258  struct ib_device *ibdev = mi->ibdev;
259  struct ib_mad_hdr *hdr = &madx->mad.hdr;
260 
261  /* Abandon transaction if we have tried too many times */
262  if ( expired ) {
263  DBGC ( mi, "MI %p abandoning TID %08x%08x\n",
264  mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
265  madx->op->complete ( ibdev, mi, madx, -ETIMEDOUT, NULL, NULL );
266  return;
267  }
268 
269  /* Restart retransmission timer */
270  start_timer ( timer );
271 
272  /* Resend MAD */
273  ib_mi_send ( ibdev, mi, &madx->mad, &madx->av );
274 }
struct ib_device * ibdev
Infiniband device.
Definition: ib_mi.h:90
struct ib_address_vector av
Destination address vector.
Definition: ib_mi.h:78
static void(* expired)(struct pooled_connection *pool)
Definition: pool.h:61
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
An Infiniband management interface.
Definition: ib_mi.h:88
A timer.
Definition: timer.h:28
An Infiniband device.
Definition: infiniband.h:398
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An Infiniband management transaction.
Definition: ib_mi.h:70
A management datagram common header.
Definition: ib_mad.h:538
struct ib_mad_transaction_operations * op
Transaction operations.
Definition: ib_mi.h:82
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
union ib_mad mad
MAD being sent.
Definition: ib_mi.h:80
void(* complete)(struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av)
Handle transaction completion.
Definition: ib_mi.h:62
struct list_head madx
List of management transactions.
Definition: ib_mi.h:96
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
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

References ib_mad_transaction::av, ib_mad_transaction_operations::complete, container_of, DBGC, ETIMEDOUT, expired, ib_mad::hdr, hdr, ib_mi_send(), ib_mad_interface::ibdev, ib_mad_transaction::mad, ib_mad_interface::madx, ntohl, NULL, ib_mad_transaction::op, and start_timer().

Referenced by ib_create_madx().

◆ ib_create_madx()

struct ib_mad_transaction* ib_create_madx ( struct ib_device ibdev,
struct ib_mad_interface mi,
union ib_mad mad,
struct ib_address_vector av,
struct ib_mad_transaction_operations op 
)

Create management transaction.

Parameters
ibdevInfiniband device
miManagement interface
madMAD to send
avDestination address, or NULL to use SM's GSI
opManagement transaction operations
Return values
madxManagement transaction, or NULL

Definition at line 287 of file ib_mi.c.

289  {
290  struct ib_mad_transaction *madx;
291 
292  /* Allocate and initialise structure */
293  madx = zalloc ( sizeof ( *madx ) );
294  if ( ! madx )
295  return NULL;
296  timer_init ( &madx->timer, ib_mi_timer_expired, NULL );
297  madx->mi = mi;
298  madx->op = op;
299 
300  /* Determine address vector */
301  if ( av ) {
302  memcpy ( &madx->av, av, sizeof ( madx->av ) );
303  } else {
304  madx->av.lid = ibdev->sm_lid;
305  madx->av.sl = ibdev->sm_sl;
306  madx->av.qpn = IB_QPN_GSI;
307  madx->av.qkey = IB_QKEY_GSI;
308  }
309 
310  /* Copy MAD */
311  memcpy ( &madx->mad, mad, sizeof ( madx->mad ) );
312 
313  /* Add to list and start timer to send initial MAD */
314  list_add ( &madx->list, &mi->madx );
315  start_timer_nodelay ( &madx->timer );
316 
317  return madx;
318 }
struct ib_address_vector av
Destination address vector.
Definition: ib_mi.h:78
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
struct list_head list
List of transactions.
Definition: ib_mi.h:74
#define IB_QKEY_GSI
General service interface queue key.
Definition: infiniband.h:30
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned long qkey
Queue key.
Definition: infiniband.h:79
An Infiniband management transaction.
Definition: ib_mi.h:70
uint16_t sm_lid
Subnet manager LID.
Definition: infiniband.h:445
uint8_t sm_sl
Subnet manager SL.
Definition: infiniband.h:447
#define IB_QPN_GSI
General service interface QPN.
Definition: infiniband.h:27
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
struct ib_mad_transaction_operations * op
Transaction operations.
Definition: ib_mi.h:82
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
unsigned int sl
Service level.
Definition: infiniband.h:88
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
struct ib_mad_interface * mi
Associated management interface.
Definition: ib_mi.h:72
static void ib_mi_timer_expired(struct retry_timer *timer, int expired)
Handle management transaction timer expiry.
Definition: ib_mi.c:254
union ib_mad mad
MAD being sent.
Definition: ib_mi.h:80
unsigned int lid
Local ID.
Definition: infiniband.h:81
struct list_head madx
List of management transactions.
Definition: ib_mi.h:96
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
union ib_mad mad
Definition: arbel.h:12
struct retry_timer timer
Retry timer.
Definition: ib_mi.h:76

References ib_mad_transaction::av, ib_mi_timer_expired(), IB_QKEY_GSI, IB_QPN_GSI, ib_address_vector::lid, ib_mad_transaction::list, list_add, mad, ib_mad_transaction::mad, ib_mad_interface::madx, memcpy(), ib_mad_transaction::mi, NULL, ib_mad_transaction::op, op, ib_address_vector::qkey, ib_address_vector::qpn, ib_address_vector::sl, ib_device::sm_lid, ib_device::sm_sl, start_timer_nodelay(), ib_mad_transaction::timer, and zalloc().

Referenced by ib_cm_path_complete(), ib_create_path(), ib_create_service_madx(), ib_mcast_join(), and xsigo_xds_complete().

◆ ib_destroy_madx()

void ib_destroy_madx ( struct ib_device *ibdev  __unused,
struct ib_mad_interface *mi  __unused,
struct ib_mad_transaction madx 
)

Destroy management transaction.

Parameters
ibdevInfiniband device
miManagement interface
madxManagement transaction

Definition at line 327 of file ib_mi.c.

329  {
330 
331  /* Stop timer and remove from list */
332  stop_timer ( &madx->timer );
333  list_del ( &madx->list );
334 
335  /* Free transaction */
336  free ( madx );
337 }
struct list_head list
List of transactions.
Definition: ib_mi.h:74
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
struct retry_timer timer
Retry timer.
Definition: ib_mi.h:76

References free, ib_mad_transaction::list, list_del, stop_timer(), and ib_mad_transaction::timer.

Referenced by ib_cm_req_complete(), ib_create_path(), ib_destroy_conn(), ib_destroy_path(), ib_mcast_complete(), ib_mcast_join(), ib_mcast_leave(), ib_path_complete(), xsigo_discover(), xsigo_ib_notify(), xsigo_ib_remove(), xsigo_xcm_complete(), and xsigo_xds_complete().

◆ ib_create_mi()

int ib_create_mi ( struct ib_device ibdev,
enum ib_queue_pair_type  type,
struct ib_mad_interface **  new_mi 
)

Create management interface.

Parameters
ibdevInfiniband device
typeQueue pair type
new_miNew management interface to fill in
Return values
rcReturn status code

Definition at line 347 of file ib_mi.c.

348  {
349  struct ib_mad_interface *mi;
350  const char *name;
351  int rc;
352 
353  /* Allocate and initialise fields */
354  mi = zalloc ( sizeof ( *mi ) );
355  if ( ! mi ) {
356  rc = -ENOMEM;
357  goto err_alloc;
358  }
359  mi->ibdev = ibdev;
360  INIT_LIST_HEAD ( &mi->madx );
361 
362  /* Create completion queue */
364  &mi->cq ) ) != 0 ) {
365  DBGC ( mi, "MI %p could not create completion queue: %s\n",
366  mi, strerror ( rc ) );
367  goto err_create_cq;
368  }
369 
370  /* Create queue pair */
371  name = ( ( type == IB_QPT_SMI ) ? "SMI" : "GSI" );
372  if ( ( rc = ib_create_qp ( ibdev, type, IB_MI_NUM_SEND_WQES, mi->cq,
373  IB_MI_NUM_RECV_WQES, mi->cq,
374  &ib_mi_queue_pair_ops, name, &mi->qp ) )!=0){
375  DBGC ( mi, "MI %p could not create queue pair: %s\n",
376  mi, strerror ( rc ) );
377  goto err_create_qp;
378  }
379  ib_qp_set_ownerdata ( mi->qp, mi );
380  DBGC ( mi, "MI %p (%s) running on QPN %#lx\n",
381  mi, mi->qp->name, mi->qp->qpn );
382 
383  /* Set queue key */
384  mi->qp->qkey = ( ( type == IB_QPT_SMI ) ? IB_QKEY_SMI : IB_QKEY_GSI );
385  if ( ( rc = ib_modify_qp ( ibdev, mi->qp ) ) != 0 ) {
386  DBGC ( mi, "MI %p could not set queue key: %s\n",
387  mi, strerror ( rc ) );
388  goto err_modify_qp;
389  }
390 
391  /* Fill receive ring */
392  ib_refill_recv ( ibdev, mi->qp );
393  *new_mi = mi;
394  return 0;
395 
396  err_modify_qp:
397  ib_destroy_qp ( ibdev, mi->qp );
398  err_create_qp:
399  ib_destroy_cq ( ibdev, mi->cq );
400  err_create_cq:
401  free ( mi );
402  err_alloc:
403  return rc;
404 }
struct ib_device * ibdev
Infiniband device.
Definition: ib_mi.h:90
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define IB_MI_NUM_RECV_WQES
Management interface number of receive WQEs.
Definition: ib_mi.c:54
const char * name
Definition: ath9k_hw.c:1984
uint32_t type
Operating system type.
Definition: ena.h:12
#define IB_QKEY_SMI
Subnet management interface queue key.
Definition: infiniband.h:24
int ib_modify_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition: infiniband.c:294
int ib_create_cq(struct ib_device *ibdev, unsigned int num_cqes, struct ib_completion_queue_operations *op, struct ib_completion_queue **new_cq)
Create completion queue.
Definition: infiniband.c:98
void ib_refill_recv(struct ib_device *ibdev, struct ib_queue_pair *qp)
Refill receive work queue.
Definition: infiniband.c:556
#define DBGC(...)
Definition: compiler.h:505
An Infiniband management interface.
Definition: ib_mi.h:88
#define IB_QKEY_GSI
General service interface queue key.
Definition: infiniband.h:30
unsigned long qkey
Queue key.
Definition: infiniband.h:176
void ib_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: infiniband.c:145
struct ib_queue_pair * qp
Queue pair.
Definition: ib_mi.h:94
#define ENOMEM
Not enough space.
Definition: errno.h:534
static struct ib_completion_queue_operations ib_mi_completion_ops
Management interface completion operations.
Definition: ib_mi.c:169
struct ib_completion_queue * cq
Completion queue.
Definition: ib_mi.h:92
#define IB_MI_NUM_SEND_WQES
Management interface number of send WQEs.
Definition: ib_mi.c:48
const char * name
Queue pair name.
Definition: infiniband.h:163
unsigned long qpn
Queue pair number.
Definition: infiniband.h:165
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
static struct ib_queue_pair_operations ib_mi_queue_pair_ops
Management interface queue pair operations.
Definition: ib_mi.c:174
#define IB_MI_NUM_CQES
Management interface number of completion queue entries.
Definition: ib_mi.c:60
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
int ib_create_qp(struct ib_device *ibdev, enum ib_queue_pair_type type, unsigned int num_send_wqes, struct ib_completion_queue *send_cq, unsigned int num_recv_wqes, struct ib_completion_queue *recv_cq, struct ib_queue_pair_operations *op, const char *name, struct ib_queue_pair **new_qp)
Create queue pair.
Definition: infiniband.c:199
struct list_head madx
List of management transactions.
Definition: ib_mi.h:96
static __always_inline void ib_qp_set_ownerdata(struct ib_queue_pair *qp, void *priv)
Set Infiniband queue pair owner-private data.
Definition: infiniband.h:653

References ib_mad_interface::cq, DBGC, ENOMEM, free, ib_create_cq(), ib_create_qp(), ib_destroy_cq(), ib_destroy_qp(), ib_mi_completion_ops, IB_MI_NUM_CQES, IB_MI_NUM_RECV_WQES, IB_MI_NUM_SEND_WQES, ib_mi_queue_pair_ops, ib_modify_qp(), IB_QKEY_GSI, IB_QKEY_SMI, ib_qp_set_ownerdata(), IB_QPT_SMI, ib_refill_recv(), ib_mad_interface::ibdev, INIT_LIST_HEAD, ib_mad_interface::madx, ib_queue_pair::name, name, ib_queue_pair::qkey, ib_mad_interface::qp, ib_queue_pair::qpn, rc, strerror(), type, and zalloc().

Referenced by ib_open().

◆ ib_destroy_mi()

void ib_destroy_mi ( struct ib_device ibdev,
struct ib_mad_interface mi 
)

Destroy management interface.

Parameters
miManagement interface

Definition at line 411 of file ib_mi.c.

411  {
412  struct ib_mad_transaction *madx;
413  struct ib_mad_transaction *tmp;
414 
415  /* Flush any outstanding requests */
416  list_for_each_entry_safe ( madx, tmp, &mi->madx, list ) {
417  DBGC ( mi, "MI %p destroyed while TID %08x%08x in progress\n",
418  mi, ntohl ( madx->mad.hdr.tid.high ),
419  ntohl ( madx->mad.hdr.tid.low ) );
420  madx->op->complete ( ibdev, mi, madx, -ECANCELED, NULL, NULL );
421  }
422 
423  ib_destroy_qp ( ibdev, mi->qp );
424  ib_destroy_cq ( ibdev, mi->cq );
425  free ( mi );
426 }
#define DBGC(...)
Definition: compiler.h:505
struct list_head list
List of transactions.
Definition: ib_mi.h:74
#define ntohl(value)
Definition: byteswap.h:134
#define ECANCELED
Operation canceled.
Definition: errno.h:343
void ib_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: infiniband.c:145
struct ib_queue_pair * qp
Queue pair.
Definition: ib_mi.h:94
unsigned long tmp
Definition: linux_pci.h:63
uint32_t low
Definition: ib_mad.h:531
struct ib_completion_queue * cq
Completion queue.
Definition: ib_mi.h:92
An Infiniband management transaction.
Definition: ib_mi.h:70
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
struct ib_mad_transaction_operations * op
Transaction operations.
Definition: ib_mi.h:82
struct ib_mad_tid tid
Definition: ib_mad.h:545
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
struct ib_mad_interface * mi
Associated management interface.
Definition: ib_mi.h:72
uint32_t high
Definition: ib_mad.h:530
union ib_mad mad
MAD being sent.
Definition: ib_mi.h:80
void(* complete)(struct ib_device *ibdev, struct ib_mad_interface *mi, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av)
Handle transaction completion.
Definition: ib_mi.h:62
struct list_head madx
List of management transactions.
Definition: ib_mi.h:96
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ib_mad_transaction_operations::complete, ib_mad_interface::cq, DBGC, ECANCELED, free, ib_mad::hdr, ib_mad_tid::high, ib_destroy_cq(), ib_destroy_qp(), ib_mad_transaction::list, list_for_each_entry_safe, ib_mad_tid::low, ib_mad_transaction::mad, ib_mad_interface::madx, ib_mad_transaction::mi, ntohl, NULL, ib_mad_transaction::op, ib_mad_interface::qp, ib_mad_hdr::tid, and tmp.

Referenced by ib_close(), and ib_open().

Variable Documentation

◆ next_tid

unsigned int next_tid
static

TID to use for next MAD.

Definition at line 66 of file ib_mi.c.

Referenced by ib_mi_send().

◆ ib_mi_completion_ops

struct ib_completion_queue_operations ib_mi_completion_ops
static
Initial value:
= {
.complete_recv = ib_mi_complete_recv,
}
static void ib_mi_complete_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest __unused, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Complete receive via management interface.
Definition: ib_mi.c:124

Management interface completion operations.

Definition at line 169 of file ib_mi.c.

Referenced by ib_create_mi().

◆ ib_mi_queue_pair_ops

struct ib_queue_pair_operations ib_mi_queue_pair_ops
static
Initial value:
= {
.alloc_iob = alloc_iob,
}
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129

Management interface queue pair operations.

Definition at line 174 of file ib_mi.c.

Referenced by ib_create_mi().