git: 2ed061f08d9e - main - if_bnxt: Add support for smaller backing_store_cfg message size

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 04 Nov 2022 22:55:57 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ed061f08d9e2fe35bb8ff925cc19768d2430e77

commit 2ed061f08d9e2fe35bb8ff925cc19768d2430e77
Author:     Sumit Saxena <sumit.saxena@broadcom.com>
AuthorDate: 2022-11-04 22:33:21 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-11-04 22:33:21 +0000

    if_bnxt: Add support for smaller backing_store_cfg message size
    
    Add compat logic to fallback to the older/smaller backing_store_cfg
    message size.
    
    Reviewed by: imp
    Differentil Revision: https://reviews.freebsd.org/D36447
---
 sys/dev/bnxt/bnxt_hwrm.c | 8 ++++++--
 sys/dev/bnxt/bnxt_hwrm.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/sys/dev/bnxt/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_hwrm.c
index 9d74b1ebf65b..46dd8f34a6c5 100644
--- a/sys/dev/bnxt/bnxt_hwrm.c
+++ b/sys/dev/bnxt/bnxt_hwrm.c
@@ -394,7 +394,7 @@ int bnxt_hwrm_func_backing_store_cfg(struct bnxt_softc *softc, uint32_t enables)
 	struct hwrm_func_backing_store_cfg_input req = {0};
 	struct bnxt_ctx_mem_info *ctx = softc->ctx_mem;
 	struct bnxt_ctx_pg_info *ctx_pg;
-	uint32_t *num_entries;
+	uint32_t *num_entries, req_len = sizeof(req);
 	uint64_t *pg_dir;
 	uint8_t *pg_attr;
 	int i, rc;
@@ -481,7 +481,11 @@ int bnxt_hwrm_func_backing_store_cfg(struct bnxt_softc *softc, uint32_t enables)
 		*num_entries = htole32(ctx_pg->entries);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir);
 	}
-	rc = hwrm_send_message(softc, &req, sizeof(req));
+
+	if (req_len > softc->hwrm_max_ext_req_len)
+		req_len = BNXT_BACKING_STORE_CFG_LEGACY_LEN;
+
+	rc = hwrm_send_message(softc, &req, req_len);
 	if (rc)
 		rc = -EIO;
 	return rc;
diff --git a/sys/dev/bnxt/bnxt_hwrm.h b/sys/dev/bnxt/bnxt_hwrm.h
index 8033ddb50136..dde82c0aaff8 100644
--- a/sys/dev/bnxt/bnxt_hwrm.h
+++ b/sys/dev/bnxt/bnxt_hwrm.h
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #define BNXT_AUTO_PAUSE_AUTONEG_PAUSE  				\
         (HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_AUTONEG_PAUSE)
 #define BNXT_HWRM_SHORT_REQ_LEN	sizeof(struct hwrm_short_input)
+#define BNXT_BACKING_STORE_CFG_LEGACY_LEN       256
 
 /* HWRM Function Prototypes */
 int bnxt_alloc_hwrm_dma_mem(struct bnxt_softc *softc);