1 /* ni5010.c: A network driver for the MiCom-Interlan NI5010 ethercard.
3 * Copyright 1996,1997 Jan-Pascal van Best and Andreas Mohr.
5 * This software may be used and distributed according to the terms
6 * of the GNU Public License, incorporated herein by reference.
8 * The authors may be reached as:
9 * jvbest@wi.leidenuniv.nl a.mohr@mailto.de
11 * Jan-Pascal van Best Andreas Mohr
12 * Klikspaanweg 58-4 Stauferstr. 6
13 * 2324 LZ Leiden D-71272 Renningen
14 * The Netherlands Germany
17 * Donald Becker's "skeleton.c"
18 * Crynwr ni5010 packet driver
21 * v0.0: First test version
22 * v0.1: First working version
24 * v0.3->v0.90: Now demand setting io and irq when loading as module
25 * 970430 v0.91: modified for Linux 2.1.14
26 * v0.92: Implemented Andreas' (better) NI5010 probe
27 * 970503 v0.93: Fixed auto-irq failure on warm reboot (JB)
28 * 970623 v1.00: First kernel version (AM)
29 * 970814 v1.01: Added detection of onboard receive buffer size (AM)
32 * - Note that you have to patch ifconfig for the new /proc/net/dev
33 * format. It gives incorrect stats otherwise.
37 * Move some stuff to chipset_init()
38 * Handle xmt errors other than collisions
39 * Complete merge with Andreas' driver
40 * Implement ring buffers (Is this useful? You can't squeeze
41 * too many packet in a 2k buffer!)
42 * Implement DMA (Again, is this useful? Some docs says DMA is
43 * slower than programmed I/O)
46 * gcc -O2 -fomit-frame-pointer -m486 -D__KERNEL__ \
47 * -DMODULE -c ni5010.c
50 * insmod ni5010.o io=0x300 irq=5
53 #include <linux/module.h>
54 #include <linux/kernel.h>
55 #include <linux/string.h>
56 #include <linux/errno.h>
57 #include <linux/ioport.h>
58 #include <linux/malloc.h>
59 #include <linux/interrupt.h>
60 #include <linux/delay.h>
61 #include <linux/init.h>
62 #include <asm/bitops.h>
66 #include <linux/netdevice.h>
67 #include <linux/etherdevice.h>
68 #include <linux/skbuff.h>
72 static const char *boardname
= "NI5010";
73 static char *version
=
74 "ni5010.c: v1.00 06/23/97 Jan-Pascal van Best and Andreas Mohr\n";
76 /* bufsize_rcv == 0 means autoprobing */
77 unsigned int bufsize_rcv
= 0;
79 #define jumpered_interrupts /* IRQ line jumpered on board */
80 #undef jumpered_dma /* No DMA used */
81 #undef FULL_IODETECT /* Only detect in portlist */
84 /* A zero-terminated list of I/O addresses to be probed. */
85 static unsigned int ni5010_portlist
[] __initdata
=
86 { 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0 };
89 /* Use 0 for production, 1 for verification, >2 for debug */
91 #define NI5010_DEBUG 0
94 /* Information that needs to be kept for each board. */
96 struct net_device_stats stats
;
101 /* Index to functions, as function prototypes. */
103 extern int ni5010_probe(struct net_device
*dev
);
104 static int ni5010_probe1(struct net_device
*dev
, int ioaddr
);
105 static int ni5010_open(struct net_device
*dev
);
106 static int ni5010_send_packet(struct sk_buff
*skb
, struct net_device
*dev
);
107 static void ni5010_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
108 static void ni5010_rx(struct net_device
*dev
);
109 static void ni5010_timeout(struct net_device
*dev
);
110 static int ni5010_close(struct net_device
*dev
);
111 static struct net_device_stats
*ni5010_get_stats(struct net_device
*dev
);
112 static void ni5010_set_multicast_list(struct net_device
*dev
);
113 static void reset_receiver(struct net_device
*dev
);
115 static int process_xmt_interrupt(struct net_device
*dev
);
116 #define tx_done(dev) 1
117 extern void hardware_send_packet(struct net_device
*dev
, char *buf
, int length
);
118 extern void chipset_init(struct net_device
*dev
, int startp
);
119 static void dump_packet(void *buf
, int len
);
120 static void show_registers(struct net_device
*dev
);
123 int __init
ni5010_probe(struct net_device
*dev
)
127 int base_addr
= dev
? dev
->base_addr
: 0;
129 PRINTK2((KERN_DEBUG
"%s: Entering ni5010_probe\n", dev
->name
));
131 if (base_addr
> 0x1ff) /* Check a single specified location. */
132 return ni5010_probe1(dev
, base_addr
);
133 else if (base_addr
!= 0) /* Don't probe at all. */
137 for (int ioaddr
=0x200; ioaddr
<0x400; ioaddr
+=0x20) {
138 if (check_region(ioaddr
, NI5010_IO_EXTENT
))
140 if (ni5010_probe1(dev
, ioaddr
) == 0)
144 for (port
= ni5010_portlist
; *port
; port
++) {
146 if (check_region(ioaddr
, NI5010_IO_EXTENT
))
148 if (ni5010_probe1(dev
, ioaddr
) == 0)
151 #endif /* FULL_IODETECT */
155 static inline int rd_port(int ioaddr
)
158 return inb(IE_SAPROM
);
161 void __init
trigger_irq(int ioaddr
)
163 outb(0x00, EDLC_RESET
); /* Clear EDLC hold RESET state */
164 outb(0x00, IE_RESET
); /* Board reset */
165 outb(0x00, EDLC_XMASK
); /* Disable all Xmt interrupts */
166 outb(0x00, EDLC_RMASK
); /* Disable all Rcv interrupt */
167 outb(0xff, EDLC_XCLR
); /* Clear all pending Xmt interrupts */
168 outb(0xff, EDLC_RCLR
); /* Clear all pending Rcv interrupts */
170 * Transmit packet mode: Ignore parity, Power xcvr,
173 outb(XMD_IG_PAR
| XMD_T_MODE
| XMD_LBC
, EDLC_XMODE
);
174 outb(RMD_BROADCAST
, EDLC_RMODE
); /* Receive normal&broadcast */
175 outb(XM_ALL
, EDLC_XMASK
); /* Enable all Xmt interrupts */
176 udelay(50); /* FIXME: Necessary? */
177 outb(MM_EN_XMT
|MM_MUX
, IE_MMODE
); /* Start transmission */
181 * This is the real probe routine. Linux has a history of friendly device
182 * probes on the ISA bus. A good device probes avoids doing writes, and
183 * verifies that the correct device exists and functions.
186 static int __init
ni5010_probe1(struct net_device
*dev
, int ioaddr
)
188 static unsigned version_printed
= 0;
190 unsigned int data
= 0;
194 * This is no "official" probe method, I've rather tested which
195 * probe works best with my seven NI5010 cards
196 * (they have very different serial numbers)
197 * Suggestions or failure reports are very, very welcome !
198 * But I think it is a relatively good probe method
199 * since it doesn't use any "outb"
200 * It should be nearly 100% reliable !
201 * well-known WARNING: this probe method (like many others)
202 * will hang the system if a NE2000 card region is probed !
207 PRINTK2((KERN_DEBUG
"%s: entering ni5010_probe1(%#3x)\n",
210 if (inb(ioaddr
+0) == 0xff) return -ENODEV
;
212 while ( (rd_port(ioaddr
) & rd_port(ioaddr
) & rd_port(ioaddr
) &
213 rd_port(ioaddr
) & rd_port(ioaddr
) & rd_port(ioaddr
)) != 0xff)
215 if (boguscount
-- == 0) return -ENODEV
;
218 PRINTK2((KERN_DEBUG
"%s: I/O #1 passed!\n", dev
->name
));
221 if ( (data
= rd_port(ioaddr
)) != 0xff) break;
222 if (data
==0xff) return -ENODEV
;
224 PRINTK2((KERN_DEBUG
"%s: I/O #2 passed!\n", dev
->name
));
226 if ( (data
== SA_ADDR0
) &&
227 (rd_port(ioaddr
) == SA_ADDR1
) &&
228 (rd_port(ioaddr
) == SA_ADDR2
) ) {
229 for (i
=0; i
<4; i
++) rd_port(ioaddr
);
230 if ( (rd_port(ioaddr
) != NI5010_MAGICVAL1
) ||
231 (rd_port(ioaddr
) != NI5010_MAGICVAL2
) ) {
234 } else return -ENODEV
;
236 PRINTK2((KERN_DEBUG
"%s: I/O #3 passed!\n", dev
->name
));
238 if (NI5010_DEBUG
&& version_printed
++ == 0)
239 printk(KERN_INFO
"%s", version
);
241 printk("NI5010 ethercard probe at 0x%x: ", ioaddr
);
243 dev
->base_addr
= ioaddr
;
245 for (i
=0; i
<6; i
++) {
247 printk("%2.2x ", dev
->dev_addr
[i
] = inb(IE_SAPROM
));
250 PRINTK2((KERN_DEBUG
"%s: I/O #4 passed!\n", dev
->name
));
252 #ifdef jumpered_interrupts
253 if (dev
->irq
== 0xff)
255 else if (dev
->irq
< 2) {
256 PRINTK2((KERN_DEBUG
"%s: I/O #5 passed!\n", dev
->name
));
260 dev
->irq
= autoirq_report(2);
262 PRINTK2((KERN_DEBUG
"%s: I/O #6 passed!\n", dev
->name
));
265 printk(KERN_WARNING
"%s: no IRQ found!\n", dev
->name
);
268 PRINTK2((KERN_DEBUG
"%s: I/O #7 passed!\n", dev
->name
));
269 } else if (dev
->irq
== 2) {
272 #endif /* jumpered_irq */
273 PRINTK2((KERN_DEBUG
"%s: I/O #9 passed!\n", dev
->name
));
275 /* DMA is not supported (yet?), so no use detecting it */
277 if (dev
->priv
== NULL
) {
278 dev
->priv
= kmalloc(sizeof(struct ni5010_local
), GFP_KERNEL
|GFP_DMA
);
279 if (dev
->priv
== NULL
) {
280 printk(KERN_WARNING
"%s: Failed to allocate private memory\n", dev
->name
);
285 PRINTK2((KERN_DEBUG
"%s: I/O #10 passed!\n", dev
->name
));
287 /* get the size of the onboard receive buffer
288 * higher addresses than bufsize are wrapped into real buffer
289 * i.e. data for offs. 0x801 is written to 0x1 with a 2K onboard buffer
292 outb(1, IE_MMODE
); /* Put Rcv buffer on system bus */
293 outw(0, IE_GP
); /* Point GP at start of packet */
294 outb(0, IE_RBUF
); /* set buffer byte 0 to 0 */
295 for (i
= 1; i
< 0xff; i
++) {
296 outw(i
<< 8, IE_GP
); /* Point GP at packet size to be tested */
298 outw(0x0, IE_GP
); /* Point GP at start of packet */
300 if (data
== i
) break;
302 bufsize_rcv
= i
<< 8;
303 outw(0, IE_GP
); /* Point GP at start of packet */
304 outb(0, IE_RBUF
); /* set buffer byte 0 to 0 again */
306 printk("// bufsize rcv/xmt=%d/%d\n", bufsize_rcv
, NI5010_BUFSIZE
);
307 memset(dev
->priv
, 0, sizeof(struct ni5010_local
));
309 /* Grab the region so we can find another board if autoIRQ fails. */
310 request_region(ioaddr
, NI5010_IO_EXTENT
, boardname
);
312 dev
->open
= ni5010_open
;
313 dev
->stop
= ni5010_close
;
314 dev
->hard_start_xmit
= ni5010_send_packet
;
315 dev
->get_stats
= ni5010_get_stats
;
316 dev
->set_multicast_list
= ni5010_set_multicast_list
;
317 dev
->tx_timeout
= ni5010_timeout
;
318 dev
->watchdog_timeo
= HZ
/20;
320 /* Fill in the fields of the device structure with ethernet values. */
323 dev
->flags
&= ~IFF_MULTICAST
; /* Multicast doesn't work */
325 /* Shut up the ni5010 */
326 outb(0, EDLC_RMASK
); /* Mask all receive interrupts */
327 outb(0, EDLC_XMASK
); /* Mask all xmit interrupts */
328 outb(0xff, EDLC_RCLR
); /* Kill all pending rcv interrupts */
329 outb(0xff, EDLC_XCLR
); /* Kill all pending xmt interrupts */
331 printk(KERN_INFO
"%s: NI5010 found at 0x%x, using IRQ %d", dev
->name
, ioaddr
, dev
->irq
);
332 if (dev
->dma
) printk(" & DMA %d", dev
->dma
);
335 printk(KERN_INFO
"Join the NI5010 driver development team!\n");
336 printk(KERN_INFO
"Mail to a.mohr@mailto.de or jvbest@wi.leidenuniv.nl\n");
341 * Open/initialize the board. This is called (in the current kernel)
342 * sometime after booting when the 'ifconfig' program is run.
344 * This routine should set everything up anew at each open, even
345 * registers that "should" only need to be set once at boot, so that
346 * there is non-reboot way to recover if something goes wrong.
349 static int ni5010_open(struct net_device
*dev
)
351 int ioaddr
= dev
->base_addr
;
354 PRINTK2((KERN_DEBUG
"%s: entering ni5010_open()\n", dev
->name
));
356 if (request_irq(dev
->irq
, &ni5010_interrupt
, 0, boardname
, dev
)) {
357 printk(KERN_WARNING
"%s: Cannot get irq %#2x\n", dev
->name
, dev
->irq
);
360 PRINTK3((KERN_DEBUG
"%s: passed open() #1\n", dev
->name
));
362 * Always allocate the DMA channel after the IRQ,
363 * and clean up on failure.
366 if (request_dma(dev
->dma
, cardname
)) {
367 printk(KERN_WARNING
"%s: Cannot get dma %#2x\n", dev
->name
, dev
->dma
);
368 free_irq(dev
->irq
, NULL
);
371 #endif /* jumpered_dma */
373 PRINTK3((KERN_DEBUG
"%s: passed open() #2\n", dev
->name
));
374 /* Reset the hardware here. Don't forget to set the station address. */
376 outb(RS_RESET
, EDLC_RESET
); /* Hold up EDLC_RESET while configing board */
377 outb(0, IE_RESET
); /* Hardware reset of ni5010 board */
378 outb(XMD_LBC
, EDLC_XMODE
); /* Only loopback xmits */
380 PRINTK3((KERN_DEBUG
"%s: passed open() #3\n", dev
->name
));
381 /* Set the station address */
382 for(i
= 0;i
< 6; i
++) {
383 outb(dev
->dev_addr
[i
], EDLC_ADDR
+ i
);
386 PRINTK3((KERN_DEBUG
"%s: Initialising ni5010\n", dev
->name
));
387 outb(0, EDLC_XMASK
); /* No xmit interrupts for now */
388 outb(XMD_IG_PAR
| XMD_T_MODE
| XMD_LBC
, EDLC_XMODE
);
389 /* Normal packet xmit mode */
390 outb(0xff, EDLC_XCLR
); /* Clear all pending xmit interrupts */
391 outb(RMD_BROADCAST
, EDLC_RMODE
);
392 /* Receive broadcast and normal packets */
393 reset_receiver(dev
); /* Ready ni5010 for receiving packets */
395 outb(0, EDLC_RESET
); /* Un-reset the ni5010 */
397 netif_start_queue(dev
);
399 if (NI5010_DEBUG
) show_registers(dev
);
402 PRINTK((KERN_DEBUG
"%s: open successful\n", dev
->name
));
406 static void reset_receiver(struct net_device
*dev
)
408 int ioaddr
= dev
->base_addr
;
410 PRINTK3((KERN_DEBUG
"%s: resetting receiver\n", dev
->name
));
411 outw(0, IE_GP
); /* Receive packet at start of buffer */
412 outb(0xff, EDLC_RCLR
); /* Clear all pending rcv interrupts */
413 outb(0, IE_MMODE
); /* Put EDLC to rcv buffer */
414 outb(MM_EN_RCV
, IE_MMODE
); /* Enable rcv */
415 outb(0xff, EDLC_RMASK
); /* Enable all rcv interrupts */
418 static void ni5010_timeout(struct net_device
*dev
)
420 printk(KERN_WARNING
"%s: transmit timed out, %s?\n", dev
->name
,
421 tx_done(dev
) ? "IRQ conflict" : "network cable problem");
422 /* Try to restart the adaptor. */
423 /* FIXME: Give it a real kick here */
424 chipset_init(dev
, 1);
425 dev
->trans_start
= jiffies
;
426 netif_wake_queue(dev
);
429 static int ni5010_send_packet(struct sk_buff
*skb
, struct net_device
*dev
)
431 int length
= ETH_ZLEN
< skb
->len
? skb
->len
: ETH_ZLEN
;
433 PRINTK2((KERN_DEBUG
"%s: entering ni5010_send_packet\n", dev
->name
));
439 netif_stop_queue(dev
);
440 hardware_send_packet(dev
, (unsigned char *)skb
->data
, length
);
441 dev
->trans_start
= jiffies
;
447 * The typical workload of the driver:
448 * Handle the network interface interrupts.
450 static void ni5010_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
452 struct net_device
*dev
= dev_id
;
453 struct ni5010_local
*lp
;
455 int xmit_was_error
= 0;
457 PRINTK2((KERN_DEBUG
"%s: entering ni5010_interrupt\n", dev
->name
));
459 ioaddr
= dev
->base_addr
;
460 lp
= (struct ni5010_local
*)dev
->priv
;
462 status
= inb(IE_ISTAT
);
463 PRINTK3((KERN_DEBUG
"%s: IE_ISTAT = %#02x\n", dev
->name
, status
));
465 if ((status
& IS_R_INT
) == 0) ni5010_rx(dev
);
467 if ((status
& IS_X_INT
) == 0) {
468 xmit_was_error
= process_xmt_interrupt(dev
);
471 if ((status
& IS_DMA_INT
) == 0) {
472 PRINTK((KERN_DEBUG
"%s: DMA complete (???)\n", dev
->name
));
473 outb(0, IE_DMA_RST
); /* Reset DMA int */
482 static void dump_packet(void *buf
, int len
)
486 printk(KERN_DEBUG
"Packet length = %#4x\n", len
);
487 for (i
= 0; i
< len
; i
++){
488 if (i
% 16 == 0) printk(KERN_DEBUG
"%#4.4x", i
);
489 if (i
% 2 == 0) printk(" ");
490 printk("%2.2x", ((unsigned char *)buf
)[i
]);
491 if (i
% 16 == 15) printk("\n");
498 /* We have a good packet, get it out of the buffer. */
499 static void ni5010_rx(struct net_device
*dev
)
501 struct ni5010_local
*lp
= (struct ni5010_local
*)dev
->priv
;
502 int ioaddr
= dev
->base_addr
;
503 unsigned char rcv_stat
;
506 PRINTK2((KERN_DEBUG
"%s: entering ni5010_rx()\n", dev
->name
));
508 rcv_stat
= inb(EDLC_RSTAT
);
509 PRINTK3((KERN_DEBUG
"%s: EDLC_RSTAT = %#2x\n", dev
->name
, rcv_stat
));
511 if ( (rcv_stat
& RS_VALID_BITS
) != RS_PKT_OK
) {
512 PRINTK((KERN_INFO
"%s: receive error.\n", dev
->name
));
513 lp
->stats
.rx_errors
++;
514 if (rcv_stat
& RS_RUNT
) lp
->stats
.rx_length_errors
++;
515 if (rcv_stat
& RS_ALIGN
) lp
->stats
.rx_frame_errors
++;
516 if (rcv_stat
& RS_CRC_ERR
) lp
->stats
.rx_crc_errors
++;
517 if (rcv_stat
& RS_OFLW
) lp
->stats
.rx_fifo_errors
++;
518 outb(0xff, EDLC_RCLR
); /* Clear the interrupt */
522 outb(0xff, EDLC_RCLR
); /* Clear the interrupt */
524 lp
->i_pkt_size
= inw(IE_RCNT
);
525 if (lp
->i_pkt_size
> ETH_FRAME_LEN
|| lp
->i_pkt_size
< 10 ) {
526 PRINTK((KERN_DEBUG
"%s: Packet size error, packet size = %#4.4x\n",
527 dev
->name
, lp
->i_pkt_size
));
528 lp
->stats
.rx_errors
++;
529 lp
->stats
.rx_length_errors
++;
533 /* Malloc up new buffer. */
534 skb
= dev_alloc_skb(lp
->i_pkt_size
+ 3);
536 printk(KERN_WARNING
"%s: Memory squeeze, dropping packet.\n", dev
->name
);
537 lp
->stats
.rx_dropped
++;
544 /* Read packet into buffer */
545 outb(MM_MUX
, IE_MMODE
); /* Rcv buffer to system bus */
546 outw(0, IE_GP
); /* Seek to beginning of packet */
547 insb(IE_RBUF
, skb_put(skb
, lp
->i_pkt_size
), lp
->i_pkt_size
);
549 if (NI5010_DEBUG
>= 4)
550 dump_packet(skb
->data
, skb
->len
);
552 skb
->protocol
= eth_type_trans(skb
,dev
);
554 lp
->stats
.rx_packets
++;
555 lp
->stats
.rx_bytes
+= lp
->i_pkt_size
;
557 PRINTK2((KERN_DEBUG
"%s: Received packet, size=%#4.4x\n",
558 dev
->name
, lp
->i_pkt_size
));
562 static int process_xmt_interrupt(struct net_device
*dev
)
564 struct ni5010_local
*lp
= (struct ni5010_local
*)dev
->priv
;
565 int ioaddr
= dev
->base_addr
;
568 PRINTK2((KERN_DEBUG
"%s: entering process_xmt_interrupt\n", dev
->name
));
570 xmit_stat
= inb(EDLC_XSTAT
);
571 PRINTK3((KERN_DEBUG
"%s: EDLC_XSTAT = %2.2x\n", dev
->name
, xmit_stat
));
573 outb(0, EDLC_XMASK
); /* Disable xmit IRQ's */
574 outb(0xff, EDLC_XCLR
); /* Clear all pending xmit IRQ's */
576 if (xmit_stat
& XS_COLL
){
577 printk("ether collision\n"); /* FIXME: remove */
578 PRINTK((KERN_DEBUG
"%s: collision detected, retransmitting\n",
580 outw(NI5010_BUFSIZE
- lp
->o_pkt_size
, IE_GP
);
581 /* outb(0, IE_MMODE); */ /* xmt buf on sysbus FIXME: needed ? */
582 outb(MM_EN_XMT
| MM_MUX
, IE_MMODE
);
583 outb(XM_ALL
, EDLC_XMASK
); /* Enable xmt IRQ's */
584 lp
->stats
.collisions
++;
588 /* FIXME: handle other xmt error conditions */
590 lp
->stats
.tx_packets
++;
591 lp
->stats
.tx_bytes
+= lp
->o_pkt_size
;
592 netif_wake_queue(dev
);
594 PRINTK2((KERN_DEBUG
"%s: sent packet, size=%#4.4x\n",
595 dev
->name
, lp
->o_pkt_size
));
600 /* The inverse routine to ni5010_open(). */
601 static int ni5010_close(struct net_device
*dev
)
603 int ioaddr
= dev
->base_addr
;
605 PRINTK2((KERN_DEBUG
"%s: entering ni5010_close\n", dev
->name
));
606 #ifdef jumpered_interrupts
607 free_irq(dev
->irq
, NULL
);
609 /* Put card in held-RESET state */
611 outb(RS_RESET
, EDLC_RESET
);
613 netif_stop_queue(dev
);
616 PRINTK((KERN_DEBUG
"%s: %s closed down\n", dev
->name
, boardname
));
621 /* Get the current statistics. This may be called with the card open or
623 static struct net_device_stats
*ni5010_get_stats(struct net_device
*dev
)
625 struct ni5010_local
*lp
= (struct ni5010_local
*)dev
->priv
;
627 PRINTK2((KERN_DEBUG
"%s: entering ni5010_get_stats\n", dev
->name
));
629 if (NI5010_DEBUG
) show_registers(dev
);
632 /* Update the statistics from the device registers. */
633 /* We do this in the interrupt handler */
639 /* Set or clear the multicast filter for this adaptor.
640 num_addrs == -1 Promiscuous mode, receive all packets
641 num_addrs == 0 Normal mode, clear multicast list
642 num_addrs > 0 Multicast mode, receive normal and MC packets, and do
643 best-effort filtering.
645 static void ni5010_set_multicast_list(struct net_device
*dev
)
647 short ioaddr
= dev
->base_addr
;
649 PRINTK2((KERN_DEBUG
"%s: entering set_multicast_list\n", dev
->name
));
651 if (dev
->flags
&IFF_PROMISC
|| dev
->flags
&IFF_ALLMULTI
) {
652 dev
->flags
|= IFF_PROMISC
;
653 outb(RMD_PROMISC
, EDLC_RMODE
); /* Enable promiscuous mode */
654 PRINTK((KERN_DEBUG
"%s: Entering promiscuous mode\n", dev
->name
));
655 } else if (dev
->mc_list
) {
656 /* Sorry, multicast not supported */
657 PRINTK((KERN_DEBUG
"%s: No multicast, entering broadcast mode\n", dev
->name
));
658 outb(RMD_BROADCAST
, EDLC_RMODE
);
660 PRINTK((KERN_DEBUG
"%s: Entering broadcast mode\n", dev
->name
));
661 outb(RMD_BROADCAST
, EDLC_RMODE
); /* Disable promiscuous mode, use normal mode */
665 extern void hardware_send_packet(struct net_device
*dev
, char *buf
, int length
)
667 struct ni5010_local
*lp
= (struct ni5010_local
*)dev
->priv
;
668 int ioaddr
= dev
->base_addr
;
670 unsigned int buf_offs
;
672 PRINTK2((KERN_DEBUG
"%s: entering hardware_send_packet\n", dev
->name
));
674 if (length
> ETH_FRAME_LEN
) {
675 PRINTK((KERN_WARNING
"%s: packet too large, not possible\n",
680 if (NI5010_DEBUG
) show_registers(dev
);
682 if (inb(IE_ISTAT
) & IS_EN_XMT
) {
683 PRINTK((KERN_WARNING
"%s: sending packet while already transmitting, not possible\n",
688 if (NI5010_DEBUG
> 3) dump_packet(buf
, length
);
690 buf_offs
= NI5010_BUFSIZE
- length
;
691 lp
->o_pkt_size
= length
;
696 outb(0, EDLC_RMASK
); /* Mask all receive interrupts */
697 outb(0, IE_MMODE
); /* Put Xmit buffer on system bus */
698 outb(0xff, EDLC_RCLR
); /* Clear out pending rcv interrupts */
700 outw(buf_offs
, IE_GP
); /* Point GP at start of packet */
701 outsb(IE_XBUF
, buf
, length
); /* Put data in buffer */
702 outw(buf_offs
, IE_GP
); /* Rewrite where packet starts */
704 /* should work without that outb() (Crynwr used it) */
705 /*outb(MM_MUX, IE_MMODE);*/ /* Xmt buffer to EDLC bus */
706 outb(MM_EN_XMT
| MM_MUX
, IE_MMODE
); /* Begin transmission */
707 outb(XM_ALL
, EDLC_XMASK
); /* Cause interrupt after completion or fail */
709 restore_flags(flags
);
711 netif_wake_queue(dev
);
713 if (NI5010_DEBUG
) show_registers(dev
);
716 extern void chipset_init(struct net_device
*dev
, int startp
)
718 /* FIXME: Move some stuff here */
719 PRINTK3((KERN_DEBUG
"%s: doing NOTHING in chipset_init\n", dev
->name
));
722 static void show_registers(struct net_device
*dev
)
724 int ioaddr
= dev
->base_addr
;
726 PRINTK3((KERN_DEBUG
"%s: XSTAT %#2.2x\n", dev
->name
, inb(EDLC_XSTAT
)));
727 PRINTK3((KERN_DEBUG
"%s: XMASK %#2.2x\n", dev
->name
, inb(EDLC_XMASK
)));
728 PRINTK3((KERN_DEBUG
"%s: RSTAT %#2.2x\n", dev
->name
, inb(EDLC_RSTAT
)));
729 PRINTK3((KERN_DEBUG
"%s: RMASK %#2.2x\n", dev
->name
, inb(EDLC_RMASK
)));
730 PRINTK3((KERN_DEBUG
"%s: RMODE %#2.2x\n", dev
->name
, inb(EDLC_RMODE
)));
731 PRINTK3((KERN_DEBUG
"%s: XMODE %#2.2x\n", dev
->name
, inb(EDLC_XMODE
)));
732 PRINTK3((KERN_DEBUG
"%s: ISTAT %#2.2x\n", dev
->name
, inb(IE_ISTAT
)));
736 static struct net_device dev_ni5010
= { init
: ni5010_probe
};
740 MODULE_PARM(io
, "i");
741 MODULE_PARM(irq
, "i");
743 int init_module(void)
747 PRINTK2((KERN_DEBUG
"%s: entering init_module\n", boardname
));
749 if(io <= 0 || irq == 0){
750 printk(KERN_WARNING "%s: Autoprobing not allowed for modules.\n", boardname);
751 printk(KERN_WARNING "%s: Set symbols 'io' and 'irq'\n", boardname);
756 printk(KERN_WARNING
"%s: Autoprobing for modules is hazardous, trying anyway..\n", boardname
);
759 PRINTK2((KERN_DEBUG
"%s: init_module irq=%#2x, io=%#3x\n", boardname
, irq
, io
));
761 dev_ni5010
.base_addr
=io
;
762 if ((result
= register_netdev(&dev_ni5010
)) != 0) {
763 PRINTK((KERN_WARNING
"%s: register_netdev returned %d.\n",
773 PRINTK2((KERN_DEBUG
"%s: entering cleanup_module\n", boardname
));
775 unregister_netdev(&dev_ni5010
);
777 release_region(dev_ni5010
.base_addr
, NI5010_IO_EXTENT
);
778 if (dev_ni5010
.priv
!= NULL
){
779 kfree(dev_ni5010
.priv
);
780 dev_ni5010
.priv
= NULL
;
787 * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c ni5010.c"
789 * kept-new-versions: 5