Skip to contentSkip to conversation

IB/mlx5: Return failure when rts2rts_qp_counters_set_id is not supported

PATCH Applied Leon Romanovsky 2 participants 2 messages Jan 26, 2020 – Feb 11, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/mlx5: Return failure when rts2rts_qp_counters_set_id is not supported

From: Mark Zhang <[email protected]>

When bind a QP with a counter and the QP state is not RESET, return failure if the rts2rts_qp_counters_set_id is not supported. This is to prevent cases like manual bind for Connect-IB devices from returning success when the feature is not supported.

Fixes d14133dd4161 ("IB/mlx5: Support set qp counter")
---
 drivers/infiniband/hw/mlx5/qp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +6 -3
index a4f8e7030787..957f3a52589b 100644
@@ -3441,9 +3441,6 @@ static int __mlx5_ib_qp_set_counter(struct ib_qp *qp,
 	struct mlx5_ib_qp_base *base;
 	u32 set_id;
 
-	if (!MLX5_CAP_GEN(dev->mdev, rts2rts_qp_counters_set_id))
-		return 0;
-
 	if (counter)
 		set_id = counter->id;
 	else
@@ -6576,6 +6573,7 @@ void mlx5_ib_drain_rq(struct ib_qp *qp)
  */
 int mlx5_ib_qp_set_counter(struct ib_qp *qp, struct rdma_counter *counter)
 {
+	struct mlx5_ib_dev *dev = to_mdev(qp->device);
 	struct mlx5_ib_qp *mqp = to_mqp(qp);
 	int err = 0;
 
@@ -6585,6 +6583,11 @@ int mlx5_ib_qp_set_counter(struct ib_qp *qp, struct rdma_counter *counter)
 		goto out;
 	}
 
+	if (!MLX5_CAP_GEN(dev->mdev, rts2rts_qp_counters_set_id)) {
+		err = -EOPNOTSUPP;
+		goto out;
+	}
+
 	if (mqp->state == IB_QPS_RTS) {
 		err = __mlx5_ib_qp_set_counter(qp, counter);
 		if (!err)

--
2.24.1

#1 lore raw
Quoted 7 lines · Leon Romanovsky

From: Mark Zhang <[email protected]>

When bind a QP with a counter and the QP state is not RESET, return failure if the rts2rts_qp_counters_set_id is not supported. This is to prevent cases like manual bind for Connect-IB devices from returning success when the feature is not supported.

Quoted 7 lines
Fixes d14133dd4161 ("IB/mlx5: Support set qp counter")
---
 drivers/infiniband/hw/mlx5/qp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Applied to for-rc, thanks

Jason