Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jul 2026 01:01:18 +0000
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e389a05164cc - main - igc: count TSO wire segments in the AIM counters
Message-ID:  <6a655c5e.32f9b.6b98a342@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kbowling:

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

commit e389a05164ccb1dd41ee8d7f09203b475322dd72
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-07-26 00:01:06 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-07-26 01:00:02 +0000

    igc: count TSO wire segments in the AIM counters
    
    The transmit path bills one packet of ipi_len bytes per request.  For
    TSO that is the whole unsegmented payload, up to 64 KiB, rather than a
    packet size that appears on the wire.
    
    Count the segments the hardware emits and the header carried by each
    segment.  Non-TSO accounting is unchanged.
    
    MFC after:      1 week
---
 sys/dev/igc/igc_txrx.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c
index 12b6f2c43c39..0f88a0a5acd5 100644
--- a/sys/dev/igc/igc_txrx.c
+++ b/sys/dev/igc/igc_txrx.c
@@ -317,10 +317,27 @@ igc_isc_txd_encap(void *arg, if_pkt_info_t pi)
 	txd->read.cmd_type_len |= htole32(IGC_ADVTXD_DCMD_EOP | txd_flags);
 	pi->ipi_new_pidx = i;
 
-	/* Sent data accounting for AIM */
+	/*
+	 * Sent data accounting for AIM.  For TSO, ipi_len is the whole
+	 * unsegmented payload, which is not a size the moderation calculation
+	 * can use.  Count the segments the hardware will put on the wire and
+	 * the header each of them carries, so that the average it sees is a
+	 * wire packet.
+	 */
+	if ((pi->ipi_csum_flags & CSUM_TSO) && pi->ipi_tso_segsz != 0) {
+		u32 hdrlen, segs;
+
+		hdrlen = pi->ipi_ehdrlen + pi->ipi_ip_hlen + pi->ipi_tcp_hlen;
+		if (pi->ipi_len > hdrlen) {
+			segs = howmany(pi->ipi_len - hdrlen, pi->ipi_tso_segsz);
+			txr->tx_bytes += pi->ipi_len + (segs - 1) * hdrlen;
+			txr->tx_packets += segs;
+			return (0);
+		}
+	}
+
 	txr->tx_bytes += pi->ipi_len;
 	++txr->tx_packets;
-
 	return (0);
 }
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a655c5e.32f9b.6b98a342>