IB/mlx5: Exposing modify CQ callback to uverbs layer
authorYonatan Cohen <yonatanc@mellanox.com>
Mon, 13 Nov 2017 08:51:15 +0000 (10:51 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 13 Nov 2017 21:59:22 +0000 (16:59 -0500)
Exposed mlx5_ib_modify_cq to be called from ib device
verb list.

Signed-off-by: Yonatan Cohen <yonatanc@mellanox.com>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx5/cq.c
drivers/infiniband/hw/mlx5/main.c
include/linux/mlx5/cq.h

index 01b218a3c2774b50aed7b83cb7e2aebbb0cb7c28..18705cbcdc8c1788b636424926498f2883a56d5e 100644 (file)
@@ -1149,6 +1149,9 @@ int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
        if (!MLX5_CAP_GEN(dev->mdev, cq_moderation))
                return -ENOSYS;
 
+       if (cq_period > MLX5_MAX_CQ_PERIOD)
+               return -EINVAL;
+
        err = mlx5_core_modify_cq_moderation(dev->mdev, &mcq->mcq,
                                             cq_period, cq_count);
        if (err)
index d2aadb13637b7383c6d6782cef95c8f4b402a924..5a0ed6a499f42ef2ea34ef084963a9c3e9b3724f 100644 (file)
@@ -4022,7 +4022,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
                (1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE)     |
                (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ)        |
                (1ull << IB_USER_VERBS_EX_CMD_CREATE_QP)        |
-               (1ull << IB_USER_VERBS_EX_CMD_MODIFY_QP);
+               (1ull << IB_USER_VERBS_EX_CMD_MODIFY_QP)        |
+               (1ull << IB_USER_VERBS_EX_CMD_MODIFY_CQ);
 
        dev->ib_dev.query_device        = mlx5_ib_query_device;
        dev->ib_dev.query_port          = mlx5_ib_query_port;
index cc718e245b1e269614b6bc9d7693bf419ce21d1c..6be357b219ec7aa83394658fb366eb573959c954 100644 (file)
@@ -128,6 +128,9 @@ enum {
        CQE_SIZE_128_PAD = 2,
 };
 
+#define MLX5_MAX_CQ_PERIOD (BIT(__mlx5_bit_sz(cqc, cq_period)) - 1)
+#define MLX5_MAX_CQ_COUNT (BIT(__mlx5_bit_sz(cqc, cq_max_count)) - 1)
+
 static inline int cqe_sz_to_mlx_sz(u8 size, int padding_128_en)
 {
        return padding_128_en ? CQE_SIZE_128_PAD :