]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/mlx5: Implement modify CQ
authorEli Cohen <eli@dev.mellanox.co.il>
Tue, 14 Jan 2014 15:45:17 +0000 (17:45 +0200)
committerRoland Dreier <roland@purestorage.com>
Thu, 23 Jan 2014 07:23:49 +0000 (23:23 -0800)
Modify CQ is used by ULPs like IPoIB to change moderation parameters.  This
patch adds support in mlx5.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/mlx5/cq.c
drivers/net/ethernet/mellanox/mlx5/core/cq.c
include/linux/mlx5/cq.h
include/linux/mlx5/device.h

index b726274297458e2de91b2c324881f2f83dababf6..b4c122eab484f1bb7f1025e2c7defa0cec80d957 100644 (file)
@@ -818,7 +818,31 @@ void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq)
 
 int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
 {
-       return -ENOSYS;
+       struct mlx5_modify_cq_mbox_in *in;
+       struct mlx5_ib_dev *dev = to_mdev(cq->device);
+       struct mlx5_ib_cq *mcq = to_mcq(cq);
+       int err;
+       u32 fsel;
+
+       if (!(dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_CQ_MODER))
+               return -ENOSYS;
+
+       in = kzalloc(sizeof(*in), GFP_KERNEL);
+       if (!in)
+               return -ENOMEM;
+
+       in->cqn = cpu_to_be32(mcq->mcq.cqn);
+       fsel = (MLX5_CQ_MODIFY_PERIOD | MLX5_CQ_MODIFY_COUNT);
+       in->ctx.cq_period = cpu_to_be16(cq_period);
+       in->ctx.cq_max_count = cpu_to_be16(cq_count);
+       in->field_select = cpu_to_be32(fsel);
+       err = mlx5_core_modify_cq(&dev->mdev, &mcq->mcq, in);
+       kfree(in);
+
+       if (err)
+               mlx5_ib_warn(dev, "modify cq 0x%x failed\n", mcq->mcq.cqn);
+
+       return err;
 }
 
 int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
index c2d660be6f769e6877f3ccf2748c687ef0aa96bd..e6fedcf9418273da9d7a0e75b6f39ce861ba6570 100644 (file)
@@ -201,10 +201,23 @@ EXPORT_SYMBOL(mlx5_core_query_cq);
 
 
 int mlx5_core_modify_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
-                       int type, struct mlx5_cq_modify_params *params)
+                       struct mlx5_modify_cq_mbox_in *in)
 {
-       return -ENOSYS;
+       struct mlx5_modify_cq_mbox_out out;
+       int err;
+
+       memset(&out, 0, sizeof(out));
+       in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MODIFY_CQ);
+       err = mlx5_cmd_exec(dev, in, sizeof(*in), &out, sizeof(out));
+       if (err)
+               return err;
+
+       if (out.hdr.status)
+               return mlx5_cmd_status_to_err(&out.hdr);
+
+       return 0;
 }
+EXPORT_SYMBOL(mlx5_core_modify_cq);
 
 int mlx5_init_cq_table(struct mlx5_core_dev *dev)
 {
index 3db67f73d96df125941486a208c176fda78c35bd..c3cf5a46abced3fd72cd53ef8947e08e1a58532f 100644 (file)
@@ -85,9 +85,9 @@ enum {
 };
 
 enum {
-       MLX5_CQ_MODIFY_RESEIZE = 0,
-       MLX5_CQ_MODIFY_MODER = 1,
-       MLX5_CQ_MODIFY_MAPPING = 2,
+       MLX5_CQ_MODIFY_PERIOD   = 1 << 0,
+       MLX5_CQ_MODIFY_COUNT    = 1 << 1,
+       MLX5_CQ_MODIFY_OVERRUN  = 1 << 2,
 };
 
 struct mlx5_cq_modify_params {
@@ -158,7 +158,7 @@ int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq);
 int mlx5_core_query_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
                       struct mlx5_query_cq_mbox_out *out);
 int mlx5_core_modify_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
-                       int type, struct mlx5_cq_modify_params *params);
+                       struct mlx5_modify_cq_mbox_in *in);
 int mlx5_debug_cq_add(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq);
 void mlx5_debug_cq_remove(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq);
 
index 2c1c62e339caad1a109b10c9f933227005ea9bf9..dbb03caa8aed7e5fac2fcf0d3efd398063d2a91a 100644 (file)
@@ -177,6 +177,7 @@ enum {
        MLX5_DEV_CAP_FLAG_APM           = 1LL << 17,
        MLX5_DEV_CAP_FLAG_ATOMIC        = 1LL << 18,
        MLX5_DEV_CAP_FLAG_ON_DMND_PG    = 1LL << 24,
+       MLX5_DEV_CAP_FLAG_CQ_MODER      = 1LL << 29,
        MLX5_DEV_CAP_FLAG_RESIZE_SRQ    = 1LL << 32,
        MLX5_DEV_CAP_FLAG_REMOTE_FENCE  = 1LL << 38,
        MLX5_DEV_CAP_FLAG_TLP_HINTS     = 1LL << 39,
@@ -698,6 +699,19 @@ struct mlx5_query_cq_mbox_out {
        __be64                  pas[0];
 };
 
+struct mlx5_modify_cq_mbox_in {
+       struct mlx5_inbox_hdr   hdr;
+       __be32                  cqn;
+       __be32                  field_select;
+       struct mlx5_cq_context  ctx;
+       u8                      rsvd[192];
+       __be64                  pas[0];
+};
+
+struct mlx5_modify_cq_mbox_out {
+       struct mlx5_outbox_hdr  hdr;
+};
+
 struct mlx5_enable_hca_mbox_in {
        struct mlx5_inbox_hdr   hdr;
        u8                      rsvd[8];
@@ -872,6 +886,7 @@ struct mlx5_modify_mkey_mbox_in {
 
 struct mlx5_modify_mkey_mbox_out {
        struct mlx5_outbox_hdr  hdr;
+       u8                      rsvd[8];
 };
 
 struct mlx5_dump_mkey_mbox_in {