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