From owner-svn-src-stable@freebsd.org Sat Jun 4 14:11:34 2016 Return-Path: Delivered-To: svn-src-stable@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 1423FB699D4; Sat, 4 Jun 2016 14:11:34 +0000 (UTC) (envelope-from arybchik@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 6C0C811F2; Sat, 4 Jun 2016 14:11:33 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u54EBWSG082099; Sat, 4 Jun 2016 14:11:32 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u54EBWNJ082096; Sat, 4 Jun 2016 14:11:32 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606041411.u54EBWNJ082096@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 4 Jun 2016 14:11:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301315 - stable/10/sys/dev/sfxge X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jun 2016 14:11:34 -0000 Author: arybchik Date: Sat Jun 4 14:11:32 2016 New Revision: 301315 URL: https://svnweb.freebsd.org/changeset/base/301315 Log: MFC r301105 sfxge(4): cope with code duplication on SW events composition Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/sfxge.h stable/10/sys/dev/sfxge/sfxge_ev.c stable/10/sys/dev/sfxge/sfxge_rx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/sfxge.h ============================================================================== --- stable/10/sys/dev/sfxge/sfxge.h Sat Jun 4 14:09:39 2016 (r301314) +++ stable/10/sys/dev/sfxge/sfxge.h Sat Jun 4 14:11:32 2016 (r301315) @@ -129,6 +129,26 @@ enum sfxge_sw_ev { #define SFXGE_SW_EV_MAGIC(_sw_ev) \ (SFXGE_MAGIC_RESERVED | ((_sw_ev) << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) +static inline uint16_t +sfxge_sw_ev_mk_magic(enum sfxge_sw_ev sw_ev, unsigned int label) +{ + KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, + ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != label")); + return SFXGE_SW_EV_MAGIC(sw_ev) | label; +} + +static inline uint16_t +sfxge_sw_ev_rxq_magic(enum sfxge_sw_ev sw_ev, struct sfxge_rxq *rxq) +{ + return sfxge_sw_ev_mk_magic(sw_ev, 0); +} + +static inline uint16_t +sfxge_sw_ev_txq_magic(enum sfxge_sw_ev sw_ev, struct sfxge_txq *txq) +{ + return sfxge_sw_ev_mk_magic(sw_ev, txq->type); +} + enum sfxge_evq_state { SFXGE_EVQ_UNINITIALIZED = 0, SFXGE_EVQ_INITIALIZED, Modified: stable/10/sys/dev/sfxge/sfxge_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_ev.c Sat Jun 4 14:09:39 2016 (r301314) +++ stable/10/sys/dev/sfxge/sfxge_ev.c Sat Jun 4 14:11:32 2016 (r301315) @@ -202,7 +202,6 @@ sfxge_ev_rxq_flush_done(void *arg, uint3 struct sfxge_softc *sc; struct sfxge_rxq *rxq; unsigned int index; - unsigned int label; uint16_t magic; evq = (struct sfxge_evq *)arg; @@ -221,11 +220,7 @@ sfxge_ev_rxq_flush_done(void *arg, uint3 } evq = sc->evq[index]; - - label = 0; - KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, - ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != level")); - magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_DONE) | label; + magic = sfxge_sw_ev_rxq_magic(SFXGE_SW_EV_RX_QFLUSH_DONE, rxq); KASSERT(evq->init_state == SFXGE_EVQ_STARTED, ("evq not started")); @@ -241,7 +236,6 @@ sfxge_ev_rxq_flush_failed(void *arg, uin struct sfxge_softc *sc; struct sfxge_rxq *rxq; unsigned int index; - unsigned int label; uint16_t magic; evq = (struct sfxge_evq *)arg; @@ -255,11 +249,7 @@ sfxge_ev_rxq_flush_failed(void *arg, uin /* Resend a software event on the correct queue */ index = rxq->index; evq = sc->evq[index]; - - label = 0; - KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, - ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != label")); - magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_FAILED) | label; + magic = sfxge_sw_ev_rxq_magic(SFXGE_SW_EV_RX_QFLUSH_FAILED, rxq); KASSERT(evq->init_state == SFXGE_EVQ_STARTED, ("evq not started")); @@ -326,7 +316,6 @@ sfxge_ev_txq_flush_done(void *arg, uint3 struct sfxge_evq *evq; struct sfxge_softc *sc; struct sfxge_txq *txq; - unsigned int label; uint16_t magic; evq = (struct sfxge_evq *)arg; @@ -346,11 +335,7 @@ sfxge_ev_txq_flush_done(void *arg, uint3 /* Resend a software event on the correct queue */ evq = sc->evq[txq->evq_index]; - - label = txq->type; - KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, - ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != label")); - magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_TX_QFLUSH_DONE) | label; + magic = sfxge_sw_ev_txq_magic(SFXGE_SW_EV_TX_QFLUSH_DONE, txq); KASSERT(evq->init_state == SFXGE_EVQ_STARTED, ("evq not started")); Modified: stable/10/sys/dev/sfxge/sfxge_rx.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_rx.c Sat Jun 4 14:09:39 2016 (r301314) +++ stable/10/sys/dev/sfxge/sfxge_rx.c Sat Jun 4 14:11:32 2016 (r301315) @@ -174,17 +174,12 @@ sfxge_rx_post_refill(void *arg) struct sfxge_softc *sc; unsigned int index; struct sfxge_evq *evq; - unsigned int label; uint16_t magic; sc = rxq->sc; index = rxq->index; evq = sc->evq[index]; - - label = 0; - KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, - ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != level")); - magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QREFILL) | label; + magic = sfxge_sw_ev_rxq_magic(SFXGE_SW_EV_RX_QREFILL, rxq); /* This is guaranteed due to the start/stop order of rx and ev */ KASSERT(evq->init_state == SFXGE_EVQ_STARTED,