1 --- linux-2.6.27.5/drivers/net/korina.c 2008-11-07 18:55:34.000000000 +0100
2 +++ ../build_dir/linux-rb532/linux-2.6.27.5/drivers/net/korina.c 2008-11-16 00:38:19.000000000 +0100
5 dmas = readl(&lp->rx_dma_regs->dmas);
6 if (dmas & (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR)) {
7 - netif_rx_schedule_prep(dev, &lp->napi);
9 dmasm = readl(&lp->rx_dma_regs->dmasm);
10 writel(dmasm | (DMA_STAT_DONE |
11 DMA_STAT_HALT | DMA_STAT_ERR),
12 &lp->rx_dma_regs->dmasm);
13 + netif_rx_schedule(dev, &lp->napi);
15 if (dmas & DMA_STAT_ERR)
16 printk(KERN_ERR DRV_NAME "%s: DMA error\n", dev->name);
18 struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done];
19 struct sk_buff *skb, *skb_new;
21 - u32 devcs, pkt_len, dmas, rx_free_desc;
22 + u32 devcs, pkt_len, dmas, pktuncrc_len;
25 dma_cache_inv((u32)rd, sizeof(*rd));
27 for (count = 0; count < limit; count++) {
31 + pkt_len = RCVPKT_LENGTH(devcs);
32 + skb = lp->rx_skb[lp->rx_next_done];
34 + if ((devcs & ETH_RX_LD) != ETH_RX_LD) {
35 + /* check that this is a whole packet
36 + * WARNING: DMA_FD bit incorrectly set
37 + * in Rc32434 (errata ref #077) */
38 + dev->stats.rx_errors++;
39 + dev->stats.rx_dropped++;
42 /* Update statistics counters */
43 if (devcs & ETH_RX_CRC)
45 if (devcs & ETH_RX_MP)
46 dev->stats.multicast++;
48 - if ((devcs & ETH_RX_LD) != ETH_RX_LD) {
49 - /* check that this is a whole packet
50 - * WARNING: DMA_FD bit incorrectly set
51 - * in Rc32434 (errata ref #077) */
52 - dev->stats.rx_errors++;
53 - dev->stats.rx_dropped++;
56 - while ((rx_free_desc = KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) != 0) {
57 - /* init the var. used for the later
58 - * operations within the while loop */
60 - pkt_len = RCVPKT_LENGTH(devcs);
61 - skb = lp->rx_skb[lp->rx_next_done];
63 - if ((devcs & ETH_RX_ROK)) {
64 - /* must be the (first and) last
65 - * descriptor then */
66 - pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
67 + else if ((devcs & ETH_RX_ROK)) {
68 + /* must be the (first and) last
69 + * descriptor then */
70 + pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
71 + pktuncrc_len = pkt_len - 4;
73 - /* invalidate the cache */
74 - dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
75 + /* invalidate the cache */
76 + dma_cache_inv((unsigned long)pkt_buf, pktuncrc_len);
78 - /* Malloc up new buffer. */
79 - skb_new = netdev_alloc_skb(dev, KORINA_RBSIZE + 2);
80 + /* Malloc up new buffer. */
81 + skb_new = netdev_alloc_skb(dev, KORINA_RBSIZE + 2);
86 /* Do not count the CRC */
87 - skb_put(skb, pkt_len - 4);
88 + skb_put(skb, pktuncrc_len);
89 skb->protocol = eth_type_trans(skb, dev);
91 /* Pass the packet to upper layers */
92 netif_receive_skb(skb);
94 dev->last_rx = jiffies;
95 dev->stats.rx_packets++;
96 - dev->stats.rx_bytes += pkt_len;
98 - /* Update the mcast stats */
99 - if (devcs & ETH_RX_MP)
100 - dev->stats.multicast++;
102 + dev->stats.rx_bytes += pktuncrc_len;
104 lp->rx_skb[lp->rx_next_done] = skb_new;
106 + dev->stats.rx_errors++;
107 + dev->stats.rx_dropped++;
110 + dev->stats.rx_errors++;
111 + dev->stats.rx_dropped++;
113 + /* Update statistics counters */
114 + if (devcs & ETH_RX_CRC)
115 + dev->stats.rx_crc_errors++;
116 + else if (devcs & ETH_RX_LOR)
117 + dev->stats.rx_length_errors++;
118 + else if (devcs & ETH_RX_LE)
119 + dev->stats.rx_length_errors++;
120 + else if (devcs & ETH_RX_OVR)
121 + dev->stats.rx_over_errors++;
122 + else if (devcs & ETH_RX_CV)
123 + dev->stats.rx_frame_errors++;
124 + else if (devcs & ETH_RX_CES)
125 + dev->stats.rx_length_errors++;
126 + else if (devcs & ETH_RX_MP)
127 + dev->stats.multicast++;
133 - /* Restore descriptor's curr_addr */
135 - rd->ca = CPHYSADDR(skb_new->data);
137 - rd->ca = CPHYSADDR(skb->data);
138 + /* Restore descriptor's curr_addr */
140 + rd->ca = CPHYSADDR(skb_new->data);
142 + rd->ca = CPHYSADDR(skb->data);
144 - rd->control = DMA_COUNT(KORINA_RBSIZE) |
145 + rd->control = DMA_COUNT(KORINA_RBSIZE) |
146 DMA_DESC_COD | DMA_DESC_IOD;
147 - lp->rd_ring[(lp->rx_next_done - 1) &
148 - KORINA_RDS_MASK].control &=
151 - lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
152 - dma_cache_wback((u32)rd, sizeof(*rd));
153 - rd = &lp->rd_ring[lp->rx_next_done];
154 - writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
156 + lp->rd_ring[(lp->rx_next_done - 1) &
157 + KORINA_RDS_MASK].control &= ~DMA_DESC_COD;
159 + lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
160 + dma_cache_wback((u32)rd, sizeof(*rd));
161 + rd = &lp->rd_ring[lp->rx_next_done];
162 + writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
165 dmas = readl(&lp->rx_dma_regs->dmas);
167 if (dmas & DMA_STAT_HALT) {
168 + /* Mask off halt and errors bits */
169 writel(~(DMA_STAT_HALT | DMA_STAT_ERR),
170 &lp->rx_dma_regs->dmas);
173 if (work_done < budget) {
174 netif_rx_complete(dev, napi);
176 + /* Mask off interrupts */
177 writel(readl(&lp->rx_dma_regs->dmasm) &
178 - ~(DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR),
179 + (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR),
180 &lp->rx_dma_regs->dmasm);
183 @@ -534,10 +548,11 @@
185 struct korina_private *lp = netdev_priv(dev);
186 struct dma_desc *td = &lp->td_ring[lp->tx_next_done];
187 + unsigned long flags;
191 - spin_lock(&lp->lock);
192 + spin_lock_irqsave(&lp->lock, flags);
194 /* Process all desc that are done */
195 while (IS_DMA_FINISHED(td->control)) {
197 ~(DMA_STAT_FINI | DMA_STAT_ERR),
198 &lp->tx_dma_regs->dmasm);
200 - spin_unlock(&lp->lock);
201 + spin_unlock_irqrestore(&lp->lock, flags);
205 @@ -624,11 +639,10 @@
206 dmas = readl(&lp->tx_dma_regs->dmas);
208 if (dmas & (DMA_STAT_FINI | DMA_STAT_ERR)) {
211 dmasm = readl(&lp->tx_dma_regs->dmasm);
212 writel(dmasm | (DMA_STAT_FINI | DMA_STAT_ERR),
213 &lp->tx_dma_regs->dmasm);
216 if (lp->tx_chain_status == desc_filled &&
217 (readl(&(lp->tx_dma_regs->dmandptr)) == 0)) {
218 @@ -1078,11 +1092,18 @@
220 static int korina_probe(struct platform_device *pdev)
222 - struct korina_device *bif = platform_get_drvdata(pdev);
223 + struct korina_device *bif;
224 struct korina_private *lp;
225 struct net_device *dev;
228 + DECLARE_MAC_BUF(mac);
230 + bif = (struct korina_device *)pdev->dev.platform_data;
232 + printk(KERN_ERR DRV_NAME ": missing platform_data\n");
236 dev = alloc_etherdev(sizeof(struct korina_private));
238 @@ -1172,6 +1193,7 @@
239 ": cannot register net device %d\n", rc);
240 goto probe_err_register;
242 + printk(KERN_INFO DRV_NAME ": registered %s, IRQ %d MAC %s\n", dev->name, dev->irq, print_mac(mac, dev->dev_addr));