]>
Commit | Line | Data |
---|---|---|
8043cbef GKH |
1 | From 8812304cf1110ae16b0778680f6022216cf4716a Mon Sep 17 00:00:00 2001 |
2 | From: Raimonds Cicans <ray@apollo.lv> | |
3 | Date: Fri, 13 Nov 2009 10:52:19 +0000 | |
4 | Subject: r8169: Fix receive buffer length when MTU is between 1515 and 1536 | |
5 | ||
6 | From: Raimonds Cicans <ray@apollo.lv> | |
7 | ||
8 | commit 8812304cf1110ae16b0778680f6022216cf4716a upstream. | |
9 | ||
10 | In r8169 driver MTU is used to calculate receive buffer size. | |
11 | Receive buffer size is used to configure hardware incoming packet filter. | |
12 | ||
13 | For jumbo frames: | |
14 | Receive buffer size = Max frame size = MTU + 14 (ethernet header) + 4 | |
15 | (vlan header) + 4 (ethernet checksum) = MTU + 22 | |
16 | ||
17 | Bug: | |
18 | driver for all MTU up to 1536 use receive buffer size 1536 | |
19 | ||
20 | As you can see from formula, this mean all IP packets > 1536 - 22 | |
21 | (for vlan tagged, 1536 - 18 for not tagged) are dropped by hardware | |
22 | filter. | |
23 | ||
24 | Example: | |
25 | ||
26 | host_good> ifconfig eth0 mtu 1536 | |
27 | host_r8169> ifconfig eth0 mtu 1536 | |
28 | host_good> ping host_r8169 | |
29 | Ok | |
30 | host_good> ping -s 1500 host_r8169 | |
31 | Fail | |
32 | host_good> ifconfig eth0 mtu 7000 | |
33 | host_r8169> ifconfig eth0 mtu 7000 | |
34 | host_good> ping -s 1500 host_r8169 | |
35 | Ok | |
36 | ||
37 | Bonus: got rid of magic number 8 | |
38 | ||
39 | Signed-off-by: Raimonds Cicans <ray@apollo.lv> | |
40 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
41 | Cc: Jean Delvare <khali@linux-fr.org> | |
42 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
43 | ||
44 | --- | |
45 | drivers/net/r8169.c | 4 ++-- | |
46 | 1 file changed, 2 insertions(+), 2 deletions(-) | |
47 | ||
48 | --- a/drivers/net/r8169.c | |
49 | +++ b/drivers/net/r8169.c | |
50 | @@ -1842,9 +1842,9 @@ static void __devexit rtl8169_remove_one | |
51 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, | |
52 | struct net_device *dev) | |
53 | { | |
54 | - unsigned int mtu = dev->mtu; | |
55 | + unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; | |
56 | ||
57 | - tp->rx_buf_sz = (mtu > RX_BUF_SIZE) ? mtu + ETH_HLEN + 8 : RX_BUF_SIZE; | |
58 | + tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; | |
59 | } | |
60 | ||
61 | static int rtl8169_open(struct net_device *dev) |