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