Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
/*	$NetBSD: if_il.c,v 1.35.2.1 2019/10/23 19:43:25 martin Exp $	*/
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)if_il.c	7.8 (Berkeley) 12/16/90
 */

/*
 * Interlan Ethernet Communications Controller interface
 */

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_il.c,v 1.35.2.1 2019/10/23 19:43:25 martin Exp $");

#include "opt_inet.h"

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/buf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/device.h>

#include <net/if.h>
#include <net/if_ether.h>
#include <net/if_dl.h>

#ifdef INET
#include <netinet/in.h>
#endif


#include <sys/bus.h>

#include <dev/qbus/ubareg.h>
#include <dev/qbus/ubavar.h>
#include <dev/qbus/if_uba.h>

#include <dev/qbus/if_il.h>
#include <dev/qbus/if_ilreg.h>

/*
 * Ethernet software status per interface.
 *
 * Each interface is referenced by a network interface structure,
 * is_if, which the routing code uses to locate the interface.
 * This structure contains the output queue for the interface, its address, ...
 * We also have, for each interface, a UBA interface structure, which
 * contains information about the UNIBUS resources held by the interface:
 * map registers, buffered data paths, etc.  Information is cached in this
 * structure for use by the if_uba.c routines in running the interface
 * efficiently.
 */

struct	il_softc {
	device_t sc_dev;		/* Configuration common part */
	struct ethercom sc_ec;		/* Ethernet common part */
#define	sc_if	sc_ec.ec_if		/* network-visible interface */
	struct evcnt sc_cintrcnt;	/* Command interrupts */
	struct evcnt sc_rintrcnt;	/* Receive interrupts */
	bus_space_tag_t sc_iot;
	bus_addr_t sc_ioh;
	bus_dma_tag_t sc_dmat;
	struct	ubinfo sc_ui;

	struct	ifuba sc_ifuba;		/* UNIBUS resources */
	int	sc_flags;
#define	ILF_RCVPENDING	0x2		/* start rcv in ilcint */
#define	ILF_STATPENDING	0x4		/* stat cmd pending */
#define	ILF_RUNNING	0x8		/* board is running */
#define	ILF_SETADDR	0x10		/* physical address is changed */
	short	sc_lastcmd;		/* can't read csr, so must save it */
	short	sc_scaninterval;	/* interval of stat collection */
#define	ILWATCHINTERVAL	60		/* once every 60 seconds */
	union {
	    struct	il_stats isu_stats;	/* holds on-board statistics */
	    struct	ether_addr isu_maddrs[63];	/* multicast addrs */
	}	sc_isu;
#define sc_stats	sc_isu.isu_stats
#define sc_maddrs	sc_isu.isu_maddrs
	struct	il_stats sc_sum;	/* summation over time */
	int	sc_ubaddr;		/* mapping registers of is_stats */
};

static	int ilmatch(device_t, cfdata_t, void *);
static	void ilattach(device_t, device_t, void *);
static	void ilcint(void *);
static	void ilrint(void *);
static	void ilreset(device_t);
static	int ilwait(struct il_softc *, const char *);
static	int ilinit(struct ifnet *);
static	void ilstart(struct ifnet *);
static	void ilwatch(struct ifnet *);
static	void iltotal(struct il_softc *);
static	void ilstop(struct ifnet *, int);

CFATTACH_DECL_NEW(il, sizeof(struct il_softc),
    ilmatch, ilattach, NULL, NULL);

#define IL_WCSR(csr, val) \
	bus_space_write_2(sc->sc_iot, sc->sc_ioh, csr, val)
#define IL_RCSR(csr) \
	bus_space_read_2(sc->sc_iot, sc->sc_ioh, csr)
#define LOWORD(x)	((int)(x) & 0xffff)
#define HIWORD(x)	(((int)(x) >> 16) & 0x3)

int
ilmatch(device_t parent, cfdata_t cf, void *aux)
{
	struct uba_attach_args *ua = aux;

	bus_space_write_2(ua->ua_iot, ua->ua_ioh, IL_CSR,
	    ILC_OFFLINE | IL_CIE);
	DELAY(100000);
	bus_space_read_2(ua->ua_iot, ua->ua_ioh, IL_CSR); /* clear CDONE */

	return 1;
}

/*
 * Interface exists: make available by filling in network interface
 * record.  System will initialize the interface when it is ready
 * to accept packets.  A STATUS command is done to get the ethernet
 * address and other interesting data.
 */
void
ilattach(device_t parent, device_t self, void *aux)
{
	struct uba_attach_args *ua = aux;
	struct il_softc *sc = device_private(self);
	struct ifnet *ifp = &sc->sc_if;
	int error;

	sc->sc_dev = self;
	sc->sc_iot = ua->ua_iot;
	sc->sc_ioh = ua->ua_ioh;
	sc->sc_dmat = ua->ua_dmat;

	/*
	 * Map interrupt vectors and reset function.
	 */
	uba_intr_establish(ua->ua_icookie, ua->ua_cvec, ilcint,
	    sc, &sc->sc_cintrcnt);
	evcnt_attach_dynamic(&sc->sc_cintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
	    device_xname(sc->sc_dev), "intr");
	uba_intr_establish(ua->ua_icookie, ua->ua_cvec-4, ilrint,
	    sc, &sc->sc_rintrcnt);
	evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
	    device_xname(sc->sc_dev), "intr");
	uba_reset_establish(ilreset, sc->sc_dev);

	/*
	 * Reset the board and map the statistics
	 * buffer onto the Unibus.
	 */
	IL_WCSR(IL_CSR, ILC_RESET);
	(void)ilwait(sc, "reset");
	sc->sc_ui.ui_size = sizeof(struct il_stats);
	sc->sc_ui.ui_vaddr = (void *)&sc->sc_stats;
	if ((error = uballoc(device_private(parent), &sc->sc_ui, 0)))
		return printf(": failed uballoc, error = %d\n", error);

	IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
	IL_WCSR(IL_BCR, sizeof(struct il_stats));
	IL_WCSR(IL_CSR, ((sc->sc_ui.ui_baddr >> 2) & IL_EUA) | ILC_STAT);
	(void)ilwait(sc, "status");
	ubfree(device_private(parent), &sc->sc_ui);
	printf("%s: module=%s firmware=%s\n", device_xname(sc->sc_dev),
		sc->sc_stats.ils_module, sc->sc_stats.ils_firmware);
	printf("%s: hardware address %s\n", device_xname(sc->sc_dev),
		ether_sprintf(sc->sc_stats.ils_addr));

	strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
	ifp->if_softc = sc;
	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_init = ilinit;
	ifp->if_stop = ilstop;
	ifp->if_ioctl = ether_ioctl;
	ifp->if_start = ilstart;
	ifp->if_watchdog = ilwatch;
	IFQ_SET_READY(&ifp->if_snd);

	if_attach(ifp);
	ether_ifattach(ifp, sc->sc_stats.ils_addr);
}

void
ilstop(struct ifnet *ifp, int a)
{
	struct il_softc *sc = ifp->if_softc;

	IL_WCSR(IL_CSR, ILC_RESET);
}


int
ilwait(struct il_softc *sc, const char *op)
{

	while ((IL_RCSR(IL_CSR)&IL_CDONE) == 0)
		;
	if (IL_RCSR(IL_CSR)&IL_STATUS) {
		char bits[64];

		snprintb(bits, sizeof(bits), IL_BITS, IL_RCSR(IL_CSR));
		aprint_error_dev(sc->sc_dev, "%s failed, csr=%s\n", op, bits);
		return -1;
	}
	return 0;
}

/*
 * Reset of interface after UNIBUS reset.
 * If interface is on specified uba, reset its state.
 */
void
ilreset(device_t dev)
{
	struct il_softc *sc = (void *)dev;

	printf(" %s", device_xname(sc->sc_dev));
	sc->sc_if.if_flags &= ~IFF_RUNNING;
	sc->sc_flags &= ~ILF_RUNNING;
	ilinit(&sc->sc_if);
}

/*
 * Initialization of interface; clear recorded pending
 * operations, and reinitialize UNIBUS usage.
 */
int
ilinit(struct ifnet *ifp)
{
	struct il_softc *sc = ifp->if_softc;
	int s;

	if (sc->sc_flags & ILF_RUNNING)
		return 0;

	if ((ifp->if_flags & IFF_RUNNING) == 0) {
		if (if_ubainit(&sc->sc_ifuba,
		    device_private(device_parent(sc->sc_dev)),
		    ETHER_MAX_LEN)) {
			aprint_error_dev(sc->sc_dev, "can't initialize\n");
			sc->sc_if.if_flags &= ~IFF_UP;
			return 0;
		}
		sc->sc_ui.ui_size = sizeof(sc->sc_isu);
		sc->sc_ui.ui_vaddr = (void *)&sc->sc_isu;
		uballoc(device_private(device_parent(sc->sc_dev)),
		    &sc->sc_ui, 0);
	}
	sc->sc_scaninterval = ILWATCHINTERVAL;
	ifp->if_timer = sc->sc_scaninterval;

	/*
	 * Turn off source address insertion (it's faster this way),
	 * and set board online.  Former doesn't work if board is
	 * already online (happens on ubareset), so we put it offline
	 * first.
	 */
	s = splnet();
	IL_WCSR(IL_CSR, ILC_RESET);
	if (ilwait(sc, "hardware diag")) {
		sc->sc_if.if_flags &= ~IFF_UP;
		goto out;
	}
	IL_WCSR(IL_CSR, ILC_CISA);
	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
		;
	/*
	 * If we must reprogram this board's physical ethernet
	 * address (as for secondary XNS interfaces), we do so
	 * before putting it on line, and starting receive requests.
	 * If you try this on an older 1010 board, it will total
	 * wedge the board.
	 */
	if (sc->sc_flags & ILF_SETADDR) {
		memcpy(&sc->sc_isu, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
		IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
		IL_WCSR(IL_BCR, ETHER_ADDR_LEN);
		IL_WCSR(IL_CSR,
		    ((sc->sc_ui.ui_baddr >> 2) & IL_EUA) | ILC_LDPA);
		if (ilwait(sc, "setaddr"))
			goto out;
		IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
		IL_WCSR(IL_BCR, sizeof (struct il_stats));
		IL_WCSR(IL_CSR,
		    ((sc->sc_ui.ui_baddr >> 2) & IL_EUA) | ILC_STAT);
		if (ilwait(sc, "verifying setaddr"))
			goto out;
		if (memcmp(sc->sc_stats.ils_addr,
		    CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN) != 0) {
			aprint_error_dev(sc->sc_dev, "setaddr didn't work\n");
			goto out;
		}
	}
	if (sc->sc_if.if_flags & IFF_PROMISC) {
		IL_WCSR(IL_CSR, ILC_PRMSC);
		if (ilwait(sc, "all multi"))
			goto out;
	} else if (sc->sc_if.if_flags & IFF_ALLMULTI) {
too_many_multis:
		IL_WCSR(IL_CSR, ILC_ALLMC);
		if (ilwait(sc, "all multi"))
			goto out;
	} else {
		int i;
		struct ethercom *ec = &sc->sc_ec;
		register struct ether_addr *ep = sc->sc_maddrs;
		struct ether_multi *enm;
		struct ether_multistep step;
		/*
		 * Step through our list of multicast addresses.  If we have
		 * too many multicast addresses, or if we have to listen to
		 * a range of multicast addresses, turn on reception of all
		 * multicasts.
		 */
		i = 0;
		ETHER_LOCK(ec);
		ETHER_FIRST_MULTI(step, ec, enm);
		while (enm != NULL) {
			if (++i > 63 /* && k != 0 */) {
				break;
			}
			*ep++ = *(struct ether_addr *)enm->enm_addrlo;
			ETHER_NEXT_MULTI(step, enm);
		}
		ETHER_UNLOCK(ec);
		if (i == 0) {
			/* no multicasts! */
		} else if (i <= 63) {
			IL_WCSR(IL_BAR, sc->sc_ubaddr & 0xffff);
			IL_WCSR(IL_BCR, i * sizeof(struct ether_addr));
			IL_WCSR(IL_CSR,
			    ((sc->sc_ubaddr >> 2) & IL_EUA) | ILC_LDGRPS);
			if (ilwait(sc, "load multi"))
				goto out;
		} else {
			sc->sc_if.if_flags |= IFF_ALLMULTI;
			goto too_many_multis;
		}
	}
	/*
	 * Set board online.
	 * Hang receive buffer and start any pending
	 * writes by faking a transmit complete.
	 * Receive bcr is not a multiple of 8 so buffer
	 * chaining can't happen.
	 */
	IL_WCSR(IL_CSR, ILC_ONLINE);
	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
		;

	IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_r.ifrw_info));
	IL_WCSR(IL_BCR, sizeof(struct il_rheader) + ETHERMTU + 6);
	IL_WCSR(IL_CSR,
	    ((sc->sc_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA) | ILC_RCV | IL_RIE);
	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
		;
	ifp->if_flags |= IFF_RUNNING | IFF_OACTIVE;
	sc->sc_flags |= ILF_RUNNING;
	sc->sc_lastcmd = 0;
	ilcint(sc);
out:
	splx(s);
	return 0;
}

/*
 * Start output on interface.
 * Get another datagram to send off of the interface queue,
 * and map it to the interface before starting the output.
 */
void
ilstart(struct ifnet *ifp)
{
	struct il_softc *sc = ifp->if_softc;
	int len;
	struct mbuf *m;
	short csr;

	IFQ_DEQUEUE(&ifp->if_snd, m);
	if (m == 0) {
		if ((sc->sc_flags & ILF_STATPENDING) == 0)
			return;
		IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr));
		IL_WCSR(IL_BCR, sizeof (struct il_stats));
		csr = ((sc->sc_ui.ui_baddr >> 2) & IL_EUA)
		    | ILC_STAT | IL_RIE | IL_CIE;
		sc->sc_flags &= ~ILF_STATPENDING;
		goto startcmd;
	}
	len = if_wubaput(&sc->sc_ifuba, m);
#ifdef notdef
	if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
		UBAPURGE(is->is_ifuba.ifu_uba, is->is_ifuba.ifu_w.ifrw_bdp);
#endif
	IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_w.ifrw_info));
	IL_WCSR(IL_BCR, len);
	csr = ((sc->sc_ifuba.ifu_w.ifrw_info >> 2) & IL_EUA)
	    | ILC_XMIT | IL_CIE | IL_RIE;

startcmd:
	sc->sc_lastcmd = csr & IL_CMD;
	IL_WCSR(IL_CSR, csr);
	ifp->if_flags |= IFF_OACTIVE;
	return;
}

/*
 * Command done interrupt.
 */
void
ilcint(void *arg)
{
	struct il_softc *sc = arg;
	short csr;

	if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0) {
		char bits[64];

		snprintb(bits, sizeof(bits), IL_BITS, IL_RCSR(IL_CSR));
		aprint_error_dev(sc->sc_dev,
				 "stray xmit interrupt, csr=%s\n", bits);
		return;
	}

	csr = IL_RCSR(IL_CSR);
	/*
	 * Hang receive buffer if it couldn't
	 * be done earlier (in ilrint).
	 */
	if (sc->sc_flags & ILF_RCVPENDING) {
		int s;

		IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_r.ifrw_info));
		IL_WCSR(IL_BCR, sizeof(struct il_rheader) + ETHERMTU + 6);
		IL_WCSR(IL_CSR, ((sc->sc_ifuba.ifu_r.ifrw_info>>2) & IL_EUA)
		    | ILC_RCV | IL_RIE);
		s = splhigh();
		while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
			;
		splx(s);
		sc->sc_flags &= ~ILF_RCVPENDING;
	}
	sc->sc_if.if_flags &= ~IFF_OACTIVE;
	csr &= IL_STATUS;
	switch (sc->sc_lastcmd) {

	case ILC_XMIT:
		sc->sc_if.if_opackets++;
		if (csr > ILERR_RETRIES)
			sc->sc_if.if_oerrors++;
		break;

	case ILC_STAT:
		if (csr == ILERR_SUCCESS)
			iltotal(sc);
		break;
	}
	if_wubaend(&sc->sc_ifuba);
	ilstart(&sc->sc_if);
}

/*
 * Ethernet interface receiver interrupt.
 * If input error just drop packet.
 * Otherwise purge input buffered data path and examine
 * packet to determine type.  If can't determine length
 * from type, then have to drop packet.  Othewise decapsulate
 * packet based on type and pass to type specific higher-level
 * input routine.
 */
void
ilrint(void *arg)
{
	struct il_softc *sc = arg;
	struct il_rheader *il;
	struct mbuf *m;
	int len, s;

#ifdef notyet
	if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
		UBAPURGE(is->is_ifuba.ifu_uba, is->is_ifuba.ifu_r.ifrw_bdp);
#endif
	il = (struct il_rheader *)(sc->sc_ifuba.ifu_r.ifrw_addr);
	len = il->ilr_length - sizeof(struct il_rheader);
	if ((il->ilr_status&(ILFSTAT_A | ILFSTAT_C)) || len < 46 ||
	    len > ETHERMTU) {
		sc->sc_if.if_ierrors++;
#ifdef notdef
		if (sc->sc_if.if_ierrors % 100 == 0)
			printf("il%d: += 100 input errors\n", unit);
#endif
		goto setup;
	}

	if (len == 0)
		goto setup;

	/*
	 * Pull packet off interface.
	 */
	m = if_rubaget(&sc->sc_ifuba, &sc->sc_if, len);
	if (m == NULL)
		goto setup;

	/* Shave off status hdr */
	m_adj(m, 4);
	if_percpuq_enqueue((&sc->sc_if)->if_percpuq, m);
setup:
	/*
	 * Reset for next packet if possible.
	 * If waiting for transmit command completion, set flag
	 * and wait until command completes.
	 */
	if (sc->sc_if.if_flags & IFF_OACTIVE) {
		sc->sc_flags |= ILF_RCVPENDING;
		return;
	}
	IL_WCSR(IL_BAR, LOWORD(sc->sc_ifuba.ifu_r.ifrw_info));
	IL_WCSR(IL_BCR, sizeof(struct il_rheader) + ETHERMTU + 6);
	IL_WCSR(IL_CSR,
	    ((sc->sc_ifuba.ifu_r.ifrw_info >> 2) & IL_EUA) | ILC_RCV | IL_RIE);
	s = splhigh();
	while ((IL_RCSR(IL_CSR) & IL_CDONE) == 0)
		;
	splx(s);
}
/*
 * Watchdog routine, request statistics from board.
 */
void
ilwatch(struct ifnet *ifp)
{
	struct il_softc *sc = ifp->if_softc;
	int s;

	if (sc->sc_flags & ILF_STATPENDING) {
		ifp->if_timer = sc->sc_scaninterval;
		return;
	}
	s = splnet();
	sc->sc_flags |= ILF_STATPENDING;
	if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0)
		ilstart(ifp);
	splx(s);
	ifp->if_timer = sc->sc_scaninterval;
}

/*
 * Total up the on-board statistics.
 */
void
iltotal(struct il_softc *sc)
{
	struct ifnet *ifp = &sc->sc_if;
	u_short *interval, *sum, *end;

	interval = &sc->sc_stats.ils_frames;
	sum = &sc->sc_sum.ils_frames;
	end = sc->sc_sum.ils_fill2;
	while (sum < end)
		*sum++ += *interval++;
	sc->sc_if.if_collisions = sc->sc_sum.ils_collis;
	if ((sc->sc_flags & ILF_SETADDR) &&
	    (memcmp(sc->sc_stats.ils_addr, CLLADDR(ifp->if_sadl),
		    ETHER_ADDR_LEN) != 0)) {
		log(LOG_ERR, "%s: physaddr reverted\n",
		    device_xname(sc->sc_dev));
		sc->sc_flags &= ~ILF_RUNNING;
		ilinit(&sc->sc_if);
	}
}

#ifdef notyet
/*
 * set ethernet address for unit
 */
void
il_setaddr(u_char *physaddr, struct il_softc *sc)
{
	if (! (sc->sc_flags & ILF_RUNNING))
		return;

	memcpy((void *)is->is_addr, (void *)physaddr, sizeof is->is_addr);
	sc->sc_flags &= ~ILF_RUNNING;
	sc->sc_flags |= ILF_SETADDR;
	ilinit(&sc->sc_if);
}
#endif