From owner-freebsd-net@FreeBSD.ORG Fri Dec 17 12:56:42 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 741B6106564A for ; Fri, 17 Dec 2010 12:56:42 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 43CA48FC13 for ; Fri, 17 Dec 2010 12:56:42 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id D127446B7E; Fri, 17 Dec 2010 07:56:41 -0500 (EST) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id D0CC58A009; Fri, 17 Dec 2010 07:56:40 -0500 (EST) From: John Baldwin To: freebsd-net@freebsd.org Date: Fri, 17 Dec 2010 07:48:13 -0500 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20101102; KDE/4.4.5; amd64; ; ) References: <808782.86181.qm@web53807.mail.re2.yahoo.com> In-Reply-To: <808782.86181.qm@web53807.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201012170748.13980.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Fri, 17 Dec 2010 07:56:41 -0500 (EST) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=4.2 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: abcde abcde Subject: Re: nfe_defrag() routine in nividia ethernet driver 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: Fri, 17 Dec 2010 12:56:42 -0000 On Thursday, December 16, 2010 10:53:16 pm abcde abcde wrote: > Hi, we ported the nvidia ethernet driver to our product. It's been OK until > recently we ran into an error condition where packets would get dropped quietly. > The root cause resides in the nfe_encap() routine, where we call nfe_defrag() to > try to reduce the length of the mbuf chain to 32, if it's longer than 32. In the > event the 32 mbufs need more than 32 segments, the subsequent call to > bus_dmamap_load_mbuf_sg() would cause it to return an error then the packet is > subsequently dropped. > > > My questions are, > > 1. there appears to be a generic m_defrag() routine available, which doesn't > stop at 32 and is used by a couple of other drivers (Intel, Broadcom, to name a > few). What was the need for a nvidia version of the defrag routine? The nfe_defrag() routine is a copy of a similar method from another driver. It is now called m_collapse() in newer versions of FreeBSD. m_collapse() is less expensive than m_defrag() in that it can avoid extra allocations if they aren't needed. You can use m_defrag() if you wish, but I would still try nfe_defrag() first and only fall back to m_defrag() if that fails. > 2. The NFE_MAX_SCATTER constant, which limits how many segments can be used, is > defined to be 32, while the corresponding constants for other drivers are 100 or > 64 (again Intel or Broadcom). How was the value 32 picked? Anybody knows the > reasoning behind them? It may very well be a chip-dependent limitation due to something in the hardware or firmware of the nfe(4) devices. -- John Baldwin