From owner-freebsd-net@FreeBSD.ORG Wed Aug 8 14:29:33 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A0833106566C for ; Wed, 8 Aug 2012 14:29:33 +0000 (UTC) (envelope-from aboyer@averesystems.com) Received: from mail.averesystems.com (mail.averesystems.com [208.70.68.85]) by mx1.freebsd.org (Postfix) with ESMTP id 707308FC19 for ; Wed, 8 Aug 2012 14:29:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.averesystems.com (Postfix) with ESMTP id A070248078D for ; Wed, 8 Aug 2012 10:29:35 -0400 (EDT) X-Virus-Scanned: amavisd-new at mail.averesystems.com Received: from mail.averesystems.com ([127.0.0.1]) by localhost (mail.averesystems.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sRCFmyXz4qkY for ; Wed, 8 Aug 2012 10:29:35 -0400 (EDT) Received: from riven.arriad.com (206.193.225.214.nauticom.net [206.193.225.214]) by mail.averesystems.com (Postfix) with ESMTPSA id 2F6FA4804F7 for ; Wed, 8 Aug 2012 10:29:35 -0400 (EDT) From: Andrew Boyer Content-Type: multipart/mixed; boundary="Apple-Mail=_239844E5-18A3-42AF-9DAB-C74CDBA994ED" Date: Wed, 8 Aug 2012 10:29:31 -0400 Message-Id: <5F36EE1D-89F0-4CF8-AB13-705847F2753F@averesystems.com> To: freebsd-net@freebsd.org Mime-Version: 1.0 (Apple Message framework v1278) X-Mailer: Apple Mail (2.1278) Subject: [patch] e1000 / lem handling of TSO defragmentation X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2012 14:29:33 -0000 --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--