From owner-svn-src-all@freebsd.org Tue May 31 20:54:43 2016 Return-Path: Delivered-To: svn-src-all@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 78764B583F2; Tue, 31 May 2016 20:54:43 +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 52F9A16BB; Tue, 31 May 2016 20:54:43 +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 u4VKsgTe094006; Tue, 31 May 2016 20:54:42 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4VKsgAu094003; Tue, 31 May 2016 20:54:42 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201605312054.u4VKsgAu094003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Tue, 31 May 2016 20:54:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301075 - head/sys/dev/sfxge X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 31 May 2016 20:54:43 -0000 Author: arybchik Date: Tue May 31 20:54:42 2016 New Revision: 301075 URL: https://svnweb.freebsd.org/changeset/base/301075 Log: sfxge(4): avoid code duplication in SW events definition Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D6662 Modified: head/sys/dev/sfxge/sfxge.h head/sys/dev/sfxge/sfxge_ev.c head/sys/dev/sfxge/sfxge_rx.c Modified: head/sys/dev/sfxge/sfxge.h ============================================================================== --- head/sys/dev/sfxge/sfxge.h Tue May 31 19:24:32 2016 (r301074) +++ head/sys/dev/sfxge/sfxge.h Tue May 31 20:54:42 2016 (r301075) @@ -120,18 +120,15 @@ #define SFXGE_MAGIC_DMAQ_LABEL_MASK \ ((1 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH) - 1) -#define SFXGE_MAGIC_RX_QFLUSH_DONE \ - (SFXGE_MAGIC_RESERVED | (1 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) - -#define SFXGE_MAGIC_RX_QFLUSH_FAILED \ - (SFXGE_MAGIC_RESERVED | (2 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) - -#define SFXGE_MAGIC_RX_QREFILL \ - (SFXGE_MAGIC_RESERVED | (3 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) - -#define SFXGE_MAGIC_TX_QFLUSH_DONE \ - (SFXGE_MAGIC_RESERVED | (4 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) +enum sfxge_sw_ev { + SFXGE_SW_EV_RX_QFLUSH_DONE = 1, + SFXGE_SW_EV_RX_QFLUSH_FAILED, + SFXGE_SW_EV_RX_QREFILL, + SFXGE_SW_EV_TX_QFLUSH_DONE, +}; +#define SFXGE_SW_EV_MAGIC(_sw_ev) \ + (SFXGE_MAGIC_RESERVED | ((_sw_ev) << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) enum sfxge_evq_state { SFXGE_EVQ_UNINITIALIZED = 0, Modified: head/sys/dev/sfxge/sfxge_ev.c ============================================================================== --- head/sys/dev/sfxge/sfxge_ev.c Tue May 31 19:24:32 2016 (r301074) +++ head/sys/dev/sfxge/sfxge_ev.c Tue May 31 20:54:42 2016 (r301075) @@ -230,7 +230,7 @@ sfxge_ev_rxq_flush_done(void *arg, uint3 label = 0; KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != level")); - magic = SFXGE_MAGIC_RX_QFLUSH_DONE | label; + magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_DONE) | label; KASSERT(evq->init_state == SFXGE_EVQ_STARTED, ("evq not started")); @@ -264,7 +264,7 @@ sfxge_ev_rxq_flush_failed(void *arg, uin label = 0; KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != label")); - magic = SFXGE_MAGIC_RX_QFLUSH_FAILED | label; + magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_FAILED) | label; KASSERT(evq->init_state == SFXGE_EVQ_STARTED, ("evq not started")); @@ -355,7 +355,7 @@ sfxge_ev_txq_flush_done(void *arg, uint3 label = txq->type; KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != label")); - magic = SFXGE_MAGIC_TX_QFLUSH_DONE | label; + magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_TX_QFLUSH_DONE) | label; KASSERT(evq->init_state == SFXGE_EVQ_STARTED, ("evq not started")); @@ -380,19 +380,19 @@ sfxge_ev_software(void *arg, uint16_t ma magic &= ~SFXGE_MAGIC_DMAQ_LABEL_MASK; switch (magic) { - case SFXGE_MAGIC_RX_QFLUSH_DONE: + case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_DONE): sfxge_rx_qflush_done(sfxge_get_rxq_by_label(evq, label)); break; - case SFXGE_MAGIC_RX_QFLUSH_FAILED: + case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_FAILED): sfxge_rx_qflush_failed(sfxge_get_rxq_by_label(evq, label)); break; - case SFXGE_MAGIC_RX_QREFILL: + case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QREFILL): sfxge_rx_qrefill(sfxge_get_rxq_by_label(evq, label)); break; - case SFXGE_MAGIC_TX_QFLUSH_DONE: { + case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_TX_QFLUSH_DONE): { struct sfxge_txq *txq = sfxge_get_txq_by_label(evq, label); KASSERT(txq != NULL, ("txq == NULL")); Modified: head/sys/dev/sfxge/sfxge_rx.c ============================================================================== --- head/sys/dev/sfxge/sfxge_rx.c Tue May 31 19:24:32 2016 (r301074) +++ head/sys/dev/sfxge/sfxge_rx.c Tue May 31 20:54:42 2016 (r301075) @@ -185,7 +185,7 @@ sfxge_rx_post_refill(void *arg) label = 0; KASSERT((label & SFXGE_MAGIC_DMAQ_LABEL_MASK) == label, ("(label & SFXGE_MAGIC_DMAQ_LABEL_MASK) != level")); - magic = SFXGE_MAGIC_RX_QREFILL | label; + magic = SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QREFILL) | label; /* This is guaranteed due to the start/stop order of rx and ev */ KASSERT(evq->init_state == SFXGE_EVQ_STARTED,