Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

r8152: support jumbo frame for RTL8153

The maximum jumbo frame size for RTL8153 is 9K bytes.
Change the max rx packet size to 9K.
Change the use of the shared fifo from 6K (default) to 12K for tx.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

hayeswang and committed by
David S. Miller
69b4b7a4 d6700790

+32 -4
+32 -4
drivers/net/usb/r8152.c
··· 59 59 #define PLA_WDT6_CTRL 0xe428 60 60 #define PLA_TCR0 0xe610 61 61 #define PLA_TCR1 0xe612 62 + #define PLA_MTPS 0xe615 62 63 #define PLA_TXFIFO_CTRL 0xe618 63 64 #define PLA_RSTTALLY 0xe800 64 65 #define PLA_CR 0xe813 ··· 180 179 181 180 /* PLA_TCR1 */ 182 181 #define VERSION_MASK 0x7cf0 182 + 183 + /* PLA_MTPS */ 184 + #define MTPS_JUMBO (12 * 1024 / 64) 185 + #define MTPS_DEFAULT (6 * 1024 / 64) 183 186 184 187 /* PLA_RSTTALLY */ 185 188 #define TALLY_RESET 0x0001 ··· 445 440 #define BYTE_EN_START_MASK 0x0f 446 441 #define BYTE_EN_END_MASK 0xf0 447 442 443 + #define RTL8153_MAX_PACKET 9216 /* 9K */ 444 + #define RTL8153_MAX_MTU (RTL8153_MAX_PACKET - VLAN_ETH_HLEN - VLAN_HLEN) 448 445 #define RTL8152_RMS (VLAN_ETH_FRAME_LEN + VLAN_HLEN) 446 + #define RTL8153_RMS RTL8153_MAX_PACKET 449 447 #define RTL8152_TX_TIMEOUT (5 * HZ) 450 448 451 449 /* rtl8152 flags */ ··· 2530 2522 ocp_data &= ~CPCR_RX_VLAN; 2531 2523 ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data); 2532 2524 2533 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); 2525 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); 2526 + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_JUMBO); 2534 2527 2535 2528 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); 2536 2529 ocp_data |= TCR0_AUTO_FIFO; ··· 2581 2572 mdelay(1); 2582 2573 } 2583 2574 2584 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); 2575 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); 2585 2576 2586 2577 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); 2587 2578 ocp_data &= ~TEREDO_WAKE_MASK; ··· 3293 3284 return res; 3294 3285 } 3295 3286 3287 + static int rtl8152_change_mtu(struct net_device *dev, int new_mtu) 3288 + { 3289 + struct r8152 *tp = netdev_priv(dev); 3290 + 3291 + switch (tp->version) { 3292 + case RTL_VER_01: 3293 + case RTL_VER_02: 3294 + return eth_change_mtu(dev, new_mtu); 3295 + default: 3296 + break; 3297 + } 3298 + 3299 + if (new_mtu < 68 || new_mtu > RTL8153_MAX_MTU) 3300 + return -EINVAL; 3301 + 3302 + dev->mtu = new_mtu; 3303 + 3304 + return 0; 3305 + } 3306 + 3296 3307 static const struct net_device_ops rtl8152_netdev_ops = { 3297 3308 .ndo_open = rtl8152_open, 3298 3309 .ndo_stop = rtl8152_close, ··· 3321 3292 .ndo_tx_timeout = rtl8152_tx_timeout, 3322 3293 .ndo_set_rx_mode = rtl8152_set_rx_mode, 3323 3294 .ndo_set_mac_address = rtl8152_set_mac_address, 3324 - 3325 - .ndo_change_mtu = eth_change_mtu, 3295 + .ndo_change_mtu = rtl8152_change_mtu, 3326 3296 .ndo_validate_addr = eth_validate_addr, 3327 3297 }; 3328 3298