Skip to content

Commit

Permalink
[infiniband] Add notion of a queue pair type
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brown committed Jul 17, 2009
1 parent 3f4972d commit 80c41b9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/drivers/net/ipoib.c
Expand Up @@ -519,7 +519,8 @@ static int ipoib_open ( struct net_device *netdev ) {
}

/* Allocate queue pair */
ipoib->qp = ib_create_qp ( ibdev, IPOIB_NUM_SEND_WQES, ipoib->cq,
ipoib->qp = ib_create_qp ( ibdev, IB_QPT_UD,
IPOIB_NUM_SEND_WQES, ipoib->cq,
IPOIB_NUM_RECV_WQES, ipoib->cq, 0 );
if ( ! ipoib->qp ) {
DBGC ( ipoib, "IPoIB %p could not allocate queue pair\n",
Expand Down
3 changes: 2 additions & 1 deletion src/include/gpxe/ib_gma.h
Expand Up @@ -18,6 +18,7 @@ struct ib_completion_queue;
struct ib_queue_pair;
union ib_mad;
struct ib_gma;
enum ib_queue_pair_type;

/** A GMA attribute handler */
struct ib_gma_handler {
Expand Down Expand Up @@ -68,7 +69,7 @@ struct ib_gma {
extern int ib_gma_request ( struct ib_gma *gma, union ib_mad *mad,
struct ib_address_vector *av, int retry );
extern int ib_create_gma ( struct ib_gma *gma, struct ib_device *ibdev,
unsigned long qkey );
enum ib_queue_pair_type type );
extern void ib_destroy_gma ( struct ib_gma *gma );

#endif /* _GPXE_IB_GMA_H */
16 changes: 13 additions & 3 deletions src/include/gpxe/infiniband.h
Expand Up @@ -83,6 +83,13 @@ struct ib_multicast_gid {
struct ib_gid gid;
};

/** An Infiniband queue pair type */
enum ib_queue_pair_type {
IB_QPT_SMA,
IB_QPT_GMA,
IB_QPT_UD,
};

/** An Infiniband Queue Pair */
struct ib_queue_pair {
/** Containing Infiniband device */
Expand All @@ -91,6 +98,8 @@ struct ib_queue_pair {
struct list_head list;
/** Queue Pair Number */
unsigned long qpn;
/** Queue pair type */
enum ib_queue_pair_type type;
/** Queue key */
unsigned long qkey;
/** Send queue */
Expand Down Expand Up @@ -395,9 +404,10 @@ extern void ib_destroy_cq ( struct ib_device *ibdev,
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_completion_queue *recv_cq, unsigned long qkey );
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,
unsigned long qkey );
extern int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp,
unsigned long mod_list, unsigned long qkey );
extern void ib_destroy_qp ( struct ib_device *ibdev,
Expand Down
5 changes: 4 additions & 1 deletion src/net/infiniband.c
Expand Up @@ -143,6 +143,7 @@ void ib_poll_cq ( struct ib_device *ibdev,
* Create queue pair
*
* @v ibdev Infiniband device
* @v type Queue pair type
* @v num_send_wqes Number of send work queue entries
* @v send_cq Send completion queue
* @v num_recv_wqes Number of receive work queue entries
Expand All @@ -151,6 +152,7 @@ void ib_poll_cq ( struct ib_device *ibdev,
* @ret qp Queue pair
*/
struct ib_queue_pair * 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,
Expand All @@ -171,6 +173,7 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
goto err_alloc_qp;
qp->ibdev = ibdev;
list_add ( &qp->list, &ibdev->qps );
qp->type = type;
qp->qkey = qkey;
qp->send.qp = qp;
qp->send.is_send = 1;
Expand Down Expand Up @@ -515,7 +518,7 @@ int ib_open ( struct ib_device *ibdev ) {
}

/* Create general management agent */
if ( ( rc = ib_create_gma ( &ibdev->gma, ibdev, IB_QKEY_GMA ) ) != 0 ){
if ( ( rc = ib_create_gma ( &ibdev->gma, ibdev, IB_QPT_GMA ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not create GMA: %s\n",
ibdev, strerror ( rc ) );
goto err_create_gma;
Expand Down
8 changes: 5 additions & 3 deletions src/net/infiniband/ib_gma.c
Expand Up @@ -343,11 +343,12 @@ int ib_gma_request ( struct ib_gma *gma, union ib_mad *mad,
*
* @v gma General management agent
* @v ibdev Infiniband device
* @v qkey Queue key
* @v type Queue pair type
* @ret rc Return status code
*/
int ib_create_gma ( struct ib_gma *gma, struct ib_device *ibdev,
unsigned long qkey ) {
enum ib_queue_pair_type type ) {
unsigned long qkey;
int rc;

/* Initialise fields */
Expand All @@ -366,7 +367,8 @@ int ib_create_gma ( struct ib_gma *gma, struct ib_device *ibdev,
}

/* Create queue pair */
gma->qp = ib_create_qp ( ibdev, IB_GMA_NUM_SEND_WQES, gma->cq,
qkey = ( ( type == IB_QPT_SMA ) ? IB_QKEY_SMA : IB_QKEY_GMA );
gma->qp = ib_create_qp ( ibdev, type, IB_GMA_NUM_SEND_WQES, gma->cq,
IB_GMA_NUM_RECV_WQES, gma->cq, qkey );
if ( ! gma->qp ) {
DBGC ( gma, "GMA %p could not allocate queue pair\n", gma );
Expand Down
2 changes: 1 addition & 1 deletion src/net/infiniband/ib_sma.c
Expand Up @@ -286,7 +286,7 @@ int ib_create_sma ( struct ib_sma *sma, struct ib_device *ibdev ) {
int rc;

/* Initialise GMA */
if ( ( rc = ib_create_gma ( &sma->gma, ibdev, 0 ) ) != 0 ) {
if ( ( rc = ib_create_gma ( &sma->gma, ibdev, IB_QPT_SMA ) ) != 0 ) {
DBGC ( sma, "SMA %p could not create GMA: %s\n",
sma, strerror ( rc ) );
goto err_create_gma;
Expand Down

0 comments on commit 80c41b9

Please sign in to comment.