Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 Aug 2026 00:24:45 +0000
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 03125b959758 - stable/15 - e1000: fix rx accounting for multi-descriptor packets
Message-ID:  <6a6d3ccd.1868f.431357f5@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by kbowling:

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

commit 03125b959758a5bfed0e4f10aa36a33fed279097
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-07-25 11:02:36 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-01 00:24:33 +0000

    e1000: fix rx accounting for multi-descriptor packets
    
    The receive paths accumulate ri->iri_len across the descriptors making
    up a packet, then add that running total to rxr->rx_bytes on every
    iteration of the loop.  A packet spanning descriptors of length l1, l2
    and l3 thus contributes 3*l1 + 2*l2 + l3 instead of l1 + l2 + l3.
    
    Single descriptor packets, the common case, are accounted correctly,
    so this only shows up on jumbo frames.
    
    Add the per descriptor length instead.  iflib memsets the if_rxd_info
    before each isc_rxd_pkt_get() call, so summing len gives the same total
    as the final iri_len, and the frame error path that returns without
    incrementing rx_packets keeps counting bytes exactly as before.
    
    (cherry picked from commit 41a46c2d46aa4078c597ce3a0d19323cab988277)
---
 sys/dev/e1000/em_txrx.c  | 4 ++--
 sys/dev/e1000/igb_txrx.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c
index ced8d0f41d14..cfeb43036563 100644
--- a/sys/dev/e1000/em_txrx.c
+++ b/sys/dev/e1000/em_txrx.c
@@ -681,7 +681,7 @@ lem_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
 
 		len = le16toh(rxd->length);
 		ri->iri_len += len;
-		rxr->rx_bytes += ri->iri_len;
+		rxr->rx_bytes += len;
 
 		eop = (status & E1000_RXD_STAT_EOP) != 0;
 
@@ -747,7 +747,7 @@ em_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
 
 		len = le16toh(rxd->wb.upper.length);
 		ri->iri_len += len;
-		rxr->rx_bytes += ri->iri_len;
+		rxr->rx_bytes += len;
 
 		eop = (staterr & E1000_RXD_STAT_EOP) != 0;
 
diff --git a/sys/dev/e1000/igb_txrx.c b/sys/dev/e1000/igb_txrx.c
index 568d84807173..19b365bf020a 100644
--- a/sys/dev/e1000/igb_txrx.c
+++ b/sys/dev/e1000/igb_txrx.c
@@ -460,7 +460,7 @@ igb_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
 		    le32toh(rxd->wb.lower.lo_dword.data) &  IGB_PKTTYPE_MASK;
 
 		ri->iri_len += len;
-		rxr->rx_bytes += ri->iri_len;
+		rxr->rx_bytes += len;
 
 		rxd->wb.upper.status_error = 0;
 		eop = ((staterr & E1000_RXD_STAT_EOP) == E1000_RXD_STAT_EOP);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a6d3ccd.1868f.431357f5>