if_le.c revision 1.3 1 /* $NetBSD: if_le.c,v 1.3 1999/03/25 23:12:10 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1993 Adam Glass
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Adam Glass.
18 * 4. The name of the Author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #include <sys/param.h>
35 #include <sys/types.h>
36
37 #include <netinet/in.h>
38 #include <netinet/in_systm.h>
39
40 #include <lib/libsa/netif.h>
41
42 #include <hp300/stand/common/device.h>
43 #include <hp300/stand/common/if_lereg.h>
44 #include <hp300/stand/common/samachdep.h>
45
46 #ifndef NLE
47 #define NLE 1
48 #endif
49
50 #ifdef LE_DEBUG
51 int le_debug = 0;
52 #endif
53
54 int le_probe();
55 int le_match();
56 void le_init();
57 int le_get();
58 int le_put();
59 void le_end();
60
61 struct le_sel {
62 int le_id;
63 int le_regs;
64 int le_mem;
65 int le_nvram;
66 int le_heat;
67 int le_bonus;
68 } le0conf[] = {
69 /* offsets for: ID REGS MEM NVRAM le_heat le_bonus*/
70 { 0, 0x4000, 0x8000, 0xC008, 1, 10 }
71 };
72
73 extern struct netif_stats le_stats[];
74
75 struct netif_dif le_ifs[] = {
76 /* dif_unit dif_nsel dif_stats dif_private */
77 { 0, NENTS(le0conf), &le_stats[0], le0conf, },
78 };
79
80 struct netif_stats le_stats[NENTS(le_ifs)];
81
82 struct netif_driver le_driver = {
83 "le", /* netif_bname */
84 le_match, /* netif_match */
85 le_probe, /* netif_probe */
86 le_init, /* netif_init */
87 le_get, /* netif_get */
88 le_put, /* netif_put */
89 le_end, /* netif_end */
90 le_ifs, /* netif_ifs */
91 NENTS(le_ifs) /* netif_nifs */
92 };
93
94 struct le_softc {
95 struct lereg0 *sc_r0; /* DIO registers */
96 struct lereg1 *sc_r1; /* LANCE registers */
97 void *sc_mem;
98 struct init_block *sc_init;
99 struct mds *sc_rd, *sc_td;
100 u_char *sc_rbuf, *sc_tbuf;
101 int sc_next_rd, sc_next_td;
102 u_char sc_addr[ETHER_ADDR_LEN];
103 } le_softc[NLE];
104
105 static inline void
106 lewrcsr(sc, port, val)
107 struct le_softc *sc;
108 register u_short port;
109 register u_short val;
110 {
111 register struct lereg0 *ler0 = sc->sc_r0;
112 register struct lereg1 *ler1 = sc->sc_r1;
113
114 do {
115 ler1->ler1_rap = port;
116 } while ((ler0->ler0_status & LE_ACK) == 0);
117 do {
118 ler1->ler1_rdp = val;
119 } while ((ler0->ler0_status & LE_ACK) == 0);
120 }
121
122 static inline u_short
123 lerdcsr(sc, port)
124 struct le_softc *sc;
125 register u_short port;
126 {
127 register struct lereg0 *ler0 = sc->sc_r0;
128 register struct lereg1 *ler1 = sc->sc_r1;
129 register u_short val;
130
131 do {
132 ler1->ler1_rap = port;
133 } while ((ler0->ler0_status & LE_ACK) == 0);
134 do {
135 val = ler1->ler1_rdp;
136 } while ((ler0->ler0_status & LE_ACK) == 0);
137 return (val);
138 }
139
140 leinit()
141 {
142 extern struct hp_hw sc_table[];
143 register struct hp_hw *hw;
144 struct le_softc *sc;
145 struct le_sel *sels;
146 register int i, n;
147 char *cp;
148
149 i = 0;
150
151 for (hw = sc_table; i < NLE && hw < &sc_table[MAXCTLRS]; hw++) {
152 #ifdef LE_DEBUG
153 if (le_debug)
154 printf("found type %x\n", hw->hw_type);
155 #endif
156
157 #if 0
158 if (!HW_ISDEV(hw, D_LAN))
159 continue;
160 #endif
161
162 sels = (struct le_sel *)le_ifs[i].dif_private;
163
164 sc = &le_softc[i];
165 sc->sc_r0 = (struct lereg0 *)(sels->le_id + (int)hw->hw_kva);
166
167 if (sc->sc_r0->ler0_id != LEID)
168 continue;
169
170 sc->sc_r1 = (struct lereg1 *)(sels->le_regs + (int)hw->hw_kva);
171 sc->sc_mem = (struct lereg2 *)(sels->le_mem + (int)hw->hw_kva);
172
173 #ifdef LE_DEBUG
174 if (le_debug)
175 printf("le%d: DIO=%x regs=%x mem=%x\n",
176 i, sc->sc_r0, sc->sc_r1, sc->sc_mem);
177 #endif
178
179 /*
180 * Read the ethernet address off the board, one nibble at a time.
181 */
182 cp = (char *)(sels->le_nvram + (int)hw->hw_kva);
183 for (n = 0; n < sizeof(sc->sc_addr); n++) {
184 sc->sc_addr[n] = (*++cp & 0xF) << 4;
185 cp++;
186 sc->sc_addr[n] |= *++cp & 0xF;
187 cp++;
188 }
189 #ifdef LE_DEBUG
190 if (le_debug)
191 printf("le%d at sc%d physical address %s\n",
192 i, hw->hw_sc, ether_sprintf(sc->sc_addr));
193 #endif
194 hw->hw_pa = (caddr_t) i; /* XXX for autoconfig */
195 i++;
196 }
197 }
198
199 int
200 le_match(nif, machdep_hint)
201 struct netif *nif;
202 void *machdep_hint;
203 {
204 struct le_sel *sels;
205 char *name = machdep_hint;
206 int rv = 0;
207
208 if (nif->nif_sel < le_ifs[nif->nif_unit].dif_nsel) {
209 sels = (struct le_sel *)le_ifs[nif->nif_unit].dif_private;
210 rv = sels[nif->nif_sel].le_heat;
211 if (name && !strncmp(le_driver.netif_bname, name, 2))
212 rv += sels[nif->nif_sel].le_bonus;
213 }
214 #ifdef LE_DEBUG
215 if (le_debug)
216 printf("le%d: sel %d --> %d\n", nif->nif_unit, nif->nif_sel,
217 rv);
218 #endif
219 return rv;
220 }
221
222 le_probe(nif, machdep_hint)
223 struct netif *nif;
224 void *machdep_hint;
225 {
226 char *cp;
227 int i;
228
229 /* the set unit is the current unit */
230 #ifdef LE_DEBUG
231 if (le_debug)
232 printf("le%d.%d: le_probe called\n", nif->nif_unit, nif->nif_sel);
233 #endif
234 /* XXX reset controller */
235 return 0;
236 }
237
238 #ifdef MEM_SUMMARY
239 void le_mem_summary(unit)
240 {
241 struct lereg1 *ler1 = le_softc.sc_r1;
242 struct lereg2 *ler2 = le_softc.sc_r2;
243 register int i;
244
245 printf("le%d: ler1 = %x\n", unit, ler1);
246 printf("le%d: ler2 = %x\n", unit, ler2);
247
248 #if 0
249 ler1->ler1_rap = LE_CSR0;
250 ler1->ler1_rdp = LE_STOP;
251 printf("le%d: csr0 = %x\n", unit, ler1->ler1_rdp);
252 ler1->ler1_rap = LE_CSR1;
253 printf("le%d: csr1 = %x\n", unit, ler1->ler1_rdp);
254 ler1->ler1_rap = LE_CSR2;
255 printf("le%d: csr2 = %x\n", unit, ler1->ler1_rdp);
256 ler1->ler1_rap = LE_CSR3;
257 printf("le%d: csr3 = %x\n", unit, ler1->ler1_rdp);
258 #endif
259 printf("le%d: ladrf[0] = %x\n", unit, ler2->ler2_ladrf[0]);
260 printf("le%d: ladrf[1] = %x\n", unit, ler2->ler2_ladrf[1]);
261 printf("le%d: ler2_rdra = %x\n", unit, ler2->ler2_rdra);
262 printf("le%d: ler2_rlen = %x\n", unit, ler2->ler2_rlen);
263 printf("le%d: ler2_tdra = %x\n", unit, ler2->ler2_tdra);
264 printf("le%d: ler2_tlen = %x\n", unit, ler2->ler2_tlen);
265
266 for (i = 0; i < LERBUF; i++) {
267 printf("le%d: ler2_rmd[%d].rmd0 (ladr) = %x\n", unit, i,
268 ler2->ler2_rmd[i].rmd0);
269 printf("le%d: ler2_rmd[%d].rmd1 = %x\n", unit, i,
270 ler2->ler2_rmd[i].rmd1);
271 printf("le%d: ler2_rmd[%d].rmd2 (-bcnt) = %x\n", unit, i,
272 ler2->ler2_rmd[i].rmd2);
273 printf("le%d: ler2_rmd[%d].rmd3 (mcnt) = %x\n", unit, i,
274 ler2->ler2_rmd[i].rmd3);
275 printf("le%d: ler2_rbuf[%d] addr = %x\n", unit, i,
276 &ler2->ler2_rbuf[i]);
277 }
278 for (i = 0; i < LETBUF; i++) {
279 printf("le%d: ler2_tmd[%d].tmd0 = %x\n", unit, i,
280 ler2->ler2_tmd[i].tmd0);
281 printf("le%d: ler2_tmd[%d].tmd1 = %x\n", unit, i,
282 ler2->ler2_tmd[i].tmd1);
283 printf("le%d: ler2_tmd[%d].tmd2 (bcnt) = %x\n", unit, i,
284 ler2->ler2_tmd[i].tmd2);
285 printf("le%d: ler2_tmd[%d].tmd3 = %x\n", unit, i,
286 ler2->ler2_tmd[i].tmd3);
287 printf("le%d: ler2_tbuf[%d] addr = %x\n", unit, i,
288 &ler2->ler2_tbuf[i]);
289 }
290 }
291 #else
292 #define le_mem_summary(u)
293 #endif
294
295 void
296 le_error(unit, str, stat)
297 int unit;
298 char *str;
299 u_short stat;
300 {
301
302 if (stat & LE_BABL)
303 panic("le%d: been babbling, found by '%s'\n", unit, str);
304 if (stat & LE_CERR)
305 le_stats[unit].collision_error++;
306 if (stat & LE_MISS)
307 le_stats[unit].missed++;
308 if (stat & LE_MERR) {
309 printf("le%d: memory error in '%s'\n", unit, str);
310 le_mem_summary(unit);
311 panic("bye");
312 }
313 }
314
315 #define LANCE_ADDR(sc, a) \
316 ((u_long)(a) - (u_long)sc->sc_mem)
317
318 /* LANCE initialization block set up. */
319 void
320 lememinit(sc)
321 register struct le_softc *sc;
322 {
323 int i;
324 void *mem;
325 u_long a;
326
327 /*
328 * At this point we assume that the memory allocated to the Lance is
329 * quadword aligned. If it isn't then the initialisation is going
330 * fail later on.
331 */
332 mem = sc->sc_mem;
333
334 sc->sc_init = mem;
335 sc->sc_init->mode = LE_NORMAL;
336 for (i = 0; i < ETHER_ADDR_LEN; i++)
337 sc->sc_init->padr[i] = sc->sc_addr[i^1];
338 sc->sc_init->ladrf[0] = sc->sc_init->ladrf[1] = 0;
339 mem += sizeof(struct init_block);
340
341 sc->sc_rd = mem;
342 a = LANCE_ADDR(sc, mem);
343 sc->sc_init->rdra = a;
344 sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13);
345 mem += NRBUF * sizeof(struct mds);
346
347 sc->sc_td = mem;
348 a = LANCE_ADDR(sc, mem);
349 sc->sc_init->tdra = a;
350 sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13);
351 mem += NTBUF * sizeof(struct mds);
352
353 /*
354 * Set up receive ring descriptors.
355 */
356 sc->sc_rbuf = mem;
357 for (i = 0; i < NRBUF; i++) {
358 a = LANCE_ADDR(sc, mem);
359 sc->sc_rd[i].addr = a;
360 sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN;
361 sc->sc_rd[i].bcnt = -BUFSIZE;
362 sc->sc_rd[i].mcnt = 0;
363 mem += BUFSIZE;
364 }
365
366 /*
367 * Set up transmit ring descriptors.
368 */
369 sc->sc_tbuf = mem;
370 for (i = 0; i < NTBUF; i++) {
371 a = LANCE_ADDR(sc, mem);
372 sc->sc_td[i].addr = a;
373 sc->sc_td[i].flags = ((a >> 16) & 0xff);
374 sc->sc_td[i].bcnt = 0xf000;
375 sc->sc_td[i].mcnt = 0;
376 mem += BUFSIZE;
377 }
378 }
379
380 void
381 le_reset(unit, myea)
382 int unit;
383 u_char *myea;
384 {
385 struct le_softc *sc = &le_softc[unit];
386 u_long a;
387 int timo = 100000, stat, i;
388
389 #ifdef LE_DEBUG
390 if (le_debug) {
391 printf("le%d: le_reset called\n", unit);
392 printf(" r0=%x, r1=%x, mem=%x, addr=%x:%x:%x:%x:%x:%x\n",
393 sc->sc_r0, sc->sc_r1, sc->sc_mem,
394 sc->sc_addr[0], sc->sc_addr[1], sc->sc_addr[2],
395 sc->sc_addr[3], sc->sc_addr[4], sc->sc_addr[5]);
396 }
397 #endif
398 lewrcsr(sc, 0, LE_STOP);
399 for (timo = 1000; timo; timo--);
400
401 sc->sc_next_rd = sc->sc_next_td = 0;
402
403 /* Set up LANCE init block. */
404 lememinit(sc);
405
406 if (myea)
407 bcopy(sc->sc_addr, myea, ETHER_ADDR_LEN);
408
409 /* Turn on byte swapping. */
410 lewrcsr(sc, 3, LE_BSWP);
411
412 /* Give LANCE the physical address of its init block. */
413 a = LANCE_ADDR(sc, sc->sc_init);
414 lewrcsr(sc, 1, a);
415 lewrcsr(sc, 2, (a >> 16) & 0xff);
416
417 #ifdef LE_DEBUG
418 if (le_debug)
419 printf("le%d: before init\n", unit);
420 #endif
421
422 /* Try to initialize the LANCE. */
423 lewrcsr(sc, 0, LE_INIT);
424
425 /* Wait for initialization to finish. */
426 for (timo = 100000; timo; timo--)
427 if (lerdcsr(sc, 0) & LE_IDON)
428 break;
429
430 if (lerdcsr(sc, 0) & LE_IDON) {
431 /* Start the LANCE. */
432 lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON);
433 } else
434 printf("le%d: card failed to initialize\n", unit);
435
436 #ifdef LE_DEBUG
437 if (le_debug)
438 printf("le%d: after init\n", unit);
439 #endif
440
441 le_mem_summary(unit);
442 }
443
444 int
445 le_poll(desc, pkt, len)
446 struct iodesc *desc;
447 void *pkt;
448 int len;
449 {
450 struct netif *nif = desc->io_netif;
451 int unit = /*nif->nif_unit*/0;
452 struct le_softc *sc = &le_softc[unit];
453 volatile struct lereg0 *ler0 = sc->sc_r0;
454 volatile struct lereg1 *ler1 = sc->sc_r1;
455 int length;
456 volatile struct mds *cdm;
457 register int stat;
458
459 #ifdef LE_DEBUG
460 if (/*le_debug*/0)
461 printf("le%d: le_poll called. next_rd=%d\n", unit, sc->sc_next_rd);
462 #endif
463 stat = lerdcsr(sc, 0);
464 lewrcsr(sc, 0, stat & (LE_BABL | LE_MISS | LE_MERR | LE_RINT));
465 cdm = &sc->sc_rd[sc->sc_next_rd];
466 if (cdm->flags & LE_OWN)
467 return 0;
468 #ifdef LE_DEBUG
469 if (le_debug) {
470 printf("next_rd %d\n", sc->sc_next_rd);
471 printf("cdm->flags %x\n", cdm->flags);
472 printf("cdm->bcnt %x, cdm->mcnt %x\n", cdm->bcnt, cdm->mcnt);
473 printf("cdm->rbuf msg %d buf %d\n", cdm->mcnt, -cdm->bcnt );
474 }
475 #endif
476 if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
477 le_error(unit, "le_poll", stat);
478 if (cdm->flags & (LE_FRAM | LE_OFLO | LE_CRC | LE_RBUFF)) {
479 printf("le%d_poll: rmd status 0x%x\n", unit, cdm->flags);
480 length = 0;
481 goto cleanup;
482 }
483 if ((cdm->flags & (LE_STP|LE_ENP)) != (LE_STP|LE_ENP))
484 panic("le_poll: chained packet\n");
485
486 length = cdm->mcnt;
487 #ifdef LE_DEBUG
488 if (le_debug)
489 printf("le_poll: length %d\n", length);
490 #endif
491 if (length >= BUFSIZE) {
492 length = 0;
493 panic("csr0 when bad things happen: %x\n", stat);
494 goto cleanup;
495 }
496 if (!length)
497 goto cleanup;
498 length -= 4;
499
500 if (length > 0) {
501 /*
502 * If the length of the packet is greater than the size of the
503 * buffer, we have to truncate it, to avoid Bad Things.
504 * XXX Is this the right thing to do?
505 */
506 if (length > len)
507 length = len;
508
509 bcopy(sc->sc_rbuf + (BUFSIZE * sc->sc_next_rd), pkt, length);
510 }
511
512 cleanup:
513 cdm->mcnt = 0;
514 cdm->flags |= LE_OWN;
515 if (++sc->sc_next_rd >= NRBUF)
516 sc->sc_next_rd = 0;
517 #ifdef LE_DEBUG
518 if (le_debug)
519 printf("new next_rd %d\n", sc->sc_next_rd);
520 #endif
521
522 return length;
523 }
524
525 int
526 le_put(desc, pkt, len)
527 struct iodesc *desc;
528 void *pkt;
529 int len;
530 {
531 struct netif *nif = desc->io_netif;
532 int unit = /*nif->nif_unit*/0;
533 struct le_softc *sc = &le_softc[unit];
534 volatile struct lereg0 *ler0 = sc->sc_r0;
535 volatile struct lereg1 *ler1 = sc->sc_r1;
536 volatile struct mds *cdm;
537 int timo, i, stat;
538
539 le_put_loop:
540 timo = 100000;
541
542 #ifdef LE_DEBUG
543 if (le_debug)
544 printf("le%d: le_put called. next_td=%d\n", unit, sc->sc_next_td);
545 #endif
546 stat = lerdcsr(sc, 0);
547 lewrcsr(sc, 0, stat & (LE_BABL | LE_MISS | LE_MERR | LE_TINT));
548 if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
549 le_error(unit, "le_put(way before xmit)", stat);
550 cdm = &sc->sc_td[sc->sc_next_td];
551 i = 0;
552 #if 0
553 while (cdm->flags & LE_OWN) {
554 if ((i % 100) == 0)
555 printf("le%d: output buffer busy - flags=%x\n",
556 unit, cdm->flags);
557 if (i++ > 500) break;
558 }
559 if (cdm->flags & LE_OWN)
560 getchar();
561 #else
562 while (cdm->flags & LE_OWN);
563 #endif
564 bcopy(pkt, sc->sc_tbuf + (BUFSIZE * sc->sc_next_td), len);
565 if (len < ETHER_MIN_LEN)
566 cdm->bcnt = -ETHER_MIN_LEN;
567 else
568 cdm->bcnt = -len;
569 cdm->mcnt = 0;
570 cdm->flags |= LE_OWN | LE_STP | LE_ENP;
571 stat = lerdcsr(sc, 0);
572 if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
573 le_error(unit, "le_put(before xmit)", stat);
574 lewrcsr(sc, 0, LE_TDMD);
575 stat = lerdcsr(sc, 0);
576 if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
577 le_error(unit, "le_put(after xmit)", stat);
578 do {
579 if (--timo == 0) {
580 printf("le%d: transmit timeout, stat = 0x%x\n",
581 unit, stat);
582 if (stat & LE_SERR)
583 le_error(unit, "le_put(timeout)", stat);
584 if (stat & LE_INIT) {
585 printf("le%d: reset and retry packet\n");
586 lewrcsr(sc, 0, LE_TINT); /* sanity */
587 le_init();
588 goto le_put_loop;
589 }
590 break;
591 }
592 stat = lerdcsr(sc, 0);
593 } while ((stat & LE_TINT) == 0);
594 lewrcsr(sc, 0, LE_TINT);
595 if (stat & (LE_BABL |/* LE_CERR |*/ LE_MISS | LE_MERR)) {
596 printf("le_put: xmit error, buf %d\n", sc->sc_next_td);
597 le_error(unit, "le_put(xmit error)", stat);
598 }
599 if (++sc->sc_next_td >= NTBUF)
600 sc->sc_next_td = 0;
601 if (cdm->flags & LE_DEF)
602 le_stats[unit].deferred++;
603 if (cdm->flags & LE_ONE)
604 le_stats[unit].collisions++;
605 if (cdm->flags & LE_MORE)
606 le_stats[unit].collisions += 2;
607 if (cdm->flags & LE_ERR) {
608 if (cdm->mcnt & LE_UFLO)
609 printf("le%d: transmit underflow\n", unit);
610 if (cdm->mcnt & LE_LCOL)
611 le_stats[unit].collisions++;
612 if (cdm->mcnt & LE_LCAR)
613 printf("le%d: lost carrier\n", unit);
614 if (cdm->mcnt & LE_RTRY)
615 le_stats[unit].collisions += 16;
616 return -1;
617 }
618 #ifdef LE_DEBUG
619 if (le_debug) {
620 printf("le%d: le_put() successful: sent %d\n", unit, len);
621 printf("le%d: le_put(): flags: %x mcnt: %x\n", unit,
622 (unsigned int) cdm->flags,
623 (unsigned int) cdm->mcnt);
624 }
625 #endif
626 return len;
627 }
628
629
630 int
631 le_get(desc, pkt, len, timeout)
632 struct iodesc *desc;
633 void *pkt;
634 int len;
635 time_t timeout;
636 {
637 time_t t;
638 int cc;
639
640 t = getsecs();
641 cc = 0;
642 while (((getsecs() - t) < timeout) && !cc) {
643 cc = le_poll(desc, pkt, len);
644 }
645 return cc;
646 }
647
648 void
649 le_init(desc, machdep_hint)
650 struct iodesc *desc;
651 void *machdep_hint;
652 {
653 struct netif *nif = desc->io_netif;
654 int unit = nif->nif_unit;
655
656 /* Get machine's common ethernet interface. This is done in leinit() */
657 /* machdep_common_ether(myea); */
658 leinit();
659
660 #ifdef LE_DEBUG
661 if (le_debug)
662 printf("le%d: le_init called\n", unit);
663 #endif
664 unit = 0;
665 le_reset(unit, desc->myea);
666 }
667
668 void
669 le_end(nif)
670 struct netif *nif;
671 {
672 int unit = nif->nif_unit;
673
674 #ifdef LE_DEBUG
675 if (le_debug)
676 printf("le%d: le_end called\n", unit);
677 #endif
678
679 lewrcsr(&le_softc[unit], 0, LE_STOP);
680 }
681