From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, gospo@broadcom.com,
Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [PATCH net-next 04/13] bnxt_en: Add page info to struct bnxt_ctx_mem_type
Date: Mon, 20 Nov 2023 15:43:56 -0800 [thread overview]
Message-ID: <20231120234405.194542-5-michael.chan@broadcom.com> (raw)
In-Reply-To: <20231120234405.194542-1-michael.chan@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 2796 bytes --]
This will further improve the organization of the bnxt_ctx_mem_info
structure by moving the standalone page info structures into the
bnxt_ctx_mem_type array. Add the allocation and free logic first and
the next patch will migrate to use the new infrastructure.
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++++++++++++
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
2 files changed, 32 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index df25b559ee45..3b18bcee151a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7187,6 +7187,27 @@ static void bnxt_init_ctx_initializer(struct bnxt_ctx_mem_type *ctxm,
ctxm->init_value = 0;
}
+static int bnxt_alloc_all_ctx_pg_info(struct bnxt *bp, int ctx_max)
+{
+ struct bnxt_ctx_mem_info *ctx = bp->ctx;
+ u16 type;
+
+ for (type = 0; type < ctx_max; type++) {
+ struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
+ int n = 1;
+
+ if (!ctxm->max_entries)
+ continue;
+
+ if (ctxm->instance_bmap)
+ n = hweight32(ctxm->instance_bmap);
+ ctxm->pg_info = kcalloc(n, sizeof(*ctxm->pg_info), GFP_KERNEL);
+ if (!ctxm->pg_info)
+ return -ENOMEM;
+ }
+ return 0;
+}
+
static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
{
struct hwrm_func_backing_store_qcaps_output *resp;
@@ -7298,6 +7319,7 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
}
for (i = 0; i < tqm_rings; i++, ctx_pg++)
ctx->tqm_mem[i] = ctx_pg;
+ rc = bnxt_alloc_all_ctx_pg_info(bp, BNXT_CTX_MAX);
} else {
rc = 0;
}
@@ -7564,6 +7586,7 @@ static void bnxt_free_ctx_pg_tbls(struct bnxt *bp,
void bnxt_free_ctx_mem(struct bnxt *bp)
{
struct bnxt_ctx_mem_info *ctx = bp->ctx;
+ u16 type;
int i;
if (!ctx)
@@ -7583,6 +7606,14 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
bnxt_free_ctx_pg_tbls(bp, &ctx->cq_mem);
bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem);
bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem);
+
+ for (type = 0; type < BNXT_CTX_MAX; type++) {
+ struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
+
+ kfree(ctxm->pg_info);
+ ctxm->pg_info = NULL;
+ }
+
ctx->flags &= ~BNXT_CTX_FLAG_INITED;
kfree(ctx);
bp->ctx = NULL;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 757d2edb8c05..7e67df57b8af 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1573,6 +1573,7 @@ struct bnxt_ctx_mem_type {
};
u32 split[BNXT_MAX_SPLIT_ENTRY];
};
+ struct bnxt_ctx_pg_info *pg_info;
};
#define BNXT_CTX_MRAV_AV_SPLIT_ENTRY 0
--
2.30.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
next prev parent reply other threads:[~2023-11-20 23:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 23:43 [PATCH net-next 00/13] bnxt_en: Prepare to support new P7 chips Michael Chan
2023-11-20 23:43 ` [PATCH net-next 01/13] bnxt_en: The caller of bnxt_alloc_ctx_mem() should always free bp->ctx Michael Chan
2023-11-20 23:43 ` [PATCH net-next 02/13] bnxt_en: Free bp->ctx inside bnxt_free_ctx_mem() Michael Chan
2023-11-20 23:43 ` [PATCH net-next 03/13] bnxt_en: Restructure context memory data structures Michael Chan
2023-11-20 23:43 ` Michael Chan [this message]
2023-11-20 23:43 ` [PATCH net-next 05/13] bnxt_en: Use the pg_info field in bnxt_ctx_mem_type struct Michael Chan
2023-11-20 23:43 ` [PATCH net-next 06/13] bnxt_en: Add bnxt_setup_ctxm_pg_tbls() helper function Michael Chan
2023-11-20 23:43 ` [PATCH net-next 07/13] bnxt_en: Add support for new backing store query firmware API Michael Chan
2023-11-20 23:44 ` [PATCH net-next 08/13] bnxt_en: Add support for HWRM_FUNC_BACKING_STORE_CFG_V2 firmware calls Michael Chan
2023-11-20 23:44 ` [PATCH net-next 09/13] bnxt_en: Add db_ring_mask and related macro to bnxt_db_info struct Michael Chan
2023-11-20 23:44 ` [PATCH net-next 10/13] bnxt_en: Modify TX ring indexing logic Michael Chan
2023-11-20 23:44 ` [PATCH net-next 11/13] bnxt_en: Modify RX " Michael Chan
2023-11-20 23:44 ` [PATCH net-next 12/13] bnxt_en: Modify the NAPI logic for the new P7 chips Michael Chan
2023-11-20 23:44 ` [PATCH net-next 13/13] bnxt_en: Rename some macros for the P5 chips Michael Chan
2023-11-22 1:40 ` [PATCH net-next 00/13] bnxt_en: Prepare to support new P7 chips patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231120234405.194542-5-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gospo@broadcom.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=somnath.kotur@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).