From: Dave A. <ai...@us...> - 2001-01-20 23:45:17
|
Update of /cvsroot/linux-vax/kernel-2.4/drivers/net In directory usw-pr-cvs1:/tmp/cvs-serv30738/drivers/net Modified Files: vaxlance.c Log Message: updated to 2.4 .. not tested of course should compile though.. Index: vaxlance.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/net/vaxlance.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** vaxlance.c 2001/01/17 16:00:11 1.1 --- vaxlance.c 2001/01/20 23:45:25 1.2 *************** *** 215,219 **** volatile struct lance_init_block *init_block; volatile unsigned long *dma_ptr_reg; ! int rx_new, tx_new; int rx_old, tx_old; --- 215,221 ---- volatile struct lance_init_block *init_block; volatile unsigned long *dma_ptr_reg; ! ! spinlock_t lock; ! int rx_new, tx_new; int rx_old, tx_old; *************** *** 223,229 **** unsigned short busmaster_regval; ! struct device *dev; /* Backpointer */ ! struct lance_private *next_module; ! struct timer_list multicast_timer; /* Pointers to the ring buffers as seen from the CPU */ --- 225,231 ---- unsigned short busmaster_regval; ! struct net_device *dev; /* Backpointer */ ! struct lance_private *next_module; ! struct timer_list multicast_timer; /* Pointers to the ring buffers as seen from the CPU */ *************** *** 269,275 **** { volatile struct lance_regs *ll = lp->ll; ! int leptr; ! leptr = lp->init_block; /* FIXME: This function needs a re-write for VAX, --- 271,277 ---- { volatile struct lance_regs *ll = lp->ll; ! unsigned long leptr; ! leptr = (unsigned long)lp->init_block; /* FIXME: This function needs a re-write for VAX, *************** *** 297,303 **** void cp_to_buf(void *to, const void *from, __kernel_size_t len) { - unsigned short *tp, *fp, clen; - unsigned char *rtp, *rfp; - memcpy(to, from, len); } --- 299,302 ---- *************** *** 305,317 **** void cp_from_buf(void *to, unsigned char *from, int len) { - unsigned short *tp, *fp, clen; - unsigned char *rtp, *rfp; - memcpy(to, from, len); } /* Setup the Lance Rx and Tx rings */ ! /* Sets dev->tbusy */ ! static void lance_init_ring(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; --- 304,312 ---- void cp_from_buf(void *to, unsigned char *from, int len) { memcpy(to, from, len); } /* Setup the Lance Rx and Tx rings */ ! static void lance_init_ring(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; *************** *** 323,327 **** lp->init_block=ib; /* Lock out other processes while setting up hardware */ ! dev->tbusy = 1; lp->rx_new = lp->tx_new = 0; lp->rx_old = lp->tx_old = 0; --- 318,322 ---- lp->init_block=ib; /* Lock out other processes while setting up hardware */ ! netif_stop_queue(dev); lp->rx_new = lp->tx_new = 0; lp->rx_old = lp->tx_old = 0; *************** *** 417,421 **** } ! static int lance_rx(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; --- 412,416 ---- } ! static int lance_rx(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; *************** *** 500,504 **** } ! static int lance_tx(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; --- 495,499 ---- } ! static void lance_tx(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; *************** *** 511,514 **** --- 506,511 ---- j = lp->tx_old; + spin_lock(&lp->lock); + for (i = j; i != lp->tx_new; i = j) { td = &ib->btx_ring[i]; *************** *** 535,539 **** load_csrs(lp); init_restart_lance(lp); ! return 0; } /* Buffer errors and underflows turn off the --- 532,536 ---- load_csrs(lp); init_restart_lance(lp); ! goto out; } /* Buffer errors and underflows turn off the *************** *** 551,555 **** load_csrs(lp); init_restart_lance(lp); ! return 0; } } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { --- 548,552 ---- load_csrs(lp); init_restart_lance(lp); ! goto out; } } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { *************** *** 572,589 **** } lp->tx_old = j; ! return 0; } static void lance_interrupt(const int irq, void *dev_id, struct pt_regs *regs) { ! struct device *dev = (struct device *) dev_id; struct lance_private *lp = (struct lance_private *) dev->priv; volatile struct lance_regs *ll = lp->ll; int csr0; - - if (dev->interrupt) - printk("%s: again\n", dev->name); - - dev->interrupt = 1; writereg(&ll->rap, LE_CSR0); --- 569,586 ---- } lp->tx_old = j; ! out: ! if (netif_queue_stopped(dev) && ! TX_BUFFS_AVAIL > 0) ! netif_wake_queue(dev); ! ! spin_unlock(&lp->lock); } static void lance_interrupt(const int irq, void *dev_id, struct pt_regs *regs) { ! struct net_device *dev = (struct net_device *) dev_id; struct lance_private *lp = (struct lance_private *) dev->priv; volatile struct lance_regs *ll = lp->ll; int csr0; writereg(&ll->rap, LE_CSR0); *************** *** 603,611 **** if (csr0 & LE_C0_TINT) lance_tx(dev); ! ! if ((TX_BUFFS_AVAIL >= 0) && dev->tbusy) { ! dev->tbusy = 0; ! mark_bh(NET_BH); ! } if (csr0 & LE_C0_BABL) lp->stats.tx_errors++; --- 600,604 ---- if (csr0 & LE_C0_TINT) lance_tx(dev); ! if (csr0 & LE_C0_BABL) lp->stats.tx_errors++; *************** *** 633,646 **** load_csrs(lp); init_restart_lance(lp); ! dev->tbusy = 0; } writereg(&ll->rdp, LE_C0_INEA); writereg(&ll->rdp, LE_C0_INEA); - dev->interrupt = 0; } ! struct device *last_dev = 0; ! static int lance_open(struct device *dev) { volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); --- 626,638 ---- load_csrs(lp); init_restart_lance(lp); ! netif_wake_queue(dev); } writereg(&ll->rdp, LE_C0_INEA); writereg(&ll->rdp, LE_C0_INEA); } ! struct net_device *last_dev = 0; ! static int lance_open(struct net_device *dev) { volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); *************** *** 673,679 **** load_csrs(lp); ! dev->tbusy = 0; ! dev->interrupt = 0; ! dev->start = 1; status = init_restart_lance(lp); --- 665,669 ---- load_csrs(lp); ! netif_start_queue(dev); status = init_restart_lance(lp); *************** *** 687,698 **** } ! static int lance_close(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; volatile struct lance_regs *ll = lp->ll; ! dev->start = 0; ! dev->tbusy = 1; ! del_timer(&lp->multicast_timer); /* Stop the card */ --- 677,687 ---- } ! static int lance_close(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; volatile struct lance_regs *ll = lp->ll; ! netif_stop_queue(dev); ! del_timer_sync(&lp->multicast_timer); /* Stop the card */ *************** *** 707,711 **** } ! static inline int lance_reset(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; --- 696,700 ---- } ! static inline int lance_reset(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; *************** *** 720,726 **** load_csrs(lp); dev->trans_start = jiffies; - dev->interrupt = 0; - dev->start = 1; - dev->tbusy = 0; status = init_restart_lance(lp); #ifdef DEBUG_DRIVER --- 709,712 ---- *************** *** 730,775 **** } ! static int lance_start_xmit(struct sk_buff *skb, struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; volatile struct lance_regs *ll = lp->ll; - volatile struct lance_init_block *ib; - unsigned long flags; - int entry, skblen, len; - int status = 0; - static int outs; - int csr0; ! ib = (struct lance_init_block *) (dev->mem_start); ! writereg(&ll->rap, LE_CSR0); ! csr0 = ll->rdp; - /* Transmitter timeout, serious problems */ - if (dev->tbusy) { - int tickssofar = jiffies - dev->trans_start; - - if (tickssofar < 100) { - status = -1; - } else { - printk("%s: transmit timed out, status %04x, reset\n", - dev->name, ll->rdp); - lance_reset(dev); - } - return status; - } - /* Block a timer-based transmit from overlapping. */ - if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) { - printk("Transmitter access conflict.\n"); - return -1; - } skblen = skb->len; ! save_flags(flags); ! cli(); ! if (!TX_BUFFS_AVAIL) { ! restore_flags(flags); ! printk("lance: No Buffs available\n"); ! return -1; ! } len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen; --- 716,739 ---- } ! static void lance_tx_timeout(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; volatile struct lance_regs *ll = lp->ll; ! printk(KERN_ERR "%s: transmit timed out, status %04x, reset\n", ! dev->name, ll->rdp); ! lance_reset(dev); ! netif_wake_queue(dev); ! } ! static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) ! { ! struct lance_private *lp = (struct lance_private *) dev->priv; ! volatile struct lance_regs *ll = lp->ll; ! volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); ! int entry, skblen, len; skblen = skb->len; ! len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen; *************** *** 792,809 **** lp->tx_new = (lp->tx_new + 1) & TX_RING_MOD_MASK; ! outs++; /* Kick the lance: transmit now */ writereg(&ll->rdp, LE_C0_INEA | LE_C0_TDMD); dev->trans_start = jiffies; dev_kfree_skb(skb); - - if (TX_BUFFS_AVAIL) - dev->tbusy = 0; ! restore_flags(flags); ! return status; } ! static struct net_device_stats *lance_get_stats(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; --- 756,774 ---- lp->tx_new = (lp->tx_new + 1) & TX_RING_MOD_MASK; ! if (TX_BUFFS_AVAIL <= 0) ! netif_stop_queue(dev); ! /* Kick the lance: transmit now */ writereg(&ll->rdp, LE_C0_INEA | LE_C0_TDMD); + + spin_unlock_irq(&lp->lock); + dev->trans_start = jiffies; dev_kfree_skb(skb); ! return 0; } ! static struct net_device_stats *lance_get_stats(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; *************** *** 812,816 **** } ! static void lance_load_multicast(struct device *dev) { volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); --- 777,781 ---- } ! static void lance_load_multicast(struct net_device *dev) { volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); *************** *** 863,867 **** } ! static void lance_set_multicast(struct device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; --- 828,832 ---- } ! static void lance_set_multicast(struct net_device *dev) { struct lance_private *lp = (struct lance_private *) dev->priv; *************** *** 871,889 **** ib = (struct lance_init_block *) (dev->mem_start); ! if (!dev->start) ! return; ! ! if (dev->tbusy) { ! mod_timer(&lp->multicast_timer, jiffies + 2); ! return; ! } ! set_bit(0, (void *) &dev->tbusy); ! while (lp->tx_old != lp->tx_new) { ! mod_timer(&lp->multicast_timer, jiffies + 4); ! dev->tbusy = 0; ! return; } writereg(&ll->rap, LE_CSR0); --- 836,849 ---- ib = (struct lance_init_block *) (dev->mem_start); ! if (!netif_running(dev)) ! return; ! if (lp->tx_old != lp->tx_new) { ! mod_timer(&lp->multicast_timer, jiffies + 4); ! netif_wake_queue(dev); ! return; } + netif_stop_queue(dev); writereg(&ll->rap, LE_CSR0); *************** *** 900,915 **** load_csrs(lp); init_restart_lance(lp); ! dev->tbusy = 0; ! mark_bh(NET_BH); } volatile void *base_addr=NULL; ! __initfunc(static int vax_lance_init(struct device *dev, const int type)) { static unsigned version_printed = 0; struct lance_private *lp; volatile struct lance_regs *ll; ! int i; unsigned long esar_base; unsigned char *esar; --- 860,881 ---- load_csrs(lp); init_restart_lance(lp); ! netif_wake_queue(dev); } + static void lance_set_multicast_retry(unsigned long _opaque) + { + struct net_device *dev = (struct net_device *) _opaque; + + lance_set_multicast(dev); + } + volatile void *base_addr=NULL; ! static int __init vax_lance_init(struct net_device *dev, const int type) { static unsigned version_printed = 0; struct lance_private *lp; volatile struct lance_regs *ll; ! int i, ret; unsigned long esar_base; unsigned char *esar; *************** *** 921,925 **** if (vax_lance_debug && version_printed++ == 0) printk(version); ! if (dev == NULL) { dev = init_etherdev(0, sizeof(struct lance_private) + 8); --- 887,891 ---- if (vax_lance_debug && version_printed++ == 0) printk(version); ! #if 0 if (dev == NULL) { dev = init_etherdev(0, sizeof(struct lance_private) + 8); *************** *** 932,945 **** } - /* Make certain the data structures used by the LANCE are aligned. */ dev->priv = (void *) (((unsigned long) dev->priv + 7) & ~7); lp = (struct lance_private *) dev->priv; /* Need to kmalloc a block of 64k */ dev->mem_start=kmalloc(65536, GFP_KERNEL); - printk("mem_start = %p\n", dev->mem_start); dev->mem_start = (((unsigned long) dev->mem_start + 7) & ~7); - printk("mem_start = %p\n", dev->mem_start); dev->mem_end = dev->mem_start + 65536; /* dev->mem_start = base_addr;*/ --- 898,915 ---- } /* Make certain the data structures used by the LANCE are aligned. */ dev->priv = (void *) (((unsigned long) dev->priv + 7) & ~7); + #else + dev = init_etherdev(0, sizeof(struct lance_private)); + if (!dev) + return -ENOMEM; + #endif + lp = (struct lance_private *) dev->priv; + spin_lock_init(&lp->lock); /* Need to kmalloc a block of 64k */ dev->mem_start=kmalloc(65536, GFP_KERNEL); dev->mem_start = (((unsigned long) dev->mem_start + 7) & ~7); dev->mem_end = dev->mem_start + 65536; /* dev->mem_start = base_addr;*/ *************** *** 989,995 **** esar[0x68] != 0x55 && esar[0x6c] != 0xaa) { printk("Ethernet station address prom not found!\n"); ! return -ENODEV; } - printk("Hello 2\n"); /* Check the prom contents */ for (i = 0; i < 8; i++) { --- 959,965 ---- esar[0x68] != 0x55 && esar[0x6c] != 0xaa) { printk("Ethernet station address prom not found!\n"); ! ret = -ENODEV; ! goto err_out; } /* Check the prom contents */ for (i = 0; i < 8; i++) { *************** *** 998,1003 **** esar[0x3c - i * 4] != esar[0x40 + i * 4]) { printk("Something is wrong with the ethernet " ! "station address prom!\n"); ! return -ENODEV; } } --- 968,974 ---- esar[0x3c - i * 4] != esar[0x40 + i * 4]) { printk("Something is wrong with the ethernet " ! "station address prom!\n"); ! ret = -ENODEV; ! goto err_out; } } *************** *** 1012,1017 **** } - #if 1 - #if 0 autoirq_setup(0); --- 983,986 ---- *************** *** 1040,1043 **** --- 1009,1014 ---- dev->stop = &lance_close; dev->hard_start_xmit = &lance_start_xmit; + dev->tx_timeout = &lance_tx_timeout; + dev->watchdog_timeo = 5*HZ; dev->get_stats = &lance_get_stats; dev->set_multicast_list = &lance_set_multicast; *************** *** 1064,1077 **** init_timer(&lp->multicast_timer); lp->multicast_timer.data = (unsigned long) dev; ! lp->multicast_timer.function = ! (void (*)(unsigned long)) &lance_set_multicast; ! ! /* ! #ifdef MODULE ! dev->ifindex = dev_new_index(); ! lp->next_module = root_lance_dev; ! root_lance_dev = lp; ! #endif ! */ #endif /* --- 1035,1047 ---- init_timer(&lp->multicast_timer); lp->multicast_timer.data = (unsigned long) dev; ! lp->multicast_timer.function = &lance_set_multicast_retry; ! ! #ifdef MODULE ! /* ! dev->ifindex = dev_new_index(); ! lp->next_module = root_lance_dev; ! root_lance_dev = lp; ! #endif ! */ #endif /* *************** *** 1090,1099 **** /* vax_lance_test_xmit(dev);*/ return 0; } /* Find all the lance cards on the system and initialize them */ ! __initfunc(int vax_lance_probe(struct device *dev)) { static int called = 0; --- 1060,1075 ---- /* vax_lance_test_xmit(dev);*/ return 0; + + err_out: + unregister_netdev(dev); + kfree(dev); + return ret; } /* Find all the lance cards on the system and initialize them */ ! static int __init dec_lance_probe(void) { + struct net_device *dev = NULL; static int called = 0; *************** *** 1134,1137 **** --- 1110,1114 ---- unsigned char tx_block[30]; + #if 0 static int vax_lance_test_xmit(struct device *dev) { *************** *** 1183,1184 **** --- 1160,1162 ---- return status; } + #endif |