Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Chih Kai Hsu
Mon, 30 Nov 2026 06:31
[PATCH net-next v10 03/12] r8152: add rtl8157_change_mtu() for RTL8157 and RTL8159
Author: Chih Kai Hsu
Date: Mon, 30 Nov 2026 06:31
Date: Mon, 30 Nov 2026 06:31
79 lines
12101 bytes
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
Re: [PATCH net-next v10 03/12] r8152: add rtl8157_change_mtu() for RTL8157 and RTL8159
Author: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 06:46
Date: Tue, 01 Dec 2026 06:46
52 lines
10026 bytes
10026 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit is tagged with two Fixes: tags (fd3c7d080df5 for
RTL8157 and ad2a55b63b41 for RTL8159), so it will be picked up forβ¦
--
r8152: add rtl8157_change_mtu() for RTL8157 and RTL8159
This commit adds rtl8157_change_mtu() for RTL8157 and RTL8159. The new
helper programs PLA_MTPS from the configured MTU: max_pkt_size / 64,
with a 10K minimum and a cap of 0xff. Before this, these chips used the
fixed MTPS_JUMBO from rtl8156_change_mtu(). rtl8156_up() now calls
tp->rtl_ops.change_mtu(), so each chip uses its own helper.
> 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.
[Severity: Low]
This patch has two Fixes: tags, so it will likely be picked up for
stable. Could the commit message say what actually goes wrong on RTL8157
and RTL8159 with the old fixed MTPS_JUMBO (12 * 1024 / 64 = 0xc0)?
The only reason given is the datasheet. The message names no symptom
and no affected MTU range. It also doesn't say whether the problem was
seen on hardware or found by reading the datasheet.
It may also be worth stating that this changes the value for normal
MTUs, not only for jumbo frames. In rtl8157_change_mtu(), the default
MTU of 1500 gives:
max_pkt_size = mtu_to_size(1500) = 1500 + 18 + 4 = 1522
ocp_data = max_t(u32, 1522, 10 * 1024) / 64 = 0xa0
So at the default MTU, PLA_MTPS drops from 12K to 10K. The new value
stays below the old 0xc0 until the MTU reaches roughly 12266. Above
that it is larger than before, and it hits the 0xff cap for MTUs near
max_mtu.
Without the user-visible impact, a stable backporter can't easily tell
two cases apart. Does the bug only affect frames above 12K? Or is
lowering MTPS for standard MTUs also intended and safe to backport?
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130063123.2408-1-nic_swsd%40realtek.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads