1 diff -urN linux.old/drivers/net/Kconfig linux.dev/drivers/net/Kconfig
2 --- linux.old/drivers/net/Kconfig 2006-06-08 20:21:20.000000000 +0200
3 +++ linux.dev/drivers/net/Kconfig 2006-06-08 20:19:40.000000000 +0200
6 source "drivers/net/arm/Kconfig"
9 + tristate "Korina Local Ethernet support"
10 + depends on NET_ETHERNET && ( IDT_EB434 || MIKROTIK_RB500)
12 + IDT RC32434 has one local ethernet port. Say Y here to enable it.
13 + To compile this driver as a module, choose M here.
16 tristate "MACE (Power Mac ethernet) support"
17 depends on NET_ETHERNET && PPC_PMAC && PPC32
18 diff -urN linux.old/drivers/net/korina.c linux.dev/drivers/net/korina.c
19 --- linux.old/drivers/net/korina.c 1970-01-01 01:00:00.000000000 +0100
20 +++ linux.dev/drivers/net/korina.c 2006-06-09 00:48:40.000000000 +0200
22 +/**************************************************************************
24 + * BRIEF MODULE DESCRIPTION
25 + * Driver for the IDT RC32434 on-chip ethernet controller.
27 + * Copyright 2004 IDT Inc. (rischelp@idt.com)
29 + * This program is free software; you can redistribute it and/or modify it
30 + * under the terms of the GNU General Public License as published by the
31 + * Free Software Foundation; either version 2 of the License, or (at your
32 + * option) any later version.
34 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
35 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
37 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
38 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
39 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
40 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
43 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 + * You should have received a copy of the GNU General Public License along
46 + * with this program; if not, write to the Free Software Foundation, Inc.,
47 + * 675 Mass Ave, Cambridge, MA 02139, USA.
50 + **************************************************************************
53 + * Based on the driver developed by B. Maruthanayakam, H. Kou and others.
59 + **************************************************************************
62 +#include <linux/config.h>
63 +#include <linux/module.h>
64 +#include <linux/kernel.h>
65 +#include <linux/moduleparam.h>
66 +#include <linux/sched.h>
67 +#include <linux/ctype.h>
68 +#include <linux/types.h>
69 +#include <linux/fcntl.h>
70 +#include <linux/interrupt.h>
71 +#include <linux/ptrace.h>
72 +#include <linux/init.h>
73 +#include <linux/ioport.h>
74 +#include <linux/proc_fs.h>
75 +#include <linux/in.h>
76 +#include <linux/slab.h>
77 +#include <linux/string.h>
78 +#include <linux/delay.h>
79 +#include <linux/netdevice.h>
80 +#include <linux/etherdevice.h>
81 +#include <linux/skbuff.h>
82 +#include <linux/errno.h>
83 +#include <linux/platform_device.h>
84 +#include <asm/bootinfo.h>
85 +#include <asm/system.h>
86 +#include <asm/bitops.h>
87 +#include <asm/pgtable.h>
88 +#include <asm/segment.h>
92 +#include <asm/rc32434/rb.h>
93 +#include "rc32434_eth.h"
95 +#define DRIVER_VERSION "(mar2904)"
97 +#define DRIVER_NAME "rc32434 Ethernet driver. " DRIVER_VERSION
99 +#define STATION_ADDRESS_HIGH(dev) (((dev)->dev_addr[0] << 8) | \
100 + ((dev)->dev_addr[1]))
101 +#define STATION_ADDRESS_LOW(dev) (((dev)->dev_addr[2] << 24) | \
102 + ((dev)->dev_addr[3] << 16) | \
103 + ((dev)->dev_addr[4] << 8) | \
104 + ((dev)->dev_addr[5]))
106 +#define MII_CLOCK 1250000 /* no more than 2.5MHz */
107 +#define CONFIG_IDT_USE_NAPI 1
110 +static inline void rc32434_abort_tx(struct net_device *dev)
112 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
113 + rc32434_abort_dma(dev, lp->tx_dma_regs);
117 +static inline void rc32434_abort_rx(struct net_device *dev)
119 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
120 + rc32434_abort_dma(dev, lp->rx_dma_regs);
124 +static inline void rc32434_start_tx(struct rc32434_local *lp, volatile DMAD_t td)
126 + rc32434_start_dma(lp->tx_dma_regs, CPHYSADDR(td));
129 +static inline void rc32434_start_rx(struct rc32434_local *lp, volatile DMAD_t rd)
131 + rc32434_start_dma(lp->rx_dma_regs, CPHYSADDR(rd));
134 +static inline void rc32434_chain_tx(struct rc32434_local *lp, volatile DMAD_t td)
136 + rc32434_chain_dma(lp->tx_dma_regs, CPHYSADDR(td));
139 +static inline void rc32434_chain_rx(struct rc32434_local *lp, volatile DMAD_t rd)
141 + rc32434_chain_dma(lp->rx_dma_regs, CPHYSADDR(rd));
144 +#ifdef RC32434_PROC_DEBUG
145 +static int rc32434_read_proc(char *buf, char **start, off_t fpos,
146 + int length, int *eof, void *data)
148 + struct net_device *dev = (struct net_device *)data;
149 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
152 + /* print out header */
153 + len += sprintf(buf + len, "\n\tKorina Ethernet Debug\n\n");
154 + len += sprintf (buf + len,
155 + "DMA halt count = %10d, DMA run count = %10d\n",
156 + lp->dma_halt_cnt, lp->dma_run_cnt);
163 + *start = buf + fpos;
165 + if ((len -= fpos) > length)
176 + * Restart the RC32434 ethernet controller.
178 +static int rc32434_restart(struct net_device *dev)
180 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
183 + * Disable interrupts
185 + disable_irq(lp->rx_irq);
186 + disable_irq(lp->tx_irq);
187 +#ifdef RC32434_REVISION
188 + disable_irq(lp->ovr_irq);
190 + disable_irq(lp->und_irq);
192 + /* Mask F E bit in Tx DMA */
193 + __raw_writel(__raw_readl(&lp->tx_dma_regs->dmasm) | DMASM_f_m | DMASM_e_m, &lp->tx_dma_regs->dmasm);
194 + /* Mask D H E bit in Rx DMA */
195 + __raw_writel(__raw_readl(&lp->rx_dma_regs->dmasm) | DMASM_d_m | DMASM_h_m | DMASM_e_m, &lp->rx_dma_regs->dmasm);
198 + rc32434_multicast_list(dev);
200 + enable_irq(lp->und_irq);
201 +#ifdef RC32434_REVISION
202 + enable_irq(lp->ovr_irq);
204 + enable_irq(lp->tx_irq);
205 + enable_irq(lp->rx_irq);
210 +static int rc32434_probe(struct platform_device *pdev)
212 + struct korina_device *bif = (struct korina_device *) pdev->dev.platform_data;
213 + struct rc32434_local *lp = NULL;
214 + struct net_device *dev = NULL;
215 + struct resource *r;
218 + dev = alloc_etherdev(sizeof(struct rc32434_local));
220 + ERR("Korina_eth: alloc_etherdev failed\n");
224 + platform_set_drvdata(pdev, dev);
225 + SET_MODULE_OWNER(dev);
228 + memcpy(dev->dev_addr, bif->mac, 6);
230 + /* Initialize the device structure. */
231 + if (dev->priv == NULL) {
232 + lp = (struct rc32434_local *)kmalloc(sizeof(*lp), GFP_KERNEL);
233 + memset(lp, 0, sizeof(struct rc32434_local));
236 + lp = (struct rc32434_local *)dev->priv;
239 + lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx");
240 + lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx");
241 + lp->ovr_irq = platform_get_irq_byname(pdev, "korina_ovr");
242 + lp->und_irq = platform_get_irq_byname(pdev, "korina_und");
244 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_regs");
245 + dev->base_addr = r->start;
246 + lp->eth_regs = ioremap_nocache(r->start, r->end - r->start);
247 + if (!lp->eth_regs) {
248 + ERR("Can't remap eth registers\n");
250 + goto probe_err_out;
253 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_rx");
254 + lp->rx_dma_regs = ioremap_nocache(r->start, r->end - r->start);
255 + if (!lp->rx_dma_regs) {
256 + ERR("Can't remap Rx DMA registers\n");
258 + goto probe_err_out;
261 + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_tx");
262 + lp->tx_dma_regs = ioremap_nocache(r->start, r->end - r->start);
263 + if (!lp->tx_dma_regs) {
264 + ERR("Can't remap Tx DMA registers\n");
266 + goto probe_err_out;
269 +#ifdef RC32434_PROC_DEBUG
270 + lp->ps = create_proc_read_entry (bif->name, 0, proc_net,
271 + rc32434_read_proc, dev);
274 + lp->td_ring = (DMAD_t)kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL);
275 + if (!lp->td_ring) {
276 + ERR("Can't allocate descriptors\n");
278 + goto probe_err_out;
281 + dma_cache_inv((unsigned long)(lp->td_ring), TD_RING_SIZE + RD_RING_SIZE);
283 + /* now convert TD_RING pointer to KSEG1 */
284 + lp->td_ring = (DMAD_t )KSEG1ADDR(lp->td_ring);
285 + lp->rd_ring = &lp->td_ring[RC32434_NUM_TDS];
288 + spin_lock_init(&lp->lock);
290 + /* just use the rx dma irq */
291 + dev->irq = lp->rx_irq;
295 + dev->open = rc32434_open;
296 + dev->stop = rc32434_close;
297 + dev->hard_start_xmit = rc32434_send_packet;
298 + dev->get_stats = rc32434_get_stats;
299 + dev->set_multicast_list = &rc32434_multicast_list;
300 + dev->tx_timeout = rc32434_tx_timeout;
301 + dev->watchdog_timeo = RC32434_TX_TIMEOUT;
303 +#ifdef CONFIG_IDT_USE_NAPI
304 + dev->poll = rc32434_poll;
306 + printk("Using NAPI with weight %d\n",dev->weight);
308 + lp->rx_tasklet = kmalloc(sizeof(struct tasklet_struct), GFP_KERNEL);
309 + tasklet_init(lp->rx_tasklet, rc32434_rx_tasklet, (unsigned long)dev);
311 + lp->tx_tasklet = kmalloc(sizeof(struct tasklet_struct), GFP_KERNEL);
312 + tasklet_init(lp->tx_tasklet, rc32434_tx_tasklet, (unsigned long)dev);
314 + if ((err = register_netdev(dev))) {
315 + printk(KERN_ERR "rc32434 ethernet. Cannot register net device %d\n", err);
318 + goto probe_err_out;
321 + INFO("Rx IRQ %d, Tx IRQ %d, ", lp->rx_irq, lp->tx_irq);
322 + for (i = 0; i < 6; i++) {
323 + printk("%2.2x", dev->dev_addr[i]);
332 + rc32434_cleanup_module();
333 + ERR(" failed. Returns %d\n", retval);
338 +static int rc32434_remove(struct platform_device *pdev)
340 + struct korina_device *bif = (struct korina_device *) pdev->dev.platform_data;
342 + if (bif->dev != NULL) {
343 + struct rc32434_local *lp = (struct rc32434_local *)bif->dev->priv;
346 + iounmap((void*)lp->eth_regs);
347 + if (lp->rx_dma_regs)
348 + iounmap((void*)lp->rx_dma_regs);
349 + if (lp->tx_dma_regs)
350 + iounmap((void*)lp->tx_dma_regs);
352 + kfree((void*)KSEG0ADDR(lp->td_ring));
354 +#ifdef RC32434_PROC_DEBUG
356 + remove_proc_entry(bif->name, proc_net);
362 + platform_set_drvdata(pdev, NULL);
363 + unregister_netdev(bif->dev);
364 + free_netdev(bif->dev);
371 +static int rc32434_open(struct net_device *dev)
373 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
376 + if (rc32434_init(dev)) {
377 + ERR("Error: cannot open the Ethernet device\n");
381 + /* Install the interrupt handler that handles the Done Finished Ovr and Und Events */
382 + if (request_irq(lp->rx_irq, &rc32434_rx_dma_interrupt,
383 + SA_SHIRQ | SA_INTERRUPT,
384 + "Korina ethernet Rx", dev)) {
385 + ERR(": unable to get Rx DMA IRQ %d\n",
389 + if (request_irq(lp->tx_irq, &rc32434_tx_dma_interrupt,
390 + SA_SHIRQ | SA_INTERRUPT,
391 + "Korina ethernet Tx", dev)) {
392 + ERR(": unable to get Tx DMA IRQ %d\n",
394 + free_irq(lp->rx_irq, dev);
398 +#ifdef RC32434_REVISION
399 + /* Install handler for overrun error. */
400 + if (request_irq(lp->ovr_irq, &rc32434_ovr_interrupt,
401 + SA_SHIRQ | SA_INTERRUPT,
402 + "Ethernet Overflow", dev)) {
403 + ERR(": unable to get OVR IRQ %d\n",
405 + free_irq(lp->rx_irq, dev);
406 + free_irq(lp->tx_irq, dev);
411 + /* Install handler for underflow error. */
412 + if (request_irq(lp->und_irq, &rc32434_und_interrupt,
413 + SA_SHIRQ | SA_INTERRUPT,
414 + "Ethernet Underflow", dev)) {
415 + ERR(": unable to get UND IRQ %d\n",
417 + free_irq(lp->rx_irq, dev);
418 + free_irq(lp->tx_irq, dev);
419 +#ifdef RC32434_REVISION
420 + free_irq(lp->ovr_irq, dev);
432 +static int rc32434_close(struct net_device *dev)
434 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
437 + /* Disable interrupts */
438 + disable_irq(lp->rx_irq);
439 + disable_irq(lp->tx_irq);
440 +#ifdef RC32434_REVISION
441 + disable_irq(lp->ovr_irq);
443 + disable_irq(lp->und_irq);
445 + tmp = __raw_readl(&lp->tx_dma_regs->dmasm);
446 + tmp = tmp | DMASM_f_m | DMASM_e_m;
447 + __raw_writel(tmp, &lp->tx_dma_regs->dmasm);
449 + tmp = __raw_readl(&lp->rx_dma_regs->dmasm);
450 + tmp = tmp | DMASM_d_m | DMASM_h_m | DMASM_e_m;
451 + __raw_writel(tmp, &lp->rx_dma_regs->dmasm);
453 + free_irq(lp->rx_irq, dev);
454 + free_irq(lp->tx_irq, dev);
455 +#ifdef RC32434_REVISION
456 + free_irq(lp->ovr_irq, dev);
458 + free_irq(lp->und_irq, dev);
463 +/* transmit packet */
464 +static int rc32434_send_packet(struct sk_buff *skb, struct net_device *dev)
466 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
467 + unsigned long flags;
472 + spin_lock_irqsave(&lp->lock, flags);
474 + td = &lp->td_ring[lp->tx_chain_tail];
476 + /* stop queue when full, drop pkts if queue already full */
477 + if(lp->tx_count >= (RC32434_NUM_TDS - 2)) {
480 + if(lp->tx_count == (RC32434_NUM_TDS - 2)) {
481 + netif_stop_queue(dev);
484 + lp->stats.tx_dropped++;
485 + dev_kfree_skb_any(skb);
486 + spin_unlock_irqrestore(&lp->lock, flags);
493 + lp->tx_skb[lp->tx_chain_tail] = skb;
497 + /* Setup the transmit descriptor. */
498 + td->ca = CPHYSADDR(skb->data);
500 + if(__raw_readl(&(lp->tx_dma_regs->dmandptr)) == 0) {
501 + if( lp->tx_chain_status == empty ) {
502 + td->control = DMA_COUNT(length) |DMAD_cof_m |DMAD_iof_m; /* Update tail */
503 + lp->tx_chain_tail = (lp->tx_chain_tail + 1) & RC32434_TDS_MASK; /* Move tail */
504 + __raw_writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), &(lp->tx_dma_regs->dmandptr)); /* Write to NDPTR */
505 + lp->tx_chain_head = lp->tx_chain_tail; /* Move head to tail */
508 + td->control = DMA_COUNT(length) |DMAD_cof_m|DMAD_iof_m; /* Update tail */
509 + lp->td_ring[(lp->tx_chain_tail-1)& RC32434_TDS_MASK].control &= ~(DMAD_cof_m); /* Link to prev */
510 + lp->td_ring[(lp->tx_chain_tail-1)& RC32434_TDS_MASK].link = CPHYSADDR(td); /* Link to prev */
511 + lp->tx_chain_tail = (lp->tx_chain_tail + 1) & RC32434_TDS_MASK; /* Move tail */
512 + __raw_writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), &(lp->tx_dma_regs->dmandptr)); /* Write to NDPTR */
513 + lp->tx_chain_head = lp->tx_chain_tail; /* Move head to tail */
514 + lp->tx_chain_status = empty;
518 + if( lp->tx_chain_status == empty ) {
519 + td->control = DMA_COUNT(length) |DMAD_cof_m |DMAD_iof_m; /* Update tail */
520 + lp->tx_chain_tail = (lp->tx_chain_tail + 1) & RC32434_TDS_MASK; /* Move tail */
521 + lp->tx_chain_status = filled;
524 + td->control = DMA_COUNT(length) |DMAD_cof_m |DMAD_iof_m; /* Update tail */
525 + lp->td_ring[(lp->tx_chain_tail-1)& RC32434_TDS_MASK].control &= ~(DMAD_cof_m); /* Link to prev */
526 + lp->td_ring[(lp->tx_chain_tail-1)& RC32434_TDS_MASK].link = CPHYSADDR(td); /* Link to prev */
527 + lp->tx_chain_tail = (lp->tx_chain_tail + 1) & RC32434_TDS_MASK; /* Move tail */
531 + dev->trans_start = jiffies;
533 + spin_unlock_irqrestore(&lp->lock, flags);
539 +/* Ethernet MII-PHY Handler */
540 +static void rc32434_mii_handler(unsigned long data)
542 + struct net_device *dev = (struct net_device *)data;
543 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
544 + unsigned long flags;
545 + unsigned long duplex_status;
546 + int port_addr = (lp->rx_irq == 0x2c? 1:0) << 8;
548 + spin_lock_irqsave(&lp->lock, flags);
550 + /* Two ports are using the same MII, the difference is the PHY address */
551 + __raw_writel(0, &rc32434_eth0_regs->miimcfg);
552 + __raw_writel(0, &rc32434_eth0_regs->miimcmd);
553 + __raw_writel(port_addr |0x05, &rc32434_eth0_regs->miimaddr);
554 + __raw_writel(MIIMCMD_scn_m, &rc32434_eth0_regs->miimcmd);
555 + while(__raw_readl(&rc32434_eth0_regs->miimind) & MIIMIND_nv_m);
557 + ERR("irq:%x port_addr:%x RDD:%x\n",
558 + lp->rx_irq, port_addr, __raw_readl(&rc32434_eth0_regs->miimrdd));
559 + duplex_status = (__raw_readl(&rc32434_eth0_regs->miimrdd) & 0x140)? ETHMAC2_fd_m: 0;
560 + if(duplex_status != lp->duplex_mode) {
561 + ERR("The MII-PHY is Auto-negotiated to %s-Duplex mode for Eth-%x\n", duplex_status? "Full":"Half", lp->rx_irq == 0x2c? 1:0);
562 + lp->duplex_mode = duplex_status;
563 + rc32434_restart(dev);
566 + lp->mii_phy_timer.expires = jiffies + 10 * HZ;
567 + add_timer(&lp->mii_phy_timer);
569 + spin_unlock_irqrestore(&lp->lock, flags);
573 +#ifdef RC32434_REVISION
574 +/* Ethernet Rx Overflow interrupt */
576 +rc32434_ovr_interrupt(int irq, void *dev_id, struct pt_regs * regs)
578 + struct net_device *dev = (struct net_device *)dev_id;
579 + struct rc32434_local *lp;
581 + irqreturn_t retval = IRQ_NONE;
583 + ASSERT(dev != NULL);
585 + lp = (struct rc32434_local *)dev->priv;
586 + spin_lock(&lp->lock);
587 + ovr = __raw_readl(&lp->eth_regs->ethintfc);
589 + if(ovr & ETHINTFC_ovr_m) {
590 + netif_stop_queue(dev);
592 + /* clear OVR bit */
593 + __raw_writel((ovr & ~ETHINTFC_ovr_m), &lp->eth_regs->ethintfc);
595 + /* Restart interface */
596 + rc32434_restart(dev);
597 + retval = IRQ_HANDLED;
599 + spin_unlock(&lp->lock);
607 +/* Ethernet Tx Underflow interrupt */
609 +rc32434_und_interrupt(int irq, void *dev_id, struct pt_regs * regs)
611 + struct net_device *dev = (struct net_device *)dev_id;
612 + struct rc32434_local *lp;
614 + irqreturn_t retval = IRQ_NONE;
616 + ASSERT(dev != NULL);
618 + lp = (struct rc32434_local *)dev->priv;
620 + spin_lock(&lp->lock);
622 + und = __raw_readl(&lp->eth_regs->ethintfc);
624 + if(und & ETHINTFC_und_m) {
625 + netif_stop_queue(dev);
627 + __raw_writel((und & ~ETHINTFC_und_m), &lp->eth_regs->ethintfc);
629 + /* Restart interface */
630 + rc32434_restart(dev);
631 + retval = IRQ_HANDLED;
634 + spin_unlock(&lp->lock);
640 +/* Ethernet Rx DMA interrupt */
642 +rc32434_rx_dma_interrupt(int irq, void *dev_id, struct pt_regs * regs)
644 + struct net_device *dev = (struct net_device *)dev_id;
645 + struct rc32434_local* lp;
646 + volatile u32 dmas,dmasm;
647 + irqreturn_t retval;
649 + ASSERT(dev != NULL);
651 + lp = (struct rc32434_local *)dev->priv;
653 + spin_lock(&lp->lock);
654 + dmas = __raw_readl(&lp->rx_dma_regs->dmas);
655 + if(dmas & (DMAS_d_m|DMAS_h_m|DMAS_e_m)) {
656 + /* Mask D H E bit in Rx DMA */
657 + dmasm = __raw_readl(&lp->rx_dma_regs->dmasm);
658 + __raw_writel(dmasm | (DMASM_d_m | DMASM_h_m | DMASM_e_m), &lp->rx_dma_regs->dmasm);
659 +#ifdef CONFIG_IDT_USE_NAPI
660 + if(netif_rx_schedule_prep(dev))
661 + __netif_rx_schedule(dev);
663 + tasklet_hi_schedule(lp->rx_tasklet);
666 + if (dmas & DMAS_e_m)
667 + ERR(": DMA error\n");
669 + retval = IRQ_HANDLED;
674 + spin_unlock(&lp->lock);
678 +#ifdef CONFIG_IDT_USE_NAPI
679 +static int rc32434_poll(struct net_device *rx_data_dev, int *budget)
681 +static void rc32434_rx_tasklet(unsigned long rx_data_dev)
684 + struct net_device *dev = (struct net_device *)rx_data_dev;
685 + struct rc32434_local* lp = netdev_priv(dev);
686 + volatile DMAD_t rd = &lp->rd_ring[lp->rx_next_done];
687 + struct sk_buff *skb, *skb_new;
689 + u32 devcs, count, pkt_len, pktuncrc_len;
691 +#ifdef CONFIG_IDT_USE_NAPI
693 + int rx_work_limit = min(*budget,dev->quota);
695 + unsigned long flags;
696 + spin_lock_irqsave(&lp->lock, flags);
699 + while ( (count = RC32434_RBSIZE - (u32)DMA_COUNT(rd->control)) != 0) {
700 +#ifdef CONFIG_IDT_USE_NAPI
701 + if(--rx_work_limit <0)
706 + /* init the var. used for the later operations within the while loop */
709 + pkt_len = RCVPKT_LENGTH(devcs);
710 + skb = lp->rx_skb[lp->rx_next_done];
713 + lp->stats.rx_errors++;
714 + lp->stats.rx_dropped++;
716 + else if ((devcs & ( ETHRX_ld_m)) != ETHRX_ld_m) {
717 + /* check that this is a whole packet */
718 + /* WARNING: DMA_FD bit incorrectly set in Rc32434 (errata ref #077) */
719 + lp->stats.rx_errors++;
720 + lp->stats.rx_dropped++;
722 + else if ( (devcs & ETHRX_rok_m) ) {
725 + /* must be the (first and) last descriptor then */
726 + pkt_buf = (u8*)lp->rx_skb[lp->rx_next_done]->data;
728 + pktuncrc_len = pkt_len - 4;
729 + /* invalidate the cache */
730 + dma_cache_inv((unsigned long)pkt_buf, pktuncrc_len);
732 + /* Malloc up new buffer. */
733 + skb_new = dev_alloc_skb(RC32434_RBSIZE + 2);
735 + if (skb_new != NULL){
737 + skb_put(skb, pktuncrc_len);
739 + skb->protocol = eth_type_trans(skb, dev);
741 + /* pass the packet to upper layers */
742 +#ifdef CONFIG_IDT_USE_NAPI
743 + netif_receive_skb(skb);
748 + dev->last_rx = jiffies;
749 + lp->stats.rx_packets++;
750 + lp->stats.rx_bytes += pktuncrc_len;
752 + if (IS_RCV_MP(devcs))
753 + lp->stats.multicast++;
756 + skb_reserve(skb_new, 2);
758 + skb_new->dev = dev;
759 + lp->rx_skb[lp->rx_next_done] = skb_new;
762 + ERR("no memory, dropping rx packet.\n");
763 + lp->stats.rx_errors++;
764 + lp->stats.rx_dropped++;
770 + /* This should only happen if we enable accepting broken packets */
771 + lp->stats.rx_errors++;
772 + lp->stats.rx_dropped++;
774 + /* add statistics counters */
775 + if (IS_RCV_CRC_ERR(devcs)) {
776 + DBG(2, "RX CRC error\n");
777 + lp->stats.rx_crc_errors++;
779 + else if (IS_RCV_LOR_ERR(devcs)) {
780 + DBG(2, "RX LOR error\n");
781 + lp->stats.rx_length_errors++;
783 + else if (IS_RCV_LE_ERR(devcs)) {
784 + DBG(2, "RX LE error\n");
785 + lp->stats.rx_length_errors++;
787 + else if (IS_RCV_OVR_ERR(devcs)) {
788 + lp->stats.rx_over_errors++;
790 + else if (IS_RCV_CV_ERR(devcs)) {
791 + /* code violation */
792 + DBG(2, "RX CV error\n");
793 + lp->stats.rx_frame_errors++;
795 + else if (IS_RCV_CES_ERR(devcs)) {
796 + DBG(2, "RX Preamble error\n");
802 + /* restore descriptor's curr_addr */
804 + rd->ca = CPHYSADDR(skb_new->data);
806 + rd->ca = CPHYSADDR(skb->data);
808 + rd->control = DMA_COUNT(RC32434_RBSIZE) |DMAD_cod_m |DMAD_iod_m;
809 + lp->rd_ring[(lp->rx_next_done-1)& RC32434_RDS_MASK].control &= ~(DMAD_cod_m);
811 + lp->rx_next_done = (lp->rx_next_done + 1) & RC32434_RDS_MASK;
812 + rd = &lp->rd_ring[lp->rx_next_done];
813 + __raw_writel( ~DMAS_d_m, &lp->rx_dma_regs->dmas);
815 +#ifdef CONFIG_IDT_USE_NAPI
816 + dev->quota -= received;
817 + *budget =- received;
818 + if(rx_work_limit < 0)
822 + dmas = __raw_readl(&lp->rx_dma_regs->dmas);
824 + if(dmas & DMAS_h_m) {
825 + __raw_writel( ~(DMAS_h_m | DMAS_e_m), &lp->rx_dma_regs->dmas);
826 +#ifdef RC32434_PROC_DEBUG
827 + lp->dma_halt_cnt++;
830 + skb = lp->rx_skb[lp->rx_next_done];
831 + rd->ca = CPHYSADDR(skb->data);
832 + rc32434_chain_rx(lp,rd);
835 +#ifdef CONFIG_IDT_USE_NAPI
836 + netif_rx_complete(dev);
838 + /* Enable D H E bit in Rx DMA */
839 + __raw_writel(__raw_readl(&lp->rx_dma_regs->dmasm) & ~(DMASM_d_m | DMASM_h_m |DMASM_e_m), &lp->rx_dma_regs->dmasm);
840 +#ifdef CONFIG_IDT_USE_NAPI
845 + spin_unlock_irqrestore(&lp->lock, flags);
854 +/* Ethernet Tx DMA interrupt */
856 +rc32434_tx_dma_interrupt(int irq, void *dev_id, struct pt_regs * regs)
858 + struct net_device *dev = (struct net_device *)dev_id;
859 + struct rc32434_local *lp;
860 + volatile u32 dmas,dmasm;
861 + irqreturn_t retval;
863 + ASSERT(dev != NULL);
865 + lp = (struct rc32434_local *)dev->priv;
867 + spin_lock(&lp->lock);
869 + dmas = __raw_readl(&lp->tx_dma_regs->dmas);
871 + if (dmas & (DMAS_f_m | DMAS_e_m)) {
872 + dmasm = __raw_readl(&lp->tx_dma_regs->dmasm);
873 + /* Mask F E bit in Tx DMA */
874 + __raw_writel(dmasm | (DMASM_f_m | DMASM_e_m), &lp->tx_dma_regs->dmasm);
876 + tasklet_hi_schedule(lp->tx_tasklet);
878 + if(lp->tx_chain_status == filled && (__raw_readl(&(lp->tx_dma_regs->dmandptr)) == 0)) {
879 + __raw_writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), &(lp->tx_dma_regs->dmandptr));
880 + lp->tx_chain_status = empty;
881 + lp->tx_chain_head = lp->tx_chain_tail;
882 + dev->trans_start = jiffies;
885 + if (dmas & DMAS_e_m)
886 + ERR(": DMA error\n");
888 + retval = IRQ_HANDLED;
893 + spin_unlock(&lp->lock);
899 +static void rc32434_tx_tasklet(unsigned long tx_data_dev)
901 + struct net_device *dev = (struct net_device *)tx_data_dev;
902 + struct rc32434_local* lp = (struct rc32434_local *)dev->priv;
903 + volatile DMAD_t td = &lp->td_ring[lp->tx_next_done];
905 + unsigned long flags;
908 + spin_lock_irqsave(&lp->lock, flags);
910 + /* process all desc that are done */
911 + while(IS_DMA_FINISHED(td->control)) {
912 + if(lp->tx_full == 1) {
913 + netif_wake_queue(dev);
917 + devcs = lp->td_ring[lp->tx_next_done].devcs;
918 + if ((devcs & (ETHTX_fd_m | ETHTX_ld_m)) != (ETHTX_fd_m | ETHTX_ld_m)) {
919 + lp->stats.tx_errors++;
920 + lp->stats.tx_dropped++;
922 + /* should never happen */
923 + DBG(1, __FUNCTION__ ": split tx ignored\n");
925 + else if (IS_TX_TOK(devcs)) {
926 + lp->stats.tx_packets++;
929 + lp->stats.tx_errors++;
930 + lp->stats.tx_dropped++;
933 + if (IS_TX_UND_ERR(devcs))
934 + lp->stats.tx_fifo_errors++;
936 + /* oversized frame */
937 + if (IS_TX_OF_ERR(devcs))
938 + lp->stats.tx_aborted_errors++;
940 + /* excessive deferrals */
941 + if (IS_TX_ED_ERR(devcs))
942 + lp->stats.tx_carrier_errors++;
944 + /* collisions: medium busy */
945 + if (IS_TX_EC_ERR(devcs))
946 + lp->stats.collisions++;
948 + /* late collision */
949 + if (IS_TX_LC_ERR(devcs))
950 + lp->stats.tx_window_errors++;
954 + /* We must always free the original skb */
955 + if (lp->tx_skb[lp->tx_next_done] != NULL) {
956 + dev_kfree_skb_any(lp->tx_skb[lp->tx_next_done]);
957 + lp->tx_skb[lp->tx_next_done] = NULL;
960 + lp->td_ring[lp->tx_next_done].control = DMAD_iof_m;
961 + lp->td_ring[lp->tx_next_done].devcs = ETHTX_fd_m | ETHTX_ld_m;
962 + lp->td_ring[lp->tx_next_done].link = 0;
963 + lp->td_ring[lp->tx_next_done].ca = 0;
966 + /* go on to next transmission */
967 + lp->tx_next_done = (lp->tx_next_done + 1) & RC32434_TDS_MASK;
968 + td = &lp->td_ring[lp->tx_next_done];
972 + dmas = __raw_readl(&lp->tx_dma_regs->dmas);
973 + __raw_writel( ~dmas, &lp->tx_dma_regs->dmas);
975 + /* Enable F E bit in Tx DMA */
976 + __raw_writel(__raw_readl(&lp->tx_dma_regs->dmasm) & ~(DMASM_f_m | DMASM_e_m), &lp->tx_dma_regs->dmasm);
977 + spin_unlock_irqrestore(&lp->lock, flags);
982 +static struct net_device_stats * rc32434_get_stats(struct net_device *dev)
984 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
990 + * Set or clear the multicast filter for this adaptor.
992 +static void rc32434_multicast_list(struct net_device *dev)
994 + /* listen to broadcasts always and to treat */
995 + /* IFF bits independantly */
996 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
997 + unsigned long flags;
998 + u32 recognise = ETHARC_ab_m; /* always accept broadcasts */
1000 + if (dev->flags & IFF_PROMISC) /* set promiscuous mode */
1001 + recognise |= ETHARC_pro_m;
1003 + if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 15))
1004 + recognise |= ETHARC_am_m; /* all multicast & bcast */
1005 + else if (dev->mc_count > 0) {
1006 + DBG(2, __FUNCTION__ ": mc_count %d\n", dev->mc_count);
1007 + recognise |= ETHARC_am_m; /* for the time being */
1010 + spin_lock_irqsave(&lp->lock, flags);
1011 + __raw_writel(recognise, &lp->eth_regs->etharc);
1012 + spin_unlock_irqrestore(&lp->lock, flags);
1016 +static void rc32434_tx_timeout(struct net_device *dev)
1018 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
1019 + unsigned long flags;
1021 + spin_lock_irqsave(&lp->lock, flags);
1022 + rc32434_restart(dev);
1023 + spin_unlock_irqrestore(&lp->lock, flags);
1029 + * Initialize the RC32434 ethernet controller.
1031 +static int rc32434_init(struct net_device *dev)
1033 + struct rc32434_local *lp = (struct rc32434_local *)dev->priv;
1037 + rc32434_abort_tx(dev);
1038 + rc32434_abort_rx(dev);
1040 + /* reset ethernet logic */
1041 + __raw_writel(0, &lp->eth_regs->ethintfc);
1042 + while((__raw_readl(&lp->eth_regs->ethintfc) & ETHINTFC_rip_m))
1043 + dev->trans_start = jiffies;
1045 + /* Enable Ethernet Interface */
1046 + __raw_writel(ETHINTFC_en_m, &lp->eth_regs->ethintfc);
1048 +#ifndef CONFIG_IDT_USE_NAPI
1049 + tasklet_disable(lp->rx_tasklet);
1051 + tasklet_disable(lp->tx_tasklet);
1053 + /* Initialize the transmit Descriptors */
1054 + for (i = 0; i < RC32434_NUM_TDS; i++) {
1055 + lp->td_ring[i].control = DMAD_iof_m;
1056 + lp->td_ring[i].devcs = ETHTX_fd_m | ETHTX_ld_m;
1057 + lp->td_ring[i].ca = 0;
1058 + lp->td_ring[i].link = 0;
1059 + if (lp->tx_skb[i] != NULL) {
1060 + dev_kfree_skb_any(lp->tx_skb[i]);
1061 + lp->tx_skb[i] = NULL;
1064 + lp->tx_next_done = lp->tx_chain_head = lp->tx_chain_tail = lp->tx_full = lp->tx_count = 0;
1065 + lp-> tx_chain_status = empty;
1068 + * Initialize the receive descriptors so that they
1069 + * become a circular linked list, ie. let the last
1070 + * descriptor point to the first again.
1072 + for (i=0; i<RC32434_NUM_RDS; i++) {
1073 + struct sk_buff *skb = lp->rx_skb[i];
1075 + if (lp->rx_skb[i] == NULL) {
1076 + skb = dev_alloc_skb(RC32434_RBSIZE + 2);
1077 + if (skb == NULL) {
1078 + ERR("No memory in the system\n");
1079 + for (j = 0; j < RC32434_NUM_RDS; j ++)
1080 + if (lp->rx_skb[j] != NULL)
1081 + dev_kfree_skb_any(lp->rx_skb[j]);
1087 + skb_reserve(skb, 2);
1088 + lp->rx_skb[i] = skb;
1089 + lp->rd_ring[i].ca = CPHYSADDR(skb->data);
1093 + lp->rd_ring[i].control = DMAD_iod_m | DMA_COUNT(RC32434_RBSIZE);
1094 + lp->rd_ring[i].devcs = 0;
1095 + lp->rd_ring[i].ca = CPHYSADDR(skb->data);
1096 + lp->rd_ring[i].link = CPHYSADDR(&lp->rd_ring[i+1]);
1100 + lp->rd_ring[RC32434_NUM_RDS-1].link = CPHYSADDR(&lp->rd_ring[0]);
1101 + lp->rx_next_done = 0;
1103 + lp->rd_ring[RC32434_NUM_RDS-1].control |= DMAD_cod_m;
1104 + lp->rx_chain_head = 0;
1105 + lp->rx_chain_tail = 0;
1106 + lp->rx_chain_status = empty;
1108 + __raw_writel(0, &lp->rx_dma_regs->dmas);
1109 + /* Start Rx DMA */
1110 + rc32434_start_rx(lp, &lp->rd_ring[0]);
1112 + /* Enable F E bit in Tx DMA */
1113 + __raw_writel(__raw_readl(&lp->tx_dma_regs->dmasm) & ~(DMASM_f_m | DMASM_e_m), &lp->tx_dma_regs->dmasm);
1114 + /* Enable D H E bit in Rx DMA */
1115 + __raw_writel(__raw_readl(&lp->rx_dma_regs->dmasm) & ~(DMASM_d_m | DMASM_h_m | DMASM_e_m), &lp->rx_dma_regs->dmasm);
1117 + /* Accept only packets destined for this Ethernet device address */
1118 + __raw_writel(ETHARC_ab_m, &lp->eth_regs->etharc);
1120 + /* Set all Ether station address registers to their initial values */
1121 + __raw_writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal0);
1122 + __raw_writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah0);
1124 + __raw_writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal1);
1125 + __raw_writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah1);
1127 + __raw_writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal2);
1128 + __raw_writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah2);
1130 + __raw_writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal3);
1131 + __raw_writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah3);
1134 + /* Frame Length Checking, Pad Enable, CRC Enable, Full Duplex set */
1135 + __raw_writel(ETHMAC2_pe_m | ETHMAC2_cen_m | ETHMAC2_fd_m, &lp->eth_regs->ethmac2);
1136 + //ETHMAC2_flc_m ETHMAC2_fd_m lp->duplex_mode
1138 + /* Back to back inter-packet-gap */
1139 + __raw_writel(0x15, &lp->eth_regs->ethipgt);
1140 + /* Non - Back to back inter-packet-gap */
1141 + __raw_writel(0x12, &lp->eth_regs->ethipgr);
1143 + /* Management Clock Prescaler Divisor */
1144 + /* Clock independent setting */
1145 + __raw_writel(((idt_cpu_freq)/MII_CLOCK+1) & ~1,
1146 + &lp->eth_regs->ethmcp);
1148 + /* don't transmit until fifo contains 48b */
1149 + __raw_writel(48, &lp->eth_regs->ethfifott);
1151 + __raw_writel(ETHMAC1_re_m, &lp->eth_regs->ethmac1);
1153 +#ifndef CONFIG_IDT_USE_NAPI
1154 + tasklet_enable(lp->rx_tasklet);
1156 + tasklet_enable(lp->tx_tasklet);
1158 + netif_start_queue(dev);
1163 +static struct platform_driver korina_driver = {
1164 + .driver.name = "korina",
1165 + .probe = rc32434_probe,
1166 + .remove = rc32434_remove,
1169 +static int __init rc32434_init_module(void)
1171 + return platform_driver_register(&korina_driver);
1174 +static void rc32434_cleanup_module(void)
1176 + return platform_driver_unregister(&korina_driver);
1179 +module_init(rc32434_init_module);
1180 +module_exit(rc32434_cleanup_module);
1181 diff -urN linux.old/drivers/net/Makefile linux.dev/drivers/net/Makefile
1182 --- linux.old/drivers/net/Makefile 2006-06-08 20:21:20.000000000 +0200
1183 +++ linux.dev/drivers/net/Makefile 2006-06-08 20:19:40.000000000 +0200
1186 obj-$(CONFIG_PLIP) += plip.o
1188 +obj-$(CONFIG_KORINA) += korina.o
1190 obj-$(CONFIG_ROADRUNNER) += rrunner.o
1192 obj-$(CONFIG_HAPPYMEAL) += sunhme.o
1193 diff -urN linux.old/drivers/net/rc32434_eth.h linux.dev/drivers/net/rc32434_eth.h
1194 --- linux.old/drivers/net/rc32434_eth.h 1970-01-01 01:00:00.000000000 +0100
1195 +++ linux.dev/drivers/net/rc32434_eth.h 2006-06-08 21:57:12.000000000 +0200
1197 +/**************************************************************************
1199 + * BRIEF MODULE DESCRIPTION
1200 + * Definitions for IDT RC32434 on-chip ethernet controller.
1202 + * Copyright 2004 IDT Inc. (rischelp@idt.com)
1204 + * This program is free software; you can redistribute it and/or modify it
1205 + * under the terms of the GNU General Public License as published by the
1206 + * Free Software Foundation; either version 2 of the License, or (at your
1207 + * option) any later version.
1209 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
1210 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1211 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
1212 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1213 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1214 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1215 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
1216 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1217 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1218 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1220 + * You should have received a copy of the GNU General Public License along
1221 + * with this program; if not, write to the Free Software Foundation, Inc.,
1222 + * 675 Mass Ave, Cambridge, MA 02139, USA.
1225 + **************************************************************************
1226 + * May 2004 rkt, neb
1234 + **************************************************************************
1238 +#include <asm/rc32434/rc32434.h>
1239 +#include <asm/rc32434/dma_v.h>
1240 +#include <asm/rc32434/eth_v.h>
1242 +#define CONFIG_IDT_USE_NAPI 1
1243 +#define RC32434_DEBUG 2
1244 +//#define RC32434_PROC_DEBUG
1245 +#undef RC32434_DEBUG
1247 +#ifdef RC32434_DEBUG
1249 +/* use 0 for production, 1 for verification, >2 for debug */
1250 +static int rc32434_debug = RC32434_DEBUG;
1251 +#define ASSERT(expr) \
1253 + printk( "Assertion failed! %s,%s,%s,line=%d\n", \
1254 + #expr,__FILE__,__FUNCTION__,__LINE__); }
1255 +#define DBG(lvl, format, arg...) if (rc32434_debug > lvl) printk(KERN_INFO "%s: " format, dev->name , ## arg)
1257 +#define ASSERT(expr) do {} while (0)
1258 +#define DBG(lvl, format, arg...) do {} while (0)
1261 +#define INFO(format, arg...) printk(KERN_INFO "%s: " format, dev->name , ## arg)
1262 +#define ERR(format, arg...) printk(KERN_ERR "%s: " format, dev->name , ## arg)
1263 +#define WARN(format, arg...) printk(KERN_WARNING "%s: " format, dev->name , ## arg)
1265 +/* the following must be powers of two */
1266 +#ifdef CONFIG_IDT_USE_NAPI
1267 +#define RC32434_NUM_RDS 64 /* number of receive descriptors */
1268 +#define RC32434_NUM_TDS 64 /* number of transmit descriptors */
1270 +#define RC32434_NUM_RDS 128 /* number of receive descriptors */
1271 +#define RC32434_NUM_TDS 128 /* number of transmit descriptors */
1274 +#define RC32434_RBSIZE 1536 /* size of one resource buffer = Ether MTU */
1275 +#define RC32434_RDS_MASK (RC32434_NUM_RDS-1)
1276 +#define RC32434_TDS_MASK (RC32434_NUM_TDS-1)
1277 +#define RD_RING_SIZE (RC32434_NUM_RDS * sizeof(struct DMAD_s))
1278 +#define TD_RING_SIZE (RC32434_NUM_TDS * sizeof(struct DMAD_s))
1280 +#define RC32434_TX_TIMEOUT HZ * 100
1282 +#define rc32434_eth0_regs ((ETH_t)(ETH0_VirtualAddress))
1283 +#define rc32434_eth1_regs ((ETH_t)(ETH1_VirtualAddress))
1285 +enum status { filled, empty};
1286 +#define IS_DMA_FINISHED(X) (((X) & (DMAD_f_m)) != 0)
1287 +#define IS_DMA_DONE(X) (((X) & (DMAD_d_m)) != 0)
1290 +/* Information that need to be kept for each board. */
1291 +struct rc32434_local {
1293 + DMA_Chan_t rx_dma_regs;
1294 + DMA_Chan_t tx_dma_regs;
1295 + volatile DMAD_t td_ring; /* transmit descriptor ring */
1296 + volatile DMAD_t rd_ring; /* receive descriptor ring */
1298 + struct sk_buff* tx_skb[RC32434_NUM_TDS]; /* skbuffs for pkt to trans */
1299 + struct sk_buff* rx_skb[RC32434_NUM_RDS]; /* skbuffs for pkt to trans */
1301 +#ifndef CONFIG_IDT_USE_NAPI
1302 + struct tasklet_struct * rx_tasklet;
1304 + struct tasklet_struct * tx_tasklet;
1307 + int rx_chain_head;
1308 + int rx_chain_tail;
1309 + enum status rx_chain_status;
1312 + int tx_chain_head;
1313 + int tx_chain_tail;
1314 + enum status tx_chain_status;
1318 + struct timer_list mii_phy_timer;
1319 + unsigned long duplex_mode;
1326 + struct net_device_stats stats;
1329 + /* debug /proc entry */
1330 + struct proc_dir_entry *ps;
1331 + int dma_halt_cnt; int dma_run_cnt;
1334 +extern unsigned int idt_cpu_freq;
1336 +/* Index to functions, as function prototypes. */
1337 +static int rc32434_open(struct net_device *dev);
1338 +static int rc32434_send_packet(struct sk_buff *skb, struct net_device *dev);
1339 +static void rc32434_mii_handler(unsigned long data);
1340 +static irqreturn_t rc32434_und_interrupt(int irq, void *dev_id, struct pt_regs * regs);
1341 +static irqreturn_t rc32434_rx_dma_interrupt(int irq, void *dev_id, struct pt_regs * regs);
1342 +static irqreturn_t rc32434_tx_dma_interrupt(int irq, void *dev_id, struct pt_regs * regs);
1343 +#ifdef RC32434_REVISION
1344 +static irqreturn_t rc32434_ovr_interrupt(int irq, void *dev_id, struct pt_regs * regs);
1346 +static int rc32434_close(struct net_device *dev);
1347 +static struct net_device_stats *rc32434_get_stats(struct net_device *dev);
1348 +static void rc32434_multicast_list(struct net_device *dev);
1349 +static int rc32434_init(struct net_device *dev);
1350 +static void rc32434_tx_timeout(struct net_device *dev);
1352 +static void rc32434_tx_tasklet(unsigned long tx_data_dev);
1353 +#ifdef CONFIG_IDT_USE_NAPI
1354 +static int rc32434_poll(struct net_device *rx_data_dev, int *budget);
1356 +static void rc32434_rx_tasklet(unsigned long rx_data_dev);
1358 +static void rc32434_cleanup_module(void);
1361 +static inline void rc32434_abort_dma(struct net_device *dev, DMA_Chan_t ch)
1363 + if (__raw_readl(&ch->dmac) & DMAC_run_m) {
1364 + __raw_writel(0x10, &ch->dmac);
1366 + while (!(__raw_readl(&ch->dmas) & DMAS_h_m))
1367 + dev->trans_start = jiffies;
1369 + __raw_writel(0, &ch->dmas);
1372 + __raw_writel(0, &ch->dmadptr);
1373 + __raw_writel(0, &ch->dmandptr);