driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I98RAX
--------------------------------------------------------------------------
In the hns_roce_alloc_ucontext() function, the configuration code is too much. Extract this part of the code into the function hns_roce_get_uctx_config() to improve readability.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Juan Zhou zhoujuan51@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_main.c | 56 +++++++++++++---------- 1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 43512aa39..e65310f13 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -451,6 +451,37 @@ static int hns_roce_alloc_reset_entry(struct ib_ucontext *uctx) return 0; }
+static void hns_roce_get_uctx_config(struct hns_roce_dev *hr_dev, + struct hns_roce_ucontext *context, + struct hns_roce_ib_alloc_ucontext *ucmd, + struct hns_roce_ib_alloc_ucontext_resp *resp) +{ + if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) + context->config = ucmd->config & HNS_ROCE_EXSGE_FLAGS; + + if (context->config & HNS_ROCE_EXSGE_FLAGS) { + resp->config |= HNS_ROCE_RSP_EXSGE_FLAGS; + resp->max_inline_data = hr_dev->caps.max_sq_inline; + } + + if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) { + context->config |= ucmd->config & HNS_ROCE_RQ_INLINE_FLAGS; + if (context->config & HNS_ROCE_RQ_INLINE_FLAGS) + resp->config |= HNS_ROCE_RSP_RQ_INLINE_FLAGS; + } + + if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQE_INLINE) { + context->config |= ucmd->config & HNS_ROCE_CQE_INLINE_FLAGS; + if (context->config & HNS_ROCE_CQE_INLINE_FLAGS) + resp->config |= HNS_ROCE_RSP_CQE_INLINE_FLAGS; + } + + if (ucmd->config & HNS_ROCE_UCTX_DYN_QP_PGSZ) { + context->config |= HNS_ROCE_UCTX_DYN_QP_PGSZ; + resp->config |= HNS_ROCE_UCTX_RSP_DYN_QP_PGSZ; + } +} + static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata) { @@ -472,33 +503,10 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx, if (ret) goto error_out;
- if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) - context->config = ucmd.config & HNS_ROCE_EXSGE_FLAGS; - - if (context->config & HNS_ROCE_EXSGE_FLAGS) { - resp.config |= HNS_ROCE_RSP_EXSGE_FLAGS; - resp.max_inline_data = hr_dev->caps.max_sq_inline; - } - - if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) { - context->config |= ucmd.config & HNS_ROCE_RQ_INLINE_FLAGS; - if (context->config & HNS_ROCE_RQ_INLINE_FLAGS) - resp.config |= HNS_ROCE_RSP_RQ_INLINE_FLAGS; - } - - if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQE_INLINE) { - context->config |= ucmd.config & HNS_ROCE_CQE_INLINE_FLAGS; - if (context->config & HNS_ROCE_CQE_INLINE_FLAGS) - resp.config |= HNS_ROCE_RSP_CQE_INLINE_FLAGS; - } - if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) resp.congest_type = hr_dev->caps.cong_cap;
- if (ucmd.config & HNS_ROCE_UCTX_DYN_QP_PGSZ) { - context->config |= HNS_ROCE_UCTX_DYN_QP_PGSZ; - resp.config |= HNS_ROCE_UCTX_RSP_DYN_QP_PGSZ; - } + hns_roce_get_uctx_config(hr_dev, context, &ucmd, &resp);
ret = hns_roce_uar_alloc(hr_dev, &context->uar); if (ret)