2 * Copyright (c) 2010-2016 Solarflare Communications Inc.
5 * This software was developed in part by Philip Paeps under contract for
6 * Solarflare Communications, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * The views and conclusions contained in the software and documentation are
30 * those of the authors and should not be interpreted as representing official
31 * policies, either expressed or implied, of the FreeBSD Project.
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
37 #include <sys/param.h>
38 #include <sys/systm.h>
40 #include "common/efx.h"
45 sfxge_ev_qcomplete(struct sfxge_evq *evq, boolean_t eop)
47 struct sfxge_softc *sc;
49 struct sfxge_rxq *rxq;
50 struct sfxge_txq *txq;
52 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
58 if ((txq = evq->txq) != NULL) {
60 evq->txqs = &(evq->txq);
63 struct sfxge_txq *next;
68 KASSERT(txq->evq_index == index,
69 ("txq->evq_index != index"));
71 if (txq->pending != txq->completed)
72 sfxge_tx_qcomplete(txq, evq);
75 } while (txq != NULL);
78 if (rxq->pending != rxq->completed)
79 sfxge_rx_qcomplete(rxq, eop);
82 static struct sfxge_rxq *
83 sfxge_get_rxq_by_label(struct sfxge_evq *evq, uint32_t label)
85 struct sfxge_rxq *rxq;
87 KASSERT(label == 0, ("unexpected rxq label != 0"));
89 rxq = evq->sc->rxq[evq->index];
91 KASSERT(rxq != NULL, ("rxq == NULL"));
92 KASSERT(evq->index == rxq->index, ("evq->index != rxq->index"));
98 sfxge_ev_rx(void *arg, uint32_t label, uint32_t id, uint32_t size,
101 struct sfxge_evq *evq;
102 struct sfxge_softc *sc;
103 struct sfxge_rxq *rxq;
106 struct sfxge_rx_sw_desc *rx_desc;
109 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
116 rxq = sfxge_get_rxq_by_label(evq, label);
117 if (__predict_false(rxq->init_state != SFXGE_RXQ_STARTED))
120 stop = (id + 1) & rxq->ptr_mask;
121 id = rxq->pending & rxq->ptr_mask;
122 delta = (stop >= id) ? (stop - id) : (rxq->entries - id + stop);
123 rxq->pending += delta;
126 if ((!efx_nic_cfg_get(sc->enp)->enc_rx_batching_enabled) ||
128 (delta > efx_nic_cfg_get(sc->enp)->enc_rx_batch_max)) {
129 evq->exception = B_TRUE;
131 device_printf(sc->dev, "RX completion out of order"
132 " (id=%#x delta=%u flags=%#x); resetting\n",
134 sfxge_schedule_reset(sc);
140 rx_desc = &rxq->queue[id];
142 prefetch_read_many(rx_desc->mbuf);
144 for (; id != stop; id = (id + 1) & rxq->ptr_mask) {
145 rx_desc = &rxq->queue[id];
146 KASSERT(rx_desc->flags == EFX_DISCARD,
147 ("rx_desc->flags != EFX_DISCARD"));
148 rx_desc->flags = flags;
150 KASSERT(size < (1 << 16), ("size > (1 << 16)"));
151 rx_desc->size = (uint16_t)size;
156 if (rxq->pending - rxq->completed >= SFXGE_RX_BATCH)
157 sfxge_ev_qcomplete(evq, B_FALSE);
160 return (evq->rx_done >= SFXGE_EV_BATCH);
164 sfxge_ev_exception(void *arg, uint32_t code, uint32_t data)
166 struct sfxge_evq *evq;
167 struct sfxge_softc *sc;
169 evq = (struct sfxge_evq *)arg;
170 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
174 DBGPRINT(sc->dev, "[%d] %s", evq->index,
175 (code == EFX_EXCEPTION_RX_RECOVERY) ? "RX_RECOVERY" :
176 (code == EFX_EXCEPTION_RX_DSC_ERROR) ? "RX_DSC_ERROR" :
177 (code == EFX_EXCEPTION_TX_DSC_ERROR) ? "TX_DSC_ERROR" :
178 (code == EFX_EXCEPTION_UNKNOWN_SENSOREVT) ? "UNKNOWN_SENSOREVT" :
179 (code == EFX_EXCEPTION_FWALERT_SRAM) ? "FWALERT_SRAM" :
180 (code == EFX_EXCEPTION_UNKNOWN_FWALERT) ? "UNKNOWN_FWALERT" :
181 (code == EFX_EXCEPTION_RX_ERROR) ? "RX_ERROR" :
182 (code == EFX_EXCEPTION_TX_ERROR) ? "TX_ERROR" :
183 (code == EFX_EXCEPTION_EV_ERROR) ? "EV_ERROR" :
186 evq->exception = B_TRUE;
188 if (code != EFX_EXCEPTION_UNKNOWN_SENSOREVT) {
189 device_printf(sc->dev,
190 "hardware exception (code=%u); resetting\n",
192 sfxge_schedule_reset(sc);
199 sfxge_ev_rxq_flush_done(void *arg, uint32_t rxq_index)
201 struct sfxge_evq *evq;
202 struct sfxge_softc *sc;
203 struct sfxge_rxq *rxq;
207 evq = (struct sfxge_evq *)arg;
208 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
211 rxq = sc->rxq[rxq_index];
213 KASSERT(rxq != NULL, ("rxq == NULL"));
215 /* Resend a software event on the correct queue */
217 if (index == evq->index) {
218 sfxge_rx_qflush_done(rxq);
222 evq = sc->evq[index];
223 magic = sfxge_sw_ev_rxq_magic(SFXGE_SW_EV_RX_QFLUSH_DONE, rxq);
225 KASSERT(evq->init_state == SFXGE_EVQ_STARTED,
226 ("evq not started"));
227 efx_ev_qpost(evq->common, magic);
233 sfxge_ev_rxq_flush_failed(void *arg, uint32_t rxq_index)
235 struct sfxge_evq *evq;
236 struct sfxge_softc *sc;
237 struct sfxge_rxq *rxq;
241 evq = (struct sfxge_evq *)arg;
242 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
245 rxq = sc->rxq[rxq_index];
247 KASSERT(rxq != NULL, ("rxq == NULL"));
249 /* Resend a software event on the correct queue */
251 evq = sc->evq[index];
252 magic = sfxge_sw_ev_rxq_magic(SFXGE_SW_EV_RX_QFLUSH_FAILED, rxq);
254 KASSERT(evq->init_state == SFXGE_EVQ_STARTED,
255 ("evq not started"));
256 efx_ev_qpost(evq->common, magic);
261 static struct sfxge_txq *
262 sfxge_get_txq_by_label(struct sfxge_evq *evq, enum sfxge_txq_type label)
266 KASSERT((evq->index == 0 && label < SFXGE_TXQ_NTYPES) ||
267 (label == SFXGE_TXQ_IP_TCP_UDP_CKSUM), ("unexpected txq label"));
268 index = (evq->index == 0) ? label : (evq->index - 1 + SFXGE_TXQ_NTYPES);
269 return (evq->sc->txq[index]);
273 sfxge_ev_tx(void *arg, uint32_t label, uint32_t id)
275 struct sfxge_evq *evq;
276 struct sfxge_txq *txq;
280 evq = (struct sfxge_evq *)arg;
281 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
283 txq = sfxge_get_txq_by_label(evq, label);
285 KASSERT(txq != NULL, ("txq == NULL"));
286 KASSERT(evq->index == txq->evq_index,
287 ("evq->index != txq->evq_index"));
289 if (__predict_false(txq->init_state != SFXGE_TXQ_STARTED))
292 stop = (id + 1) & txq->ptr_mask;
293 id = txq->pending & txq->ptr_mask;
295 delta = (stop >= id) ? (stop - id) : (txq->entries - id + stop);
296 txq->pending += delta;
300 if (txq->next == NULL &&
301 evq->txqs != &(txq->next)) {
303 evq->txqs = &(txq->next);
306 if (txq->pending - txq->completed >= SFXGE_TX_BATCH)
307 sfxge_tx_qcomplete(txq, evq);
310 return (evq->tx_done >= SFXGE_EV_BATCH);
314 sfxge_ev_txq_flush_done(void *arg, uint32_t txq_index)
316 struct sfxge_evq *evq;
317 struct sfxge_softc *sc;
318 struct sfxge_txq *txq;
321 evq = (struct sfxge_evq *)arg;
322 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
325 txq = sc->txq[txq_index];
327 KASSERT(txq != NULL, ("txq == NULL"));
328 KASSERT(txq->init_state == SFXGE_TXQ_INITIALIZED,
329 ("txq not initialized"));
331 if (txq->evq_index == evq->index) {
332 sfxge_tx_qflush_done(txq);
336 /* Resend a software event on the correct queue */
337 evq = sc->evq[txq->evq_index];
338 magic = sfxge_sw_ev_txq_magic(SFXGE_SW_EV_TX_QFLUSH_DONE, txq);
340 KASSERT(evq->init_state == SFXGE_EVQ_STARTED,
341 ("evq not started"));
342 efx_ev_qpost(evq->common, magic);
348 sfxge_ev_software(void *arg, uint16_t magic)
350 struct sfxge_evq *evq;
351 struct sfxge_softc *sc;
354 evq = (struct sfxge_evq *)arg;
355 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
359 label = magic & SFXGE_MAGIC_DMAQ_LABEL_MASK;
360 magic &= ~SFXGE_MAGIC_DMAQ_LABEL_MASK;
363 case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_DONE):
364 sfxge_rx_qflush_done(sfxge_get_rxq_by_label(evq, label));
367 case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QFLUSH_FAILED):
368 sfxge_rx_qflush_failed(sfxge_get_rxq_by_label(evq, label));
371 case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_RX_QREFILL):
372 sfxge_rx_qrefill(sfxge_get_rxq_by_label(evq, label));
375 case SFXGE_SW_EV_MAGIC(SFXGE_SW_EV_TX_QFLUSH_DONE): {
376 struct sfxge_txq *txq = sfxge_get_txq_by_label(evq, label);
378 KASSERT(txq != NULL, ("txq == NULL"));
379 KASSERT(evq->index == txq->evq_index,
380 ("evq->index != txq->evq_index"));
382 sfxge_tx_qflush_done(txq);
393 sfxge_ev_sram(void *arg, uint32_t code)
399 case EFX_SRAM_UPDATE:
400 EFSYS_PROBE(sram_update);
404 EFSYS_PROBE(sram_clear);
407 case EFX_SRAM_ILLEGAL_CLEAR:
408 EFSYS_PROBE(sram_illegal_clear);
412 KASSERT(B_FALSE, ("Impossible SRAM event"));
420 sfxge_ev_timer(void *arg, uint32_t index)
429 sfxge_ev_wake_up(void *arg, uint32_t index)
440 sfxge_ev_stat_update(struct sfxge_softc *sc)
442 struct sfxge_evq *evq;
446 SFXGE_ADAPTER_LOCK(sc);
448 if (__predict_false(sc->evq[0]->init_state != SFXGE_EVQ_STARTED))
452 if (now - sc->ev_stats_update_time < hz)
455 sc->ev_stats_update_time = now;
457 /* Add event counts from each event queue in turn */
458 for (index = 0; index < sc->evq_count; index++) {
459 evq = sc->evq[index];
461 efx_ev_qstats_update(evq->common, sc->ev_stats);
462 SFXGE_EVQ_UNLOCK(evq);
465 SFXGE_ADAPTER_UNLOCK(sc);
469 sfxge_ev_stat_handler(SYSCTL_HANDLER_ARGS)
471 struct sfxge_softc *sc = arg1;
472 unsigned int id = arg2;
474 sfxge_ev_stat_update(sc);
476 return (SYSCTL_OUT(req, &sc->ev_stats[id], sizeof(sc->ev_stats[id])));
480 sfxge_ev_stat_init(struct sfxge_softc *sc)
482 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
483 struct sysctl_oid_list *stat_list;
487 stat_list = SYSCTL_CHILDREN(sc->stats_node);
489 for (id = 0; id < EV_NQSTATS; id++) {
490 snprintf(name, sizeof(name), "ev_%s",
491 efx_ev_qstat_name(sc->enp, id));
494 OID_AUTO, name, CTLTYPE_U64|CTLFLAG_RD,
495 sc, id, sfxge_ev_stat_handler, "Q",
500 #endif /* EFSYS_OPT_QSTATS */
503 sfxge_ev_qmoderate(struct sfxge_softc *sc, unsigned int idx, unsigned int us)
505 struct sfxge_evq *evq;
511 KASSERT(evq->init_state == SFXGE_EVQ_STARTED,
512 ("evq->init_state != SFXGE_EVQ_STARTED"));
514 (void)efx_ev_qmoderate(eep, us);
518 sfxge_int_mod_handler(SYSCTL_HANDLER_ARGS)
520 struct sfxge_softc *sc = arg1;
521 struct sfxge_intr *intr = &sc->intr;
522 unsigned int moderation;
526 SFXGE_ADAPTER_LOCK(sc);
528 if (req->newptr != NULL) {
529 if ((error = SYSCTL_IN(req, &moderation, sizeof(moderation)))
533 /* We may not be calling efx_ev_qmoderate() now,
534 * so we have to range-check the value ourselves.
537 efx_nic_cfg_get(sc->enp)->enc_evq_timer_max_us) {
542 sc->ev_moderation = moderation;
543 if (intr->state == SFXGE_INTR_STARTED) {
544 for (index = 0; index < sc->evq_count; index++)
545 sfxge_ev_qmoderate(sc, index, moderation);
548 error = SYSCTL_OUT(req, &sc->ev_moderation,
549 sizeof(sc->ev_moderation));
553 SFXGE_ADAPTER_UNLOCK(sc);
559 sfxge_ev_initialized(void *arg)
561 struct sfxge_evq *evq;
563 evq = (struct sfxge_evq *)arg;
564 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
566 /* Init done events may be duplicated on 7xxx */
567 KASSERT(evq->init_state == SFXGE_EVQ_STARTING ||
568 evq->init_state == SFXGE_EVQ_STARTED,
569 ("evq not starting"));
571 evq->init_state = SFXGE_EVQ_STARTED;
577 sfxge_ev_link_change(void *arg, efx_link_mode_t link_mode)
579 struct sfxge_evq *evq;
580 struct sfxge_softc *sc;
582 evq = (struct sfxge_evq *)arg;
583 SFXGE_EVQ_LOCK_ASSERT_OWNED(evq);
587 sfxge_mac_link_update(sc, link_mode);
592 static const efx_ev_callbacks_t sfxge_ev_callbacks = {
593 .eec_initialized = sfxge_ev_initialized,
594 .eec_rx = sfxge_ev_rx,
595 .eec_tx = sfxge_ev_tx,
596 .eec_exception = sfxge_ev_exception,
597 .eec_rxq_flush_done = sfxge_ev_rxq_flush_done,
598 .eec_rxq_flush_failed = sfxge_ev_rxq_flush_failed,
599 .eec_txq_flush_done = sfxge_ev_txq_flush_done,
600 .eec_software = sfxge_ev_software,
601 .eec_sram = sfxge_ev_sram,
602 .eec_wake_up = sfxge_ev_wake_up,
603 .eec_timer = sfxge_ev_timer,
604 .eec_link_change = sfxge_ev_link_change,
609 sfxge_ev_qpoll(struct sfxge_evq *evq)
615 if (__predict_false(evq->init_state != SFXGE_EVQ_STARTING &&
616 evq->init_state != SFXGE_EVQ_STARTED)) {
621 /* Synchronize the DMA memory for reading */
622 bus_dmamap_sync(evq->mem.esm_tag, evq->mem.esm_map,
623 BUS_DMASYNC_POSTREAD);
625 KASSERT(evq->rx_done == 0, ("evq->rx_done != 0"));
626 KASSERT(evq->tx_done == 0, ("evq->tx_done != 0"));
627 KASSERT(evq->txq == NULL, ("evq->txq != NULL"));
628 KASSERT(evq->txqs == &evq->txq, ("evq->txqs != &evq->txq"));
631 efx_ev_qpoll(evq->common, &evq->read_ptr, &sfxge_ev_callbacks, evq);
636 /* Perform any pending completion processing */
637 sfxge_ev_qcomplete(evq, B_TRUE);
639 /* Re-prime the event queue for interrupts */
640 if ((rc = efx_ev_qprime(evq->common, evq->read_ptr)) != 0)
643 SFXGE_EVQ_UNLOCK(evq);
648 SFXGE_EVQ_UNLOCK(evq);
653 sfxge_ev_qstop(struct sfxge_softc *sc, unsigned int index)
655 struct sfxge_evq *evq;
657 evq = sc->evq[index];
659 KASSERT(evq->init_state == SFXGE_EVQ_STARTED,
660 ("evq->init_state != SFXGE_EVQ_STARTED"));
663 evq->init_state = SFXGE_EVQ_INITIALIZED;
665 evq->exception = B_FALSE;
668 /* Add event counts before discarding the common evq state */
669 efx_ev_qstats_update(evq->common, sc->ev_stats);
672 efx_ev_qdestroy(evq->common);
673 efx_sram_buf_tbl_clear(sc->enp, evq->buf_base_id,
674 EFX_EVQ_NBUFS(evq->entries));
675 SFXGE_EVQ_UNLOCK(evq);
679 sfxge_ev_qstart(struct sfxge_softc *sc, unsigned int index)
681 struct sfxge_evq *evq;
686 evq = sc->evq[index];
689 KASSERT(evq->init_state == SFXGE_EVQ_INITIALIZED,
690 ("evq->init_state != SFXGE_EVQ_INITIALIZED"));
692 /* Clear all events. */
693 (void)memset(esmp->esm_base, 0xff, EFX_EVQ_SIZE(evq->entries));
695 /* Program the buffer table. */
696 if ((rc = efx_sram_buf_tbl_set(sc->enp, evq->buf_base_id, esmp,
697 EFX_EVQ_NBUFS(evq->entries))) != 0)
700 /* Create the common code event queue. */
701 if ((rc = efx_ev_qcreate(sc->enp, index, esmp, evq->entries,
702 evq->buf_base_id, sc->ev_moderation, &evq->common)) != 0)
707 /* Prime the event queue for interrupts */
708 if ((rc = efx_ev_qprime(evq->common, evq->read_ptr)) != 0)
711 evq->init_state = SFXGE_EVQ_STARTING;
713 SFXGE_EVQ_UNLOCK(evq);
715 /* Wait for the initialization event */
718 /* Pause for 100 ms */
719 pause("sfxge evq init", hz / 10);
721 /* Check to see if the test event has been processed */
722 if (evq->init_state == SFXGE_EVQ_STARTED)
725 } while (++count < 20);
735 evq->init_state = SFXGE_EVQ_INITIALIZED;
737 SFXGE_EVQ_UNLOCK(evq);
738 efx_ev_qdestroy(evq->common);
740 efx_sram_buf_tbl_clear(sc->enp, evq->buf_base_id,
741 EFX_EVQ_NBUFS(evq->entries));
747 sfxge_ev_stop(struct sfxge_softc *sc)
749 struct sfxge_intr *intr;
756 KASSERT(intr->state == SFXGE_INTR_STARTED,
757 ("Interrupts not started"));
759 /* Stop the event queue(s) */
760 index = sc->evq_count;
762 sfxge_ev_qstop(sc, index);
764 /* Tear down the event module */
769 sfxge_ev_start(struct sfxge_softc *sc)
771 struct sfxge_intr *intr;
777 KASSERT(intr->state == SFXGE_INTR_STARTED,
778 ("intr->state != SFXGE_INTR_STARTED"));
780 /* Initialize the event module */
781 if ((rc = efx_ev_init(sc->enp)) != 0)
784 /* Start the event queues */
785 for (index = 0; index < sc->evq_count; index++) {
786 if ((rc = sfxge_ev_qstart(sc, index)) != 0)
793 /* Stop the event queue(s) */
795 sfxge_ev_qstop(sc, index);
797 /* Tear down the event module */
798 efx_ev_fini(sc->enp);
804 sfxge_ev_qfini(struct sfxge_softc *sc, unsigned int index)
806 struct sfxge_evq *evq;
808 evq = sc->evq[index];
810 KASSERT(evq->init_state == SFXGE_EVQ_INITIALIZED,
811 ("evq->init_state != SFXGE_EVQ_INITIALIZED"));
812 KASSERT(evq->txqs == &evq->txq, ("evq->txqs != &evq->txq"));
814 sfxge_dma_free(&evq->mem);
816 sc->evq[index] = NULL;
818 SFXGE_EVQ_LOCK_DESTROY(evq);
824 sfxge_ev_qinit(struct sfxge_softc *sc, unsigned int index)
826 struct sfxge_evq *evq;
830 KASSERT(index < SFXGE_RX_SCALE_MAX, ("index >= SFXGE_RX_SCALE_MAX"));
832 evq = malloc(sizeof(struct sfxge_evq), M_SFXGE, M_ZERO | M_WAITOK);
835 sc->evq[index] = evq;
838 /* Build an event queue with room for one event per tx and rx buffer,
839 * plus some extra for link state events and MCDI completions.
840 * There are three tx queues in the first event queue and one in
845 ROUNDUP_POW_OF_TWO(sc->rxq_entries +
846 3 * sc->txq_entries +
850 ROUNDUP_POW_OF_TWO(sc->rxq_entries +
854 /* Initialise TX completion list */
855 evq->txqs = &evq->txq;
857 /* Allocate DMA space. */
858 if ((rc = sfxge_dma_alloc(sc, EFX_EVQ_SIZE(evq->entries), esmp)) != 0)
861 /* Allocate buffer table entries. */
862 sfxge_sram_buf_tbl_alloc(sc, EFX_EVQ_NBUFS(evq->entries),
865 SFXGE_EVQ_LOCK_INIT(evq, device_get_nameunit(sc->dev), index);
867 evq->init_state = SFXGE_EVQ_INITIALIZED;
873 sfxge_ev_fini(struct sfxge_softc *sc)
875 struct sfxge_intr *intr;
880 KASSERT(intr->state == SFXGE_INTR_INITIALIZED,
881 ("intr->state != SFXGE_INTR_INITIALIZED"));
883 sc->ev_moderation = 0;
885 /* Tear down the event queue(s). */
886 index = sc->evq_count;
888 sfxge_ev_qfini(sc, index);
894 sfxge_ev_init(struct sfxge_softc *sc)
896 struct sysctl_ctx_list *sysctl_ctx = device_get_sysctl_ctx(sc->dev);
897 struct sysctl_oid *sysctl_tree = device_get_sysctl_tree(sc->dev);
898 struct sfxge_intr *intr;
904 sc->evq_count = intr->n_alloc;
906 KASSERT(intr->state == SFXGE_INTR_INITIALIZED,
907 ("intr->state != SFXGE_INTR_INITIALIZED"));
909 /* Set default interrupt moderation; add a sysctl to
910 * read and change it.
912 sc->ev_moderation = SFXGE_MODERATION;
913 SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
914 OID_AUTO, "int_mod", CTLTYPE_UINT|CTLFLAG_RW,
915 sc, 0, sfxge_int_mod_handler, "IU",
916 "sfxge interrupt moderation (us)");
919 * Initialize the event queue(s) - one per interrupt.
921 for (index = 0; index < sc->evq_count; index++) {
922 if ((rc = sfxge_ev_qinit(sc, index)) != 0)
927 sfxge_ev_stat_init(sc);
934 sfxge_ev_qfini(sc, index);