am79c950.c revision 1.25 1 /* $NetBSD: am79c950.c,v 1.25 2009/03/14 14:46:01 dsl Exp $ */
2
3 /*-
4 * Copyright (c) 1997 David Huang <khym (at) bga.com>
5 * All rights reserved.
6 *
7 * Portions of this code are based on code by Denton Gentry <denny1 (at) home.com>,
8 * Charles M. Hannum, Yanagisawa Takeshi <yanagisw (at) 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.25 2009/03/14 14:46:01 dsl 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(struct ifnet *);
80 hide int mcinit(struct mc_softc *sc);
81 hide int mcstop(struct mc_softc *sc);
82 hide int mcioctl(struct ifnet *ifp, u_long cmd, void *data);
83 hide void mcstart(struct ifnet *ifp);
84 hide void mcreset(struct mc_softc *sc);
85
86 integrate u_int maceput(struct mc_softc *sc, struct mbuf *m0);
87 integrate void mc_tint(struct mc_softc *sc);
88 integrate void mace_read(struct mc_softc *, uint8_t *, int);
89 integrate struct mbuf *mace_get(struct mc_softc *, uint8_t *, int);
90 static void mace_calcladrf(struct ethercom *ac, u_int8_t *af);
91 static inline u_int16_t ether_cmp(void *, void *);
92 static int mc_mediachange(struct ifnet *);
93 static void mc_mediastatus(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 SIOCINITIFADDR:
194 ifa = (struct ifaddr *)data;
195 ifp->if_flags |= IFF_UP;
196 mcinit(sc);
197 switch (ifa->ifa_addr->sa_family) {
198 #ifdef INET
199 case AF_INET:
200 arp_ifinit(ifp, ifa);
201 break;
202 #endif
203 default:
204 break;
205 }
206 break;
207
208 case SIOCSIFFLAGS:
209 if ((err = ifioctl_common(ifp, cmd, data)) != 0)
210 break;
211 /* XXX see the comment in ed_ioctl() about code re-use */
212 if ((ifp->if_flags & IFF_UP) == 0 &&
213 (ifp->if_flags & IFF_RUNNING) != 0) {
214 /*
215 * If interface is marked down and it is running,
216 * then stop it.
217 */
218 mcstop(sc);
219 ifp->if_flags &= ~IFF_RUNNING;
220 } else if ((ifp->if_flags & IFF_UP) != 0 &&
221 (ifp->if_flags & IFF_RUNNING) == 0) {
222 /*
223 * If interface is marked up and it is stopped,
224 * then start it.
225 */
226 (void)mcinit(sc);
227 } else {
228 /*
229 * reset the interface to pick up any other changes
230 * in flags
231 */
232 mcreset(sc);
233 mcstart(ifp);
234 }
235 break;
236
237 case SIOCADDMULTI:
238 case SIOCDELMULTI:
239 if ((err = ether_ioctl(ifp, cmd, data)) == ENETRESET) {
240 /*
241 * Multicast list has changed; set the hardware
242 * filter accordingly. But remember UP flag!
243 */
244 if (ifp->if_flags & IFF_RUNNING)
245 mcreset(sc);
246 err = 0;
247 }
248 break;
249
250 case SIOCGIFMEDIA:
251 case SIOCSIFMEDIA:
252 ifr = (struct ifreq *) data;
253 err = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
254 break;
255
256 default:
257 err = ether_ioctl(ifp, cmd, data);
258 break;
259 }
260 splx(s);
261 return (err);
262 }
263
264 /*
265 * Encapsulate a packet of type family for the local net.
266 */
267 hide void
268 mcstart(ifp)
269 struct ifnet *ifp;
270 {
271 struct mc_softc *sc = ifp->if_softc;
272 struct mbuf *m;
273
274 if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
275 return;
276
277 while (1) {
278 if (ifp->if_flags & IFF_OACTIVE)
279 return;
280
281 IF_DEQUEUE(&ifp->if_snd, m);
282 if (m == 0)
283 return;
284
285 #if NBPFILTER > 0
286 /*
287 * If bpf is listening on this interface, let it
288 * see the packet before we commit it to the wire.
289 */
290 if (ifp->if_bpf)
291 bpf_mtap(ifp->if_bpf, m);
292 #endif
293
294 /*
295 * Copy the mbuf chain into the transmit buffer.
296 */
297 ifp->if_flags |= IFF_OACTIVE;
298 maceput(sc, m);
299
300 ifp->if_opackets++; /* # of pkts */
301 }
302 }
303
304 /*
305 * reset and restart the MACE. Called in case of fatal
306 * hardware/software errors.
307 */
308 hide void
309 mcreset(sc)
310 struct mc_softc *sc;
311 {
312 mcstop(sc);
313 mcinit(sc);
314 }
315
316 hide int
317 mcinit(sc)
318 struct mc_softc *sc;
319 {
320 int s;
321 u_int8_t maccc, ladrf[8];
322
323 if (sc->sc_if.if_flags & IFF_RUNNING)
324 /* already running */
325 return (0);
326
327 s = splnet();
328
329 NIC_PUT(sc, MACE_BIUCC, sc->sc_biucc);
330 NIC_PUT(sc, MACE_FIFOCC, sc->sc_fifocc);
331 NIC_PUT(sc, MACE_IMR, ~0); /* disable all interrupts */
332 NIC_PUT(sc, MACE_PLSCC, sc->sc_plscc);
333
334 NIC_PUT(sc, MACE_UTR, RTRD); /* disable reserved test registers */
335
336 /* set MAC address */
337 NIC_PUT(sc, MACE_IAC, ADDRCHG);
338 while (NIC_GET(sc, MACE_IAC) & ADDRCHG)
339 ;
340 NIC_PUT(sc, MACE_IAC, PHYADDR);
341 bus_space_write_multi_1(sc->sc_regt, sc->sc_regh, MACE_REG(MACE_PADR),
342 sc->sc_enaddr, ETHER_ADDR_LEN);
343
344 /* set logical address filter */
345 mace_calcladrf(&sc->sc_ethercom, ladrf);
346
347 NIC_PUT(sc, MACE_IAC, ADDRCHG);
348 while (NIC_GET(sc, MACE_IAC) & ADDRCHG)
349 ;
350 NIC_PUT(sc, MACE_IAC, LOGADDR);
351 bus_space_write_multi_1(sc->sc_regt, sc->sc_regh, MACE_REG(MACE_LADRF),
352 ladrf, 8);
353
354 NIC_PUT(sc, MACE_XMTFC, APADXMT);
355 /*
356 * No need to autostrip padding on receive... Ethernet frames
357 * don't have a length field, unlike 802.3 frames, so the MACE
358 * can't figure out the length of the packet anyways.
359 */
360 NIC_PUT(sc, MACE_RCVFC, 0);
361
362 maccc = ENXMT | ENRCV;
363 if (sc->sc_if.if_flags & IFF_PROMISC)
364 maccc |= PROM;
365
366 NIC_PUT(sc, MACE_MACCC, maccc);
367
368 if (sc->sc_bus_init)
369 (*sc->sc_bus_init)(sc);
370
371 /*
372 * Enable all interrupts except receive, since we use the DMA
373 * completion interrupt for that.
374 */
375 NIC_PUT(sc, MACE_IMR, RCVINTM);
376
377 /* flag interface as "running" */
378 sc->sc_if.if_flags |= IFF_RUNNING;
379 sc->sc_if.if_flags &= ~IFF_OACTIVE;
380
381 splx(s);
382 return (0);
383 }
384
385 /*
386 * close down an interface and free its buffers
387 * Called on final close of device, or if mcinit() fails
388 * part way through.
389 */
390 hide int
391 mcstop(sc)
392 struct mc_softc *sc;
393 {
394 int s = splnet();
395
396 NIC_PUT(sc, MACE_BIUCC, SWRST);
397 DELAY(100);
398
399 sc->sc_if.if_timer = 0;
400 sc->sc_if.if_flags &= ~IFF_RUNNING;
401
402 splx(s);
403 return (0);
404 }
405
406 /*
407 * Called if any Tx packets remain unsent after 5 seconds,
408 * In all cases we just reset the chip, and any retransmission
409 * will be handled by higher level protocol timeouts.
410 */
411 hide void
412 mcwatchdog(ifp)
413 struct ifnet *ifp;
414 {
415 struct mc_softc *sc = ifp->if_softc;
416
417 printf("mcwatchdog: resetting chip\n");
418 mcreset(sc);
419 }
420
421 /*
422 * stuff packet into MACE (at splnet)
423 */
424 integrate u_int
425 maceput(sc, m)
426 struct mc_softc *sc;
427 struct mbuf *m;
428 {
429 struct mbuf *n;
430 u_int len, totlen = 0;
431 u_char *buff;
432
433 buff = sc->sc_txbuf;
434
435 for (; m; m = n) {
436 u_char *data = mtod(m, u_char *);
437 len = m->m_len;
438 totlen += len;
439 memcpy(buff, data, len);
440 buff += len;
441 MFREE(m, n);
442 }
443
444 if (totlen > PAGE_SIZE)
445 panic("%s: maceput: packet overflow", sc->sc_dev.dv_xname);
446
447 #if 0
448 if (totlen < ETHERMIN + sizeof(struct ether_header)) {
449 int pad = ETHERMIN + sizeof(struct ether_header) - totlen;
450 memset(sc->sc_txbuf + totlen, 0, pad);
451 totlen = ETHERMIN + sizeof(struct ether_header);
452 }
453 #endif
454
455 (*sc->sc_putpacket)(sc, totlen);
456
457 sc->sc_if.if_timer = 5; /* 5 seconds to watch for failing to transmit */
458 return (totlen);
459 }
460
461 int
462 mcintr(arg)
463 void *arg;
464 {
465 struct mc_softc *sc = arg;
466 u_int8_t ir;
467
468 ir = NIC_GET(sc, MACE_IR) & ~NIC_GET(sc, MACE_IMR);
469 if (ir == 0)
470 return 0;
471
472 if (ir & JAB) {
473 #ifdef MCDEBUG
474 printf("%s: jabber error\n", sc->sc_dev.dv_xname);
475 #endif
476 sc->sc_if.if_oerrors++;
477 }
478
479 if (ir & BABL) {
480 #ifdef MCDEBUG
481 printf("%s: babble\n", sc->sc_dev.dv_xname);
482 #endif
483 sc->sc_if.if_oerrors++;
484 }
485
486 if (ir & CERR) {
487 printf("%s: collision error\n", sc->sc_dev.dv_xname);
488 sc->sc_if.if_collisions++;
489 }
490
491 /*
492 * Pretend we have carrier; if we don't this will be cleared
493 * shortly.
494 */
495 sc->sc_havecarrier = 1;
496
497 if (ir & XMTINT)
498 mc_tint(sc);
499
500 if (ir & RCVINT)
501 mc_rint(sc);
502
503 return 1;
504 }
505
506 integrate void
507 mc_tint(sc)
508 struct mc_softc *sc;
509 {
510 u_int8_t xmtrc, xmtfs;
511
512 xmtrc = NIC_GET(sc, MACE_XMTRC);
513 xmtfs = NIC_GET(sc, MACE_XMTFS);
514
515 if ((xmtfs & XMTSV) == 0)
516 return;
517
518 if (xmtfs & UFLO) {
519 printf("%s: underflow\n", sc->sc_dev.dv_xname);
520 mcreset(sc);
521 return;
522 }
523
524 if (xmtfs & LCOL) {
525 printf("%s: late collision\n", sc->sc_dev.dv_xname);
526 sc->sc_if.if_oerrors++;
527 sc->sc_if.if_collisions++;
528 }
529
530 if (xmtfs & MORE)
531 /* Real number is unknown. */
532 sc->sc_if.if_collisions += 2;
533 else if (xmtfs & ONE)
534 sc->sc_if.if_collisions++;
535 else if (xmtfs & RTRY) {
536 sc->sc_if.if_collisions += 16;
537 sc->sc_if.if_oerrors++;
538 }
539
540 if (xmtfs & LCAR) {
541 sc->sc_havecarrier = 0;
542 printf("%s: lost carrier\n", sc->sc_dev.dv_xname);
543 sc->sc_if.if_oerrors++;
544 }
545
546 sc->sc_if.if_flags &= ~IFF_OACTIVE;
547 sc->sc_if.if_timer = 0;
548 mcstart(&sc->sc_if);
549 }
550
551 void
552 mc_rint(sc)
553 struct mc_softc *sc;
554 {
555 #define rxf sc->sc_rxframe
556 u_int len;
557
558 len = (rxf.rx_rcvcnt | ((rxf.rx_rcvsts & 0xf) << 8)) - 4;
559
560 #ifdef MCDEBUG
561 if (rxf.rx_rcvsts & 0xf0)
562 printf("%s: rcvcnt %02x rcvsts %02x rntpc 0x%02x rcvcc 0x%02x\n",
563 sc->sc_dev.dv_xname, rxf.rx_rcvcnt, rxf.rx_rcvsts,
564 rxf.rx_rntpc, rxf.rx_rcvcc);
565 #endif
566
567 if (rxf.rx_rcvsts & OFLO) {
568 printf("%s: receive FIFO overflow\n", sc->sc_dev.dv_xname);
569 sc->sc_if.if_ierrors++;
570 return;
571 }
572
573 if (rxf.rx_rcvsts & CLSN)
574 sc->sc_if.if_collisions++;
575
576 if (rxf.rx_rcvsts & FRAM) {
577 #ifdef MCDEBUG
578 printf("%s: framing error\n", sc->sc_dev.dv_xname);
579 #endif
580 sc->sc_if.if_ierrors++;
581 return;
582 }
583
584 if (rxf.rx_rcvsts & FCS) {
585 #ifdef MCDEBUG
586 printf("%s: frame control checksum error\n", sc->sc_dev.dv_xname);
587 #endif
588 sc->sc_if.if_ierrors++;
589 return;
590 }
591
592 mace_read(sc, rxf.rx_frame, len);
593 #undef rxf
594 }
595
596 integrate void
597 mace_read(sc, pkt, len)
598 struct mc_softc *sc;
599 uint8_t *pkt;
600 int len;
601 {
602 struct ifnet *ifp = &sc->sc_if;
603 struct mbuf *m;
604
605 if (len <= sizeof(struct ether_header) ||
606 len > ETHERMTU + sizeof(struct ether_header)) {
607 #ifdef MCDEBUG
608 printf("%s: invalid packet size %d; dropping\n",
609 sc->sc_dev.dv_xname, len);
610 #endif
611 ifp->if_ierrors++;
612 return;
613 }
614
615 m = mace_get(sc, pkt, len);
616 if (m == NULL) {
617 ifp->if_ierrors++;
618 return;
619 }
620
621 ifp->if_ipackets++;
622
623 #if NBPFILTER > 0
624 /* Pass this up to any BPF listeners. */
625 if (ifp->if_bpf)
626 bpf_mtap(ifp->if_bpf, m);
627 #endif
628
629 /* Pass the packet up. */
630 (*ifp->if_input)(ifp, m);
631 }
632
633 /*
634 * Pull data off an interface.
635 * Len is length of data, with local net header stripped.
636 * We copy the data into mbufs. When full cluster sized units are present
637 * we copy into clusters.
638 */
639 integrate struct mbuf *
640 mace_get(sc, pkt, totlen)
641 struct mc_softc *sc;
642 uint8_t *pkt;
643 int totlen;
644 {
645 register struct mbuf *m;
646 struct mbuf *top, **mp;
647 int len;
648
649 MGETHDR(m, M_DONTWAIT, MT_DATA);
650 if (m == 0)
651 return (0);
652 m->m_pkthdr.rcvif = &sc->sc_if;
653 m->m_pkthdr.len = totlen;
654 len = MHLEN;
655 top = 0;
656 mp = ⊤
657
658 while (totlen > 0) {
659 if (top) {
660 MGET(m, M_DONTWAIT, MT_DATA);
661 if (m == 0) {
662 m_freem(top);
663 return 0;
664 }
665 len = MLEN;
666 }
667 if (totlen >= MINCLSIZE) {
668 MCLGET(m, M_DONTWAIT);
669 if ((m->m_flags & M_EXT) == 0) {
670 m_free(m);
671 m_freem(top);
672 return 0;
673 }
674 len = MCLBYTES;
675 }
676 m->m_len = len = min(totlen, len);
677 memcpy(mtod(m, void *), pkt, len);
678 pkt += len;
679 totlen -= len;
680 *mp = m;
681 mp = &m->m_next;
682 }
683
684 return (top);
685 }
686
687 /*
688 * Go through the list of multicast addresses and calculate the logical
689 * address filter.
690 */
691 void
692 mace_calcladrf(ac, af)
693 struct ethercom *ac;
694 u_int8_t *af;
695 {
696 struct ifnet *ifp = &ac->ec_if;
697 struct ether_multi *enm;
698 register u_char *cp, c;
699 register u_int32_t crc;
700 register int i, len;
701 struct ether_multistep step;
702
703 /*
704 * Set up multicast address filter by passing all multicast addresses
705 * through a crc generator, and then using the high order 6 bits as an
706 * index into the 64 bit logical address filter. The high order bit
707 * selects the word, while the rest of the bits select the bit within
708 * the word.
709 */
710
711 *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0;
712
713 ETHER_FIRST_MULTI(step, ac, enm);
714 while (enm != NULL) {
715 if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) {
716 /*
717 * We must listen to a range of multicast addresses.
718 * For now, just accept all multicasts, rather than
719 * trying to set only those filter bits needed to match
720 * the range. (At this time, the only use of address
721 * ranges is for IP multicast routing, for which the
722 * range is big enough to require all bits set.)
723 */
724 goto allmulti;
725 }
726
727 cp = enm->enm_addrlo;
728 crc = 0xffffffff;
729 for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
730 c = *cp++;
731 for (i = 8; --i >= 0;) {
732 if ((crc & 0x01) ^ (c & 0x01)) {
733 crc >>= 1;
734 crc ^= 0xedb88320;
735 } else
736 crc >>= 1;
737 c >>= 1;
738 }
739 }
740 /* Just want the 6 most significant bits. */
741 crc >>= 26;
742
743 /* Set the corresponding bit in the filter. */
744 af[crc >> 3] |= 1 << (crc & 7);
745
746 ETHER_NEXT_MULTI(step, enm);
747 }
748 ifp->if_flags &= ~IFF_ALLMULTI;
749 return;
750
751 allmulti:
752 ifp->if_flags |= IFF_ALLMULTI;
753 *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0xffffffff;
754 }
755
756 int
757 mc_mediachange(ifp)
758 struct ifnet *ifp;
759 {
760 return EINVAL;
761 }
762
763 void
764 mc_mediastatus(ifp, ifmr)
765 struct ifnet *ifp;
766 struct ifmediareq *ifmr;
767 {
768 struct mc_softc *sc = ifp->if_softc;
769
770 if ((ifp->if_flags & IFF_UP) == 0)
771 return;
772
773 if (sc->sc_havecarrier)
774 ifmr->ifm_status |= IFM_ACTIVE;
775 }
776