xref: /netbsd-src/sys/dev/qbus/if_il.c (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1 /*	$NetBSD: if_il.c,v 1.1 2001/05/06 15:30:46 ragge Exp $	*/
2 /*
3  * Copyright (c) 1982, 1986 Regents of the University of California.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by the University of
17  *	California, Berkeley and its contributors.
18  * 4. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)if_il.c	7.8 (Berkeley) 12/16/90
35  */
36 
37 /*
38  * Interlan Ethernet Communications Controller interface
39  */
40 #include "opt_inet.h"
41 #include "opt_ns.h"
42 
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/mbuf.h>
46 #include <sys/buf.h>
47 #include <sys/protosw.h>
48 #include <sys/socket.h>
49 #include <sys/ioctl.h>
50 #include <sys/errno.h>
51 #include <sys/syslog.h>
52 #include <sys/device.h>
53 
54 #include <net/if.h>
55 #include <net/if_ether.h>
56 #include <net/if_dl.h>
57 
58 #ifdef INET
59 #include <netinet/in.h>
60 #endif
61 
62 #ifdef NS
63 #include <netns/ns.h>
64 #include <netns/ns_if.h>
65 #endif
66 
67 #include <machine/bus.h>
68 
69 #include <dev/qbus/ubareg.h>
70 #include <dev/qbus/ubavar.h>
71 #include <dev/qbus/if_uba.h>
72 
73 #include <dev/qbus/if_il.h>
74 #include <dev/qbus/if_ilreg.h>
75 
76 /*
77  * Ethernet software status per interface.
78  *
79  * Each interface is referenced by a network interface structure,
80  * is_if, which the routing code uses to locate the interface.
81  * This structure contains the output queue for the interface, its address, ...
82  * We also have, for each interface, a UBA interface structure, which
83  * contains information about the UNIBUS resources held by the interface:
84  * map registers, buffered data paths, etc.  Information is cached in this
85  * structure for use by the if_uba.c routines in running the interface
86  * efficiently.
87  */
88 
89 struct	il_softc {
90 	struct	device sc_dev;		/* Configuration common part */
91 	struct	ethercom sc_ec;		/* Ethernet common part */
92 #define	sc_if	sc_ec.ec_if		/* network-visible interface */
93 	struct	evcnt sc_cintrcnt;	/* Command interrupts */
94 	struct  evcnt sc_rintrcnt;	/* Receive interrupts */
95 	bus_space_tag_t sc_iot;
96 	bus_addr_t sc_ioh;
97 	bus_dma_tag_t sc_dmat;
98 	struct	ubinfo sc_ui;
99 
100 	struct	ifuba sc_ifuba;		/* UNIBUS resources */
101 	int	sc_flags;
102 #define	ILF_RCVPENDING	0x2		/* start rcv in ilcint */
103 #define	ILF_STATPENDING	0x4		/* stat cmd pending */
104 #define	ILF_RUNNING	0x8		/* board is running */
105 #define	ILF_SETADDR	0x10		/* physical address is changed */
106 	short	sc_lastcmd;		/* can't read csr, so must save it */
107 	short	sc_scaninterval;	/* interval of stat collection */
108 #define	ILWATCHINTERVAL	60		/* once every 60 seconds */
109 	union {
110 	    struct	il_stats isu_stats;	/* holds on-board statistics */
111 	    struct	ether_addr isu_maddrs[63];	/* multicast addrs */
112 	}	sc_isu;
113 #define sc_stats	sc_isu.isu_stats
114 #define sc_maddrs	sc_isu.isu_maddrs
115 	struct	il_stats sc_sum;	/* summation over time */
116 	int	sc_ubaddr;		/* mapping registers of is_stats */
117 };
118 
119 static	int ilmatch(struct device *, struct cfdata *, void *);
120 static	void ilattach(struct device *, struct device *, void *);
121 static	void ilcint(void *);
122 static	void ilrint(void *);
123 static	void ilreset(struct device *);
124 static	int ilwait(struct il_softc *, char *);
125 static	int ilinit(struct ifnet *);
126 static	void ilstart(struct ifnet *);
127 static	void ilwatch(struct ifnet *);
128 static	void iltotal(struct il_softc *);
129 static	void ilstop(struct ifnet *, int);
130 
131 struct	cfattach il_ca = {
132 	sizeof(struct il_softc), ilmatch, ilattach
133 };
134 
135 #define IL_WCSR(csr, val) \
136 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, csr, val)
137 #define IL_RCSR(csr) \
138 	bus_space_read_2(sc->sc_iot, sc->sc_ioh, csr)
139 #define LOWORD(x)	((int)(x) & 0xffff)
140 #define HIWORD(x)	(((int)(x) >> 16) & 0x3)
141 
142 int
143 ilmatch(struct device *parent, struct cfdata *cf, void *aux)
144 {
145 	struct uba_attach_args *ua = aux;
146 	volatile int i;
147 
148 	bus_space_write_2(ua->ua_iot, ua->ua_ioh, IL_CSR, ILC_OFFLINE|IL_CIE);
149 	DELAY(100000);
150 	i = bus_space_read_2(ua->ua_iot, ua->ua_ioh, IL_CSR); /* clear CDONE */
151 
152 	return 1;
153 }
154 
155 /*
156  * Interface exists: make available by filling in network interface
157  * record.  System will initialize the interface when it is ready
158  * to accept packets.  A STATUS command is done to get the ethernet
159  * address and other interesting data.
160  */
161 void
162 ilattach(struct device *parent, struct device *self, void *aux)
163 {
164 	struct uba_attach_args *ua = aux;
165 	struct il_softc *sc = (struct il_softc *)self;
166 	struct ifnet *ifp = &sc->sc_if;
167 	int error;
168 
169 	sc->sc_iot = ua->ua_iot;
170 	sc->sc_ioh = ua->ua_ioh;
171 	sc->sc_dmat = ua->ua_dmat;
172 
173 	/*
174 	 * Map interrupt vectors and reset function.
175 	 */
176 	uba_intr_establish(ua->ua_icookie, ua->ua_cvec, ilcint,
177 	    sc, &sc->sc_cintrcnt);
178 	evcnt_attach_dynamic(&sc->sc_cintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
179 	    sc->sc_dev.dv_xname, "intr");
180 	uba_intr_establish(ua->ua_icookie, ua->ua_cvec-4, ilrint,
181 	    sc, &sc->sc_rintrcnt);
182 	evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
183 	    sc->sc_dev.dv_xname, "intr");
184 	uba_reset_establish(ilreset, &sc->sc_dev);
185 
186 	/*
187 	 * Reset the board and map the statistics
188 	 * buffer onto the Unibus.
189 	 */
190 	IL_WCSR(IL_CSR, ILC_RESET);
191 	(void)ilwait(sc, "reset");
192 	sc->sc_ui.ui_size = sizeof(struct il_stats);
193 	sc->sc_ui.ui_vaddr = (caddr_t)&sc->sc_stats;
194 	if ((error = uballoc((struct uba_softc *)parent, &sc->sc_ui, 0)))
195 		return printf(": failed uballoc, error = %d\n", error);
196 
197 	IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
198 	IL_WCSR(IL_BCR, sizeof(struct il_stats));
199 	IL_WCSR(IL_CSR, ((sc->sc_ui.ui_baddr >> 2) & IL_EUA)|ILC_STAT);
200 	(void)ilwait(sc, "status");
201 	ubfree((struct uba_softc *)parent, &sc->sc_ui);
202 	printf("%s: module=%s firmware=%s\n", sc->sc_dev.dv_xname,
203 		sc->sc_stats.ils_module, sc->sc_stats.ils_firmware);
204 	printf("%s: hardware address %s\n", sc->sc_dev.dv_xname,
205 		ether_sprintf(sc->sc_stats.ils_addr));
206 
207 	strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
208 	ifp->if_softc = sc;
209 	ifp->if_flags = IFF_BROADCAST;
210 	ifp->if_init = ilinit;
211 	ifp->if_stop = ilstop;
212 	ifp->if_ioctl = ether_ioctl;
213 	ifp->if_start = ilstart;
214 	ifp->if_watchdog = ilwatch;
215 
216 	if_attach(ifp);
217 	ether_ifattach(ifp, sc->sc_stats.ils_addr);
218 }
219 
220 void
221 ilstop(struct ifnet *ifp, int a)
222 {
223 	struct il_softc *sc = ifp->if_softc;
224 
225 	IL_WCSR(IL_CSR, ILC_RESET);
226 }
227 
228 
229 int
230 ilwait(struct il_softc *sc, char *op)
231 {
232 
233 	while ((IL_RCSR(IL_CSR)&IL_CDONE) == 0)
234 		;
235 	if (IL_RCSR(IL_CSR)&IL_STATUS) {
236 		char bits[64];
237 
238 		printf("%s: %s failed, csr=%s\n", sc->sc_dev.dv_xname, op,
239 		    bitmask_snprintf(IL_RCSR(IL_CSR), IL_BITS, bits,
240 		    sizeof(bits)));
241 		return (-1);
242 	}
243 	return (0);
244 }
245 
246 /*
247  * Reset of interface after UNIBUS reset.
248  * If interface is on specified uba, reset its state.
249  */
250 void
251 ilreset(struct device *dev)
252 {
253 	struct il_softc *sc = (void *)dev;
254 
255 	printf(" %s", sc->sc_dev.dv_xname);
256 	sc->sc_if.if_flags &= ~IFF_RUNNING;
257 	sc->sc_flags &= ~ILF_RUNNING;
258 	ilinit(&sc->sc_if);
259 }
260 
261 /*
262  * Initialization of interface; clear recorded pending
263  * operations, and reinitialize UNIBUS usage.
264  */
265 int
266 ilinit(struct ifnet *ifp)
267 {
268 	struct il_softc *sc = ifp->if_softc;
269 	int s;
270 
271 	if (sc->sc_flags & ILF_RUNNING)
272 		return 0;
273 
274 	if ((ifp->if_flags & IFF_RUNNING) == 0) {
275 		if (if_ubainit(&sc->sc_ifuba, (void *)sc->sc_dev.dv_parent,
276 		    ETHER_MAX_LEN)) {
277 			printf("%s: can't initialize\n", sc->sc_dev.dv_xname);
278 			sc->sc_if.if_flags &= ~IFF_UP;
279 			return 0;
280 		}
281 		sc->sc_ui.ui_size = sizeof(sc->sc_isu);
282 		sc->sc_ui.ui_vaddr = (caddr_t)&sc->sc_isu;
283 		uballoc((void *)sc->sc_dev.dv_parent, &sc->sc_ui, 0);
284 	}
285 	sc->sc_scaninterval = ILWATCHINTERVAL;
286 	ifp->if_timer = sc->sc_scaninterval;
287 
288 	/*
289 	 * Turn off source address insertion (it's faster this way),
290 	 * and set board online.  Former doesn't work if board is
291 	 * already online (happens on ubareset), so we put it offline
292 	 * first.
293 	 */
294 	s = splnet();
295 	IL_WCSR(IL_CSR, ILC_RESET);
296 	if (ilwait(sc, "hardware diag")) {
297  		sc->sc_if.if_flags &= ~IFF_UP;
298  		splx(s);
299  		return 0;
300  	}
301 	IL_WCSR(IL_CSR, ILC_CISA);
302 	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
303 		;
304 	/*
305 	 * If we must reprogram this board's physical ethernet
306 	 * address (as for secondary XNS interfaces), we do so
307 	 * before putting it on line, and starting receive requests.
308 	 * If you try this on an older 1010 board, it will total
309 	 * wedge the board.
310 	 */
311 	if (sc->sc_flags & ILF_SETADDR) {
312 		bcopy((caddr_t)LLADDR(ifp->if_sadl),
313 		    (caddr_t)&sc->sc_isu, ETHER_ADDR_LEN);
314 		IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
315 		IL_WCSR(IL_BCR, ETHER_ADDR_LEN);
316 		IL_WCSR(IL_CSR, ((sc->sc_ui.ui_baddr >> 2) & IL_EUA)|ILC_LDPA);
317 		if (ilwait(sc, "setaddr"))
318 			return 0;
319 		IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
320 		IL_WCSR(IL_BCR, sizeof (struct il_stats));
321 		IL_WCSR(IL_CSR, ((sc->sc_ui.ui_baddr >> 2) & IL_EUA)|ILC_STAT);
322 		if (ilwait(sc, "verifying setaddr"))
323 			return 0;
324 		if (bcmp((caddr_t)sc->sc_stats.ils_addr,
325 		    (caddr_t)LLADDR(ifp->if_sadl), ETHER_ADDR_LEN) != 0) {
326 			printf("%s: setaddr didn't work\n",
327 			    sc->sc_dev.dv_xname);
328 			return 0;
329 		}
330 	}
331 #ifdef MULTICAST
332 	if (is->is_if.if_flags & IFF_PROMISC) {
333 		addr->il_csr = ILC_PRMSC;
334 		if (ilwait(ui, "all multi"))
335 			return 0;
336 	} else if (is->is_if.if_flags & IFF_ALLMULTI) {
337 	too_many_multis:
338 		addr->il_csr = ILC_ALLMC;
339 		if (ilwait(ui, "all multi"))
340 			return 0;
341 	else {
342 		int i;
343 		register struct ether_addr *ep = is->is_maddrs;
344 		struct ether_multi *enm;
345 		struct ether_multistep step;
346 		/*
347 		 * Step through our list of multicast addresses.  If we have
348 		 * too many multicast addresses, or if we have to listen to
349 		 * a range of multicast addresses, turn on reception of all
350 		 * multicasts.
351 		 */
352 		i = 0;
353 		ETHER_FIRST_MULTI(step, &is->is_ac, enm);
354 		while (enm != NULL) {
355 			if (++i > 63 && k != 0) {
356 				break;
357 			}
358 			*ep++ = *(struct ether_addr *)enm->enm_addrlo;
359 			ETHER_NEXT_MULTI(step, enm);
360 		}
361 		if (i = 0) {
362 			/* no multicasts! */
363 		} else if (i <= 63) {
364 			addr->il_bar = is->is_ubaddr & 0xffff;
365 			addr->il_bcr = i * sizeof (struct ether_addr);
366 			addr->il_csr = ((is->is_ubaddr >> 2) & IL_EUA)|
367 						LC_LDGRPS;
368 			if (ilwait(ui, "load multi"))
369 				return;
370 		} else {
371 		    is->is_if.if_flags |= IFF_ALLMULTI;
372 		    goto too_many_multis;
373 		}
374 	}
375 #endif MULTI
376 	/*
377 	 * Set board online.
378 	 * Hang receive buffer and start any pending
379 	 * writes by faking a transmit complete.
380 	 * Receive bcr is not a multiple of 8 so buffer
381 	 * chaining can't happen.
382 	 */
383 	IL_WCSR(IL_CSR, ILC_ONLINE);
384 	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
385 		;
386 
387 	IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_r.ifrw_info));
388 	IL_WCSR(IL_BCR, sizeof(struct il_rheader) + ETHERMTU + 6);
389 	IL_WCSR(IL_CSR,
390 	    ((sc->sc_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE);
391 	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
392 		;
393 	ifp->if_flags |= IFF_RUNNING | IFF_OACTIVE;
394 	sc->sc_flags |= ILF_RUNNING;
395 	sc->sc_lastcmd = 0;
396 	ilcint(sc);
397 	splx(s);
398 	return 0;
399 }
400 
401 /*
402  * Start output on interface.
403  * Get another datagram to send off of the interface queue,
404  * and map it to the interface before starting the output.
405  */
406 void
407 ilstart(struct ifnet *ifp)
408 {
409 	struct il_softc *sc = ifp->if_softc;
410         int len;
411 	struct mbuf *m;
412 	short csr;
413 
414 	IF_DEQUEUE(&ifp->if_snd, m);
415 	if (m == 0) {
416 		if ((sc->sc_flags & ILF_STATPENDING) == 0)
417 			return;
418 		IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
419 		IL_WCSR(IL_BCR, sizeof (struct il_stats));
420 		csr = ((sc->sc_ui.ui_baddr >> 2) & IL_EUA)|ILC_STAT|IL_RIE|IL_CIE;
421 		sc->sc_flags &= ~ILF_STATPENDING;
422 		goto startcmd;
423 	}
424 	len = if_wubaput(&sc->sc_ifuba, m);
425 	/*
426 	 * Ensure minimum packet length.
427 	 * This makes the safe assumtion that there are no virtual holes
428 	 * after the data.
429 	 * For security, it might be wise to zero out the added bytes,
430 	 * but we're mainly interested in speed at the moment.
431 	 */
432 	if (len - sizeof(struct ether_header) < ETHERMIN)
433 		len = ETHERMIN + sizeof(struct ether_header);
434 #ifdef notdef
435 	if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
436 		UBAPURGE(is->is_ifuba.ifu_uba, is->is_ifuba.ifu_w.ifrw_bdp);
437 #endif
438 	IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_w.ifrw_info));
439 	IL_WCSR(IL_BCR, len);
440 	csr =
441 	  ((sc->sc_ifuba.ifu_w.ifrw_info >> 2) & IL_EUA)|ILC_XMIT|IL_CIE|IL_RIE;
442 
443 startcmd:
444 	sc->sc_lastcmd = csr & IL_CMD;
445 	IL_WCSR(IL_CSR, csr);
446 	ifp->if_flags |= IFF_OACTIVE;
447 	return;
448 }
449 
450 /*
451  * Command done interrupt.
452  */
453 void
454 ilcint(void *arg)
455 {
456 	struct il_softc *sc = arg;
457 	short csr;
458 
459 	if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0) {
460 		char bits[64];
461 
462 		printf("%s: stray xmit interrupt, csr=%s\n",
463 		    sc->sc_dev.dv_xname,
464 		    bitmask_snprintf(IL_RCSR(IL_CSR), IL_BITS, bits,
465 		    sizeof(bits)));
466 		return;
467 	}
468 
469 	csr = IL_RCSR(IL_CSR);
470 	/*
471 	 * Hang receive buffer if it couldn't
472 	 * be done earlier (in ilrint).
473 	 */
474 	if (sc->sc_flags & ILF_RCVPENDING) {
475 		int s;
476 
477 		IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_r.ifrw_info));
478 		IL_WCSR(IL_BCR, sizeof(struct il_rheader) + ETHERMTU + 6);
479 		IL_WCSR(IL_CSR,
480 		  ((sc->sc_ifuba.ifu_r.ifrw_info>>2) & IL_EUA)|ILC_RCV|IL_RIE);
481 		s = splhigh();
482 		while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
483 			;
484 		splx(s);
485 		sc->sc_flags &= ~ILF_RCVPENDING;
486 	}
487 	sc->sc_if.if_flags &= ~IFF_OACTIVE;
488 	csr &= IL_STATUS;
489 	switch (sc->sc_lastcmd) {
490 
491 	case ILC_XMIT:
492 		sc->sc_if.if_opackets++;
493 		if (csr > ILERR_RETRIES)
494 			sc->sc_if.if_oerrors++;
495 		break;
496 
497 	case ILC_STAT:
498 		if (csr == ILERR_SUCCESS)
499 			iltotal(sc);
500 		break;
501 	}
502 	if_wubaend(&sc->sc_ifuba);
503 	ilstart(&sc->sc_if);
504 }
505 
506 /*
507  * Ethernet interface receiver interrupt.
508  * If input error just drop packet.
509  * Otherwise purge input buffered data path and examine
510  * packet to determine type.  If can't determine length
511  * from type, then have to drop packet.  Othewise decapsulate
512  * packet based on type and pass to type specific higher-level
513  * input routine.
514  */
515 void
516 ilrint(void *arg)
517 {
518 	struct il_softc *sc = arg;
519 	struct il_rheader *il;
520     	struct mbuf *m;
521 	int len, s;
522 
523 	sc->sc_if.if_ipackets++;
524 #ifdef notyet
525 	if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
526 		UBAPURGE(is->is_ifuba.ifu_uba, is->is_ifuba.ifu_r.ifrw_bdp);
527 #endif
528 	il = (struct il_rheader *)(sc->sc_ifuba.ifu_r.ifrw_addr);
529 	len = il->ilr_length - sizeof(struct il_rheader);
530 	if ((il->ilr_status&(ILFSTAT_A|ILFSTAT_C)) || len < 46 ||
531 	    len > ETHERMTU) {
532 		sc->sc_if.if_ierrors++;
533 #ifdef notdef
534 		if (sc->sc_if.if_ierrors % 100 == 0)
535 			printf("il%d: += 100 input errors\n", unit);
536 #endif
537 		goto setup;
538 	}
539 
540 	if (len == 0)
541 		goto setup;
542 
543 	/*
544 	 * Pull packet off interface.
545 	 */
546 	m = if_rubaget(&sc->sc_ifuba, &sc->sc_if, len);
547 	if (m == NULL)
548 		goto setup;
549 
550 	/* Shave off status hdr */
551 	m_adj(m, 4);
552 	(*sc->sc_if.if_input)(&sc->sc_if, m);
553 setup:
554 	/*
555 	 * Reset for next packet if possible.
556 	 * If waiting for transmit command completion, set flag
557 	 * and wait until command completes.
558 	 */
559 	if (sc->sc_if.if_flags & IFF_OACTIVE) {
560 		sc->sc_flags |= ILF_RCVPENDING;
561 		return;
562 	}
563 	IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_r.ifrw_info));
564 	IL_WCSR(IL_BCR, sizeof(struct il_rheader) + ETHERMTU + 6);
565 	IL_WCSR(IL_CSR,
566 	    ((sc->sc_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA)|ILC_RCV|IL_RIE);
567 	s = splhigh();
568 	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
569 		;
570 	splx(s);
571 }
572 /*
573  * Watchdog routine, request statistics from board.
574  */
575 void
576 ilwatch(struct ifnet *ifp)
577 {
578 	struct il_softc *sc = ifp->if_softc;
579 	int s;
580 
581 	if (sc->sc_flags & ILF_STATPENDING) {
582 		ifp->if_timer = sc->sc_scaninterval;
583 		return;
584 	}
585 	s = splnet();
586 	sc->sc_flags |= ILF_STATPENDING;
587 	if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0)
588 		ilstart(ifp);
589 	splx(s);
590 	ifp->if_timer = sc->sc_scaninterval;
591 }
592 
593 /*
594  * Total up the on-board statistics.
595  */
596 void
597 iltotal(struct il_softc *sc)
598 {
599 	struct ifnet *ifp = &sc->sc_if;
600 	u_short *interval, *sum, *end;
601 
602 	interval = &sc->sc_stats.ils_frames;
603 	sum = &sc->sc_sum.ils_frames;
604 	end = sc->sc_sum.ils_fill2;
605 	while (sum < end)
606 		*sum++ += *interval++;
607 	sc->sc_if.if_collisions = sc->sc_sum.ils_collis;
608 	if ((sc->sc_flags & ILF_SETADDR) &&
609 	    (bcmp((caddr_t)sc->sc_stats.ils_addr, LLADDR(ifp->if_sadl),
610 					ETHER_ADDR_LEN) != 0)) {
611 		log(LOG_ERR, "%s: physaddr reverted\n", sc->sc_dev.dv_xname);
612 		sc->sc_flags &= ~ILF_RUNNING;
613 		ilinit(&sc->sc_if);
614 	}
615 }
616 
617 #ifdef notyet
618 /*
619  * set ethernet address for unit
620  */
621 void
622 il_setaddr(u_char *physaddr, struct il_softc *sc)
623 {
624 	if (! (sc->sc_flags & ILF_RUNNING))
625 		return;
626 
627 	bcopy((caddr_t)physaddr, (caddr_t)is->is_addr, sizeof is->is_addr);
628 	sc->sc_flags &= ~ILF_RUNNING;
629 	sc->sc_flags |= ILF_SETADDR;
630 	ilinit(&sc->sc_if);
631 }
632 #endif
633