struct ipoib_device *ipoib = netdev->priv;
struct ib_device *ibdev = ipoib->ibdev;
- ib_poll_cq ( ibdev, ipoib->meta.cq );
- ib_poll_cq ( ibdev, ipoib->data.cq );
- ib_qset_refill_recv ( ibdev, &ipoib->meta );
- ib_qset_refill_recv ( ibdev, &ipoib->data );
+ ib_poll_eq ( ibdev );
}
/**
mac->qpn = htonl ( ipoib->data.qp->qpn );
/* Fill receive rings */
- ib_qset_refill_recv ( ibdev, &ipoib->meta );
- ib_qset_refill_recv ( ibdev, &ipoib->data );
+ ib_refill_recv ( ibdev, ipoib->meta.qp );
+ ib_refill_recv ( ibdev, ipoib->data.qp );
/* Join broadcast group */
if ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) {
struct ib_completion_queue *cq;
/** Queue pair */
struct ib_queue_pair *qp;
- /** Receive work queue maximum fill level */
- unsigned int recv_max_fill;
};
extern int ib_create_qset ( struct ib_device *ibdev,
struct ib_completion_queue_operations *cq_op,
unsigned int num_send_wqes,
unsigned int num_recv_wqes, unsigned long qkey );
-extern void ib_qset_refill_recv ( struct ib_device *ibdev,
- struct ib_queue_set *qset );
extern void ib_destroy_qset ( struct ib_device *ibdev,
struct ib_queue_set *qset );
FILE_LICENCE ( GPL2_OR_LATER );
#include <gpxe/infiniband.h>
-#include <gpxe/process.h>
/** Infiniband Subnet Management Agent operations */
struct ib_sma_operations {
struct ib_completion_queue *cq;
/** SMA queue pair */
struct ib_queue_pair *qp;
- /** Poll process */
- struct process poll;
};
/** SMA number of send WQEs
/** An Infiniband Completion Queue */
struct ib_completion_queue {
+ /** Containing Infiniband device */
+ struct ib_device *ibdev;
+ /** List of completion queues on this Infiniband device */
+ struct list_head list;
/** Completion queue number */
unsigned long cqn;
/** Number of completion queue entries */
struct list_head list;
/** Underlying device */
struct device *dev;
+ /** List of completion queues */
+ struct list_head cqs;
/** List of queue pairs */
struct list_head qps;
/** Infiniband operations */
struct ib_completion_queue_operations *op );
extern void ib_destroy_cq ( struct ib_device *ibdev,
struct ib_completion_queue *cq );
+extern void ib_poll_cq ( struct ib_device *ibdev,
+ struct ib_completion_queue *cq );
extern struct ib_queue_pair *
ib_create_qp ( struct ib_device *ibdev, unsigned int num_send_wqes,
struct ib_completion_queue *send_cq, unsigned int num_recv_wqes,
struct ib_queue_pair *qp,
struct ib_address_vector *av,
struct io_buffer *iobuf, int rc );
+extern void ib_refill_recv ( struct ib_device *ibdev,
+ struct ib_queue_pair *qp );
extern int ib_open ( struct ib_device *ibdev );
extern void ib_close ( struct ib_device *ibdev );
extern int ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
extern int register_ibdev ( struct ib_device *ibdev );
extern void unregister_ibdev ( struct ib_device *ibdev );
extern void ib_link_state_changed ( struct ib_device *ibdev );
+extern void ib_poll_eq ( struct ib_device *ibdev );
extern struct list_head ib_devices;
/** Iterate over all network devices */
#define for_each_ibdev( ibdev ) \
list_for_each_entry ( (ibdev), &ib_devices, list )
-/**
- * Poll completion queue
- *
- * @v ibdev Infiniband device
- * @v cq Completion queue
- */
-static inline __always_inline void
-ib_poll_cq ( struct ib_device *ibdev, struct ib_completion_queue *cq ) {
- ibdev->op->poll_cq ( ibdev, cq );
-}
-
/**
* Check link state
*
/** List of Infiniband devices */
struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices );
+/***************************************************************************
+ *
+ * Completion queues
+ *
+ ***************************************************************************
+ */
+
/**
* Create completion queue
*
cq = zalloc ( sizeof ( *cq ) );
if ( ! cq )
goto err_alloc_cq;
+ cq->ibdev = ibdev;
+ list_add ( &cq->list, &ibdev->cqs );
cq->num_cqes = num_cqes;
INIT_LIST_HEAD ( &cq->work_queues );
cq->op = op;
ibdev->op->destroy_cq ( ibdev, cq );
err_dev_create_cq:
+ list_del ( &cq->list );
free ( cq );
err_alloc_cq:
return NULL;
ibdev, cq->cqn );
assert ( list_empty ( &cq->work_queues ) );
ibdev->op->destroy_cq ( ibdev, cq );
+ list_del ( &cq->list );
free ( cq );
}
+/**
+ * Poll completion queue
+ *
+ * @v ibdev Infiniband device
+ * @v cq Completion queue
+ */
+void ib_poll_cq ( struct ib_device *ibdev,
+ struct ib_completion_queue *cq ) {
+ struct ib_work_queue *wq;
+
+ /* Poll completion queue */
+ ibdev->op->poll_cq ( ibdev, cq );
+
+ /* Refill receive work queues */
+ list_for_each_entry ( wq, &cq->work_queues, list ) {
+ if ( ! wq->is_send )
+ ib_refill_recv ( ibdev, wq->qp );
+ }
+}
+
+/***************************************************************************
+ *
+ * Work queues
+ *
+ ***************************************************************************
+ */
+
/**
* Create queue pair
*
qp->recv.fill--;
}
+/**
+ * Refill receive work queue
+ *
+ * @v ibdev Infiniband device
+ * @v qp Queue pair
+ */
+void ib_refill_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
+ struct io_buffer *iobuf;
+ int rc;
+
+ /* Keep filling while unfilled entries remain */
+ while ( qp->recv.fill < qp->recv.num_wqes ) {
+
+ /* Allocate I/O buffer */
+ iobuf = alloc_iob ( IB_MAX_PAYLOAD_SIZE );
+ if ( ! iobuf ) {
+ /* Non-fatal; we will refill on next attempt */
+ return;
+ }
+
+ /* Post I/O buffer */
+ if ( ( rc = ib_post_recv ( ibdev, qp, iobuf ) ) != 0 ) {
+ DBGC ( ibdev, "IBDEV %p could not refill: %s\n",
+ ibdev, strerror ( rc ) );
+ free_iob ( iobuf );
+ /* Give up */
+ return;
+ }
+ }
+}
+
+/***************************************************************************
+ *
+ * Link control
+ *
+ ***************************************************************************
+ */
+
/**
* Open port
*
ibdev->op->close ( ibdev );
}
+/***************************************************************************
+ *
+ * Multicast
+ *
+ ***************************************************************************
+ */
+
/**
* Attach to multicast group
*
}
}
+/***************************************************************************
+ *
+ * Miscellaneous
+ *
+ ***************************************************************************
+ */
+
/**
* Get Infiniband HCA information
*
ipoib_link_state_changed ( ibdev );
}
+/**
+ * Poll event queue
+ *
+ * @v ibdev Infiniband device
+ */
+void ib_poll_eq ( struct ib_device *ibdev ) {
+ struct ib_completion_queue *cq;
+
+ /* Poll device's event queue */
+ ibdev->op->poll_eq ( ibdev );
+
+ /* Poll all completion queues */
+ list_for_each_entry ( cq, &ibdev->cqs, list )
+ ib_poll_cq ( ibdev, cq );
+}
+
/**
* Single-step the Infiniband event queue
*
static void ib_step ( struct process *process __unused ) {
struct ib_device *ibdev;
- list_for_each_entry ( ibdev, &ib_devices, list ) {
- ibdev->op->poll_eq ( ibdev );
- }
+ for_each_ibdev ( ibdev )
+ ib_poll_eq ( ibdev );
}
/** Infiniband event queue process */
if ( ibdev ) {
drv_priv = ( ( ( void * ) ibdev ) + sizeof ( *ibdev ) );
ib_set_drvdata ( ibdev, drv_priv );
+ INIT_LIST_HEAD ( &ibdev->cqs );
INIT_LIST_HEAD ( &ibdev->qps );
ibdev->lid = IB_LID_NONE;
ibdev->pkey = IB_PKEY_NONE;
assert ( qset->cq == NULL );
assert ( qset->qp == NULL );
- /* Store queue parameters */
- qset->recv_max_fill = num_recv_wqes;
-
/* Allocate completion queue */
qset->cq = ib_create_cq ( ibdev, num_cqes, cq_op );
if ( ! qset->cq ) {
return rc;
}
-/**
- * Refill IPoIB receive ring
- *
- * @v ibdev Infiniband device
- * @v qset Queue set
- */
-void ib_qset_refill_recv ( struct ib_device *ibdev,
- struct ib_queue_set *qset ) {
- struct io_buffer *iobuf;
- int rc;
-
- while ( qset->qp->recv.fill < qset->recv_max_fill ) {
-
- /* Allocate I/O buffer */
- iobuf = alloc_iob ( IB_MAX_PAYLOAD_SIZE );
- if ( ! iobuf ) {
- /* Non-fatal; we will refill on next attempt */
- return;
- }
-
- /* Post I/O buffer */
- if ( ( rc = ib_post_recv ( ibdev, qset->qp, iobuf ) ) != 0 ) {
- DBGC ( ibdev, "IBDEV %p could not refill: %s\n",
- ibdev, strerror ( rc ) );
- free_iob ( iobuf );
- /* Give up */
- return;
- }
- }
-}
-
/**
* Destroy queue set
*
#include <byteswap.h>
#include <gpxe/infiniband.h>
#include <gpxe/iobuf.h>
-#include <gpxe/process.h>
#include <gpxe/ib_sma.h>
/**
return 0;
}
-/**
- * Refill SMA receive ring
- *
- * @v sma Subnet management agent
- */
-static void ib_sma_refill_recv ( struct ib_sma *sma ) {
- struct ib_device *ibdev = sma->ibdev;
- struct io_buffer *iobuf;
- int rc;
-
- while ( sma->qp->recv.fill < IB_SMA_NUM_RECV_WQES ) {
-
- /* Allocate I/O buffer */
- iobuf = alloc_iob ( IB_MAX_PAYLOAD_SIZE );
- if ( ! iobuf ) {
- /* Non-fatal; we will refill on next attempt */
- return;
- }
-
- /* Post I/O buffer */
- if ( ( rc = ib_post_recv ( ibdev, sma->qp, iobuf ) ) != 0 ) {
- DBGC ( sma, "SMA %p could not refill: %s\n",
- sma, strerror ( rc ) );
- free_iob ( iobuf );
- /* Give up */
- return;
- }
- }
-}
-
/**
* Complete SMA send
*
.complete_recv = ib_sma_complete_recv,
};
-/**
- * Poll SMA
- *
- * @v process Process
- */
-static void ib_sma_step ( struct process *process ) {
- struct ib_sma *sma =
- container_of ( process, struct ib_sma, poll );
- struct ib_device *ibdev = sma->ibdev;
-
- /* Poll the kernel completion queue */
- ib_poll_cq ( ibdev, sma->cq );
-
- /* Refill the receive ring */
- ib_sma_refill_recv ( sma );
-}
-
/**
* Create SMA
*
memset ( sma, 0, sizeof ( *sma ) );
sma->ibdev = ibdev;
sma->op = op;
- process_init ( &sma->poll, ib_sma_step, &ibdev->refcnt );
/* Create completion queue */
sma->cq = ib_create_cq ( ibdev, IB_SMA_NUM_CQES,
}
/* Fill receive ring */
- ib_sma_refill_recv ( sma );
+ ib_refill_recv ( ibdev, sma->qp );
return 0;
err_not_qp0:
err_create_qp:
ib_destroy_cq ( ibdev, sma->cq );
err_create_cq:
- process_del ( &sma->poll );
return rc;
}
ib_destroy_qp ( ibdev, sma->qp );
ib_destroy_cq ( ibdev, sma->cq );
- process_del ( &sma->poll );
}