am7990.c (6cec9cad762b6476313fb1f8e931a1647822db6b) am7990.c (c8dfaf382fa6df9dc6fd1e1c3356e0c8bf607e6a)
1/* $NetBSD: am7990.c,v 1.68 2005/12/11 12:21:25 christos Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace

--- 258 unchanged lines hidden (view full) ---

267 rmd.rmd2 = -LEBLEN | LE_XMD2_ONES;
268 rmd.rmd3 = 0;
269 (*sc->sc_copytodesc)(sc, &rmd, rp, sizeof(rmd));
270
271 if (++bix == sc->sc_nrbuf)
272 bix = 0;
273
274 if (m != NULL) {
1/* $NetBSD: am7990.c,v 1.68 2005/12/11 12:21:25 christos Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace

--- 258 unchanged lines hidden (view full) ---

267 rmd.rmd2 = -LEBLEN | LE_XMD2_ONES;
268 rmd.rmd3 = 0;
269 (*sc->sc_copytodesc)(sc, &rmd, rp, sizeof(rmd));
270
271 if (++bix == sc->sc_nrbuf)
272 bix = 0;
273
274 if (m != NULL) {
275 ifp->if_ipackets++;
275 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
276
277#ifdef LANCE_REVC_BUG
278 /*
279 * The old LANCE (Rev. C) chips have a bug which
280 * causes garbage to be inserted in front of the
281 * received packet. The workaround is to ignore
282 * packets with an invalid destination address
283 * (garbage will usually not match).

--- 7 unchanged lines hidden (view full) ---

291 }
292#endif
293
294 /* Pass the packet up. */
295 LE_UNLOCK(sc);
296 (*ifp->if_input)(ifp, m);
297 LE_LOCK(sc);
298 } else
276
277#ifdef LANCE_REVC_BUG
278 /*
279 * The old LANCE (Rev. C) chips have a bug which
280 * causes garbage to be inserted in front of the
281 * received packet. The workaround is to ignore
282 * packets with an invalid destination address
283 * (garbage will usually not match).

--- 7 unchanged lines hidden (view full) ---

291 }
292#endif
293
294 /* Pass the packet up. */
295 LE_UNLOCK(sc);
296 (*ifp->if_input)(ifp, m);
297 LE_LOCK(sc);
298 } else
299 ifp->if_ierrors++;
299 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
300 }
301
302 sc->sc_last_rd = bix;
303}
304
305static void
306am7990_tint(struct lance_softc *sc)
307{

--- 39 unchanged lines hidden (view full) ---

347 LINK_STATE_DOWN);
348 sc->sc_flags &= ~LE_CARRIER;
349 if (sc->sc_nocarrier)
350 (*sc->sc_nocarrier)(sc);
351 else
352 if_printf(ifp, "lost carrier\n");
353 }
354 if (tmd.tmd3 & LE_T3_LCOL)
300 }
301
302 sc->sc_last_rd = bix;
303}
304
305static void
306am7990_tint(struct lance_softc *sc)
307{

--- 39 unchanged lines hidden (view full) ---

347 LINK_STATE_DOWN);
348 sc->sc_flags &= ~LE_CARRIER;
349 if (sc->sc_nocarrier)
350 (*sc->sc_nocarrier)(sc);
351 else
352 if_printf(ifp, "lost carrier\n");
353 }
354 if (tmd.tmd3 & LE_T3_LCOL)
355 ifp->if_collisions++;
355 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
356 if (tmd.tmd3 & LE_T3_RTRY) {
357#ifdef LEDEBUG
358 if_printf(ifp, "excessive collisions, tdr %d\n",
359 tmd.tmd3 & LE_T3_TDR_MASK);
360#endif
356 if (tmd.tmd3 & LE_T3_RTRY) {
357#ifdef LEDEBUG
358 if_printf(ifp, "excessive collisions, tdr %d\n",
359 tmd.tmd3 & LE_T3_TDR_MASK);
360#endif
361 ifp->if_collisions += 16;
361 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16);
362 }
362 }
363 ifp->if_oerrors++;
363 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
364 } else {
365 if (tmd.tmd1_bits & LE_T1_ONE)
364 } else {
365 if (tmd.tmd1_bits & LE_T1_ONE)
366 ifp->if_collisions++;
366 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
367 else if (tmd.tmd1_bits & LE_T1_MORE)
368 /* Real number is unknown. */
367 else if (tmd.tmd1_bits & LE_T1_MORE)
368 /* Real number is unknown. */
369 ifp->if_collisions += 2;
370 ifp->if_opackets++;
369 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2);
370 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
371 }
372
373 if (++bix == sc->sc_ntbuf)
374 bix = 0;
375
376 --sc->sc_no_td;
377 }
378

--- 10 unchanged lines hidden (view full) ---

389{
390 struct lance_softc *sc = arg;
391 struct ifnet *ifp = sc->sc_ifp;
392 uint16_t isr;
393
394 LE_LOCK(sc);
395
396 if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
371 }
372
373 if (++bix == sc->sc_ntbuf)
374 bix = 0;
375
376 --sc->sc_no_td;
377 }
378

--- 10 unchanged lines hidden (view full) ---

389{
390 struct lance_softc *sc = arg;
391 struct ifnet *ifp = sc->sc_ifp;
392 uint16_t isr;
393
394 LE_LOCK(sc);
395
396 if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
397 ifp->if_ierrors++;
397 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
398 lance_init_locked(sc);
399 LE_UNLOCK(sc);
400 return;
401 }
402
403 isr = (*sc->sc_rdcsr)(sc, LE_CSR0);
404#if defined(LEDEBUG) && LEDEBUG > 1
405 if (sc->sc_flags & LE_DEBUG)

--- 15 unchanged lines hidden (view full) ---

421 (*sc->sc_wrcsr)(sc, LE_CSR0, isr & ~(LE_C0_INEA | LE_C0_TDMD |
422 LE_C0_STOP | LE_C0_STRT | LE_C0_INIT));
423
424 if (isr & LE_C0_ERR) {
425 if (isr & LE_C0_BABL) {
426#ifdef LEDEBUG
427 if_printf(ifp, "babble\n");
428#endif
398 lance_init_locked(sc);
399 LE_UNLOCK(sc);
400 return;
401 }
402
403 isr = (*sc->sc_rdcsr)(sc, LE_CSR0);
404#if defined(LEDEBUG) && LEDEBUG > 1
405 if (sc->sc_flags & LE_DEBUG)

--- 15 unchanged lines hidden (view full) ---

421 (*sc->sc_wrcsr)(sc, LE_CSR0, isr & ~(LE_C0_INEA | LE_C0_TDMD |
422 LE_C0_STOP | LE_C0_STRT | LE_C0_INIT));
423
424 if (isr & LE_C0_ERR) {
425 if (isr & LE_C0_BABL) {
426#ifdef LEDEBUG
427 if_printf(ifp, "babble\n");
428#endif
429 ifp->if_oerrors++;
429 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
430 }
431#if 0
432 if (isr & LE_C0_CERR) {
433 if_printf(ifp, "collision error\n");
430 }
431#if 0
432 if (isr & LE_C0_CERR) {
433 if_printf(ifp, "collision error\n");
434 ifp->if_collisions++;
434 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
435 }
436#endif
437 if (isr & LE_C0_MISS) {
438#ifdef LEDEBUG
439 if_printf(ifp, "missed packet\n");
440#endif
435 }
436#endif
437 if (isr & LE_C0_MISS) {
438#ifdef LEDEBUG
439 if_printf(ifp, "missed packet\n");
440#endif
441 ifp->if_ierrors++;
441 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
442 }
443 if (isr & LE_C0_MERR) {
444 if_printf(ifp, "memory error\n");
445 lance_init_locked(sc);
446 LE_UNLOCK(sc);
447 return;
448 }
449 }
450
451 if ((isr & LE_C0_RXON) == 0) {
452 if_printf(ifp, "receiver disabled\n");
442 }
443 if (isr & LE_C0_MERR) {
444 if_printf(ifp, "memory error\n");
445 lance_init_locked(sc);
446 LE_UNLOCK(sc);
447 return;
448 }
449 }
450
451 if ((isr & LE_C0_RXON) == 0) {
452 if_printf(ifp, "receiver disabled\n");
453 ifp->if_ierrors++;
453 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
454 lance_init_locked(sc);
455 LE_UNLOCK(sc);
456 return;
457 }
458 if ((isr & LE_C0_TXON) == 0) {
459 if_printf(ifp, "transmitter disabled\n");
454 lance_init_locked(sc);
455 LE_UNLOCK(sc);
456 return;
457 }
458 if ((isr & LE_C0_TXON) == 0) {
459 if_printf(ifp, "transmitter disabled\n");
460 ifp->if_oerrors++;
460 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
461 lance_init_locked(sc);
462 LE_UNLOCK(sc);
463 return;
464 }
465
466 /*
467 * Pretend we have carrier; if we don't this will be cleared shortly.
468 */

--- 151 unchanged lines hidden ---
461 lance_init_locked(sc);
462 LE_UNLOCK(sc);
463 return;
464 }
465
466 /*
467 * Pretend we have carrier; if we don't this will be cleared shortly.
468 */

--- 151 unchanged lines hidden ---