Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/mlx4: Add support for modifying CQ moderation parameters

Signed-off-by: Eli Cohen <eli@mellnaox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Eli Cohen and committed by
Roland Dreier
3fdcb97f 28d52b3c

+51 -8
+8
drivers/infiniband/hw/mlx4/cq.c
··· 85 85 return get_sw_cqe(cq, cq->mcq.cons_index); 86 86 } 87 87 88 + int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period) 89 + { 90 + struct mlx4_ib_cq *mcq = to_mcq(cq); 91 + struct mlx4_ib_dev *dev = to_mdev(cq->device); 92 + 93 + return mlx4_cq_modify(dev->dev, &mcq->mcq, cq_count, cq_period); 94 + } 95 + 88 96 struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector, 89 97 struct ib_ucontext *context, 90 98 struct ib_udata *udata)
+1
drivers/infiniband/hw/mlx4/main.c
··· 609 609 ibdev->ib_dev.post_send = mlx4_ib_post_send; 610 610 ibdev->ib_dev.post_recv = mlx4_ib_post_recv; 611 611 ibdev->ib_dev.create_cq = mlx4_ib_create_cq; 612 + ibdev->ib_dev.modify_cq = mlx4_ib_modify_cq; 612 613 ibdev->ib_dev.destroy_cq = mlx4_ib_destroy_cq; 613 614 ibdev->ib_dev.poll_cq = mlx4_ib_poll_cq; 614 615 ibdev->ib_dev.req_notify_cq = mlx4_ib_arm_cq;
+1
drivers/infiniband/hw/mlx4/mlx4_ib.h
··· 254 254 struct ib_udata *udata); 255 255 int mlx4_ib_dereg_mr(struct ib_mr *mr); 256 256 257 + int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); 257 258 struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector, 258 259 struct ib_ucontext *context, 259 260 struct ib_udata *udata);
+37 -7
drivers/net/mlx4/cq.c
··· 38 38 #include <linux/hardirq.h> 39 39 40 40 #include <linux/mlx4/cmd.h> 41 + #include <linux/mlx4/cq.h> 41 42 42 43 #include "mlx4.h" 43 44 #include "icm.h" ··· 48 47 u16 reserved1[3]; 49 48 __be16 page_offset; 50 49 __be32 logsize_usrpage; 51 - u8 reserved2; 52 - u8 cq_period; 53 - u8 reserved3; 54 - u8 cq_max_count; 55 - u8 reserved4[3]; 50 + __be16 cq_period; 51 + __be16 cq_max_count; 52 + u8 reserved2[3]; 56 53 u8 comp_eqn; 57 54 u8 log_page_size; 58 - u8 reserved5[2]; 55 + u8 reserved3[2]; 59 56 u8 mtt_base_addr_h; 60 57 __be32 mtt_base_addr_l; 61 58 __be32 last_notified_index; 62 59 __be32 solicit_producer_index; 63 60 __be32 consumer_index; 64 61 __be32 producer_index; 65 - u32 reserved6[2]; 62 + u32 reserved4[2]; 66 63 __be64 db_rec_addr; 67 64 }; 68 65 ··· 120 121 MLX4_CMD_TIME_CLASS_A); 121 122 } 122 123 124 + static int mlx4_MODIFY_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 125 + int cq_num, u32 opmod) 126 + { 127 + return mlx4_cmd(dev, mailbox->dma, cq_num, opmod, MLX4_CMD_MODIFY_CQ, 128 + MLX4_CMD_TIME_CLASS_A); 129 + } 130 + 123 131 static int mlx4_HW2SW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 124 132 int cq_num) 125 133 { ··· 134 128 mailbox ? 0 : 1, MLX4_CMD_HW2SW_CQ, 135 129 MLX4_CMD_TIME_CLASS_A); 136 130 } 131 + 132 + int mlx4_cq_modify(struct mlx4_dev *dev, struct mlx4_cq *cq, 133 + u16 count, u16 period) 134 + { 135 + struct mlx4_cmd_mailbox *mailbox; 136 + struct mlx4_cq_context *cq_context; 137 + int err; 138 + 139 + mailbox = mlx4_alloc_cmd_mailbox(dev); 140 + if (IS_ERR(mailbox)) 141 + return PTR_ERR(mailbox); 142 + 143 + cq_context = mailbox->buf; 144 + memset(cq_context, 0, sizeof *cq_context); 145 + 146 + cq_context->cq_max_count = cpu_to_be16(count); 147 + cq_context->cq_period = cpu_to_be16(period); 148 + 149 + err = mlx4_MODIFY_CQ(dev, mailbox, cq->cqn, 1); 150 + 151 + mlx4_free_cmd_mailbox(dev, mailbox); 152 + return err; 153 + } 154 + EXPORT_SYMBOL_GPL(mlx4_cq_modify); 137 155 138 156 int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, 139 157 struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq)
+1 -1
include/linux/mlx4/cmd.h
··· 81 81 MLX4_CMD_SW2HW_CQ = 0x16, 82 82 MLX4_CMD_HW2SW_CQ = 0x17, 83 83 MLX4_CMD_QUERY_CQ = 0x18, 84 - MLX4_CMD_RESIZE_CQ = 0x2c, 84 + MLX4_CMD_MODIFY_CQ = 0x2c, 85 85 86 86 /* SRQ commands */ 87 87 MLX4_CMD_SW2HW_SRQ = 0x35,
+3
include/linux/mlx4/cq.h
··· 130 130 MLX4_CQ_DB_REQ_NOT = 2 << 24 131 131 }; 132 132 133 + int mlx4_cq_modify(struct mlx4_dev *dev, struct mlx4_cq *cq, 134 + u16 count, u16 period); 135 + 133 136 #endif /* MLX4_CQ_H */