Commit 08b386b1 authored by Michael Chan's avatar Michael Chan Committed by Jakub Kicinski

bnxt_en: Fix backing store V2 logic

The current code determines the last backing store valid type during
bnxt_hwrm_func_backing_store_qcaps_v2().  In effect, the last type
is determined based on what firmware advertises.  The more correct
way is to determine it based on what the driver is configuring.  The
driver may not configure all the backing store types advertised by
firmware.

Move the logic to determine the last type to bnxt_backing_store_cfg_v2().
We need to pass the legacy enable flags to the function in case only
the legacy types are being configured.

Fixes: 236e237f ("bnxt_en: Add support for HWRM_FUNC_BACKING_STORE_CFG_V2 firmware calls")
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20231201223924.26955-2-michael.chan@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 91051f00
...@@ -7249,7 +7249,6 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp) ...@@ -7249,7 +7249,6 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
{ {
struct hwrm_func_backing_store_qcaps_v2_output *resp; struct hwrm_func_backing_store_qcaps_v2_output *resp;
struct hwrm_func_backing_store_qcaps_v2_input *req; struct hwrm_func_backing_store_qcaps_v2_input *req;
u16 last_valid_type = BNXT_CTX_INV;
struct bnxt_ctx_mem_info *ctx; struct bnxt_ctx_mem_info *ctx;
u16 type; u16 type;
int rc; int rc;
...@@ -7281,7 +7280,6 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp) ...@@ -7281,7 +7280,6 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
continue; continue;
ctxm->type = le16_to_cpu(resp->type); ctxm->type = le16_to_cpu(resp->type);
last_valid_type = ctxm->type;
ctxm->entry_size = le16_to_cpu(resp->entry_size); ctxm->entry_size = le16_to_cpu(resp->entry_size);
ctxm->flags = flags; ctxm->flags = flags;
ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map); ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map);
...@@ -7298,8 +7296,6 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp) ...@@ -7298,8 +7296,6 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
i++, p++) i++, p++)
ctxm->split[i] = le32_to_cpu(*p); ctxm->split[i] = le32_to_cpu(*p);
} }
if (last_valid_type < BNXT_CTX_V2_MAX)
ctx->ctx_arr[last_valid_type].last = true;
rc = bnxt_alloc_all_ctx_pg_info(bp, BNXT_CTX_V2_MAX); rc = bnxt_alloc_all_ctx_pg_info(bp, BNXT_CTX_V2_MAX);
ctx_done: ctx_done:
...@@ -7751,13 +7747,22 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp, ...@@ -7751,13 +7747,22 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
return rc; return rc;
} }
static int bnxt_backing_store_cfg_v2(struct bnxt *bp) static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
{ {
struct bnxt_ctx_mem_info *ctx = bp->ctx; struct bnxt_ctx_mem_info *ctx = bp->ctx;
struct bnxt_ctx_mem_type *ctxm; struct bnxt_ctx_mem_type *ctxm;
u16 last_type;
int rc = 0; int rc = 0;
u16 type; u16 type;
if (!ena)
return 0;
else if (ena & FUNC_BACKING_STORE_CFG_REQ_ENABLES_TIM)
last_type = BNXT_CTX_MAX - 1;
else
last_type = BNXT_CTX_L2_MAX - 1;
ctx->ctx_arr[last_type].last = 1;
for (type = 0 ; type < BNXT_CTX_V2_MAX; type++) { for (type = 0 ; type < BNXT_CTX_V2_MAX; type++) {
ctxm = &ctx->ctx_arr[type]; ctxm = &ctx->ctx_arr[type];
...@@ -7904,7 +7909,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp) ...@@ -7904,7 +7909,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
ena |= FUNC_BACKING_STORE_CFG_REQ_DFLT_ENABLES; ena |= FUNC_BACKING_STORE_CFG_REQ_DFLT_ENABLES;
if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2) if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2)
rc = bnxt_backing_store_cfg_v2(bp); rc = bnxt_backing_store_cfg_v2(bp, ena);
else else
rc = bnxt_hwrm_func_backing_store_cfg(bp, ena); rc = bnxt_hwrm_func_backing_store_cfg(bp, ena);
if (rc) { if (rc) {
......
...@@ -1611,6 +1611,7 @@ struct bnxt_ctx_mem_type { ...@@ -1611,6 +1611,7 @@ struct bnxt_ctx_mem_type {
#define BNXT_CTX_XPAR FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_XID_PARTITION #define BNXT_CTX_XPAR FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_XID_PARTITION
#define BNXT_CTX_MAX (BNXT_CTX_TIM + 1) #define BNXT_CTX_MAX (BNXT_CTX_TIM + 1)
#define BNXT_CTX_L2_MAX (BNXT_CTX_FTQM + 1)
#define BNXT_CTX_V2_MAX (BNXT_CTX_XPAR + 1) #define BNXT_CTX_V2_MAX (BNXT_CTX_XPAR + 1)
#define BNXT_CTX_INV ((u16)-1) #define BNXT_CTX_INV ((u16)-1)
......
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