27 static int automatic_resume = 0;
28 static int rfdadd = 0;
31 #include <linux/kernel.h>
32 #include <linux/string.h>
33 #include <linux/errno.h>
38 #include <linux/bitops.h>
40 #include <asm/idprom.h>
41 #include <asm/machines.h>
44 #include <asm/byteorder.h>
46 #include <linux/netdevice.h>
52 #define DRV_NAME "sun3_82586"
56 #define SUN3_82586_TOTAL_SIZE PAGE_SIZE
58 #define sun3_attn586() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_ATTEN; *(volatile unsigned char *)(dev->base_addr) &= ~IEOB_ATTEN;}
59 #define sun3_reset586() {*(volatile unsigned char *)(dev->base_addr) = 0; udelay(100); *(volatile unsigned char *)(dev->base_addr) = IEOB_NORSET;}
60 #define sun3_disint() {*(volatile unsigned char *)(dev->base_addr) &= ~IEOB_IENAB;}
61 #define sun3_enaint() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_IENAB;}
62 #define sun3_active() {*(volatile unsigned char *)(dev->base_addr) |= (IEOB_IENAB|IEOB_ONAIR|IEOB_NORSET);}
64 #define make32(ptr16) (p->memtop + (swab16((unsigned short) (ptr16))) )
65 #define make24(ptr32) (char *)swab32(( ((unsigned long) (ptr32)) - p->base))
66 #define make16(ptr32) (swab16((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop )))
82 #define RECV_BUFF_SIZE 1536
83 #define XMIT_BUFF_SIZE 1536
84 #define NUM_XMIT_BUFFS 1
85 #define NUM_RECV_BUFFS_8 4
86 #define NUM_RECV_BUFFS_16 9
87 #define NUM_RECV_BUFFS_32 16
88 #define NO_NOPCOMMANDS
93 #define DELAY(x) mdelay(32 * x);
94 #define DELAY_16(); { udelay(16); }
95 #define DELAY_18(); { udelay(4); }
98 #define WAIT_4_SCB_CMD() \
100 for(i=0;i<16384;i++) { \
101 if(!p->scb->cmd_cuc) break; \
104 printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
105 if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
107 #define WAIT_4_SCB_CMD_RUC() { int i; \
108 for(i=0;i<16384;i++) { \
109 if(!p->scb->cmd_ruc) break; \
112 printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
113 if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
115 #define WAIT_4_STAT_COMPL(addr) { int i; \
116 for(i=0;i<32767;i++) { \
117 if(swab16((addr)->cmd_status) & STAT_COMPL) break; \
118 DELAY_16(); DELAY_16(); } }
120 static int sun3_82586_probe1(
struct net_device *
dev,
int ioaddr);
129 static void sun3_82586_dump(
struct net_device *,
void *);
154 #if (NUM_XMIT_BUFFS == 1)
173 netif_stop_queue(dev);
198 netif_start_queue(dev);
206 static int check586(
struct net_device *dev,
char *where,
unsigned size)
209 struct priv *
p = &pb;
218 if(((
char *)p->
scp)[i])
224 iscp_addr = (
char *)
dvma_btov((
unsigned long)where);
247 struct priv *p = netdev_priv(dev);
271 printk(
"%s: Init-Problems (alloc).\n",dev->
name);
281 unsigned long ioaddr;
282 static int found = 0;
304 dev = alloc_etherdev(
sizeof(
struct priv));
314 err = sun3_82586_probe1(dev, ioaddr);
332 .ndo_open = sun3_82586_open,
333 .ndo_stop = sun3_82586_close,
334 .ndo_start_xmit = sun3_82586_send_packet,
335 .ndo_set_rx_mode = set_multicast_list,
336 .ndo_tx_timeout = sun3_82586_timeout,
337 .ndo_get_stats = sun3_82586_get_stats,
351 for(i = 0; i < 6 ; i++)
364 if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
365 printk(
"\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 bytes.\n",dev->
name,size);
369 if(!check586(dev,(
char *) dev->
mem_start,size)) {
370 printk(
"?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->
mem_start,size);
384 else if(size == 0x4000)
408 struct priv *p = netdev_priv(dev);
433 int len = ((
char *) p->
iscp - (
char *) ptr - 8) / 6;
434 if(num_addrs > len) {
435 printk(
"%s: switching to promisc. mode\n",dev->
name);
500 printk(
"%s: Problems while running the TDR.\n",dev->
name);
513 printk(
"%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->
name);
519 printk(
"%s: TDR: Detected a short circuit %d clocks away.\n",dev->
name,result & TDR_TIMEMASK);
522 printk(
"%s: TDR: Unknown status %04x\n",dev->
name,result);
554 #if (NUM_XMIT_BUFFS == 1)
574 ptr = alloc_rfa(dev,ptr);
586 ptr = (
char *) ptr +
sizeof(
struct tbd_struct);
589 printk(
"%s: not enough shared-mem for your configuration!\n",dev->
name);
604 #ifndef NO_NOPCOMMANDS
611 #ifndef NO_NOPCOMMANDS
639 static void *alloc_rfa(
struct net_device *dev,
void *ptr)
644 struct priv *p = netdev_priv(dev);
693 printk (
"sun3_82586-interrupt: irq %d for unknown device.\n",irq);
696 p = netdev_priv(dev);
709 sun3_82586_rcv_int(dev);
723 printk(
"%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->
name,(
int) stat,(
int) p->
scb->rus);
724 sun3_82586_rnr_int(dev);
729 sun3_82586_xmt_int(dev);
731 #ifndef NO_NOPCOMMANDS
734 if(netif_running(dev))
735 printk(
"%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->
name,(
int) stat,(
int) p->
scb->cus);
745 printk(
"%s: Acknowledge timed out.\n",dev->
name);
760 static void sun3_82586_rcv_int(
struct net_device *dev)
766 struct priv *p = netdev_priv(dev);
781 skb = netdev_alloc_skb(dev, totlen + 2);
786 skb_copy_to_linear_data(skb,(
char *) p->
base+
swab32((
unsigned long) rbd->
buffer),totlen);
789 dev->
stats.rx_packets++;
792 dev->
stats.rx_dropped++;
804 printk(
"%s: Whoops .. no end mark in RBD list\n",dev->
name);
812 printk(
"%s: received oversized frame! length: %d\n",dev->
name,totlen);
813 dev->
stats.rx_dropped++;
818 printk(
"%s: oops! rfd-error-status: %04x\n",dev->
name,status);
819 dev->
stats.rx_errors++;
823 p->
rfd_top->rbd_offset = 0xffff;
850 printk(
"%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->
name);
861 printk(
"%s: received a FC intr. without having a frame: %04x %d\n",dev->
name,status,old_at_least);
868 printk(
"\nerrs: %04x %04x stat: %04x\n",(
int)p->
scb->rsc_errs,(
int)p->
scb->ovrn_errs,(
int)p->
scb->status);
869 printk(
"\nerrs: %04x %04x rus: %02x, cus: %02x\n",(
int)p->
scb->rsc_errs,(
int)p->
scb->ovrn_errs,(
int)p->
scb->rus,(
int)p->
scb->cus);
871 old_at_least = at_least_one;
882 static void sun3_82586_rnr_int(
struct net_device *dev)
884 struct priv *p = netdev_priv(dev);
886 dev->
stats.rx_errors++;
897 printk(
"%s: Receive-Unit restarted. Status: %04x\n",dev->
name,p->
scb->rus);
905 static void sun3_82586_xmt_int(
struct net_device *dev)
908 struct priv *p = netdev_priv(dev);
915 printk(
"%s: strange .. xmit-int without a 'COMPLETE'\n",dev->
name);
919 dev->
stats.tx_packets++;
924 dev->
stats.tx_errors++;
926 printk(
"%s: late collision detected.\n",dev->
name);
927 dev->
stats.collisions++;
930 dev->
stats.tx_carrier_errors++;
931 printk(
"%s: no carrier detected.\n",dev->
name);
934 printk(
"%s: loss of CTS detected.\n",dev->
name);
936 dev->
stats.tx_fifo_errors++;
937 printk(
"%s: DMA underrun detected.\n",dev->
name);
940 printk(
"%s: Max. collisions exceeded.\n",dev->
name);
941 dev->
stats.collisions += 16;
945 #if (NUM_XMIT_BUFFS > 1)
949 netif_wake_queue(dev);
956 static void startrecv586(
struct net_device *dev)
958 struct priv *p = netdev_priv(dev);
968 static void sun3_82586_timeout(
struct net_device *dev)
970 struct priv *p = netdev_priv(dev);
971 #ifndef NO_NOPCOMMANDS
974 netif_wake_queue(dev);
976 printk(
"%s: strange ... timeout with CU active?!?\n",dev->
name);
992 printk(
"%s: xmitter timed out, try to restart! stat: %02x\n",dev->
name,p->
scb->cus);
994 printk(
"%s: check, whether you set the right interrupt number!\n",dev->
name);
996 sun3_82586_close(dev);
997 sun3_82586_open(dev);
1009 #ifndef NO_NOPCOMMANDS
1012 struct priv *p = netdev_priv(dev);
1020 netif_stop_queue(dev);
1022 #if(NUM_XMIT_BUFFS > 1)
1038 #if (NUM_XMIT_BUFFS == 1)
1039 # ifdef NO_NOPCOMMANDS
1044 printk(
"%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->
name);
1071 printk(
"%s: Can't start transmit-command.\n",dev->
name);
1087 if( (next_nop = p->
xmit_count + 1) == NUM_XMIT_BUFFS )
1093 p->
nop_cmds[next_nop]->cmd_status = 0;
1099 unsigned long flags;
1102 netif_wake_queue(dev);
1118 struct priv *p = netdev_priv(dev);
1119 unsigned short crc,aln,
rsc,ovrn;
1122 p->
scb->crc_errs = 0;
1124 p->
scb->aln_errs = 0;
1126 p->
scb->rsc_errs = 0;
1128 p->
scb->ovrn_errs = 0;
1131 dev->
stats.rx_fifo_errors += ovrn;
1132 dev->
stats.rx_frame_errors += aln;
1142 static void set_multicast_list(
struct net_device *dev)
1144 netif_stop_queue(dev);
1150 netif_wake_queue(dev);
1157 void sun3_82586_dump(
struct net_device *dev,
void *ptr)
1159 struct priv *p = netdev_priv(dev);
1178 if( (dump_cmd->
cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
1179 printk(
"%s: Can't get dump information.\n",dev->
name);
1181 for(i=0;i<170;i++) {
1182 printk(
"%02x ",(
int) ((
unsigned char *) (dump_cmd + 1))[i]);