git: 41a46c2d46aa - main - e1000: fix rx accounting for multi-descriptor packets

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a652c71.43139.60a2f8ab__6468.32548534206$1785015425$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by kbowling:

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

commit 41a46c2d46aa4078c597ce3a0d19323cab988277
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-07-25 11:02:36 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-07-25 21:36:18 +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.
    
    MFC after:      1 week
---
 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 b86222e363e9..f2b48d6518f7 100644
--- a/sys/dev/e1000/em_txrx.c
+++ b/sys/dev/e1000/em_txrx.c
@@ -679,7 +679,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;
 
@@ -745,7 +745,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 e01bc72cdc55..fc690dcfc100 100644
--- a/sys/dev/e1000/igb_txrx.c
+++ b/sys/dev/e1000/igb_txrx.c
@@ -458,7 +458,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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.