summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarybchik <arybchik@FreeBSD.org>2016-06-04 14:11:32 +0000
committerarybchik <arybchik@FreeBSD.org>2016-06-04 14:11:32 +0000
commit43cfa20f26ba23be32b74f40769a53725207ac5c (patch)
tree67f5fedb8dbb229161faac6fc3b9088906094410
parent63eae8936e2cfa6ef206bd80e3f88a667cd66c54 (diff)
downloadFreeBSD-src-43cfa20f26ba23be32b74f40769a53725207ac5c.zip
FreeBSD-src-43cfa20f26ba23be32b74f40769a53725207ac5c.tar.gz
MFC r301105
sfxge(4): cope with code duplication on SW events composition Sponsored by: Solarflare Communications, Inc.
-rw-r--r--sys/dev/sfxge/sfxge.h20
-rw-r--r--sys/dev/sfxge/sfxge_ev.c21
-rw-r--r--sys/dev/sfxge/sfxge_rx.c7
3 files changed, 24 insertions, 24 deletions
diff --git a/sys/dev/sfxge/sfxge.h b/sys/dev/sfxge/sfxge.h
index 9233e9c..a824fe6 100644
--- a/sys/dev/sfxge/sfxge.h
+++ b/sys/dev/sfxge/sfxge.h
@@ -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,
diff --git a/sys/dev/sfxge/sfxge_ev.c b/sys/dev/sfxge/sfxge_ev.c
index a9c787b..bf8418f 100644
--- a/sys/dev/sfxge/sfxge_ev.c
+++ b/sys/dev/sfxge/sfxge_ev.c
@@ -202,7 +202,6 @@ sfxge_ev_rxq_flush_done(void *arg, uint32_t rxq_index)
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, uint32_t 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_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, uint32_t rxq_index)
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, uint32_t rxq_index)
/* 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, uint32_t txq_index)
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, uint32_t txq_index)
/* 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"));
diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c
index 54dccea..194486a 100644
--- a/sys/dev/sfxge/sfxge_rx.c
+++ b/sys/dev/sfxge/sfxge_rx.c
@@ -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,
OpenPOWER on IntegriCloud