mlx4: Update/add Mellanox Technologies copyright lines to mlx4 driver files
[linux-block.git] / drivers / net / mlx4 / qp.c
index fa24e6597591fc0f10ab11158ead02051f884a6d..c49a86044bf7bec2c53d77264164e0c5e223e005 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
  * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -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);