2 * Copyright (C) 2009 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 FILE_LICENCE ( GPL2_OR_LATER );
23 #include <gpxe/iobuf.h>
24 #include <gpxe/infiniband.h>
25 #include <gpxe/ib_qset.h>
30 * Infiniband queue sets
37 * @v ibdev Infiniband device
39 * @v num_cqes Number of completion queue entries
40 * @v cq_op Completion queue operations
41 * @v num_send_wqes Number of send work queue entries
42 * @v num_recv_wqes Number of receive work queue entries
44 * @ret rc Return status code
46 int ib_create_qset ( struct ib_device *ibdev, struct ib_queue_set *qset,
47 unsigned int num_cqes,
48 struct ib_completion_queue_operations *cq_op,
49 unsigned int num_send_wqes, unsigned int num_recv_wqes,
50 unsigned long qkey ) {
54 assert ( qset->cq == NULL );
55 assert ( qset->qp == NULL );
57 /* Allocate completion queue */
58 qset->cq = ib_create_cq ( ibdev, num_cqes, cq_op );
60 DBGC ( ibdev, "IBDEV %p could not allocate completion queue\n",
66 /* Allocate queue pair */
67 qset->qp = ib_create_qp ( ibdev, num_send_wqes, qset->cq,
68 num_recv_wqes, qset->cq, qkey );
70 DBGC ( ibdev, "IBDEV %p could not allocate queue pair\n",
79 ib_destroy_qset ( ibdev, qset );
86 * @v ibdev Infiniband device
89 void ib_destroy_qset ( struct ib_device *ibdev,
90 struct ib_queue_set *qset ) {
93 ib_destroy_qp ( ibdev, qset->qp );
95 ib_destroy_cq ( ibdev, qset->cq );
96 memset ( qset, 0, sizeof ( *qset ) );