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