netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/4] bnxt_en: Bug fixes.
@ 2020-06-23 23:01 Michael Chan
  2020-06-23 23:01 ` [PATCH net 1/4] bnxt_en: Store the running firmware version code Michael Chan
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Michael Chan @ 2020-06-23 23:01 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba

The first patch stores the firmware version code which is needed by the
next 2 patches to determine some worarounds based on the firmware version.
The workarounds are to disable legacy TX push mode and to clear the
hardware statistics during ifdown.  The last patch checks that it is
a PF before reading the VPD.

Please also queue these for -stable.  Thanks.

Michael Chan (3):
  bnxt_en: Store the running firmware version code.
  bnxt_en: Do not enable legacy TX push on older firmware.
  bnxt_en: Fix statistics counters issue during ifdown with older
    firmware.

Vasundhara Volam (1):
  bnxt_en: Read VPD info only for PFs

 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 36 +++++++++++++++++++++++++------
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  5 +++++
 2 files changed, 34 insertions(+), 7 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net 1/4] bnxt_en: Store the running firmware version code.
  2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
@ 2020-06-23 23:01 ` Michael Chan
  2020-06-23 23:01 ` [PATCH net 2/4] bnxt_en: Do not enable legacy TX push on older firmware Michael Chan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Michael Chan @ 2020-06-23 23:01 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba

We currently only store the firmware version as a string for ethtool
and devlink info.  Store it also as a version code.  The next 2
patches will need to check the firmware major version to determine
some workarounds.

We also use the 16-bit firmware version fields if the firmware is newer
and provides the 16-bit fields.

Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 ++++++++++++++++++----
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  4 ++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index b93e05f..0ad8d49 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7240,8 +7240,9 @@ static int __bnxt_hwrm_ver_get(struct bnxt *bp, bool silent)
 static int bnxt_hwrm_ver_get(struct bnxt *bp)
 {
 	struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
+	u16 fw_maj, fw_min, fw_bld, fw_rsv;
 	u32 dev_caps_cfg, hwrm_ver;
-	int rc;
+	int rc, len;
 
 	bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
 	mutex_lock(&bp->hwrm_cmd_lock);
@@ -7273,9 +7274,22 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
 			 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
 			 resp->hwrm_intf_upd_8b);
 
-	snprintf(bp->fw_ver_str, BC_HWRM_STR_LEN, "%d.%d.%d.%d",
-		 resp->hwrm_fw_maj_8b, resp->hwrm_fw_min_8b,
-		 resp->hwrm_fw_bld_8b, resp->hwrm_fw_rsvd_8b);
+	fw_maj = le16_to_cpu(resp->hwrm_fw_major);
+	if (bp->hwrm_spec_code > 0x10803 && fw_maj) {
+		fw_min = le16_to_cpu(resp->hwrm_fw_minor);
+		fw_bld = le16_to_cpu(resp->hwrm_fw_build);
+		fw_rsv = le16_to_cpu(resp->hwrm_fw_patch);
+		len = FW_VER_STR_LEN;
+	} else {
+		fw_maj = resp->hwrm_fw_maj_8b;
+		fw_min = resp->hwrm_fw_min_8b;
+		fw_bld = resp->hwrm_fw_bld_8b;
+		fw_rsv = resp->hwrm_fw_rsvd_8b;
+		len = BC_HWRM_STR_LEN;
+	}
+	bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv);
+	snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld,
+		 fw_rsv);
 
 	if (strlen(resp->active_pkg_name)) {
 		int fw_ver_len = strlen(bp->fw_ver_str);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 9e173d7..858440e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1746,6 +1746,10 @@ struct bnxt {
 #define PHY_VER_STR_LEN         (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
 	char			fw_ver_str[FW_VER_STR_LEN];
 	char			hwrm_ver_supp[FW_VER_STR_LEN];
+	u64			fw_ver_code;
+#define BNXT_FW_VER_CODE(maj, min, bld, rsv)			\
+	((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv))
+
 	__be16			vxlan_port;
 	u8			vxlan_port_cnt;
 	__le16			vxlan_fw_dst_port_id;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 2/4] bnxt_en: Do not enable legacy TX push on older firmware.
  2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
  2020-06-23 23:01 ` [PATCH net 1/4] bnxt_en: Store the running firmware version code Michael Chan
@ 2020-06-23 23:01 ` Michael Chan
  2020-06-23 23:47   ` Jakub Kicinski
  2020-06-23 23:01 ` [PATCH net 3/4] bnxt_en: Fix statistics counters issue during ifdown with " Michael Chan
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Michael Chan @ 2020-06-23 23:01 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba

Older firmware may not support legacy TX push properly and may not
be disabling it.  So we check certain firmware versions that may
have this problem and disable legacy TX push unconditionally.

Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.")
Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 0ad8d49..f8c50b1 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -6976,7 +6976,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD;
 
 	bp->tx_push_thresh = 0;
-	if (flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED)
+	if ((flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED) &&
+	    BNXT_FW_MAJ(bp) > 217)
 		bp->tx_push_thresh = BNXT_TX_PUSH_THRESH;
 
 	hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 858440e..78e2fd6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1749,6 +1749,7 @@ struct bnxt {
 	u64			fw_ver_code;
 #define BNXT_FW_VER_CODE(maj, min, bld, rsv)			\
 	((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv))
+#define BNXT_FW_MAJ(bp)		((bp)->fw_ver_code >> 48)
 
 	__be16			vxlan_port;
 	u8			vxlan_port_cnt;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 3/4] bnxt_en: Fix statistics counters issue during ifdown with older firmware.
  2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
  2020-06-23 23:01 ` [PATCH net 1/4] bnxt_en: Store the running firmware version code Michael Chan
  2020-06-23 23:01 ` [PATCH net 2/4] bnxt_en: Do not enable legacy TX push on older firmware Michael Chan
@ 2020-06-23 23:01 ` Michael Chan
  2020-06-24  0:47   ` Jakub Kicinski
  2020-06-23 23:01 ` [PATCH net 4/4] bnxt_en: Read VPD info only for PFs Michael Chan
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Michael Chan @ 2020-06-23 23:01 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba

On older firmware, the hardware statistics are not cleared when the
driver frees the hardware stats contexts during ifdown.  The driver
expects these stats to be cleared and saves a copy before freeing
the stats contexts.  During the next ifup, the driver will likely
allocate the same hardware stats contexts and this will cause a big
increase in the counters as the old counters are added back to the
saved counters.

We fix it by making an additional firmware call to clear the counters
before freeing the hw stats contexts when the firmware is the older
20.x firmware.

Fixes: b8875ca356f1 ("bnxt_en: Save ring statistics before reset.")
Reported-by: Jakub Kicinski <kicinski@fb.com>
Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index f8c50b1..6dc7cc4 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -6292,6 +6292,7 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
 
 static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
 {
+	struct hwrm_stat_ctx_clr_stats_input req0 = {0};
 	struct hwrm_stat_ctx_free_input req = {0};
 	int i;
 
@@ -6301,6 +6302,7 @@ static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
 	if (BNXT_CHIP_TYPE_NITRO_A0(bp))
 		return;
 
+	bnxt_hwrm_cmd_hdr_init(bp, &req0, HWRM_STAT_CTX_CLR_STATS, -1, -1);
 	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_STAT_CTX_FREE, -1, -1);
 
 	mutex_lock(&bp->hwrm_cmd_lock);
@@ -6310,7 +6312,11 @@ static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
 
 		if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) {
 			req.stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id);
-
+			if (BNXT_FW_MAJ(bp) <= 20) {
+				req0.stat_ctx_id = req.stat_ctx_id;
+				_hwrm_send_message(bp, &req0, sizeof(req0),
+						   HWRM_CMD_TIMEOUT);
+			}
 			_hwrm_send_message(bp, &req, sizeof(req),
 					   HWRM_CMD_TIMEOUT);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 4/4] bnxt_en: Read VPD info only for PFs
  2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
                   ` (2 preceding siblings ...)
  2020-06-23 23:01 ` [PATCH net 3/4] bnxt_en: Fix statistics counters issue during ifdown with " Michael Chan
@ 2020-06-23 23:01 ` Michael Chan
  2020-06-23 23:45 ` [PATCH net 0/4] bnxt_en: Bug fixes Jakub Kicinski
  2020-06-24  3:15 ` David Miller
  5 siblings, 0 replies; 9+ messages in thread
From: Michael Chan @ 2020-06-23 23:01 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba

From: Vasundhara Volam <vasundhara-v.volam@broadcom.com>

Virtual functions does not have VPD information. This patch modifies
calling bnxt_read_vpd_info() only for PFs and avoids an unnecessary
error log.

Fixes: a0d0fd70fed5 ("bnxt_en: Read partno and serialno of the board from VPD")
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 6dc7cc4..6a884df 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -11913,7 +11913,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->ethtool_ops = &bnxt_ethtool_ops;
 	pci_set_drvdata(pdev, dev);
 
-	bnxt_vpd_read_info(bp);
+	if (BNXT_PF(bp))
+		bnxt_vpd_read_info(bp);
 
 	rc = bnxt_alloc_hwrm_resources(bp);
 	if (rc)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net 0/4] bnxt_en: Bug fixes.
  2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
                   ` (3 preceding siblings ...)
  2020-06-23 23:01 ` [PATCH net 4/4] bnxt_en: Read VPD info only for PFs Michael Chan
@ 2020-06-23 23:45 ` Jakub Kicinski
  2020-06-24  3:15 ` David Miller
  5 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2020-06-23 23:45 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev

On Tue, 23 Jun 2020 19:01:34 -0400 Michael Chan wrote:
> The first patch stores the firmware version code which is needed by the
> next 2 patches to determine some worarounds based on the firmware version.
> The workarounds are to disable legacy TX push mode and to clear the
> hardware statistics during ifdown.  The last patch checks that it is
> a PF before reading the VPD.
> 
> Please also queue these for -stable.  Thanks.

FWIW looks good to me:

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 2/4] bnxt_en: Do not enable legacy TX push on older firmware.
  2020-06-23 23:01 ` [PATCH net 2/4] bnxt_en: Do not enable legacy TX push on older firmware Michael Chan
@ 2020-06-23 23:47   ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2020-06-23 23:47 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev

On Tue, 23 Jun 2020 19:01:36 -0400 Michael Chan wrote:
> Older firmware may not support legacy TX push properly and may not
> be disabling it.  So we check certain firmware versions that may
> have this problem and disable legacy TX push unconditionally.

For the future this commit message should have been clearer on user
impact. What are the symptoms? Will the TX hang because of this? 
Will the performance be low?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 3/4] bnxt_en: Fix statistics counters issue during ifdown with older firmware.
  2020-06-23 23:01 ` [PATCH net 3/4] bnxt_en: Fix statistics counters issue during ifdown with " Michael Chan
@ 2020-06-24  0:47   ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2020-06-24  0:47 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev

On Tue, 23 Jun 2020 19:01:37 -0400 Michael Chan wrote:
> On older firmware, the hardware statistics are not cleared when the
> driver frees the hardware stats contexts during ifdown.  The driver
> expects these stats to be cleared and saves a copy before freeing
> the stats contexts.  During the next ifup, the driver will likely
> allocate the same hardware stats contexts and this will cause a big
> increase in the counters as the old counters are added back to the
> saved counters.
> 
> We fix it by making an additional firmware call to clear the counters
> before freeing the hw stats contexts when the firmware is the older
> 20.x firmware.
> 
> Fixes: b8875ca356f1 ("bnxt_en: Save ring statistics before reset.")
> Reported-by: Jakub Kicinski <kicinski@fb.com>
> Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Tested-by: Jakub Kicinski <kicinski@fb.com>

Thanks Michael!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net 0/4] bnxt_en: Bug fixes.
  2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
                   ` (4 preceding siblings ...)
  2020-06-23 23:45 ` [PATCH net 0/4] bnxt_en: Bug fixes Jakub Kicinski
@ 2020-06-24  3:15 ` David Miller
  5 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2020-06-24  3:15 UTC (permalink / raw)
  To: michael.chan; +Cc: netdev, kuba

From: Michael Chan <michael.chan@broadcom.com>
Date: Tue, 23 Jun 2020 19:01:34 -0400

> The first patch stores the firmware version code which is needed by the
> next 2 patches to determine some worarounds based on the firmware version.
> The workarounds are to disable legacy TX push mode and to clear the
> hardware statistics during ifdown.  The last patch checks that it is
> a PF before reading the VPD.

Series applied.

> Please also queue these for -stable.  Thanks.

Queued up, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-24  3:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 23:01 [PATCH net 0/4] bnxt_en: Bug fixes Michael Chan
2020-06-23 23:01 ` [PATCH net 1/4] bnxt_en: Store the running firmware version code Michael Chan
2020-06-23 23:01 ` [PATCH net 2/4] bnxt_en: Do not enable legacy TX push on older firmware Michael Chan
2020-06-23 23:47   ` Jakub Kicinski
2020-06-23 23:01 ` [PATCH net 3/4] bnxt_en: Fix statistics counters issue during ifdown with " Michael Chan
2020-06-24  0:47   ` Jakub Kicinski
2020-06-23 23:01 ` [PATCH net 4/4] bnxt_en: Read VPD info only for PFs Michael Chan
2020-06-23 23:45 ` [PATCH net 0/4] bnxt_en: Bug fixes Jakub Kicinski
2020-06-24  3:15 ` David Miller

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).