diff mbox series

[for-next,09/10] RDMA/hns: Use the macro instead of qp state transition support

Message ID 1540624524-118822-10-git-send-email-oulijun@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series hns misc updates for 4.20 | expand

Commit Message

Lijun Ou Oct. 27, 2018, 7:15 a.m. UTC
This patch refactors the code of implementing qp state transition.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 16 +---------------
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index e95b947..45ba108 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -3844,21 +3844,7 @@  static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
 					   qpc_mask);
 		if (ret)
 			goto out;
-	} else if ((cur_state == IB_QPS_RTS && new_state == IB_QPS_RTS) ||
-		   (cur_state == IB_QPS_SQE && new_state == IB_QPS_RTS) ||
-		   (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD) ||
-		   (cur_state == IB_QPS_SQD && new_state == IB_QPS_SQD) ||
-		   (cur_state == IB_QPS_SQD && new_state == IB_QPS_RTS) ||
-		   (cur_state == IB_QPS_INIT && new_state == IB_QPS_RESET) ||
-		   (cur_state == IB_QPS_RTR && new_state == IB_QPS_RESET) ||
-		   (cur_state == IB_QPS_RTS && new_state == IB_QPS_RESET) ||
-		   (cur_state == IB_QPS_ERR && new_state == IB_QPS_RESET) ||
-		   (cur_state == IB_QPS_INIT && new_state == IB_QPS_ERR) ||
-		   (cur_state == IB_QPS_RTR && new_state == IB_QPS_ERR) ||
-		   (cur_state == IB_QPS_RTS && new_state == IB_QPS_ERR) ||
-		   (cur_state == IB_QPS_SQD && new_state == IB_QPS_ERR) ||
-		   (cur_state == IB_QPS_SQE && new_state == IB_QPS_ERR) ||
-		   (cur_state == IB_QPS_ERR && new_state == IB_QPS_ERR)) {
+	} else if (V2_QP_SUPPORT_STATE(cur_state, new_state)) {
 		/* Nothing */
 		;
 	} else {
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index e6e3d8fb..7b308ac 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -133,6 +133,25 @@ 
 	(step_idx == 1 && hop_num == 1) || \
 	(step_idx == 2 && hop_num == 2))
 
+#define V2_QP_SUPPORT_STATE(cur_state, new_state) \
+	((cur_state == IB_QPS_RTS && new_state == IB_QPS_RTS) || \
+	(cur_state == IB_QPS_SQE && new_state == IB_QPS_RTS) || \
+	(cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD) || \
+	(cur_state == IB_QPS_SQD && new_state == IB_QPS_SQD) || \
+	(cur_state == IB_QPS_SQD && new_state == IB_QPS_RTS) || \
+	(cur_state == IB_QPS_INIT && new_state == IB_QPS_RESET) || \
+	(cur_state == IB_QPS_RTR && new_state == IB_QPS_RESET) || \
+	(cur_state == IB_QPS_RTS && new_state == IB_QPS_RESET) || \
+	(cur_state == IB_QPS_ERR && new_state == IB_QPS_RESET) || \
+	(cur_state == IB_QPS_SQD && new_state == IB_QPS_RESET) || \
+	(cur_state == IB_QPS_SQE && new_state == IB_QPS_RESET) || \
+	(cur_state == IB_QPS_INIT && new_state == IB_QPS_ERR) || \
+	(cur_state == IB_QPS_RTR && new_state == IB_QPS_ERR) || \
+	(cur_state == IB_QPS_RTS && new_state == IB_QPS_ERR) || \
+	(cur_state == IB_QPS_SQD && new_state == IB_QPS_ERR) || \
+	(cur_state == IB_QPS_SQE && new_state == IB_QPS_ERR) || \
+	(cur_state == IB_QPS_ERR && new_state == IB_QPS_ERR))
+
 #define CMD_CSQ_DESC_NUM		1024
 #define CMD_CRQ_DESC_NUM		1024