git: c0b69999b1b3 - stable/14 - cxgbe(4): Query TPCHMAP once and not once per port.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Wed, 17 Jul 2024 14:21:48 UTC
The branch stable/14 has been updated by np:

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

commit c0b69999b1b34cc02b02222a63e0cd918c522e88
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-04-30 23:32:55 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-07-17 06:38:57 +0000

    cxgbe(4): Query TPCHMAP once and not once per port.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 7f10048f983a31c09587b436e7fb073f7cbb76e4)
---
 sys/dev/cxgbe/common/common.h |  4 +++-
 sys/dev/cxgbe/common/t4_hw.c  | 11 ++---------
 sys/dev/cxgbe/t4_main.c       |  8 ++++++++
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h
index f43ffc83dff1..67bbf5e43b79 100644
--- a/sys/dev/cxgbe/common/common.h
+++ b/sys/dev/cxgbe/common/common.h
@@ -402,7 +402,9 @@ struct adapter_params {
 	unsigned int max_ordird_qp;
 	unsigned int max_ird_adapter;
 
-	uint32_t mps_bg_map;	/* rx buffer group map for all ports (upto 4) */
+	/* These values are for all ports (8b/port, upto 4 ports) */
+	uint32_t mps_bg_map;	/* MPS rx buffer group map */
+	uint32_t tp_ch_map;	/* TPCHMAP from firmware */
 
 	bool ulptx_memwrite_dsgl;	/* use of T5 DSGL allowed */
 	bool fr_nsmr_tpte_wr_support;	/* FW support for FR_NSMR_TPTE_WR */
diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c
index 3e04995eec3b..07940a44f66e 100644
--- a/sys/dev/cxgbe/common/t4_hw.c
+++ b/sys/dev/cxgbe/common/t4_hw.c
@@ -6774,15 +6774,8 @@ static unsigned int t4_get_rx_e_chan_map(struct adapter *adap, int idx)
  */
 static unsigned int t4_get_rx_c_chan(struct adapter *adap, int idx)
 {
-	u32 param, val;
-	int ret;
-
-	param = (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
-	    V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_TPCHMAP));
-	ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, &param, &val);
-	if (!ret)
-		return (val >> (8 * idx)) & 0xff;
-
+	if (adap->params.tp_ch_map != UINT32_MAX)
+		return (adap->params.tp_ch_map >> (8 * idx)) & 0xff;
         return 0;
 }
 
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 1c4fe4b4d0cf..2e885b9c3ffe 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -5339,6 +5339,14 @@ get_params__post_init(struct adapter *sc)
 	else
 		sc->params.mps_bg_map = UINT32_MAX;	/* Not a legal value. */
 
+	param[0] = FW_PARAM_DEV(TPCHMAP);
+	val[0] = 0;
+	rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val);
+	if (rc == 0)
+		sc->params.tp_ch_map = val[0];
+	else
+		sc->params.tp_ch_map = UINT32_MAX;	/* Not a legal value. */
+
 	/*
 	 * Determine whether the firmware supports the filter2 work request.
 	 */