iPXE
infiniband.c File Reference

Infiniband protocol. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <byteswap.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/list.h>
#include <ipxe/errortab.h>
#include <ipxe/if_arp.h>
#include <ipxe/netdevice.h>
#include <ipxe/iobuf.h>
#include <ipxe/process.h>
#include <ipxe/profile.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_mi.h>
#include <ipxe/ib_sma.h>

Go to the source code of this file.

Macros

#define EINPROGRESS_INIT   __einfo_error ( EINFO_EINPROGRESS_INIT )
#define EINFO_EINPROGRESS_INIT
#define EINPROGRESS_ARMED   __einfo_error ( EINFO_EINPROGRESS_ARMED )
#define EINFO_EINPROGRESS_ARMED

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
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.
void ib_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Destroy completion queue.
void ib_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Poll completion queue.
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.
int ib_modify_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Modify queue pair.
void ib_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy queue pair.
struct ib_queue_pairib_find_qp_qpn (struct ib_device *ibdev, unsigned long qpn)
 Find queue pair by QPN.
struct ib_queue_pairib_find_qp_mgid (struct ib_device *ibdev, union ib_gid *gid)
 Find queue pair by multicast GID.
struct ib_work_queueib_find_wq (struct ib_completion_queue *cq, unsigned long qpn, int is_send)
 Find work queue belonging to completion queue.
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.
int ib_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
 Post receive work queue entry.
void ib_complete_send (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
 Complete send work queue entry.
void ib_complete_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
 Complete receive work queue entry.
void ib_refill_recv (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Refill receive work queue.
int ib_link_rc (struct ib_device *ibdev)
 Get link state.
static const char * ib_link_state_text (struct ib_device *ibdev)
 Textual representation of Infiniband link state.
static void ib_notify (struct ib_device *ibdev)
 Notify drivers of Infiniband device or link state change.
void ib_link_state_changed (struct ib_device *ibdev)
 Notify of Infiniband link state change.
int ib_open (struct ib_device *ibdev)
 Open port.
void ib_close (struct ib_device *ibdev)
 Close port.
int ib_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Attach to multicast group.
void ib_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Detach from multicast group.
int ib_set_port_info (struct ib_device *ibdev, union ib_mad *mad)
 Set port information.
int ib_set_pkey_table (struct ib_device *ibdev, union ib_mad *mad)
 Set partition key table.
void ib_poll_eq (struct ib_device *ibdev)
 Poll event queue.
static void ib_step (struct process *process __unused)
 Single-step the Infiniband event queue.
 PERMANENT_PROCESS (ib_process, ib_step)
 Infiniband event queue process.
struct ib_devicealloc_ibdev (size_t priv_size)
 Allocate Infiniband device.
int register_ibdev (struct ib_device *ibdev)
 Register Infiniband device.
void unregister_ibdev (struct ib_device *ibdev)
 Unregister Infiniband device.
struct ib_devicefind_ibdev (union ib_gid *gid)
 Find Infiniband device by GID.
struct ib_devicelast_opened_ibdev (void)
 Get most recently opened Infiniband device.
 REQUIRING_SYMBOL (register_ibdev)
 REQUIRE_OBJECT (config_infiniband)

Variables

struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices )
 List of Infiniband devices.
static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices )
 List of open Infiniband devices, in reverse order of opening.
static unsigned int ibdev_index = 0
 Infiniband device index.
static struct profiler ib_post_send_profiler __profiler
 Post send work queue entry profiler.
struct errortab infiniband_errors[] __errortab
 Human-readable message for the link statuses.

Detailed Description

Infiniband protocol.

Definition in file infiniband.c.

Macro Definition Documentation

◆ EINPROGRESS_INIT

#define EINPROGRESS_INIT   __einfo_error ( EINFO_EINPROGRESS_INIT )

Definition at line 69 of file infiniband.c.

Referenced by ib_link_rc().

◆ EINFO_EINPROGRESS_INIT

#define EINFO_EINPROGRESS_INIT
Value:
( EINFO_EINPROGRESS, 0x01, "Initialising" )
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition errno.h:181
#define EINFO_EINPROGRESS
Definition errno.h:420

Definition at line 70 of file infiniband.c.

70#define EINFO_EINPROGRESS_INIT __einfo_uniqify \
71 ( EINFO_EINPROGRESS, 0x01, "Initialising" )

◆ EINPROGRESS_ARMED

#define EINPROGRESS_ARMED   __einfo_error ( EINFO_EINPROGRESS_ARMED )

Definition at line 72 of file infiniband.c.

Referenced by ib_link_rc().

◆ EINFO_EINPROGRESS_ARMED

#define EINFO_EINPROGRESS_ARMED
Value:
( EINFO_EINPROGRESS, 0x02, "Armed" )

Definition at line 73 of file infiniband.c.

73#define EINFO_EINPROGRESS_ARMED __einfo_uniqify \
74 ( EINFO_EINPROGRESS, 0x02, "Armed" )

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ ib_create_cq()

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.

Parameters
ibdevInfiniband device
num_cqesNumber of completion queue entries
opCompletion queue operations
new_cqNew completion queue to fill in
Return values
rcReturn status code

Definition at line 98 of file infiniband.c.

100 {
101 struct ib_completion_queue *cq;
102 int rc;
103
104 DBGC ( ibdev, "IBDEV %s creating completion queue\n", ibdev->name );
105
106 /* Allocate and initialise data structure */
107 cq = zalloc ( sizeof ( *cq ) );
108 if ( ! cq ) {
109 rc = -ENOMEM;
110 goto err_alloc_cq;
111 }
112 cq->ibdev = ibdev;
113 list_add_tail ( &cq->list, &ibdev->cqs );
114 cq->num_cqes = num_cqes;
116 cq->op = op;
117
118 /* Perform device-specific initialisation and get CQN */
119 if ( ( rc = ibdev->op->create_cq ( ibdev, cq ) ) != 0 ) {
120 DBGC ( ibdev, "IBDEV %s could not initialise completion "
121 "queue: %s\n", ibdev->name, strerror ( rc ) );
122 goto err_dev_create_cq;
123 }
124
125 DBGC ( ibdev, "IBDEV %s created %d-entry completion queue %p (%p) "
126 "with CQN %#lx\n", ibdev->name, num_cqes, cq,
127 ib_cq_get_drvdata ( cq ), cq->cqn );
128 *new_cq = cq;
129 return 0;
130
131 ibdev->op->destroy_cq ( ibdev, cq );
132 err_dev_create_cq:
133 list_del ( &cq->list );
134 free ( cq );
135 err_alloc_cq:
136 return rc;
137}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBGC(...)
Definition compiler.h:505
#define ENOMEM
Not enough space.
Definition errno.h:535
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition infiniband.h:687
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition list.h:94
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition list.h:46
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
An Infiniband Completion Queue.
Definition infiniband.h:225
struct ib_device * ibdev
Containing Infiniband device.
Definition infiniband.h:227
unsigned long cqn
Completion queue number.
Definition infiniband.h:231
struct list_head list
List of completion queues on this Infiniband device.
Definition infiniband.h:229
struct list_head work_queues
List of work queues completing to this queue.
Definition infiniband.h:243
struct ib_completion_queue_operations * op
Completion queue operations.
Definition infiniband.h:245
unsigned int num_cqes
Number of completion queue entries.
Definition infiniband.h:233
int(* create_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Create completion queue.
Definition infiniband.h:262
void(* destroy_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition infiniband.h:269
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition infiniband.h:409
struct ib_device_operations * op
Infiniband operations.
Definition infiniband.h:417
struct list_head cqs
List of completion queues.
Definition infiniband.h:413

References ib_completion_queue::cqn, ib_device::cqs, ib_device_operations::create_cq, DBGC, ib_device_operations::destroy_cq, ENOMEM, free, ib_cq_get_drvdata(), ib_completion_queue::ibdev, INIT_LIST_HEAD, ib_completion_queue::list, list_add_tail, list_del, ib_device::name, ib_completion_queue::num_cqes, ib_completion_queue::op, ib_device::op, op, rc, strerror(), ib_completion_queue::work_queues, and zalloc().

Referenced by eoib_open(), flexboot_nodnic_eth_open(), hermon_eth_open(), ib_cmrc_open(), ib_create_mi(), and ipoib_open().

◆ ib_destroy_cq()

void ib_destroy_cq ( struct ib_device * ibdev,
struct ib_completion_queue * cq )

Destroy completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 145 of file infiniband.c.

146 {
147 DBGC ( ibdev, "IBDEV %s destroying completion queue %#lx\n",
148 ibdev->name, cq->cqn );
149 assert ( list_empty ( &cq->work_queues ) );
150 ibdev->op->destroy_cq ( ibdev, cq );
151 list_del ( &cq->list );
152 free ( cq );
153}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
#define list_empty(list)
Test whether a list is empty.
Definition list.h:137

References assert, ib_completion_queue::cqn, DBGC, ib_device_operations::destroy_cq, free, ib_completion_queue::ibdev, ib_completion_queue::list, list_del, list_empty, ib_device::name, ib_device::op, and ib_completion_queue::work_queues.

Referenced by eoib_close(), eoib_open(), flexboot_nodnic_eth_close(), hermon_eth_close(), hermon_eth_open(), ib_cmrc_open(), ib_cmrc_shutdown(), ib_create_mi(), ib_destroy_mi(), ipoib_close(), and ipoib_open().

◆ ib_poll_cq()

void ib_poll_cq ( struct ib_device * ibdev,
struct ib_completion_queue * cq )

Poll completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 161 of file infiniband.c.

162 {
163 struct ib_work_queue *wq;
164
165 /* Poll completion queue */
166 ibdev->op->poll_cq ( ibdev, cq );
167
168 /* Refill receive work queues */
170 if ( ! wq->is_send )
171 ib_refill_recv ( ibdev, wq->qp );
172 }
173}
void ib_refill_recv(struct ib_device *ibdev, struct ib_queue_pair *qp)
Refill receive work queue.
Definition infiniband.c:556
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
void(* poll_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition infiniband.h:334
An Infiniband Work Queue.
Definition infiniband.h:101
struct ib_completion_queue * cq
Associated completion queue.
Definition infiniband.h:107
struct list_head list
List of work queues on this completion queue.
Definition infiniband.h:109
struct ib_queue_pair * qp
Containing queue pair.
Definition infiniband.h:103
int is_send
"Is a send queue" flag
Definition infiniband.h:105

References ib_work_queue::cq, ib_refill_recv(), ib_work_queue::is_send, ib_work_queue::list, list_for_each_entry, ib_device::op, ib_device_operations::poll_cq, ib_work_queue::qp, and ib_completion_queue::work_queues.

Referenced by flexboot_nodnic_complete_all_tx(), golan_cq_clean(), and ib_poll_eq().

◆ ib_create_qp()

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.

Parameters
ibdevInfiniband device
typeQueue pair type
num_send_wqesNumber of send work queue entries
send_cqSend completion queue
num_recv_wqesNumber of receive work queue entries
recv_cqReceive completion queue
opQueue pair operations
nameQueue pair name
new_qpNew queue pair to fill in
Return values
rcReturn status code

The queue pair will be left in the INIT state; you must call ib_modify_qp() before it is ready to use for sending and receiving.

Definition at line 199 of file infiniband.c.

205 {
206 struct ib_queue_pair *qp;
207 size_t total_size;
208 int rc;
209
210 DBGC ( ibdev, "IBDEV %s creating queue pair\n", ibdev->name );
211
212 /* Allocate and initialise data structure */
213 total_size = ( sizeof ( *qp ) +
214 ( num_send_wqes * sizeof ( qp->send.iobufs[0] ) ) +
215 ( num_recv_wqes * sizeof ( qp->recv.iobufs[0] ) ) );
216 qp = zalloc ( total_size );
217 if ( ! qp ) {
218 rc = -ENOMEM;
219 goto err_alloc_qp;
220 }
221 qp->ibdev = ibdev;
222 list_add_tail ( &qp->list, &ibdev->qps );
223 qp->type = type;
224 qp->send.qp = qp;
225 qp->send.is_send = 1;
226 qp->send.cq = send_cq;
227 list_add_tail ( &qp->send.list, &send_cq->work_queues );
228 qp->send.psn = ( random() & 0xffffffUL );
229 qp->send.num_wqes = num_send_wqes;
230 qp->send.iobufs = ( ( ( void * ) qp ) + sizeof ( *qp ) );
231 qp->recv.qp = qp;
232 qp->recv.cq = recv_cq;
233 list_add_tail ( &qp->recv.list, &recv_cq->work_queues );
234 qp->recv.psn = ( random() & 0xffffffUL );
235 qp->recv.num_wqes = num_recv_wqes;
236 qp->recv.iobufs = ( ( ( void * ) qp ) + sizeof ( *qp ) +
237 ( num_send_wqes * sizeof ( qp->send.iobufs[0] ) ));
238 INIT_LIST_HEAD ( &qp->mgids );
239 qp->op = op;
240 qp->name = name;
241
242 /* Perform device-specific initialisation and get QPN */
243 if ( ( rc = ibdev->op->create_qp ( ibdev, qp ) ) != 0 ) {
244 DBGC ( ibdev, "IBDEV %s could not initialise queue pair: "
245 "%s\n", ibdev->name, strerror ( rc ) );
246 goto err_dev_create_qp;
247 }
248 DBGC ( ibdev, "IBDEV %s created queue pair %p (%p) with QPN %#lx\n",
249 ibdev->name, qp, ib_qp_get_drvdata ( qp ), qp->qpn );
250 DBGC ( ibdev, "IBDEV %s QPN %#lx has %d send entries at [%p,%p)\n",
251 ibdev->name, qp->qpn, num_send_wqes, qp->send.iobufs,
252 qp->recv.iobufs );
253 DBGC ( ibdev, "IBDEV %s QPN %#lx has %d receive entries at [%p,%p)\n",
254 ibdev->name, qp->qpn, num_recv_wqes, qp->recv.iobufs,
255 ( ( ( void * ) qp ) + total_size ) );
256
257 /* Calculate externally-visible QPN */
258 switch ( type ) {
259 case IB_QPT_SMI:
260 qp->ext_qpn = IB_QPN_SMI;
261 break;
262 case IB_QPT_GSI:
263 qp->ext_qpn = IB_QPN_GSI;
264 break;
265 default:
266 qp->ext_qpn = qp->qpn;
267 break;
268 }
269 if ( qp->ext_qpn != qp->qpn ) {
270 DBGC ( ibdev, "IBDEV %s QPN %#lx has external QPN %#lx\n",
271 ibdev->name, qp->qpn, qp->ext_qpn );
272 }
273
274 *new_qp = qp;
275 return 0;
276
277 ibdev->op->destroy_qp ( ibdev, qp );
278 err_dev_create_qp:
279 list_del ( &qp->send.list );
280 list_del ( &qp->recv.list );
281 list_del ( &qp->list );
282 free ( qp );
283 err_alloc_qp:
284 return rc;
285}
struct arbelprm_qp_db_record qp
Definition arbel.h:2
const char * name
Definition ath9k_hw.c:1986
uint32_t type
Operating system type.
Definition ena.h:1
#define IB_QPN_SMI
Subnet management interface QPN.
Definition infiniband.h:22
@ IB_QPT_GSI
Definition infiniband.h:141
@ IB_QPT_SMI
Definition infiniband.h:140
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition infiniband.h:643
#define IB_QPN_GSI
General service interface QPN.
Definition infiniband.h:28
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition random.c:32
int(* create_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create queue pair.
Definition infiniband.h:277
void(* destroy_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition infiniband.h:292
struct list_head qps
List of queue pairs.
Definition infiniband.h:415
An Infiniband Queue Pair.
Definition infiniband.h:158
struct ib_device * ibdev
Containing Infiniband device.
Definition infiniband.h:160

References ib_device_operations::create_qp, DBGC, ib_device_operations::destroy_qp, ENOMEM, free, ib_qp_get_drvdata(), IB_QPN_GSI, IB_QPN_SMI, IB_QPT_GSI, IB_QPT_SMI, ib_queue_pair::ibdev, INIT_LIST_HEAD, list_add_tail, list_del, ib_device::name, name, ib_device::op, op, qp, ib_device::qps, random(), rc, strerror(), type, ib_completion_queue::work_queues, and zalloc().

Referenced by eoib_open(), flexboot_nodnic_eth_open(), hermon_eth_open(), ib_cmrc_open(), ib_create_mi(), and ipoib_open().

◆ ib_modify_qp()

int ib_modify_qp ( struct ib_device * ibdev,
struct ib_queue_pair * qp )

Modify queue pair.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 294 of file infiniband.c.

294 {
295 int rc;
296
297 DBGC ( ibdev, "IBDEV %s modifying QPN %#lx\n", ibdev->name, qp->qpn );
298
299 if ( ( rc = ibdev->op->modify_qp ( ibdev, qp ) ) != 0 ) {
300 DBGC ( ibdev, "IBDEV %s could not modify QPN %#lx: %s\n",
301 ibdev->name, qp->qpn, strerror ( rc ) );
302 return rc;
303 }
304
305 return 0;
306}
int(* modify_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition infiniband.h:285

References DBGC, ib_queue_pair::ibdev, ib_device_operations::modify_qp, ib_device::name, ib_device::op, qp, rc, and strerror().

Referenced by hermon_eth_open(), ib_cm_req_complete(), ib_create_mi(), and ib_mcast_complete().

◆ ib_destroy_qp()

void ib_destroy_qp ( struct ib_device * ibdev,
struct ib_queue_pair * qp )

Destroy queue pair.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 314 of file infiniband.c.

314 {
315 struct io_buffer *iobuf;
316 unsigned int i;
317
318 DBGC ( ibdev, "IBDEV %s destroying QPN %#lx\n",
319 ibdev->name, qp->qpn );
320
321 assert ( list_empty ( &qp->mgids ) );
322
323 /* Perform device-specific destruction */
324 ibdev->op->destroy_qp ( ibdev, qp );
325
326 /* Complete any remaining I/O buffers with errors */
327 for ( i = 0 ; i < qp->send.num_wqes ; i++ ) {
328 if ( ( iobuf = qp->send.iobufs[i] ) != NULL )
329 ib_complete_send ( ibdev, qp, iobuf, -ECANCELED );
330 }
331 for ( i = 0 ; i < qp->recv.num_wqes ; i++ ) {
332 if ( ( iobuf = qp->recv.iobufs[i] ) != NULL ) {
333 ib_complete_recv ( ibdev, qp, NULL, NULL, iobuf,
334 -ECANCELED );
335 }
336 }
337
338 /* Remove work queues from completion queue */
339 list_del ( &qp->send.list );
340 list_del ( &qp->recv.list );
341
342 /* Free QP */
343 list_del ( &qp->list );
344 free ( qp );
345}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define ECANCELED
Operation canceled.
Definition errno.h:344
void ib_complete_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Complete receive work queue entry.
Definition infiniband.c:536
void ib_complete_send(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
Complete send work queue entry.
Definition infiniband.c:515
A persistent I/O buffer.
Definition iobuf.h:38

References assert, DBGC, ib_device_operations::destroy_qp, ECANCELED, free, ib_complete_recv(), ib_complete_send(), list_del, list_empty, ib_device::name, NULL, ib_device::op, and qp.

Referenced by eoib_close(), eoib_open(), flexboot_nodnic_eth_close(), flexboot_nodnic_eth_open(), hermon_eth_close(), hermon_eth_open(), ib_cmrc_open(), ib_cmrc_shutdown(), ib_create_mi(), ib_destroy_mi(), ipoib_close(), and ipoib_open().

◆ ib_find_qp_qpn()

struct ib_queue_pair * ib_find_qp_qpn ( struct ib_device * ibdev,
unsigned long qpn )

Find queue pair by QPN.

Parameters
ibdevInfiniband device
qpnQueue pair number
Return values
qpQueue pair, or NULL

Definition at line 354 of file infiniband.c.

355 {
356 struct ib_queue_pair *qp;
357
359 if ( ( qpn == qp->qpn ) || ( qpn == qp->ext_qpn ) )
360 return qp;
361 }
362 return NULL;
363}
__be32 qpn
Definition CIB_PRM.h:1
struct list_head list
List of queue pairs on this Infiniband device.
Definition infiniband.h:162

References ib_queue_pair::ibdev, ib_queue_pair::list, list_for_each_entry, NULL, qp, qpn, and ib_device::qps.

Referenced by ib_pull().

◆ ib_find_qp_mgid()

struct ib_queue_pair * ib_find_qp_mgid ( struct ib_device * ibdev,
union ib_gid * gid )

Find queue pair by multicast GID.

Parameters
ibdevInfiniband device
gidMulticast GID
Return values
qpQueue pair, or NULL

Definition at line 372 of file infiniband.c.

373 {
374 struct ib_queue_pair *qp;
375 struct ib_multicast_gid *mgid;
376
377 list_for_each_entry ( qp, &ibdev->qps, list ) {
378 list_for_each_entry ( mgid, &qp->mgids, list ) {
379 if ( memcmp ( &mgid->gid, gid,
380 sizeof ( mgid->gid ) ) == 0 ) {
381 return qp;
382 }
383 }
384 }
385 return NULL;
386}
u8 gid[16]
Definition CIB_PRM.h:3
union ib_gid mgid
Definition ib_mad.h:0
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
An Infiniband multicast GID.
Definition infiniband.h:131
struct list_head list
List of multicast GIDs on this QP.
Definition infiniband.h:133

References gid, ib_multicast_gid::list, list_for_each_entry, memcmp(), mgid, NULL, qp, and ib_device::qps.

Referenced by ib_pull().

◆ ib_find_wq()

struct ib_work_queue * ib_find_wq ( struct ib_completion_queue * cq,
unsigned long qpn,
int is_send )

Find work queue belonging to completion queue.

Parameters
cqCompletion queue
qpnQueue pair number
is_sendFind send work queue (rather than receive)
Return values
wqWork queue, or NULL if not found

Definition at line 396 of file infiniband.c.

397 {
398 struct ib_work_queue *wq;
399
401 if ( ( wq->qp->qpn == qpn ) && ( wq->is_send == is_send ) )
402 return wq;
403 }
404 return NULL;
405}
unsigned long qpn
Queue pair number.
Definition infiniband.h:166

References ib_work_queue::cq, ib_work_queue::is_send, ib_work_queue::list, list_for_each_entry, NULL, ib_work_queue::qp, ib_queue_pair::qpn, qpn, and ib_completion_queue::work_queues.

Referenced by arbel_complete(), golan_complete(), and hermon_complete().

◆ ib_post_send()

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.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
Return values
rcReturn status code

Definition at line 416 of file infiniband.c.

418 {
419 struct ib_address_vector dest_copy;
420 int rc;
421
422 /* Start profiling */
423 profile_start ( &ib_post_send_profiler );
424
425 /* Check queue fill level */
426 if ( qp->send.fill >= qp->send.num_wqes ) {
427 DBGC ( ibdev, "IBDEV %s QPN %#lx send queue full\n",
428 ibdev->name, qp->qpn );
429 return -ENOBUFS;
430 }
431
432 /* Use default address vector if none specified */
433 if ( ! dest )
434 dest = &qp->av;
435
436 /* Make modifiable copy of address vector */
437 memcpy ( &dest_copy, dest, sizeof ( dest_copy ) );
438 dest = &dest_copy;
439
440 /* Fill in optional parameters in address vector */
441 if ( ! dest->qkey )
442 dest->qkey = qp->qkey;
443 if ( ! dest->rate )
444 dest->rate = IB_RATE_2_5;
445
446 /* Post to hardware */
447 if ( ( rc = ibdev->op->post_send ( ibdev, qp, dest, iobuf ) ) != 0 ) {
448 DBGC ( ibdev, "IBDEV %s QPN %#lx could not post send WQE: "
449 "%s\n", ibdev->name, qp->qpn, strerror ( rc ) );
450 return rc;
451 }
452
453 /* Increase fill level */
454 qp->send.fill++;
455
456 /* Stop profiling */
457 profile_stop ( &ib_post_send_profiler );
458
459 return 0;
460}
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
#define ENOBUFS
No buffer space available.
Definition errno.h:499
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition profile.h:174
static void profile_start(struct profiler *profiler)
Start profiling.
Definition profile.h:161
void * memcpy(void *dest, const void *src, size_t len) __nonnull
@ IB_RATE_2_5
Definition infiniband.h:61
An Infiniband Address Vector.
Definition infiniband.h:73
int(* 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.h:307

References DBGC, dest, ENOBUFS, IB_RATE_2_5, memcpy(), ib_device::name, ib_device::op, ib_device_operations::post_send, profile_start(), profile_stop(), qp, rc, and strerror().

Referenced by eoib_duplicate(), eoib_transmit(), flexboot_nodnic_eth_transmit(), hermon_eth_transmit(), ib_cmrc_xfer_deliver(), ib_mi_send(), and ipoib_transmit().

◆ ib_post_recv()

int ib_post_recv ( struct ib_device * ibdev,
struct ib_queue_pair * qp,
struct io_buffer * iobuf )

Post receive work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
iobufI/O buffer
Return values
rcReturn status code

Definition at line 470 of file infiniband.c.

471 {
472 int rc;
473
474 /* Start profiling */
475 profile_start ( &ib_post_recv_profiler );
476
477 /* Check packet length */
478 if ( iob_tailroom ( iobuf ) < IB_MAX_PAYLOAD_SIZE ) {
479 DBGC ( ibdev, "IBDEV %s QPN %#lx wrong RX buffer size (%zd)\n",
480 ibdev->name, qp->qpn, iob_tailroom ( iobuf ) );
481 return -EINVAL;
482 }
483
484 /* Check queue fill level */
485 if ( qp->recv.fill >= qp->recv.num_wqes ) {
486 DBGC ( ibdev, "IBDEV %s QPN %#lx receive queue full\n",
487 ibdev->name, qp->qpn );
488 return -ENOBUFS;
489 }
490
491 /* Post to hardware */
492 if ( ( rc = ibdev->op->post_recv ( ibdev, qp, iobuf ) ) != 0 ) {
493 DBGC ( ibdev, "IBDEV %s QPN %#lx could not post receive WQE: "
494 "%s\n", ibdev->name, qp->qpn, strerror ( rc ) );
495 return rc;
496 }
497
498 /* Increase fill level */
499 qp->recv.fill++;
500
501 /* Stop profiling */
502 profile_stop ( &ib_post_recv_profiler );
503
504 return 0;
505}
#define EINVAL
Invalid argument.
Definition errno.h:429
#define IB_MAX_PAYLOAD_SIZE
Maximum payload size.
Definition infiniband.h:51
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition iobuf.h:180
int(* post_recv)(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
Post receive work queue entry.
Definition infiniband.h:323

References DBGC, EINVAL, ENOBUFS, IB_MAX_PAYLOAD_SIZE, iob_tailroom(), ib_device::name, ib_device::op, ib_device_operations::post_recv, profile_start(), profile_stop(), qp, rc, and strerror().

Referenced by ib_refill_recv().

◆ ib_complete_send()

void ib_complete_send ( struct ib_device * ibdev,
struct ib_queue_pair * qp,
struct io_buffer * iobuf,
int rc )

Complete send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
iobufI/O buffer
rcCompletion status code

Definition at line 515 of file infiniband.c.

516 {
517
518 if ( qp->send.cq->op->complete_send ) {
519 qp->send.cq->op->complete_send ( ibdev, qp, iobuf, rc );
520 } else {
521 free_iob ( iobuf );
522 }
523 qp->send.fill--;
524}
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153

References free_iob(), qp, and rc.

Referenced by arbel_complete(), flexboot_nodnic_complete(), golan_complete(), hermon_complete(), ib_destroy_qp(), linda_complete_send(), and qib7322_complete_send().

◆ ib_complete_recv()

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

Complete receive work queue entry.

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

Definition at line 536 of file infiniband.c.

539 {
540
541 if ( qp->recv.cq->op->complete_recv ) {
542 qp->recv.cq->op->complete_recv ( ibdev, qp, dest, source,
543 iobuf, rc );
544 } else {
545 free_iob ( iobuf );
546 }
547 qp->recv.fill--;
548}

References dest, free_iob(), qp, and rc.

Referenced by arbel_complete(), flexboot_nodnic_complete(), golan_complete(), hermon_complete(), ib_destroy_qp(), linda_complete_recv(), and qib7322_complete_recv().

◆ ib_refill_recv()

void ib_refill_recv ( struct ib_device * ibdev,
struct ib_queue_pair * qp )

Refill receive work queue.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 556 of file infiniband.c.

556 {
557 struct io_buffer *iobuf;
558 int rc;
559
560 /* Keep filling while unfilled entries remain */
561 while ( qp->recv.fill < qp->recv.num_wqes ) {
562
563 /* Allocate I/O buffer */
564 iobuf = qp->op->alloc_iob ( IB_MAX_PAYLOAD_SIZE );
565 if ( ! iobuf ) {
566 /* Non-fatal; we will refill on next attempt */
567 return;
568 }
569
570 /* Post I/O buffer */
571 if ( ( rc = ib_post_recv ( ibdev, qp, iobuf ) ) != 0 ) {
572 DBGC ( ibdev, "IBDEV %s could not refill: %s\n",
573 ibdev->name, strerror ( rc ) );
574 free_iob ( iobuf );
575 /* Give up */
576 return;
577 }
578 }
579}
int ib_post_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
Post receive work queue entry.
Definition infiniband.c:470

References DBGC, free_iob(), IB_MAX_PAYLOAD_SIZE, ib_post_recv(), ib_device::name, qp, rc, and strerror().

Referenced by eoib_open(), flexboot_nodnic_eth_open(), hermon_eth_open(), ib_create_mi(), ib_poll_cq(), and ipoib_open().

◆ ib_link_rc()

int ib_link_rc ( struct ib_device * ibdev)

Get link state.

Parameters
ibdevInfiniband device
Return values
rcLink status code

Definition at line 594 of file infiniband.c.

594 {
595 switch ( ibdev->port_state ) {
596 case IB_PORT_STATE_DOWN: return -ENOTCONN;
599 case IB_PORT_STATE_ACTIVE: return 0;
600 default: return -EINVAL;
601 }
602}
#define ENOTCONN
The socket is not connected.
Definition errno.h:570
#define IB_PORT_STATE_DOWN
Definition ib_mad.h:152
#define IB_PORT_STATE_INIT
Definition ib_mad.h:153
#define IB_PORT_STATE_ACTIVE
Definition ib_mad.h:155
#define IB_PORT_STATE_ARMED
Definition ib_mad.h:154
#define EINPROGRESS_INIT
Definition infiniband.c:69
#define EINPROGRESS_ARMED
Definition infiniband.c:72
uint8_t port_state
Port state.
Definition infiniband.h:426

References EINPROGRESS_ARMED, EINPROGRESS_INIT, EINVAL, ENOTCONN, IB_PORT_STATE_ACTIVE, IB_PORT_STATE_ARMED, IB_PORT_STATE_DOWN, IB_PORT_STATE_INIT, and ib_device::port_state.

Referenced by eoib_link_state_changed(), and ipoib_link_state_changed().

◆ ib_link_state_text()

const char * ib_link_state_text ( struct ib_device * ibdev)
static

Textual representation of Infiniband link state.

Parameters
ibdevInfiniband device
Return values
link_textLink state text

Definition at line 610 of file infiniband.c.

610 {
611 switch ( ibdev->port_state ) {
612 case IB_PORT_STATE_DOWN: return "DOWN";
613 case IB_PORT_STATE_INIT: return "INIT";
614 case IB_PORT_STATE_ARMED: return "ARMED";
615 case IB_PORT_STATE_ACTIVE: return "ACTIVE";
616 default: return "UNKNOWN";
617 }
618}

References IB_PORT_STATE_ACTIVE, IB_PORT_STATE_ARMED, IB_PORT_STATE_DOWN, IB_PORT_STATE_INIT, and ib_device::port_state.

Referenced by ib_link_state_changed().

◆ ib_notify()

void ib_notify ( struct ib_device * ibdev)
static

Notify drivers of Infiniband device or link state change.

Parameters
ibdevInfiniband device

Definition at line 625 of file infiniband.c.

625 {
626 struct ib_driver *driver;
627
629 driver->notify ( ibdev );
630}
#define IB_DRIVERS
Infiniband driver table.
Definition infiniband.h:494
An Infiniband upper-layer driver.
Definition infiniband.h:472
void(* notify)(struct ib_device *ibdev)
Notify of device or link state change.
Definition infiniband.h:485
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition tables.h:386

References for_each_table_entry, IB_DRIVERS, and ib_driver::notify.

Referenced by ib_close(), ib_link_state_changed(), and ib_open().

◆ ib_link_state_changed()

void ib_link_state_changed ( struct ib_device * ibdev)

Notify of Infiniband link state change.

Parameters
ibdevInfiniband device

Definition at line 637 of file infiniband.c.

637 {
638
639 DBGC ( ibdev, "IBDEV %s link state is %s\n",
640 ibdev->name, ib_link_state_text ( ibdev ) );
641
642 /* Notify drivers of link state change */
643 ib_notify ( ibdev );
644}
static const char * ib_link_state_text(struct ib_device *ibdev)
Textual representation of Infiniband link state.
Definition infiniband.c:610
static void ib_notify(struct ib_device *ibdev)
Notify drivers of Infiniband device or link state change.
Definition infiniband.c:625

References DBGC, ib_link_state_text(), ib_notify(), and ib_device::name.

Referenced by golan_ib_update(), ib_smc_update(), linda_link_state_changed(), and qib7322_link_state_changed().

◆ ib_open()

int ib_open ( struct ib_device * ibdev)

Open port.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 652 of file infiniband.c.

652 {
653 int rc;
654
655 /* Increment device open request counter */
656 if ( ibdev->open_count++ > 0 ) {
657 /* Device was already open; do nothing */
658 return 0;
659 }
660
661 /* Open device */
662 if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 ) {
663 DBGC ( ibdev, "IBDEV %s could not open: %s\n",
664 ibdev->name, strerror ( rc ) );
665 goto err_open;
666 }
667
668 /* Create subnet management interface */
669 if ( ( rc = ib_create_mi ( ibdev, IB_QPT_SMI, &ibdev->smi ) ) != 0 ) {
670 DBGC ( ibdev, "IBDEV %s could not create SMI: %s\n",
671 ibdev->name, strerror ( rc ) );
672 goto err_create_smi;
673 }
674
675 /* Create subnet management agent */
676 if ( ( rc = ib_create_sma ( ibdev, ibdev->smi ) ) != 0 ) {
677 DBGC ( ibdev, "IBDEV %s could not create SMA: %s\n",
678 ibdev->name, strerror ( rc ) );
679 goto err_create_sma;
680 }
681
682 /* Create general services interface */
683 if ( ( rc = ib_create_mi ( ibdev, IB_QPT_GSI, &ibdev->gsi ) ) != 0 ) {
684 DBGC ( ibdev, "IBDEV %s could not create GSI: %s\n",
685 ibdev->name, strerror ( rc ) );
686 goto err_create_gsi;
687 }
688
689 /* Add to head of open devices list */
690 list_add ( &ibdev->open_list, &open_ib_devices );
691
692 /* Notify drivers of device state change */
693 ib_notify ( ibdev );
694
695 assert ( ibdev->open_count == 1 );
696 return 0;
697
698 ib_destroy_mi ( ibdev, ibdev->gsi );
699 err_create_gsi:
700 ib_destroy_sma ( ibdev, ibdev->smi );
701 err_create_sma:
702 ib_destroy_mi ( ibdev, ibdev->smi );
703 err_create_smi:
704 ibdev->op->close ( ibdev );
705 err_open:
706 assert ( ibdev->open_count == 1 );
707 ibdev->open_count = 0;
708 return rc;
709}
int ib_create_mi(struct ib_device *ibdev, enum ib_queue_pair_type type, struct ib_mad_interface **new_mi)
Create management interface.
Definition ib_mi.c:347
void ib_destroy_mi(struct ib_device *ibdev, struct ib_mad_interface *mi)
Destroy management interface.
Definition ib_mi.c:411
int ib_create_sma(struct ib_device *ibdev, struct ib_mad_interface *mi)
Create subnet management agent and interface.
Definition ib_sma.c:358
void ib_destroy_sma(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused)
Destroy subnet management agent and interface.
Definition ib_sma.c:372
static struct list_head open_ib_devices
List of open Infiniband devices, in reverse order of opening.
Definition infiniband.c:55
#define list_add(new, head)
Add a new entry to the head of a list.
Definition list.h:70
void(* close)(struct ib_device *ibdev)
Close port.
Definition infiniband.h:354
int(* open)(struct ib_device *ibdev)
Open port.
Definition infiniband.h:348
struct ib_mad_interface * gsi
General services interface.
Definition infiniband.h:462
struct ib_mad_interface * smi
Subnet management interface.
Definition infiniband.h:460
unsigned int open_count
Port open request counter.
Definition infiniband.h:423
struct list_head open_list
List of open Infiniband devices.
Definition infiniband.h:405

References assert, ib_device_operations::close, DBGC, ib_device::gsi, ib_create_mi(), ib_create_sma(), ib_destroy_mi(), ib_destroy_sma(), ib_notify(), IB_QPT_GSI, IB_QPT_SMI, list_add, ib_device::name, ib_device::op, ib_device_operations::open, ib_device::open_count, open_ib_devices, ib_device::open_list, rc, ib_device::smi, and strerror().

Referenced by eoib_open(), ib_cmrc_open(), ipoib_open(), and xsigo_ib_open().

◆ ib_close()

void ib_close ( struct ib_device * ibdev)

Close port.

Parameters
ibdevInfiniband device

Definition at line 716 of file infiniband.c.

716 {
717
718 /* Decrement device open request counter */
719 ibdev->open_count--;
720
721 /* Close device if this was the last remaining requested opening */
722 if ( ibdev->open_count == 0 ) {
723 ib_notify ( ibdev );
724 list_del ( &ibdev->open_list );
725 ib_destroy_mi ( ibdev, ibdev->gsi );
726 ib_destroy_sma ( ibdev, ibdev->smi );
727 ib_destroy_mi ( ibdev, ibdev->smi );
728 ibdev->op->close ( ibdev );
730 }
731}

References ib_device_operations::close, ib_device::gsi, ib_destroy_mi(), ib_destroy_sma(), ib_notify(), IB_PORT_STATE_DOWN, list_del, ib_device::op, ib_device::open_count, ib_device::open_list, ib_device::port_state, and ib_device::smi.

Referenced by eoib_close(), eoib_open(), ib_cmrc_open(), ib_cmrc_shutdown(), ipoib_close(), ipoib_open(), and xsigo_ib_remove().

◆ ib_mcast_attach()

int ib_mcast_attach ( struct ib_device * ibdev,
struct ib_queue_pair * qp,
union ib_gid * gid )

Attach to multicast group.

Parameters
ibdevInfiniband device
qpQueue pair
gidMulticast GID
Return values
rcReturn status code

Note that this function handles only the local device's attachment to the multicast GID; it does not issue the relevant MADs to join the multicast group on the subnet.

Definition at line 752 of file infiniband.c.

753 {
754 struct ib_multicast_gid *mgid;
755 int rc;
756
757 /* Sanity check */
758 assert ( qp != NULL );
759
760 /* Add to software multicast GID list */
761 mgid = zalloc ( sizeof ( *mgid ) );
762 if ( ! mgid ) {
763 rc = -ENOMEM;
764 goto err_alloc_mgid;
765 }
766 memcpy ( &mgid->gid, gid, sizeof ( mgid->gid ) );
767 list_add_tail ( &mgid->list, &qp->mgids );
768
769 /* Add to hardware multicast GID list */
770 if ( ( rc = ibdev->op->mcast_attach ( ibdev, qp, gid ) ) != 0 )
771 goto err_dev_mcast_attach;
772
773 return 0;
774
775 err_dev_mcast_attach:
776 list_del ( &mgid->list );
777 free ( mgid );
778 err_alloc_mgid:
779 return rc;
780}
int(* mcast_attach)(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Attach to multicast group.
Definition infiniband.h:362

References assert, ENOMEM, free, gid, list_add_tail, list_del, ib_device_operations::mcast_attach, memcpy(), mgid, NULL, ib_device::op, qp, rc, and zalloc().

Referenced by ib_mcast_join().

◆ ib_mcast_detach()

void ib_mcast_detach ( struct ib_device * ibdev,
struct ib_queue_pair * qp,
union ib_gid * gid )

Detach from multicast group.

Parameters
ibdevInfiniband device
qpQueue pair
gidMulticast GID

Definition at line 789 of file infiniband.c.

790 {
791 struct ib_multicast_gid *mgid;
792
793 /* Sanity check */
794 assert ( qp != NULL );
795
796 /* Remove from hardware multicast GID list */
797 ibdev->op->mcast_detach ( ibdev, qp, gid );
798
799 /* Remove from software multicast GID list */
800 list_for_each_entry ( mgid, &qp->mgids, list ) {
801 if ( memcmp ( &mgid->gid, gid, sizeof ( mgid->gid ) ) == 0 ) {
802 list_del ( &mgid->list );
803 free ( mgid );
804 break;
805 }
806 }
807}
void(* mcast_detach)(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Detach from multicast group.
Definition infiniband.h:371

References assert, free, gid, ib_multicast_gid::list, list_del, list_for_each_entry, ib_device_operations::mcast_detach, memcmp(), mgid, NULL, ib_device::op, and qp.

Referenced by ib_mcast_join(), and ib_mcast_leave().

◆ ib_set_port_info()

int ib_set_port_info ( struct ib_device * ibdev,
union ib_mad * mad )

Set port information.

Parameters
ibdevInfiniband device
madSet port information MAD

Definition at line 822 of file infiniband.c.

822 {
823 int rc;
824
825 /* Adapters with embedded SMAs do not need to support this method */
826 if ( ! ibdev->op->set_port_info ) {
827 DBGC ( ibdev, "IBDEV %s does not support setting port "
828 "information\n", ibdev->name );
829 return -ENOTSUP;
830 }
831
832 if ( ( rc = ibdev->op->set_port_info ( ibdev, mad ) ) != 0 ) {
833 DBGC ( ibdev, "IBDEV %s could not set port information: %s\n",
834 ibdev->name, strerror ( rc ) );
835 return rc;
836 }
837
838 return 0;
839};
union ib_mad mad
Definition arbel.h:1
#define ENOTSUP
Operation not supported.
Definition errno.h:590
int(* set_port_info)(struct ib_device *ibdev, union ib_mad *mad)
Set port information.
Definition infiniband.h:382

References DBGC, ENOTSUP, mad, ib_device::name, ib_device::op, rc, ib_device_operations::set_port_info, and strerror().

Referenced by ib_sma_set_port_info().

◆ ib_set_pkey_table()

int ib_set_pkey_table ( struct ib_device * ibdev,
union ib_mad * mad )

Set partition key table.

Parameters
ibdevInfiniband device
madSet partition key table MAD

Definition at line 847 of file infiniband.c.

847 {
848 int rc;
849
850 /* Adapters with embedded SMAs do not need to support this method */
851 if ( ! ibdev->op->set_pkey_table ) {
852 DBGC ( ibdev, "IBDEV %s does not support setting partition "
853 "key table\n", ibdev->name );
854 return -ENOTSUP;
855 }
856
857 if ( ( rc = ibdev->op->set_pkey_table ( ibdev, mad ) ) != 0 ) {
858 DBGC ( ibdev, "IBDEV %s could not set partition key table: "
859 "%s\n", ibdev->name, strerror ( rc ) );
860 return rc;
861 }
862
863 return 0;
864};
int(* set_pkey_table)(struct ib_device *ibdev, union ib_mad *mad)
Set partition key table.
Definition infiniband.h:391

References DBGC, ENOTSUP, mad, ib_device::name, ib_device::op, rc, ib_device_operations::set_pkey_table, and strerror().

Referenced by ib_sma_set_pkey_table().

◆ ib_poll_eq()

void ib_poll_eq ( struct ib_device * ibdev)

Poll event queue.

Parameters
ibdevInfiniband device

Definition at line 878 of file infiniband.c.

878 {
879 struct ib_completion_queue *cq;
880
881 /* Poll device's event queue */
882 ibdev->op->poll_eq ( ibdev );
883
884 /* Poll all completion queues */
886 ib_poll_cq ( ibdev, cq );
887}
void ib_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition infiniband.c:161
void(* poll_eq)(struct ib_device *ibdev)
Poll event queue.
Definition infiniband.h:341

References ib_device::cqs, ib_poll_cq(), ib_completion_queue::ibdev, ib_completion_queue::list, list_for_each_entry, ib_device::op, and ib_device_operations::poll_eq.

Referenced by eoib_poll(), flexboot_nodnic_eth_poll(), hermon_eth_poll(), ib_step(), and ipoib_poll().

◆ ib_step()

void ib_step ( struct process *process __unused)
static

Single-step the Infiniband event queue.

Parameters
processInfiniband event queue process

Definition at line 894 of file infiniband.c.

894 {
895 struct ib_device *ibdev;
896
898 ib_poll_eq ( ibdev );
899}
void ib_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition infiniband.c:878
An Infiniband device.
Definition infiniband.h:399

References __unused, ib_poll_eq(), list_for_each_entry, open_ib_devices, and ib_device::open_list.

Referenced by PERMANENT_PROCESS().

◆ PERMANENT_PROCESS()

PERMANENT_PROCESS ( ib_process ,
ib_step  )

Infiniband event queue process.

References ib_step().

◆ alloc_ibdev()

struct ib_device * alloc_ibdev ( size_t priv_size)

Allocate Infiniband device.

Parameters
priv_sizeSize of driver private data area
Return values
ibdevInfiniband device, or NULL

Definition at line 917 of file infiniband.c.

917 {
918 struct ib_device *ibdev;
919 void *drv_priv;
920 size_t total_len;
921
922 total_len = ( sizeof ( *ibdev ) + priv_size );
923 ibdev = zalloc ( total_len );
924 if ( ibdev ) {
925 drv_priv = ( ( ( void * ) ibdev ) + sizeof ( *ibdev ) );
926 ib_set_drvdata ( ibdev, drv_priv );
927 INIT_LIST_HEAD ( &ibdev->list );
928 INIT_LIST_HEAD ( &ibdev->open_list );
929 INIT_LIST_HEAD ( &ibdev->cqs );
930 INIT_LIST_HEAD ( &ibdev->qps );
932 ibdev->lid = IB_LID_NONE;
933 ibdev->pkey = IB_PKEY_DEFAULT;
934 }
935 return ibdev;
936}
#define IB_LID_NONE
Default Infiniband LID.
Definition ib_packet.h:84
#define IB_PKEY_DEFAULT
Default Infiniband partition key.
Definition infiniband.h:40
static __always_inline void ib_set_drvdata(struct ib_device *ibdev, void *priv)
Set Infiniband device driver-private data.
Definition infiniband.h:698
struct list_head list
List of Infiniband devices.
Definition infiniband.h:403
uint16_t pkey
Partition key.
Definition infiniband.h:450
void * drv_priv
Driver private data.
Definition infiniband.h:468
uint16_t lid
Port LID.
Definition infiniband.h:444

References ib_device::cqs, ib_device::drv_priv, IB_LID_NONE, IB_PKEY_DEFAULT, IB_PORT_STATE_DOWN, ib_set_drvdata(), INIT_LIST_HEAD, ib_device::lid, ib_device::list, ib_device::open_list, ib_device::pkey, ib_device::port_state, ib_device::qps, and zalloc().

Referenced by arbel_probe(), flexboot_nodnic_allocate_infiniband_devices(), golan_probe_normal(), hermon_probe(), linda_probe(), and qib7322_probe().

◆ register_ibdev()

int register_ibdev ( struct ib_device * ibdev)

Register Infiniband device.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 944 of file infiniband.c.

944 {
945 struct ib_driver *driver;
946 int rc;
947
948 /* Record device index and create device name */
949 if ( ibdev->name[0] == '\0' ) {
950 snprintf ( ibdev->name, sizeof ( ibdev->name ), "inf%d",
951 ibdev_index );
952 }
953 ibdev->index = ++ibdev_index;
954
955 /* Add to device list */
956 ibdev_get ( ibdev );
957 list_add_tail ( &ibdev->list, &ib_devices );
958 DBGC ( ibdev, "IBDEV %s registered (phys %s)\n", ibdev->name,
959 ibdev->dev->name );
960
961 /* Probe device */
962 for_each_table_entry ( driver, IB_DRIVERS ) {
963 if ( ( rc = driver->probe ( ibdev ) ) != 0 ) {
964 DBGC ( ibdev, "IBDEV %s could not add %s device: %s\n",
965 ibdev->name, driver->name, strerror ( rc ) );
966 goto err_probe;
967 }
968 }
969
970 return 0;
971
972 err_probe:
974 driver->remove ( ibdev );
975 list_del ( &ibdev->list );
976 ibdev_put ( ibdev );
977 return rc;
978}
static unsigned int ibdev_index
Infiniband device index.
Definition infiniband.c:58
struct list_head ib_devices
List of Infiniband devices.
Definition infiniband.c:52
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition infiniband.h:588
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition infiniband.h:599
char name[40]
Name.
Definition device.h:79
unsigned int index
Index of this Infiniband device.
Definition infiniband.h:407
struct device * dev
Underlying device.
Definition infiniband.h:411
const char * name
Name.
Definition infiniband.h:474
int(* probe)(struct ib_device *ibdev)
Probe device.
Definition infiniband.h:480
void(* remove)(struct ib_device *ibdev)
Remove device.
Definition infiniband.h:490
#define for_each_table_entry_continue_reverse(pointer, table)
Iterate through all remaining entries within a linker table in reverse order.
Definition tables.h:470
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition vsprintf.c:383

References DBGC, ib_device::dev, for_each_table_entry, for_each_table_entry_continue_reverse, ib_devices, IB_DRIVERS, ibdev_get(), ibdev_index, ibdev_put(), ib_device::index, ib_device::list, list_add_tail, list_del, device::name, ib_device::name, ib_driver::name, ib_driver::probe, rc, ib_driver::remove, snprintf(), and strerror().

Referenced by arbel_probe(), golan_register_ibdev(), hermon_register_ibdev(), linda_probe(), qib7322_probe(), and REQUIRING_SYMBOL().

◆ unregister_ibdev()

void unregister_ibdev ( struct ib_device * ibdev)

Unregister Infiniband device.

Parameters
ibdevInfiniband device

Definition at line 985 of file infiniband.c.

985 {
986 struct ib_driver *driver;
987
988 /* Remove device */
990 driver->remove ( ibdev );
991
992 /* Remove from device list */
993 list_del ( &ibdev->list );
994 ibdev_put ( ibdev );
995 DBGC ( ibdev, "IBDEV %s unregistered\n", ibdev->name );
996
997 /* Reset device index if no devices remain */
998 if ( list_empty ( &ib_devices ) )
999 ibdev_index = 0;
1000}
#define for_each_table_entry_reverse(pointer, table)
Iterate through all entries within a linker table in reverse order.
Definition tables.h:441

References DBGC, for_each_table_entry_reverse, ib_devices, IB_DRIVERS, ibdev_index, ibdev_put(), ib_device::list, list_del, list_empty, ib_device::name, and ib_driver::remove.

Referenced by arbel_probe(), arbel_remove(), golan_probe_normal(), golan_remove_normal(), hermon_unregister_ibdev(), linda_probe(), linda_remove(), qib7322_probe(), and qib7322_remove().

◆ find_ibdev()

struct ib_device * find_ibdev ( union ib_gid * gid)

Find Infiniband device by GID.

Parameters
gidGID
Return values
ibdevInfiniband device, or NULL

Definition at line 1008 of file infiniband.c.

1008 {
1009 struct ib_device *ibdev;
1010
1011 for_each_ibdev ( ibdev ) {
1012 if ( memcmp ( gid, &ibdev->gid, sizeof ( *gid ) ) == 0 )
1013 return ibdev;
1014 }
1015 return NULL;
1016}
#define for_each_ibdev(ibdev)
Iterate over all network devices.
Definition infiniband.h:556
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition infiniband.h:442

References for_each_ibdev, gid, ib_device::gid, memcmp(), and NULL.

Referenced by ib_srp_open_uri().

◆ last_opened_ibdev()

struct ib_device * last_opened_ibdev ( void )

Get most recently opened Infiniband device.

Return values
ibdevMost recently opened Infiniband device, or NULL

Definition at line 1023 of file infiniband.c.

1023 {
1024 struct ib_device *ibdev;
1025
1026 ibdev = list_first_entry ( &open_ib_devices, struct ib_device,
1027 open_list );
1028 if ( ! ibdev )
1029 return NULL;
1030
1031 assert ( ibdev->open_count != 0 );
1032 return ibdev;
1033}
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition list.h:334

References assert, list_first_entry, NULL, ib_device::open_count, open_ib_devices, and ib_device::open_list.

Referenced by ib_srp_parse_sgid().

◆ REQUIRING_SYMBOL()

REQUIRING_SYMBOL ( register_ibdev )

References register_ibdev().

◆ REQUIRE_OBJECT()

REQUIRE_OBJECT ( config_infiniband )

Variable Documentation

◆ ib_devices

struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices )

List of Infiniband devices.

Definition at line 52 of file infiniband.c.

Referenced by register_ibdev(), and unregister_ibdev().

◆ open_ib_devices

struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices )
static

List of open Infiniband devices, in reverse order of opening.

Definition at line 55 of file infiniband.c.

Referenced by ib_open(), ib_step(), and last_opened_ibdev().

◆ ibdev_index

unsigned int ibdev_index = 0
static

Infiniband device index.

Definition at line 58 of file infiniband.c.

Referenced by register_ibdev(), and unregister_ibdev().

◆ __profiler

struct profiler ib_post_recv_profiler __profiler
static
Initial value:
=
{ .name = "ib.post_send" }

Post send work queue entry profiler.

Post receive work queue entry profiler.

Definition at line 61 of file infiniband.c.

62 { .name = "ib.post_send" };

◆ __errortab

struct errortab infiniband_errors [] __errortab
Initial value:
= {
}
#define __einfo_errortab(einfo)
Definition errortab.h:24
#define EINFO_EINPROGRESS_INIT
Definition infiniband.c:70
#define EINFO_EINPROGRESS_ARMED
Definition infiniband.c:73

Human-readable message for the link statuses.

Definition at line 77 of file infiniband.c.