[8.09] kernel: refresh patches
[openwrt/svn-archive/archive.git] / target / linux / rb532 / patches-2.6.23 / 240-via_rhine_performance.patch
1 --- a/drivers/net/via-rhine.c
2 +++ b/drivers/net/via-rhine.c
3 @@ -33,6 +33,8 @@
4 #define DRV_VERSION "1.4.3"
5 #define DRV_RELDATE "2007-03-06"
6
7 +#define PKT_ALIGN 1
8 +
9
10 /* A few user-configurable values.
11 These may be modified when a driver module is loaded. */
12 @@ -40,6 +42,7 @@
13 static int debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */
14 static int max_interrupt_work = 20;
15
16 +#ifndef PKT_ALIGN
17 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
18 Setting to > 1518 effectively disables this feature. */
19 #if defined(__alpha__) || defined(__arm__) || defined(__hppa__) \
20 @@ -49,6 +52,7 @@ static int rx_copybreak = 1518;
21 #else
22 static int rx_copybreak;
23 #endif
24 +#endif /* PKT_ALIGN */
25
26 /* Work-around for broken BIOSes: they are unable to get the chip back out of
27 power state D3 so PXE booting fails. bootparam(7): via-rhine.avoid_D3=1 */
28 @@ -111,6 +115,7 @@ static const int multicast_filter_limit
29 #include <asm/io.h>
30 #include <asm/irq.h>
31 #include <asm/uaccess.h>
32 +#include <asm/unaligned.h>
33 #include <linux/dmi.h>
34
35 /* These identify the driver base version and may not be removed. */
36 @@ -130,12 +135,14 @@ MODULE_LICENSE("GPL");
37
38 module_param(max_interrupt_work, int, 0);
39 module_param(debug, int, 0);
40 -module_param(rx_copybreak, int, 0);
41 module_param(avoid_D3, bool, 0);
42 MODULE_PARM_DESC(max_interrupt_work, "VIA Rhine maximum events handled per interrupt");
43 MODULE_PARM_DESC(debug, "VIA Rhine debug level (0-7)");
44 -MODULE_PARM_DESC(rx_copybreak, "VIA Rhine copy breakpoint for copy-only-tiny-frames");
45 MODULE_PARM_DESC(avoid_D3, "Avoid power state D3 (work-around for broken BIOSes)");
46 +#ifndef PKT_ALIGN
47 +module_param(rx_copybreak, int, 0);
48 +MODULE_PARM_DESC(rx_copybreak, "VIA Rhine copy breakpoint for copy-only-tiny-frames");
49 +#endif
50
51 /*
52 Theory of Operation
53 @@ -927,7 +934,7 @@ static void alloc_rbufs(struct net_devic
54
55 /* Fill in the Rx buffers. Handle allocation failure gracefully. */
56 for (i = 0; i < RX_RING_SIZE; i++) {
57 - struct sk_buff *skb = dev_alloc_skb(rp->rx_buf_sz);
58 + struct sk_buff *skb = dev_alloc_skb(rp->rx_buf_sz + 4);
59 rp->rx_skbuff[i] = skb;
60 if (skb == NULL)
61 break;
62 @@ -1484,7 +1491,9 @@ static int rhine_rx(struct net_device *d
63 struct sk_buff *skb;
64 /* Length should omit the CRC */
65 int pkt_len = data_size - 4;
66 -
67 +#ifdef PKT_ALIGN
68 + int i;
69 +#else
70 /* Check if the packet is long enough to accept without
71 copying to a minimally-sized skbuff. */
72 if (pkt_len < rx_copybreak &&
73 @@ -1503,7 +1512,9 @@ static int rhine_rx(struct net_device *d
74 rp->rx_skbuff_dma[entry],
75 rp->rx_buf_sz,
76 PCI_DMA_FROMDEVICE);
77 - } else {
78 + } else
79 +#endif
80 + {
81 skb = rp->rx_skbuff[entry];
82 if (skb == NULL) {
83 printk(KERN_ERR "%s: Inconsistent Rx "
84 @@ -1517,6 +1528,14 @@ static int rhine_rx(struct net_device *d
85 rp->rx_skbuff_dma[entry],
86 rp->rx_buf_sz,
87 PCI_DMA_FROMDEVICE);
88 +#ifdef PKT_ALIGN
89 + /* align the data to the ip header - should be faster than copying the entire packet */
90 + for (i = pkt_len - (pkt_len % 4); i >= 0; i -= 4) {
91 + put_unaligned(*((u32 *) (skb->data + i)), (u32 *) (skb->data + i + 2));
92 + }
93 + skb->data += 2;
94 + skb->tail += 2;
95 +#endif
96 }
97 skb->protocol = eth_type_trans(skb, dev);
98 #ifdef CONFIG_VIA_RHINE_NAPI