[ofa-general] [PATCH 15 of 17] mlx4: support modify CQ

Eli Cohen eli at mellanox.co.il
Tue Sep 11 08:55:03 PDT 2007


Add support for modifying CQ parameters.

Signed-off-by: Eli Cohen <eli at mellnaox.co.il>

---

Add support for modifying CQ parameters.

Signed-off-by: Eli Cohen <eli at mellnaox.co.il>

---

Index: ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/main.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/hw/mlx4/main.c	2007-09-11 21:15:28.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/main.c	2007-09-11 21:15:30.000000000 +0300
@@ -615,6 +615,7 @@ static void *mlx4_ib_add(struct mlx4_dev
 	ibdev->ib_dev.post_send		= mlx4_ib_post_send;
 	ibdev->ib_dev.post_recv		= mlx4_ib_post_recv;
 	ibdev->ib_dev.create_cq		= mlx4_ib_create_cq;
+	ibdev->ib_dev.modify_cq		= mlx4_ib_modify_cq;
 	ibdev->ib_dev.destroy_cq	= mlx4_ib_destroy_cq;
 	ibdev->ib_dev.poll_cq		= mlx4_ib_poll_cq;
 	ibdev->ib_dev.req_notify_cq	= mlx4_ib_arm_cq;
Index: ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/cq.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/hw/mlx4/cq.c	2007-09-11 21:15:28.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/cq.c	2007-09-11 21:15:30.000000000 +0300
@@ -91,6 +91,25 @@ static struct mlx4_cqe *next_cqe_sw(stru
 	return get_sw_cqe(cq, cq->mcq.cons_index);
 }
 
+int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
+{
+	struct mlx4_ib_cq *mcq = to_mcq(cq);
+	struct mlx4_ib_dev *dev = to_mdev(cq->device);
+	struct mlx4_cq_context *context;
+	int err;
+
+	context = kzalloc(sizeof *context, GFP_KERNEL);
+	if (!context)
+		return -ENOMEM;
+
+	context->cq_period = cpu_to_be16(cq_period);
+	context->cq_max_count = cpu_to_be16(cq_count);
+	err = mlx4_cq_modify(dev->dev, &mcq->mcq, context, 1);
+
+	kfree(context);
+	return err;
+}
+
 struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector,
 				struct ib_ucontext *context,
 				struct ib_udata *udata)
Index: ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/mlx4_ib.h
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/hw/mlx4/mlx4_ib.h	2007-09-11 21:15:08.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/hw/mlx4/mlx4_ib.h	2007-09-11 21:15:30.000000000 +0300
@@ -247,6 +247,7 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct
 				  struct ib_udata *udata);
 int mlx4_ib_dereg_mr(struct ib_mr *mr);
 
+int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
 struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector,
 				struct ib_ucontext *context,
 				struct ib_udata *udata);
Index: ofa_1_3_dev_kernel/drivers/net/mlx4/cq.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/net/mlx4/cq.c	2007-09-11 21:14:34.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/net/mlx4/cq.c	2007-09-11 21:15:30.000000000 +0300
@@ -38,33 +38,11 @@
 #include <linux/hardirq.h>
 
 #include <linux/mlx4/cmd.h>
+#include <linux/mlx4/cq.h>
 
 #include "mlx4.h"
 #include "icm.h"
 
-struct mlx4_cq_context {
-	__be32			flags;
-	u16			reserved1[3];
-	__be16			page_offset;
-	__be32			logsize_usrpage;
-	u8			reserved2;
-	u8			cq_period;
-	u8			reserved3;
-	u8			cq_max_count;
-	u8			reserved4[3];
-	u8			comp_eqn;
-	u8			log_page_size;
-	u8			reserved5[2];
-	u8			mtt_base_addr_h;
-	__be32			mtt_base_addr_l;
-	__be32			last_notified_index;
-	__be32			solicit_producer_index;
-	__be32			consumer_index;
-	__be32			producer_index;
-	u32			reserved6[2];
-	__be64			db_rec_addr;
-};
-
 #define MLX4_CQ_STATUS_OK		( 0 << 28)
 #define MLX4_CQ_STATUS_OVERFLOW		( 9 << 28)
 #define MLX4_CQ_STATUS_WRITE_FAIL	(10 << 28)
@@ -121,6 +99,13 @@ static int mlx4_SW2HW_CQ(struct mlx4_dev
 			MLX4_CMD_TIME_CLASS_A);
 }
 
+static int mlx4_MODIFY_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
+			 int cq_num, u32 opmod)
+{
+	return mlx4_cmd(dev, mailbox->dma, cq_num, opmod, MLX4_CMD_MODIFY_CQ,
+			MLX4_CMD_TIME_CLASS_A);
+}
+
 static int mlx4_HW2SW_CQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
 			 int cq_num)
 {
@@ -206,6 +191,24 @@ err_out:
 }
 EXPORT_SYMBOL_GPL(mlx4_cq_alloc);
 
+int mlx4_cq_modify(struct mlx4_dev *dev, struct mlx4_cq *cq,
+		   struct mlx4_cq_context *context, int modify)
+{
+	struct mlx4_cmd_mailbox *mailbox;
+	int err;
+
+	mailbox = mlx4_alloc_cmd_mailbox(dev);
+	if (IS_ERR(mailbox))
+		return PTR_ERR(mailbox);
+
+	memcpy(mailbox->buf, context, sizeof *context);
+	err = mlx4_MODIFY_CQ(dev, mailbox, cq->cqn, modify);
+
+	mlx4_free_cmd_mailbox(dev, mailbox);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx4_cq_modify);
+
 void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq)
 {
 	struct mlx4_priv *priv = mlx4_priv(dev);
Index: ofa_1_3_dev_kernel/include/linux/mlx4/cq.h
===================================================================
--- ofa_1_3_dev_kernel.orig/include/linux/mlx4/cq.h	2007-09-11 21:15:26.000000000 +0300
+++ ofa_1_3_dev_kernel/include/linux/mlx4/cq.h	2007-09-11 21:15:30.000000000 +0300
@@ -38,6 +38,27 @@
 #include <linux/mlx4/device.h>
 #include <linux/mlx4/doorbell.h>
 
+struct mlx4_cq_context {
+	__be32			flags;
+	u16			reserved1[3];
+	__be16			page_offset;
+	__be32			logsize_usrpage;
+	u16			cq_period;
+	u16			cq_max_count;
+	u8			reserved4[3];
+	u8			comp_eqn;
+	u8			log_page_size;
+	u8			reserved5[2];
+	u8			mtt_base_addr_h;
+	__be32			mtt_base_addr_l;
+	__be32			last_notified_index;
+	__be32			solicit_producer_index;
+	__be32			consumer_index;
+	__be32			producer_index;
+	u32			reserved6[2];
+	__be64			db_rec_addr;
+};
+
 struct mlx4_cqe {
 	__be32			my_qpn;
 	__be32			immed_rss_invalid;
@@ -120,4 +141,8 @@ enum {
 	MLX4_CQ_DB_REQ_NOT		= 2 << 24
 };
 
+
+int mlx4_cq_modify(struct mlx4_dev *dev, struct mlx4_cq *cq,
+		   struct mlx4_cq_context *context, int resize);
+
 #endif /* MLX4_CQ_H */
Index: ofa_1_3_dev_kernel/include/linux/mlx4/cmd.h
===================================================================
--- ofa_1_3_dev_kernel.orig/include/linux/mlx4/cmd.h	2007-09-11 21:14:34.000000000 +0300
+++ ofa_1_3_dev_kernel/include/linux/mlx4/cmd.h	2007-09-11 21:15:30.000000000 +0300
@@ -81,7 +81,7 @@ enum {
 	MLX4_CMD_SW2HW_CQ	 = 0x16,
 	MLX4_CMD_HW2SW_CQ	 = 0x17,
 	MLX4_CMD_QUERY_CQ	 = 0x18,
-	MLX4_CMD_RESIZE_CQ	 = 0x2c,
+	MLX4_CMD_MODIFY_CQ	 = 0x2c,
 
 	/* SRQ commands */
 	MLX4_CMD_SW2HW_SRQ	 = 0x35,




More information about the general mailing list