From owner-svn-src-head@freebsd.org Tue May 9 18:33:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5658FD659DF; Tue, 9 May 2017 18:33:43 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 04F3391; Tue, 9 May 2017 18:33:42 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v49IXgRY088221; Tue, 9 May 2017 18:33:42 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v49IXfxq088218; Tue, 9 May 2017 18:33:41 GMT (envelope-from np@FreeBSD.org) Message-Id: <201705091833.v49IXfxq088218@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 9 May 2017 18:33:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318091 - head/sys/dev/cxgbe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 May 2017 18:33:43 -0000 Author: np Date: Tue May 9 18:33:41 2017 New Revision: 318091 URL: https://svnweb.freebsd.org/changeset/base/318091 Log: cxgbe(4): Do not assume that if_qflush is always followed by inteface-down. MFC after: 3 days Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Tue May 9 18:28:42 2017 (r318090) +++ head/sys/dev/cxgbe/adapter.h Tue May 9 18:33:41 2017 (r318091) @@ -399,6 +399,7 @@ enum { EQ_TYPEMASK = 0x3, /* 2 lsbits hold the type (see above) */ EQ_ALLOCATED = (1 << 2), /* firmware resources allocated */ EQ_ENABLED = (1 << 3), /* open for business */ + EQ_QFLUSH = (1 << 4), /* if_qflush in progress */ }; /* Listed in order of preference. Update t4_sysctls too if you change these */ Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Tue May 9 18:28:42 2017 (r318090) +++ head/sys/dev/cxgbe/t4_main.c Tue May 9 18:33:41 2017 (r318091) @@ -1869,12 +1869,15 @@ cxgbe_qflush(struct ifnet *ifp) if (vi->flags & VI_INIT_DONE) { for_each_txq(vi, i, txq) { TXQ_LOCK(txq); - txq->eq.flags &= ~EQ_ENABLED; + txq->eq.flags |= EQ_QFLUSH; TXQ_UNLOCK(txq); while (!mp_ring_is_idle(txq->r)) { mp_ring_check_drainage(txq->r, 0); pause("qflush", 1); } + TXQ_LOCK(txq); + txq->eq.flags &= ~EQ_QFLUSH; + TXQ_UNLOCK(txq); } } if_qflush(ifp); Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Tue May 9 18:28:42 2017 (r318090) +++ head/sys/dev/cxgbe/t4_sge.c Tue May 9 18:33:41 2017 (r318091) @@ -2452,6 +2452,13 @@ cannot_use_txpkts(struct mbuf *m) return (needs_tso(m)); } +static inline int +discard_tx(struct sge_eq *eq) +{ + + return ((eq->flags & (EQ_ENABLED | EQ_QFLUSH)) != EQ_ENABLED); +} + /* * r->items[cidx] to r->items[pidx], with a wraparound at r->size, are ready to * be consumed. Return the actual number consumed. 0 indicates a stall. @@ -2477,7 +2484,7 @@ eth_tx(struct mp_ring *r, u_int cidx, u_ total = 0; TXQ_LOCK(txq); - if (__predict_false((eq->flags & EQ_ENABLED) == 0)) { + if (__predict_false(discard_tx(eq))) { while (cidx != pidx) { m0 = r->items[cidx]; m_freem(m0);