diff options
author | Michael Brown | 2007-09-16 18:25:15 +0200 |
---|---|---|
committer | Michael Brown | 2007-09-16 18:25:15 +0200 |
commit | b21d4ca21e65025410df73b34d685b6e78c86f0d (patch) | |
tree | 5a9480ed13dd4aaab860d4c8fefad27872b3999a /src/net/infiniband.c | |
parent | destroy_cq() now implemented (not tested). (diff) | |
download | ipxe-b21d4ca21e65025410df73b34d685b6e78c86f0d.tar.gz ipxe-b21d4ca21e65025410df73b34d685b6e78c86f0d.tar.xz ipxe-b21d4ca21e65025410df73b34d685b6e78c86f0d.zip |
Revert to dev_priv/owner_priv scheme, rather than container_of; it
makes it easier to put the generic allocation code into infiniband.c
Diffstat (limited to 'src/net/infiniband.c')
-rw-r--r-- | src/net/infiniband.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c index 694c88b1..2a29c5b2 100644 --- a/src/net/infiniband.c +++ b/src/net/infiniband.c @@ -17,11 +17,13 @@ */ #include <stdint.h> +#include <stdlib.h> #include <stdio.h> #include <string.h> #include <byteswap.h> #include <errno.h> #include <assert.h> +#include <gpxe/list.h> #include <gpxe/if_arp.h> #include <gpxe/netdevice.h> #include <gpxe/iobuf.h> @@ -34,6 +36,55 @@ */ /** + * Create completion queue + * + * @v ibdev Infiniband device + * @v num_cqes Number of completion queue entries + * @ret cq New completion queue + */ +struct ib_completion_queue * ib_create_cq ( struct ib_device *ibdev, + unsigned int num_cqes ) { + struct ib_completion_queue *cq; + int rc; + + DBGC ( ibdev, "IBDEV %p creating completion queue\n", ibdev ); + + /* Allocate and initialise data structure */ + cq = zalloc ( sizeof ( *cq ) ); + if ( ! cq ) + return NULL; + cq->num_cqes = num_cqes; + INIT_LIST_HEAD ( &cq->work_queues ); + + /* Perform device-specific initialisation and get CQN */ + if ( ( rc = ibdev->op->create_cq ( ibdev, cq ) ) != 0 ) { + DBGC ( ibdev, "IBDEV %p could not initialise CQ: %s\n", + ibdev, strerror ( rc ) ); + free ( cq ); + return NULL; + } + + DBGC ( ibdev, "IBDEV %p created completion queue %#lx\n", + ibdev, cq->cqn ); + return cq; +} + +/** + * Destroy completion queue + * + * @v ibdev Infiniband device + * @v cq Completion queue + */ +void ib_destroy_cq ( struct ib_device *ibdev, + struct ib_completion_queue *cq ) { + DBGC ( ibdev, "IBDEV %p destroying completion queue %#lx\n", + ibdev, cq->cqn ); + assert ( list_empty ( &cq->work_queues ) ); + ibdev->op->destroy_cq ( ibdev, cq ); + free ( cq ); +} + +/** * Find work queue belonging to completion queue * * @v cq Completion queue |