]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RDMA/bnxt_re: Refactor hw context memory allocation
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Fri, 22 Aug 2025 04:07:54 +0000 (09:37 +0530)
committerLeon Romanovsky <leon@kernel.org>
Thu, 11 Sep 2025 06:18:03 +0000 (02:18 -0400)
This patch is in preparation for other patches in this series.
There is no functional changes intended.

1. Rename bnxt_qplib_alloc_ctx() to bnxt_qplib_alloc_hwctx().
2. Rename bnxt_qplib_free_ctx() to bnxt_qplib_free_hwctx().
3. Reduce the number of arguments of bnxt_qplib_alloc_hwctx()
   by moving a check outside of it.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Link: https://patch.msgid.link/20250822040801.776196-4-kalesh-anakkur.purayil@broadcom.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/main.c
drivers/infiniband/hw/bnxt_re/qplib_res.c
drivers/infiniband/hw/bnxt_re/qplib_res.h

index 0bdc2f66e136c457f1193b8b3503c722e2d76cd0..cc75e79b93a67572dca79ef71baebd1a562089c6 100644 (file)
@@ -2044,7 +2044,7 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type)
                        ibdev_warn(&rdev->ibdev,
                                   "Failed to deinitialize RCFW: %#x", rc);
                bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id);
-               bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx);
+               bnxt_qplib_free_hwctx(&rdev->qplib_res, &rdev->qplib_ctx);
                bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
                type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
                bnxt_re_net_ring_free(rdev, rdev->rcfw.creq.ring_id, type);
@@ -2182,12 +2182,14 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
        bnxt_qplib_query_version(&rdev->rcfw);
        bnxt_re_set_resource_limits(rdev);
 
-       rc = bnxt_qplib_alloc_ctx(&rdev->qplib_res, &rdev->qplib_ctx, 0,
-                                 bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx));
-       if (rc) {
-               ibdev_err(&rdev->ibdev,
-                         "Failed to allocate QPLIB context: %#x\n", rc);
-               goto disable_rcfw;
+       if (!rdev->is_virtfn &&
+           !bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) {
+               rc = bnxt_qplib_alloc_hwctx(&rdev->qplib_res, &rdev->qplib_ctx);
+               if (rc) {
+                       ibdev_err(&rdev->ibdev,
+                                 "Failed to allocate hw context: %#x\n", rc);
+                       goto disable_rcfw;
+               }
        }
        rc = bnxt_re_net_stats_ctx_alloc(rdev,
                                         rdev->qplib_ctx.stats.dma_map,
@@ -2255,7 +2257,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
 free_sctx:
        bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id);
 free_ctx:
-       bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx);
+       bnxt_qplib_free_hwctx(&rdev->qplib_res, &rdev->qplib_ctx);
 disable_rcfw:
        bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
 free_ring:
index 6cd05207ffeddf56f63f94cf9776605aa99ad9e6..db2ee7246861390df5e5a25c3cab9e512bc781cc 100644 (file)
@@ -350,8 +350,8 @@ fail:
 }
 
 /* Context Tables */
-void bnxt_qplib_free_ctx(struct bnxt_qplib_res *res,
-                        struct bnxt_qplib_ctx *ctx)
+void bnxt_qplib_free_hwctx(struct bnxt_qplib_res *res,
+                          struct bnxt_qplib_ctx *ctx)
 {
        int i;
 
@@ -464,7 +464,7 @@ fail:
 }
 
 /*
- * Routine: bnxt_qplib_alloc_ctx
+ * Routine: bnxt_qplib_alloc_hwctx
  * Description:
  *     Context tables are memories which are used by the chip fw.
  *     The 6 tables defined are:
@@ -484,17 +484,13 @@ fail:
  * Returns:
  *     0 if success, else -ERRORS
  */
-int bnxt_qplib_alloc_ctx(struct bnxt_qplib_res *res,
-                        struct bnxt_qplib_ctx *ctx,
-                        bool virt_fn, bool is_p5)
+int bnxt_qplib_alloc_hwctx(struct bnxt_qplib_res *res,
+                          struct bnxt_qplib_ctx *ctx)
 {
        struct bnxt_qplib_hwq_attr hwq_attr = {};
        struct bnxt_qplib_sg_info sginfo = {};
        int rc;
 
-       if (virt_fn || is_p5)
-               goto stats_alloc;
-
        /* QPC Tables */
        sginfo.pgsize = PAGE_SIZE;
        sginfo.pgshft = PAGE_SHIFT;
@@ -540,7 +536,6 @@ int bnxt_qplib_alloc_ctx(struct bnxt_qplib_res *res,
        rc = bnxt_qplib_alloc_init_hwq(&ctx->tim_tbl, &hwq_attr);
        if (rc)
                goto fail;
-stats_alloc:
        /* Stats */
        rc = bnxt_qplib_alloc_stats_ctx(res->pdev, res->cctx, &ctx->stats);
        if (rc)
@@ -549,7 +544,7 @@ stats_alloc:
        return 0;
 
 fail:
-       bnxt_qplib_free_ctx(res, ctx);
+       bnxt_qplib_free_hwctx(res, ctx);
        return rc;
 }
 
index 12e2fa23794ada2c50b254883306d2670c65093d..9d866cfdebab7ee51c298f278fdd1e0397becfa5 100644 (file)
@@ -433,11 +433,10 @@ void bnxt_qplib_cleanup_res(struct bnxt_qplib_res *res);
 int bnxt_qplib_init_res(struct bnxt_qplib_res *res);
 void bnxt_qplib_free_res(struct bnxt_qplib_res *res);
 int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct net_device *netdev);
-void bnxt_qplib_free_ctx(struct bnxt_qplib_res *res,
-                        struct bnxt_qplib_ctx *ctx);
-int bnxt_qplib_alloc_ctx(struct bnxt_qplib_res *res,
-                        struct bnxt_qplib_ctx *ctx,
-                        bool virt_fn, bool is_p5);
+void bnxt_qplib_free_hwctx(struct bnxt_qplib_res *res,
+                          struct bnxt_qplib_ctx *ctx);
+int bnxt_qplib_alloc_hwctx(struct bnxt_qplib_res *res,
+                          struct bnxt_qplib_ctx *ctx);
 int bnxt_qplib_map_db_bar(struct bnxt_qplib_res *res);
 void bnxt_qplib_unmap_db_bar(struct bnxt_qplib_res *res);