git: 44bf730761ff - stable/15 - ixl: Tie statistics baselines to hardware resource epochs

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 06:37:34 UTC
The branch stable/15 has been updated by kbowling:

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

commit 44bf730761ff4e7f2f9851e880c076c822d8b85e
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-03 10:58:30 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 06:37:25 +0000

    ixl: Tie statistics baselines to hardware resource epochs
    
    Raw VSI statistics belong to the firmware-assigned counter index and are
    reset when firmware recreates the VSI.  Reusing a baseline across either
    event makes a counter decrease look like a full width rollover.
    
    Reset the PF and main VSI baselines when rebuilding hardware resources.
    Start a new baseline when firmware assigns a different PF counter index
    and whenever it allocates a VF VSI.  Ordinary interface reinits which
    retain the hardware resources continue to retain their statistics.
    
    This follows the lifecycle used by ice without placing an unconditional
    statistics reset in ixl_initialize_vsi(), which also runs during ordinary
    iflib initialization.
    
    Sponsored by:   BBOX.io
    Differential Revision:  https://reviews.freebsd.org/D59337
    
    (cherry picked from commit 444168adbe5217ea9b73773e42c60bf75fb7a6fd)
---
 sys/dev/ixl/ixl_pf_iflib.c | 11 ++++++++++-
 sys/dev/ixl/ixl_pf_iov.c   |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/sys/dev/ixl/ixl_pf_iflib.c b/sys/dev/ixl/ixl_pf_iflib.c
index 2791ad769f67..b6283855e794 100644
--- a/sys/dev/ixl/ixl_pf_iflib.c
+++ b/sys/dev/ixl/ixl_pf_iflib.c
@@ -502,7 +502,13 @@ ixl_initialize_vsi(struct ixl_vsi *vsi)
 		ctxt.info.queueing_opt_flags |= I40E_AQ_VSI_QUE_OPT_TCP_ENA;
 	}
 #endif
-	/* Save VSI number and info for use later */
+	/*
+	 * Save the VSI number and info for later.  A changed counter index
+	 * begins a new statistics epoch.
+	 */
+	if (vsi->stat_offsets_loaded &&
+	    vsi->info.stat_counter_idx != ctxt.info.stat_counter_idx)
+		ixl_vsi_reset_stats(vsi);
 	vsi->vsi_num = ctxt.vsi_number;
 	bcopy(&ctxt.info, &vsi->info, sizeof(vsi->info));
 
@@ -1032,6 +1038,9 @@ ixl_rebuild_hw_structs_after_reset(struct ixl_pf *pf, bool is_up)
 		error = EIO;
 		goto ixl_rebuild_hw_structs_after_reset_err;
 	}
+	/* Firmware has rebuilt the port and VSI counter resources. */
+	ixl_pf_reset_stats(pf);
+	ixl_vsi_reset_stats(vsi);
 
 	error = i40e_aq_set_phy_int_mask(hw, IXL_DEFAULT_PHY_INT_MASK,
 	    NULL);
diff --git a/sys/dev/ixl/ixl_pf_iov.c b/sys/dev/ixl/ixl_pf_iov.c
index 20432770a064..bdc02f1f11ce 100644
--- a/sys/dev/ixl/ixl_pf_iov.c
+++ b/sys/dev/ixl/ixl_pf_iov.c
@@ -210,6 +210,8 @@ ixl_vf_alloc_vsi(struct ixl_pf *pf, struct ixl_vf *vf)
 	}
 
 	memcpy(&vf->vsi.info, &vsi_ctx.info, sizeof(vf->vsi.info));
+	/* A newly allocated hardware VSI starts a new statistics epoch. */
+	ixl_vsi_reset_stats(&vf->vsi);
 	return (0);
 
 fail: