Blame SOURCES/_PATCH_RHEL-7_06-12_bnxt_en_Pass_correct_extended_TX_port_statistics_s.patch

8fbaf1
Date: Wed,  5 Jun 2019 13:55:25 -0400
8fbaf1
From: Jonathan Toppins <jtoppins@redhat.com>
8fbaf1
To: rhkernel-list@redhat.com
8fbaf1
Cc: darcari@redhat.com, linville@redhat.com
8fbaf1
Subject: [PATCH RHEL-7 06/12] bnxt_en: Pass correct extended TX port
8fbaf1
 statistics size to firmware.
8fbaf1
8fbaf1
If driver determines that extended TX port statistics are not supported
8fbaf1
or allocation of the data structure fails, make sure to pass 0 TX stats
8fbaf1
size to firmware to disable it.  The firmware returned TX stats size should
8fbaf1
also be set to 0 for consistency.  This will prevent
8fbaf1
bnxt_get_ethtool_stats() from accessing the NULL TX stats pointer in
8fbaf1
case there is mismatch between firmware and driver.
8fbaf1
8fbaf1
Fixes: 36e53349b60b ("bnxt_en: Add additional extended port statistics.")
8fbaf1
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
8fbaf1
Signed-off-by: David S. Miller <davem@davemloft.net>
8fbaf1
(cherry picked from commit ad361adf0d08f1135f3845c6b3a36be7cc0bfda5)
8fbaf1
Bugzilla: 1715161
8fbaf1
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=21964229
8fbaf1
Tested: build and boot
8fbaf1
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
8fbaf1
---
8fbaf1
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++--
8fbaf1
 1 file changed, 6 insertions(+), 2 deletions(-)
8fbaf1
8fbaf1
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
8fbaf1
index 0b57c5522791..a301f53f01aa 100644
8fbaf1
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
8fbaf1
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
8fbaf1
@@ -6740,6 +6740,7 @@ static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp)
8fbaf1
 	struct hwrm_queue_pri2cos_qcfg_input req2 = {0};
8fbaf1
 	struct hwrm_port_qstats_ext_input req = {0};
8fbaf1
 	struct bnxt_pf_info *pf = &bp->pf;
8fbaf1
+	u32 tx_stat_size;
8fbaf1
 	int rc;
8fbaf1
 
8fbaf1
 	if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT))
8fbaf1
@@ -6749,13 +6750,16 @@ static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp)
8fbaf1
 	req.port_id = cpu_to_le16(pf->port_id);
8fbaf1
 	req.rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext));
8fbaf1
 	req.rx_stat_host_addr = cpu_to_le64(bp->hw_rx_port_stats_ext_map);
8fbaf1
-	req.tx_stat_size = cpu_to_le16(sizeof(struct tx_port_stats_ext));
8fbaf1
+	tx_stat_size = bp->hw_tx_port_stats_ext ?
8fbaf1
+		       sizeof(*bp->hw_tx_port_stats_ext) : 0;
8fbaf1
+	req.tx_stat_size = cpu_to_le16(tx_stat_size);
8fbaf1
 	req.tx_stat_host_addr = cpu_to_le64(bp->hw_tx_port_stats_ext_map);
8fbaf1
 	mutex_lock(&bp->hwrm_cmd_lock);
8fbaf1
 	rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
8fbaf1
 	if (!rc) {
8fbaf1
 		bp->fw_rx_stats_ext_size = le16_to_cpu(resp->rx_stat_size) / 8;
8fbaf1
-		bp->fw_tx_stats_ext_size = le16_to_cpu(resp->tx_stat_size) / 8;
8fbaf1
+		bp->fw_tx_stats_ext_size = tx_stat_size ?
8fbaf1
+			le16_to_cpu(resp->tx_stat_size) / 8 : 0;
8fbaf1
 	} else {
8fbaf1
 		bp->fw_rx_stats_ext_size = 0;
8fbaf1
 		bp->fw_tx_stats_ext_size = 0;
8fbaf1
-- 
8fbaf1
2.16.4
8fbaf1
8fbaf1