Commit 07d5ce14 authored by Kalesh AP's avatar Kalesh AP Committed by Jason Gunthorpe

RDMA/bnxt_re: Return directly without goto jumps

When there is no cleanup to be done, return directly.  This will help
eliminating unnecessary local variables and goto labels.  This patch fixes
such occurrences in qplib_fp.c file.

Fixes: 37cb11ac ("RDMA/bnxt_re: Add SRQ support for Broadcom adapters")
Fixes: 159fb4ce ("RDMA/bnxt_re: introduce a function to allocate swq")
Link: https://lore.kernel.org/r/1684478897-12247-7-git-send-email-selvin.xavier@broadcom.comSigned-off-by: default avatarKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: default avatarSelvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 43774bc1
...@@ -483,7 +483,6 @@ static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt) ...@@ -483,7 +483,6 @@ static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt)
resource_size_t reg_base; resource_size_t reg_base;
struct bnxt_qplib_nq_db *nq_db; struct bnxt_qplib_nq_db *nq_db;
struct pci_dev *pdev; struct pci_dev *pdev;
int rc = 0;
pdev = nq->pdev; pdev = nq->pdev;
nq_db = &nq->nq_db; nq_db = &nq->nq_db;
...@@ -493,8 +492,7 @@ static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt) ...@@ -493,8 +492,7 @@ static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt)
if (!nq_db->reg.bar_base) { if (!nq_db->reg.bar_base) {
dev_err(&pdev->dev, "QPLIB: NQ BAR region %d resc start is 0!", dev_err(&pdev->dev, "QPLIB: NQ BAR region %d resc start is 0!",
nq_db->reg.bar_id); nq_db->reg.bar_id);
rc = -ENOMEM; return -ENOMEM;
goto fail;
} }
reg_base = nq_db->reg.bar_base + reg_offt; reg_base = nq_db->reg.bar_base + reg_offt;
...@@ -504,15 +502,14 @@ static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt) ...@@ -504,15 +502,14 @@ static int bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq, u32 reg_offt)
if (!nq_db->reg.bar_reg) { if (!nq_db->reg.bar_reg) {
dev_err(&pdev->dev, "QPLIB: NQ BAR region %d mapping failed", dev_err(&pdev->dev, "QPLIB: NQ BAR region %d mapping failed",
nq_db->reg.bar_id); nq_db->reg.bar_id);
rc = -ENOMEM; return -ENOMEM;
goto fail;
} }
nq_db->dbinfo.db = nq_db->reg.bar_reg; nq_db->dbinfo.db = nq_db->reg.bar_reg;
nq_db->dbinfo.hwq = &nq->hwq; nq_db->dbinfo.hwq = &nq->hwq;
nq_db->dbinfo.xid = nq->ring_id; nq_db->dbinfo.xid = nq->ring_id;
fail:
return rc; return 0;
} }
int bnxt_qplib_enable_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq, int bnxt_qplib_enable_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq,
...@@ -626,7 +623,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res, ...@@ -626,7 +623,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
hwq_attr.type = HWQ_TYPE_QUEUE; hwq_attr.type = HWQ_TYPE_QUEUE;
rc = bnxt_qplib_alloc_init_hwq(&srq->hwq, &hwq_attr); rc = bnxt_qplib_alloc_init_hwq(&srq->hwq, &hwq_attr);
if (rc) if (rc)
goto exit; return rc;
srq->swq = kcalloc(srq->hwq.max_elements, sizeof(*srq->swq), srq->swq = kcalloc(srq->hwq.max_elements, sizeof(*srq->swq),
GFP_KERNEL); GFP_KERNEL);
...@@ -680,7 +677,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res, ...@@ -680,7 +677,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
fail: fail:
bnxt_qplib_free_hwq(res, &srq->hwq); bnxt_qplib_free_hwq(res, &srq->hwq);
kfree(srq->swq); kfree(srq->swq);
exit:
return rc; return rc;
} }
...@@ -744,15 +741,14 @@ int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq, ...@@ -744,15 +741,14 @@ int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
struct rq_wqe *srqe; struct rq_wqe *srqe;
struct sq_sge *hw_sge; struct sq_sge *hw_sge;
u32 sw_prod, sw_cons, count = 0; u32 sw_prod, sw_cons, count = 0;
int i, rc = 0, next; int i, next;
spin_lock(&srq_hwq->lock); spin_lock(&srq_hwq->lock);
if (srq->start_idx == srq->last_idx) { if (srq->start_idx == srq->last_idx) {
dev_err(&srq_hwq->pdev->dev, dev_err(&srq_hwq->pdev->dev,
"FP: SRQ (0x%x) is full!\n", srq->id); "FP: SRQ (0x%x) is full!\n", srq->id);
rc = -EINVAL;
spin_unlock(&srq_hwq->lock); spin_unlock(&srq_hwq->lock);
goto done; return -EINVAL;
} }
next = srq->start_idx; next = srq->start_idx;
srq->start_idx = srq->swq[next].next_idx; srq->start_idx = srq->swq[next].next_idx;
...@@ -793,22 +789,19 @@ int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq, ...@@ -793,22 +789,19 @@ int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
srq->arm_req = false; srq->arm_req = false;
bnxt_qplib_srq_arm_db(&srq->dbinfo, srq->threshold); bnxt_qplib_srq_arm_db(&srq->dbinfo, srq->threshold);
} }
done:
return rc; return 0;
} }
/* QP */ /* QP */
static int bnxt_qplib_alloc_init_swq(struct bnxt_qplib_q *que) static int bnxt_qplib_alloc_init_swq(struct bnxt_qplib_q *que)
{ {
int rc = 0;
int indx; int indx;
que->swq = kcalloc(que->max_wqe, sizeof(*que->swq), GFP_KERNEL); que->swq = kcalloc(que->max_wqe, sizeof(*que->swq), GFP_KERNEL);
if (!que->swq) { if (!que->swq)
rc = -ENOMEM; return -ENOMEM;
goto out;
}
que->swq_start = 0; que->swq_start = 0;
que->swq_last = que->max_wqe - 1; que->swq_last = que->max_wqe - 1;
...@@ -816,8 +809,8 @@ static int bnxt_qplib_alloc_init_swq(struct bnxt_qplib_q *que) ...@@ -816,8 +809,8 @@ static int bnxt_qplib_alloc_init_swq(struct bnxt_qplib_q *que)
que->swq[indx].next_idx = indx + 1; que->swq[indx].next_idx = indx + 1;
que->swq[que->swq_last].next_idx = 0; /* Make it circular */ que->swq[que->swq_last].next_idx = 0; /* Make it circular */
que->swq_last = 0; que->swq_last = 0;
out:
return rc; return 0;
} }
int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
...@@ -851,7 +844,7 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) ...@@ -851,7 +844,7 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
hwq_attr.type = HWQ_TYPE_QUEUE; hwq_attr.type = HWQ_TYPE_QUEUE;
rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr); rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
if (rc) if (rc)
goto exit; return rc;
rc = bnxt_qplib_alloc_init_swq(sq); rc = bnxt_qplib_alloc_init_swq(sq);
if (rc) if (rc)
...@@ -939,7 +932,6 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) ...@@ -939,7 +932,6 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
kfree(sq->swq); kfree(sq->swq);
fail_sq: fail_sq:
bnxt_qplib_free_hwq(res, &sq->hwq); bnxt_qplib_free_hwq(res, &sq->hwq);
exit:
return rc; return rc;
} }
...@@ -1004,7 +996,7 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) ...@@ -1004,7 +996,7 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
hwq_attr.type = HWQ_TYPE_QUEUE; hwq_attr.type = HWQ_TYPE_QUEUE;
rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr); rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
if (rc) if (rc)
goto exit; return rc;
rc = bnxt_qplib_alloc_init_swq(sq); rc = bnxt_qplib_alloc_init_swq(sq);
if (rc) if (rc)
...@@ -1152,7 +1144,6 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) ...@@ -1152,7 +1144,6 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
kfree(sq->swq); kfree(sq->swq);
fail_sq: fail_sq:
bnxt_qplib_free_hwq(res, &sq->hwq); bnxt_qplib_free_hwq(res, &sq->hwq);
exit:
return rc; return rc;
} }
...@@ -2513,7 +2504,6 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq, ...@@ -2513,7 +2504,6 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
struct bnxt_qplib_qp *qp; struct bnxt_qplib_qp *qp;
struct bnxt_qplib_q *rq; struct bnxt_qplib_q *rq;
u32 wr_id_idx; u32 wr_id_idx;
int rc = 0;
qp = (struct bnxt_qplib_qp *)((unsigned long) qp = (struct bnxt_qplib_qp *)((unsigned long)
le64_to_cpu(hwcqe->qp_handle)); le64_to_cpu(hwcqe->qp_handle));
...@@ -2524,7 +2514,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq, ...@@ -2524,7 +2514,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
if (qp->rq.flushed) { if (qp->rq.flushed) {
dev_dbg(&cq->hwq.pdev->dev, dev_dbg(&cq->hwq.pdev->dev,
"%s: QP in Flush QP = %p\n", __func__, qp); "%s: QP in Flush QP = %p\n", __func__, qp);
goto done; return 0;
} }
cqe = *pcqe; cqe = *pcqe;
...@@ -2580,8 +2570,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq, ...@@ -2580,8 +2570,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
} }
} }
done: return 0;
return rc;
} }
static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
...@@ -2594,7 +2583,6 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, ...@@ -2594,7 +2583,6 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
struct bnxt_qplib_qp *qp; struct bnxt_qplib_qp *qp;
struct bnxt_qplib_q *rq; struct bnxt_qplib_q *rq;
u32 wr_id_idx; u32 wr_id_idx;
int rc = 0;
qp = (struct bnxt_qplib_qp *)((unsigned long) qp = (struct bnxt_qplib_qp *)((unsigned long)
le64_to_cpu(hwcqe->qp_handle)); le64_to_cpu(hwcqe->qp_handle));
...@@ -2605,7 +2593,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, ...@@ -2605,7 +2593,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
if (qp->rq.flushed) { if (qp->rq.flushed) {
dev_dbg(&cq->hwq.pdev->dev, dev_dbg(&cq->hwq.pdev->dev,
"%s: QP in Flush QP = %p\n", __func__, qp); "%s: QP in Flush QP = %p\n", __func__, qp);
goto done; return 0;
} }
cqe = *pcqe; cqe = *pcqe;
cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK; cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
...@@ -2667,8 +2655,8 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, ...@@ -2667,8 +2655,8 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
bnxt_qplib_add_flush_qp(qp); bnxt_qplib_add_flush_qp(qp);
} }
} }
done:
return rc; return 0;
} }
bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq) bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq)
...@@ -2695,7 +2683,6 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, ...@@ -2695,7 +2683,6 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
struct bnxt_qplib_srq *srq; struct bnxt_qplib_srq *srq;
struct bnxt_qplib_cqe *cqe; struct bnxt_qplib_cqe *cqe;
u32 wr_id_idx; u32 wr_id_idx;
int rc = 0;
qp = (struct bnxt_qplib_qp *)((unsigned long) qp = (struct bnxt_qplib_qp *)((unsigned long)
le64_to_cpu(hwcqe->qp_handle)); le64_to_cpu(hwcqe->qp_handle));
...@@ -2706,7 +2693,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, ...@@ -2706,7 +2693,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
if (qp->rq.flushed) { if (qp->rq.flushed) {
dev_dbg(&cq->hwq.pdev->dev, dev_dbg(&cq->hwq.pdev->dev,
"%s: QP in Flush QP = %p\n", __func__, qp); "%s: QP in Flush QP = %p\n", __func__, qp);
goto done; return 0;
} }
cqe = *pcqe; cqe = *pcqe;
cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK; cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
...@@ -2775,8 +2762,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, ...@@ -2775,8 +2762,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
} }
} }
done: return 0;
return rc;
} }
static int bnxt_qplib_cq_process_terminal(struct bnxt_qplib_cq *cq, static int bnxt_qplib_cq_process_terminal(struct bnxt_qplib_cq *cq,
......
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