--- sys/pci/if_rl.c.orig 2008-03-03 13:15:08.000000000 +0900 +++ sys/pci/if_rl.c 2008-03-31 14:16:02.000000000 +0900 @@ -1117,17 +1117,19 @@ * datasheet makes absolutely no mention of this and * RealTek should be shot for this. */ - if ((uint16_t)(rxstat >> 16) == RL_RXSTAT_UNFINISHED) + total_len = rxstat >> 16; + if (total_len == RL_RXSTAT_UNFINISHED) break; - if (!(rxstat & RL_RXSTAT_RXOK)) { + if (!(rxstat & RL_RXSTAT_RXOK) || + total_len < ETHER_MIN_LEN || + total_len > ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) { ifp->if_ierrors++; rl_init_locked(sc); return; } /* No errors; receive the packet. */ - total_len = rxstat >> 16; rx_bytes += total_len + 4; /* @@ -1244,8 +1246,6 @@ if (RL_LAST_TXMBUF(sc) == NULL) sc->rl_watchdog_timer = 0; - else if (sc->rl_watchdog_timer == 0) - sc->rl_watchdog_timer = 5; } static void @@ -1326,27 +1326,32 @@ goto done_locked; #endif - for (;;) { - status = CSR_READ_2(sc, RL_ISR); + status = CSR_READ_2(sc, RL_ISR); + if (status == 0 || status == 0xffff || (status & RL_INTRS) == 0) + goto done_locked; + + /* Disable interrupts. */ + CSR_WRITE_2(sc, RL_IMR, 0); + + for (; (status & RL_INTRS) != 0;) { /* If the card has gone away, the read returns 0xffff. */ if (status == 0xffff) break; - if (status != 0) - CSR_WRITE_2(sc, RL_ISR, status); - if ((status & RL_INTRS) == 0) - break; - if (status & RL_ISR_RX_OK) + CSR_WRITE_2(sc, RL_ISR, status); + if ((status & (RL_ISR_RX_OK | RL_ISR_RX_ERR)) != 0) rl_rxeof(sc); - if (status & RL_ISR_RX_ERR) - rl_rxeof(sc); - if ((status & RL_ISR_TX_OK) || (status & RL_ISR_TX_ERR)) + if ((status & (RL_ISR_TX_OK | RL_ISR_TX_ERR)) != 0) rl_txeof(sc); if (status & RL_ISR_SYSTEM_ERR) { rl_reset(sc); rl_init_locked(sc); } + status = CSR_READ_2(sc, RL_ISR); } + /* Enable interrupts. */ + CSR_WRITE_2(sc, RL_IMR, RL_INTRS); + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) rl_start_locked(ifp);