iPXE
Data Structures | Macros | Enumerations | Functions | Variables
infiniband.h File Reference

Infiniband protocol. More...

#include <stdint.h>
#include <ipxe/refcnt.h>
#include <ipxe/device.h>
#include <ipxe/tables.h>
#include <ipxe/ib_packet.h>
#include <ipxe/ib_mad.h>
#include <ipxe/if_ether.h>

Go to the source code of this file.

Data Structures

struct  ib_address_vector
 An Infiniband Address Vector. More...
 
struct  ib_work_queue
 An Infiniband Work Queue. More...
 
struct  ib_multicast_gid
 An Infiniband multicast GID. More...
 
struct  ib_queue_pair_operations
 Infiniband queue pair operations. More...
 
struct  ib_queue_pair
 An Infiniband Queue Pair. More...
 
struct  ib_completion_queue_operations
 Infiniband completion queue operations. More...
 
struct  ib_completion_queue
 An Infiniband Completion Queue. More...
 
struct  ib_device_operations
 Infiniband device operations. More...
 
struct  ib_device
 An Infiniband device. More...
 
struct  ib_driver
 An Infiniband upper-layer driver. More...
 

Macros

#define IB_QPN_SMI   0
 Subnet management interface QPN. More...
 
#define IB_QKEY_SMI   0
 Subnet management interface queue key. More...
 
#define IB_QPN_GSI   1
 General service interface QPN. More...
 
#define IB_QKEY_GSI   0x80010000UL
 General service interface queue key. More...
 
#define IB_QPN_BROADCAST   0xffffffUL
 Broadcast QPN. More...
 
#define IB_QPN_MASK   0xffffffUL
 QPN mask. More...
 
#define IB_PKEY_DEFAULT   0xffff
 Default Infiniband partition key. More...
 
#define IB_PKEY_FULL   0x8000
 Infiniband partition key full membership flag. More...
 
#define IB_MAX_PAYLOAD_SIZE   2048
 Maximum payload size. More...
 
#define IBDEV_NAME_LEN   8
 Maximum length of an Infiniband device name. More...
 
#define IB_DRIVERS   __table ( struct ib_driver, "ib_drivers" )
 Infiniband driver table. More...
 
#define __ib_driver   __table_entry ( IB_DRIVERS, 01 )
 Declare an Infiniband driver. More...
 
#define for_each_ibdev(ibdev)   list_for_each_entry ( (ibdev), &ib_devices, list )
 Iterate over all network devices. More...
 

Enumerations

enum  ib_rate {
  IB_RATE_2_5 = 2, IB_RATE_10 = 3, IB_RATE_30 = 4, IB_RATE_5 = 5,
  IB_RATE_20 = 6, IB_RATE_40 = 7, IB_RATE_60 = 8, IB_RATE_80 = 9,
  IB_RATE_120 = 10
}
 Infiniband transmission rates. More...
 
enum  ib_queue_pair_type {
  IB_QPT_SMI, IB_QPT_GSI, IB_QPT_UD, IB_QPT_RC,
  IB_QPT_ETH
}
 An Infiniband queue pair type. More...
 

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_open (struct ib_device *ibdev)
 Open port. More...
 
void ib_close (struct ib_device *ibdev)
 Close port. More...
 
int ib_link_rc (struct ib_device *ibdev)
 Get link state. 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_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...
 
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...
 
void ib_link_state_changed (struct ib_device *ibdev)
 Notify of Infiniband link state change. More...
 
void ib_poll_eq (struct ib_device *ibdev)
 Poll event queue. More...
 
static __always_inline int ib_link_ok (struct ib_device *ibdev)
 Check link state of Infiniband device. More...
 
static int ib_is_open (struct ib_device *ibdev)
 Check whether or not Infiniband device is open. More...
 
static __always_inline struct ib_deviceibdev_get (struct ib_device *ibdev)
 Get reference to Infiniband device. More...
 
static __always_inline void ibdev_put (struct ib_device *ibdev)
 Drop reference to Infiniband device. More...
 
static __always_inline void ib_wq_set_drvdata (struct ib_work_queue *wq, void *priv)
 Set Infiniband work queue driver-private data. More...
 
static __always_inline void * ib_wq_get_drvdata (struct ib_work_queue *wq)
 Get Infiniband work queue driver-private data. More...
 
static __always_inline void ib_qp_set_drvdata (struct ib_queue_pair *qp, void *priv)
 Set Infiniband queue pair driver-private data. More...
 
static __always_inline void * ib_qp_get_drvdata (struct ib_queue_pair *qp)
 Get Infiniband queue pair driver-private data. More...
 
static __always_inline void ib_qp_set_ownerdata (struct ib_queue_pair *qp, void *priv)
 Set Infiniband queue pair owner-private data. More...
 
static __always_inline void * ib_qp_get_ownerdata (struct ib_queue_pair *qp)
 Get Infiniband queue pair owner-private data. More...
 
static __always_inline void ib_cq_set_drvdata (struct ib_completion_queue *cq, void *priv)
 Set Infiniband completion queue driver-private data. More...
 
static __always_inline void * ib_cq_get_drvdata (struct ib_completion_queue *cq)
 Get Infiniband completion queue driver-private data. More...
 
static __always_inline void ib_set_drvdata (struct ib_device *ibdev, void *priv)
 Set Infiniband device driver-private data. More...
 
static __always_inline void * ib_get_drvdata (struct ib_device *ibdev)
 Get Infiniband device driver-private data. More...
 

Variables

struct list_head ib_devices
 List of Infiniband devices. More...
 

Detailed Description

Infiniband protocol.

Definition in file infiniband.h.

Macro Definition Documentation

◆ IB_QPN_SMI

#define IB_QPN_SMI   0

Subnet management interface QPN.

Definition at line 21 of file infiniband.h.

◆ IB_QKEY_SMI

#define IB_QKEY_SMI   0

Subnet management interface queue key.

Definition at line 24 of file infiniband.h.

◆ IB_QPN_GSI

#define IB_QPN_GSI   1

General service interface QPN.

Definition at line 27 of file infiniband.h.

◆ IB_QKEY_GSI

#define IB_QKEY_GSI   0x80010000UL

General service interface queue key.

Definition at line 30 of file infiniband.h.

◆ IB_QPN_BROADCAST

#define IB_QPN_BROADCAST   0xffffffUL

Broadcast QPN.

Definition at line 33 of file infiniband.h.

◆ IB_QPN_MASK

#define IB_QPN_MASK   0xffffffUL

QPN mask.

Definition at line 36 of file infiniband.h.

◆ IB_PKEY_DEFAULT

#define IB_PKEY_DEFAULT   0xffff

Default Infiniband partition key.

Definition at line 39 of file infiniband.h.

◆ IB_PKEY_FULL

#define IB_PKEY_FULL   0x8000

Infiniband partition key full membership flag.

Definition at line 42 of file infiniband.h.

◆ IB_MAX_PAYLOAD_SIZE

#define IB_MAX_PAYLOAD_SIZE   2048

Maximum payload size.

This is currently hard-coded in various places (drivers, subnet management agent, etc.) to 2048.

Definition at line 50 of file infiniband.h.

◆ IBDEV_NAME_LEN

#define IBDEV_NAME_LEN   8

Maximum length of an Infiniband device name.

Definition at line 395 of file infiniband.h.

◆ IB_DRIVERS

#define IB_DRIVERS   __table ( struct ib_driver, "ib_drivers" )

Infiniband driver table.

Definition at line 493 of file infiniband.h.

◆ __ib_driver

#define __ib_driver   __table_entry ( IB_DRIVERS, 01 )

Declare an Infiniband driver.

Definition at line 496 of file infiniband.h.

◆ for_each_ibdev

#define for_each_ibdev (   ibdev)    list_for_each_entry ( (ibdev), &ib_devices, list )

Iterate over all network devices.

Definition at line 555 of file infiniband.h.

Enumeration Type Documentation

◆ ib_rate

enum ib_rate

Infiniband transmission rates.

Enumerator
IB_RATE_2_5 
IB_RATE_10 
IB_RATE_30 
IB_RATE_5 
IB_RATE_20 
IB_RATE_40 
IB_RATE_60 
IB_RATE_80 
IB_RATE_120 

Definition at line 59 of file infiniband.h.

59  {
60  IB_RATE_2_5 = 2,
61  IB_RATE_10 = 3,
62  IB_RATE_30 = 4,
63  IB_RATE_5 = 5,
64  IB_RATE_20 = 6,
65  IB_RATE_40 = 7,
66  IB_RATE_60 = 8,
67  IB_RATE_80 = 9,
68  IB_RATE_120 = 10,
69 };

◆ ib_queue_pair_type

An Infiniband queue pair type.

Enumerator
IB_QPT_SMI 
IB_QPT_GSI 
IB_QPT_UD 
IB_QPT_RC 
IB_QPT_ETH 

Definition at line 138 of file infiniband.h.

138  {
139  IB_QPT_SMI,
140  IB_QPT_GSI,
141  IB_QPT_UD,
142  IB_QPT_RC,
143  IB_QPT_ETH,
144 };

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:686
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:431
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
#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:642
#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:31
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
uint32_t type
Operating system type.
Definition: ena.h:12
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:321
A persistent I/O buffer.
Definition: iobuf.h:33

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:431
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:321

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:431
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:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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:431
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:321

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:175
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:146
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:146
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:146
#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:33

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_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:459
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:422
#define DBGC(...)
Definition: compiler.h:505
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
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:459
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:422
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
#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:425
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_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:425

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_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:321

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:431
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:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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

◆ 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 }
static __always_inline void ib_set_drvdata(struct ib_device *ibdev, void *priv)
Set Infiniband device driver-private data.
Definition: infiniband.h:697
uint16_t lid
Port LID.
Definition: infiniband.h:443
void * drv_priv
Driver private data.
Definition: infiniband.h:467
#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:425
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:449

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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int(* probe)(struct ib_device *ibdev)
Probe device.
Definition: infiniband.h:479
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:471
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition: infiniband.h:587
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:493
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:598
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:385
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:489
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:473
#define for_each_table_entry_continue_reverse(pointer, table)
Iterate through all remaining entries within a linker table in reverse order.
Definition: tables.h:469

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 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 }
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:471
#define for_each_table_entry_reverse(pointer, table)
Iterate through all entries within a linker table in reverse order.
Definition: tables.h:440
#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:493
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:598
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:489

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 }
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
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:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define for_each_ibdev(ibdev)
Iterate over all network devices.
Definition: infiniband.h:555

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 }
unsigned int open_count
Port open request counter.
Definition: infiniband.h:422
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:321

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

Referenced by ib_srp_parse_sgid().

◆ 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_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 */
885  list_for_each_entry ( cq, &ibdev->cqs, list )
886  ib_poll_cq ( ibdev, cq );
887 }
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:431
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_link_ok()

static __always_inline int ib_link_ok ( struct ib_device ibdev)
inlinestatic

Check link state of Infiniband device.

Parameters
ibdevInfiniband device
Return values
link_upLink is up

Definition at line 565 of file infiniband.h.

565  {
566  return ( ibdev->port_state == IB_PORT_STATE_ACTIVE );
567 }
#define IB_PORT_STATE_ACTIVE
Definition: ib_mad.h:154
uint8_t port_state
Port state.
Definition: infiniband.h:425
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

References IB_PORT_STATE_ACTIVE, and ib_device::port_state.

Referenced by eoib_link_state_changed(), ibstat(), ipoib_link_state_changed(), ipoib_transmit(), xsigo_ib_notify(), and xsigo_ib_open().

◆ ib_is_open()

static int ib_is_open ( struct ib_device ibdev)
inlinestatic

Check whether or not Infiniband device is open.

Parameters
ibdevInfiniband device
is_openInfiniband device is open

Definition at line 576 of file infiniband.h.

576  {
577  return ( ibdev->open_count > 0 );
578 }
unsigned int open_count
Port open request counter.
Definition: infiniband.h:422
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

References ib_device::open_count.

Referenced by arbel_poll_eq(), eoib_link_state_changed(), golan_handle_port_event(), hermon_poll_eq(), ibstat(), and ipoib_link_state_changed().

◆ ibdev_get()

static __always_inline struct ib_device* ibdev_get ( struct ib_device ibdev)
inlinestatic

Get reference to Infiniband device.

Parameters
ibdevInfiniband device
Return values
ibdevInfiniband device

Definition at line 587 of file infiniband.h.

587  {
588  ref_get ( &ibdev->refcnt );
589  return ibdev;
590 }
struct refcnt refcnt
Reference counter.
Definition: infiniband.h:400
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

References ref_get, and ib_device::refcnt.

Referenced by eoib_create(), ib_srp_open(), register_ibdev(), and xsigo_ib_probe().

◆ ibdev_put()

static __always_inline void ibdev_put ( struct ib_device ibdev)
inlinestatic

Drop reference to Infiniband device.

Parameters
ibdevInfiniband device

Definition at line 598 of file infiniband.h.

598  {
599  ref_put ( &ibdev->refcnt );
600 }
struct refcnt refcnt
Reference counter.
Definition: infiniband.h:400
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put, and ib_device::refcnt.

Referenced by arbel_probe(), arbel_remove(), eoib_create(), eoib_destroy(), flexboot_nodnic_allocate_infiniband_devices(), flexboot_nodnic_ports_unregister_dev(), golan_probe_normal(), golan_remove_normal(), hermon_probe(), hermon_remove(), ib_srp_free(), linda_probe(), linda_remove(), qib7322_probe(), qib7322_remove(), register_ibdev(), unregister_ibdev(), and xsigo_free().

◆ ib_wq_set_drvdata()

static __always_inline void ib_wq_set_drvdata ( struct ib_work_queue wq,
void *  priv 
)
inlinestatic

Set Infiniband work queue driver-private data.

Parameters
wqWork queue
privPrivate data

Definition at line 609 of file infiniband.h.

609  {
610  wq->drv_priv = priv;
611 }
static struct tlan_private * priv
Definition: tlan.c:224
void * drv_priv
Driver private data.
Definition: infiniband.h:126

References ib_work_queue::drv_priv, and priv.

Referenced by linda_create_qp(), and qib7322_create_qp().

◆ ib_wq_get_drvdata()

static __always_inline void* ib_wq_get_drvdata ( struct ib_work_queue wq)
inlinestatic

◆ ib_qp_set_drvdata()

static __always_inline void ib_qp_set_drvdata ( struct ib_queue_pair qp,
void *  priv 
)
inlinestatic

Set Infiniband queue pair driver-private data.

Parameters
qpQueue pair
privPrivate data

Definition at line 631 of file infiniband.h.

631  {
632  qp->drv_priv = priv;
633 }
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static struct tlan_private * priv
Definition: tlan.c:224

References priv, and qp.

Referenced by arbel_create_qp(), arbel_destroy_qp(), flexboot_nodnic_create_qp(), golan_create_qp_aux(), golan_destroy_qp(), hermon_create_qp(), and hermon_destroy_qp().

◆ ib_qp_get_drvdata()

static __always_inline void* ib_qp_get_drvdata ( struct ib_queue_pair qp)
inlinestatic

◆ ib_qp_set_ownerdata()

static __always_inline void ib_qp_set_ownerdata ( struct ib_queue_pair qp,
void *  priv 
)
inlinestatic

Set Infiniband queue pair owner-private data.

Parameters
qpQueue pair
privPrivate data

Definition at line 653 of file infiniband.h.

653  {
654  qp->owner_priv = priv;
655 }
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static struct tlan_private * priv
Definition: tlan.c:224

References priv, and qp.

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

◆ ib_qp_get_ownerdata()

static __always_inline void* ib_qp_get_ownerdata ( struct ib_queue_pair qp)
inlinestatic

Get Infiniband queue pair owner-private data.

Parameters
qpQueue pair
Return values
privPrivate data

Definition at line 664 of file infiniband.h.

664  {
665  return qp->owner_priv;
666 }
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

References qp.

Referenced by eoib_complete_recv(), eoib_complete_send(), flexboot_nodnic_eth_complete_recv(), flexboot_nodnic_eth_complete_send(), hermon_eth_complete_recv(), hermon_eth_complete_send(), ib_cmrc_changed(), ib_cmrc_complete_recv(), ib_cmrc_complete_send(), ib_mi_complete_recv(), ipoib_complete_recv(), and ipoib_complete_send().

◆ ib_cq_set_drvdata()

static __always_inline void ib_cq_set_drvdata ( struct ib_completion_queue cq,
void *  priv 
)
inlinestatic

Set Infiniband completion queue driver-private data.

Parameters
cqCompletion queue
privPrivate data

Definition at line 675 of file infiniband.h.

675  {
676  cq->drv_priv = priv;
677 }
void * drv_priv
Driver private data.
Definition: infiniband.h:246
static struct tlan_private * priv
Definition: tlan.c:224

References ib_completion_queue::drv_priv, and priv.

Referenced by arbel_create_cq(), arbel_destroy_cq(), flexboot_nodnic_create_cq(), golan_create_cq(), golan_destroy_cq(), hermon_create_cq(), and hermon_destroy_cq().

◆ ib_cq_get_drvdata()

static __always_inline void* ib_cq_get_drvdata ( struct ib_completion_queue cq)
inlinestatic

Get Infiniband completion queue driver-private data.

Parameters
cqCompletion queue
Return values
privPrivate data

Definition at line 686 of file infiniband.h.

686  {
687  return cq->drv_priv;
688 }
void * drv_priv
Driver private data.
Definition: infiniband.h:246

References ib_completion_queue::drv_priv.

Referenced by arbel_destroy_cq(), arbel_poll_cq(), flexboot_nodnic_destroy_cq(), flexboot_nodnic_poll_cq(), golan_destroy_cq(), golan_poll_cq(), hermon_destroy_cq(), hermon_poll_cq(), and ib_create_cq().

◆ ib_set_drvdata()

static __always_inline void ib_set_drvdata ( struct ib_device ibdev,
void *  priv 
)
inlinestatic

Set Infiniband device driver-private data.

Parameters
ibdevInfiniband device
privPrivate data

Definition at line 697 of file infiniband.h.

697  {
698  ibdev->drv_priv = priv;
699 }
void * drv_priv
Driver private data.
Definition: infiniband.h:467
static struct tlan_private * priv
Definition: tlan.c:224
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

References ib_device::drv_priv, and priv.

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

◆ ib_get_drvdata()

static __always_inline void* ib_get_drvdata ( struct ib_device ibdev)
inlinestatic

Get Infiniband device driver-private data.

Parameters
ibdevInfiniband device
Return values
privPrivate data

Definition at line 708 of file infiniband.h.

708  {
709  return ibdev->drv_priv;
710 }
void * drv_priv
Driver private data.
Definition: infiniband.h:467
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

References ib_device::drv_priv.

Referenced by arbel_alloc_qpn(), arbel_complete(), arbel_create_cq(), arbel_create_qp(), arbel_destroy_cq(), arbel_destroy_qp(), arbel_fill_mlx_send_wqe(), arbel_fill_rc_send_wqe(), arbel_fill_ud_send_wqe(), arbel_free_qpn(), arbel_ib_close(), arbel_ib_open(), arbel_mad(), arbel_mcast_attach(), arbel_mcast_detach(), arbel_modify_qp(), arbel_poll_cq(), arbel_poll_eq(), arbel_post_recv(), arbel_post_send(), flexboot_nodnic_complete(), flexboot_nodnic_create_cq(), flexboot_nodnic_create_qp(), flexboot_nodnic_destroy_cq(), flexboot_nodnic_destroy_qp(), flexboot_nodnic_eth_close(), flexboot_nodnic_eth_open(), flexboot_nodnic_eth_transmit(), flexboot_nodnic_find_wq(), flexboot_nodnic_mcast_attach(), flexboot_nodnic_mcast_detach(), flexboot_nodnic_poll_cq(), flexboot_nodnic_poll_eq(), flexboot_nodnic_post_recv(), flexboot_nodnic_post_send(), golan_complete(), golan_create_cq(), golan_create_qp_aux(), golan_destroy_cq(), golan_destroy_qp(), golan_ib_close(), golan_ib_open(), golan_mcast_attach(), golan_mcast_detach(), golan_modify_qp(), golan_modify_qp_to_rst(), golan_poll_cq(), golan_poll_eq(), golan_post_recv(), golan_post_send(), golan_query_vport_context(), golan_query_vport_gid(), golan_query_vport_pkey(), hermon_alloc_qpn(), hermon_complete(), hermon_create_cq(), hermon_create_qp(), hermon_destroy_cq(), hermon_destroy_qp(), hermon_eth_close(), hermon_eth_open(), hermon_eth_transmit(), hermon_fill_eth_send_wqe(), hermon_fill_mlx_send_wqe(), hermon_fill_rc_send_wqe(), hermon_fill_ud_send_wqe(), hermon_free_qpn(), hermon_ib_close(), hermon_ib_open(), hermon_mad(), hermon_mcast_attach(), hermon_mcast_detach(), hermon_modify_qp(), hermon_poll_cq(), hermon_poll_eq(), hermon_post_recv(), hermon_post_send(), linda_close(), linda_complete_recv(), linda_complete_send(), linda_create_cq(), linda_create_qp(), linda_destroy_cq(), linda_destroy_qp(), linda_link_state_changed(), linda_mcast_attach(), linda_mcast_detach(), linda_modify_qp(), linda_open(), linda_poll_eq(), linda_poll_recv_wq(), linda_poll_send_wq(), linda_post_recv(), linda_post_send(), linda_probe(), linda_remove(), linda_set_port_info(), qib7322_alloc_ctx(), qib7322_close(), qib7322_complete_recv(), qib7322_complete_send(), qib7322_create_cq(), qib7322_create_qp(), qib7322_create_recv_wq(), qib7322_create_send_wq(), qib7322_destroy_cq(), qib7322_destroy_recv_wq(), qib7322_free_ctx(), qib7322_link_state_changed(), qib7322_link_state_check(), qib7322_mcast_attach(), qib7322_mcast_detach(), qib7322_modify_qp(), qib7322_open(), qib7322_poll_eq(), qib7322_poll_recv_wq(), qib7322_poll_send_wq(), qib7322_post_recv(), qib7322_post_send(), qib7322_set_port_info(), shomron_fill_eth_send_wqe(), and shomron_tx_uar_send_db().

Variable Documentation

◆ ib_devices

struct list_head ib_devices

List of Infiniband devices.

Definition at line 52 of file infiniband.c.

Referenced by register_ibdev(), and unregister_ibdev().