Home | History | Annotate | Line # | Download | only in ic
am7990.c revision 1.54
      1 /*	$NetBSD: am7990.c,v 1.54 1998/08/15 10:51:17 mycroft Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
      9  * Simulation Facility, NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*-
     41  * Copyright (c) 1992, 1993
     42  *	The Regents of the University of California.  All rights reserved.
     43  *
     44  * This code is derived from software contributed to Berkeley by
     45  * Ralph Campbell and Rick Macklem.
     46  *
     47  * Redistribution and use in source and binary forms, with or without
     48  * modification, are permitted provided that the following conditions
     49  * are met:
     50  * 1. Redistributions of source code must retain the above copyright
     51  *    notice, this list of conditions and the following disclaimer.
     52  * 2. Redistributions in binary form must reproduce the above copyright
     53  *    notice, this list of conditions and the following disclaimer in the
     54  *    documentation and/or other materials provided with the distribution.
     55  * 3. All advertising materials mentioning features or use of this software
     56  *    must display the following acknowledgement:
     57  *	This product includes software developed by the University of
     58  *	California, Berkeley and its contributors.
     59  * 4. Neither the name of the University nor the names of its contributors
     60  *    may be used to endorse or promote products derived from this software
     61  *    without specific prior written permission.
     62  *
     63  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     64  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     65  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     66  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     67  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     68  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     69  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     70  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     71  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     72  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     73  * SUCH DAMAGE.
     74  *
     75  *	@(#)if_le.c	8.2 (Berkeley) 11/16/93
     76  */
     77 
     78 #include "bpfilter.h"
     79 #include "rnd.h"
     80 
     81 #include <sys/param.h>
     82 #include <sys/systm.h>
     83 #include <sys/mbuf.h>
     84 #include <sys/syslog.h>
     85 #include <sys/socket.h>
     86 #include <sys/device.h>
     87 #include <sys/malloc.h>
     88 #include <sys/ioctl.h>
     89 #include <sys/errno.h>
     90 #if NRND > 0
     91 #include <sys/rnd.h>
     92 #endif
     93 
     94 #include <net/if.h>
     95 #include <net/if_dl.h>
     96 #include <net/if_ether.h>
     97 #include <net/if_media.h>
     98 
     99 #if NBPFILTER > 0
    100 #include <net/bpf.h>
    101 #include <net/bpfdesc.h>
    102 #endif
    103 
    104 #include <dev/ic/lancereg.h>
    105 #include <dev/ic/lancevar.h>
    106 #include <dev/ic/am7990reg.h>
    107 #include <dev/ic/am7990var.h>
    108 
    109 void am7990_meminit __P((struct lance_softc *));
    110 void am7990_start __P((struct ifnet *));
    111 
    112 #if defined(_KERNEL) && !defined(_LKM)
    113 #include "opt_ddb.h"
    114 #endif
    115 
    116 #ifdef DDB
    117 #define	integrate
    118 #define hide
    119 #else
    120 #define	integrate	static __inline
    121 #define hide		static
    122 #endif
    123 
    124 integrate void am7990_rint __P((struct lance_softc *));
    125 integrate void am7990_tint __P((struct lance_softc *));
    126 
    127 #ifdef LEDEBUG
    128 void am7990_recv_print __P((struct lance_softc *, int));
    129 void am7990_xmit_print __P((struct lance_softc *, int));
    130 #endif
    131 
    132 #define	ifp	(&sc->sc_ethercom.ec_if)
    133 
    134 void
    135 am7990_config(sc)
    136 	struct am7990_softc *sc;
    137 {
    138 	int mem, i;
    139 
    140 	sc->lsc.sc_meminit = am7990_meminit;
    141 	sc->lsc.sc_start = am7990_start;
    142 
    143 	lance_config(&sc->lsc);
    144 
    145 	mem = 0;
    146 	sc->lsc.sc_initaddr = mem;
    147 	mem += sizeof(struct leinit);
    148 	sc->lsc.sc_rmdaddr = mem;
    149 	mem += sizeof(struct lermd) * sc->lsc.sc_nrbuf;
    150 	sc->lsc.sc_tmdaddr = mem;
    151 	mem += sizeof(struct letmd) * sc->lsc.sc_ntbuf;
    152 	for (i = 0; i < sc->lsc.sc_nrbuf; i++, mem += LEBLEN)
    153 		sc->lsc.sc_rbufaddr[i] = mem;
    154 	for (i = 0; i < sc->lsc.sc_ntbuf; i++, mem += LEBLEN)
    155 		sc->lsc.sc_tbufaddr[i] = mem;
    156 #ifdef notyet
    157 	if (mem > ...)
    158 		panic(...);
    159 #endif
    160 }
    161 
    162 /*
    163  * Set up the initialization block and the descriptor rings.
    164  */
    165 void
    166 am7990_meminit(sc)
    167 	register struct lance_softc *sc;
    168 {
    169 	u_long a;
    170 	int bix;
    171 	struct leinit init;
    172 	struct lermd rmd;
    173 	struct letmd tmd;
    174 	u_int8_t *myaddr;
    175 
    176 #if NBPFILTER > 0
    177 	if (ifp->if_flags & IFF_PROMISC)
    178 		init.init_mode = LE_MODE_NORMAL | LE_MODE_PROM;
    179 	else
    180 #endif
    181 		init.init_mode = LE_MODE_NORMAL;
    182 	if (sc->sc_initmodemedia == 1)
    183 		init.init_mode |= LE_MODE_PSEL0;
    184 
    185 	/*
    186 	 * Update our private copy of the Ethernet address.
    187 	 * We NEED the copy so we can ensure its alignment!
    188 	 */
    189 	bcopy(LLADDR(ifp->if_sadl), sc->sc_enaddr, 6);
    190 	myaddr = sc->sc_enaddr;
    191 
    192 	init.init_padr[0] = (myaddr[1] << 8) | myaddr[0];
    193 	init.init_padr[1] = (myaddr[3] << 8) | myaddr[2];
    194 	init.init_padr[2] = (myaddr[5] << 8) | myaddr[4];
    195 	lance_setladrf(&sc->sc_ethercom, init.init_ladrf);
    196 
    197 	sc->sc_last_rd = 0;
    198 	sc->sc_first_td = sc->sc_last_td = sc->sc_no_td = 0;
    199 
    200 	a = sc->sc_addr + LE_RMDADDR(sc, 0);
    201 	init.init_rdra = a;
    202 	init.init_rlen = (a >> 16) | ((ffs(sc->sc_nrbuf) - 1) << 13);
    203 
    204 	a = sc->sc_addr + LE_TMDADDR(sc, 0);
    205 	init.init_tdra = a;
    206 	init.init_tlen = (a >> 16) | ((ffs(sc->sc_ntbuf) - 1) << 13);
    207 
    208 	(*sc->sc_copytodesc)(sc, &init, LE_INITADDR(sc), sizeof(init));
    209 
    210 	/*
    211 	 * Set up receive ring descriptors.
    212 	 */
    213 	for (bix = 0; bix < sc->sc_nrbuf; bix++) {
    214 		a = sc->sc_addr + LE_RBUFADDR(sc, bix);
    215 		rmd.rmd0 = a;
    216 		rmd.rmd1_hadr = a >> 16;
    217 		rmd.rmd1_bits = LE_R1_OWN;
    218 		rmd.rmd2 = -LEBLEN | LE_XMD2_ONES;
    219 		rmd.rmd3 = 0;
    220 		(*sc->sc_copytodesc)(sc, &rmd, LE_RMDADDR(sc, bix),
    221 		    sizeof(rmd));
    222 	}
    223 
    224 	/*
    225 	 * Set up transmit ring descriptors.
    226 	 */
    227 	for (bix = 0; bix < sc->sc_ntbuf; bix++) {
    228 		a = sc->sc_addr + LE_TBUFADDR(sc, bix);
    229 		tmd.tmd0 = a;
    230 		tmd.tmd1_hadr = a >> 16;
    231 		tmd.tmd1_bits = 0;
    232 		tmd.tmd2 = 0 | LE_XMD2_ONES;
    233 		tmd.tmd3 = 0;
    234 		(*sc->sc_copytodesc)(sc, &tmd, LE_TMDADDR(sc, bix),
    235 		    sizeof(tmd));
    236 	}
    237 }
    238 
    239 integrate void
    240 am7990_rint(sc)
    241 	struct lance_softc *sc;
    242 {
    243 	register int bix;
    244 	int rp;
    245 	struct lermd rmd;
    246 
    247 	bix = sc->sc_last_rd;
    248 
    249 	/* Process all buffers with valid data. */
    250 	for (;;) {
    251 		rp = LE_RMDADDR(sc, bix);
    252 		(*sc->sc_copyfromdesc)(sc, &rmd, rp, sizeof(rmd));
    253 
    254 		if (rmd.rmd1_bits & LE_R1_OWN)
    255 			break;
    256 
    257 		if (rmd.rmd1_bits & LE_R1_ERR) {
    258 			if (rmd.rmd1_bits & LE_R1_ENP) {
    259 #ifdef LEDEBUG
    260 				if ((rmd.rmd1_bits & LE_R1_OFLO) == 0) {
    261 					if (rmd.rmd1_bits & LE_R1_FRAM)
    262 						printf("%s: framing error\n",
    263 						    sc->sc_dev.dv_xname);
    264 					if (rmd.rmd1_bits & LE_R1_CRC)
    265 						printf("%s: crc mismatch\n",
    266 						    sc->sc_dev.dv_xname);
    267 				}
    268 #endif
    269 			} else {
    270 				if (rmd.rmd1_bits & LE_R1_OFLO)
    271 					printf("%s: overflow\n",
    272 					    sc->sc_dev.dv_xname);
    273 			}
    274 			if (rmd.rmd1_bits & LE_R1_BUFF)
    275 				printf("%s: receive buffer error\n",
    276 				    sc->sc_dev.dv_xname);
    277 			ifp->if_ierrors++;
    278 		} else if ((rmd.rmd1_bits & (LE_R1_STP | LE_R1_ENP)) !=
    279 		    (LE_R1_STP | LE_R1_ENP)) {
    280 			printf("%s: dropping chained buffer\n",
    281 			    sc->sc_dev.dv_xname);
    282 			ifp->if_ierrors++;
    283 		} else {
    284 #ifdef LEDEBUG
    285 			if (sc->sc_debug)
    286 				am7990_recv_print(sc, sc->sc_last_rd);
    287 #endif
    288 			lance_read(sc, LE_RBUFADDR(sc, bix),
    289 				   (int)rmd.rmd3 - 4);
    290 		}
    291 
    292 		rmd.rmd1_bits = LE_R1_OWN;
    293 		rmd.rmd2 = -LEBLEN | LE_XMD2_ONES;
    294 		rmd.rmd3 = 0;
    295 		(*sc->sc_copytodesc)(sc, &rmd, rp, sizeof(rmd));
    296 
    297 #ifdef LEDEBUG
    298 		if (sc->sc_debug)
    299 			printf("sc->sc_last_rd = %x, rmd: "
    300 			       "ladr %04x, hadr %02x, flags %02x, "
    301 			       "bcnt %04x, mcnt %04x\n",
    302 				sc->sc_last_rd,
    303 				rmd.rmd0, rmd.rmd1_hadr, rmd.rmd1_bits,
    304 				rmd.rmd2, rmd.rmd3);
    305 #endif
    306 
    307 		if (++bix == sc->sc_nrbuf)
    308 			bix = 0;
    309 	}
    310 
    311 	sc->sc_last_rd = bix;
    312 }
    313 
    314 integrate void
    315 am7990_tint(sc)
    316 	register struct lance_softc *sc;
    317 {
    318 	register int bix;
    319 	struct letmd tmd;
    320 
    321 	bix = sc->sc_first_td;
    322 
    323 	for (;;) {
    324 		if (sc->sc_no_td <= 0)
    325 			break;
    326 
    327 		(*sc->sc_copyfromdesc)(sc, &tmd, LE_TMDADDR(sc, bix),
    328 		    sizeof(tmd));
    329 
    330 #ifdef LEDEBUG
    331 		if (sc->sc_debug)
    332 			printf("trans tmd: "
    333 			    "ladr %04x, hadr %02x, flags %02x, "
    334 			    "bcnt %04x, mcnt %04x\n",
    335 			    tmd.tmd0, tmd.tmd1_hadr, tmd.tmd1_bits,
    336 			    tmd.tmd2, tmd.tmd3);
    337 #endif
    338 
    339 		if (tmd.tmd1_bits & LE_T1_OWN)
    340 			break;
    341 
    342 		ifp->if_flags &= ~IFF_OACTIVE;
    343 
    344 		if (tmd.tmd1_bits & LE_T1_ERR) {
    345 			if (tmd.tmd3 & LE_T3_BUFF)
    346 				printf("%s: transmit buffer error\n",
    347 				    sc->sc_dev.dv_xname);
    348 			else if (tmd.tmd3 & LE_T3_UFLO)
    349 				printf("%s: underflow\n", sc->sc_dev.dv_xname);
    350 			if (tmd.tmd3 & (LE_T3_BUFF | LE_T3_UFLO)) {
    351 				lance_reset(sc);
    352 				return;
    353 			}
    354 			if (tmd.tmd3 & LE_T3_LCAR) {
    355 				sc->sc_havecarrier = 0;
    356 				if (sc->sc_nocarrier)
    357 					(*sc->sc_nocarrier)(sc);
    358 				else
    359 					printf("%s: lost carrier\n",
    360 					    sc->sc_dev.dv_xname);
    361 			}
    362 			if (tmd.tmd3 & LE_T3_LCOL)
    363 				ifp->if_collisions++;
    364 			if (tmd.tmd3 & LE_T3_RTRY) {
    365 				printf("%s: excessive collisions, tdr %d\n",
    366 				    sc->sc_dev.dv_xname,
    367 				    tmd.tmd3 & LE_T3_TDR_MASK);
    368 				ifp->if_collisions += 16;
    369 			}
    370 			ifp->if_oerrors++;
    371 		} else {
    372 			if (tmd.tmd1_bits & LE_T1_ONE)
    373 				ifp->if_collisions++;
    374 			else if (tmd.tmd1_bits & LE_T1_MORE)
    375 				/* Real number is unknown. */
    376 				ifp->if_collisions += 2;
    377 			ifp->if_opackets++;
    378 		}
    379 
    380 		if (++bix == sc->sc_ntbuf)
    381 			bix = 0;
    382 
    383 		--sc->sc_no_td;
    384 	}
    385 
    386 	sc->sc_first_td = bix;
    387 
    388 	am7990_start(ifp);
    389 
    390 	if (sc->sc_no_td == 0)
    391 		ifp->if_timer = 0;
    392 }
    393 
    394 /*
    395  * Controller interrupt.
    396  */
    397 int
    398 am7990_intr(arg)
    399 	register void *arg;
    400 {
    401 	register struct lance_softc *sc = arg;
    402 	register u_int16_t isr;
    403 
    404 	isr = (*sc->sc_rdcsr)(sc, LE_CSR0) | sc->sc_saved_csr0;
    405 	sc->sc_saved_csr0 = 0;
    406 #ifdef LEDEBUG
    407 	if (sc->sc_debug)
    408 		printf("%s: am7990_intr entering with isr=%04x\n",
    409 		    sc->sc_dev.dv_xname, isr);
    410 #endif
    411 	if ((isr & LE_C0_INTR) == 0)
    412 		return (0);
    413 
    414 	(*sc->sc_wrcsr)(sc, LE_CSR0,
    415 	    isr & (LE_C0_INEA | LE_C0_BABL | LE_C0_MISS | LE_C0_MERR |
    416 		   LE_C0_RINT | LE_C0_TINT | LE_C0_IDON));
    417 	if (isr & LE_C0_ERR) {
    418 		if (isr & LE_C0_BABL) {
    419 #ifdef LEDEBUG
    420 			printf("%s: babble\n", sc->sc_dev.dv_xname);
    421 #endif
    422 			ifp->if_oerrors++;
    423 		}
    424 #if 0
    425 		if (isr & LE_C0_CERR) {
    426 			printf("%s: collision error\n", sc->sc_dev.dv_xname);
    427 			ifp->if_collisions++;
    428 		}
    429 #endif
    430 		if (isr & LE_C0_MISS) {
    431 #ifdef LEDEBUG
    432 			printf("%s: missed packet\n", sc->sc_dev.dv_xname);
    433 #endif
    434 			ifp->if_ierrors++;
    435 		}
    436 		if (isr & LE_C0_MERR) {
    437 			printf("%s: memory error\n", sc->sc_dev.dv_xname);
    438 			lance_reset(sc);
    439 			return (1);
    440 		}
    441 	}
    442 
    443 	if ((isr & LE_C0_RXON) == 0) {
    444 		printf("%s: receiver disabled\n", sc->sc_dev.dv_xname);
    445 		ifp->if_ierrors++;
    446 		lance_reset(sc);
    447 		return (1);
    448 	}
    449 	if ((isr & LE_C0_TXON) == 0) {
    450 		printf("%s: transmitter disabled\n", sc->sc_dev.dv_xname);
    451 		ifp->if_oerrors++;
    452 		lance_reset(sc);
    453 		return (1);
    454 	}
    455 
    456 	/*
    457 	 * Pretend we have carrier; if we don't this will be cleared
    458 	 * shortly.
    459 	 */
    460 	sc->sc_havecarrier = 1;
    461 
    462 	if (isr & LE_C0_RINT)
    463 		am7990_rint(sc);
    464 	if (isr & LE_C0_TINT)
    465 		am7990_tint(sc);
    466 
    467 #if NRND > 0
    468 	rnd_add_uint32(&sc->rnd_source, isr);
    469 #endif
    470 
    471 	return (1);
    472 }
    473 
    474 #undef ifp
    475 
    476 /*
    477  * Setup output on interface.
    478  * Get another datagram to send off of the interface queue, and map it to the
    479  * interface before starting the output.
    480  * Called only at splnet or interrupt level.
    481  */
    482 void
    483 am7990_start(ifp)
    484 	register struct ifnet *ifp;
    485 {
    486 	register struct lance_softc *sc = ifp->if_softc;
    487 	register int bix;
    488 	register struct mbuf *m;
    489 	struct letmd tmd;
    490 	int rp;
    491 	int len;
    492 
    493 	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
    494 		return;
    495 
    496 	bix = sc->sc_last_td;
    497 
    498 	for (;;) {
    499 		rp = LE_TMDADDR(sc, bix);
    500 		(*sc->sc_copyfromdesc)(sc, &tmd, rp, sizeof(tmd));
    501 
    502 		if (tmd.tmd1_bits & LE_T1_OWN) {
    503 			ifp->if_flags |= IFF_OACTIVE;
    504 			printf("missing buffer, no_td = %d, last_td = %d\n",
    505 			    sc->sc_no_td, sc->sc_last_td);
    506 		}
    507 
    508 		IF_DEQUEUE(&ifp->if_snd, m);
    509 		if (m == 0)
    510 			break;
    511 
    512 #if NBPFILTER > 0
    513 		/*
    514 		 * If BPF is listening on this interface, let it see the packet
    515 		 * before we commit it to the wire.
    516 		 */
    517 		if (ifp->if_bpf)
    518 			bpf_mtap(ifp->if_bpf, m);
    519 #endif
    520 
    521 		/*
    522 		 * Copy the mbuf chain into the transmit buffer.
    523 		 */
    524 		len = lance_put(sc, LE_TBUFADDR(sc, bix), m);
    525 
    526 #ifdef LEDEBUG
    527 		if (len > ETHERMTU + sizeof(struct ether_header))
    528 			printf("packet length %d\n", len);
    529 #endif
    530 
    531 		ifp->if_timer = 5;
    532 
    533 		/*
    534 		 * Init transmit registers, and set transmit start flag.
    535 		 */
    536 		tmd.tmd1_bits = LE_T1_OWN | LE_T1_STP | LE_T1_ENP;
    537 		tmd.tmd2 = -len | LE_XMD2_ONES;
    538 		tmd.tmd3 = 0;
    539 
    540 		(*sc->sc_copytodesc)(sc, &tmd, rp, sizeof(tmd));
    541 
    542 #ifdef LEDEBUG
    543 		if (sc->sc_debug)
    544 			am7990_xmit_print(sc, sc->sc_last_td);
    545 #endif
    546 
    547 		(*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA | LE_C0_TDMD);
    548 
    549 		if (++bix == sc->sc_ntbuf)
    550 			bix = 0;
    551 
    552 		if (++sc->sc_no_td == sc->sc_ntbuf) {
    553 			ifp->if_flags |= IFF_OACTIVE;
    554 			break;
    555 		}
    556 
    557 	}
    558 
    559 	sc->sc_last_td = bix;
    560 }
    561 
    562 #ifdef LEDEBUG
    563 void
    564 am7990_recv_print(sc, no)
    565 	struct lance_softc *sc;
    566 	int no;
    567 {
    568 	struct lermd rmd;
    569 	u_int16_t len;
    570 	struct ether_header eh;
    571 
    572 	(*sc->sc_copyfromdesc)(sc, &rmd, LE_RMDADDR(sc, no), sizeof(rmd));
    573 	len = rmd.rmd3;
    574 	printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
    575 	    len);
    576 	printf("%s: status %04x\n", sc->sc_dev.dv_xname,
    577 	    (*sc->sc_rdcsr)(sc, LE_CSR0));
    578 	printf("%s: ladr %04x, hadr %02x, flags %02x, bcnt %04x, mcnt %04x\n",
    579 	    sc->sc_dev.dv_xname,
    580 	    rmd.rmd0, rmd.rmd1_hadr, rmd.rmd1_bits, rmd.rmd2, rmd.rmd3);
    581 	if (len >= sizeof(eh)) {
    582 		(*sc->sc_copyfrombuf)(sc, &eh, LE_RBUFADDR(sc, no), sizeof(eh));
    583 		printf("%s: dst %s", sc->sc_dev.dv_xname,
    584 			ether_sprintf(eh.ether_dhost));
    585 		printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
    586 			ntohs(eh.ether_type));
    587 	}
    588 }
    589 
    590 void
    591 am7990_xmit_print(sc, no)
    592 	struct lance_softc *sc;
    593 	int no;
    594 {
    595 	struct letmd tmd;
    596 	u_int16_t len;
    597 	struct ether_header eh;
    598 
    599 	(*sc->sc_copyfromdesc)(sc, &tmd, LE_TMDADDR(sc, no), sizeof(tmd));
    600 	len = -tmd.tmd2;
    601 	printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
    602 	    len);
    603 	printf("%s: status %04x\n", sc->sc_dev.dv_xname,
    604 	    (*sc->sc_rdcsr)(sc, LE_CSR0));
    605 	printf("%s: ladr %04x, hadr %02x, flags %02x, bcnt %04x, mcnt %04x\n",
    606 	    sc->sc_dev.dv_xname,
    607 	    tmd.tmd0, tmd.tmd1_hadr, tmd.tmd1_bits, tmd.tmd2, tmd.tmd3);
    608 	if (len >= sizeof(eh)) {
    609 		(*sc->sc_copyfrombuf)(sc, &eh, LE_TBUFADDR(sc, no), sizeof(eh));
    610 		printf("%s: dst %s", sc->sc_dev.dv_xname,
    611 			ether_sprintf(eh.ether_dhost));
    612 		printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
    613 		    ntohs(eh.ether_type));
    614 	}
    615 }
    616 #endif /* LEDEBUG */
    617