svn commit: r198924 - head/sys/dev/bge
Pyun YongHyeon
yongari at FreeBSD.org
Wed Nov 4 20:40:38 UTC 2009
Author: yongari
Date: Wed Nov 4 20:40:38 2009
New Revision: 198924
URL: http://svn.freebsd.org/changeset/base/198924
Log:
Covert bge_newbuf_std to use bus_dmamap_load_mbuf_sg(9). Note,
bge_newbuf_std still has a bug for handling dma map load failure
under high network load. Just reusing mbuf is not enough as driver
already unloaded the dma map of the mbuf. Graceful recovery needs
more work.
Ideally we can just update dma address part of a Rx descriptor
because the controller never overwrite the Rx descriptor. This
requires some Rx initialization code changes and it would be done
later after fixing other incorrect bus_dma(9) usages.
Modified:
head/sys/dev/bge/if_bge.c
Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c Wed Nov 4 20:19:21 2009 (r198923)
+++ head/sys/dev/bge/if_bge.c Wed Nov 4 20:40:38 2009 (r198924)
@@ -916,8 +916,8 @@ bge_newbuf_std(struct bge_softc *sc, int
{
struct mbuf *m_new = NULL;
struct bge_rx_bd *r;
- struct bge_dmamap_arg ctx;
- int error;
+ bus_dma_segment_t segs[1];
+ int error, nsegs;
if (m == NULL) {
m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
@@ -932,24 +932,21 @@ bge_newbuf_std(struct bge_softc *sc, int
if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
m_adj(m_new, ETHER_ALIGN);
- sc->bge_cdata.bge_rx_std_chain[i] = m_new;
- r = &sc->bge_ldata.bge_rx_std_ring[i];
- ctx.bge_maxsegs = 1;
- ctx.sc = sc;
- error = bus_dmamap_load(sc->bge_cdata.bge_mtag,
- sc->bge_cdata.bge_rx_std_dmamap[i], mtod(m_new, void *),
- m_new->m_len, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT);
- if (error || ctx.bge_maxsegs == 0) {
+ error = bus_dmamap_load_mbuf_sg(sc->bge_cdata.bge_mtag,
+ sc->bge_cdata.bge_rx_std_dmamap[i], m_new, segs, &nsegs, 0);
+ if (error != 0) {
if (m == NULL) {
sc->bge_cdata.bge_rx_std_chain[i] = NULL;
m_freem(m_new);
}
- return (ENOMEM);
+ return (error);
}
- r->bge_addr.bge_addr_lo = BGE_ADDR_LO(ctx.bge_busaddr);
- r->bge_addr.bge_addr_hi = BGE_ADDR_HI(ctx.bge_busaddr);
+ sc->bge_cdata.bge_rx_std_chain[i] = m_new;
+ r = &sc->bge_ldata.bge_rx_std_ring[i];
+ r->bge_addr.bge_addr_lo = BGE_ADDR_LO(segs[0].ds_addr);
+ r->bge_addr.bge_addr_hi = BGE_ADDR_HI(segs[0].ds_addr);
r->bge_flags = BGE_RXBDFLAG_END;
- r->bge_len = m_new->m_len;
+ r->bge_len = segs[0].ds_len;
r->bge_idx = i;
bus_dmamap_sync(sc->bge_cdata.bge_mtag,
More information about the svn-src-all
mailing list