Date: Tue, 28 Jul 2015 19:15:45 +0000 (UTC) From: David C Somayajulu <davidcs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285973 - head/sys/dev/bxe Message-ID: <201507281915.t6SJFjSj084767@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidcs Date: Tue Jul 28 19:15:44 2015 New Revision: 285973 URL: https://svnweb.freebsd.org/changeset/base/285973 Log: - Avoid lock contention in the if_transmit callback by using trylock and enqueueing the frames when it fails. This way there is some latency removed from the transmitting path. - If IFF_DRV_OACTIVE is set (and also if IFF_DRV_RUNNING is not) just enqueue the desired frames and return successful transmit. This way we avoid to return errors on transmit side and resulting in possible out-of-order frames. Please note that IFF_DRV_OACTIVE is set everytime we get the threshold ring hit, so this can be happening quite often. Submitted by: Attilio.Rao@isilon.com MFC after:5 days Modified: head/sys/dev/bxe/bxe.c head/sys/dev/bxe/bxe.h Modified: head/sys/dev/bxe/bxe.c ============================================================================== --- head/sys/dev/bxe/bxe.c Tue Jul 28 18:41:28 2015 (r285972) +++ head/sys/dev/bxe/bxe.c Tue Jul 28 19:15:44 2015 (r285973) @@ -5999,19 +5999,26 @@ bxe_tx_mq_start_locked(struct bxe_softc rc = tx_count = 0; + BXE_FP_TX_LOCK_ASSERT(fp); + if (!tx_br) { BLOGE(sc, "Multiqueue TX and no buf_ring!\n"); return (EINVAL); } + if (!sc->link_vars.link_up || + (ifp->if_drv_flags & + (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) { + rc = drbr_enqueue_drv(ifp, tx_br, m); + goto bxe_tx_mq_start_locked_exit; + } + /* fetch the depth of the driver queue */ depth = drbr_inuse_drv(ifp, tx_br); if (depth > fp->eth_q_stats.tx_max_drbr_queue_depth) { fp->eth_q_stats.tx_max_drbr_queue_depth = depth; } - BXE_FP_TX_LOCK_ASSERT(fp); - if (m == NULL) { /* no new work, check for pending frames */ next = drbr_dequeue_drv(ifp, tx_br); @@ -6103,26 +6110,11 @@ bxe_tx_mq_start(struct ifnet *ifp, fp = &sc->fp[fp_index]; - if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { - BLOGW(sc, "Interface not running, ignoring transmit request\n"); - return (ENETDOWN); - } - - if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) { - BLOGW(sc, "Interface TX queue is full, ignoring transmit request\n"); - return (EBUSY); - } - - if (!sc->link_vars.link_up) { - BLOGW(sc, "Interface link is down, ignoring transmit request\n"); - return (ENETDOWN); - } - - /* XXX change to TRYLOCK here and if failed then schedule taskqueue */ - - BXE_FP_TX_LOCK(fp); - rc = bxe_tx_mq_start_locked(sc, ifp, fp, m); - BXE_FP_TX_UNLOCK(fp); + if (BXE_FP_TX_TRYLOCK(fp)) { + rc = bxe_tx_mq_start_locked(sc, ifp, fp, m); + BXE_FP_TX_UNLOCK(fp); + } else + rc = drbr_enqueue_drv(ifp, fp->tx_br, m); return (rc); } Modified: head/sys/dev/bxe/bxe.h ============================================================================== --- head/sys/dev/bxe/bxe.h Tue Jul 28 18:41:28 2015 (r285972) +++ head/sys/dev/bxe/bxe.h Tue Jul 28 19:15:44 2015 (r285973) @@ -582,6 +582,7 @@ struct bxe_fastpath { #define BXE_FP_TX_LOCK(fp) mtx_lock(&fp->tx_mtx) #define BXE_FP_TX_UNLOCK(fp) mtx_unlock(&fp->tx_mtx) #define BXE_FP_TX_LOCK_ASSERT(fp) mtx_assert(&fp->tx_mtx, MA_OWNED) +#define BXE_FP_TX_TRYLOCK(fp) mtx_trylock(&fp->tx_mtx) #define BXE_FP_RX_LOCK(fp) mtx_lock(&fp->rx_mtx) #define BXE_FP_RX_UNLOCK(fp) mtx_unlock(&fp->rx_mtx)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507281915.t6SJFjSj084767>