]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
mlx4_core: Add helper to move QP to ready-to-send
authorYevgeny Petrilin <yevgenyp@mellanox.co.il>
Fri, 25 Apr 2008 21:52:32 +0000 (14:52 -0700)
committerRoland Dreier <rolandd@cisco.com>
Fri, 25 Apr 2008 21:52:32 +0000 (14:52 -0700)
Avoid duplicating code in ethernet and FC modules.

Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/net/mlx4/qp.c
include/linux/mlx4/qp.h

index fa24e6597591fc0f10ab11158ead02051f884a6d..ee5484c44a1833781887dbbdc42775f5d661bc60 100644 (file)
@@ -299,3 +299,34 @@ 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)
+{
+       int err;
+       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(~(0xf << 28));
+               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);
index a5e43febee4fa550a6a4a9d145ed0c893acd76f8..7f128b266faa39044cc85e4f7175aed51664fe16 100644 (file)
@@ -296,6 +296,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));