Skip to content

Commit 8fb106b

Browse files
committed
Merge branch 'r8152-rx-settings'
Hayes Wang says: ==================== r8152: fix the rx settings of RTL8153 The RMS and the rx early size should base on the same rx size. However, the RMS is set to 9K bytes now and the rx early depends on mtu. For using the rx buffer effectively, sync the two settings according to the mtu. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a05d4fd + b20cb60 commit 8fb106b

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

drivers/net/usb/r8152.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define NETNEXT_VERSION "08"
3333

3434
/* Information for net */
35-
#define NET_VERSION "8"
35+
#define NET_VERSION "9"
3636

3737
#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
3838
#define DRIVER_AUTHOR "Realtek linux nic maintainers <[email protected]>"
@@ -501,6 +501,8 @@ enum rtl_register_content {
501501
#define RTL8153_RMS RTL8153_MAX_PACKET
502502
#define RTL8152_TX_TIMEOUT (5 * HZ)
503503
#define RTL8152_NAPI_WEIGHT 64
504+
#define rx_reserved_size(x) ((x) + VLAN_ETH_HLEN + CRC_SIZE + \
505+
sizeof(struct rx_desc) + RX_ALIGN)
504506

505507
/* rtl8152 flags */
506508
enum rtl8152_flags {
@@ -2253,8 +2255,7 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp)
22532255

22542256
static void r8153_set_rx_early_size(struct r8152 *tp)
22552257
{
2256-
u32 mtu = tp->netdev->mtu;
2257-
u32 ocp_data = (agg_buf_sz - mtu - VLAN_ETH_HLEN - VLAN_HLEN) / 8;
2258+
u32 ocp_data = (agg_buf_sz - rx_reserved_size(tp->netdev->mtu)) / 4;
22582259

22592260
ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data);
22602261
}
@@ -2899,7 +2900,8 @@ static void r8153_first_init(struct r8152 *tp)
28992900

29002901
rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX);
29012902

2902-
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS);
2903+
ocp_data = tp->netdev->mtu + VLAN_ETH_HLEN + CRC_SIZE;
2904+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, ocp_data);
29032905
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_JUMBO);
29042906

29052907
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0);
@@ -2951,7 +2953,8 @@ static void r8153_enter_oob(struct r8152 *tp)
29512953
usleep_range(1000, 2000);
29522954
}
29532955

2954-
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS);
2956+
ocp_data = tp->netdev->mtu + VLAN_ETH_HLEN + CRC_SIZE;
2957+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, ocp_data);
29552958

29562959
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG);
29572960
ocp_data &= ~TEREDO_WAKE_MASK;
@@ -4201,8 +4204,14 @@ static int rtl8152_change_mtu(struct net_device *dev, int new_mtu)
42014204

42024205
dev->mtu = new_mtu;
42034206

4204-
if (netif_running(dev) && netif_carrier_ok(dev))
4205-
r8153_set_rx_early_size(tp);
4207+
if (netif_running(dev)) {
4208+
u32 rms = new_mtu + VLAN_ETH_HLEN + CRC_SIZE;
4209+
4210+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, rms);
4211+
4212+
if (netif_carrier_ok(dev))
4213+
r8153_set_rx_early_size(tp);
4214+
}
42064215

42074216
mutex_unlock(&tp->control);
42084217

0 commit comments

Comments
 (0)