if_le.c revision 1.9 1 1.1 cgd /*
2 1.1 cgd * Copyright (c) 1982, 1990 The Regents of the University of California.
3 1.1 cgd * All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.2 cgd * from: @(#)if_le.c 7.6 (Berkeley) 5/8/91
34 1.9 mycroft * $Id: if_le.c,v 1.9 1994/02/14 23:03:54 mycroft Exp $
35 1.1 cgd */
36 1.1 cgd
37 1.1 cgd #include "le.h"
38 1.1 cgd #if NLE > 0
39 1.1 cgd
40 1.1 cgd #include "bpfilter.h"
41 1.1 cgd
42 1.1 cgd /*
43 1.1 cgd * AMD 7990 LANCE
44 1.5 mycroft */
45 1.5 mycroft #include <sys/param.h>
46 1.5 mycroft #include <sys/systm.h>
47 1.5 mycroft #include <sys/kernel.h>
48 1.5 mycroft #include <sys/mbuf.h>
49 1.5 mycroft #include <sys/buf.h>
50 1.5 mycroft #include <sys/socket.h>
51 1.5 mycroft #include <sys/syslog.h>
52 1.5 mycroft #include <sys/ioctl.h>
53 1.5 mycroft #include <sys/malloc.h>
54 1.5 mycroft #include <sys/errno.h>
55 1.5 mycroft
56 1.5 mycroft #include <net/if.h>
57 1.5 mycroft #include <net/netisr.h>
58 1.5 mycroft #include <net/route.h>
59 1.5 mycroft #if NBPFILTER > 0
60 1.5 mycroft #include <net/bpf.h>
61 1.5 mycroft #include <net/bpfdesc.h>
62 1.5 mycroft #endif
63 1.1 cgd
64 1.1 cgd #ifdef INET
65 1.5 mycroft #include <netinet/in.h>
66 1.5 mycroft #include <netinet/in_systm.h>
67 1.5 mycroft #include <netinet/in_var.h>
68 1.5 mycroft #include <netinet/ip.h>
69 1.5 mycroft #include <netinet/if_ether.h>
70 1.1 cgd #endif
71 1.1 cgd
72 1.1 cgd #ifdef NS
73 1.5 mycroft #include <netns/ns.h>
74 1.5 mycroft #include <netns/ns_if.h>
75 1.1 cgd #endif
76 1.1 cgd
77 1.5 mycroft #include <machine/cpu.h>
78 1.5 mycroft #include <hp300/hp300/isr.h>
79 1.5 mycroft #include <machine/mtpr.h>
80 1.1 cgd
81 1.5 mycroft #include <hp300/dev/device.h>
82 1.5 mycroft #include <hp300/dev/if_lereg.h>
83 1.1 cgd
84 1.1 cgd /* offsets for: ID, REGS, MEM, NVRAM */
85 1.1 cgd int lestd[] = { 0, 0x4000, 0x8000, 0xC008 };
86 1.1 cgd
87 1.1 cgd struct isr le_isr[NLE];
88 1.1 cgd int ledebug = 0; /* console error messages */
89 1.1 cgd
90 1.1 cgd /*
91 1.1 cgd * Ethernet software status per interface.
92 1.1 cgd *
93 1.1 cgd * Each interface is referenced by a network interface structure,
94 1.1 cgd * le_if, which the routing code uses to locate the interface.
95 1.1 cgd * This structure contains the output queue for the interface, its address, ...
96 1.1 cgd */
97 1.1 cgd struct le_softc {
98 1.1 cgd struct arpcom sc_ac; /* common Ethernet structures */
99 1.1 cgd #define sc_if sc_ac.ac_if /* network-visible interface */
100 1.1 cgd #define sc_addr sc_ac.ac_enaddr /* hardware Ethernet address */
101 1.1 cgd struct lereg0 *sc_r0; /* DIO registers */
102 1.1 cgd struct lereg1 *sc_r1; /* LANCE registers */
103 1.1 cgd struct lereg2 *sc_r2; /* dual-port RAM */
104 1.1 cgd int sc_rmd; /* predicted next rmd to process */
105 1.6 mycroft int sc_tmd; /* next available tmd */
106 1.6 mycroft int sc_txcnt; /* # of transmit buffers in use */
107 1.6 mycroft /* stats */
108 1.1 cgd int sc_runt;
109 1.1 cgd int sc_jab;
110 1.1 cgd int sc_merr;
111 1.1 cgd int sc_babl;
112 1.1 cgd int sc_cerr;
113 1.1 cgd int sc_miss;
114 1.6 mycroft int sc_rown;
115 1.1 cgd int sc_xint;
116 1.1 cgd int sc_xown;
117 1.6 mycroft int sc_xown2;
118 1.1 cgd int sc_uflo;
119 1.1 cgd int sc_rxlen;
120 1.1 cgd int sc_rxoff;
121 1.1 cgd int sc_txoff;
122 1.1 cgd int sc_busy;
123 1.1 cgd short sc_iflags;
124 1.1 cgd #if NBPFILTER > 0
125 1.1 cgd caddr_t sc_bpf;
126 1.1 cgd #endif
127 1.1 cgd } le_softc[NLE];
128 1.1 cgd
129 1.1 cgd /* access LANCE registers */
130 1.1 cgd #define LERDWR(cntl, src, dst) \
131 1.1 cgd do { \
132 1.1 cgd (dst) = (src); \
133 1.1 cgd } while (((cntl)->ler0_status & LE_ACK) == 0);
134 1.1 cgd
135 1.8 mycroft int leattach __P((struct hp_device *));
136 1.8 mycroft void lesetladrf __P((struct le_softc *));
137 1.8 mycroft void ledrinit __P((struct lereg2 *));
138 1.8 mycroft void lereset __P((struct le_softc *));
139 1.8 mycroft void leinit __P((int));
140 1.8 mycroft int lestart __P((struct ifnet *));
141 1.8 mycroft int leintr __P((int));
142 1.8 mycroft void lexint __P((struct le_softc *));
143 1.8 mycroft void lerint __P((struct le_softc *));
144 1.8 mycroft void leread __P((struct le_softc *, char *, int));
145 1.8 mycroft int leput __P((char *, struct mbuf *));
146 1.8 mycroft struct mbuf *leget __P((char *, int, int, struct ifnet *));
147 1.8 mycroft int leioctl __P((struct ifnet *, int, caddr_t));
148 1.8 mycroft void leerror __P((struct le_softc *, int));
149 1.8 mycroft void lererror __P((struct le_softc *, char *));
150 1.8 mycroft void lexerror __P((struct le_softc *));
151 1.8 mycroft int ether_output();
152 1.8 mycroft
153 1.8 mycroft struct driver ledriver = {
154 1.8 mycroft leattach, "le",
155 1.8 mycroft };
156 1.8 mycroft
157 1.1 cgd /*
158 1.1 cgd * Interface exists: make available by filling in network interface
159 1.1 cgd * record. System will initialize the interface when it is ready
160 1.1 cgd * to accept packets.
161 1.1 cgd */
162 1.8 mycroft int
163 1.1 cgd leattach(hd)
164 1.1 cgd struct hp_device *hd;
165 1.1 cgd {
166 1.1 cgd register struct lereg0 *ler0;
167 1.1 cgd register struct lereg2 *ler2;
168 1.1 cgd struct lereg2 *lemem = 0;
169 1.5 mycroft struct le_softc *sc = &le_softc[hd->hp_unit];
170 1.5 mycroft struct ifnet *ifp = &sc->sc_if;
171 1.1 cgd char *cp;
172 1.1 cgd int i;
173 1.1 cgd
174 1.5 mycroft ler0 = sc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr);
175 1.5 mycroft sc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr);
176 1.5 mycroft ler2 = sc->sc_r2 = (struct lereg2 *)(lestd[2] + (int)hd->hp_addr);
177 1.1 cgd if (ler0->ler0_id != LEID)
178 1.1 cgd return(0);
179 1.1 cgd le_isr[hd->hp_unit].isr_intr = leintr;
180 1.1 cgd hd->hp_ipl = le_isr[hd->hp_unit].isr_ipl = LE_IPL(ler0->ler0_status);
181 1.1 cgd le_isr[hd->hp_unit].isr_arg = hd->hp_unit;
182 1.1 cgd ler0->ler0_id = 0xFF;
183 1.1 cgd DELAY(100);
184 1.1 cgd
185 1.1 cgd /*
186 1.1 cgd * Read the ethernet address off the board, one nibble at a time.
187 1.1 cgd */
188 1.1 cgd cp = (char *)(lestd[3] + (int)hd->hp_addr);
189 1.5 mycroft for (i = 0; i < sizeof(sc->sc_addr); i++) {
190 1.5 mycroft sc->sc_addr[i] = (*++cp & 0xF) << 4;
191 1.1 cgd cp++;
192 1.5 mycroft sc->sc_addr[i] |= *++cp & 0xF;
193 1.1 cgd cp++;
194 1.1 cgd }
195 1.1 cgd printf("le%d: hardware address %s\n", hd->hp_unit,
196 1.5 mycroft ether_sprintf(sc->sc_addr));
197 1.1 cgd
198 1.1 cgd /*
199 1.1 cgd * Setup for transmit/receive
200 1.1 cgd */
201 1.1 cgd ler2->ler2_mode = LE_MODE;
202 1.1 cgd ler2->ler2_rlen = LE_RLEN;
203 1.1 cgd ler2->ler2_rdra = (int)lemem->ler2_rmd;
204 1.1 cgd ler2->ler2_tlen = LE_TLEN;
205 1.1 cgd ler2->ler2_tdra = (int)lemem->ler2_tmd;
206 1.1 cgd isrlink(&le_isr[hd->hp_unit]);
207 1.1 cgd ler0->ler0_status = LE_IE;
208 1.1 cgd
209 1.1 cgd ifp->if_unit = hd->hp_unit;
210 1.1 cgd ifp->if_name = "le";
211 1.1 cgd ifp->if_mtu = ETHERMTU;
212 1.1 cgd ifp->if_ioctl = leioctl;
213 1.1 cgd ifp->if_output = ether_output;
214 1.1 cgd ifp->if_start = lestart;
215 1.5 mycroft ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
216 1.5 mycroft IFF_NOTRAILERS;
217 1.1 cgd #if NBPFILTER > 0
218 1.5 mycroft bpfattach(&sc->sc_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
219 1.1 cgd #endif
220 1.1 cgd if_attach(ifp);
221 1.1 cgd return (1);
222 1.1 cgd }
223 1.1 cgd
224 1.5 mycroft /*
225 1.5 mycroft * Set up the logical address filter
226 1.5 mycroft */
227 1.5 mycroft void
228 1.5 mycroft lesetladrf(sc)
229 1.5 mycroft struct le_softc *sc;
230 1.5 mycroft {
231 1.9 mycroft u_long *af = sc->sc_r2->ler2_ladrf;
232 1.5 mycroft struct ifnet *ifp = &sc->sc_if;
233 1.5 mycroft struct ether_multi *enm;
234 1.5 mycroft register u_char *cp, c;
235 1.5 mycroft register u_long crc;
236 1.5 mycroft register int i, len;
237 1.5 mycroft struct ether_multistep step;
238 1.5 mycroft
239 1.5 mycroft /*
240 1.9 mycroft * Set up multicast address filter by passing all multicast addresses
241 1.9 mycroft * through a crc generator, and then using the high order 6 bits as an
242 1.9 mycroft * index into the 64 bit logical address filter. The high order bit
243 1.9 mycroft * selects the word, while the rest of the bits select the bit within
244 1.9 mycroft * the word.
245 1.5 mycroft */
246 1.5 mycroft
247 1.9 mycroft if (ifp->if_flags & IFF_ALLMULTI) {
248 1.9 mycroft af[0] = af[1] = 0xffffffff;
249 1.9 mycroft return;
250 1.9 mycroft }
251 1.9 mycroft
252 1.9 mycroft af[0] = af[1] = 0;
253 1.5 mycroft ETHER_FIRST_MULTI(step, &sc->sc_ac, enm);
254 1.5 mycroft while (enm != NULL) {
255 1.9 mycroft if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
256 1.9 mycroft sizeof(enm->enm_addrlo)) != 0) {
257 1.5 mycroft /*
258 1.9 mycroft * We must listen to a range of multicast addresses.
259 1.9 mycroft * For now, just accept all multicasts, rather than
260 1.9 mycroft * trying to set only those filter bits needed to match
261 1.9 mycroft * the range. (At this time, the only use of address
262 1.9 mycroft * ranges is for IP multicast routing, for which the
263 1.9 mycroft * range is big enough to require all bits set.)
264 1.5 mycroft */
265 1.9 mycroft af[0] = af[1] = 0xffffffff;
266 1.5 mycroft return;
267 1.5 mycroft }
268 1.5 mycroft
269 1.9 mycroft cp = enm->enm_addrlo;
270 1.5 mycroft crc = 0xffffffff;
271 1.9 mycroft for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
272 1.5 mycroft c = *cp++;
273 1.5 mycroft for (i = 8; --i >= 0;) {
274 1.5 mycroft if ((c & 0x01) ^ (crc & 0x01)) {
275 1.5 mycroft crc >>= 1;
276 1.9 mycroft crc ^= 0x6db88320 | 0x80000000;
277 1.5 mycroft } else
278 1.5 mycroft crc >>= 1;
279 1.5 mycroft c >>= 1;
280 1.5 mycroft }
281 1.5 mycroft }
282 1.5 mycroft /* Just want the 6 most significant bits. */
283 1.9 mycroft crc >>= 26;
284 1.5 mycroft
285 1.5 mycroft /* Turn on the corresponding bit in the filter. */
286 1.9 mycroft af[crc >> 5] |= 1 << (crc & 0x1f);
287 1.5 mycroft
288 1.5 mycroft ETHER_NEXT_MULTI(step, enm);
289 1.5 mycroft }
290 1.5 mycroft }
291 1.5 mycroft
292 1.8 mycroft void
293 1.6 mycroft ledrinit(ler2)
294 1.6 mycroft register struct lereg2 *ler2;
295 1.6 mycroft {
296 1.6 mycroft register struct lereg2 *lemem = 0;
297 1.6 mycroft register int i;
298 1.6 mycroft
299 1.6 mycroft for (i = 0; i < LERBUF; i++) {
300 1.6 mycroft ler2->ler2_rmd[i].rmd0 = (int)lemem->ler2_rbuf[i];
301 1.6 mycroft ler2->ler2_rmd[i].rmd1 = LE_OWN;
302 1.6 mycroft ler2->ler2_rmd[i].rmd2 = -LEMTU;
303 1.6 mycroft ler2->ler2_rmd[i].rmd3 = 0;
304 1.6 mycroft }
305 1.6 mycroft for (i = 0; i < LETBUF; i++) {
306 1.6 mycroft ler2->ler2_tmd[i].tmd0 = (int)lemem->ler2_tbuf[i];
307 1.6 mycroft ler2->ler2_tmd[i].tmd1 = 0;
308 1.6 mycroft ler2->ler2_tmd[i].tmd2 = 0;
309 1.6 mycroft ler2->ler2_tmd[i].tmd3 = 0;
310 1.6 mycroft }
311 1.6 mycroft }
312 1.6 mycroft
313 1.8 mycroft void
314 1.5 mycroft lereset(sc)
315 1.5 mycroft register struct le_softc *sc;
316 1.1 cgd {
317 1.5 mycroft register struct lereg0 *ler0 = sc->sc_r0;
318 1.5 mycroft register struct lereg1 *ler1 = sc->sc_r1;
319 1.5 mycroft register struct lereg2 *ler2 = sc->sc_r2;
320 1.5 mycroft struct lereg2 *lemem = 0;
321 1.5 mycroft register int timo, stat;
322 1.1 cgd
323 1.1 cgd #if NBPFILTER > 0
324 1.5 mycroft if (sc->sc_if.if_flags & IFF_PROMISC)
325 1.1 cgd /* set the promiscuous bit */
326 1.5 mycroft ler2->ler2_mode = LE_MODE|0x8000;
327 1.1 cgd else
328 1.1 cgd #endif
329 1.5 mycroft ler2->ler2_mode = LE_MODE;
330 1.1 cgd LERDWR(ler0, LE_CSR0, ler1->ler1_rap);
331 1.1 cgd LERDWR(ler0, LE_STOP, ler1->ler1_rdp);
332 1.5 mycroft
333 1.6 mycroft ler2->ler2_padr[0] = sc->sc_addr[1];
334 1.6 mycroft ler2->ler2_padr[1] = sc->sc_addr[0];
335 1.6 mycroft ler2->ler2_padr[2] = sc->sc_addr[3];
336 1.6 mycroft ler2->ler2_padr[3] = sc->sc_addr[2];
337 1.6 mycroft ler2->ler2_padr[4] = sc->sc_addr[5];
338 1.6 mycroft ler2->ler2_padr[5] = sc->sc_addr[4];
339 1.5 mycroft lesetladrf(sc);
340 1.5 mycroft ledrinit(ler2);
341 1.7 mycroft sc->sc_rmd = sc->sc_tmd = sc->sc_txcnt = 0;
342 1.5 mycroft
343 1.1 cgd LERDWR(ler0, LE_CSR1, ler1->ler1_rap);
344 1.1 cgd LERDWR(ler0, (int)&lemem->ler2_mode, ler1->ler1_rdp);
345 1.1 cgd LERDWR(ler0, LE_CSR2, ler1->ler1_rap);
346 1.1 cgd LERDWR(ler0, 0, ler1->ler1_rdp);
347 1.5 mycroft LERDWR(ler0, LE_CSR3, ler1->ler1_rap);
348 1.5 mycroft LERDWR(ler0, LE_BSWP, ler1->ler1_rdp);
349 1.1 cgd LERDWR(ler0, LE_CSR0, ler1->ler1_rap);
350 1.1 cgd LERDWR(ler0, LE_INIT, ler1->ler1_rdp);
351 1.5 mycroft timo = 100000;
352 1.1 cgd do {
353 1.1 cgd if (--timo == 0) {
354 1.5 mycroft printf("le%d: init timeout, stat=0x%x\n",
355 1.5 mycroft sc->sc_if.if_unit, stat);
356 1.1 cgd break;
357 1.1 cgd }
358 1.1 cgd LERDWR(ler0, ler1->ler1_rdp, stat);
359 1.5 mycroft } while ((stat & (LE_IDON | LE_ERR)) == 0);
360 1.5 mycroft if (stat & LE_ERR)
361 1.5 mycroft printf("le%d: init failed, stat=0x%x\n",
362 1.5 mycroft sc->sc_if.if_unit, stat);
363 1.5 mycroft else
364 1.5 mycroft LERDWR(ler0, LE_IDON, ler1->ler1_rdp);
365 1.8 mycroft sc->sc_if.if_flags &= ~IFF_OACTIVE;
366 1.1 cgd LERDWR(ler0, LE_STRT | LE_INEA, ler1->ler1_rdp);
367 1.1 cgd }
368 1.1 cgd
369 1.1 cgd /*
370 1.1 cgd * Initialization of interface
371 1.1 cgd */
372 1.8 mycroft void
373 1.1 cgd leinit(unit)
374 1.1 cgd int unit;
375 1.1 cgd {
376 1.5 mycroft struct le_softc *sc = &le_softc[unit];
377 1.5 mycroft register struct ifnet *ifp = &sc->sc_if;
378 1.1 cgd int s;
379 1.1 cgd
380 1.1 cgd /* not yet, if address still unknown */
381 1.1 cgd if (ifp->if_addrlist == (struct ifaddr *)0)
382 1.1 cgd return;
383 1.1 cgd if ((ifp->if_flags & IFF_RUNNING) == 0) {
384 1.1 cgd s = splimp();
385 1.1 cgd ifp->if_flags |= IFF_RUNNING;
386 1.5 mycroft lereset(sc);
387 1.5 mycroft (void) lestart(ifp);
388 1.1 cgd splx(s);
389 1.1 cgd }
390 1.1 cgd }
391 1.1 cgd
392 1.6 mycroft #define LENEXTTMP \
393 1.6 mycroft if (++bix == LETBUF) bix = 0, tmd = sc->sc_r2->ler2_tmd; else ++tmd
394 1.6 mycroft
395 1.1 cgd /*
396 1.1 cgd * Start output on interface. Get another datagram to send
397 1.1 cgd * off of the interface queue, and copy it to the interface
398 1.1 cgd * before starting the output.
399 1.1 cgd */
400 1.8 mycroft int
401 1.1 cgd lestart(ifp)
402 1.1 cgd struct ifnet *ifp;
403 1.1 cgd {
404 1.5 mycroft register struct le_softc *sc = &le_softc[ifp->if_unit];
405 1.6 mycroft register int bix;
406 1.1 cgd register struct letmd *tmd;
407 1.1 cgd register struct mbuf *m;
408 1.6 mycroft int len, gotone = 0;
409 1.1 cgd
410 1.5 mycroft if ((sc->sc_if.if_flags & IFF_RUNNING) == 0)
411 1.1 cgd return (0);
412 1.6 mycroft bix = sc->sc_tmd;
413 1.6 mycroft tmd = &sc->sc_r2->ler2_tmd[bix];
414 1.6 mycroft do {
415 1.6 mycroft if (tmd->tmd1 & LE_OWN) {
416 1.6 mycroft if (gotone)
417 1.6 mycroft break;
418 1.6 mycroft sc->sc_xown2++;
419 1.6 mycroft return (0);
420 1.6 mycroft }
421 1.6 mycroft IF_DEQUEUE(&sc->sc_if.if_snd, m);
422 1.6 mycroft if (m == 0) {
423 1.6 mycroft if (gotone)
424 1.6 mycroft break;
425 1.6 mycroft return (0);
426 1.6 mycroft }
427 1.6 mycroft len = leput(sc->sc_r2->ler2_tbuf[bix], m);
428 1.1 cgd #if NBPFILTER > 0
429 1.6 mycroft /*
430 1.6 mycroft * If bpf is listening on this interface, let it
431 1.6 mycroft * see the packet before we commit it to the wire.
432 1.6 mycroft */
433 1.6 mycroft if (sc->sc_bpf)
434 1.6 mycroft bpf_tap(sc->sc_bpf, sc->sc_r2->ler2_tbuf[bix], len);
435 1.1 cgd #endif
436 1.6 mycroft tmd->tmd3 = 0;
437 1.6 mycroft tmd->tmd2 = -len;
438 1.6 mycroft tmd->tmd1 = LE_OWN | LE_STP | LE_ENP;
439 1.6 mycroft LENEXTTMP;
440 1.6 mycroft gotone++;
441 1.6 mycroft } while (++sc->sc_txcnt < LETBUF);
442 1.8 mycroft sc->sc_tmd = bix;
443 1.8 mycroft sc->sc_if.if_flags |= IFF_OACTIVE;
444 1.6 mycroft /* transmit as soon as possible */
445 1.6 mycroft LERDWR(sc->sc_r0, LE_INEA|LE_TDMD, sc->sc_r1->ler1_rdp);
446 1.1 cgd return (0);
447 1.1 cgd }
448 1.1 cgd
449 1.8 mycroft int
450 1.1 cgd leintr(unit)
451 1.1 cgd register int unit;
452 1.1 cgd {
453 1.5 mycroft register struct le_softc *sc = &le_softc[unit];
454 1.5 mycroft register struct lereg0 *ler0 = sc->sc_r0;
455 1.1 cgd register struct lereg1 *ler1;
456 1.1 cgd register int stat;
457 1.1 cgd
458 1.1 cgd if ((ler0->ler0_status & LE_IR) == 0)
459 1.1 cgd return(0);
460 1.1 cgd if (ler0->ler0_status & LE_JAB) {
461 1.5 mycroft sc->sc_jab++;
462 1.5 mycroft lereset(sc);
463 1.1 cgd return(1);
464 1.1 cgd }
465 1.5 mycroft ler1 = sc->sc_r1;
466 1.1 cgd LERDWR(ler0, ler1->ler1_rdp, stat);
467 1.1 cgd if (stat & LE_SERR) {
468 1.5 mycroft leerror(sc, stat);
469 1.1 cgd if (stat & LE_MERR) {
470 1.5 mycroft sc->sc_merr++;
471 1.5 mycroft lereset(sc);
472 1.1 cgd return(1);
473 1.1 cgd }
474 1.1 cgd if (stat & LE_BABL)
475 1.5 mycroft sc->sc_babl++;
476 1.1 cgd if (stat & LE_CERR)
477 1.5 mycroft sc->sc_cerr++;
478 1.1 cgd if (stat & LE_MISS)
479 1.5 mycroft sc->sc_miss++;
480 1.1 cgd LERDWR(ler0, LE_BABL|LE_CERR|LE_MISS|LE_INEA, ler1->ler1_rdp);
481 1.1 cgd }
482 1.1 cgd if ((stat & LE_RXON) == 0) {
483 1.5 mycroft sc->sc_rxoff++;
484 1.5 mycroft lereset(sc);
485 1.1 cgd return(1);
486 1.1 cgd }
487 1.1 cgd if ((stat & LE_TXON) == 0) {
488 1.5 mycroft sc->sc_txoff++;
489 1.5 mycroft lereset(sc);
490 1.1 cgd return(1);
491 1.1 cgd }
492 1.6 mycroft if (stat & LE_RINT)
493 1.5 mycroft lerint(sc);
494 1.6 mycroft if (stat & LE_TINT)
495 1.5 mycroft lexint(sc);
496 1.1 cgd return(1);
497 1.1 cgd }
498 1.1 cgd
499 1.1 cgd /*
500 1.1 cgd * Ethernet interface transmitter interrupt.
501 1.1 cgd * Start another output if more data to send.
502 1.1 cgd */
503 1.8 mycroft void
504 1.5 mycroft lexint(sc)
505 1.5 mycroft register struct le_softc *sc;
506 1.1 cgd {
507 1.6 mycroft register struct letmd *tmd;
508 1.8 mycroft int bix, gotone = 0;
509 1.1 cgd
510 1.5 mycroft if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0) {
511 1.5 mycroft sc->sc_xint++;
512 1.1 cgd return;
513 1.1 cgd }
514 1.8 mycroft if ((bix = sc->sc_tmd - sc->sc_txcnt) < 0)
515 1.8 mycroft bix += LETBUF;
516 1.8 mycroft tmd = &sc->sc_r2->ler2_tmd[bix];
517 1.6 mycroft do {
518 1.6 mycroft if (tmd->tmd1 & LE_OWN) {
519 1.6 mycroft if (gotone)
520 1.6 mycroft break;
521 1.6 mycroft sc->sc_xown++;
522 1.6 mycroft return;
523 1.6 mycroft }
524 1.6 mycroft
525 1.6 mycroft /* clear interrupt */
526 1.6 mycroft LERDWR(sc->sc_r0, LE_TINT|LE_INEA, sc->sc_r1->ler1_rdp);
527 1.6 mycroft
528 1.6 mycroft /* XXX documentation says BUFF not included in ERR */
529 1.6 mycroft if ((tmd->tmd1 & LE_ERR) || (tmd->tmd3 & LE_TBUFF)) {
530 1.6 mycroft lexerror(sc);
531 1.6 mycroft sc->sc_if.if_oerrors++;
532 1.6 mycroft if (tmd->tmd3 & (LE_TBUFF|LE_UFLO)) {
533 1.6 mycroft sc->sc_uflo++;
534 1.6 mycroft lereset(sc);
535 1.6 mycroft } else if (tmd->tmd3 & LE_LCOL)
536 1.6 mycroft sc->sc_if.if_collisions++;
537 1.6 mycroft else if (tmd->tmd3 & LE_RTRY)
538 1.6 mycroft sc->sc_if.if_collisions += 16;
539 1.6 mycroft }
540 1.6 mycroft else if (tmd->tmd1 & LE_ONE)
541 1.5 mycroft sc->sc_if.if_collisions++;
542 1.6 mycroft else if (tmd->tmd1 & LE_MORE)
543 1.6 mycroft /* what is the real number? */
544 1.6 mycroft sc->sc_if.if_collisions += 2;
545 1.6 mycroft else
546 1.6 mycroft sc->sc_if.if_opackets++;
547 1.8 mycroft LENEXTTMP;
548 1.6 mycroft gotone++;
549 1.6 mycroft } while (--sc->sc_txcnt > 0);
550 1.5 mycroft sc->sc_if.if_flags &= ~IFF_OACTIVE;
551 1.5 mycroft (void) lestart(&sc->sc_if);
552 1.1 cgd }
553 1.1 cgd
554 1.1 cgd #define LENEXTRMP \
555 1.5 mycroft if (++bix == LERBUF) bix = 0, rmd = sc->sc_r2->ler2_rmd; else ++rmd
556 1.1 cgd
557 1.1 cgd /*
558 1.1 cgd * Ethernet interface receiver interrupt.
559 1.1 cgd * If input error just drop packet.
560 1.1 cgd * Decapsulate packet based on type and pass to type specific
561 1.1 cgd * higher-level input routine.
562 1.1 cgd */
563 1.8 mycroft void
564 1.5 mycroft lerint(sc)
565 1.5 mycroft register struct le_softc *sc;
566 1.1 cgd {
567 1.5 mycroft register int bix = sc->sc_rmd;
568 1.5 mycroft register struct lermd *rmd = &sc->sc_r2->ler2_rmd[bix];
569 1.1 cgd
570 1.1 cgd /*
571 1.1 cgd * Out of sync with hardware, should never happen?
572 1.1 cgd */
573 1.1 cgd if (rmd->rmd1 & LE_OWN) {
574 1.6 mycroft sc->sc_rown++;
575 1.5 mycroft do {
576 1.5 mycroft LENEXTRMP;
577 1.5 mycroft } while ((rmd->rmd1 & LE_OWN) && bix != sc->sc_rmd);
578 1.5 mycroft if (bix == sc->sc_rmd) {
579 1.5 mycroft printf("le%d: rint with no buffer\n",
580 1.5 mycroft sc->sc_if.if_unit);
581 1.5 mycroft LERDWR(sc->sc_r0, LE_RINT|LE_INEA, sc->sc_r1->ler1_rdp);
582 1.5 mycroft return;
583 1.5 mycroft }
584 1.1 cgd }
585 1.1 cgd
586 1.1 cgd /*
587 1.1 cgd * Process all buffers with valid data
588 1.1 cgd */
589 1.1 cgd while ((rmd->rmd1 & LE_OWN) == 0) {
590 1.1 cgd int len = rmd->rmd3;
591 1.1 cgd
592 1.1 cgd /* Clear interrupt to avoid race condition */
593 1.5 mycroft LERDWR(sc->sc_r0, LE_RINT|LE_INEA, sc->sc_r1->ler1_rdp);
594 1.1 cgd
595 1.1 cgd if (rmd->rmd1 & LE_ERR) {
596 1.5 mycroft sc->sc_rmd = bix;
597 1.5 mycroft lererror(sc, "bad packet");
598 1.5 mycroft sc->sc_if.if_ierrors++;
599 1.1 cgd } else if ((rmd->rmd1 & (LE_STP|LE_ENP)) != (LE_STP|LE_ENP)) {
600 1.1 cgd /*
601 1.1 cgd * Find the end of the packet so we can see how long
602 1.1 cgd * it was. We still throw it away.
603 1.1 cgd */
604 1.1 cgd do {
605 1.5 mycroft LERDWR(sc->sc_r0, LE_RINT|LE_INEA,
606 1.5 mycroft sc->sc_r1->ler1_rdp);
607 1.1 cgd rmd->rmd3 = 0;
608 1.1 cgd rmd->rmd1 = LE_OWN;
609 1.1 cgd LENEXTRMP;
610 1.1 cgd } while (!(rmd->rmd1 & (LE_OWN|LE_ERR|LE_STP|LE_ENP)));
611 1.5 mycroft sc->sc_rmd = bix;
612 1.5 mycroft lererror(sc, "chained buffer");
613 1.5 mycroft sc->sc_rxlen++;
614 1.1 cgd /*
615 1.1 cgd * If search terminated without successful completion
616 1.1 cgd * we reset the hardware (conservative).
617 1.1 cgd */
618 1.1 cgd if ((rmd->rmd1 & (LE_OWN|LE_ERR|LE_STP|LE_ENP)) !=
619 1.1 cgd LE_ENP) {
620 1.5 mycroft lereset(sc);
621 1.1 cgd return;
622 1.1 cgd }
623 1.1 cgd } else
624 1.5 mycroft leread(sc, sc->sc_r2->ler2_rbuf[bix], len);
625 1.1 cgd rmd->rmd3 = 0;
626 1.1 cgd rmd->rmd1 = LE_OWN;
627 1.1 cgd LENEXTRMP;
628 1.1 cgd }
629 1.5 mycroft sc->sc_rmd = bix;
630 1.1 cgd }
631 1.1 cgd
632 1.8 mycroft void
633 1.5 mycroft leread(sc, buf, len)
634 1.5 mycroft register struct le_softc *sc;
635 1.1 cgd char *buf;
636 1.1 cgd int len;
637 1.1 cgd {
638 1.1 cgd register struct ether_header *et;
639 1.5 mycroft register struct ifnet *ifp = &sc->sc_if;
640 1.1 cgd struct mbuf *m;
641 1.1 cgd
642 1.5 mycroft ifp->if_ipackets++;
643 1.1 cgd et = (struct ether_header *)buf;
644 1.1 cgd /* adjust input length to account for header and CRC */
645 1.5 mycroft len -= sizeof(struct ether_header) + 4;
646 1.1 cgd
647 1.1 cgd if (len <= 0) {
648 1.1 cgd if (ledebug)
649 1.1 cgd log(LOG_WARNING,
650 1.1 cgd "le%d: ierror(runt packet): from %s: len=%d\n",
651 1.5 mycroft sc->sc_if.if_unit, ether_sprintf(et->ether_shost),
652 1.5 mycroft len);
653 1.5 mycroft sc->sc_runt++;
654 1.5 mycroft ifp->if_ierrors++;
655 1.1 cgd return;
656 1.1 cgd }
657 1.5 mycroft
658 1.1 cgd #if NBPFILTER > 0
659 1.1 cgd /*
660 1.1 cgd * Check if there's a bpf filter listening on this interface.
661 1.5 mycroft * If so, hand off the raw packet to bpf, then discard things
662 1.5 mycroft * not destined for us (but be sure to keep broadcast/multicast).
663 1.1 cgd */
664 1.5 mycroft if (sc->sc_bpf) {
665 1.5 mycroft bpf_tap(sc->sc_bpf, buf, len + sizeof(struct ether_header));
666 1.5 mycroft if ((ifp->if_flags & IFF_PROMISC) &&
667 1.5 mycroft (et->ether_dhost[0] & 1) == 0 &&
668 1.5 mycroft bcmp(et->ether_dhost, sc->sc_addr,
669 1.5 mycroft sizeof(et->ether_dhost)) != 0 &&
670 1.5 mycroft bcmp(et->ether_dhost, etherbroadcastaddr,
671 1.1 cgd sizeof(et->ether_dhost)) != 0)
672 1.1 cgd return;
673 1.1 cgd }
674 1.1 cgd #endif
675 1.5 mycroft
676 1.5 mycroft m = leget(buf, len, 0, ifp);
677 1.1 cgd if (m == 0)
678 1.1 cgd return;
679 1.5 mycroft
680 1.5 mycroft ether_input(ifp, et, m);
681 1.1 cgd }
682 1.1 cgd
683 1.1 cgd /*
684 1.1 cgd * Routine to copy from mbuf chain to transmit
685 1.1 cgd * buffer in board local memory.
686 1.1 cgd */
687 1.8 mycroft int
688 1.1 cgd leput(lebuf, m)
689 1.1 cgd register char *lebuf;
690 1.1 cgd register struct mbuf *m;
691 1.1 cgd {
692 1.1 cgd register struct mbuf *mp;
693 1.1 cgd register int len, tlen = 0;
694 1.1 cgd
695 1.1 cgd for (mp = m; mp; mp = mp->m_next) {
696 1.1 cgd len = mp->m_len;
697 1.1 cgd if (len == 0)
698 1.1 cgd continue;
699 1.1 cgd tlen += len;
700 1.1 cgd bcopy(mtod(mp, char *), lebuf, len);
701 1.1 cgd lebuf += len;
702 1.1 cgd }
703 1.1 cgd m_freem(m);
704 1.1 cgd if (tlen < LEMINSIZE) {
705 1.1 cgd bzero(lebuf, LEMINSIZE - tlen);
706 1.1 cgd tlen = LEMINSIZE;
707 1.1 cgd }
708 1.1 cgd return(tlen);
709 1.1 cgd }
710 1.1 cgd
711 1.1 cgd /*
712 1.1 cgd * Routine to copy from board local memory into mbufs.
713 1.1 cgd */
714 1.1 cgd struct mbuf *
715 1.1 cgd leget(lebuf, totlen, off0, ifp)
716 1.1 cgd char *lebuf;
717 1.1 cgd int totlen, off0;
718 1.1 cgd struct ifnet *ifp;
719 1.1 cgd {
720 1.1 cgd register struct mbuf *m;
721 1.1 cgd struct mbuf *top = 0, **mp = ⊤
722 1.1 cgd register int off = off0, len;
723 1.1 cgd register char *cp;
724 1.1 cgd char *epkt;
725 1.1 cgd
726 1.1 cgd lebuf += sizeof (struct ether_header);
727 1.1 cgd cp = lebuf;
728 1.1 cgd epkt = cp + totlen;
729 1.1 cgd if (off) {
730 1.1 cgd cp += off + 2 * sizeof(u_short);
731 1.1 cgd totlen -= 2 * sizeof(u_short);
732 1.1 cgd }
733 1.1 cgd
734 1.1 cgd MGETHDR(m, M_DONTWAIT, MT_DATA);
735 1.1 cgd if (m == 0)
736 1.1 cgd return (0);
737 1.1 cgd m->m_pkthdr.rcvif = ifp;
738 1.1 cgd m->m_pkthdr.len = totlen;
739 1.1 cgd m->m_len = MHLEN;
740 1.1 cgd
741 1.1 cgd while (totlen > 0) {
742 1.1 cgd if (top) {
743 1.1 cgd MGET(m, M_DONTWAIT, MT_DATA);
744 1.1 cgd if (m == 0) {
745 1.1 cgd m_freem(top);
746 1.1 cgd return (0);
747 1.1 cgd }
748 1.1 cgd m->m_len = MLEN;
749 1.1 cgd }
750 1.1 cgd len = min(totlen, epkt - cp);
751 1.1 cgd if (len >= MINCLSIZE) {
752 1.1 cgd MCLGET(m, M_DONTWAIT);
753 1.1 cgd if (m->m_flags & M_EXT)
754 1.1 cgd m->m_len = len = min(len, MCLBYTES);
755 1.1 cgd else
756 1.1 cgd len = m->m_len;
757 1.1 cgd } else {
758 1.1 cgd /*
759 1.1 cgd * Place initial small packet/header at end of mbuf.
760 1.1 cgd */
761 1.1 cgd if (len < m->m_len) {
762 1.1 cgd if (top == 0 && len + max_linkhdr <= m->m_len)
763 1.1 cgd m->m_data += max_linkhdr;
764 1.1 cgd m->m_len = len;
765 1.1 cgd } else
766 1.1 cgd len = m->m_len;
767 1.1 cgd }
768 1.1 cgd bcopy(cp, mtod(m, caddr_t), (unsigned)len);
769 1.1 cgd cp += len;
770 1.1 cgd *mp = m;
771 1.1 cgd mp = &m->m_next;
772 1.1 cgd totlen -= len;
773 1.1 cgd if (cp == epkt)
774 1.1 cgd cp = lebuf;
775 1.1 cgd }
776 1.1 cgd return (top);
777 1.1 cgd }
778 1.1 cgd
779 1.1 cgd /*
780 1.1 cgd * Process an ioctl request.
781 1.1 cgd */
782 1.8 mycroft int
783 1.1 cgd leioctl(ifp, cmd, data)
784 1.1 cgd register struct ifnet *ifp;
785 1.1 cgd int cmd;
786 1.1 cgd caddr_t data;
787 1.1 cgd {
788 1.5 mycroft register struct ifaddr *ifa;
789 1.5 mycroft struct le_softc *sc = &le_softc[ifp->if_unit];
790 1.1 cgd int s = splimp(), error = 0;
791 1.1 cgd
792 1.1 cgd switch (cmd) {
793 1.1 cgd
794 1.1 cgd case SIOCSIFADDR:
795 1.5 mycroft ifa = (struct ifaddr *)data;
796 1.1 cgd ifp->if_flags |= IFF_UP;
797 1.1 cgd switch (ifa->ifa_addr->sa_family) {
798 1.1 cgd #ifdef INET
799 1.1 cgd case AF_INET:
800 1.1 cgd leinit(ifp->if_unit); /* before arpwhohas */
801 1.1 cgd ((struct arpcom *)ifp)->ac_ipaddr =
802 1.1 cgd IA_SIN(ifa)->sin_addr;
803 1.1 cgd arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr);
804 1.1 cgd break;
805 1.1 cgd #endif
806 1.1 cgd #ifdef NS
807 1.1 cgd case AF_NS:
808 1.1 cgd {
809 1.1 cgd register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
810 1.1 cgd
811 1.1 cgd if (ns_nullhost(*ina))
812 1.5 mycroft ina->x_host = *(union ns_host *)(sc->sc_addr);
813 1.1 cgd else {
814 1.1 cgd /*
815 1.1 cgd * The manual says we can't change the address
816 1.1 cgd * while the receiver is armed,
817 1.1 cgd * so reset everything
818 1.1 cgd */
819 1.1 cgd ifp->if_flags &= ~IFF_RUNNING;
820 1.8 mycroft LERDWR(sc->sc_r0, LE_STOP, sc->sc_r1->ler1_rdp);
821 1.1 cgd bcopy((caddr_t)ina->x_host.c_host,
822 1.5 mycroft (caddr_t)sc->sc_addr, sizeof(sc->sc_addr));
823 1.1 cgd }
824 1.1 cgd leinit(ifp->if_unit); /* does le_setaddr() */
825 1.1 cgd break;
826 1.1 cgd }
827 1.1 cgd #endif
828 1.1 cgd default:
829 1.1 cgd leinit(ifp->if_unit);
830 1.1 cgd break;
831 1.1 cgd }
832 1.1 cgd break;
833 1.1 cgd
834 1.1 cgd case SIOCSIFFLAGS:
835 1.1 cgd if ((ifp->if_flags & IFF_UP) == 0 &&
836 1.1 cgd ifp->if_flags & IFF_RUNNING) {
837 1.6 mycroft ifp->if_flags &= ~IFF_RUNNING;
838 1.8 mycroft LERDWR(sc->sc_r0, LE_STOP, sc->sc_r1->ler1_rdp);
839 1.1 cgd } else if (ifp->if_flags & IFF_UP &&
840 1.1 cgd (ifp->if_flags & IFF_RUNNING) == 0)
841 1.1 cgd leinit(ifp->if_unit);
842 1.1 cgd /*
843 1.1 cgd * If the state of the promiscuous bit changes, the interface
844 1.1 cgd * must be reset to effect the change.
845 1.1 cgd */
846 1.5 mycroft if (((ifp->if_flags ^ sc->sc_iflags) & IFF_PROMISC) &&
847 1.1 cgd (ifp->if_flags & IFF_RUNNING)) {
848 1.5 mycroft sc->sc_iflags = ifp->if_flags;
849 1.5 mycroft lereset(sc);
850 1.1 cgd lestart(ifp);
851 1.1 cgd }
852 1.1 cgd break;
853 1.1 cgd
854 1.5 mycroft case SIOCADDMULTI:
855 1.5 mycroft error = ether_addmulti((struct ifreq *)data, &sc->sc_ac);
856 1.5 mycroft goto update_multicast;
857 1.5 mycroft
858 1.5 mycroft case SIOCDELMULTI:
859 1.5 mycroft error = ether_delmulti((struct ifreq *)data, &sc->sc_ac);
860 1.5 mycroft update_multicast:
861 1.5 mycroft if (error == ENETRESET) {
862 1.5 mycroft /*
863 1.5 mycroft * Multicast list has changed; set the hardware
864 1.5 mycroft * filter accordingly.
865 1.5 mycroft */
866 1.5 mycroft lereset(sc);
867 1.5 mycroft error = 0;
868 1.5 mycroft }
869 1.5 mycroft break;
870 1.5 mycroft
871 1.1 cgd default:
872 1.1 cgd error = EINVAL;
873 1.1 cgd }
874 1.1 cgd splx(s);
875 1.1 cgd return (error);
876 1.1 cgd }
877 1.1 cgd
878 1.8 mycroft void
879 1.5 mycroft leerror(sc, stat)
880 1.5 mycroft register struct le_softc *sc;
881 1.1 cgd int stat;
882 1.1 cgd {
883 1.6 mycroft
884 1.1 cgd if (!ledebug)
885 1.1 cgd return;
886 1.1 cgd
887 1.1 cgd /*
888 1.1 cgd * Not all transceivers implement heartbeat
889 1.1 cgd * so we only log CERR once.
890 1.1 cgd */
891 1.5 mycroft if ((stat & LE_CERR) && sc->sc_cerr)
892 1.1 cgd return;
893 1.1 cgd log(LOG_WARNING,
894 1.5 mycroft "le%d: error: stat=%b\n", sc->sc_if.if_unit, stat,
895 1.1 cgd "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT");
896 1.1 cgd }
897 1.1 cgd
898 1.8 mycroft void
899 1.5 mycroft lererror(sc, msg)
900 1.5 mycroft register struct le_softc *sc;
901 1.1 cgd char *msg;
902 1.1 cgd {
903 1.1 cgd register struct lermd *rmd;
904 1.1 cgd int len;
905 1.1 cgd
906 1.1 cgd if (!ledebug)
907 1.1 cgd return;
908 1.1 cgd
909 1.5 mycroft rmd = &sc->sc_r2->ler2_rmd[sc->sc_rmd];
910 1.1 cgd len = rmd->rmd3;
911 1.1 cgd log(LOG_WARNING,
912 1.1 cgd "le%d: ierror(%s): from %s: buf=%d, len=%d, rmd1=%b\n",
913 1.5 mycroft sc->sc_if.if_unit, msg,
914 1.5 mycroft len > 11 ? ether_sprintf(&sc->sc_r2->ler2_rbuf[sc->sc_rmd][6]) : "unknown",
915 1.5 mycroft sc->sc_rmd, len, rmd->rmd1,
916 1.1 cgd "\20\20OWN\17ERR\16FRAM\15OFLO\14CRC\13RBUF\12STP\11ENP");
917 1.1 cgd }
918 1.1 cgd
919 1.8 mycroft void
920 1.5 mycroft lexerror(sc)
921 1.5 mycroft register struct le_softc *sc;
922 1.1 cgd {
923 1.1 cgd register struct letmd *tmd;
924 1.5 mycroft register int len;
925 1.1 cgd
926 1.1 cgd if (!ledebug)
927 1.1 cgd return;
928 1.1 cgd
929 1.5 mycroft tmd = sc->sc_r2->ler2_tmd;
930 1.1 cgd len = -tmd->tmd2;
931 1.1 cgd log(LOG_WARNING,
932 1.1 cgd "le%d: oerror: to %s: buf=%d, len=%d, tmd1=%b, tmd3=%b\n",
933 1.5 mycroft sc->sc_if.if_unit,
934 1.5 mycroft len > 5 ? ether_sprintf(&sc->sc_r2->ler2_tbuf[0][0]) : "unknown",
935 1.5 mycroft 0, len, tmd->tmd1,
936 1.1 cgd "\20\20OWN\17ERR\16RES\15MORE\14ONE\13DEF\12STP\11ENP",
937 1.1 cgd tmd->tmd3,
938 1.1 cgd "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY");
939 1.1 cgd }
940 1.1 cgd #endif
941