summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2006-08-12 01:30:38 +0000
committeryongari <yongari@FreeBSD.org>2006-08-12 01:30:38 +0000
commit36aa6705100b69cc3c482c73a8b095f0c1e404d2 (patch)
tree7024c4e2c0a092866169174c282a363da9ca42c6
parent88c94f7a066113a020df0ee72d4030f30217047f (diff)
downloadFreeBSD-src-36aa6705100b69cc3c482c73a8b095f0c1e404d2.zip
FreeBSD-src-36aa6705100b69cc3c482c73a8b095f0c1e404d2.tar.gz
Fix invalid reference of mbuf chains.
Use proper pointer dereference to inform modified mbuf chains to caller. While I'm here perform checksum offload setup after loading DMA maps. In collaboration with: glebius
-rw-r--r--sys/dev/ti/if_ti.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index b603103..898fe14 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -2955,7 +2955,7 @@ ti_encap(sc, m_head)
struct ti_txdesc *txd;
struct ti_tx_desc *f;
struct ti_tx_desc txdesc;
- struct mbuf *m, *n;
+ struct mbuf *m;
struct m_tag *mtag;
bus_dma_segment_t txsegs[TI_MAXTXSEGS];
u_int16_t csum_flags;
@@ -2964,41 +2964,28 @@ ti_encap(sc, m_head)
if ((txd = STAILQ_FIRST(&sc->ti_cdata.ti_txfreeq)) == NULL)
return (ENOBUFS);
- m = *m_head;
- csum_flags = 0;
- if (m->m_pkthdr.csum_flags) {
- if (m->m_pkthdr.csum_flags & CSUM_IP)
- csum_flags |= TI_BDFLAG_IP_CKSUM;
- if (m->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP))
- csum_flags |= TI_BDFLAG_TCP_UDP_CKSUM;
- if (m->m_flags & M_LASTFRAG)
- csum_flags |= TI_BDFLAG_IP_FRAG_END;
- else if (m->m_flags & M_FRAG)
- csum_flags |= TI_BDFLAG_IP_FRAG;
- }
-
error = bus_dmamap_load_mbuf_sg(sc->ti_mbuftx_dmat, txd->tx_dmamap,
- m, txsegs, &nseg, 0);
+ *m_head, txsegs, &nseg, 0);
if (error == EFBIG) {
- n = m_defrag(m, M_DONTWAIT);
- if (n == NULL) {
- m_freem(m);
- m = NULL;
+ m = m_defrag(*m_head, M_DONTWAIT);
+ if (m == NULL) {
+ m_freem(*m_head);
+ *m_head = NULL;
return (ENOMEM);
}
- m = n;
+ *m_head = m;
error = bus_dmamap_load_mbuf_sg(sc->ti_mbuftx_dmat,
- txd->tx_dmamap, m, txsegs, &nseg, 0);
+ txd->tx_dmamap, *m_head, txsegs, &nseg, 0);
if (error) {
- m_freem(m);
- m = NULL;
+ m_freem(*m_head);
+ *m_head = NULL;
return (error);
}
} else if (error != 0)
return (error);
if (nseg == 0) {
- m_freem(m);
- m = NULL;
+ m_freem(*m_head);
+ *m_head = NULL;
return (EIO);
}
@@ -3007,6 +2994,19 @@ ti_encap(sc, m_head)
return (ENOBUFS);
}
+ m = *m_head;
+ csum_flags = 0;
+ if (m->m_pkthdr.csum_flags) {
+ if (m->m_pkthdr.csum_flags & CSUM_IP)
+ csum_flags |= TI_BDFLAG_IP_CKSUM;
+ if (m->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP))
+ csum_flags |= TI_BDFLAG_TCP_UDP_CKSUM;
+ if (m->m_flags & M_LASTFRAG)
+ csum_flags |= TI_BDFLAG_IP_FRAG_END;
+ else if (m->m_flags & M_FRAG)
+ csum_flags |= TI_BDFLAG_IP_FRAG;
+ }
+
bus_dmamap_sync(sc->ti_mbuftx_dmat, txd->tx_dmamap,
BUS_DMASYNC_PREWRITE);
bus_dmamap_sync(sc->ti_rdata_dmat, sc->ti_rdata_dmamap,
OpenPOWER on IntegriCloud