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 <[email protected]>
36 the 2.1 version of the old driver - Alan Cox
39 Arnaldo Carvalho de Melo <[email protected]> - 11/01/2001
42 Vesselin Kostadinov <vesok at yahoo dot com > - 22/4/2004
67 static unsigned int lance_portlist[] __initdata = { 0x300, 0x320, 0x340, 0x360, 0};
77 .id_offset14 = 0x57,
78 .id_offset15 = 0x57,
81 .id_offset14 = 0x52,
82 .id_offset15 = 0x44,
85 .id_offset14 = 0x52,
86 .id_offset15 = 0x49,
102 This device driver is designed for the AMD 79C960, the "PCnet-ISA
103 single-chip ethernet controller for ISA". This chip is used in a wide
110 II. Board-specific settings
113 bus-master mode, rather than in shared memory mode. (Only older designs
114 have on-board buffer memory needed to support the slower shared memory mode.)
118 {0x300, 0x320, 0x340, 0x360}.
119 After the board is found it generates a DMA-timeout interrupt and uses
121 of the otherwise-unused dev->mem_start value (aka PARAM1). If unset it is
125 The HP-J2405A board is an exception: with this board it is easy to read the
126 EEPROM-set values for the base, IRQ, and DMA. (Of course you must already
127 _know_ the base address -- that field is for writing the EEPROM.)
140 of entries makes it more difficult to achieve back-to-back packet transmission
142 of receiving back-to-back minimum-sized packets.)
145 statically allocates full-sized (slightly oversized -- PKT_BUF_SZ) buffers to
147 allocating full-sized buffers "just in case", at the expense of a
148 memory-to-memory data copy for each packet received. For most systems this
151 the buffers are only used when needed as low-memory bounce buffers.
162 As mentioned before, low-memory "bounce-buffers" are used when needed.
165 The driver runs as two independent, single-threaded flows of control. One
166 is the send-packet routine, which enforces single-threaded use by the
167 dev->tbusy flag. The other thread is the interrupt handler, which is single
170 The send packet thread has partial control over the Tx ring and 'dev->tbusy'
173 the 'lp->tx_full' flag.
176 from the Tx ring. (The Tx-done interrupt can't be selectively turned off, so
179 the 'base' to zero. Iff the 'lp->tx_full' flag is set, it clears both the
187 This is a compile-time option for efficiency.
195 #define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
199 #define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
205 #define LANCE_DATA 0x10
206 #define LANCE_ADDR 0x12
207 #define LANCE_RESET 0x14
208 #define LANCE_BUS_IF 0x16
209 #define LANCE_TOTAL_SIZE 0x18
228 u16 mode; /* Pre-set mode (reg. 15) */
237 /* The Tx and Rx ring entries must be aligned on 8-byte boundaries. */
242 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
244 /* The addresses of receive-in-place skbuffs. */
247 /* Tx low-memory "bounce buffer" address. */
256 #define LANCE_MUST_PAD 0x00000001
257 #define LANCE_ENABLE_AUTOSELECT 0x00000002
258 #define LANCE_MUST_REINIT_RING 0x00000004
259 #define LANCE_MUST_UNRESET 0x00000008
260 #define LANCE_HAS_MISSED_FRAME 0x00000010
263 These are from the datasheets -- in real life the '970 version
270 {0x0000, "LANCE 7990", /* Ancient lance chip. */
272 {0x0003, "PCnet/ISA 79C960", /* 79C960 PCnet/ISA. */
275 {0x2260, "PCnet/ISA+ 79C961", /* 79C961 PCnet/ISA+, Plug-n-Play. */
278 {0x2420, "PCnet/PCI 79C970", /* 79C970 or 79C974 PCnet-SCSI, PCI. */
283 {0x2430, "PCnet32", /* 79C965 PCnet for VL bus. */
286 {0x2621, "PCnet/PCI-II 79C970A", /* 79C970A PCInetPCI II. */
289 {0x0, "PCnet (unknown)",
294 enum {OLD_LANCE = 0, PCNET_ISA=1, PCNET_ISAP=2, PCNET_PCI=3, PCNET_VLB=4, PCNET_PCI_II=5, LANCE_UNK…
297 /* Non-zero if lance_probe1() needs to allocate low-memory bounce buffers.
322 module_param_hw_array(io, int, ioport, NULL, 0);
323 module_param_hw_array(dma, int, dma, NULL, 0);
324 module_param_hw_array(irq, int, irq, NULL, 0);
325 module_param(lance_debug, int, 0);
329 MODULE_PARM_DESC(lance_debug, "LANCE/PCnet debug level (0-7)");
334 int this_dev, found = 0; in lance_init_module()
336 for (this_dev = 0; this_dev < MAX_CARDS; this_dev++) { in lance_init_module()
337 if (io[this_dev] == 0) { in lance_init_module()
338 if (this_dev != 0) /* only complain once */ in lance_init_module()
340 printk(KERN_NOTICE "lance.c: Module autoprobing not allowed. Append \"io=0xNNN\" value(s).\n"); in lance_init_module()
341 return -EPERM; in lance_init_module()
343 dev = alloc_etherdev(0); in lance_init_module()
346 dev->irq = irq[this_dev]; in lance_init_module()
347 dev->base_addr = io[this_dev]; in lance_init_module()
348 dev->dma = dma[this_dev]; in lance_init_module()
349 if (do_lance_probe(dev) == 0) { in lance_init_module()
356 if (found != 0) in lance_init_module()
357 return 0; in lance_init_module()
358 return -ENXIO; in lance_init_module()
364 struct lance_private *lp = dev->ml_priv; in cleanup_card()
365 if (dev->dma != 4) in cleanup_card()
366 free_dma(dev->dma); in cleanup_card()
367 release_region(dev->base_addr, LANCE_TOTAL_SIZE); in cleanup_card()
368 kfree(lp->tx_bounce_buffs); in cleanup_card()
369 kfree((void*)lp->rx_buffs); in cleanup_card()
377 for (this_dev = 0; this_dev < MAX_CARDS; this_dev++) { in lance_cleanup_module()
393 board probes now that kmalloc() can allocate ISA DMA-able regions.
402 lance_need_isa_bounce_buffers = 0; in do_lance_probe()
407 "lance-probe"); in do_lance_probe()
413 for (card = 0; card < NUM_CARDS; ++card) in do_lance_probe()
418 for (card = 0; card < NUM_CARDS; ++card) in do_lance_probe()
424 result = lance_probe1(dev, ioaddr, 0, 0); in do_lance_probe()
426 struct lance_private *lp = dev->ml_priv; in do_lance_probe()
427 int ver = lp->chip_version; in do_lance_probe()
429 r->name = chip_table[ver].name; in do_lance_probe()
430 return 0; in do_lance_probe()
436 return -ENODEV; in do_lance_probe()
442 struct net_device *dev = alloc_etherdev(0); in lance_probe()
446 return ERR_PTR(-ENODEV); in lance_probe()
448 sprintf(dev->name, "eth%d", unit); in lance_probe()
475 unsigned long dma_channels; /* Mark spuriously-busy DMA channels */ in lance_probe1()
479 unsigned char hpJ2405A = 0; /* HP ISA adaptor */ in lance_probe1()
480 int hp_builtin = 0; /* HP on-board ethernet. */ in lance_probe1()
483 int err = -ENOMEM; in lance_probe1()
488 Check for HP's on-board ethernet by looking for 'HP' in the BIOS. in lance_probe1()
492 bios = ioremap(0xf00f0, 0x14); in lance_probe1()
494 return -ENOMEM; in lance_probe1()
495 if (readw(bios + 0x12) == 0x5048) { in lance_probe1()
496 static const short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360}; in lance_probe1()
497 int hp_port = (readl(bios + 1) & 1) ? 0x499 : 0x99; in lance_probe1()
498 /* We can have boards other than the built-in! Verify this is on-board. */ in lance_probe1()
499 if ((inb(hp_port) & 0xc0) == 0x80 && in lance_probe1()
504 /* We also recognize the HP Vectra on-board here, but check below. */ in lance_probe1()
505 hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00 && in lance_probe1()
506 inb(ioaddr+2) == 0x09); in lance_probe1()
511 /* The Un-Reset needed is only needed for the real NE2100, and will in lance_probe1()
516 outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */ in lance_probe1()
517 if (inw(ioaddr+LANCE_DATA) != 0x0004) in lance_probe1()
518 return -ENODEV; in lance_probe1()
523 lance_version = 0; in lance_probe1()
530 if ((chip_version & 0xfff) != 0x003) in lance_probe1()
531 return -ENODEV; in lance_probe1()
532 chip_version = (chip_version >> 12) & 0xffff; in lance_probe1()
540 a ISA DMA-able region. */ in lance_probe1()
542 printk("%s: %s at %#3x, ", dev->name, chipname, ioaddr); in lance_probe1()
546 for (i = 0; i < 6; i++) in lance_probe1()
549 printk("%pM", dev->dev_addr); in lance_probe1()
551 dev->base_addr = ioaddr; in lance_probe1()
556 return -ENOMEM; in lance_probe1()
557 if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); in lance_probe1()
558 dev->ml_priv = lp; in lance_probe1()
559 lp->name = chipname; in lance_probe1()
560 lp->rx_buffs = (unsigned long)kmalloc_array(RX_RING_SIZE, PKT_BUF_SZ, in lance_probe1()
562 if (!lp->rx_buffs) in lance_probe1()
565 lp->tx_bounce_buffs = kmalloc_array(TX_RING_SIZE, PKT_BUF_SZ, in lance_probe1()
567 if (!lp->tx_bounce_buffs) in lance_probe1()
570 lp->tx_bounce_buffs = NULL; in lance_probe1()
572 lp->chip_version = lance_version; in lance_probe1()
573 spin_lock_init(&lp->devlock); in lance_probe1()
575 lp->init_block.mode = 0x0003; /* Disable Rx and Tx. */ in lance_probe1()
576 for (i = 0; i < 6; i++) in lance_probe1()
577 lp->init_block.phys_addr[i] = dev->dev_addr[i]; in lance_probe1()
578 lp->init_block.filter[0] = 0x00000000; in lance_probe1()
579 lp->init_block.filter[1] = 0x00000000; in lance_probe1()
580 lp->init_block.rx_ring = ((u32)isa_virt_to_bus(lp->rx_ring) & 0xffffff) | RX_RING_LEN_BITS; in lance_probe1()
581 lp->init_block.tx_ring = ((u32)isa_virt_to_bus(lp->tx_ring) & 0xffffff) | TX_RING_LEN_BITS; in lance_probe1()
583 outw(0x0001, ioaddr+LANCE_ADDR); in lance_probe1()
585 outw((short) (u32) isa_virt_to_bus(&lp->init_block), ioaddr+LANCE_DATA); in lance_probe1()
586 outw(0x0002, ioaddr+LANCE_ADDR); in lance_probe1()
588 outw(((u32)isa_virt_to_bus(&lp->init_block)) >> 16, ioaddr+LANCE_DATA); in lance_probe1()
589 outw(0x0000, ioaddr+LANCE_ADDR); in lance_probe1()
593 dev->dma = 4; /* Native bus-master, no DMA channel needed. */ in lance_probe1()
594 dev->irq = irq; in lance_probe1()
596 static const char dma_tbl[4] = {3, 5, 6, 0}; in lance_probe1()
599 dev->dma = dma_tbl[(port_val >> 4) & 3]; in lance_probe1()
600 dev->irq = irq_tbl[(port_val >> 2) & 3]; in lance_probe1()
601 printk(" HP Vectra IRQ %d DMA %d.\n", dev->irq, dev->dma); in lance_probe1()
606 dev->dma = dma_tbl[(reset_val >> 2) & 3]; in lance_probe1()
607 dev->irq = irq_tbl[(reset_val >> 4) & 7]; in lance_probe1()
608 printk(" HP J2405A IRQ %d DMA %d.\n", dev->irq, dev->dma); in lance_probe1()
609 } else if (lance_version == PCNET_ISAP) { /* The plug-n-play version. */ in lance_probe1()
613 dev->dma = bus_info & 0x07; in lance_probe1()
614 dev->irq = (bus_info >> 4) & 0x0F; in lance_probe1()
617 if (dev->mem_start & 0x07) in lance_probe1()
618 dev->dma = dev->mem_start & 0x07; in lance_probe1()
621 if (dev->dma == 0) { in lance_probe1()
624 dma_channels = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) | in lance_probe1()
625 (inb(DMA2_STAT_REG) & 0xf0); in lance_probe1()
627 err = -ENODEV; in lance_probe1()
628 if (dev->irq >= 2) in lance_probe1()
629 printk(" assigned IRQ %d", dev->irq); in lance_probe1()
630 else if (lance_version != 0) { /* 7990 boards need DMA detection first. */ in lance_probe1()
633 /* To auto-IRQ we enable the initialization-done and DMA error in lance_probe1()
639 outw(0x0041, ioaddr+LANCE_DATA); in lance_probe1()
642 dev->irq = probe_irq_off(irq_mask); in lance_probe1()
643 if (dev->irq) in lance_probe1()
644 printk(", probed IRQ %d", dev->irq); in lance_probe1()
650 /* Check for the initialization done bit, 0x0100, which means in lance_probe1()
652 if (inw(ioaddr+LANCE_DATA) & 0x0100) in lance_probe1()
653 dev->dma = 4; in lance_probe1()
656 if (dev->dma == 4) { in lance_probe1()
658 } else if (dev->dma) { in lance_probe1()
659 if (request_dma(dev->dma, chipname)) { in lance_probe1()
660 printk("DMA %d allocation failed.\n", dev->dma); in lance_probe1()
663 printk(", assigned DMA %d.\n", dev->dma); in lance_probe1()
664 } else { /* OK, we have to auto-DMA. */ in lance_probe1()
665 for (i = 0; i < 4; i++) { in lance_probe1()
674 outw(0x7f04, ioaddr+LANCE_DATA); /* Clear the memory error bits. */ in lance_probe1()
684 outw(0x0001, ioaddr+LANCE_DATA); in lance_probe1()
685 for (boguscnt = 100; boguscnt > 0; --boguscnt) in lance_probe1()
686 if (inw(ioaddr+LANCE_DATA) & 0x0900) in lance_probe1()
688 if (inw(ioaddr+LANCE_DATA) & 0x0100) { in lance_probe1()
689 dev->dma = dma; in lance_probe1()
690 printk(", DMA %d.\n", dev->dma); in lance_probe1()
705 if (lance_version == 0 && dev->irq == 0) { in lance_probe1()
706 /* We may auto-IRQ now that we have a DMA channel. */ in lance_probe1()
711 outw(0x0041, ioaddr+LANCE_DATA); in lance_probe1()
714 dev->irq = probe_irq_off(irq_mask); in lance_probe1()
715 if (dev->irq == 0) { in lance_probe1()
719 printk(" Auto-IRQ detected IRQ%d.\n", dev->irq); in lance_probe1()
722 if (chip_table[lp->chip_version].flags & LANCE_ENABLE_AUTOSELECT) { in lance_probe1()
723 /* Turn on auto-select of media (10baseT or BNC) so that the user in lance_probe1()
725 outw(0x0002, ioaddr+LANCE_ADDR); in lance_probe1()
727 outw(inw(ioaddr+LANCE_BUS_IF) | 0x0002, ioaddr+LANCE_BUS_IF); in lance_probe1()
730 if (lance_debug > 0 && did_version++ == 0) in lance_probe1()
733 /* The LANCE-specific entries in the device structure. */ in lance_probe1()
734 dev->netdev_ops = &lance_netdev_ops; in lance_probe1()
735 dev->watchdog_timeo = TX_TIMEOUT; in lance_probe1()
740 return 0; in lance_probe1()
742 if (dev->dma != 4) in lance_probe1()
743 free_dma(dev->dma); in lance_probe1()
745 kfree(lp->tx_bounce_buffs); in lance_probe1()
747 kfree((void*)lp->rx_buffs); in lance_probe1()
757 struct lance_private *lp = dev->ml_priv; in lance_open()
758 int ioaddr = dev->base_addr; in lance_open()
761 if (dev->irq == 0 || in lance_open()
762 request_irq(dev->irq, lance_interrupt, 0, dev->name, dev)) { in lance_open()
763 return -EAGAIN; in lance_open()
772 /* The DMA controller is used as a no-operation slave, "cascade mode". */ in lance_open()
773 if (dev->dma != 4) { in lance_open()
775 enable_dma(dev->dma); in lance_open()
776 set_dma_mode(dev->dma, DMA_MODE_CASCADE); in lance_open()
780 /* Un-Reset the LANCE, needed only for the NE2100. */ in lance_open()
781 if (chip_table[lp->chip_version].flags & LANCE_MUST_UNRESET) in lance_open()
782 outw(0, ioaddr+LANCE_RESET); in lance_open()
784 if (chip_table[lp->chip_version].flags & LANCE_ENABLE_AUTOSELECT) { in lance_open()
785 /* This is 79C960-specific: Turn on auto-select of media (AUI, BNC). */ in lance_open()
786 outw(0x0002, ioaddr+LANCE_ADDR); in lance_open()
788 outw(inw(ioaddr+LANCE_BUS_IF) | 0x0002, ioaddr+LANCE_BUS_IF); in lance_open()
793 dev->name, dev->irq, dev->dma, in lance_open()
794 (u32) isa_virt_to_bus(lp->tx_ring), in lance_open()
795 (u32) isa_virt_to_bus(lp->rx_ring), in lance_open()
796 (u32) isa_virt_to_bus(&lp->init_block)); in lance_open()
799 /* Re-initialize the LANCE, and start it when done. */ in lance_open()
800 outw(0x0001, ioaddr+LANCE_ADDR); in lance_open()
801 outw((short) (u32) isa_virt_to_bus(&lp->init_block), ioaddr+LANCE_DATA); in lance_open()
802 outw(0x0002, ioaddr+LANCE_ADDR); in lance_open()
803 outw(((u32)isa_virt_to_bus(&lp->init_block)) >> 16, ioaddr+LANCE_DATA); in lance_open()
805 outw(0x0004, ioaddr+LANCE_ADDR); in lance_open()
806 outw(0x0915, ioaddr+LANCE_DATA); in lance_open()
808 outw(0x0000, ioaddr+LANCE_ADDR); in lance_open()
809 outw(0x0001, ioaddr+LANCE_DATA); in lance_open()
813 i = 0; in lance_open()
815 if (inw(ioaddr+LANCE_DATA) & 0x0100) in lance_open()
818 * We used to clear the InitDone bit, 0x0100, here but Mark Stockton in lance_open()
821 outw(0x0042, ioaddr+LANCE_DATA); in lance_open()
825 dev->name, i, (u32) isa_virt_to_bus(&lp->init_block), inw(ioaddr+LANCE_DATA)); in lance_open()
827 return 0; /* Always succeed */ in lance_open()
832 etc.). Modern LANCE variants always reload their ring-buffer
836 sent (in effect, drop the packets on the floor) - the higher-level
838 these skbs to a temp list and then actually re-Tx them after
845 struct lance_private *lp = dev->ml_priv; in lance_purge_ring()
849 for (i = 0; i < RX_RING_SIZE; i++) { in lance_purge_ring()
850 struct sk_buff *skb = lp->rx_skbuff[i]; in lance_purge_ring()
851 lp->rx_skbuff[i] = NULL; in lance_purge_ring()
852 lp->rx_ring[i].base = 0; /* Not owned by LANCE chip. */ in lance_purge_ring()
856 for (i = 0; i < TX_RING_SIZE; i++) { in lance_purge_ring()
857 if (lp->tx_skbuff[i]) { in lance_purge_ring()
858 dev_kfree_skb_any(lp->tx_skbuff[i]); in lance_purge_ring()
859 lp->tx_skbuff[i] = NULL; in lance_purge_ring()
869 struct lance_private *lp = dev->ml_priv; in lance_init_ring()
872 lp->cur_rx = lp->cur_tx = 0; in lance_init_ring()
873 lp->dirty_rx = lp->dirty_tx = 0; in lance_init_ring()
875 for (i = 0; i < RX_RING_SIZE; i++) { in lance_init_ring()
880 lp->rx_skbuff[i] = skb; in lance_init_ring()
882 rx_buff = skb->data; in lance_init_ring()
886 lp->rx_ring[i].base = 0; in lance_init_ring()
888 lp->rx_ring[i].base = (u32)isa_virt_to_bus(rx_buff) | 0x80000000; in lance_init_ring()
889 lp->rx_ring[i].buf_length = -PKT_BUF_SZ; in lance_init_ring()
893 for (i = 0; i < TX_RING_SIZE; i++) { in lance_init_ring()
894 lp->tx_skbuff[i] = NULL; in lance_init_ring()
895 lp->tx_ring[i].base = 0; in lance_init_ring()
898 lp->init_block.mode = 0x0000; in lance_init_ring()
899 for (i = 0; i < 6; i++) in lance_init_ring()
900 lp->init_block.phys_addr[i] = dev->dev_addr[i]; in lance_init_ring()
901 lp->init_block.filter[0] = 0x00000000; in lance_init_ring()
902 lp->init_block.filter[1] = 0x00000000; in lance_init_ring()
903 lp->init_block.rx_ring = ((u32)isa_virt_to_bus(lp->rx_ring) & 0xffffff) | RX_RING_LEN_BITS; in lance_init_ring()
904 lp->init_block.tx_ring = ((u32)isa_virt_to_bus(lp->tx_ring) & 0xffffff) | TX_RING_LEN_BITS; in lance_init_ring()
910 struct lance_private *lp = dev->ml_priv; in lance_restart()
913 (chip_table[lp->chip_version].flags & LANCE_MUST_REINIT_RING)) { in lance_restart()
917 outw(0x0000, dev->base_addr + LANCE_ADDR); in lance_restart()
918 outw(csr0_bits, dev->base_addr + LANCE_DATA); in lance_restart()
924 struct lance_private *lp = (struct lance_private *) dev->ml_priv; in lance_tx_timeout()
925 int ioaddr = dev->base_addr; in lance_tx_timeout()
927 outw (0, ioaddr + LANCE_ADDR); in lance_tx_timeout()
929 dev->name, inw (ioaddr + LANCE_DATA)); in lance_tx_timeout()
930 outw (0x0004, ioaddr + LANCE_DATA); in lance_tx_timeout()
931 dev->stats.tx_errors++; in lance_tx_timeout()
936 lp->dirty_tx, lp->cur_tx, netif_queue_stopped(dev) ? " (full)" : "", in lance_tx_timeout()
937 lp->cur_rx); in lance_tx_timeout()
938 for (i = 0; i < RX_RING_SIZE; i++) in lance_tx_timeout()
939 printk ("%s %08x %04x %04x", i & 0x3 ? "" : "\n ", in lance_tx_timeout()
940 lp->rx_ring[i].base, -lp->rx_ring[i].buf_length, in lance_tx_timeout()
941 lp->rx_ring[i].msg_length); in lance_tx_timeout()
942 for (i = 0; i < TX_RING_SIZE; i++) in lance_tx_timeout()
943 printk ("%s %08x %04x %04x", i & 0x3 ? "" : "\n ", in lance_tx_timeout()
944 lp->tx_ring[i].base, -lp->tx_ring[i].length, in lance_tx_timeout()
945 lp->tx_ring[i].misc); in lance_tx_timeout()
949 lance_restart (dev, 0x0043, 1); in lance_tx_timeout()
959 struct lance_private *lp = dev->ml_priv; in lance_start_xmit()
960 int ioaddr = dev->base_addr; in lance_start_xmit()
964 spin_lock_irqsave(&lp->devlock, flags); in lance_start_xmit()
967 outw(0x0000, ioaddr+LANCE_ADDR); in lance_start_xmit()
968 printk("%s: lance_start_xmit() called, csr0 %4.4x.\n", dev->name, in lance_start_xmit()
970 outw(0x0000, ioaddr+LANCE_DATA); in lance_start_xmit()
976 entry = lp->cur_tx & TX_RING_MOD_MASK; in lance_start_xmit()
982 if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) { in lance_start_xmit()
983 if (skb->len < ETH_ZLEN) { in lance_start_xmit()
986 lp->tx_ring[entry].length = -ETH_ZLEN; in lance_start_xmit()
989 lp->tx_ring[entry].length = -skb->len; in lance_start_xmit()
991 lp->tx_ring[entry].length = -skb->len; in lance_start_xmit()
993 lp->tx_ring[entry].misc = 0x0000; in lance_start_xmit()
995 dev->stats.tx_bytes += skb->len; in lance_start_xmit()
997 /* If any part of this buffer is >16M we must copy it to a low-memory in lance_start_xmit()
999 if ((u32)isa_virt_to_bus(skb->data) + skb->len > 0x01000000) { in lance_start_xmit()
1001 printk("%s: bouncing a high-memory packet (%#x).\n", in lance_start_xmit()
1002 dev->name, (u32)isa_virt_to_bus(skb->data)); in lance_start_xmit()
1003 skb_copy_from_linear_data(skb, &lp->tx_bounce_buffs[entry], skb->len); in lance_start_xmit()
1004 lp->tx_ring[entry].base = in lance_start_xmit()
1005 ((u32)isa_virt_to_bus((lp->tx_bounce_buffs + entry)) & 0xffffff) | 0x83000000; in lance_start_xmit()
1008 lp->tx_skbuff[entry] = skb; in lance_start_xmit()
1009 lp->tx_ring[entry].base = ((u32)isa_virt_to_bus(skb->data) & 0xffffff) | 0x83000000; in lance_start_xmit()
1011 lp->cur_tx++; in lance_start_xmit()
1014 outw(0x0000, ioaddr+LANCE_ADDR); in lance_start_xmit()
1015 outw(0x0048, ioaddr+LANCE_DATA); in lance_start_xmit()
1017 if ((lp->cur_tx - lp->dirty_tx) >= TX_RING_SIZE) in lance_start_xmit()
1021 spin_unlock_irqrestore(&lp->devlock, flags); in lance_start_xmit()
1033 ioaddr = dev->base_addr; in lance_interrupt()
1034 lp = dev->ml_priv; in lance_interrupt()
1036 spin_lock (&lp->devlock); in lance_interrupt()
1038 outw(0x00, dev->base_addr + LANCE_ADDR); in lance_interrupt()
1039 while ((csr0 = inw(dev->base_addr + LANCE_DATA)) & 0x8600 && in lance_interrupt()
1040 --boguscnt >= 0) { in lance_interrupt()
1042 outw(csr0 & ~0x004f, dev->base_addr + LANCE_DATA); in lance_interrupt()
1044 must_restart = 0; in lance_interrupt()
1048 dev->name, csr0, inw(dev->base_addr + LANCE_DATA)); in lance_interrupt()
1050 if (csr0 & 0x0400) /* Rx interrupt */ in lance_interrupt()
1053 if (csr0 & 0x0200) { /* Tx-done interrupt */ in lance_interrupt()
1054 int dirty_tx = lp->dirty_tx; in lance_interrupt()
1056 while (dirty_tx < lp->cur_tx) { in lance_interrupt()
1058 int status = lp->tx_ring[entry].base; in lance_interrupt()
1060 if (status < 0) in lance_interrupt()
1063 lp->tx_ring[entry].base = 0; in lance_interrupt()
1065 if (status & 0x40000000) { in lance_interrupt()
1067 int err_status = lp->tx_ring[entry].misc; in lance_interrupt()
1068 dev->stats.tx_errors++; in lance_interrupt()
1069 if (err_status & 0x0400) in lance_interrupt()
1070 dev->stats.tx_aborted_errors++; in lance_interrupt()
1071 if (err_status & 0x0800) in lance_interrupt()
1072 dev->stats.tx_carrier_errors++; in lance_interrupt()
1073 if (err_status & 0x1000) in lance_interrupt()
1074 dev->stats.tx_window_errors++; in lance_interrupt()
1075 if (err_status & 0x4000) { in lance_interrupt()
1077 dev->stats.tx_fifo_errors++; in lance_interrupt()
1080 dev->name, csr0); in lance_interrupt()
1085 if (status & 0x18000000) in lance_interrupt()
1086 dev->stats.collisions++; in lance_interrupt()
1087 dev->stats.tx_packets++; in lance_interrupt()
1090 /* We must free the original skb if it's not a data-only copy in lance_interrupt()
1092 if (lp->tx_skbuff[entry]) { in lance_interrupt()
1093 dev_consume_skb_irq(lp->tx_skbuff[entry]); in lance_interrupt()
1094 lp->tx_skbuff[entry] = NULL; in lance_interrupt()
1100 if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) { in lance_interrupt()
1101 printk("out-of-sync dirty pointer, %d vs. %d, full=%s.\n", in lance_interrupt()
1102 dirty_tx, lp->cur_tx, in lance_interrupt()
1110 dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) in lance_interrupt()
1113 lp->dirty_tx = dirty_tx; in lance_interrupt()
1117 if (csr0 & 0x4000) in lance_interrupt()
1118 dev->stats.tx_errors++; /* Tx babble. */ in lance_interrupt()
1119 if (csr0 & 0x1000) in lance_interrupt()
1120 dev->stats.rx_errors++; /* Missed a Rx frame. */ in lance_interrupt()
1121 if (csr0 & 0x0800) { in lance_interrupt()
1123 dev->name, csr0); in lance_interrupt()
1130 outw(0x0000, dev->base_addr + LANCE_ADDR); in lance_interrupt()
1131 outw(0x0004, dev->base_addr + LANCE_DATA); in lance_interrupt()
1132 lance_restart(dev, 0x0002, 0); in lance_interrupt()
1137 outw(0x0000, dev->base_addr + LANCE_ADDR); in lance_interrupt()
1138 outw(0x7940, dev->base_addr + LANCE_DATA); in lance_interrupt()
1142 dev->name, inw(ioaddr + LANCE_ADDR), in lance_interrupt()
1143 inw(dev->base_addr + LANCE_DATA)); in lance_interrupt()
1145 spin_unlock (&lp->devlock); in lance_interrupt()
1152 struct lance_private *lp = dev->ml_priv; in lance_rx()
1153 int entry = lp->cur_rx & RX_RING_MOD_MASK; in lance_rx()
1157 while (lp->rx_ring[entry].base >= 0) { in lance_rx()
1158 int status = lp->rx_ring[entry].base >> 24; in lance_rx()
1160 if (status != 0x03) { /* There was an error. */ in lance_rx()
1162 <[email protected]> to Russ Nelson: Even with full-sized in lance_rx()
1165 if (status & 0x01) /* Only count a general error at the */ in lance_rx()
1166 dev->stats.rx_errors++; /* end of a packet.*/ in lance_rx()
1167 if (status & 0x20) in lance_rx()
1168 dev->stats.rx_frame_errors++; in lance_rx()
1169 if (status & 0x10) in lance_rx()
1170 dev->stats.rx_over_errors++; in lance_rx()
1171 if (status & 0x08) in lance_rx()
1172 dev->stats.rx_crc_errors++; in lance_rx()
1173 if (status & 0x04) in lance_rx()
1174 dev->stats.rx_fifo_errors++; in lance_rx()
1175 lp->rx_ring[entry].base &= 0x03ffffff; in lance_rx()
1180 short pkt_len = (lp->rx_ring[entry].msg_length & 0xfff)-4; in lance_rx()
1185 printk("%s: Runt packet!\n",dev->name); in lance_rx()
1186 dev->stats.rx_errors++; in lance_rx()
1193 printk("%s: Memory squeeze, deferring packet.\n", dev->name); in lance_rx()
1194 for (i=0; i < RX_RING_SIZE; i++) in lance_rx()
1195 if (lp->rx_ring[(entry+i) & RX_RING_MOD_MASK].base < 0) in lance_rx()
1198 if (i > RX_RING_SIZE -2) in lance_rx()
1200 dev->stats.rx_dropped++; in lance_rx()
1201 lp->rx_ring[entry].base |= 0x80000000; in lance_rx()
1202 lp->cur_rx++; in lance_rx()
1209 (unsigned char *)isa_bus_to_virt((lp->rx_ring[entry].base & 0x00ffffff)), in lance_rx()
1211 skb->protocol=eth_type_trans(skb,dev); in lance_rx()
1213 dev->stats.rx_packets++; in lance_rx()
1214 dev->stats.rx_bytes += pkt_len; in lance_rx()
1219 lp->rx_ring[entry].buf_length = -PKT_BUF_SZ; in lance_rx()
1220 lp->rx_ring[entry].base |= 0x80000000; in lance_rx()
1221 entry = (++lp->cur_rx) & RX_RING_MOD_MASK; in lance_rx()
1225 we should free one and mark stats->rx_dropped++. */ in lance_rx()
1227 return 0; in lance_rx()
1233 int ioaddr = dev->base_addr; in lance_close()
1234 struct lance_private *lp = dev->ml_priv; in lance_close()
1238 if (chip_table[lp->chip_version].flags & LANCE_HAS_MISSED_FRAME) { in lance_close()
1240 dev->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA); in lance_close()
1242 outw(0, ioaddr+LANCE_ADDR); in lance_close()
1246 dev->name, inw(ioaddr+LANCE_DATA)); in lance_close()
1248 /* We stop the LANCE here -- it occasionally polls in lance_close()
1250 outw(0x0004, ioaddr+LANCE_DATA); in lance_close()
1252 if (dev->dma != 4) in lance_close()
1255 disable_dma(dev->dma); in lance_close()
1258 free_irq(dev->irq, dev); in lance_close()
1262 return 0; in lance_close()
1267 struct lance_private *lp = dev->ml_priv; in lance_get_stats()
1269 if (chip_table[lp->chip_version].flags & LANCE_HAS_MISSED_FRAME) { in lance_get_stats()
1270 short ioaddr = dev->base_addr; in lance_get_stats()
1274 spin_lock_irqsave(&lp->devlock, flags); in lance_get_stats()
1277 dev->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA); in lance_get_stats()
1279 spin_unlock_irqrestore(&lp->devlock, flags); in lance_get_stats()
1282 return &dev->stats; in lance_get_stats()
1290 short ioaddr = dev->base_addr; in set_multicast_list()
1292 outw(0, ioaddr+LANCE_ADDR); in set_multicast_list()
1293 outw(0x0004, ioaddr+LANCE_DATA); /* Temporarily stop the lance. */ in set_multicast_list()
1295 if (dev->flags&IFF_PROMISC) { in set_multicast_list()
1297 outw(0x8000, ioaddr+LANCE_DATA); /* Set promiscuous mode */ in set_multicast_list()
1302 if(dev->flags&IFF_ALLMULTI) in set_multicast_list()
1304 /* FIXIT: We don't use the multicast table, but rely on upper-layer filtering. */ in set_multicast_list()
1305 memset(multicast_table, (num_addrs == 0) ? 0 : -1, sizeof(multicast_table)); in set_multicast_list()
1306 for (i = 0; i < 4; i++) { in set_multicast_list()
1311 outw(0x0000, ioaddr+LANCE_DATA); /* Unset promiscuous mode */ in set_multicast_list()
1314 lance_restart(dev, 0x0142, 0); /* Resume normal operation */ in set_multicast_list()