Lines Matching +full:0 +full:x00000000 +full:- +full:0 +full:x03ffffff
3 Written/copyright 1993-1998 by Donald Becker.
11 with most other LANCE-based bus-master (NE2100/NE2500) ethercards.
19 - alignment problem with 1.3.* kernel and some minor changes.
21 - added support for Linux/Alpha, but removed most of it, because
23 - added hook for the 32bit lance driver
24 - added PCnetPCI II (79C970A) to chip table
26 - hopefully fix above so Linux/Alpha can use ISA cards too.
27 8/20/96 Fixed 7990 autoIRQ failure and reversed unneeded alignment -djb
28 v1.12 10/27/97 Module support -djb
29 v1.14 2/3/98 Module support modified, made PCI support optional -djb
30 v1.15 5/27/99 Fixed bug in the cleanup_module(). dev->priv was freed
33 -- Mika Kuoppala <miku@iki.fi>
36 the 2.1 version of the old driver - Alan Cox
39 Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 11/01/2001
42 Vesselin Kostadinov <vesok at yahoo dot com > - 22/4/2004
66 static unsigned int lance_portlist[] __initdata = { 0x300, 0x320, 0x340, 0x360, 0};
76 .id_offset14 = 0x57,
77 .id_offset15 = 0x57,
80 .id_offset14 = 0x52,
81 .id_offset15 = 0x44,
84 .id_offset14 = 0x52,
85 .id_offset15 = 0x49,
101 This device driver is designed for the AMD 79C960, the "PCnet-ISA
102 single-chip ethernet controller for ISA". This chip is used in a wide
109 II. Board-specific settings
112 bus-master mode, rather than in shared memory mode. (Only older designs
113 have on-board buffer memory needed to support the slower shared memory mode.)
117 {0x300, 0x320, 0x340, 0x360}.
118 After the board is found it generates a DMA-timeout interrupt and uses
120 of the otherwise-unused dev->mem_start value (aka PARAM1). If unset it is
124 The HP-J2405A board is an exception: with this board it is easy to read the
125 EEPROM-set values for the base, IRQ, and DMA. (Of course you must already
126 _know_ the base address -- that field is for writing the EEPROM.)
139 of entries makes it more difficult to achieve back-to-back packet transmission
141 of receiving back-to-back minimum-sized packets.)
144 statically allocates full-sized (slightly oversized -- PKT_BUF_SZ) buffers to
146 allocating full-sized buffers "just in case", at the expense of a
147 memory-to-memory data copy for each packet received. For most systems this
150 the buffers are only used when needed as low-memory bounce buffers.
161 As mentioned before, low-memory "bounce-buffers" are used when needed.
164 The driver runs as two independent, single-threaded flows of control. One
165 is the send-packet routine, which enforces single-threaded use by the
166 dev->tbusy flag. The other thread is the interrupt handler, which is single
169 The send packet thread has partial control over the Tx ring and 'dev->tbusy'
172 the 'lp->tx_full' flag.
175 from the Tx ring. (The Tx-done interrupt can't be selectively turned off, so
178 the 'base' to zero. Iff the 'lp->tx_full' flag is set, it clears both the
186 This is a compile-time option for efficiency.
194 #define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
198 #define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
204 #define LANCE_DATA 0x10
205 #define LANCE_ADDR 0x12
206 #define LANCE_RESET 0x14
207 #define LANCE_BUS_IF 0x16
208 #define LANCE_TOTAL_SIZE 0x18
227 u16 mode; /* Pre-set mode (reg. 15) */
236 /* The Tx and Rx ring entries must be aligned on 8-byte boundaries. */
241 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
243 /* The addresses of receive-in-place skbuffs. */
246 /* Tx low-memory "bounce buffer" address. */
255 #define LANCE_MUST_PAD 0x00000001
256 #define LANCE_ENABLE_AUTOSELECT 0x00000002
257 #define LANCE_MUST_REINIT_RING 0x00000004
258 #define LANCE_MUST_UNRESET 0x00000008
259 #define LANCE_HAS_MISSED_FRAME 0x00000010
262 These are from the datasheets -- in real life the '970 version
269 {0x0000, "LANCE 7990", /* Ancient lance chip. */
271 {0x0003, "PCnet/ISA 79C960", /* 79C960 PCnet/ISA. */
274 {0x2260, "PCnet/ISA+ 79C961", /* 79C961 PCnet/ISA+, Plug-n-Play. */
277 {0x2420, "PCnet/PCI 79C970", /* 79C970 or 79C974 PCnet-SCSI, PCI. */
282 {0x2430, "PCnet32", /* 79C965 PCnet for VL bus. */
285 {0x2621, "PCnet/PCI-II 79C970A", /* 79C970A PCInetPCI II. */
288 {0x0, "PCnet (unknown)",
293 enum {OLD_LANCE = 0, PCNET_ISA=1, PCNET_ISAP=2, PCNET_PCI=3, PCNET_VLB=4, PCNET_PCI_II=5, LANCE_UNK…
296 /* Non-zero if lance_probe1() needs to allocate low-memory bounce buffers.
321 module_param_hw_array(io, int, ioport, NULL, 0);
322 module_param_hw_array(dma, int, dma, NULL, 0);
323 module_param_hw_array(irq, int, irq, NULL, 0);
324 module_param(lance_debug, int, 0);
328 MODULE_PARM_DESC(lance_debug, "LANCE/PCnet debug level (0-7)");
333 int this_dev, found = 0; in lance_init_module()
335 for (this_dev = 0; this_dev < MAX_CARDS; this_dev++) { in lance_init_module()
336 if (io[this_dev] == 0) { in lance_init_module()
337 if (this_dev != 0) /* only complain once */ in lance_init_module()
339 printk(KERN_NOTICE "lance.c: Module autoprobing not allowed. Append \"io=0xNNN\" value(s).\n"); in lance_init_module()
340 return -EPERM; in lance_init_module()
342 dev = alloc_etherdev(0); in lance_init_module()
345 dev->irq = irq[this_dev]; in lance_init_module()
346 dev->base_addr = io[this_dev]; in lance_init_module()
347 dev->dma = dma[this_dev]; in lance_init_module()
348 if (do_lance_probe(dev) == 0) { in lance_init_module()
355 if (found != 0) in lance_init_module()
356 return 0; in lance_init_module()
357 return -ENXIO; in lance_init_module()
363 struct lance_private *lp = dev->ml_priv; in cleanup_card()
364 if (dev->dma != 4) in cleanup_card()
365 free_dma(dev->dma); in cleanup_card()
366 release_region(dev->base_addr, LANCE_TOTAL_SIZE); in cleanup_card()
367 kfree(lp->tx_bounce_buffs); in cleanup_card()
368 kfree((void*)lp->rx_buffs); in cleanup_card()
376 for (this_dev = 0; this_dev < MAX_CARDS; this_dev++) { in lance_cleanup_module()
391 board probes now that kmalloc() can allocate ISA DMA-able regions.
400 lance_need_isa_bounce_buffers = 0; in do_lance_probe()
405 "lance-probe"); in do_lance_probe()
411 for (card = 0; card < NUM_CARDS; ++card) in do_lance_probe()
416 for (card = 0; card < NUM_CARDS; ++card) in do_lance_probe()
422 result = lance_probe1(dev, ioaddr, 0, 0); in do_lance_probe()
424 struct lance_private *lp = dev->ml_priv; in do_lance_probe()
425 int ver = lp->chip_version; in do_lance_probe()
427 r->name = chip_table[ver].name; in do_lance_probe()
428 return 0; in do_lance_probe()
434 return -ENODEV; in do_lance_probe()
440 struct net_device *dev = alloc_etherdev(0); in lance_probe()
444 return ERR_PTR(-ENODEV); in lance_probe()
446 sprintf(dev->name, "eth%d", unit); in lance_probe()
473 unsigned long dma_channels; /* Mark spuriously-busy DMA channels */ in lance_probe1()
477 unsigned char hpJ2405A = 0; /* HP ISA adaptor */ in lance_probe1()
478 int hp_builtin = 0; /* HP on-board ethernet. */ in lance_probe1()
481 int err = -ENOMEM; in lance_probe1()
486 Check for HP's on-board ethernet by looking for 'HP' in the BIOS. in lance_probe1()
490 bios = ioremap(0xf00f0, 0x14); in lance_probe1()
492 return -ENOMEM; in lance_probe1()
493 if (readw(bios + 0x12) == 0x5048) { in lance_probe1()
494 static const short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360}; in lance_probe1()
495 int hp_port = (readl(bios + 1) & 1) ? 0x499 : 0x99; in lance_probe1()
496 /* We can have boards other than the built-in! Verify this is on-board. */ in lance_probe1()
497 if ((inb(hp_port) & 0xc0) == 0x80 && in lance_probe1()
502 /* We also recognize the HP Vectra on-board here, but check below. */ in lance_probe1()
503 hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00 && in lance_probe1()
504 inb(ioaddr+2) == 0x09); in lance_probe1()
509 /* The Un-Reset needed is only needed for the real NE2100, and will in lance_probe1()
514 outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */ in lance_probe1()
515 if (inw(ioaddr+LANCE_DATA) != 0x0004) in lance_probe1()
516 return -ENODEV; in lance_probe1()
521 lance_version = 0; in lance_probe1()
528 if ((chip_version & 0xfff) != 0x003) in lance_probe1()
529 return -ENODEV; in lance_probe1()
530 chip_version = (chip_version >> 12) & 0xffff; in lance_probe1()
538 a ISA DMA-able region. */ in lance_probe1()
540 printk("%s: %s at %#3x, ", dev->name, chipname, ioaddr); in lance_probe1()
544 for (i = 0; i < 6; i++) in lance_probe1()
547 printk("%pM", dev->dev_addr); in lance_probe1()
549 dev->base_addr = ioaddr; in lance_probe1()
554 return -ENOMEM; in lance_probe1()
555 if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); in lance_probe1()
556 dev->ml_priv = lp; in lance_probe1()
557 lp->name = chipname; in lance_probe1()
558 lp->rx_buffs = (unsigned long)kmalloc_array(RX_RING_SIZE, PKT_BUF_SZ, in lance_probe1()
560 if (!lp->rx_buffs) in lance_probe1()
563 lp->tx_bounce_buffs = kmalloc_array(TX_RING_SIZE, PKT_BUF_SZ, in lance_probe1()
565 if (!lp->tx_bounce_buffs) in lance_probe1()
568 lp->tx_bounce_buffs = NULL; in lance_probe1()
570 lp->chip_version = lance_version; in lance_probe1()
571 spin_lock_init(&lp->devlock); in lance_probe1()
573 lp->init_block.mode = 0x0003; /* Disable Rx and Tx. */ in lance_probe1()
574 for (i = 0; i < 6; i++) in lance_probe1()
575 lp->init_block.phys_addr[i] = dev->dev_addr[i]; in lance_probe1()
576 lp->init_block.filter[0] = 0x00000000; in lance_probe1()
577 lp->init_block.filter[1] = 0x00000000; in lance_probe1()
578 lp->init_block.rx_ring = ((u32)isa_virt_to_bus(lp->rx_ring) & 0xffffff) | RX_RING_LEN_BITS; in lance_probe1()
579 lp->init_block.tx_ring = ((u32)isa_virt_to_bus(lp->tx_ring) & 0xffffff) | TX_RING_LEN_BITS; in lance_probe1()
581 outw(0x0001, ioaddr+LANCE_ADDR); in lance_probe1()
583 outw((short) (u32) isa_virt_to_bus(&lp->init_block), ioaddr+LANCE_DATA); in lance_probe1()
584 outw(0x0002, ioaddr+LANCE_ADDR); in lance_probe1()
586 outw(((u32)isa_virt_to_bus(&lp->init_block)) >> 16, ioaddr+LANCE_DATA); in lance_probe1()
587 outw(0x0000, ioaddr+LANCE_ADDR); in lance_probe1()
591 dev->dma = 4; /* Native bus-master, no DMA channel needed. */ in lance_probe1()
592 dev->irq = irq; in lance_probe1()
594 static const char dma_tbl[4] = {3, 5, 6, 0}; in lance_probe1()
597 dev->dma = dma_tbl[(port_val >> 4) & 3]; in lance_probe1()
598 dev->irq = irq_tbl[(port_val >> 2) & 3]; in lance_probe1()
599 printk(" HP Vectra IRQ %d DMA %d.\n", dev->irq, dev->dma); in lance_probe1()
604 dev->dma = dma_tbl[(reset_val >> 2) & 3]; in lance_probe1()
605 dev->irq = irq_tbl[(reset_val >> 4) & 7]; in lance_probe1()
606 printk(" HP J2405A IRQ %d DMA %d.\n", dev->irq, dev->dma); in lance_probe1()
607 } else if (lance_version == PCNET_ISAP) { /* The plug-n-play version. */ in lance_probe1()
611 dev->dma = bus_info & 0x07; in lance_probe1()
612 dev->irq = (bus_info >> 4) & 0x0F; in lance_probe1()
615 if (dev->mem_start & 0x07) in lance_probe1()
616 dev->dma = dev->mem_start & 0x07; in lance_probe1()
619 if (dev->dma == 0) { in lance_probe1()
622 dma_channels = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) | in lance_probe1()
623 (inb(DMA2_STAT_REG) & 0xf0); in lance_probe1()
625 err = -ENODEV; in lance_probe1()
626 if (dev->irq >= 2) in lance_probe1()
627 printk(" assigned IRQ %d", dev->irq); in lance_probe1()
628 else if (lance_version != 0) { /* 7990 boards need DMA detection first. */ in lance_probe1()
631 /* To auto-IRQ we enable the initialization-done and DMA error in lance_probe1()
637 outw(0x0041, ioaddr+LANCE_DATA); in lance_probe1()
640 dev->irq = probe_irq_off(irq_mask); in lance_probe1()
641 if (dev->irq) in lance_probe1()
642 printk(", probed IRQ %d", dev->irq); in lance_probe1()
648 /* Check for the initialization done bit, 0x0100, which means in lance_probe1()
650 if (inw(ioaddr+LANCE_DATA) & 0x0100) in lance_probe1()
651 dev->dma = 4; in lance_probe1()
654 if (dev->dma == 4) { in lance_probe1()
656 } else if (dev->dma) { in lance_probe1()
657 if (request_dma(dev->dma, chipname)) { in lance_probe1()
658 printk("DMA %d allocation failed.\n", dev->dma); in lance_probe1()
661 printk(", assigned DMA %d.\n", dev->dma); in lance_probe1()
662 } else { /* OK, we have to auto-DMA. */ in lance_probe1()
663 for (i = 0; i < 4; i++) { in lance_probe1()
672 outw(0x7f04, ioaddr+LANCE_DATA); /* Clear the memory error bits. */ in lance_probe1()
682 outw(0x0001, ioaddr+LANCE_DATA); in lance_probe1()
683 for (boguscnt = 100; boguscnt > 0; --boguscnt) in lance_probe1()
684 if (inw(ioaddr+LANCE_DATA) & 0x0900) in lance_probe1()
686 if (inw(ioaddr+LANCE_DATA) & 0x0100) { in lance_probe1()
687 dev->dma = dma; in lance_probe1()
688 printk(", DMA %d.\n", dev->dma); in lance_probe1()
703 if (lance_version == 0 && dev->irq == 0) { in lance_probe1()
704 /* We may auto-IRQ now that we have a DMA channel. */ in lance_probe1()
709 outw(0x0041, ioaddr+LANCE_DATA); in lance_probe1()
712 dev->irq = probe_irq_off(irq_mask); in lance_probe1()
713 if (dev->irq == 0) { in lance_probe1()
717 printk(" Auto-IRQ detected IRQ%d.\n", dev->irq); in lance_probe1()
720 if (chip_table[lp->chip_version].flags & LANCE_ENABLE_AUTOSELECT) { in lance_probe1()
721 /* Turn on auto-select of media (10baseT or BNC) so that the user in lance_probe1()
723 outw(0x0002, ioaddr+LANCE_ADDR); in lance_probe1()
725 outw(inw(ioaddr+LANCE_BUS_IF) | 0x0002, ioaddr+LANCE_BUS_IF); in lance_probe1()
728 if (lance_debug > 0 && did_version++ == 0) in lance_probe1()
731 /* The LANCE-specific entries in the device structure. */ in lance_probe1()
732 dev->netdev_ops = &lance_netdev_ops; in lance_probe1()
733 dev->watchdog_timeo = TX_TIMEOUT; in lance_probe1()
738 return 0; in lance_probe1()
740 if (dev->dma != 4) in lance_probe1()
741 free_dma(dev->dma); in lance_probe1()
743 kfree(lp->tx_bounce_buffs); in lance_probe1()
745 kfree((void*)lp->rx_buffs); in lance_probe1()
755 struct lance_private *lp = dev->ml_priv; in lance_open()
756 int ioaddr = dev->base_addr; in lance_open()
759 if (dev->irq == 0 || in lance_open()
760 request_irq(dev->irq, lance_interrupt, 0, dev->name, dev)) { in lance_open()
761 return -EAGAIN; in lance_open()
770 /* The DMA controller is used as a no-operation slave, "cascade mode". */ in lance_open()
771 if (dev->dma != 4) { in lance_open()
773 enable_dma(dev->dma); in lance_open()
774 set_dma_mode(dev->dma, DMA_MODE_CASCADE); in lance_open()
778 /* Un-Reset the LANCE, needed only for the NE2100. */ in lance_open()
779 if (chip_table[lp->chip_version].flags & LANCE_MUST_UNRESET) in lance_open()
780 outw(0, ioaddr+LANCE_RESET); in lance_open()
782 if (chip_table[lp->chip_version].flags & LANCE_ENABLE_AUTOSELECT) { in lance_open()
783 /* This is 79C960-specific: Turn on auto-select of media (AUI, BNC). */ in lance_open()
784 outw(0x0002, ioaddr+LANCE_ADDR); in lance_open()
786 outw(inw(ioaddr+LANCE_BUS_IF) | 0x0002, ioaddr+LANCE_BUS_IF); in lance_open()
791 dev->name, dev->irq, dev->dma, in lance_open()
792 (u32) isa_virt_to_bus(lp->tx_ring), in lance_open()
793 (u32) isa_virt_to_bus(lp->rx_ring), in lance_open()
794 (u32) isa_virt_to_bus(&lp->init_block)); in lance_open()
797 /* Re-initialize the LANCE, and start it when done. */ in lance_open()
798 outw(0x0001, ioaddr+LANCE_ADDR); in lance_open()
799 outw((short) (u32) isa_virt_to_bus(&lp->init_block), ioaddr+LANCE_DATA); in lance_open()
800 outw(0x0002, ioaddr+LANCE_ADDR); in lance_open()
801 outw(((u32)isa_virt_to_bus(&lp->init_block)) >> 16, ioaddr+LANCE_DATA); in lance_open()
803 outw(0x0004, ioaddr+LANCE_ADDR); in lance_open()
804 outw(0x0915, ioaddr+LANCE_DATA); in lance_open()
806 outw(0x0000, ioaddr+LANCE_ADDR); in lance_open()
807 outw(0x0001, ioaddr+LANCE_DATA); in lance_open()
811 i = 0; in lance_open()
813 if (inw(ioaddr+LANCE_DATA) & 0x0100) in lance_open()
816 * We used to clear the InitDone bit, 0x0100, here but Mark Stockton in lance_open()
819 outw(0x0042, ioaddr+LANCE_DATA); in lance_open()
823 dev->name, i, (u32) isa_virt_to_bus(&lp->init_block), inw(ioaddr+LANCE_DATA)); in lance_open()
825 return 0; /* Always succeed */ in lance_open()
830 etc.). Modern LANCE variants always reload their ring-buffer
834 sent (in effect, drop the packets on the floor) - the higher-level
836 these skbs to a temp list and then actually re-Tx them after
843 struct lance_private *lp = dev->ml_priv; in lance_purge_ring()
847 for (i = 0; i < RX_RING_SIZE; i++) { in lance_purge_ring()
848 struct sk_buff *skb = lp->rx_skbuff[i]; in lance_purge_ring()
849 lp->rx_skbuff[i] = NULL; in lance_purge_ring()
850 lp->rx_ring[i].base = 0; /* Not owned by LANCE chip. */ in lance_purge_ring()
854 for (i = 0; i < TX_RING_SIZE; i++) { in lance_purge_ring()
855 if (lp->tx_skbuff[i]) { in lance_purge_ring()
856 dev_kfree_skb_any(lp->tx_skbuff[i]); in lance_purge_ring()
857 lp->tx_skbuff[i] = NULL; in lance_purge_ring()
867 struct lance_private *lp = dev->ml_priv; in lance_init_ring()
870 lp->cur_rx = lp->cur_tx = 0; in lance_init_ring()
871 lp->dirty_rx = lp->dirty_tx = 0; in lance_init_ring()
873 for (i = 0; i < RX_RING_SIZE; i++) { in lance_init_ring()
878 lp->rx_skbuff[i] = skb; in lance_init_ring()
880 rx_buff = skb->data; in lance_init_ring()
884 lp->rx_ring[i].base = 0; in lance_init_ring()
886 lp->rx_ring[i].base = (u32)isa_virt_to_bus(rx_buff) | 0x80000000; in lance_init_ring()
887 lp->rx_ring[i].buf_length = -PKT_BUF_SZ; in lance_init_ring()
891 for (i = 0; i < TX_RING_SIZE; i++) { in lance_init_ring()
892 lp->tx_skbuff[i] = NULL; in lance_init_ring()
893 lp->tx_ring[i].base = 0; in lance_init_ring()
896 lp->init_block.mode = 0x0000; in lance_init_ring()
897 for (i = 0; i < 6; i++) in lance_init_ring()
898 lp->init_block.phys_addr[i] = dev->dev_addr[i]; in lance_init_ring()
899 lp->init_block.filter[0] = 0x00000000; in lance_init_ring()
900 lp->init_block.filter[1] = 0x00000000; in lance_init_ring()
901 lp->init_block.rx_ring = ((u32)isa_virt_to_bus(lp->rx_ring) & 0xffffff) | RX_RING_LEN_BITS; in lance_init_ring()
902 lp->init_block.tx_ring = ((u32)isa_virt_to_bus(lp->tx_ring) & 0xffffff) | TX_RING_LEN_BITS; in lance_init_ring()
908 struct lance_private *lp = dev->ml_priv; in lance_restart()
911 (chip_table[lp->chip_version].flags & LANCE_MUST_REINIT_RING)) { in lance_restart()
915 outw(0x0000, dev->base_addr + LANCE_ADDR); in lance_restart()
916 outw(csr0_bits, dev->base_addr + LANCE_DATA); in lance_restart()
922 struct lance_private *lp = (struct lance_private *) dev->ml_priv; in lance_tx_timeout()
923 int ioaddr = dev->base_addr; in lance_tx_timeout()
925 outw (0, ioaddr + LANCE_ADDR); in lance_tx_timeout()
927 dev->name, inw (ioaddr + LANCE_DATA)); in lance_tx_timeout()
928 outw (0x0004, ioaddr + LANCE_DATA); in lance_tx_timeout()
929 dev->stats.tx_errors++; in lance_tx_timeout()
934 lp->dirty_tx, lp->cur_tx, netif_queue_stopped(dev) ? " (full)" : "", in lance_tx_timeout()
935 lp->cur_rx); in lance_tx_timeout()
936 for (i = 0; i < RX_RING_SIZE; i++) in lance_tx_timeout()
937 printk ("%s %08x %04x %04x", i & 0x3 ? "" : "\n ", in lance_tx_timeout()
938 lp->rx_ring[i].base, -lp->rx_ring[i].buf_length, in lance_tx_timeout()
939 lp->rx_ring[i].msg_length); in lance_tx_timeout()
940 for (i = 0; i < TX_RING_SIZE; i++) in lance_tx_timeout()
941 printk ("%s %08x %04x %04x", i & 0x3 ? "" : "\n ", in lance_tx_timeout()
942 lp->tx_ring[i].base, -lp->tx_ring[i].length, in lance_tx_timeout()
943 lp->tx_ring[i].misc); in lance_tx_timeout()
947 lance_restart (dev, 0x0043, 1); in lance_tx_timeout()
957 struct lance_private *lp = dev->ml_priv; in lance_start_xmit()
958 int ioaddr = dev->base_addr; in lance_start_xmit()
962 spin_lock_irqsave(&lp->devlock, flags); in lance_start_xmit()
965 outw(0x0000, ioaddr+LANCE_ADDR); in lance_start_xmit()
966 printk("%s: lance_start_xmit() called, csr0 %4.4x.\n", dev->name, in lance_start_xmit()
968 outw(0x0000, ioaddr+LANCE_DATA); in lance_start_xmit()
974 entry = lp->cur_tx & TX_RING_MOD_MASK; in lance_start_xmit()
980 if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) { in lance_start_xmit()
981 if (skb->len < ETH_ZLEN) { in lance_start_xmit()
984 lp->tx_ring[entry].length = -ETH_ZLEN; in lance_start_xmit()
987 lp->tx_ring[entry].length = -skb->len; in lance_start_xmit()
989 lp->tx_ring[entry].length = -skb->len; in lance_start_xmit()
991 lp->tx_ring[entry].misc = 0x0000; in lance_start_xmit()
993 dev->stats.tx_bytes += skb->len; in lance_start_xmit()
995 /* If any part of this buffer is >16M we must copy it to a low-memory in lance_start_xmit()
997 if ((u32)isa_virt_to_bus(skb->data) + skb->len > 0x01000000) { in lance_start_xmit()
999 printk("%s: bouncing a high-memory packet (%#x).\n", in lance_start_xmit()
1000 dev->name, (u32)isa_virt_to_bus(skb->data)); in lance_start_xmit()
1001 skb_copy_from_linear_data(skb, &lp->tx_bounce_buffs[entry], skb->len); in lance_start_xmit()
1002 lp->tx_ring[entry].base = in lance_start_xmit()
1003 ((u32)isa_virt_to_bus((lp->tx_bounce_buffs + entry)) & 0xffffff) | 0x83000000; in lance_start_xmit()
1006 lp->tx_skbuff[entry] = skb; in lance_start_xmit()
1007 lp->tx_ring[entry].base = ((u32)isa_virt_to_bus(skb->data) & 0xffffff) | 0x83000000; in lance_start_xmit()
1009 lp->cur_tx++; in lance_start_xmit()
1012 outw(0x0000, ioaddr+LANCE_ADDR); in lance_start_xmit()
1013 outw(0x0048, ioaddr+LANCE_DATA); in lance_start_xmit()
1015 if ((lp->cur_tx - lp->dirty_tx) >= TX_RING_SIZE) in lance_start_xmit()
1019 spin_unlock_irqrestore(&lp->devlock, flags); in lance_start_xmit()
1031 ioaddr = dev->base_addr; in lance_interrupt()
1032 lp = dev->ml_priv; in lance_interrupt()
1034 spin_lock (&lp->devlock); in lance_interrupt()
1036 outw(0x00, dev->base_addr + LANCE_ADDR); in lance_interrupt()
1037 while ((csr0 = inw(dev->base_addr + LANCE_DATA)) & 0x8600 && in lance_interrupt()
1038 --boguscnt >= 0) { in lance_interrupt()
1040 outw(csr0 & ~0x004f, dev->base_addr + LANCE_DATA); in lance_interrupt()
1042 must_restart = 0; in lance_interrupt()
1046 dev->name, csr0, inw(dev->base_addr + LANCE_DATA)); in lance_interrupt()
1048 if (csr0 & 0x0400) /* Rx interrupt */ in lance_interrupt()
1051 if (csr0 & 0x0200) { /* Tx-done interrupt */ in lance_interrupt()
1052 int dirty_tx = lp->dirty_tx; in lance_interrupt()
1054 while (dirty_tx < lp->cur_tx) { in lance_interrupt()
1056 int status = lp->tx_ring[entry].base; in lance_interrupt()
1058 if (status < 0) in lance_interrupt()
1061 lp->tx_ring[entry].base = 0; in lance_interrupt()
1063 if (status & 0x40000000) { in lance_interrupt()
1065 int err_status = lp->tx_ring[entry].misc; in lance_interrupt()
1066 dev->stats.tx_errors++; in lance_interrupt()
1067 if (err_status & 0x0400) in lance_interrupt()
1068 dev->stats.tx_aborted_errors++; in lance_interrupt()
1069 if (err_status & 0x0800) in lance_interrupt()
1070 dev->stats.tx_carrier_errors++; in lance_interrupt()
1071 if (err_status & 0x1000) in lance_interrupt()
1072 dev->stats.tx_window_errors++; in lance_interrupt()
1073 if (err_status & 0x4000) { in lance_interrupt()
1075 dev->stats.tx_fifo_errors++; in lance_interrupt()
1078 dev->name, csr0); in lance_interrupt()
1083 if (status & 0x18000000) in lance_interrupt()
1084 dev->stats.collisions++; in lance_interrupt()
1085 dev->stats.tx_packets++; in lance_interrupt()
1088 /* We must free the original skb if it's not a data-only copy in lance_interrupt()
1090 if (lp->tx_skbuff[entry]) { in lance_interrupt()
1091 dev_consume_skb_irq(lp->tx_skbuff[entry]); in lance_interrupt()
1092 lp->tx_skbuff[entry] = NULL; in lance_interrupt()
1098 if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) { in lance_interrupt()
1099 printk("out-of-sync dirty pointer, %d vs. %d, full=%s.\n", in lance_interrupt()
1100 dirty_tx, lp->cur_tx, in lance_interrupt()
1108 dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) in lance_interrupt()
1111 lp->dirty_tx = dirty_tx; in lance_interrupt()
1115 if (csr0 & 0x4000) in lance_interrupt()
1116 dev->stats.tx_errors++; /* Tx babble. */ in lance_interrupt()
1117 if (csr0 & 0x1000) in lance_interrupt()
1118 dev->stats.rx_errors++; /* Missed a Rx frame. */ in lance_interrupt()
1119 if (csr0 & 0x0800) { in lance_interrupt()
1121 dev->name, csr0); in lance_interrupt()
1128 outw(0x0000, dev->base_addr + LANCE_ADDR); in lance_interrupt()
1129 outw(0x0004, dev->base_addr + LANCE_DATA); in lance_interrupt()
1130 lance_restart(dev, 0x0002, 0); in lance_interrupt()
1135 outw(0x0000, dev->base_addr + LANCE_ADDR); in lance_interrupt()
1136 outw(0x7940, dev->base_addr + LANCE_DATA); in lance_interrupt()
1140 dev->name, inw(ioaddr + LANCE_ADDR), in lance_interrupt()
1141 inw(dev->base_addr + LANCE_DATA)); in lance_interrupt()
1143 spin_unlock (&lp->devlock); in lance_interrupt()
1150 struct lance_private *lp = dev->ml_priv; in lance_rx()
1151 int entry = lp->cur_rx & RX_RING_MOD_MASK; in lance_rx()
1155 while (lp->rx_ring[entry].base >= 0) { in lance_rx()
1156 int status = lp->rx_ring[entry].base >> 24; in lance_rx()
1158 if (status != 0x03) { /* There was an error. */ in lance_rx()
1160 <murf@perftech.com> to Russ Nelson: Even with full-sized in lance_rx()
1163 if (status & 0x01) /* Only count a general error at the */ in lance_rx()
1164 dev->stats.rx_errors++; /* end of a packet.*/ in lance_rx()
1165 if (status & 0x20) in lance_rx()
1166 dev->stats.rx_frame_errors++; in lance_rx()
1167 if (status & 0x10) in lance_rx()
1168 dev->stats.rx_over_errors++; in lance_rx()
1169 if (status & 0x08) in lance_rx()
1170 dev->stats.rx_crc_errors++; in lance_rx()
1171 if (status & 0x04) in lance_rx()
1172 dev->stats.rx_fifo_errors++; in lance_rx()
1173 lp->rx_ring[entry].base &= 0x03ffffff; in lance_rx()
1178 short pkt_len = (lp->rx_ring[entry].msg_length & 0xfff)-4; in lance_rx()
1183 printk("%s: Runt packet!\n",dev->name); in lance_rx()
1184 dev->stats.rx_errors++; in lance_rx()
1191 printk("%s: Memory squeeze, deferring packet.\n", dev->name); in lance_rx()
1192 for (i=0; i < RX_RING_SIZE; i++) in lance_rx()
1193 if (lp->rx_ring[(entry+i) & RX_RING_MOD_MASK].base < 0) in lance_rx()
1196 if (i > RX_RING_SIZE -2) in lance_rx()
1198 dev->stats.rx_dropped++; in lance_rx()
1199 lp->rx_ring[entry].base |= 0x80000000; in lance_rx()
1200 lp->cur_rx++; in lance_rx()
1207 (unsigned char *)isa_bus_to_virt((lp->rx_ring[entry].base & 0x00ffffff)), in lance_rx()
1209 skb->protocol=eth_type_trans(skb,dev); in lance_rx()
1211 dev->stats.rx_packets++; in lance_rx()
1212 dev->stats.rx_bytes += pkt_len; in lance_rx()
1217 lp->rx_ring[entry].buf_length = -PKT_BUF_SZ; in lance_rx()
1218 lp->rx_ring[entry].base |= 0x80000000; in lance_rx()
1219 entry = (++lp->cur_rx) & RX_RING_MOD_MASK; in lance_rx()
1223 we should free one and mark stats->rx_dropped++. */ in lance_rx()
1225 return 0; in lance_rx()
1231 int ioaddr = dev->base_addr; in lance_close()
1232 struct lance_private *lp = dev->ml_priv; in lance_close()
1236 if (chip_table[lp->chip_version].flags & LANCE_HAS_MISSED_FRAME) { in lance_close()
1238 dev->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA); in lance_close()
1240 outw(0, ioaddr+LANCE_ADDR); in lance_close()
1244 dev->name, inw(ioaddr+LANCE_DATA)); in lance_close()
1246 /* We stop the LANCE here -- it occasionally polls in lance_close()
1248 outw(0x0004, ioaddr+LANCE_DATA); in lance_close()
1250 if (dev->dma != 4) in lance_close()
1253 disable_dma(dev->dma); in lance_close()
1256 free_irq(dev->irq, dev); in lance_close()
1260 return 0; in lance_close()
1265 struct lance_private *lp = dev->ml_priv; in lance_get_stats()
1267 if (chip_table[lp->chip_version].flags & LANCE_HAS_MISSED_FRAME) { in lance_get_stats()
1268 short ioaddr = dev->base_addr; in lance_get_stats()
1272 spin_lock_irqsave(&lp->devlock, flags); in lance_get_stats()
1275 dev->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA); in lance_get_stats()
1277 spin_unlock_irqrestore(&lp->devlock, flags); in lance_get_stats()
1280 return &dev->stats; in lance_get_stats()
1288 short ioaddr = dev->base_addr; in set_multicast_list()
1290 outw(0, ioaddr+LANCE_ADDR); in set_multicast_list()
1291 outw(0x0004, ioaddr+LANCE_DATA); /* Temporarily stop the lance. */ in set_multicast_list()
1293 if (dev->flags&IFF_PROMISC) { in set_multicast_list()
1295 outw(0x8000, ioaddr+LANCE_DATA); /* Set promiscuous mode */ in set_multicast_list()
1300 if(dev->flags&IFF_ALLMULTI) in set_multicast_list()
1302 /* FIXIT: We don't use the multicast table, but rely on upper-layer filtering. */ in set_multicast_list()
1303 memset(multicast_table, (num_addrs == 0) ? 0 : -1, sizeof(multicast_table)); in set_multicast_list()
1304 for (i = 0; i < 4; i++) { in set_multicast_list()
1309 outw(0x0000, ioaddr+LANCE_DATA); /* Unset promiscuous mode */ in set_multicast_list()
1312 lance_restart(dev, 0x0142, 0); /* Resume normal operation */ in set_multicast_list()