aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/mlx4/qp.c31
-rw-r--r--include/linux/mlx4/qp.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c
index fa24e6597591..ee5484c44a18 100644
--- a/drivers/net/mlx4/qp.c
+++ b/drivers/net/mlx4/qp.c
@@ -299,3 +299,34 @@ int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
299} 299}
300EXPORT_SYMBOL_GPL(mlx4_qp_query); 300EXPORT_SYMBOL_GPL(mlx4_qp_query);
301 301
302int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
303 struct mlx4_qp_context *context,
304 struct mlx4_qp *qp, enum mlx4_qp_state *qp_state)
305{
306 int err;
307 int i;
308 enum mlx4_qp_state states[] = {
309 MLX4_QP_STATE_RST,
310 MLX4_QP_STATE_INIT,
311 MLX4_QP_STATE_RTR,
312 MLX4_QP_STATE_RTS
313 };
314
315 for (i = 0; i < ARRAY_SIZE(states) - 1; i++) {
316 context->flags &= cpu_to_be32(~(0xf << 28));
317 context->flags |= cpu_to_be32(states[i + 1] << 28);
318 err = mlx4_qp_modify(dev, mtt, states[i], states[i + 1],
319 context, 0, 0, qp);
320 if (err) {
321 mlx4_err(dev, "Failed to bring QP to state: "
322 "%d with error: %d\n",
323 states[i + 1], err);
324 return err;
325 }
326
327 *qp_state = states[i + 1];
328 }
329
330 return 0;
331}
332EXPORT_SYMBOL_GPL(mlx4_qp_to_ready);
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index a5e43febee4f..7f128b266faa 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -296,6 +296,10 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
296int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp, 296int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
297 struct mlx4_qp_context *context); 297 struct mlx4_qp_context *context);
298 298
299int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
300 struct mlx4_qp_context *context,
301 struct mlx4_qp *qp, enum mlx4_qp_state *qp_state);
302
299static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn) 303static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
300{ 304{
301 return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1)); 305 return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1));