🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24431

[PATCH net-next v10 03/12] r8152: add rtl8157_change_mtu() for RTL8157 and RTL8159

#24431
From: Chih Kai Hsu
Date: Mon, 30 Nov 2026 06:31
79 lines
12101 bytes
RTL8157 and RTL8159 used rtl8156_change_mtu(), which programs a fixed
MTPS_JUMBO. Per the datasheet they need an MTPS scaled from the
configured MTU instead: max_pkt_size / 64, at least 10K and capped
at 0xff.

Add rtl8157_change_mtu() for them. Since rtl8156_up() is shared with
these chips, have it call tp->rtl_ops.change_mtu() instead of
rtl8156_change_mtu() directly so each chip gets its own helper.

Fixes: fd3c7d080df5 ("r8152: Add support for the RTL8157 hardware")
Fixes: ad2a55b63b41 ("r8152: Add support for the RTL8159 chip")
Signed-off-by: Chih Kai Hsu <hsu.chih.kai@realtek.com>
---
 drivers/net/usb/r8152.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index bb4106f238a3a..1517753f843ef 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -6800,6 +6800,28 @@ static void rtl8156_change_mtu(struct r8152 *tp)
 		       ALIGN(rx_max_size + tp->tx_desc.size, 1024) / 16);
 }
 
+static void rtl8157_change_mtu(struct r8152 *tp)
+{
+	u32 max_pkt_size = mtu_to_size(tp->netdev->mtu);
+	u32 ocp_data;
+
+	ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, max_pkt_size);
+
+	/* Use at least 10K for MTPS */
+	ocp_data = max_t(u32, max_pkt_size, 10 * 1024) / 64;
+
+	/* 16 * 1024 / 64 = 0x100, so the max is 0xff for 8 bits data */
+	ocp_data = min_t(u32, ocp_data, 0xff);
+
+	ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, ocp_data);
+	r8156_fc_parameter(tp);
+
+	/* TX share fifo free credit full threshold */
+	ocp_write_word(tp, MCU_TYPE_PLA, PLA_TXFIFO_CTRL, 512 / 64);
+	ocp_write_word(tp, MCU_TYPE_PLA, PLA_TXFIFO_FULL,
+		       ALIGN(max_pkt_size + tp->tx_desc.size, 1024) / 16);
+}
+
 static void rtl8156_up(struct r8152 *tp)
 {
 	if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
@@ -6826,7 +6848,7 @@ static void rtl8156_up(struct r8152 *tp)
 
 	rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX);
 
-	rtl8156_change_mtu(tp);
+	tp->rtl_ops.change_mtu(tp);
 
 	switch (tp->version) {
 	case RTL_TEST_01:
@@ -9900,7 +9922,7 @@ static int rtl_ops_init(struct r8152 *tp)
 		ops->in_nway		= rtl8153_in_nway;
 		ops->hw_phy_cfg		= r8157_hw_phy_cfg;
 		ops->autosuspend_en	= rtl8157_runtime_enable;
-		ops->change_mtu		= rtl8156_change_mtu;
+		ops->change_mtu		= rtl8157_change_mtu;
 		tp->rx_buf_sz		= 32 * 1024;
 		tp->support_2500full	= 1;
 		tp->support_5000full	= 1;
@@ -9922,7 +9944,7 @@ static int rtl_ops_init(struct r8152 *tp)
 		ops->in_nway		= rtl8153_in_nway;
 		ops->hw_phy_cfg		= r8157_hw_phy_cfg;
 		ops->autosuspend_en	= rtl8157_runtime_enable;
-		ops->change_mtu		= rtl8156_change_mtu;
+		ops->change_mtu		= rtl8157_change_mtu;
 		tp->rx_buf_sz		= 48 * 1024;
 		tp->support_2500full	= 1;
 		tp->support_5000full	= 1;
-- 
2.34.1
Technical Details
Message-ID: <20261130063123.2408-4-nic_swsd@realtek.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373920-linux-kernel-netdev=dewy.ru
References: <20261130063123.2408-1-nic_swsd@realtek.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373920-linux-kernel-netdev=dewy.ru
From: hsu.chih.kai@realtek.com (Chih Kai Hsu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v10 03/12] r8152: add rtl8157_change_mtu() for RTL8157 and RTL8159
Date: Mon, 30 Nov 2026 14:31:14 +0800
Organization: Usenet Network
Message-ID: <20261130063123.2408-4-nic_swsd@realtek.com>
References: <20261130063123.2408-1-nic_swsd@realtek.com>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1354448"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FEuKsmZ7ONzpm+hCRkD9XamoTW0= sha256:PoDCtOKfBaXm1b18VJqcICQ91v0dElneQ+oGfJbCCkU=
	sha1:FhRdbjY2PakrgmQE4Jt8I6zuJKA= sha256:MZOgqVOaPzXwkMG83xbO3juzkH03cfmrMzGPlh5B9m8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id DCC35125FCA; Mon, 30 Nov 2026 09:32:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=realtek.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id uKcjbF_934BF;
	Mon, 30 Nov 2026 09:32:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373920-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=realtek.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id D4DD3125FC8; Mon, 30 Nov 2026 09:32:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 78C5E24802; Mon, 30 Nov 2026 06:32:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796020345;
	b=zLC/5sv0tDnwt61XJ4TcYl7MTX6UsTBkILC+Yg/6nJT7tuoY5r7mPyZkEppGQXHZ8f98
	 jDiP6G5SHtoPBPIReaO6ZdW+Ad5Re/G/uPRXP5v3UZAiFrWO85rquNpi22KZrdDkdNbBh
	 ILh5EP3o0nUhGwdNENUfjsnF3U5wZFr5BEDpU5rg5g+RY+2Cr+zi/OSY31Q8SNXeWs6aN
	 awnMWZQUCoNnifzeHHO6kwEzn7IYoqH2KKIQ11a6RNNn+QXDLanb1ipl5D2YAj+4yZki7
	 gZUAN6PQDHnVEDKoXu9x6qO8x9ExILyn/zzexngd5rkbcazmhTVkqWwuQTt8BiIrLxw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796020345;
	h=X-Original-To:Received:DMARC-Filter:X-SpamFilter-By:DKIM-Signature:
	 Received:Received:Received:Received:From:To:CC:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Transfer-Encoding:Content-Type;
	bh=LHfrTOMBua6GXQUw0lFn7woJp3q39K7l7mtv+0KaE8A=;
	b=qKyGvrjjA+j308u3rRynfodcfqyZNSiYVRq7F9SlRc9+OdLqat9svh/VqvEOj/ry2uCg
	 oRhNffFKXhPEJ2MSA5F6ct+W928jxOcr17zS6ucssJ2cmsY0EE2y13so+fe72fQFfostI
	 k6lauR2ouyLV/UHXqiYv1nL+Yy2n0kIijbhSkZEungU71Z0RrFWnNdEK3/u8XnHG6EyqE
	 ThQsuQUoXzxd6zeTz0OLeAuGNodihYNT3m/VDqtgriUKvqX5sSqKB2vZrnXt7BYY78ik+
	 9Yd0FGHzhT7x1fYaJnAMNUG4XgHqncrGWZtGOVbQBq8H9rQHGKOBxYN6YPhlLuAuOMg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b="fKjhy/r2";
	dmarc=pass header.from=realtek.com;
	spf=pass smtp.mailfrom=realtek.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 38CF8606A68A;
	Mon, 30 Nov 2026 06:32:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b=fKjhy/r2
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=211.75.126.72
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796020339;
	b=Ju5ulN64LSyiqqXsdXkl9rE+A+Fcmk8+m4ngEd5cSvsLT8qSTwxYVRIzr/+8Jyxnp4TR
	 j3/z7nbBjzMGB6bNN5C3POO7nKvCIR2M0BN6I6cEcPEbN78moVoK3XZnKcYVSpFvEmrO7
	 UPY4nEjV24/0zJIymoQvQiZ7vlOt3brJf3/yjQf7gLcu3z7D71GcvlP1Gukj9xJ3NC8ev
	 2Qa9Om1Ial81BCJh3AQXLYr/1OwloXSXtzoVpIFJPdq/9sfoOCMCfVw5vv+0N2Q3ldbrY
	 Q+atsf2RflicABfld3DN1GvUkI+URrdToOV5kRM8eqjYecJ+xakuHha5x7nJ2BWgl7g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796020339;
	h=DMARC-Filter:X-SpamFilter-By:DKIM-Signature:Received:Received:
	 Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:
	 Content-Type;
	bh=LHfrTOMBua6GXQUw0lFn7woJp3q39K7l7mtv+0KaE8A=;
	b=42qFuq2rtP5hhML3NdoTdPcon3M7e1LP/cK0yy9L0lt3uevLY7AsQUgpUXLFNQ2LCG0A
	 PKPbWQZSz4vCr0diyiWyHxh9cSQ9mBCA1EmJcSMQ2wrbmWlOer1DlZ9MSyJ5xuySDWQYo
	 oWTPxd24vMfO5fMVq5uLc4ULhHxhvYwLaQESA9q+2Ovt453LXFPq8xN9Haj1XD7xzhrqX
	 1lIm3mQ3fi+FqiJKixTA0YeFGvn7JgorH8zCUpPzKkBTkiBZsUt6nTnps93oVT7/FFaqw
	 0FjP7HnU7blew7kUUpSmWx+SaGl7CAgbkPiaBNgv39276ovThWfRpBS+W+QRRrUwtPA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=realtek.com;
	spf=pass smtp.mailfrom=realtek.com;
	dkim=pass header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b="fKjhy/r2";
	arc=none smtp.remote-ip=211.75.126.72
X-Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA8BA606A32A;
	Mon, 30 Nov 2026 06:32:18 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AA8BA606A32A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com
X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 6AU6VQmrC3113291, This message is accepted by code: ctloc85258
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realtek.com; s=dkim;
	t=1796020286; bh=LHfrTOMBua6GXQUw0lFn7woJp3q39K7l7mtv+0KaE8A=;
	h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding:Content-Type;
	b=fKjhy/r2f+1ZHtt2DwtDJAH8T+eAjiD5oCgtQPicDGdr1AQMhLyBo3ejLt3vfbxaK
	 LpfafkOlxCXEVh099zbRFCoV83CsHT3O0sknzrUl7KEKlOsWyuerI7cPTfeSr636oV
	 K4POqLRQHE6gxleh6UPBJVr64h262WZnYJLdI2KkFwIPovVaPuU1yvvptGrlhWOumd
	 gfl7uK1xJArk55atcrcW73pz5ZLGHJwe5Hya9AU5QH0XJh6WzR1VGG0Vn1admHOHV4
	 SsxHAIeXZ/LeagvdUaDzcVybRzkMjBUD1wN1yt2yBTYKgCZKbWttoJdy9DxJGjATGr
	 xXFaRtp/Fk36w==
X-Received: from mail.realtek.com (rtkexhmbs04.realtek.com.tw[10.21.1.54])
	by rtits2.realtek.com.tw (8.15.2/3.29/5.94) with ESMTPS id 6AU6VQmrC3113291
	(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL);
	Mon, 30 Nov 2026 14:31:26 +0800
X-Received: from RTKEXHMBS01.realtek.com.tw (172.21.6.40) by
 RTKEXHMBS04.realtek.com.tw (10.21.1.54) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.2562.56; Mon, 30 Nov 2026 14:31:26 +0800
X-Received: from RTKEXHMBS05.realtek.com.tw (10.21.1.55) by
 RTKEXHMBS01.realtek.com.tw (172.21.6.40) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.2562.56; Mon, 30 Nov 2026 14:31:26 +0800
X-Received: from fc44.realtek.com.tw (172.22.241.7) by
 RTKEXHMBS05.realtek.com.tw (10.21.1.55) with Microsoft SMTP Server id
 15.2.2562.56 via Frontend Transport; Mon, 30 Nov 2026 14:31:25 +0800
X-CC: <netdev@vger.kernel.org>, <nic_swsd@realtek.com>,
	<linux-kernel@vger.kernel.org>, <linux-usb@vger.kernel.org>,
	<edumazet@google.com>, <bjorn@mork.no>, <pabeni@redhat.com>,
	<hsu.chih.kai@realtek.com>, <andrew+netdev@lunn.ch>, <mail@birger-koblitz.de>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261130063123.2408-1-nic_swsd@realtek.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list