aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx5/qp.c
diff options
context:
space:
mode:
authorSaeed Mahameed <saeedm@mellanox.com>2016-07-19 11:03:21 -0400
committerLeon Romanovsky <leon@kernel.org>2016-08-17 10:45:58 -0400
commit1a412fb1caa2c1b77719ccb5ed8b0c3c2bc65da7 (patch)
tree3932dca111e30df6cebae0a31679cddff00ce06e /drivers/infiniband/hw/mlx5/qp.c
parent09a7d9eca1a6cf5eb4f9abfdf8914db9dbd96f08 (diff)
{net,IB}/mlx5: Modify QP commands via mlx5 ifc
Prior to this patch we assumed that modify QP commands have the same layout. In ConnectX-4 for each QP transition there is a specific command and their layout can vary. e.g: 2err/2rst commands don't have QP context in their layout and before this patch we posted the QP context in those commands. Fortunately the FW only checks the suffix of the commands and executes them, while ignoring all invalid data sent after the valid command layout. This patch removes mlx5_modify_qp_mbox_in and changes mlx5_core_qp_modify to receive the required transition and QP context with opt_param_mask if needed. This way the caller is not required to provide the command inbox layout and it will be generated automatically. mlx5_core_qp_modify will generate the command inbox/outbox layouts according to the requested transition and will fill the requested parameters. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/qp.c')
-rw-r--r--drivers/infiniband/hw/mlx5/qp.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index d22492ff863e..626173736749 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1871,7 +1871,6 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
1871{ 1871{
1872 struct mlx5_ib_cq *send_cq, *recv_cq; 1872 struct mlx5_ib_cq *send_cq, *recv_cq;
1873 struct mlx5_ib_qp_base *base = &qp->trans_qp.base; 1873 struct mlx5_ib_qp_base *base = &qp->trans_qp.base;
1874 struct mlx5_modify_qp_mbox_in *in;
1875 unsigned long flags; 1874 unsigned long flags;
1876 int err; 1875 int err;
1877 1876
@@ -1884,16 +1883,12 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
1884 &qp->raw_packet_qp.rq.base : 1883 &qp->raw_packet_qp.rq.base :
1885 &qp->trans_qp.base; 1884 &qp->trans_qp.base;
1886 1885
1887 in = kzalloc(sizeof(*in), GFP_KERNEL);
1888 if (!in)
1889 return;
1890
1891 if (qp->state != IB_QPS_RESET) { 1886 if (qp->state != IB_QPS_RESET) {
1892 if (qp->ibqp.qp_type != IB_QPT_RAW_PACKET) { 1887 if (qp->ibqp.qp_type != IB_QPT_RAW_PACKET) {
1893 mlx5_ib_qp_disable_pagefaults(qp); 1888 mlx5_ib_qp_disable_pagefaults(qp);
1894 err = mlx5_core_qp_modify(dev->mdev, 1889 err = mlx5_core_qp_modify(dev->mdev,
1895 MLX5_CMD_OP_2RST_QP, in, 0, 1890 MLX5_CMD_OP_2RST_QP, 0,
1896 &base->mqp); 1891 NULL, &base->mqp);
1897 } else { 1892 } else {
1898 err = modify_raw_packet_qp(dev, qp, 1893 err = modify_raw_packet_qp(dev, qp,
1899 MLX5_CMD_OP_2RST_QP); 1894 MLX5_CMD_OP_2RST_QP);
@@ -1935,8 +1930,6 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
1935 base->mqp.qpn); 1930 base->mqp.qpn);
1936 } 1931 }
1937 1932
1938 kfree(in);
1939
1940 if (qp->create_type == MLX5_QP_KERNEL) 1933 if (qp->create_type == MLX5_QP_KERNEL)
1941 destroy_qp_kernel(dev, qp); 1934 destroy_qp_kernel(dev, qp);
1942 else if (qp->create_type == MLX5_QP_USER) 1935 else if (qp->create_type == MLX5_QP_USER)
@@ -2522,7 +2515,6 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
2522 struct mlx5_ib_qp_base *base = &qp->trans_qp.base; 2515 struct mlx5_ib_qp_base *base = &qp->trans_qp.base;
2523 struct mlx5_ib_cq *send_cq, *recv_cq; 2516 struct mlx5_ib_cq *send_cq, *recv_cq;
2524 struct mlx5_qp_context *context; 2517 struct mlx5_qp_context *context;
2525 struct mlx5_modify_qp_mbox_in *in;
2526 struct mlx5_ib_pd *pd; 2518 struct mlx5_ib_pd *pd;
2527 enum mlx5_qp_state mlx5_cur, mlx5_new; 2519 enum mlx5_qp_state mlx5_cur, mlx5_new;
2528 enum mlx5_qp_optpar optpar; 2520 enum mlx5_qp_optpar optpar;
@@ -2531,11 +2523,10 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
2531 int err; 2523 int err;
2532 u16 op; 2524 u16 op;
2533 2525
2534 in = kzalloc(sizeof(*in), GFP_KERNEL); 2526 context = kzalloc(sizeof(*context), GFP_KERNEL);
2535 if (!in) 2527 if (!context)
2536 return -ENOMEM; 2528 return -ENOMEM;
2537 2529
2538 context = &in->ctx;
2539 err = to_mlx5_st(ibqp->qp_type); 2530 err = to_mlx5_st(ibqp->qp_type);
2540 if (err < 0) { 2531 if (err < 0) {
2541 mlx5_ib_dbg(dev, "unsupported qp type %d\n", ibqp->qp_type); 2532 mlx5_ib_dbg(dev, "unsupported qp type %d\n", ibqp->qp_type);
@@ -2700,12 +2691,11 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
2700 op = optab[mlx5_cur][mlx5_new]; 2691 op = optab[mlx5_cur][mlx5_new];
2701 optpar = ib_mask_to_mlx5_opt(attr_mask); 2692 optpar = ib_mask_to_mlx5_opt(attr_mask);
2702 optpar &= opt_mask[mlx5_cur][mlx5_new][mlx5_st]; 2693 optpar &= opt_mask[mlx5_cur][mlx5_new][mlx5_st];
2703 in->optparam = cpu_to_be32(optpar);
2704 2694
2705 if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) 2695 if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET)
2706 err = modify_raw_packet_qp(dev, qp, op); 2696 err = modify_raw_packet_qp(dev, qp, op);
2707 else 2697 else
2708 err = mlx5_core_qp_modify(dev->mdev, op, in, sqd_event, 2698 err = mlx5_core_qp_modify(dev->mdev, op, optpar, context,
2709 &base->mqp); 2699 &base->mqp);
2710 if (err) 2700 if (err)
2711 goto out; 2701 goto out;
@@ -2746,7 +2736,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
2746 } 2736 }
2747 2737
2748out: 2738out:
2749 kfree(in); 2739 kfree(context);
2750 return err; 2740 return err;
2751} 2741}
2752 2742