Commit bcf4c1ea authored by Matan Barak's avatar Matan Barak Committed by Doug Ledford
Browse files

IB/core: Change provider's API of create_cq to be extendible



Add a new ib_cq_init_attr structure which contains the
previous cqe (minimum number of CQ entries) and comp_vector
(completion vector) in addition to a new flags field.
All vendors' create_cq callbacks are changed in order
to work with the new API.

This commit does not change any functionality.

Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Reviewed-By: Devesh Sharma <devesh.sharma@avagotech.com> to patch #2
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 74217d4c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1341,6 +1341,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
	struct ib_uverbs_event_file    *ev_file = NULL;
	struct ib_cq                   *cq;
	int                             ret;
	struct ib_cq_init_attr attr = {};

	if (out_len < sizeof resp)
		return -ENOSPC;
@@ -1376,8 +1377,9 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
	INIT_LIST_HEAD(&obj->comp_list);
	INIT_LIST_HEAD(&obj->async_list);

	cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe,
					     cmd.comp_vector,
	attr.cqe = cmd.cqe;
	attr.comp_vector = cmd.comp_vector;
	cq = file->device->ib_dev->create_cq(file->device->ib_dev, &attr,
					     file->ucontext, &udata);
	if (IS_ERR(cq)) {
		ret = PTR_ERR(cq);
+2 −1
Original line number Diff line number Diff line
@@ -1079,8 +1079,9 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
			   void *cq_context, int cqe, int comp_vector)
{
	struct ib_cq *cq;
	struct ib_cq_init_attr attr = {.cqe = cqe, .comp_vector = comp_vector};

	cq = device->create_cq(device, cqe, comp_vector, NULL, NULL);
	cq = device->create_cq(device, &attr, NULL, NULL);

	if (!IS_ERR(cq)) {
		cq->device        = device;
+6 −1
Original line number Diff line number Diff line
@@ -286,13 +286,18 @@ static int c2_destroy_qp(struct ib_qp *ib_qp)
	return 0;
}

static struct ib_cq *c2_create_cq(struct ib_device *ibdev, int entries, int vector,
static struct ib_cq *c2_create_cq(struct ib_device *ibdev,
				  const struct ib_cq_init_attr *attr,
				  struct ib_ucontext *context,
				  struct ib_udata *udata)
{
	int entries = attr->cqe;
	struct c2_cq *cq;
	int err;

	if (attr->flags)
		return ERR_PTR(-EINVAL);

	cq = kmalloc(sizeof(*cq), GFP_KERNEL);
	if (!cq) {
		pr_debug("%s: Unable to allocate CQ\n", __func__);
+8 −3
Original line number Diff line number Diff line
@@ -138,10 +138,12 @@ static int iwch_destroy_cq(struct ib_cq *ib_cq)
	return 0;
}

static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int vector,
static struct ib_cq *iwch_create_cq(struct ib_device *ibdev,
				    const struct ib_cq_init_attr *attr,
				    struct ib_ucontext *ib_context,
				    struct ib_udata *udata)
{
	int entries = attr->cqe;
	struct iwch_dev *rhp;
	struct iwch_cq *chp;
	struct iwch_create_cq_resp uresp;
@@ -151,6 +153,9 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve
	size_t resplen;

	PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries);
	if (attr->flags)
		return ERR_PTR(-EINVAL);

	rhp = to_iwch_dev(ibdev);
	chp = kzalloc(sizeof(*chp), GFP_KERNEL);
	if (!chp)
+7 −2
Original line number Diff line number Diff line
@@ -864,10 +864,13 @@ int c4iw_destroy_cq(struct ib_cq *ib_cq)
	return 0;
}

struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
			     int vector, struct ib_ucontext *ib_context,
struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
			     const struct ib_cq_init_attr *attr,
			     struct ib_ucontext *ib_context,
			     struct ib_udata *udata)
{
	int entries = attr->cqe;
	int vector = attr->comp_vector;
	struct c4iw_dev *rhp;
	struct c4iw_cq *chp;
	struct c4iw_create_cq_resp uresp;
@@ -877,6 +880,8 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
	struct c4iw_mm_entry *mm, *mm2;

	PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries);
	if (attr->flags)
		return ERR_PTR(-EINVAL);

	rhp = to_c4iw_dev(ibdev);

Loading