Date: Tue, 31 May 2016 20:54:42 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301075 - head/sys/dev/sfxge Message-ID: <201605312054.u4VKsgAu094003@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605312054.u4VKsgAu094003>