[ofa-general][PATCH 12/12 v1] mlx4: QP to ready

Yevgeny Petrilin yevgenyp at mellanox.co.il
Wed Apr 23 08:11:25 PDT 2008


>From eda80652876695342a68fd2e47d45d1c57d8b511 Mon Sep 17 00:00:00 2001
From: Yevgeny Petrilin <yevgenyp at mellanox.co.il>
Date: Wed, 23 Apr 2008 16:20:42 +0300
Subject: [PATCH] mlx4: Qp to ready

Added API to bring a QP from Reset to RTS state.

Signed-off-by: Yevgeny Petrilin <yevgenyp at mellanox.co.il>
---
 drivers/net/mlx4/qp.c   |   30 ++++++++++++++++++++++++++++++
 include/linux/mlx4/qp.h |    4 ++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c
index 2d5be15..a6ed9ca 100644
--- a/drivers/net/mlx4/qp.c
+++ b/drivers/net/mlx4/qp.c
@@ -366,3 +366,33 @@ int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
 }
 EXPORT_SYMBOL_GPL(mlx4_qp_query);

+int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
+		     struct mlx4_qp_context *context,
+		     struct mlx4_qp *qp, enum mlx4_qp_state *qp_state)
+{
+#define CLEAR_STATE_MASK 0xfffffff
+	int err = 0;
+	int i;
+	enum mlx4_qp_state states[] = {
+		MLX4_QP_STATE_RST,
+		MLX4_QP_STATE_INIT,
+		MLX4_QP_STATE_RTR,
+		MLX4_QP_STATE_RTS
+	};
+
+	for (i = 0; i < ARRAY_SIZE(states) - 1; i++) {
+		context->flags &= cpu_to_be32(CLEAR_STATE_MASK);
+		context->flags |= cpu_to_be32(states[i+1] << 28);
+		err = mlx4_qp_modify(dev, mtt, states[i],
+				     states[i+1], context, 0, 0, qp);
+		if (err) {
+			mlx4_err(dev, "Failed to bring qp to state:"
+				      "%d with error: %d\n",
+					states[i+1], err);
+			return err;
+		}
+		*qp_state = states[i+1];
+	}
+	return 0;
+}
+EXPORT_SYMBOL_GPL(mlx4_qp_to_ready);
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index d7c0227..96b0e1b 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -305,6 +305,10 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
 int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
 		  struct mlx4_qp_context *context);

+int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
+		     struct mlx4_qp_context *context,
+		     struct mlx4_qp *qp, enum mlx4_qp_state *qp_state);
+
 static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
 {
 	return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1));
-- 
1.5.4




More information about the general mailing list