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

Variables

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

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.

◆ EINFO_EINPROGRESS_INIT

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

Definition at line 70 of file infiniband.c.

◆ EINPROGRESS_ARMED

#define EINPROGRESS_ARMED   __einfo_error ( EINFO_EINPROGRESS_ARMED )

Definition at line 72 of file infiniband.c.

◆ EINFO_EINPROGRESS_ARMED

#define EINFO_EINPROGRESS_ARMED
Value:
( EINFO_EINPROGRESS, 0x02, "Armed" )
#define EINFO_EINPROGRESS
Definition: errno.h:419
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:180

Definition at line 73 of file infiniband.c.

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;
115  INIT_LIST_HEAD ( &cq->work_queues );
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:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
struct ib_completion_queue_operations * op
Completion queue operations.
Definition: infiniband.h:244
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
An Infiniband Completion Queue.
Definition: infiniband.h:224
void(* destroy_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: infiniband.h:268
struct list_head cqs
List of completion queues.
Definition: infiniband.h:412
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct list_head list
List of completion queues on this Infiniband device.
Definition: infiniband.h:228
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226
int(* create_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Create completion queue.
Definition: infiniband.h:261

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, op, ib_device::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 }
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void(* destroy_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: infiniband.h:268
struct list_head list
List of completion queues on this Infiniband device.
Definition: infiniband.h:228
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

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
struct ib_completion_queue * cq
Associated completion queue.
Definition: infiniband.h:106
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
An Infiniband Work Queue.
Definition: infiniband.h:100
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
struct list_head list
List of work queues on this completion queue.
Definition: infiniband.h:108
int is_send
"Is a send queue" flag
Definition: infiniband.h:104
void(* poll_cq)(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition: infiniband.h:333

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_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
#define IB_QPN_SMI
Subnet management interface QPN.
Definition: infiniband.h:21
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
uint8_t type
Type.
Definition: ena.h:16
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
#define IB_QPN_GSI
General service interface QPN.
Definition: infiniband.h:27
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
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition: random.c:30
int(* create_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create queue pair.
Definition: infiniband.h:276
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:159
An Infiniband Queue Pair.
Definition: infiniband.h:157
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
void(* destroy_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.h:291
struct list_head qps
List of queue pairs.
Definition: infiniband.h:414

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, op, ib_device::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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
int(* modify_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition: infiniband.h:284
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:159
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

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 }
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
#define ECANCELED
Operation canceled.
Definition: errno.h:343
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
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
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
void(* destroy_qp)(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.h:291
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
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A persistent I/O buffer.
Definition: iobuf.h:32

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:29
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head list
List of queue pairs on this Infiniband device.
Definition: infiniband.h:161
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:159
An Infiniband Queue Pair.
Definition: infiniband.h:157
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct list_head qps
List of queue pairs.
Definition: infiniband.h:414
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 }
union ib_gid mgid
Definition: ib_mad.h:11
struct list_head list
List of multicast GIDs on this QP.
Definition: infiniband.h:132
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
An Infiniband Queue Pair.
Definition: infiniband.h:157
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct list_head qps
List of queue pairs.
Definition: infiniband.h:414
An Infiniband multicast GID.
Definition: infiniband.h:130
u8 gid[16]
Definition: CIB_PRM.h:31
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 }
__be32 qpn
Definition: CIB_PRM.h:29
struct ib_completion_queue * cq
Associated completion queue.
Definition: infiniband.h:106
An Infiniband Work Queue.
Definition: infiniband.h:100
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
unsigned long qpn
Queue pair number.
Definition: infiniband.h:165
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
struct list_head list
List of work queues on this completion queue.
Definition: infiniband.h:108
int is_send
"Is a send queue" flag
Definition: infiniband.h:104
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References ib_work_queue::cq, ib_work_queue::is_send, ib_work_queue::list, list_for_each_entry, NULL, ib_work_queue::qp, qpn, ib_queue_pair::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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
static void * dest
Definition: strings.h:176
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
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:306
An Infiniband Address Vector.
Definition: infiniband.h:72

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:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
int(* post_recv)(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
Post receive work queue entry.
Definition: infiniband.h:322
#define DBGC(...)
Definition: compiler.h:505
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:171
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define IB_MAX_PAYLOAD_SIZE
Maximum payload size.
Definition: infiniband.h:50

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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
static void * dest
Definition: strings.h:176
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define DBGC(...)
Definition: compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
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
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define IB_MAX_PAYLOAD_SIZE
Maximum payload size.
Definition: infiniband.h:50
A persistent I/O buffer.
Definition: iobuf.h:32

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;
597  case IB_PORT_STATE_INIT: return -EINPROGRESS_INIT;
599  case IB_PORT_STATE_ACTIVE: return 0;
600  default: return -EINVAL;
601  }
602 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define IB_PORT_STATE_INIT
Definition: ib_mad.h:152
#define IB_PORT_STATE_ARMED
Definition: ib_mad.h:153
#define EINPROGRESS_INIT
Definition: infiniband.c:69
#define EINPROGRESS_ARMED
Definition: infiniband.c:72
#define ENOTCONN
The socket is not connected.
Definition: errno.h:569
#define IB_PORT_STATE_DOWN
Definition: ib_mad.h:151
#define IB_PORT_STATE_ACTIVE
Definition: ib_mad.h:154
uint8_t port_state
Port state.
Definition: infiniband.h:423

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

static 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 }
#define IB_PORT_STATE_INIT
Definition: ib_mad.h:152
#define IB_PORT_STATE_ARMED
Definition: ib_mad.h:153
#define IB_PORT_STATE_DOWN
Definition: ib_mad.h:151
#define IB_PORT_STATE_ACTIVE
Definition: ib_mad.h:154
uint8_t port_state
Port state.
Definition: infiniband.h:423

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

static 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 
628  for_each_table_entry ( driver, IB_DRIVERS )
629  driver->notify ( ibdev );
630 }
void(* notify)(struct ib_device *ibdev)
Notify of device or link state change.
Definition: infiniband.h:482
An Infiniband upper-layer driver.
Definition: infiniband.h:469
#define IB_DRIVERS
Infiniband driver table.
Definition: infiniband.h:491
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358

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 void ib_notify(struct ib_device *ibdev)
Notify drivers of Infiniband device or link state change.
Definition: infiniband.c:625
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
static const char * ib_link_state_text(struct ib_device *ibdev)
Textual representation of Infiniband link state.
Definition: infiniband.c:610

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 }
static void ib_notify(struct ib_device *ibdev)
Notify drivers of Infiniband device or link state change.
Definition: infiniband.c:625
struct ib_mad_interface * smi
Subnet management interface.
Definition: infiniband.h:457
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
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void ib_destroy_mi(struct ib_device *ibdev, struct ib_mad_interface *mi)
Destroy management interface.
Definition: ib_mi.c:411
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
int(* open)(struct ib_device *ibdev)
Open port.
Definition: infiniband.h:347
unsigned int open_count
Port open request counter.
Definition: infiniband.h:420
#define DBGC(...)
Definition: compiler.h:505
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:459
int ib_create_sma(struct ib_device *ibdev, struct ib_mad_interface *mi)
Create subnet management agent and interface.
Definition: ib_sma.c:358
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
static struct list_head open_ib_devices
List of open Infiniband devices, in reverse order of opening.
Definition: infiniband.c:55
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
void(* close)(struct ib_device *ibdev)
Close port.
Definition: infiniband.h:353
struct list_head open_list
List of open Infiniband devices.
Definition: infiniband.h:404
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

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 }
static void ib_notify(struct ib_device *ibdev)
Notify drivers of Infiniband device or link state change.
Definition: infiniband.c:625
struct ib_mad_interface * smi
Subnet management interface.
Definition: infiniband.h:457
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
void ib_destroy_mi(struct ib_device *ibdev, struct ib_mad_interface *mi)
Destroy management interface.
Definition: ib_mi.c:411
unsigned int open_count
Port open request counter.
Definition: infiniband.h:420
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:459
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
#define IB_PORT_STATE_DOWN
Definition: ib_mad.h:151
uint8_t port_state
Port state.
Definition: infiniband.h:423
void(* close)(struct ib_device *ibdev)
Close port.
Definition: infiniband.h:353
struct list_head open_list
List of open Infiniband devices.
Definition: infiniband.h:404

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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_gid mgid
Definition: ib_mad.h:11
int(* mcast_attach)(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Attach to multicast group.
Definition: infiniband.h:361
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#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)
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
An Infiniband multicast GID.
Definition: infiniband.h:130
u8 gid[16]
Definition: CIB_PRM.h:31
#define NULL
NULL pointer (VOID *)
Definition: Base.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 }
union ib_gid mgid
Definition: ib_mad.h:11
void(* mcast_detach)(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Detach from multicast group.
Definition: infiniband.h:370
struct list_head list
List of multicast GIDs on this QP.
Definition: infiniband.h:132
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
An Infiniband multicast GID.
Definition: infiniband.h:130
u8 gid[16]
Definition: CIB_PRM.h:31
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

int ib_count_ports ( struct ib_device ibdev)

Count Infiniband HCA ports.

Parameters
ibdevInfiniband device
Return values
num_portsNumber of ports

Definition at line 822 of file infiniband.c.

822  {
823  struct ib_device *tmp;
824  int num_ports = 0;
825 
826  /* Search for IB devices with the same physical device to
827  * identify port count.
828  */
829  for_each_ibdev ( tmp ) {
830  if ( tmp->dev == ibdev->dev )
831  num_ports++;
832  }
833  return num_ports;
834 }
struct device * dev
Underlying device.
Definition: infiniband.h:410
An Infiniband device.
Definition: infiniband.h:398
u8 num_ports
Definition: CIB_PRM.h:61
uint8_t * tmp
Definition: entropy.h:156
#define for_each_ibdev(ibdev)
Iterate over all network devices.
Definition: infiniband.h:554

References ib_device::dev, for_each_ibdev, num_ports, and tmp.

Referenced by ib_sma_node_info().

◆ 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 842 of file infiniband.c.

842  {
843  int rc;
844 
845  /* Adapters with embedded SMAs do not need to support this method */
846  if ( ! ibdev->op->set_port_info ) {
847  DBGC ( ibdev, "IBDEV %s does not support setting port "
848  "information\n", ibdev->name );
849  return -ENOTSUP;
850  }
851 
852  if ( ( rc = ibdev->op->set_port_info ( ibdev, mad ) ) != 0 ) {
853  DBGC ( ibdev, "IBDEV %s could not set port information: %s\n",
854  ibdev->name, strerror ( rc ) );
855  return rc;
856  }
857 
858  return 0;
859 };
int(* set_port_info)(struct ib_device *ibdev, union ib_mad *mad)
Set port information.
Definition: infiniband.h:381
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
union ib_mad mad
Definition: arbel.h:12

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 867 of file infiniband.c.

867  {
868  int rc;
869 
870  /* Adapters with embedded SMAs do not need to support this method */
871  if ( ! ibdev->op->set_pkey_table ) {
872  DBGC ( ibdev, "IBDEV %s does not support setting partition "
873  "key table\n", ibdev->name );
874  return -ENOTSUP;
875  }
876 
877  if ( ( rc = ibdev->op->set_pkey_table ( ibdev, mad ) ) != 0 ) {
878  DBGC ( ibdev, "IBDEV %s could not set partition key table: "
879  "%s\n", ibdev->name, strerror ( rc ) );
880  return rc;
881  }
882 
883  return 0;
884 };
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int(* set_pkey_table)(struct ib_device *ibdev, union ib_mad *mad)
Set partition key table.
Definition: infiniband.h:390
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
union ib_mad mad
Definition: arbel.h:12

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 898 of file infiniband.c.

898  {
899  struct ib_completion_queue *cq;
900 
901  /* Poll device's event queue */
902  ibdev->op->poll_eq ( ibdev );
903 
904  /* Poll all completion queues */
905  list_for_each_entry ( cq, &ibdev->cqs, list )
906  ib_poll_cq ( ibdev, cq );
907 }
void(* poll_eq)(struct ib_device *ibdev)
Poll event queue.
Definition: infiniband.h:340
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
An Infiniband Completion Queue.
Definition: infiniband.h:224
struct list_head cqs
List of completion queues.
Definition: infiniband.h:412
struct list_head list
List of completion queues on this Infiniband device.
Definition: infiniband.h:228
void ib_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition: infiniband.c:161
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

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

static void ib_step ( struct process *process  __unused)
static

Single-step the Infiniband event queue.

Parameters
processInfiniband event queue process

Definition at line 914 of file infiniband.c.

914  {
915  struct ib_device *ibdev;
916 
918  ib_poll_eq ( ibdev );
919 }
void ib_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition: infiniband.c:898
An Infiniband device.
Definition: infiniband.h:398
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
static struct list_head open_ib_devices
List of open Infiniband devices, in reverse order of opening.
Definition: infiniband.c:55
struct list_head open_list
List of open Infiniband devices.
Definition: infiniband.h:404

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

◆ PERMANENT_PROCESS()

PERMANENT_PROCESS ( ib_process  ,
ib_step   
)

Infiniband event queue process.

◆ 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 937 of file infiniband.c.

937  {
938  struct ib_device *ibdev;
939  void *drv_priv;
940  size_t total_len;
941 
942  total_len = ( sizeof ( *ibdev ) + priv_size );
943  ibdev = zalloc ( total_len );
944  if ( ibdev ) {
945  drv_priv = ( ( ( void * ) ibdev ) + sizeof ( *ibdev ) );
946  ib_set_drvdata ( ibdev, drv_priv );
947  INIT_LIST_HEAD ( &ibdev->list );
948  INIT_LIST_HEAD ( &ibdev->open_list );
949  INIT_LIST_HEAD ( &ibdev->cqs );
950  INIT_LIST_HEAD ( &ibdev->qps );
952  ibdev->lid = IB_LID_NONE;
953  ibdev->pkey = IB_PKEY_DEFAULT;
954  }
955  return ibdev;
956 }
static __always_inline void ib_set_drvdata(struct ib_device *ibdev, void *priv)
Set Infiniband device driver-private data.
Definition: infiniband.h:696
uint16_t lid
Port LID.
Definition: infiniband.h:441
void * drv_priv
Driver private data.
Definition: infiniband.h:465
#define IB_PKEY_DEFAULT
Default Infiniband partition key.
Definition: infiniband.h:39
An Infiniband device.
Definition: infiniband.h:398
struct list_head list
List of Infiniband devices.
Definition: infiniband.h:402
#define IB_LID_NONE
Default Infiniband LID.
Definition: ib_packet.h:83
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define IB_PORT_STATE_DOWN
Definition: ib_mad.h:151
struct list_head cqs
List of completion queues.
Definition: infiniband.h:412
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
uint8_t port_state
Port state.
Definition: infiniband.h:423
struct list_head qps
List of queue pairs.
Definition: infiniband.h:414
struct list_head open_list
List of open Infiniband devices.
Definition: infiniband.h:404
uint16_t pkey
Partition key.
Definition: infiniband.h:447

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 964 of file infiniband.c.

964  {
965  struct ib_driver *driver;
966  int rc;
967 
968  /* Record device index and create device name */
969  if ( ibdev->name[0] == '\0' ) {
970  snprintf ( ibdev->name, sizeof ( ibdev->name ), "inf%d",
971  ibdev_index );
972  }
973  ibdev->index = ++ibdev_index;
974 
975  /* Add to device list */
976  ibdev_get ( ibdev );
977  list_add_tail ( &ibdev->list, &ib_devices );
978  DBGC ( ibdev, "IBDEV %s registered (phys %s)\n", ibdev->name,
979  ibdev->dev->name );
980 
981  /* Probe device */
982  for_each_table_entry ( driver, IB_DRIVERS ) {
983  if ( ( rc = driver->probe ( ibdev ) ) != 0 ) {
984  DBGC ( ibdev, "IBDEV %s could not add %s device: %s\n",
985  ibdev->name, driver->name, strerror ( rc ) );
986  goto err_probe;
987  }
988  }
989 
990  return 0;
991 
992  err_probe:
994  driver->remove ( ibdev );
995  list_del ( &ibdev->list );
996  ibdev_put ( ibdev );
997  return rc;
998 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int(* probe)(struct ib_device *ibdev)
Probe device.
Definition: infiniband.h:477
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:75
struct device * dev
Underlying device.
Definition: infiniband.h:410
An Infiniband upper-layer driver.
Definition: infiniband.h:469
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition: infiniband.h:586
unsigned int index
Index of this Infiniband device.
Definition: infiniband.h:406
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
#define IB_DRIVERS
Infiniband driver table.
Definition: infiniband.h:491
struct list_head list
List of Infiniband devices.
Definition: infiniband.h:402
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:597
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
struct list_head ib_devices
List of Infiniband devices.
Definition: infiniband.c:52
static unsigned int ibdev_index
Infiniband device index.
Definition: infiniband.c:58
void(* remove)(struct ib_device *ibdev)
Remove device.
Definition: infiniband.h:487
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
const char * name
Name.
Definition: infiniband.h:471
#define for_each_table_entry_continue_reverse(pointer, table)
Iterate through all remaining entries within a linker table in reverse order.
Definition: tables.h:442

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

◆ unregister_ibdev()

void unregister_ibdev ( struct ib_device ibdev)

Unregister Infiniband device.

Parameters
ibdevInfiniband device

Definition at line 1005 of file infiniband.c.

1005  {
1006  struct ib_driver *driver;
1007 
1008  /* Remove device */
1010  driver->remove ( ibdev );
1011 
1012  /* Remove from device list */
1013  list_del ( &ibdev->list );
1014  ibdev_put ( ibdev );
1015  DBGC ( ibdev, "IBDEV %s unregistered\n", ibdev->name );
1016 
1017  /* Reset device index if no devices remain */
1018  if ( list_empty ( &ib_devices ) )
1019  ibdev_index = 0;
1020 }
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
#define DBGC(...)
Definition: compiler.h:505
An Infiniband upper-layer driver.
Definition: infiniband.h:469
#define for_each_table_entry_reverse(pointer, table)
Iterate through all entries within a linker table in reverse order.
Definition: tables.h:413
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define IB_DRIVERS
Infiniband driver table.
Definition: infiniband.h:491
struct list_head list
List of Infiniband devices.
Definition: infiniband.h:402
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:597
struct list_head ib_devices
List of Infiniband devices.
Definition: infiniband.c:52
static unsigned int ibdev_index
Infiniband device index.
Definition: infiniband.c:58
void(* remove)(struct ib_device *ibdev)
Remove device.
Definition: infiniband.h:487

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 1028 of file infiniband.c.

1028  {
1029  struct ib_device *ibdev;
1030 
1031  for_each_ibdev ( ibdev ) {
1032  if ( memcmp ( gid, &ibdev->gid, sizeof ( *gid ) ) == 0 )
1033  return ibdev;
1034  }
1035  return NULL;
1036 }
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:439
An Infiniband device.
Definition: infiniband.h:398
u8 gid[16]
Definition: CIB_PRM.h:31
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define for_each_ibdev(ibdev)
Iterate over all network devices.
Definition: infiniband.h:554

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 1043 of file infiniband.c.

1043  {
1044  struct ib_device *ibdev;
1045 
1046  ibdev = list_first_entry ( &open_ib_devices, struct ib_device,
1047  open_list );
1048  if ( ! ibdev )
1049  return NULL;
1050 
1051  assert ( ibdev->open_count != 0 );
1052  return ibdev;
1053 }
unsigned int open_count
Port open request counter.
Definition: infiniband.h:420
An Infiniband device.
Definition: infiniband.h:398
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct list_head open_ib_devices
List of open Infiniband devices, in reverse order of opening.
Definition: infiniband.c:55
struct list_head open_list
List of open Infiniband devices.
Definition: infiniband.h:404
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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  )

◆ 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.

◆ __errortab

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

Human-readable message for the link statuses.

Definition at line 77 of file infiniband.c.