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