From owner-svn-src-all@FreeBSD.ORG Thu Jul 8 14:59:33 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02F4B106566B; Thu, 8 Jul 2010 14:59:33 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E6FE68FC1D; Thu, 8 Jul 2010 14:59:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o68ExWcn044027; Thu, 8 Jul 2010 14:59:32 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o68ExWgO044025; Thu, 8 Jul 2010 14:59:32 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201007081459.o68ExWgO044025@svn.freebsd.org> From: Adrian Chadd Date: Thu, 8 Jul 2010 14:59:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209807 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2010 14:59:33 -0000 Author: adrian Date: Thu Jul 8 14:59:32 2010 New Revision: 209807 URL: http://svn.freebsd.org/changeset/base/209807 Log: Address PR kern/148307 - fix if_ath TX mbuf alignment/size constraint checks The existing code only checked the alignment of the first mbuf and didn't enforce the size constraints. This commit introduces a simple function to check the alignment and size of all mbufs in the list. This fixes the initial issue in the PR. PR: kern/148307 Reviewed by: gonzo@ Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Thu Jul 8 14:56:42 2010 (r209806) +++ head/sys/mips/atheros/if_arge.c Thu Jul 8 14:59:32 2010 (r209807) @@ -834,6 +834,28 @@ arge_init_locked(struct arge_softc *sc) } /* + * Return whether the mbuf chain is correctly aligned + * for the arge TX engine. + * + * The TX engine requires each fragment to be aligned to a + * 4 byte boundary and the size of each fragment except + * the last to be a multiple of 4 bytes. + */ +static int +arge_mbuf_chain_is_tx_aligned(struct mbuf *m0) +{ + struct mbuf *m; + + for (m = m0; m != NULL; m = m->m_next) { + if((mtod(m, intptr_t) & 3) != 0) + return 0; + if ((m->m_next != NULL) && ((m->m_len & 0x03) != 0)) + return 0; + } + return 1; +} + +/* * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data * pointers to the fragment pointers. */ @@ -853,7 +875,7 @@ arge_encap(struct arge_softc *sc, struct * even 4 bytes */ m = *m_head; - if((mtod(m, intptr_t) & 3) != 0) { + if (! arge_mbuf_chain_is_tx_aligned(m)) { m = m_defrag(*m_head, M_DONTWAIT); if (m == NULL) { *m_head = NULL;