53 #include <linux/module.h>
54 #include <linux/kernel.h>
57 #include <linux/types.h>
58 #include <linux/string.h>
59 #include <linux/bitops.h>
64 #include <linux/errno.h>
65 #include <linux/fcntl.h>
71 #include <linux/netdevice.h>
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)
204 struct ei_device *ei_local = netdev_priv(dev);
218 netif_start_queue(dev);
219 spin_unlock_irqrestore(&ei_local->
page_lock, flags);
232 struct ei_device *ei_local = netdev_priv(dev);
241 spin_unlock_irqrestore(&ei_local->
page_lock, flags);
242 netif_stop_queue(dev);
256 unsigned long e8390_base = dev->
base_addr;
257 struct ei_device *ei_local = netdev_priv(dev);
261 dev->
stats.tx_errors++;
266 spin_unlock_irqrestore(&ei_local->
page_lock, flags);
268 netdev_dbg(dev,
"Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d\n",
269 (txsr &
ENTSR_ABT) ?
"excess collisions." :
270 (isr) ?
"lost interrupt?" :
"cable problem?",
271 txsr, isr, tickssofar);
273 if (!isr && !dev->
stats.tx_packets) {
289 netif_wake_queue(dev);
303 unsigned long e8390_base = dev->
base_addr;
304 struct ei_device *ei_local = netdev_priv(dev);
305 int send_length = skb->
len, output_page;
324 spin_unlock_irqrestore(&ei_local->
page_lock, flags);
345 if (ei_local->
tx1 == 0) {
347 ei_local->
tx1 = send_length;
349 netdev_dbg(dev,
"idle transmitter tx2=%d, lasttx=%d, txing=%d\n",
351 }
else if (ei_local->
tx2 == 0) {
353 ei_local->
tx2 = send_length;
355 netdev_dbg(dev,
"idle transmitter, tx1=%d, lasttx=%d, txing=%d\n",
359 netdev_dbg(dev,
"No Tx buffers free! tx1=%d tx2=%d last=%d\n",
362 netif_stop_queue(dev);
366 dev->
stats.tx_errors++;
378 if (!ei_local->
txing) {
380 NS8390_trigger_send(dev, send_length, output_page);
391 if (ei_local->
tx1 && ei_local->
tx2)
392 netif_stop_queue(dev);
394 netif_start_queue(dev);
402 skb_tx_timestamp(skb);
404 dev->
stats.tx_bytes += send_length;
424 unsigned long e8390_base = dev->
base_addr;
425 int interrupts, nr_serviced = 0;
426 struct ei_device *ei_local = netdev_priv(dev);
439 netdev_err(dev,
"Interrupted while interrupts are masked! isr=%#2x imr=%#2x\n",
455 if (!netif_running(dev)) {
456 netdev_warn(dev,
"interrupt from stopped card\n");
492 if (interrupts != 0xFF)
493 netdev_warn(dev,
"Too much work at interrupt, status %#2.2x\n",
497 netdev_warn(dev,
"unknown interrupt %#2x\n", interrupts);
505 #ifdef CONFIG_NET_POLL_CONTROLLER
530 unsigned long e8390_base = dev->
base_addr;
534 unsigned char tx_was_aborted = txsr & (ENTSR_ABT+
ENTSR_FU);
536 #ifdef VERBOSE_ERROR_DUMP
537 netdev_dbg(dev,
"transmitter error (%#2x):", txsr);
538 if (txsr & ENTSR_ABT)
539 pr_cont(
" excess-collisions ");
556 dev->
stats.tx_errors++;
557 if (txsr & ENTSR_CRS)
558 dev->
stats.tx_carrier_errors++;
559 if (txsr & ENTSR_CDH)
560 dev->
stats.tx_heartbeat_errors++;
562 dev->
stats.tx_window_errors++;
574 static void ei_tx_intr(
struct net_device *dev)
576 unsigned long e8390_base = dev->
base_addr;
577 struct ei_device *ei_local = netdev_priv(dev);
588 if (ei_local->
tx1 < 0) {
590 pr_err(
"%s: bogus last_tx_buffer %d, tx1=%d\n",
593 if (ei_local->
tx2 > 0) {
601 }
else if (ei_local->
tx2 < 0) {
603 pr_err(
"%s: bogus last_tx_buffer %d, tx2=%d\n",
606 if (ei_local->
tx1 > 0) {
621 dev->
stats.collisions++;
623 dev->
stats.tx_packets++;
625 dev->
stats.tx_errors++;
626 if (status & ENTSR_ABT) {
627 dev->
stats.tx_aborted_errors++;
628 dev->
stats.collisions += 16;
630 if (status & ENTSR_CRS)
631 dev->
stats.tx_carrier_errors++;
632 if (status & ENTSR_FU)
633 dev->
stats.tx_fifo_errors++;
634 if (status & ENTSR_CDH)
635 dev->
stats.tx_heartbeat_errors++;
637 dev->
stats.tx_window_errors++;
639 netif_wake_queue(dev);
650 static void ei_receive(
struct net_device *dev)
652 unsigned long e8390_base = dev->
base_addr;
653 struct ei_device *ei_local = netdev_priv(dev);
654 unsigned char rxing_page, this_frame,
next_frame;
655 unsigned short current_offset;
656 int rx_pkt_count = 0;
660 while (++rx_pkt_count < 10) {
681 (this_frame != 0x0 || rxing_page != 0xFF))
682 netdev_err(dev,
"mismatched read page pointers %2x vs %2x\n",
685 if (this_frame == rxing_page)
688 current_offset = this_frame << 8;
692 pkt_stat = rx_frame.status;
694 next_frame = this_frame + 1 + ((pkt_len+4)>>8);
699 if (rx_frame.next != next_frame &&
700 rx_frame.next != next_frame + 1 &&
701 rx_frame.next != next_frame - num_rx_pages &&
702 rx_frame.next != next_frame + 1 - num_rx_pages) {
705 dev->
stats.rx_errors++;
709 if (pkt_len < 60 || pkt_len > 1518) {
711 netdev_dbg(dev,
"bogus packet size: %d, status=%#2x nxpg=%#2x\n",
712 rx_frame.count, rx_frame.status,
714 dev->
stats.rx_errors++;
715 dev->
stats.rx_length_errors++;
719 skb = netdev_alloc_skb(dev, pkt_len + 2);
722 netdev_dbg(dev,
"Couldn't allocate a sk_buff of size %d\n",
724 dev->
stats.rx_dropped++;
729 ei_block_input(dev, pkt_len, skb, current_offset +
sizeof(rx_frame));
733 dev->
stats.rx_packets++;
736 dev->
stats.multicast++;
740 netdev_dbg(dev,
"bogus packet: status=%#2x nxpg=%#2x size=%d\n",
741 rx_frame.status, rx_frame.next,
743 dev->
stats.rx_errors++;
746 dev->
stats.rx_fifo_errors++;
748 next_frame = rx_frame.next;
752 netdev_notice(dev,
"next frame inconsistency, %#2x\n",
778 static void ei_rx_overrun(
struct net_device *dev)
780 unsigned long e8390_base = dev->
base_addr;
781 unsigned char was_txing, must_resend = 0;
783 struct ei_device *ei_local __maybe_unused = netdev_priv(dev);
794 dev->
stats.rx_over_errors++;
850 struct ei_device *ei_local = netdev_priv(dev);
854 if (!netif_running(dev))
862 spin_unlock_irqrestore(&ei_local->
page_lock, flags);
882 bits[crc>>29] |= (1<<((crc>>26)&7));
894 static void do_set_multicast_list(
struct net_device *dev)
896 unsigned long e8390_base = dev->
base_addr;
898 struct ei_device *ei_local = netdev_priv(dev);
903 make_mc_bits(ei_local->
mcfilter, dev);
920 if (netif_running(dev))
923 for (i = 0; i < 8; i++) {
927 netdev_err(dev,
"Multicast filter read/write mismap %d\n",
950 struct ei_device *ei_local = netdev_priv(dev);
953 do_set_multicast_list(dev);
954 spin_unlock_irqrestore(&ei_local->
page_lock, flags);
965 static void ethdev_setup(
struct net_device *dev)
967 struct ei_device *ei_local = netdev_priv(dev);
1004 unsigned long e8390_base = dev->
base_addr;
1005 struct ei_device *ei_local = netdev_priv(dev);
1007 int endcfg = ei_local->
word16
1012 panic(
"8390.c: header struct mispacked\n");
1024 ei_local->
tx1 = ei_local->
tx2 = 0;
1036 for (i = 0; i < 6; i++) {
1040 netdev_err(dev,
"Hw. address read/write mismap %d\n", i);
1046 ei_local->
tx1 = ei_local->
tx2 = 0;
1047 ei_local->
txing = 0;
1056 do_set_multicast_list(dev);
1063 static void NS8390_trigger_send(
struct net_device *dev,
unsigned int length,
1066 unsigned long e8390_base = dev->
base_addr;
1072 netdev_warn(dev,
"trigger_send() called with the transmitter busy\n");