Lines Matching +full:tx1 +full:- +full:3
1 // SPDX-License-Identifier: GPL-1.0+
5 Written 1992-94 by Donald Becker.
16 This is the chip-specific code for many 8390-based ethernet adaptors.
17 This is not a complete driver, it must be combined with board-specific
18 code such as ne.c, wd.c, 3c503.c, etc.
23 you have found something that needs changing. -- PG
39 Paul Gortmaker : add kmod support for auto-loading of the 8390
48 The National Semiconductor LAN Databook, and the 3Com 3c503 databook.
79 /* These are the operational function interfaces to board-specific
88 "page" value uses the 8390's 256-byte pages.
97 #define ei_reset_8390 (ei_local->reset_8390)
98 #define ei_block_output (ei_local->block_output)
99 #define ei_block_input (ei_local->block_input)
100 #define ei_get_8390_hdr (ei_local->get_8390_hdr)
108 /* Routines generic to NS8390-based boards. */
126 * this with ei_local->page_lock. Nobody should assume or set the page other
156 * - IRQ delivery is asynchronous to the PCI bus
157 * - Blocking the local CPU IRQ via spin locks was too slow
158 * - The chip has register windows needing locking work
167 * Disable the IRQ (but not mask locally- someone seems to have
182 * re-enable the IRQ
196 * ei_open - Open/initialize the board.
199 * This routine goes all-out, setting everything
208 if (dev->watchdog_timeo <= 0) in __ei_open()
209 dev->watchdog_timeo = TX_TIMEOUT; in __ei_open()
216 spin_lock_irqsave(&ei_local->page_lock, flags); in __ei_open()
221 spin_unlock_irqrestore(&ei_local->page_lock, flags); in __ei_open()
222 ei_local->irqlock = 0; in __ei_open()
227 * ei_close - shut down network device
241 spin_lock_irqsave(&ei_local->page_lock, flags); in __ei_close()
243 spin_unlock_irqrestore(&ei_local->page_lock, flags); in __ei_close()
249 * ei_tx_timeout - handle transmit time out condition
253 * completed (or failed) - i.e. never posted a Tx related interrupt.
258 unsigned long e8390_base = dev->base_addr; in __ei_tx_timeout()
260 int txsr, isr, tickssofar = jiffies - dev_trans_start(dev); in __ei_tx_timeout()
263 dev->stats.tx_errors++; in __ei_tx_timeout()
265 spin_lock_irqsave(&ei_local->page_lock, flags); in __ei_tx_timeout()
268 spin_unlock_irqrestore(&ei_local->page_lock, flags); in __ei_tx_timeout()
275 if (!isr && !dev->stats.tx_packets) { in __ei_tx_timeout()
277 ei_local->interface_num ^= 1; /* Try a different xcvr. */ in __ei_tx_timeout()
282 disable_irq_nosync_lockdep(dev->irq); in __ei_tx_timeout()
283 spin_lock(&ei_local->page_lock); in __ei_tx_timeout()
289 spin_unlock(&ei_local->page_lock); in __ei_tx_timeout()
290 enable_irq_lockdep(dev->irq); in __ei_tx_timeout()
295 * ei_start_xmit - begin packet transmission
305 unsigned long e8390_base = dev->base_addr; in __ei_start_xmit()
307 int send_length = skb->len, output_page; in __ei_start_xmit()
310 char *data = skb->data; in __ei_start_xmit()
312 if (skb->len < ETH_ZLEN) { in __ei_start_xmit()
314 memcpy(buf, data, skb->len); in __ei_start_xmit()
324 spin_lock_irqsave(&ei_local->page_lock, flags); in __ei_start_xmit()
326 spin_unlock_irqrestore(&ei_local->page_lock, flags); in __ei_start_xmit()
333 disable_irq_nosync_lockdep_irqsave(dev->irq, &flags); in __ei_start_xmit()
335 spin_lock(&ei_local->page_lock); in __ei_start_xmit()
337 ei_local->irqlock = 1; in __ei_start_xmit()
342 * you get very close to transmitting back-to-back packets. With in __ei_start_xmit()
347 if (ei_local->tx1 == 0) { in __ei_start_xmit()
348 output_page = ei_local->tx_start_page; in __ei_start_xmit()
349 ei_local->tx1 = send_length; in __ei_start_xmit()
351 ei_local->tx2 > 0) in __ei_start_xmit()
354 ei_local->tx2, ei_local->lasttx, ei_local->txing); in __ei_start_xmit()
355 } else if (ei_local->tx2 == 0) { in __ei_start_xmit()
356 output_page = ei_local->tx_start_page + TX_PAGES/2; in __ei_start_xmit()
357 ei_local->tx2 = send_length; in __ei_start_xmit()
359 ei_local->tx1 > 0) in __ei_start_xmit()
361 "idle transmitter, tx1=%d, lasttx=%d, txing=%d\n", in __ei_start_xmit()
362 ei_local->tx1, ei_local->lasttx, ei_local->txing); in __ei_start_xmit()
365 "No Tx buffers free! tx1=%d tx2=%d last=%d\n", in __ei_start_xmit()
366 ei_local->tx1, ei_local->tx2, ei_local->lasttx); in __ei_start_xmit()
367 ei_local->irqlock = 0; in __ei_start_xmit()
370 spin_unlock(&ei_local->page_lock); in __ei_start_xmit()
371 enable_irq_lockdep_irqrestore(dev->irq, &flags); in __ei_start_xmit()
372 dev->stats.tx_errors++; in __ei_start_xmit()
384 if (!ei_local->txing) { in __ei_start_xmit()
385 ei_local->txing = 1; in __ei_start_xmit()
387 if (output_page == ei_local->tx_start_page) { in __ei_start_xmit()
388 ei_local->tx1 = -1; in __ei_start_xmit()
389 ei_local->lasttx = -1; in __ei_start_xmit()
391 ei_local->tx2 = -1; in __ei_start_xmit()
392 ei_local->lasttx = -2; in __ei_start_xmit()
395 ei_local->txqueue++; in __ei_start_xmit()
397 if (ei_local->tx1 && ei_local->tx2) in __ei_start_xmit()
403 ei_local->irqlock = 0; in __ei_start_xmit()
406 spin_unlock(&ei_local->page_lock); in __ei_start_xmit()
407 enable_irq_lockdep_irqrestore(dev->irq, &flags); in __ei_start_xmit()
410 dev->stats.tx_bytes += send_length; in __ei_start_xmit()
416 * ei_interrupt - handle the interrupts from an 8390
430 unsigned long e8390_base = dev->base_addr; in __ei_interrupt()
438 spin_lock(&ei_local->page_lock); in __ei_interrupt()
440 if (ei_local->irqlock) { in __ei_interrupt()
448 spin_unlock(&ei_local->page_lock); in __ei_interrupt()
457 /* !!Assumption!! -- we stay in page 0. Don't break this. */ in __ei_interrupt()
462 /* rmk - acknowledge the interrupts */ in __ei_interrupt()
473 /* Push the next to-transmit packet through. */ in __ei_interrupt()
480 dev->stats.rx_frame_errors += ei_inb_p(e8390_base + EN0_COUNTER0); in __ei_interrupt()
481 dev->stats.rx_crc_errors += ei_inb_p(e8390_base + EN0_COUNTER1); in __ei_interrupt()
482 dev->stats.rx_missed_errors += ei_inb_p(e8390_base + EN0_COUNTER2); in __ei_interrupt()
506 spin_unlock(&ei_local->page_lock); in __ei_interrupt()
513 disable_irq(dev->irq); in __ei_poll()
514 __ei_interrupt(dev->irq, dev); in __ei_poll()
515 enable_irq(dev->irq); in __ei_poll()
520 * ei_tx_err - handle transmitter error
535 unsigned long e8390_base = dev->base_addr; in ei_tx_err()
544 pr_cont(" excess-collisions "); in ei_tx_err()
546 pr_cont(" non-deferral "); in ei_tx_err()
548 pr_cont(" lost-carrier "); in ei_tx_err()
550 pr_cont(" FIFO-underrun "); in ei_tx_err()
552 pr_cont(" lost-heartbeat "); in ei_tx_err()
561 dev->stats.tx_errors++; in ei_tx_err()
563 dev->stats.tx_carrier_errors++; in ei_tx_err()
565 dev->stats.tx_heartbeat_errors++; in ei_tx_err()
567 dev->stats.tx_window_errors++; in ei_tx_err()
572 * ei_tx_intr - transmit interrupt handler
581 unsigned long e8390_base = dev->base_addr; in ei_tx_intr()
591 ei_local->txqueue--; in ei_tx_intr()
593 if (ei_local->tx1 < 0) { in ei_tx_intr()
594 if (ei_local->lasttx != 1 && ei_local->lasttx != -1) in ei_tx_intr()
595 pr_err("%s: bogus last_tx_buffer %d, tx1=%d\n", in ei_tx_intr()
596 ei_local->name, ei_local->lasttx, ei_local->tx1); in ei_tx_intr()
597 ei_local->tx1 = 0; in ei_tx_intr()
598 if (ei_local->tx2 > 0) { in ei_tx_intr()
599 ei_local->txing = 1; in ei_tx_intr()
600 NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6); in ei_tx_intr()
602 ei_local->tx2 = -1; in ei_tx_intr()
603 ei_local->lasttx = 2; in ei_tx_intr()
605 ei_local->lasttx = 20; in ei_tx_intr()
606 ei_local->txing = 0; in ei_tx_intr()
608 } else if (ei_local->tx2 < 0) { in ei_tx_intr()
609 if (ei_local->lasttx != 2 && ei_local->lasttx != -2) in ei_tx_intr()
611 ei_local->name, ei_local->lasttx, ei_local->tx2); in ei_tx_intr()
612 ei_local->tx2 = 0; in ei_tx_intr()
613 if (ei_local->tx1 > 0) { in ei_tx_intr()
614 ei_local->txing = 1; in ei_tx_intr()
615 NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page); in ei_tx_intr()
617 ei_local->tx1 = -1; in ei_tx_intr()
618 ei_local->lasttx = 1; in ei_tx_intr()
620 ei_local->lasttx = 10; in ei_tx_intr()
621 ei_local->txing = 0; in ei_tx_intr()
624 netdev_warn(dev, "unexpected TX-done interrupt, lasttx=%d\n", in ei_tx_intr()
625 ei_local->lasttx); in ei_tx_intr()
630 dev->stats.collisions++; in ei_tx_intr()
632 dev->stats.tx_packets++; in ei_tx_intr()
634 dev->stats.tx_errors++; in ei_tx_intr()
636 dev->stats.tx_aborted_errors++; in ei_tx_intr()
637 dev->stats.collisions += 16; in ei_tx_intr()
640 dev->stats.tx_carrier_errors++; in ei_tx_intr()
642 dev->stats.tx_fifo_errors++; in ei_tx_intr()
644 dev->stats.tx_heartbeat_errors++; in ei_tx_intr()
646 dev->stats.tx_window_errors++; in ei_tx_intr()
652 * ei_receive - receive some packets
661 unsigned long e8390_base = dev->base_addr; in ei_receive()
667 int num_rx_pages = ei_local->stop_page-ei_local->rx_start_page; in ei_receive()
679 if (this_frame >= ei_local->stop_page) in ei_receive()
680 this_frame = ei_local->rx_start_page; in ei_receive()
689 this_frame != ei_local->current_page && in ei_receive()
693 this_frame, ei_local->current_page); in ei_receive()
701 pkt_len = rx_frame.count - sizeof(struct e8390_pkt_hdr); in ei_receive()
706 /* Check for bogosity warned by 3c503 book: the status byte is never in ei_receive()
711 rx_frame.next != next_frame - num_rx_pages && in ei_receive()
712 rx_frame.next != next_frame + 1 - num_rx_pages) { in ei_receive()
713 ei_local->current_page = rxing_page; in ei_receive()
714 ei_outb(ei_local->current_page-1, e8390_base+EN0_BOUNDARY); in ei_receive()
715 dev->stats.rx_errors++; in ei_receive()
724 dev->stats.rx_errors++; in ei_receive()
725 dev->stats.rx_length_errors++; in ei_receive()
734 dev->stats.rx_dropped++; in ei_receive()
740 skb->protocol = eth_type_trans(skb, dev); in ei_receive()
743 dev->stats.rx_packets++; in ei_receive()
744 dev->stats.rx_bytes += pkt_len; in ei_receive()
746 dev->stats.multicast++; in ei_receive()
753 dev->stats.rx_errors++; in ei_receive()
756 dev->stats.rx_fifo_errors++; in ei_receive()
761 if (next_frame >= ei_local->stop_page) { in ei_receive()
764 next_frame = ei_local->rx_start_page; in ei_receive()
766 ei_local->current_page = next_frame; in ei_receive()
767 ei_outb_p(next_frame-1, e8390_base+EN0_BOUNDARY); in ei_receive()
776 * ei_rx_overrun - handle receiver overrun
785 * computer will hate you - it takes 10ms or so.
790 unsigned long e8390_base = dev->base_addr; in ei_rx_overrun()
803 dev->stats.rx_over_errors++; in ei_rx_overrun()
858 unsigned long ioaddr = dev->base_addr; in __ei_get_stats()
864 return &dev->stats; in __ei_get_stats()
866 spin_lock_irqsave(&ei_local->page_lock, flags); in __ei_get_stats()
868 dev->stats.rx_frame_errors += ei_inb_p(ioaddr + EN0_COUNTER0); in __ei_get_stats()
869 dev->stats.rx_crc_errors += ei_inb_p(ioaddr + EN0_COUNTER1); in __ei_get_stats()
870 dev->stats.rx_missed_errors += ei_inb_p(ioaddr + EN0_COUNTER2); in __ei_get_stats()
871 spin_unlock_irqrestore(&ei_local->page_lock, flags); in __ei_get_stats()
873 return &dev->stats; in __ei_get_stats()
886 u32 crc = ether_crc(ETH_ALEN, ha->addr); in make_mc_bits()
896 * do_set_multicast_list - set/clear multicast filter
905 unsigned long e8390_base = dev->base_addr; in do_set_multicast_list()
909 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) { in do_set_multicast_list()
910 memset(ei_local->mcfilter, 0, 8); in do_set_multicast_list()
912 make_mc_bits(ei_local->mcfilter, dev); in do_set_multicast_list()
914 memset(ei_local->mcfilter, 0xFF, 8); /* mcast set to accept-all */ in do_set_multicast_list()
924 * Elite16) appear to be write-only. The NS 8390 data sheet lists in do_set_multicast_list()
933 ei_outb_p(ei_local->mcfilter[i], e8390_base + EN1_MULT_SHIFT(i)); in do_set_multicast_list()
935 if (ei_inb_p(e8390_base + EN1_MULT_SHIFT(i)) != ei_local->mcfilter[i]) in do_set_multicast_list()
942 if (dev->flags&IFF_PROMISC) in do_set_multicast_list()
944 else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) in do_set_multicast_list()
961 spin_lock_irqsave(&ei_local->page_lock, flags); in __ei_set_multicast_list()
963 spin_unlock_irqrestore(&ei_local->page_lock, flags); in __ei_set_multicast_list()
967 * ethdev_setup - init rest of 8390 device struct
980 spin_lock_init(&ei_local->page_lock); in ethdev_setup()
982 ei_local->msg_enable = netif_msg_init(msg_enable, default_msg_level); in ethdev_setup()
989 * alloc_ei_netdev - alloc_etherdev counterpart for 8390
992 * Allocate 8390-specific net_device.
1007 * NS8390_init - initialize 8390 hardware
1009 * @startp: boolean. non-zero value to initiate chip processing
1016 unsigned long e8390_base = dev->base_addr; in __NS8390_init()
1019 int endcfg = ei_local->word16 in __NS8390_init()
1020 ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0)) in __NS8390_init()
1030 /* Set to monitor and loopback mode -- this is vital!. */ in __NS8390_init()
1034 ei_outb_p(ei_local->tx_start_page, e8390_base + EN0_TPSR); in __NS8390_init()
1035 ei_local->tx1 = ei_local->tx2 = 0; in __NS8390_init()
1036 ei_outb_p(ei_local->rx_start_page, e8390_base + EN0_STARTPG); in __NS8390_init()
1037 ei_outb_p(ei_local->stop_page-1, e8390_base + EN0_BOUNDARY); /* 3c503 says 0x3f,NS0x26*/ in __NS8390_init()
1038 ei_local->current_page = ei_local->rx_start_page; /* assert boundary+1 */ in __NS8390_init()
1039 ei_outb_p(ei_local->stop_page, e8390_base + EN0_STOPPG); in __NS8390_init()
1048 ei_outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i)); in __NS8390_init()
1050 ei_inb_p(e8390_base + EN1_PHYS_SHIFT(i)) != dev->dev_addr[i]) in __NS8390_init()
1055 ei_outb_p(ei_local->rx_start_page, e8390_base + EN1_CURPAG); in __NS8390_init()
1058 ei_local->tx1 = ei_local->tx2 = 0; in __NS8390_init()
1059 ei_local->txing = 0; in __NS8390_init()
1066 /* 3c503 TechMan says rxconfig only after the NIC is started. */ in __NS8390_init()
1078 unsigned long e8390_base = dev->base_addr; in NS8390_trigger_send()