]> git.openfabrics.org - ~shefty/libmlx4.git/commitdiff
Pass send queue sizes from userspace to kernel
authorRoland Dreier <rolandd@cisco.com>
Mon, 21 May 2007 03:12:15 +0000 (20:12 -0700)
committerRoland Dreier <rolandd@cisco.com>
Mon, 21 May 2007 03:12:15 +0000 (20:12 -0700)
Update to handle kernel mlx4 ABI version 2: pass log_2 of send queue
WQE basic block size and log_2 of number of send queue basic blocks to
the kernel to avoid bugs caused by the kernel calculating a different
send queue WQE size.  This will also allow us to use multiple BBs per
WQE if we want to someday.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
src/mlx4-abi.h
src/mlx4.c
src/mlx4.h
src/qp.c
src/verbs.c

index 781091362cc79165cd1ff9430efbea7be553424b..97f5dcd93e57db6d0f5a0372cb44dd409c24b0fc 100644 (file)
@@ -35,7 +35,8 @@
 
 #include <infiniband/kern-abi.h>
 
-#define MLX4_UVERBS_ABI_VERSION        1
+#define MLX4_UVERBS_MIN_ABI_VERSION    2
+#define MLX4_UVERBS_MAX_ABI_VERSION    2
 
 struct mlx4_alloc_ucontext_resp {
        struct ibv_get_context_resp     ibv_resp;
@@ -83,6 +84,9 @@ struct mlx4_create_qp {
        struct ibv_create_qp            ibv_cmd;
        __u64                           buf_addr;
        __u64                           db_addr;
+       __u8                            log_sq_bb_count;
+       __u8                            log_sq_stride;
+       __u8                            reserved[6];
 };
 
 #endif /* MLX4_ABI_H */
index 23577c19151d77d1f6a45f71edf2e3b12a2b9770..ac522a7315b4c93c27163ce24186c36f940bd393 100644 (file)
@@ -250,9 +250,13 @@ static struct ibv_device *mlx4_driver_init(const char *uverbs_sys_path,
        return NULL;
 
 found:
-       if (abi_version > MLX4_UVERBS_ABI_VERSION) {
-               fprintf(stderr, PFX "Fatal: ABI version %d of %s is too new (expected %d)\n",
-                       abi_version, uverbs_sys_path, MLX4_UVERBS_ABI_VERSION);
+       if (abi_version < MLX4_UVERBS_MIN_ABI_VERSION ||
+           abi_version > MLX4_UVERBS_MAX_ABI_VERSION) {
+               fprintf(stderr, PFX "Fatal: ABI version %d of %s is not supported "
+                       "(min supported %d, max supported %d)\n",
+                       abi_version, uverbs_sys_path,
+                       MLX4_UVERBS_MIN_ABI_VERSION,
+                       MLX4_UVERBS_MAX_ABI_VERSION);
                return NULL;
        }
 
index 1e92b88ddf8386e1c2e2e26578695efc965173da..7978f9fcc235ee06c9e8f363d92d7f5050719e08 100644 (file)
@@ -343,6 +343,8 @@ int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
                          struct ibv_recv_wr **bad_wr);
 int mlx4_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
                       enum ibv_qp_type type, struct mlx4_qp *qp);
+void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
+                      enum ibv_qp_type type);
 struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn);
 int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp);
 void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn);
index a4384f90460da9758309253925328445a0c02976..bff3f332cfeaa6d9cf429b2f340f6c59d2818a69 100644 (file)
--- a/src/qp.c
+++ b/src/qp.c
@@ -469,6 +469,32 @@ int mlx4_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
        return 0;
 }
 
+void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
+                      enum ibv_qp_type type)
+{
+       int wqe_size;
+
+       wqe_size = 1 << qp->sq.wqe_shift;
+       switch (type) {
+       case IBV_QPT_UD:
+               wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);
+               break;
+
+       case IBV_QPT_UC:
+       case IBV_QPT_RC:
+               wqe_size -= sizeof (struct mlx4_wqe_raddr_seg);
+               break;
+
+       default:
+               break;
+       }
+
+       qp->sq.max_gs        = wqe_size / sizeof (struct mlx4_wqe_data_seg);
+       cap->max_send_sge    = qp->sq.max_gs;
+       qp->max_inline_data  = wqe_size - sizeof (struct mlx4_wqe_inline_seg);
+       cap->max_inline_data = qp->max_inline_data;
+}
+
 struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn)
 {
        int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
index fa9674bc4e3e11a4f9461d63fb1ebd44d33b8d05..41914ac32abe3c15e5cde952fc4a5fafafa38d86 100644 (file)
@@ -390,8 +390,14 @@ struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
 
        *qp->db = 0;
 
-       cmd.buf_addr = (uintptr_t) qp->buf.buf;
-       cmd.db_addr  = (uintptr_t) qp->db;
+       cmd.buf_addr      = (uintptr_t) qp->buf.buf;
+       cmd.db_addr       = (uintptr_t) qp->db;
+       cmd.log_sq_stride = qp->sq.wqe_shift;
+       for (cmd.log_sq_bb_count = 0;
+            qp->sq.max > 1 << cmd.log_sq_bb_count;
+            ++cmd.log_sq_bb_count)
+               ; /* nothing */
+       memset(cmd.reserved, 0, sizeof cmd.reserved);
 
        ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
                                &resp, sizeof resp);
@@ -402,11 +408,9 @@ struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
        if (ret)
                goto err_destroy;
 
-       qp->sq.max          = attr->cap.max_send_wr;
-       qp->rq.max          = attr->cap.max_recv_wr;
-       qp->sq.max_gs       = attr->cap.max_send_sge;
-       qp->rq.max_gs       = attr->cap.max_recv_sge;
-       qp->max_inline_data = attr->cap.max_inline_data;
+       qp->rq.max    = attr->cap.max_recv_wr;
+       qp->rq.max_gs = attr->cap.max_recv_sge;
+       mlx4_set_sq_sizes(qp, &attr->cap, attr->qp_type);
 
        qp->doorbell_qpn    = htonl(qp->ibv_qp.qp_num << 8);
        if (attr->sq_sig_all)