]> git.karo-electronics.de Git - linux-beck.git/commitdiff
IB/mlx5: Add support for CQE compressing
authorBodong Wang <bodong@mellanox.com>
Mon, 31 Oct 2016 10:16:45 +0000 (12:16 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 13 Dec 2016 18:34:20 +0000 (13:34 -0500)
CQE compressing reduces PCI overhead by coalescing and compressing
multiple CQEs into a single merged CQE. Successful compressing
improves message rate especially for small packet traffic.

CQE compressing is supported for all 64B CQE formats (with certain
limitations) generated by RQ/Responder or by SQ/Requestor.

Signed-off-by: Bodong Wang <bodong@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx5/cq.c
include/uapi/rdma/mlx5-abi.h

index 9e0598b5615f877ba04de247a4a49691e1a3997a..d72a4367c891502bf92274c719d41353fdcc5071 100644 (file)
@@ -731,7 +731,7 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
                          int entries, u32 **cqb,
                          int *cqe_size, int *index, int *inlen)
 {
-       struct mlx5_ib_create_cq ucmd;
+       struct mlx5_ib_create_cq ucmd = {};
        size_t ucmdlen;
        int page_shift;
        __be64 *pas;
@@ -792,8 +792,36 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
 
        *index = to_mucontext(context)->uuari.uars[0].index;
 
+       if (ucmd.cqe_comp_en == 1) {
+               if (unlikely((*cqe_size != 64) ||
+                            !MLX5_CAP_GEN(dev->mdev, cqe_compression))) {
+                       err = -EOPNOTSUPP;
+                       mlx5_ib_warn(dev, "CQE compression is not supported for size %d!\n",
+                                    *cqe_size);
+                       goto err_cqb;
+               }
+
+               if (unlikely(!ucmd.cqe_comp_res_format ||
+                            !(ucmd.cqe_comp_res_format <
+                              MLX5_IB_CQE_RES_RESERVED) ||
+                            (ucmd.cqe_comp_res_format &
+                             (ucmd.cqe_comp_res_format - 1)))) {
+                       err = -EOPNOTSUPP;
+                       mlx5_ib_warn(dev, "CQE compression res format %d is not supported!\n",
+                                    ucmd.cqe_comp_res_format);
+                       goto err_cqb;
+               }
+
+               MLX5_SET(cqc, cqc, cqe_comp_en, 1);
+               MLX5_SET(cqc, cqc, mini_cqe_res_format,
+                        ilog2(ucmd.cqe_comp_res_format));
+       }
+
        return 0;
 
+err_cqb:
+       kfree(cqb);
+
 err_db:
        mlx5_ib_db_unmap_user(to_mucontext(context), &cq->db);
 
index 6649d13a2dbb257e0aed1d54c4bb52fed9a2ed7b..b0a41c8dc1fbcfed57e868d0c6064bc7374150bc 100644 (file)
@@ -149,7 +149,9 @@ struct mlx5_ib_create_cq {
        __u64   buf_addr;
        __u64   db_addr;
        __u32   cqe_size;
-       __u32   reserved; /* explicit padding (optional on i386) */
+       __u8    cqe_comp_en;
+       __u8    cqe_comp_res_format;
+       __u16   reserved; /* explicit padding (optional on i386) */
 };
 
 struct mlx5_ib_create_cq_resp {