[ofa-general] [PATCH 2/2] IB/mlx4: pass more data from user to kernel
Eli Cohen
eli at mellanox.co.il
Thu May 17 00:32:41 PDT 2007
kernel code make minimum caclulations to evaluate wq size of user space
consumers for calcualting the buffer size.
Signed-off-by: Eli Cohen <eli at mellanox.co.il>
---
Index: connectx_kernel/drivers/infiniband/hw/mlx4/qp.c
===================================================================
--- connectx_kernel.orig/drivers/infiniband/hw/mlx4/qp.c 2007-05-16 16:37:35.000000000 +0300
+++ connectx_kernel/drivers/infiniband/hw/mlx4/qp.c 2007-05-17 09:13:49.000000000 +0300
@@ -188,8 +188,8 @@ static int send_wqe_overhead(enum ib_qp_
}
}
-static int set_qp_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
- enum ib_qp_type type, struct mlx4_ib_qp *qp)
+static int set_kernel_qp_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
+ enum ib_qp_type type, struct mlx4_ib_qp *qp)
{
/* Sanity check QP size before proceeding */
if (cap->max_send_wr > dev->dev->caps.max_wqes ||
@@ -249,6 +249,23 @@ static int set_qp_size(struct mlx4_ib_de
return 0;
}
+static int set_user_qp_size(struct mlx4_ib_qp *qp,
+ struct mlx4_ib_create_qp *ucmd)
+{
+ if (ucmd->rq_size & ucmd->rq_size - 1 || ucmd->sq_size & ucmd->sq_size - 1)
+ return -EINVAL;
+
+ qp->rq.max = ucmd->rq_size;
+ qp->rq.wqe_shift = ucmd->rcv_wqe_shift;
+ qp->sq.wqe_shift = ucmd->log_wqe_bb;
+ qp->sq.max = ucmd->sq_size;
+
+ qp->buf_size = (qp->rq.max << qp->rq.wqe_shift) +
+ (qp->sq.max << qp->sq.wqe_shift);
+
+ return 0;
+}
+
static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
struct ib_qp_init_attr *init_attr,
struct ib_udata *udata, int sqpn, struct mlx4_ib_qp *qp)
@@ -270,10 +287,6 @@ static int create_qp_common(struct mlx4_
qp->sq.head = 0;
qp->sq.tail = 0;
- err = set_qp_size(dev, &init_attr->cap, init_attr->qp_type, qp);
- if (err)
- goto err;
-
if (pd->uobject) {
struct mlx4_ib_create_qp ucmd;
@@ -282,6 +295,10 @@ static int create_qp_common(struct mlx4_
goto err;
}
+ err = set_user_qp_size(qp, &ucmd);
+ if (err)
+ goto err;
+
qp->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr,
qp->buf_size, 0);
if (IS_ERR(qp->umem)) {
@@ -303,6 +320,10 @@ static int create_qp_common(struct mlx4_
if (err)
goto err_mtt;
} else {
+ err = set_kernel_qp_size(dev, &init_attr->cap, init_attr->qp_type, qp);
+ if (err)
+ goto err;
+
err = mlx4_ib_db_alloc(dev, &qp->db, 0);
if (err)
goto err;
Index: connectx_kernel/drivers/infiniband/hw/mlx4/user.h
===================================================================
--- connectx_kernel.orig/drivers/infiniband/hw/mlx4/user.h 2007-05-16 16:37:35.000000000 +0300
+++ connectx_kernel/drivers/infiniband/hw/mlx4/user.h 2007-05-17 09:45:45.000000000 +0300
@@ -39,7 +39,7 @@
* Increment this value if any changes that break userspace ABI
* compatibility are made.
*/
-#define MLX4_IB_UVERBS_ABI_VERSION 1
+#define MLX4_IB_UVERBS_ABI_VERSION 2
/*
* Make sure that all structs defined in this file remain laid out so
@@ -87,6 +87,10 @@ struct mlx4_ib_create_srq_resp {
struct mlx4_ib_create_qp {
__u64 buf_addr;
__u64 db_addr;
+ __u64 rq_size;
+ __u64 sq_size;
+ __u8 rcv_wqe_shift;
+ __u8 log_wqe_bb;
};
#endif /* MLX4_IB_USER_H */
More information about the general
mailing list