49 #include <linux/module.h>
50 #include <linux/kernel.h>
51 #include <linux/string.h>
52 #include <linux/errno.h>
57 #include <linux/bitops.h>
61 #include <linux/netdevice.h>
67 static const char boardname[] =
"NI5010";
69 "ni5010.c: v1.02 20060611 Jan-Pascal van Best and Andreas Mohr\n";
72 static unsigned int bufsize_rcv;
74 #define JUMPERED_INTERRUPTS
81 { 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0 };
86 #define NI5010_DEBUG 0
104 static void ni5010_set_multicast_list(
struct net_device *
dev);
108 #define tx_done(dev) 1
110 static void chipset_init(
struct net_device *
dev,
int startp);
111 static void dump_packet(
void *
buf,
int len);
136 err = ni5010_probe1(dev,
io);
137 }
else if (
io != 0) {
141 for (
io=0x200;
io<0x400 && ni5010_probe1(dev,
io) ;
io+=0x20)
147 for (port =
ports; *port && ni5010_probe1(dev, *port); port++)
166 static inline int rd_port(
int ioaddr)
172 static void __init trigger_irq(
int ioaddr)
192 .ndo_open = ni5010_open,
193 .ndo_stop = ni5010_close,
194 .ndo_start_xmit = ni5010_send_packet,
195 .ndo_set_rx_mode = ni5010_set_multicast_list,
196 .ndo_tx_timeout = ni5010_timeout,
210 static unsigned version_printed;
213 unsigned int data = 0;
240 if (
inb(ioaddr+0) == 0xff)
243 while ( (rd_port(ioaddr) & rd_port(ioaddr) & rd_port(ioaddr) &
244 rd_port(ioaddr) & rd_port(ioaddr) & rd_port(ioaddr)) != 0xff)
246 if (boguscount-- == 0)
253 if ( (data = rd_port(ioaddr)) != 0xff)
break;
275 printk(
"NI5010 ethercard probe at 0x%x: ", ioaddr);
279 for (i=0; i<6; i++) {
287 #ifdef JUMPERED_INTERRUPTS
288 if (dev->
irq == 0xff)
290 else if (dev->
irq < 2) {
291 unsigned long irq_mask;
308 }
else if (dev->
irq == 2) {
315 lp = netdev_priv(dev);
329 for (i = 1; i < 0xff; i++) {
334 if (data == i)
break;
336 bufsize_rcv = i << 8;
372 static int ni5010_open(
struct net_device *dev)
405 for(i = 0;i < 6; i++) {
420 netif_start_queue(dev);
428 static void reset_receiver(
struct net_device *dev)
440 static void ni5010_timeout(
struct net_device *dev)
443 tx_done(dev) ?
"IRQ conflict" :
"network cable problem");
446 chipset_init(dev, 1);
448 netif_wake_queue(dev);
461 netif_stop_queue(dev);
462 hardware_send_packet(dev, (
unsigned char *)skb->
data, skb->
len, length-skb->
len);
476 int xmit_was_error = 0;
481 lp = netdev_priv(dev);
483 spin_lock(&lp->
lock);
487 if ((status &
IS_R_INT) == 0) ni5010_rx(dev);
490 xmit_was_error = process_xmt_interrupt(dev);
500 spin_unlock(&lp->
lock);
505 static void dump_packet(
void *
buf,
int len)
510 for (i = 0; i < len; i++){
512 if (i % 2 == 0)
printk(
" ");
513 printk(
"%2.2x", ((
unsigned char *)buf)[i]);
514 if (i % 16 == 15)
printk(
"\n");
523 unsigned char rcv_stat;
534 dev->
stats.rx_errors++;
548 dev->
name, i_pkt_size));
549 dev->
stats.rx_errors++;
550 dev->
stats.rx_length_errors++;
555 skb = netdev_alloc_skb(dev, i_pkt_size + 3);
558 dev->
stats.rx_dropped++;
570 dump_packet(skb->
data, skb->
len);
574 dev->
stats.rx_packets++;
575 dev->
stats.rx_bytes += i_pkt_size;
578 dev->
name, i_pkt_size));
581 static int process_xmt_interrupt(
struct net_device *dev)
602 dev->
stats.collisions++;
608 dev->
stats.tx_packets++;
610 netif_wake_queue(dev);
619 static int ni5010_close(
struct net_device *dev)
624 #ifdef JUMPERED_INTERRUPTS
631 netif_stop_queue(dev);
644 static void ni5010_set_multicast_list(
struct net_device *dev)
660 static void hardware_send_packet(
struct net_device *dev,
char *buf,
int length,
int pad)
665 unsigned int buf_offs;
706 spin_unlock_irqrestore(&lp->
lock, flags);
708 netif_wake_queue(dev);
713 static void chipset_init(
struct net_device *dev,
int startp)
719 static void ni5010_show_registers(
struct net_device *dev)
740 static int __init ni5010_init_module(
void)
751 printk(
KERN_WARNING "%s: Autoprobing for modules is hazardous, trying anyway..\n", boardname);
756 if (IS_ERR(dev_ni5010))
757 return PTR_ERR(dev_ni5010);
761 static void __exit ni5010_cleanup_module(
void)