diff options
| author | Kevin Bowling <kbowling@FreeBSD.org> | 2026-07-26 00:01:06 +0000 |
|---|---|---|
| committer | Kevin Bowling <kbowling@FreeBSD.org> | 2026-07-26 01:00:02 +0000 |
| commit | e389a05164ccb1dd41ee8d7f09203b475322dd72 (patch) | |
| tree | 6e60d7b00074c301609afacf177aebe6b711e2f3 | |
| parent | 01e7acd38d411c78caba1c4078bb3683f586e1c2 (diff) | |
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
| -rw-r--r-- | sys/dev/igc/igc_txrx.c | 21 |
1 files 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); } |
