Date: Wed, 8 Aug 2012 10:29:31 -0400 From: Andrew Boyer <aboyer@averesystems.com> To: freebsd-net@freebsd.org Subject: [patch] e1000 / lem handling of TSO defragmentation Message-ID: <5F36EE1D-89F0-4CF8-AB13-705847F2753F@averesystems.com>
next in thread | raw e-mail | index | archive | help
--Apple-Mail=_239844E5-18A3-42AF-9DAB-C74CDBA994ED Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Similar to what was done for em in r220254, this patch improves the = error handling in lem when a TSO packet has too many segments to DMA. = This improves the behavior when either call to bus_dmamap_load_mbuf_sg() = returns ENOMEM. Although we don't need to go back and redo any offload = calculation in lem, doing it this way reduces code duplication. Comments welcome. -Andrew --Apple-Mail=_239844E5-18A3-42AF-9DAB-C74CDBA994ED Content-Disposition: attachment; filename=e1000_tso_defrag.diff Content-Type: application/octet-stream; name="e1000_tso_defrag.diff" Content-Transfer-Encoding: 7bit Index: sys/dev/e1000/if_lem.c =================================================================== --- sys/dev/e1000/if_lem.c (revision 239139) +++ sys/dev/e1000/if_lem.c (working copy) @@ -1525,8 +1525,9 @@ struct e1000_tx_desc *ctxd = NULL; struct mbuf *m_head; u32 txd_upper, txd_lower, txd_used, txd_saved; - int error, nsegs, i, j, first, last = 0; + int error, nsegs, i, j, first, last = 0, remap = 1; +retry: m_head = *m_headp; txd_upper = txd_lower = txd_used = txd_saved = 0; @@ -1568,7 +1569,7 @@ * All other errors, in particular EINVAL, are fatal and prevent the * mbuf chain from ever going through. Drop it and report error. */ - if (error == EFBIG) { + if (error == EFBIG && remap) { struct mbuf *m; m = m_defrag(*m_headp, M_DONTWAIT); @@ -1580,18 +1581,16 @@ } *m_headp = m; - /* Try it again */ - error = bus_dmamap_load_mbuf_sg(adapter->txtag, map, - *m_headp, segs, &nsegs, BUS_DMA_NOWAIT); - - if (error) { - adapter->no_tx_dma_setup++; - m_freem(*m_headp); - *m_headp = NULL; - return (error); - } + /* Try it again, but only once */ + remap = 0; + goto retry; + } else if (error == ENOMEM) { + adapter->no_tx_dma_setup++; + return (error); } else if (error != 0) { adapter->no_tx_dma_setup++; + m_freem(*m_headp); + *m_headp = NULL; return (error); } --Apple-Mail=_239844E5-18A3-42AF-9DAB-C74CDBA994ED Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii -------------------------------------------------- Andrew Boyer aboyer@averesystems.com --Apple-Mail=_239844E5-18A3-42AF-9DAB-C74CDBA994ED--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5F36EE1D-89F0-4CF8-AB13-705847F2753F>