Skip to content

Commit

Permalink
IB/mlx5: Implement modify CQ
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eli Cohen authored and rolandd committed Jan 23, 2014
1 parent ada388f commit 3bdb31f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
26 changes: 25 additions & 1 deletion drivers/infiniband/hw/mlx5/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 15 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions include/linux/mlx5/cq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down
15 changes: 15 additions & 0 deletions include/linux/mlx5/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3bdb31f

Please sign in to comment.