Fix the 'wrong packet header' errors for if_emac.

Do not strip the ethernet CRC until we read all data from FIFO, otherwise
the CRC bytes would be left in FIFO causing the failure of next packet
(wrong packet header).

When this error happens the receiver has to be disabled and the RX FIFO
flushed, discarding valid packets.

With this fix if_emac behaves a lot better.
This commit is contained in:
Luiz Otavio O Souza 2015-04-17 03:56:50 +00:00
parent 631947366f
commit e4dc9b78d7

View File

@ -358,15 +358,13 @@ emac_rxeof(struct emac_softc *sc, int count)
return;
m->m_len = m->m_pkthdr.len = MCLBYTES;
len -= ETHER_CRC_LEN;
/* Copy entire frame to mbuf first. */
bus_space_read_multi_4(sc->emac_tag, sc->emac_handle,
EMAC_RX_IO_DATA, mtod(m, uint32_t *),
roundup2(len, 4) / 4);
m->m_pkthdr.rcvif = ifp;
m->m_len = m->m_pkthdr.len = len;
m->m_len = m->m_pkthdr.len = len - ETHER_CRC_LEN;
/*
* Emac controller needs strict aligment, so to avoid