Date: Sat, 4 Jun 2016 14:09:39 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301314 - stable/10/sys/dev/sfxge Message-ID: <201606041409.u54E9d4D080700@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Sat Jun 4 14:09:39 2016 New Revision: 301314 URL: https://svnweb.freebsd.org/changeset/base/301314 Log: MFC r301075 sfxge(4): avoid code duplication in SW events definition 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:07:42 2016 (r301313) +++ stable/10/sys/dev/sfxge/sfxge.h Sat Jun 4 14:09:39 2016 (r301314) @@ -119,18 +119,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: stable/10/sys/dev/sfxge/sfxge_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_ev.c Sat Jun 4 14:07:42 2016 (r301313) +++ stable/10/sys/dev/sfxge/sfxge_ev.c Sat Jun 4 14:09:39 2016 (r301314) @@ -225,7 +225,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")); @@ -259,7 +259,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")); @@ -350,7 +350,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")); @@ -375,19 +375,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: stable/10/sys/dev/sfxge/sfxge_rx.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_rx.c Sat Jun 4 14:07:42 2016 (r301313) +++ stable/10/sys/dev/sfxge/sfxge_rx.c Sat Jun 4 14:09:39 2016 (r301314) @@ -184,7 +184,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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606041409.u54E9d4D080700>