bge_cksum_pad() can modify the mbuf, thus call it before bus_dmamap_load().

Submitted by:	yongari
This commit is contained in:
Gleb Smirnoff 2006-08-18 13:53:53 +00:00
parent fed4d6b394
commit 6909dc43c5

View File

@ -2905,6 +2905,25 @@ bge_encap(struct bge_softc *sc, struct mbuf **m_head, uint32_t *txidx)
uint16_t csum_flags;
int nsegs, i, error;
csum_flags = 0;
if (m->m_pkthdr.csum_flags) {
if (m->m_pkthdr.csum_flags & CSUM_IP)
csum_flags |= BGE_TXBDFLAG_IP_CSUM;
if (m->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP)) {
csum_flags |= BGE_TXBDFLAG_TCP_UDP_CSUM;
if (m->m_pkthdr.len < ETHER_MIN_NOPAD &&
(error = bge_cksum_pad(m)) != 0) {
m_freem(m);
*m_head = NULL;
return (error);
}
}
if (m->m_flags & M_LASTFRAG)
csum_flags |= BGE_TXBDFLAG_IP_FRAG_END;
else if (m->m_flags & M_FRAG)
csum_flags |= BGE_TXBDFLAG_IP_FRAG;
}
map = sc->bge_cdata.bge_tx_dmamap[idx];
error = bus_dmamap_load_mbuf_sg(sc->bge_cdata.bge_mtag, map, m, segs,
&nsegs, BUS_DMA_NOWAIT);
@ -2935,26 +2954,6 @@ bge_encap(struct bge_softc *sc, struct mbuf **m_head, uint32_t *txidx)
return (ENOBUFS);
}
csum_flags = 0;
if (m->m_pkthdr.csum_flags) {
if (m->m_pkthdr.csum_flags & CSUM_IP)
csum_flags |= BGE_TXBDFLAG_IP_CSUM;
if (m->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP)) {
csum_flags |= BGE_TXBDFLAG_TCP_UDP_CSUM;
if (m->m_pkthdr.len < ETHER_MIN_NOPAD &&
(error = bge_cksum_pad(m)) != 0) {
bus_dmamap_unload(sc->bge_cdata.bge_mtag, map);
m_freem(m);
*m_head = NULL;
return (error);
}
}
if (m->m_flags & M_LASTFRAG)
csum_flags |= BGE_TXBDFLAG_IP_FRAG_END;
else if (m->m_flags & M_FRAG)
csum_flags |= BGE_TXBDFLAG_IP_FRAG;
}
bus_dmamap_sync(sc->bge_cdata.bge_mtag, map, BUS_DMASYNC_PREWRITE);
for (i = 0; ; i++) {