1 /* $NetBSD: if_mc.c,v 1.47 2018/06/26 06:47:58 msaitoh Exp $ */ 2 3 /*- 4 * Copyright (c) 1997 David Huang <khym@azeotrope.org> 5 * All rights reserved. 6 * 7 * Portions of this code are based on code by Denton Gentry <denny1@home.com>, 8 * Charles M. Hannum, Yanagisawa Takeshi <yanagisw@aa.ap.titech.ac.jp>, and 9 * Jason R. Thorpe. 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. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 */ 31 32 /* 33 * Driver for the AMD Am79C940 (MACE) ethernet chip, used for onboard 34 * ethernet on the Centris/Quadra 660av and Quadra 840av. 35 */ 36 37 #include <sys/cdefs.h> 38 __KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.47 2018/06/26 06:47:58 msaitoh Exp $"); 39 40 #include "opt_ddb.h" 41 #include "opt_inet.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/syslog.h> 50 #include <sys/ioctl.h> 51 #include <sys/errno.h> 52 #include <sys/device.h> 53 54 #include <uvm/uvm_extern.h> 55 56 #include <net/if.h> 57 #include <net/if_dl.h> 58 #include <net/if_ether.h> 59 #include <net/bpf.h> 60 61 #ifdef INET 62 #include <netinet/in.h> 63 #include <netinet/if_inarp.h> 64 #include <netinet/in_systm.h> 65 #include <netinet/in_var.h> 66 #include <netinet/ip.h> 67 #endif 68 69 #include <machine/bus.h> 70 #include <mac68k/dev/if_mcreg.h> 71 #include <mac68k/dev/if_mcvar.h> 72 73 hide void mcwatchdog(struct ifnet *); 74 hide int mcinit(struct mc_softc *); 75 hide int mcstop(struct mc_softc *); 76 hide int mcioctl(struct ifnet *, u_long, void *); 77 hide void mcstart(struct ifnet *); 78 hide void mcreset(struct mc_softc *); 79 80 integrate u_int maceput(struct mc_softc *, struct mbuf *); 81 integrate void mc_tint(struct mc_softc *); 82 integrate void mace_read(struct mc_softc *, void *, int); 83 integrate struct mbuf *mace_get(struct mc_softc *, void *, int); 84 static void mace_calcladrf(struct ethercom *, u_int8_t *); 85 static inline u_int16_t ether_cmp(void *, void *); 86 87 88 /* 89 * Compare two Ether/802 addresses for equality, inlined and 90 * unrolled for speed. Use this like memcmp(). 91 * 92 * XXX: Add <machine/inlines.h> for stuff like this? 93 * XXX: or maybe add it to libkern.h instead? 94 * 95 * "I'd love to have an inline assembler version of this." 96 * XXX: Who wanted that? mycroft? I wrote one, but this 97 * version in C is as good as hand-coded assembly. -gwr 98 * 99 * Please do NOT tweak this without looking at the actual 100 * assembly code generated before and after your tweaks! 101 */ 102 static inline u_int16_t 103 ether_cmp(void *one, void *two) 104 { 105 u_int16_t *a = (u_short *) one; 106 u_int16_t *b = (u_short *) two; 107 u_int16_t diff; 108 109 #ifdef m68k 110 /* 111 * The post-increment-pointer form produces the best 112 * machine code for m68k. This was carefully tuned 113 * so it compiles to just 8 short (2-byte) op-codes! 114 */ 115 diff = *a++ - *b++; 116 diff |= *a++ - *b++; 117 diff |= *a++ - *b++; 118 #else 119 /* 120 * Most modern CPUs do better with a single expresion. 121 * Note that short-cut evaluation is NOT helpful here, 122 * because it just makes the code longer, not faster! 123 */ 124 diff = (a[0] - b[0]) | (a[1] - b[1]) | (a[2] - b[2]); 125 #endif 126 127 return (diff); 128 } 129 130 #define ETHER_CMP ether_cmp 131 132 /* 133 * Interface exists: make available by filling in network interface 134 * record. System will initialize the interface when it is ready 135 * to accept packets. 136 */ 137 int 138 mcsetup(struct mc_softc *sc, u_int8_t *lladdr) 139 { 140 struct ifnet *ifp = &sc->sc_if; 141 142 /* reset the chip and disable all interrupts */ 143 NIC_PUT(sc, MACE_BIUCC, SWRST); 144 DELAY(100); 145 NIC_PUT(sc, MACE_IMR, ~0); 146 147 memcpy(sc->sc_enaddr, lladdr, ETHER_ADDR_LEN); 148 printf(": address %s\n", ether_sprintf(lladdr)); 149 150 memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); 151 ifp->if_softc = sc; 152 ifp->if_ioctl = mcioctl; 153 ifp->if_start = mcstart; 154 ifp->if_flags = 155 IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; 156 ifp->if_watchdog = mcwatchdog; 157 158 if_attach(ifp); 159 if_deferred_start_init(ifp, NULL); 160 ether_ifattach(ifp, lladdr); 161 162 return (0); 163 } 164 165 hide int 166 mcioctl(struct ifnet *ifp, u_long cmd, void *data) 167 { 168 struct mc_softc *sc = ifp->if_softc; 169 struct ifaddr *ifa; 170 171 int s = splnet(), err = 0; 172 173 switch (cmd) { 174 175 case SIOCINITIFADDR: 176 ifa = (struct ifaddr *)data; 177 ifp->if_flags |= IFF_UP; 178 mcinit(sc); 179 switch (ifa->ifa_addr->sa_family) { 180 #ifdef INET 181 case AF_INET: 182 arp_ifinit(ifp, ifa); 183 break; 184 #endif 185 default: 186 break; 187 } 188 break; 189 190 case SIOCSIFFLAGS: 191 if ((err = ifioctl_common(ifp, cmd, data)) != 0) 192 break; 193 /* XXX see the comment in ed_ioctl() about code re-use */ 194 if ((ifp->if_flags & IFF_UP) == 0 && 195 (ifp->if_flags & IFF_RUNNING) != 0) { 196 /* 197 * If interface is marked down and it is running, 198 * then stop it. 199 */ 200 mcstop(sc); 201 ifp->if_flags &= ~IFF_RUNNING; 202 } else if ((ifp->if_flags & IFF_UP) != 0 && 203 (ifp->if_flags & IFF_RUNNING) == 0) { 204 /* 205 * If interface is marked up and it is stopped, 206 * then start it. 207 */ 208 (void)mcinit(sc); 209 } else { 210 /* 211 * reset the interface to pick up any other changes 212 * in flags 213 */ 214 mcreset(sc); 215 mcstart(ifp); 216 } 217 break; 218 219 case SIOCADDMULTI: 220 case SIOCDELMULTI: 221 if ((err = ether_ioctl(ifp, cmd, data)) == ENETRESET) { 222 /* 223 * Multicast list has changed; set the hardware 224 * filter accordingly. But remember UP flag! 225 */ 226 if (ifp->if_flags & IFF_RUNNING) 227 mcreset(sc); 228 err = 0; 229 } 230 break; 231 default: 232 err = ether_ioctl(ifp, cmd, data); 233 } 234 splx(s); 235 return (err); 236 } 237 238 /* 239 * Encapsulate a packet of type family for the local net. 240 */ 241 hide void 242 mcstart(struct ifnet *ifp) 243 { 244 struct mc_softc *sc = ifp->if_softc; 245 struct mbuf *m; 246 247 if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) 248 return; 249 250 while (1) { 251 if (ifp->if_flags & IFF_OACTIVE) 252 return; 253 254 IF_DEQUEUE(&ifp->if_snd, m); 255 if (m == 0) 256 return; 257 258 /* 259 * If bpf is listening on this interface, let it 260 * see the packet before we commit it to the wire. 261 */ 262 bpf_mtap(ifp, m, BPF_D_OUT); 263 264 /* 265 * Copy the mbuf chain into the transmit buffer. 266 */ 267 ifp->if_flags |= IFF_OACTIVE; 268 maceput(sc, m); 269 270 ifp->if_opackets++; /* # of pkts */ 271 } 272 } 273 274 /* 275 * reset and restart the MACE. Called in case of fatal 276 * hardware/software errors. 277 */ 278 hide void 279 mcreset(struct mc_softc *sc) 280 { 281 mcstop(sc); 282 mcinit(sc); 283 } 284 285 hide int 286 mcinit(struct mc_softc *sc) 287 { 288 int s; 289 u_int8_t maccc, ladrf[8]; 290 291 if (sc->sc_if.if_flags & IFF_RUNNING) 292 /* already running */ 293 return (0); 294 295 s = splnet(); 296 297 NIC_PUT(sc, MACE_BIUCC, sc->sc_biucc); 298 NIC_PUT(sc, MACE_FIFOCC, sc->sc_fifocc); 299 NIC_PUT(sc, MACE_IMR, ~0); /* disable all interrupts */ 300 NIC_PUT(sc, MACE_PLSCC, sc->sc_plscc); 301 302 NIC_PUT(sc, MACE_UTR, RTRD); /* disable reserved test registers */ 303 304 /* set MAC address */ 305 NIC_PUT(sc, MACE_IAC, ADDRCHG); 306 while (NIC_GET(sc, MACE_IAC) & ADDRCHG) 307 ; 308 NIC_PUT(sc, MACE_IAC, PHYADDR); 309 bus_space_write_multi_1(sc->sc_regt, sc->sc_regh, MACE_REG(MACE_PADR), 310 sc->sc_enaddr, ETHER_ADDR_LEN); 311 312 /* set logical address filter */ 313 mace_calcladrf(&sc->sc_ethercom, ladrf); 314 315 NIC_PUT(sc, MACE_IAC, ADDRCHG); 316 while (NIC_GET(sc, MACE_IAC) & ADDRCHG) 317 ; 318 NIC_PUT(sc, MACE_IAC, LOGADDR); 319 bus_space_write_multi_1(sc->sc_regt, sc->sc_regh, MACE_REG(MACE_LADRF), 320 ladrf, 8); 321 322 NIC_PUT(sc, MACE_XMTFC, APADXMT); 323 /* 324 * No need to autostrip padding on receive... Ethernet frames 325 * don't have a length field, unlike 802.3 frames, so the MACE 326 * can't figure out the length of the packet anyways. 327 */ 328 NIC_PUT(sc, MACE_RCVFC, 0); 329 330 maccc = ENXMT | ENRCV; 331 if (sc->sc_if.if_flags & IFF_PROMISC) 332 maccc |= PROM; 333 334 NIC_PUT(sc, MACE_MACCC, maccc); 335 336 if (sc->sc_bus_init) 337 (*sc->sc_bus_init)(sc); 338 339 /* 340 * Enable all interrupts except receive, since we use the DMA 341 * completion interrupt for that. 342 */ 343 NIC_PUT(sc, MACE_IMR, RCVINTM); 344 345 /* flag interface as "running" */ 346 sc->sc_if.if_flags |= IFF_RUNNING; 347 sc->sc_if.if_flags &= ~IFF_OACTIVE; 348 349 splx(s); 350 return (0); 351 } 352 353 /* 354 * close down an interface and free its buffers 355 * Called on final close of device, or if mcinit() fails 356 * part way through. 357 */ 358 hide int 359 mcstop(struct mc_softc *sc) 360 { 361 int s; 362 363 s = splnet(); 364 365 NIC_PUT(sc, MACE_BIUCC, SWRST); 366 DELAY(100); 367 368 sc->sc_if.if_timer = 0; 369 sc->sc_if.if_flags &= ~IFF_RUNNING; 370 371 splx(s); 372 return (0); 373 } 374 375 /* 376 * Called if any Tx packets remain unsent after 5 seconds, 377 * In all cases we just reset the chip, and any retransmission 378 * will be handled by higher level protocol timeouts. 379 */ 380 hide void 381 mcwatchdog(struct ifnet *ifp) 382 { 383 struct mc_softc *sc = ifp->if_softc; 384 385 printf("mcwatchdog: resetting chip\n"); 386 mcreset(sc); 387 } 388 389 /* 390 * stuff packet into MACE (at splnet) 391 */ 392 integrate u_int 393 maceput(struct mc_softc *sc, struct mbuf *m) 394 { 395 struct mbuf *n; 396 u_int len, totlen = 0; 397 u_char *buff; 398 399 buff = (u_char*)sc->sc_txbuf + (sc->sc_txset == 0 ? 0 : 0x800); 400 401 for (; m; m = n) { 402 u_char *data = mtod(m, u_char *); 403 len = m->m_len; 404 totlen += len; 405 memcpy(buff, data, len); 406 buff += len; 407 n = m_free(m); 408 } 409 410 if (totlen > PAGE_SIZE) 411 panic("%s: maceput: packet overflow", device_xname(sc->sc_dev)); 412 413 #if 0 414 if (totlen < ETHERMIN + sizeof(struct ether_header)) { 415 int pad = ETHERMIN + sizeof(struct ether_header) - totlen; 416 memset(sc->sc_txbuf + totlen, 0, pad); 417 totlen = ETHERMIN + sizeof(struct ether_header); 418 } 419 #endif 420 421 (*sc->sc_putpacket)(sc, totlen); 422 423 sc->sc_if.if_timer = 5; /* 5 seconds to watch for failing to transmit */ 424 return (totlen); 425 } 426 427 void 428 mcintr(void *arg) 429 { 430 struct mc_softc *sc = arg; 431 u_int8_t ir; 432 433 ir = NIC_GET(sc, MACE_IR) & ~NIC_GET(sc, MACE_IMR); 434 if (ir & JAB) { 435 #ifdef MCDEBUG 436 printf("%s: jabber error\n", device_xname(sc->sc_dev)); 437 #endif 438 sc->sc_if.if_oerrors++; 439 } 440 441 if (ir & BABL) { 442 #ifdef MCDEBUG 443 printf("%s: babble\n", device_xname(sc->sc_dev)); 444 #endif 445 sc->sc_if.if_oerrors++; 446 } 447 448 if (ir & CERR) { 449 #ifdef MCDEBUG 450 printf("%s: collision error\n", device_xname(sc->sc_dev)); 451 #endif 452 sc->sc_if.if_collisions++; 453 } 454 455 /* 456 * Pretend we have carrier; if we don't this will be cleared 457 * shortly. 458 */ 459 sc->sc_havecarrier = 1; 460 461 if (ir & XMTINT) 462 mc_tint(sc); 463 464 if (ir & RCVINT) 465 mc_rint(sc); 466 } 467 468 integrate void 469 mc_tint(struct mc_softc *sc) 470 { 471 u_int8_t /* xmtrc,*/ xmtfs; 472 473 /* xmtrc = */ NIC_GET(sc, MACE_XMTRC); 474 xmtfs = NIC_GET(sc, MACE_XMTFS); 475 476 if ((xmtfs & XMTSV) == 0) 477 return; 478 479 if (xmtfs & UFLO) { 480 printf("%s: underflow\n", device_xname(sc->sc_dev)); 481 mcreset(sc); 482 return; 483 } 484 485 if (xmtfs & LCOL) { 486 printf("%s: late collision\n", device_xname(sc->sc_dev)); 487 sc->sc_if.if_oerrors++; 488 sc->sc_if.if_collisions++; 489 } 490 491 if (xmtfs & MORE) 492 /* Real number is unknown. */ 493 sc->sc_if.if_collisions += 2; 494 else if (xmtfs & ONE) 495 sc->sc_if.if_collisions++; 496 else if (xmtfs & RTRY) { 497 printf("%s: excessive collisions\n", device_xname(sc->sc_dev)); 498 sc->sc_if.if_collisions += 16; 499 sc->sc_if.if_oerrors++; 500 } 501 502 if (xmtfs & LCAR) { 503 sc->sc_havecarrier = 0; 504 printf("%s: lost carrier\n", device_xname(sc->sc_dev)); 505 sc->sc_if.if_oerrors++; 506 } 507 508 sc->sc_if.if_flags &= ~IFF_OACTIVE; 509 sc->sc_if.if_timer = 0; 510 if_schedule_deferred_start(&sc->sc_if); 511 } 512 513 void 514 mc_rint(struct mc_softc *sc) 515 { 516 #define rxf sc->sc_rxframe 517 u_int len; 518 519 len = (rxf.rx_rcvcnt | ((rxf.rx_rcvsts & 0xf) << 8)) - 4; 520 521 #ifdef MCDEBUG 522 if (rxf.rx_rcvsts & 0xf0) 523 printf("%s: rcvcnt %02x rcvsts %02x rntpc 0x%02x rcvcc 0x%02x\n", 524 device_xname(sc->sc_dev), rxf.rx_rcvcnt, rxf.rx_rcvsts, 525 rxf.rx_rntpc, rxf.rx_rcvcc); 526 #endif 527 528 if (rxf.rx_rcvsts & OFLO) { 529 printf("%s: receive FIFO overflow\n", device_xname(sc->sc_dev)); 530 sc->sc_if.if_ierrors++; 531 return; 532 } 533 534 if (rxf.rx_rcvsts & CLSN) 535 sc->sc_if.if_collisions++; 536 537 if (rxf.rx_rcvsts & FRAM) { 538 #ifdef MCDEBUG 539 printf("%s: framing error\n", device_xname(sc->sc_dev)); 540 #endif 541 sc->sc_if.if_ierrors++; 542 return; 543 } 544 545 if (rxf.rx_rcvsts & FCS) { 546 #ifdef MCDEBUG 547 printf("%s: frame control checksum error\n", device_xname(sc->sc_dev)); 548 #endif 549 sc->sc_if.if_ierrors++; 550 return; 551 } 552 553 mace_read(sc, rxf.rx_frame, len); 554 #undef rxf 555 } 556 557 integrate void 558 mace_read(struct mc_softc *sc, void *pkt, int len) 559 { 560 struct ifnet *ifp = &sc->sc_if; 561 struct mbuf *m; 562 563 if (len <= sizeof(struct ether_header) || 564 len > ETHERMTU + sizeof(struct ether_header)) { 565 #ifdef MCDEBUG 566 printf("%s: invalid packet size %d; dropping\n", 567 device_xname(sc->sc_dev), len); 568 #endif 569 ifp->if_ierrors++; 570 return; 571 } 572 573 m = mace_get(sc, pkt, len); 574 if (m == NULL) { 575 ifp->if_ierrors++; 576 return; 577 } 578 579 /* Pass the packet up. */ 580 if_percpuq_enqueue(ifp->if_percpuq, m); 581 } 582 583 /* 584 * Pull data off an interface. 585 * Len is length of data, with local net header stripped. 586 * We copy the data into mbufs. When full cluster sized units are present 587 * we copy into clusters. 588 */ 589 integrate struct mbuf * 590 mace_get(struct mc_softc *sc, void *pkt, int totlen) 591 { 592 struct mbuf *m; 593 struct mbuf *top, **mp; 594 int len; 595 596 MGETHDR(m, M_DONTWAIT, MT_DATA); 597 if (m == 0) 598 return (0); 599 m_set_rcvif(m, &sc->sc_if); 600 m->m_pkthdr.len = totlen; 601 len = MHLEN; 602 top = 0; 603 mp = ⊤ 604 605 while (totlen > 0) { 606 if (top) { 607 MGET(m, M_DONTWAIT, MT_DATA); 608 if (m == 0) { 609 m_freem(top); 610 return 0; 611 } 612 len = MLEN; 613 } 614 if (totlen >= MINCLSIZE) { 615 MCLGET(m, M_DONTWAIT); 616 if ((m->m_flags & M_EXT) == 0) { 617 m_free(m); 618 m_freem(top); 619 return 0; 620 } 621 len = MCLBYTES; 622 } 623 m->m_len = len = min(totlen, len); 624 memcpy(mtod(m, void *), pkt, len); 625 pkt = (char*)pkt + len; 626 totlen -= len; 627 *mp = m; 628 mp = &m->m_next; 629 } 630 631 return (top); 632 } 633 634 /* 635 * Go through the list of multicast addresses and calculate the logical 636 * address filter. 637 */ 638 void 639 mace_calcladrf(struct ethercom *ac, u_int8_t *af) 640 { 641 struct ifnet *ifp = &ac->ec_if; 642 struct ether_multi *enm; 643 u_char *cp; 644 u_int32_t crc; 645 static const u_int32_t crctab[] = { 646 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 647 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 648 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 649 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c 650 }; 651 int len; 652 struct ether_multistep step; 653 654 /* 655 * Set up multicast address filter by passing all multicast addresses 656 * through a crc generator, and then using the high order 6 bits as an 657 * index into the 64 bit logical address filter. The high order bit 658 * selects the word, while the rest of the bits select the bit within 659 * the word. 660 */ 661 662 *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0; 663 ETHER_FIRST_MULTI(step, ac, enm); 664 while (enm != NULL) { 665 if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) { 666 /* 667 * We must listen to a range of multicast addresses. 668 * For now, just accept all multicasts, rather than 669 * trying to set only those filter bits needed to match 670 * the range. (At this time, the only use of address 671 * ranges is for IP multicast routing, for which the 672 * range is big enough to require all bits set.) 673 */ 674 goto allmulti; 675 } 676 677 cp = enm->enm_addrlo; 678 crc = 0xffffffff; 679 for (len = sizeof(enm->enm_addrlo); --len >= 0;) { 680 crc ^= *cp++; 681 crc = (crc >> 4) ^ crctab[crc & 0xf]; 682 crc = (crc >> 4) ^ crctab[crc & 0xf]; 683 } 684 /* Just want the 6 most significant bits. */ 685 crc >>= 26; 686 687 /* Set the corresponding bit in the filter. */ 688 af[crc >> 3] |= 1 << (crc & 7); 689 690 ETHER_NEXT_MULTI(step, enm); 691 } 692 ifp->if_flags &= ~IFF_ALLMULTI; 693 return; 694 695 allmulti: 696 ifp->if_flags |= IFF_ALLMULTI; 697 *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0xffffffff; 698 } 699 700 static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; 701 #define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf]) 702 703 u_char 704 mc_get_enaddr(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 705 u_char *dst) 706 { 707 int i; 708 u_char b, csum; 709 710 /* 711 * The XOR of the 8 bytes of the ROM must be 0xff for it to be 712 * valid 713 */ 714 for (i = 0, csum = 0; i < 8; i++) { 715 b = bus_space_read_1(t, h, o+16*i); 716 if (i < ETHER_ADDR_LEN) 717 dst[i] = bbr(b); 718 csum ^= b; 719 } 720 721 return csum; 722 } 723