From nobody Thu Apr 9 23:26:09 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD3543A63F1 for ; Thu, 5 Mar 2026 14:34:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772721281; cv=none; b=B8VwaztAA5JDakxOH9In4zMJIdjTgrOrc1FdGG+iQ/x4lmOVCppHyf4fu1wZGyjV9dc5MJXFEYShH2X1fbFeXS4TMnRJZJJ3sJ3U2rBALzAXYUHJwpnIhtcCZiGm/SvjbbJVYIDmiQ1IKXu5PYtEU2D/TxGIvd8anjw3WhvirN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772721281; c=relaxed/simple; bh=EQboYmxVwYKgzXaVs0eN+JsgiAJX6evBtJU0ZeiJgLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u1opobqRhKvgLVezmQR0+h6+RHSD4G7S8IL0aOVlea4vyMxfCMv+RrUQNBlgM3fzDLvISMpNB74gcMxwiR3rcjRp/7rjtLPwLae2I52ZK66V4PuJQLZ6Q0Jc2rQcT9sKIKUSe9LVwb1SBfS/Ny1/RD24KEMQMcb2+Mm2uz1/iVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vy9mZ-000463-Ph; Thu, 05 Mar 2026 15:34:31 +0100 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac] helo=dude04) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vy9mX-003twl-21; Thu, 05 Mar 2026 15:34:30 +0100 Received: from ore by dude04 with local (Exim 4.98.2) (envelope-from ) id 1vy9mY-00000002E8I-3lzW; Thu, 05 Mar 2026 15:34:30 +0100 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh , Andrew Lunn , Thangaraj Samynathan , Rengarajan Sundararajan Cc: Oleksij Rempel , stable@vger.kernel.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net v1 2/4] net: usb: lan78xx: fix TX byte statistics for small packets Date: Thu, 5 Mar 2026 15:34:27 +0100 Message-ID: <20260305143429.530909-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260305143429.530909-1-o.rempel@pengutronix.de> References: <20260305143429.530909-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Account for hardware auto-padding in TX byte counters to reflect actual wire traffic. The LAN7850 hardware automatically pads undersized frames to the minimum Ethernet frame length (ETH_ZLEN, 60 bytes). However, the driver tracks the network statistics based on the unpadded socket buffer length. This results in the tx_bytes counter under-reporting the actual physical bytes placed on the Ethernet wire for small packets (like short ARP or ICMP requests). Use max_t() to ensure the transmission statistics accurately account for the hardware-generated padding. Fixes: d383216a7efe ("lan78xx: Introduce Tx URB processing improvements") Cc: stable@vger.kernel.org Signed-off-by: Oleksij Rempel --- drivers/net/usb/lan78xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 1c8f69190378..507dbcf3b7b0 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -4178,7 +4178,7 @@ static struct skb_data *lan78xx_tx_buf_fill(struct la= n78xx_net *dev, } =20 tx_data +=3D len; - entry->length +=3D len; + entry->length +=3D max_t(unsigned int, len, ETH_ZLEN); entry->num_of_packet +=3D skb_shinfo(skb)->gso_segs ?: 1; =20 dev_kfree_skb_any(skb); --=20 2.47.3