The probe-time clear in 'ef10_nic_probe' runs before the VADAPTER is
allocated and so cannot zero its counters. Add a complementary clear
to the point at which the VADAPTER is already in place, so that
VADAPTER statistics begin at zero for both PFs and VFs.

This change affects only Medford4 NICs within the 26.11 release, where
Medford4 VADAPTER statistics have been added in the first place.

Signed-off-by: Ivan Malov <[email protected]>
Reviewed-by: Viacheslav Galaktionov <[email protected]>
Reviewed-by: Andy Moreton <[email protected]>
---
 drivers/common/sfc_efx/base/ef10_nic.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c 
b/drivers/common/sfc_efx/base/ef10_nic.c
index 9af4259d38..954409ec90 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -2868,10 +2868,30 @@ ef10_nic_init(
                if ((rc = ef10_upstream_port_vadaptor_alloc(enp)) != 0)
                        goto fail5;
        }
+
+#if EFSYS_OPT_MAC_STATS
+       /*
+        * Clear MAC statistics for the freshly allocated VADAPTER.
+        * The probe-time wipe in 'ef10_nic_probe' predates the
+        * allocation and cannot reach vadaptor-scoped counters;
+        * do it here while 'en_vport_id' holds a valid value.
+        */
+       rc = efx_mcdi_mac_stats_clear(enp);
+       if (rc != 0)
+               goto fail6;
+#endif
        enp->en_nic_cfg.enc_mcdi_max_payload_length = MCDI_CTL_SDU_LEN_MAX_V2;
 
        return (0);
 
+#if EFSYS_OPT_MAC_STATS
+fail6:
+       EFSYS_PROBE(fail6);
+       if (alloc_vadaptor != B_FALSE) {
+               (void) efx_mcdi_vadaptor_free(enp, enp->en_vport_id);
+               enp->en_vport_id = EVB_PORT_ID_NULL;
+       }
+#endif
 fail5:
        EFSYS_PROBE(fail5);
 fail4:
-- 
2.47.3

Reply via email to