103 static int automatic_resume;
105 static int fifo = 0x8;
107 #include <linux/module.h>
108 #include <linux/kernel.h>
109 #include <linux/string.h>
110 #include <linux/errno.h>
115 #include <linux/bitops.h>
118 #include <linux/netdevice.h>
124 #define DRV_NAME "ni52"
129 #define ni_attn586() { outb(0, dev->base_addr + NI52_ATTENTION); }
130 #define ni_reset586() { outb(0, dev->base_addr + NI52_RESET); }
131 #define ni_disint() { outb(0, dev->base_addr + NI52_INTDIS); }
132 #define ni_enaint() { outb(0, dev->base_addr + NI52_INTENA); }
134 #define make32(ptr16) ((void __iomem *)(p->memtop + (short) (ptr16)))
135 #define make24(ptr32) ((char __iomem *)(ptr32)) - p->base
136 #define make16(ptr32) ((unsigned short) ((char __iomem *)(ptr32)\
153 #define RECV_BUFF_SIZE 1524
154 #define XMIT_BUFF_SIZE 1524
155 #define NUM_XMIT_BUFFS 1
156 #define NUM_RECV_BUFFS_8 4
157 #define NUM_RECV_BUFFS_16 9
158 #define NO_NOPCOMMANDS
163 #define NI52_TOTAL_SIZE 16
164 #define NI52_ADDR0 0x02
165 #define NI52_ADDR1 0x07
166 #define NI52_ADDR2 0x01
198 #if (NUM_XMIT_BUFFS == 1)
213 struct priv *
p = netdev_priv(dev);
215 for (i = 0; i < 16384; i++) {
220 printk(
KERN_ERR "%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",
232 struct priv *
p = netdev_priv(dev);
234 for (i = 0; i < 16384; i++) {
239 printk(
KERN_ERR "%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",
250 static void wait_for_stat_compl(
void __iomem *p)
254 for (i = 0; i < 32767; i++) {
268 netif_stop_queue(dev);
290 netif_start_queue(dev);
297 struct priv *p = netdev_priv(dev);
317 struct priv *p = netdev_priv(dev);
330 for (i = 0; i <
sizeof(
struct scp_struct); i++)
338 if (!check_iscp(dev, p->
mapped))
340 if (!check_iscp(dev, p->
iscp))
353 struct priv *p = netdev_priv(dev);
381 static int io = 0x300;
382 static long memstart;
391 static const int ports[] = {0x300, 0x280, 0x360, 0x320, 0x340, 0};
399 p = netdev_priv(dev);
411 err = ni52_probe1(dev, io);
415 for (port = ports; *port && ni52_probe1(dev, *port) ; port++)
420 for (io = 0x200; io < 0x400 && ni52_probe1(dev, io); io += 8)
443 .ndo_open = ni52_open,
444 .ndo_stop = ni52_close,
445 .ndo_get_stats = ni52_get_stats,
446 .ndo_tx_timeout = ni52_timeout,
447 .ndo_start_xmit = ni52_send_packet,
448 .ndo_set_rx_mode = set_multicast_list,
457 struct priv *
priv = netdev_priv(dev);
492 if (size != 0x2000 && size != 0x4000) {
494 printk(
KERN_ERR "%s: Invalid memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n", dev->
name, size);
498 if (!check586(dev, size)) {
507 if (!check586(dev, size)) {
509 if (!check586(dev, size)) {
516 static const unsigned long memaddrs[] = {
517 0xc8000, 0xca000, 0xcc000, 0xce000, 0xd0000, 0xd2000,
518 0xd4000, 0xd6000, 0xd8000, 0xda000, 0xdc000, 0
528 if (check586(dev, size))
532 if (check586(dev, size))
553 unsigned long irq_mask;
562 printk(
"?autoirq, Failed to detect IRQ line!\n");
567 printk(
"IRQ %d (autodetected).\n", dev->
irq);
571 printk(
"IRQ %d (assigned and not checked!).\n", dev->
irq);
592 struct priv *p = netdev_priv(dev);
622 if (num_addrs > len) {
637 wait_for_stat_compl(cfg_cmd);
663 wait_for_stat_compl(ias_cmd);
686 wait_for_stat_compl(tdr_cmd);
700 printk(
KERN_ERR "%s: TDR: Transceiver problem. Check the cable(s)!\n",
703 printk(
KERN_ERR "%s: TDR: No correct termination %d clocks away.\n",
708 printk(
KERN_ERR "%s: TDR: Detected a short circuit %d clocks away.\n",
709 dev->
name, result & TDR_TIMEMASK);
733 wait_for_stat_compl(mc_cmd);
743 #if (NUM_XMIT_BUFFS == 1)
744 for (i = 0; i < 2; i++) {
761 ptr = alloc_rfa(dev, ptr);
775 printk(
KERN_ERR "%s: not enough shared-mem for your configuration!\n",
794 #ifndef NO_NOPCOMMANDS
801 #ifndef NO_NOPCOMMANDS
805 wait_for_scb_cmd(dev);
833 struct priv *p = netdev_priv(dev);
842 writew(0xffff, &rfd[i].rbd_offset);
882 p = netdev_priv(dev);
889 wait_for_scb_cmd(dev);
902 wait_for_scb_cmd(dev);
905 wait_for_scb_cmd_ruc(dev);
907 printk(
KERN_ERR "%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",
917 #ifndef NO_NOPCOMMANDS
919 if (netif_running(dev))
920 printk(
KERN_ERR "%s: oops! CU has left active state. stat: %04x/%02x.\n",
929 wait_for_scb_cmd(dev);
948 static void ni52_rcv_int(
struct net_device *dev)
954 struct priv *p = netdev_priv(dev);
967 skb = netdev_alloc_skb(dev, totlen + 2);
974 dev->
stats.rx_packets++;
977 dev->
stats.rx_dropped++;
982 while (!((rstat =
readw(&rbd->
status)) & RBD_LAST)) {
995 dev->
stats.rx_dropped++;
1000 dev->
stats.rx_errors++;
1014 if (automatic_resume) {
1015 wait_for_scb_cmd(dev);
1018 wait_for_scb_cmd_ruc(dev);
1024 for (i = 0; i < 1024; i++) {
1041 static void ni52_rnr_int(
struct net_device *dev)
1043 struct priv *p = netdev_priv(dev);
1045 dev->
stats.rx_errors++;
1047 wait_for_scb_cmd(dev);
1050 wait_for_scb_cmd_ruc(dev);
1065 static void ni52_xmt_int(
struct net_device *dev)
1068 struct priv *p = netdev_priv(dev);
1078 dev->
stats.tx_packets++;
1081 dev->
stats.tx_errors++;
1085 dev->
stats.collisions++;
1087 dev->
stats.tx_carrier_errors++;
1094 dev->
stats.tx_fifo_errors++;
1100 dev->
stats.collisions += 16;
1103 #if (NUM_XMIT_BUFFS > 1)
1107 netif_wake_queue(dev);
1114 static void startrecv586(
struct net_device *dev)
1116 struct priv *p = netdev_priv(dev);
1118 wait_for_scb_cmd(dev);
1119 wait_for_scb_cmd_ruc(dev);
1123 wait_for_scb_cmd_ruc(dev);
1127 static void ni52_timeout(
struct net_device *dev)
1129 struct priv *p = netdev_priv(dev);
1130 #ifndef NO_NOPCOMMANDS
1132 netif_wake_queue(dev);
1144 wait_for_scb_cmd(dev);
1148 wait_for_scb_cmd(dev);
1155 printk(
KERN_ERR "%s: xmitter timed out, try to restart! stat: %02x\n",
1161 printk(
KERN_ERR "%s: check, whether you set the right interrupt number!\n",
1178 #ifndef NO_NOPCOMMANDS
1181 struct priv *p = netdev_priv(dev);
1183 if (skb->
len > XMIT_BUFF_SIZE) {
1184 printk(
KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->
name, XMIT_BUFF_SIZE, skb->
len);
1188 netif_stop_queue(dev);
1198 #if (NUM_XMIT_BUFFS == 1)
1199 # ifdef NO_NOPCOMMANDS
1203 printk(
KERN_ERR "%s: Hmmm .. CU is still running and we wanna send a new packet.\n", dev->
name);
1210 for (i = 0; i < 16; i++) {
1212 wait_for_scb_cmd(dev);
1222 wait_for_scb_cmd(dev);
1247 if (next_nop == NUM_XMIT_BUFFS)
1258 unsigned long flags;
1261 netif_wake_queue(dev);
1262 spin_unlock_irqrestore(&p->
spinlock);
1275 struct priv *p = netdev_priv(dev);
1276 unsigned short crc, aln,
rsc, ovrn;
1289 dev->
stats.rx_fifo_errors += ovrn;
1290 dev->
stats.rx_frame_errors += aln;
1300 static void set_multicast_list(
struct net_device *dev)
1302 netif_stop_queue(dev);
1308 netif_wake_queue(dev);
1325 if (io <= 0x0 || !memend || !memstart || irq < 2) {
1327 printk(
KERN_ERR "ni52: Set symbols 'io' 'irq' 'memstart' and 'memend'\n");
1331 if (IS_ERR(dev_ni52))
1332 return PTR_ERR(dev_ni52);
1338 struct priv *p = netdev_priv(dev_ni52);