[ar71xx] remove root cmdline option
[openwrt.git] / target / linux / ar7 / patches-2.6.25 / 160-cpmac-rx-ring-use-eoq.diff
1 --- a/drivers/net/cpmac.c
2 +++ b/drivers/net/cpmac.c
3 @@ -187,6 +187,7 @@
4 #define CPMAC_EOQ 0x1000
5 struct sk_buff *skb;
6 struct cpmac_desc *next;
7 + struct cpmac_desc *prev;
8 dma_addr_t mapping;
9 dma_addr_t data_mapping;
10 };
11 @@ -242,6 +243,16 @@
12 printk("\n");
13 }
14
15 +static void cpmac_dump_all_desc(struct net_device *dev)
16 +{
17 + struct cpmac_priv *priv = netdev_priv(dev);
18 + struct cpmac_desc *dump = priv->rx_head;
19 + do {
20 + cpmac_dump_desc(dev, dump);
21 + dump = dump->next;
22 + } while (dump != priv->rx_head);
23 +}
24 +
25 static void cpmac_dump_skb(struct net_device *dev, struct sk_buff *skb)
26 {
27 int i;
28 @@ -413,21 +424,40 @@
29 static int cpmac_poll(struct napi_struct *napi, int budget)
30 {
31 struct sk_buff *skb;
32 - struct cpmac_desc *desc;
33 - int received = 0;
34 + struct cpmac_desc *desc, *restart;
35 struct cpmac_priv *priv = container_of(napi, struct cpmac_priv, napi);
36 + int received = 0, processed = 0;
37
38 spin_lock(&priv->rx_lock);
39 if (unlikely(!priv->rx_head)) {
40 if (netif_msg_rx_err(priv) && net_ratelimit())
41 printk(KERN_WARNING "%s: rx: polling, but no queue\n",
42 priv->dev->name);
43 + spin_unlock(&priv->rx_lock);
44 netif_rx_complete(priv->dev, napi);
45 return 0;
46 }
47
48 desc = priv->rx_head;
49 + restart = NULL;
50 while (((desc->dataflags & CPMAC_OWN) == 0) && (received < budget)) {
51 + processed++;
52 +
53 + if ((desc->dataflags & CPMAC_EOQ) != 0) {
54 + /* The last update to eoq->hw_next didn't happen soon enough, and the
55 + * receiver stopped here. Remember this descriptor so we can restart
56 + * the receiver after freeing some space.
57 + */
58 + if (unlikely(restart)) {
59 + if (netif_msg_rx_err(priv))
60 + printk(KERN_ERR "%s: poll found a duplicate EOQ: %p and %p\n",
61 + priv->dev->name, restart, desc);
62 + goto fatal_error;
63 + }
64 +
65 + restart = desc->next;
66 + }
67 +
68 skb = cpmac_rx_one(priv, desc);
69 if (likely(skb)) {
70 netif_receive_skb(skb);
71 @@ -436,19 +466,81 @@
72 desc = desc->next;
73 }
74
75 + if (desc != priv->rx_head) {
76 + /* We freed some buffers, but not the whole ring, add what we did free to the rx list */
77 + desc->prev->hw_next = (u32)0;
78 + priv->rx_head->prev->hw_next = priv->rx_head->mapping;
79 + }
80 +
81 + /* Optimization: If we did not actually process an EOQ (perhaps because of
82 + * quota limits), check to see if the tail of the queue has EOQ set. We
83 + * should immediately restart in that case so that the receiver can restart
84 + * and run in parallel with more packet processing. This lets us handle slightly
85 + * larger bursts before running out of ring space (assuming dev->weight < ring_size)
86 + */
87 + if (!restart &&
88 + (priv->rx_head->prev->dataflags & (CPMAC_OWN|CPMAC_EOQ)) == CPMAC_EOQ &&
89 + (priv->rx_head->dataflags & CPMAC_OWN) != 0) {
90 + /* reset EOQ so the poll loop (above) doesn't try to restart this when it
91 + * eventually gets to this descriptor.
92 + */
93 + priv->rx_head->prev->dataflags &= ~CPMAC_EOQ;
94 + restart = priv->rx_head;
95 + }
96 +
97 + if (restart) {
98 + priv->dev->stats.rx_errors++;
99 + priv->dev->stats.rx_fifo_errors++;
100 + if (netif_msg_rx_err(priv) && net_ratelimit())
101 + printk(KERN_WARNING "%s: rx dma ring overrun\n", priv->dev->name);
102 +
103 + if (unlikely((restart->dataflags & CPMAC_OWN) == 0)) {
104 + if (netif_msg_drv(priv))
105 + printk(KERN_ERR "%s: cpmac_poll is trying to restart rx from a descriptor that's not free: %p\n",
106 + priv->dev->name, restart);
107 + goto fatal_error;
108 + }
109 +
110 + cpmac_write(priv->regs, CPMAC_RX_PTR(0), restart->mapping);
111 + }
112 +
113 priv->rx_head = desc;
114 spin_unlock(&priv->rx_lock);
115 if (unlikely(netif_msg_rx_status(priv)))
116 printk(KERN_DEBUG "%s: poll processed %d packets\n",
117 priv->dev->name, received);
118 - if (desc->dataflags & CPMAC_OWN) {
119 + if (processed == 0) {
120 + /* we ran out of packets to read, revert to interrupt-driven mode */
121 netif_rx_complete(priv->dev, napi);
122 - cpmac_write(priv->regs, CPMAC_RX_PTR(0), (u32)desc->mapping);
123 cpmac_write(priv->regs, CPMAC_RX_INT_ENABLE, 1);
124 return 0;
125 }
126
127 return 1;
128 +
129 +fatal_error:
130 + /* Something went horribly wrong. Reset hardware to try to recover rather than wedging. */
131 +
132 + if (netif_msg_drv(priv)) {
133 + printk(KERN_ERR "%s: cpmac_poll is confused. Resetting hardware\n", priv->dev->name);
134 + cpmac_dump_all_desc(priv->dev);
135 + printk(KERN_DEBUG "%s: RX_PTR(0)=0x%08x RX_ACK(0)=0x%08x\n",
136 + priv->dev->name,
137 + cpmac_read(priv->regs, CPMAC_RX_PTR(0)),
138 + cpmac_read(priv->regs, CPMAC_RX_ACK(0)));
139 + }
140 +
141 + spin_unlock(&priv->rx_lock);
142 + netif_rx_complete(priv->dev, napi);
143 + netif_stop_queue(priv->dev);
144 + napi_disable(&priv->napi);
145 +
146 + atomic_inc(&priv->reset_pending);
147 + cpmac_hw_stop(priv->dev);
148 + if (!schedule_work(&priv->reset_work))
149 + atomic_dec(&priv->reset_pending);
150 + return 0;
151 +
152 }
153
154 static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
155 @@ -625,8 +717,10 @@
156 desc->dataflags = CPMAC_OWN;
157 dev->stats.rx_dropped++;
158 }
159 + desc->hw_next = desc->next->mapping;
160 desc = desc->next;
161 }
162 + priv->rx_head->prev->hw_next = 0;
163 }
164
165 static void cpmac_clear_tx(struct net_device *dev)
166 @@ -928,9 +1022,12 @@
167 desc->buflen = CPMAC_SKB_SIZE;
168 desc->dataflags = CPMAC_OWN;
169 desc->next = &priv->rx_head[(i + 1) % priv->ring_size];
170 + desc->next->prev = desc;
171 desc->hw_next = (u32)desc->next->mapping;
172 }
173
174 + priv->rx_head->prev->hw_next = (u32)0;
175 +
176 if ((res = request_irq(dev->irq, cpmac_irq, IRQF_SHARED,
177 dev->name, dev))) {
178 if (netif_msg_drv(priv))
This page took 0.048806 seconds and 5 git commands to generate.