From owner-svn-src-user@FreeBSD.ORG Mon Jul 19 21:24:49 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02A52106566C; Mon, 19 Jul 2010 21:24:49 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E825A8FC08; Mon, 19 Jul 2010 21:24:48 +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 o6JLOmqw086971; Mon, 19 Jul 2010 21:24:48 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6JLOmwc086969; Mon, 19 Jul 2010 21:24:48 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201007192124.o6JLOmwc086969@svn.freebsd.org> From: Juli Mallett Date: Mon, 19 Jul 2010 21:24:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210258 - user/jmallett/octeon/sys/mips/cavium/octe X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2010 21:24:49 -0000 Author: jmallett Date: Mon Jul 19 21:24:48 2010 New Revision: 210258 URL: http://svn.freebsd.org/changeset/base/210258 Log: Lock the transmitted packet queue from the time we start preparing a packet through when we free any transmitted packets. Without doing this we are vulnerable to several nasty races involving packets being freed out of order, freed twice, etc. The atomic operations are good as far as they go, but they don't provide for consistency with the packet freeing. Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-tx.c Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-tx.c ============================================================================== --- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-tx.c Mon Jul 19 21:13:07 2010 (r210257) +++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-tx.c Mon Jul 19 21:24:48 2010 (r210258) @@ -198,6 +198,7 @@ int cvm_oct_xmit(struct mbuf *m, struct pko_command.s.ipoffp1 = ETHER_HDR_LEN + 1; } + IF_LOCK(&priv->tx_free_queue[qos]); if (USE_ASYNC_IOBDMA) { /* Get the number of mbufs in use by the hardware */ CVMX_SYNCIOBDMA; @@ -241,13 +242,12 @@ int cvm_oct_xmit(struct mbuf *m, struct /* Free mbufs not in use by the hardware */ if (_IF_QLEN(&priv->tx_free_queue[qos]) > in_use) { - IF_LOCK(&priv->tx_free_queue[qos]); while (_IF_QLEN(&priv->tx_free_queue[qos]) > in_use) { _IF_DEQUEUE(&priv->tx_free_queue[qos], m); m_freem(m); } - IF_UNLOCK(&priv->tx_free_queue[qos]); } + IF_UNLOCK(&priv->tx_free_queue[qos]); return dropped; }