Commit a3de9e83 authored by Lang Cheng's avatar Lang Cheng Committed by Jason Gunthorpe

RDMA/hns: Simplify the qp state convert code

Use type map table to reduce the cyclomatic complexity.

Link: https://lore.kernel.org/r/1586938475-37049-4-git-send-email-liweihang@huawei.comSigned-off-by: default avatarLang Cheng <chenglang@huawei.com>
Signed-off-by: default avatarWeihang Li <liweihang@huawei.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 375898e8
......@@ -4539,19 +4539,20 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
return ret;
}
static inline enum ib_qp_state to_ib_qp_st(enum hns_roce_v2_qp_state state)
{
switch (state) {
case HNS_ROCE_QP_ST_RST: return IB_QPS_RESET;
case HNS_ROCE_QP_ST_INIT: return IB_QPS_INIT;
case HNS_ROCE_QP_ST_RTR: return IB_QPS_RTR;
case HNS_ROCE_QP_ST_RTS: return IB_QPS_RTS;
case HNS_ROCE_QP_ST_SQ_DRAINING:
case HNS_ROCE_QP_ST_SQD: return IB_QPS_SQD;
case HNS_ROCE_QP_ST_SQER: return IB_QPS_SQE;
case HNS_ROCE_QP_ST_ERR: return IB_QPS_ERR;
default: return -1;
}
static int to_ib_qp_st(enum hns_roce_v2_qp_state state)
{
static const enum ib_qp_state map[] = {
[HNS_ROCE_QP_ST_RST] = IB_QPS_RESET,
[HNS_ROCE_QP_ST_INIT] = IB_QPS_INIT,
[HNS_ROCE_QP_ST_RTR] = IB_QPS_RTR,
[HNS_ROCE_QP_ST_RTS] = IB_QPS_RTS,
[HNS_ROCE_QP_ST_SQD] = IB_QPS_SQD,
[HNS_ROCE_QP_ST_SQER] = IB_QPS_SQE,
[HNS_ROCE_QP_ST_ERR] = IB_QPS_ERR,
[HNS_ROCE_QP_ST_SQ_DRAINING] = IB_QPS_SQD
};
return (state < ARRAY_SIZE(map)) ? map[state] : -1;
}
static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment