1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016-2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
10 #include <rte_debug.h>
11 #include <rte_cycles.h>
12 #include <rte_alarm.h>
13 #include <rte_branch_prediction.h>
18 #include "sfc_debug.h"
23 #include "sfc_kvargs.h"
26 /* Initial delay when waiting for event queue init complete event */
27 #define SFC_EVQ_INIT_BACKOFF_START_US (1)
28 /* Maximum delay between event queue polling attempts */
29 #define SFC_EVQ_INIT_BACKOFF_MAX_US (10 * 1000)
30 /* Event queue init approx timeout */
31 #define SFC_EVQ_INIT_TIMEOUT_US (2 * US_PER_S)
33 /* Management event queue polling period in microseconds */
34 #define SFC_MGMT_EV_QPOLL_PERIOD_US (US_PER_S)
37 sfc_evq_type2str(enum sfc_evq_type type)
40 case SFC_EVQ_TYPE_MGMT:
53 sfc_ev_initialized(void *arg)
55 struct sfc_evq *evq = arg;
57 /* Init done events may be duplicated on SFN7xxx (SFC bug 31631) */
58 SFC_ASSERT(evq->init_state == SFC_EVQ_STARTING ||
59 evq->init_state == SFC_EVQ_STARTED);
61 evq->init_state = SFC_EVQ_STARTED;
67 sfc_ev_nop_rx(void *arg, uint32_t label, uint32_t id,
68 uint32_t size, uint16_t flags)
70 struct sfc_evq *evq = arg;
73 "EVQ %u unexpected Rx event label=%u id=%#x size=%u flags=%#x",
74 evq->evq_index, label, id, size, flags);
79 sfc_ev_efx_rx(void *arg, __rte_unused uint32_t label, uint32_t id,
80 uint32_t size, uint16_t flags)
82 struct sfc_evq *evq = arg;
83 struct sfc_efx_rxq *rxq;
85 unsigned int pending_id;
88 struct sfc_efx_rx_sw_desc *rxd;
90 if (unlikely(evq->exception))
93 rxq = sfc_efx_rxq_by_dp_rxq(evq->dp_rxq);
95 SFC_ASSERT(rxq != NULL);
96 SFC_ASSERT(rxq->evq == evq);
97 SFC_ASSERT(rxq->flags & SFC_EFX_RXQ_FLAG_STARTED);
99 stop = (id + 1) & rxq->ptr_mask;
100 pending_id = rxq->pending & rxq->ptr_mask;
101 delta = (stop >= pending_id) ? (stop - pending_id) :
102 (rxq->ptr_mask + 1 - pending_id + stop);
106 * Rx event with no new descriptors done and zero length
107 * is used to abort scattered packet when there is no room
110 if (unlikely(size != 0)) {
111 evq->exception = B_TRUE;
113 "EVQ %u RxQ %u invalid RX abort "
114 "(id=%#x size=%u flags=%#x); needs restart",
115 evq->evq_index, rxq->dp.dpq.queue_id,
120 /* Add discard flag to the first fragment */
121 rxq->sw_desc[pending_id].flags |= EFX_DISCARD;
122 /* Remove continue flag from the last fragment */
123 rxq->sw_desc[id].flags &= ~EFX_PKT_CONT;
124 } else if (unlikely(delta > rxq->batch_max)) {
125 evq->exception = B_TRUE;
128 "EVQ %u RxQ %u completion out of order "
129 "(id=%#x delta=%u flags=%#x); needs restart",
130 evq->evq_index, rxq->dp.dpq.queue_id,
136 for (i = pending_id; i != stop; i = (i + 1) & rxq->ptr_mask) {
137 rxd = &rxq->sw_desc[i];
141 SFC_ASSERT(size < (1 << 16));
142 rxd->size = (uint16_t)size;
145 rxq->pending += delta;
152 sfc_ev_dp_rx(void *arg, __rte_unused uint32_t label, uint32_t id,
153 __rte_unused uint32_t size, __rte_unused uint16_t flags)
155 struct sfc_evq *evq = arg;
156 struct sfc_dp_rxq *dp_rxq;
158 dp_rxq = evq->dp_rxq;
159 SFC_ASSERT(dp_rxq != NULL);
161 SFC_ASSERT(evq->sa->dp_rx->qrx_ev != NULL);
162 return evq->sa->dp_rx->qrx_ev(dp_rxq, id);
166 sfc_ev_nop_tx(void *arg, uint32_t label, uint32_t id)
168 struct sfc_evq *evq = arg;
170 sfc_err(evq->sa, "EVQ %u unexpected Tx event label=%u id=%#x",
171 evq->evq_index, label, id);
176 sfc_ev_tx(void *arg, __rte_unused uint32_t label, uint32_t id)
178 struct sfc_evq *evq = arg;
179 struct sfc_dp_txq *dp_txq;
180 struct sfc_efx_txq *txq;
184 dp_txq = evq->dp_txq;
185 SFC_ASSERT(dp_txq != NULL);
187 txq = sfc_efx_txq_by_dp_txq(dp_txq);
188 SFC_ASSERT(txq->evq == evq);
190 if (unlikely((txq->flags & SFC_EFX_TXQ_FLAG_STARTED) == 0))
193 stop = (id + 1) & txq->ptr_mask;
194 id = txq->pending & txq->ptr_mask;
196 delta = (stop >= id) ? (stop - id) : (txq->ptr_mask + 1 - id + stop);
198 txq->pending += delta;
205 sfc_ev_dp_tx(void *arg, __rte_unused uint32_t label, uint32_t id)
207 struct sfc_evq *evq = arg;
208 struct sfc_dp_txq *dp_txq;
210 dp_txq = evq->dp_txq;
211 SFC_ASSERT(dp_txq != NULL);
213 SFC_ASSERT(evq->sa->dp_tx->qtx_ev != NULL);
214 return evq->sa->dp_tx->qtx_ev(dp_txq, id);
218 sfc_ev_exception(void *arg, uint32_t code, __rte_unused uint32_t data)
220 struct sfc_evq *evq = arg;
222 if (code == EFX_EXCEPTION_UNKNOWN_SENSOREVT)
225 evq->exception = B_TRUE;
227 "hardware exception %s (code=%u, data=%#x) on EVQ %u;"
229 (code == EFX_EXCEPTION_RX_RECOVERY) ? "RX_RECOVERY" :
230 (code == EFX_EXCEPTION_RX_DSC_ERROR) ? "RX_DSC_ERROR" :
231 (code == EFX_EXCEPTION_TX_DSC_ERROR) ? "TX_DSC_ERROR" :
232 (code == EFX_EXCEPTION_FWALERT_SRAM) ? "FWALERT_SRAM" :
233 (code == EFX_EXCEPTION_UNKNOWN_FWALERT) ? "UNKNOWN_FWALERT" :
234 (code == EFX_EXCEPTION_RX_ERROR) ? "RX_ERROR" :
235 (code == EFX_EXCEPTION_TX_ERROR) ? "TX_ERROR" :
236 (code == EFX_EXCEPTION_EV_ERROR) ? "EV_ERROR" :
238 code, data, evq->evq_index);
244 sfc_ev_nop_rxq_flush_done(void *arg, uint32_t rxq_hw_index)
246 struct sfc_evq *evq = arg;
248 sfc_err(evq->sa, "EVQ %u unexpected RxQ %u flush done",
249 evq->evq_index, rxq_hw_index);
254 sfc_ev_rxq_flush_done(void *arg, __rte_unused uint32_t rxq_hw_index)
256 struct sfc_evq *evq = arg;
257 struct sfc_dp_rxq *dp_rxq;
260 dp_rxq = evq->dp_rxq;
261 SFC_ASSERT(dp_rxq != NULL);
263 rxq = sfc_rxq_by_dp_rxq(dp_rxq);
264 SFC_ASSERT(rxq != NULL);
265 SFC_ASSERT(rxq->hw_index == rxq_hw_index);
266 SFC_ASSERT(rxq->evq == evq);
267 sfc_rx_qflush_done(rxq);
273 sfc_ev_nop_rxq_flush_failed(void *arg, uint32_t rxq_hw_index)
275 struct sfc_evq *evq = arg;
277 sfc_err(evq->sa, "EVQ %u unexpected RxQ %u flush failed",
278 evq->evq_index, rxq_hw_index);
283 sfc_ev_rxq_flush_failed(void *arg, __rte_unused uint32_t rxq_hw_index)
285 struct sfc_evq *evq = arg;
286 struct sfc_dp_rxq *dp_rxq;
289 dp_rxq = evq->dp_rxq;
290 SFC_ASSERT(dp_rxq != NULL);
292 rxq = sfc_rxq_by_dp_rxq(dp_rxq);
293 SFC_ASSERT(rxq != NULL);
294 SFC_ASSERT(rxq->hw_index == rxq_hw_index);
295 SFC_ASSERT(rxq->evq == evq);
296 sfc_rx_qflush_failed(rxq);
302 sfc_ev_nop_txq_flush_done(void *arg, uint32_t txq_hw_index)
304 struct sfc_evq *evq = arg;
306 sfc_err(evq->sa, "EVQ %u unexpected TxQ %u flush done",
307 evq->evq_index, txq_hw_index);
312 sfc_ev_txq_flush_done(void *arg, __rte_unused uint32_t txq_hw_index)
314 struct sfc_evq *evq = arg;
315 struct sfc_dp_txq *dp_txq;
318 dp_txq = evq->dp_txq;
319 SFC_ASSERT(dp_txq != NULL);
321 txq = sfc_txq_by_dp_txq(dp_txq);
322 SFC_ASSERT(txq != NULL);
323 SFC_ASSERT(txq->hw_index == txq_hw_index);
324 SFC_ASSERT(txq->evq == evq);
325 sfc_tx_qflush_done(txq);
331 sfc_ev_software(void *arg, uint16_t magic)
333 struct sfc_evq *evq = arg;
335 sfc_err(evq->sa, "EVQ %u unexpected software event magic=%#.4x",
336 evq->evq_index, magic);
341 sfc_ev_sram(void *arg, uint32_t code)
343 struct sfc_evq *evq = arg;
345 sfc_err(evq->sa, "EVQ %u unexpected SRAM event code=%u",
346 evq->evq_index, code);
351 sfc_ev_wake_up(void *arg, uint32_t index)
353 struct sfc_evq *evq = arg;
355 sfc_err(evq->sa, "EVQ %u unexpected wake up event index=%u",
356 evq->evq_index, index);
361 sfc_ev_timer(void *arg, uint32_t index)
363 struct sfc_evq *evq = arg;
365 sfc_err(evq->sa, "EVQ %u unexpected timer event index=%u",
366 evq->evq_index, index);
371 sfc_ev_nop_link_change(void *arg, __rte_unused efx_link_mode_t link_mode)
373 struct sfc_evq *evq = arg;
375 sfc_err(evq->sa, "EVQ %u unexpected link change event",
381 sfc_ev_link_change(void *arg, efx_link_mode_t link_mode)
383 struct sfc_evq *evq = arg;
384 struct sfc_adapter *sa = evq->sa;
385 struct rte_eth_link *dev_link = &sa->eth_dev->data->dev_link;
386 struct rte_eth_link new_link;
387 uint64_t new_link_u64;
388 uint64_t old_link_u64;
390 EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t));
392 sfc_port_link_mode_to_info(link_mode, &new_link);
394 new_link_u64 = *(uint64_t *)&new_link;
396 old_link_u64 = rte_atomic64_read((rte_atomic64_t *)dev_link);
397 if (old_link_u64 == new_link_u64)
400 if (rte_atomic64_cmpset((volatile uint64_t *)dev_link,
401 old_link_u64, new_link_u64)) {
402 evq->sa->port.lsc_seq++;
410 static const efx_ev_callbacks_t sfc_ev_callbacks = {
411 .eec_initialized = sfc_ev_initialized,
412 .eec_rx = sfc_ev_nop_rx,
413 .eec_tx = sfc_ev_nop_tx,
414 .eec_exception = sfc_ev_exception,
415 .eec_rxq_flush_done = sfc_ev_nop_rxq_flush_done,
416 .eec_rxq_flush_failed = sfc_ev_nop_rxq_flush_failed,
417 .eec_txq_flush_done = sfc_ev_nop_txq_flush_done,
418 .eec_software = sfc_ev_software,
419 .eec_sram = sfc_ev_sram,
420 .eec_wake_up = sfc_ev_wake_up,
421 .eec_timer = sfc_ev_timer,
422 .eec_link_change = sfc_ev_link_change,
425 static const efx_ev_callbacks_t sfc_ev_callbacks_efx_rx = {
426 .eec_initialized = sfc_ev_initialized,
427 .eec_rx = sfc_ev_efx_rx,
428 .eec_tx = sfc_ev_nop_tx,
429 .eec_exception = sfc_ev_exception,
430 .eec_rxq_flush_done = sfc_ev_rxq_flush_done,
431 .eec_rxq_flush_failed = sfc_ev_rxq_flush_failed,
432 .eec_txq_flush_done = sfc_ev_nop_txq_flush_done,
433 .eec_software = sfc_ev_software,
434 .eec_sram = sfc_ev_sram,
435 .eec_wake_up = sfc_ev_wake_up,
436 .eec_timer = sfc_ev_timer,
437 .eec_link_change = sfc_ev_nop_link_change,
440 static const efx_ev_callbacks_t sfc_ev_callbacks_dp_rx = {
441 .eec_initialized = sfc_ev_initialized,
442 .eec_rx = sfc_ev_dp_rx,
443 .eec_tx = sfc_ev_nop_tx,
444 .eec_exception = sfc_ev_exception,
445 .eec_rxq_flush_done = sfc_ev_rxq_flush_done,
446 .eec_rxq_flush_failed = sfc_ev_rxq_flush_failed,
447 .eec_txq_flush_done = sfc_ev_nop_txq_flush_done,
448 .eec_software = sfc_ev_software,
449 .eec_sram = sfc_ev_sram,
450 .eec_wake_up = sfc_ev_wake_up,
451 .eec_timer = sfc_ev_timer,
452 .eec_link_change = sfc_ev_nop_link_change,
455 static const efx_ev_callbacks_t sfc_ev_callbacks_efx_tx = {
456 .eec_initialized = sfc_ev_initialized,
457 .eec_rx = sfc_ev_nop_rx,
459 .eec_exception = sfc_ev_exception,
460 .eec_rxq_flush_done = sfc_ev_nop_rxq_flush_done,
461 .eec_rxq_flush_failed = sfc_ev_nop_rxq_flush_failed,
462 .eec_txq_flush_done = sfc_ev_txq_flush_done,
463 .eec_software = sfc_ev_software,
464 .eec_sram = sfc_ev_sram,
465 .eec_wake_up = sfc_ev_wake_up,
466 .eec_timer = sfc_ev_timer,
467 .eec_link_change = sfc_ev_nop_link_change,
470 static const efx_ev_callbacks_t sfc_ev_callbacks_dp_tx = {
471 .eec_initialized = sfc_ev_initialized,
472 .eec_rx = sfc_ev_nop_rx,
473 .eec_tx = sfc_ev_dp_tx,
474 .eec_exception = sfc_ev_exception,
475 .eec_rxq_flush_done = sfc_ev_nop_rxq_flush_done,
476 .eec_rxq_flush_failed = sfc_ev_nop_rxq_flush_failed,
477 .eec_txq_flush_done = sfc_ev_txq_flush_done,
478 .eec_software = sfc_ev_software,
479 .eec_sram = sfc_ev_sram,
480 .eec_wake_up = sfc_ev_wake_up,
481 .eec_timer = sfc_ev_timer,
482 .eec_link_change = sfc_ev_nop_link_change,
487 sfc_ev_qpoll(struct sfc_evq *evq)
489 SFC_ASSERT(evq->init_state == SFC_EVQ_STARTED ||
490 evq->init_state == SFC_EVQ_STARTING);
492 /* Synchronize the DMA memory for reading not required */
494 efx_ev_qpoll(evq->common, &evq->read_ptr, evq->callbacks, evq);
496 if (unlikely(evq->exception) && sfc_adapter_trylock(evq->sa)) {
497 struct sfc_adapter *sa = evq->sa;
500 if (evq->dp_rxq != NULL) {
501 unsigned int rxq_sw_index;
503 rxq_sw_index = evq->dp_rxq->dpq.queue_id;
506 "restart RxQ %u because of exception on its EvQ %u",
507 rxq_sw_index, evq->evq_index);
509 sfc_rx_qstop(sa, rxq_sw_index);
510 rc = sfc_rx_qstart(sa, rxq_sw_index);
512 sfc_err(sa, "cannot restart RxQ %u",
516 if (evq->dp_txq != NULL) {
517 unsigned int txq_sw_index;
519 txq_sw_index = evq->dp_txq->dpq.queue_id;
522 "restart TxQ %u because of exception on its EvQ %u",
523 txq_sw_index, evq->evq_index);
525 sfc_tx_qstop(sa, txq_sw_index);
526 rc = sfc_tx_qstart(sa, txq_sw_index);
528 sfc_err(sa, "cannot restart TxQ %u",
533 sfc_panic(sa, "unrecoverable exception on EvQ %u",
536 sfc_adapter_unlock(sa);
539 /* Poll-mode driver does not re-prime the event queue for interrupts */
543 sfc_ev_mgmt_qpoll(struct sfc_adapter *sa)
545 if (rte_spinlock_trylock(&sa->mgmt_evq_lock)) {
546 if (sa->mgmt_evq_running)
547 sfc_ev_qpoll(sa->mgmt_evq);
549 rte_spinlock_unlock(&sa->mgmt_evq_lock);
554 sfc_ev_qprime(struct sfc_evq *evq)
556 SFC_ASSERT(evq->init_state == SFC_EVQ_STARTED);
557 return efx_ev_qprime(evq->common, evq->read_ptr);
560 /* Event queue HW index allocation scheme is described in sfc_ev.h. */
562 sfc_ev_qstart(struct sfc_evq *evq, unsigned int hw_index)
564 struct sfc_adapter *sa = evq->sa;
566 uint32_t evq_flags = sa->evq_flags;
567 unsigned int total_delay_us;
568 unsigned int delay_us;
571 sfc_log_init(sa, "hw_index=%u", hw_index);
575 evq->evq_index = hw_index;
577 /* Clear all events */
578 (void)memset((void *)esmp->esm_base, 0xff, EFX_EVQ_SIZE(evq->entries));
580 if (sa->intr.lsc_intr && hw_index == sa->mgmt_evq_index)
581 evq_flags |= EFX_EVQ_FLAGS_NOTIFY_INTERRUPT;
583 evq_flags |= EFX_EVQ_FLAGS_NOTIFY_DISABLED;
585 /* Create the common code event queue */
586 rc = efx_ev_qcreate(sa->nic, hw_index, esmp, evq->entries,
587 0 /* unused on EF10 */, 0, evq_flags,
590 goto fail_ev_qcreate;
592 SFC_ASSERT(evq->dp_rxq == NULL || evq->dp_txq == NULL);
593 if (evq->dp_rxq != 0) {
594 if (strcmp(sa->dp_rx->dp.name, SFC_KVARG_DATAPATH_EFX) == 0)
595 evq->callbacks = &sfc_ev_callbacks_efx_rx;
597 evq->callbacks = &sfc_ev_callbacks_dp_rx;
598 } else if (evq->dp_txq != 0) {
599 if (strcmp(sa->dp_tx->dp.name, SFC_KVARG_DATAPATH_EFX) == 0)
600 evq->callbacks = &sfc_ev_callbacks_efx_tx;
602 evq->callbacks = &sfc_ev_callbacks_dp_tx;
604 evq->callbacks = &sfc_ev_callbacks;
607 evq->init_state = SFC_EVQ_STARTING;
609 /* Wait for the initialization event */
611 delay_us = SFC_EVQ_INIT_BACKOFF_START_US;
613 (void)sfc_ev_qpoll(evq);
615 /* Check to see if the initialization complete indication
616 * posted by the hardware.
618 if (evq->init_state == SFC_EVQ_STARTED)
621 /* Give event queue some time to init */
622 rte_delay_us(delay_us);
624 total_delay_us += delay_us;
626 /* Exponential backoff */
628 if (delay_us > SFC_EVQ_INIT_BACKOFF_MAX_US)
629 delay_us = SFC_EVQ_INIT_BACKOFF_MAX_US;
631 } while (total_delay_us < SFC_EVQ_INIT_TIMEOUT_US);
640 evq->init_state = SFC_EVQ_INITIALIZED;
641 efx_ev_qdestroy(evq->common);
644 sfc_log_init(sa, "failed %d", rc);
649 sfc_ev_qstop(struct sfc_evq *evq)
654 sfc_log_init(evq->sa, "hw_index=%u", evq->evq_index);
656 if (evq->init_state != SFC_EVQ_STARTED)
659 evq->init_state = SFC_EVQ_INITIALIZED;
660 evq->callbacks = NULL;
662 evq->exception = B_FALSE;
664 efx_ev_qdestroy(evq->common);
670 sfc_ev_mgmt_periodic_qpoll(void *arg)
672 struct sfc_adapter *sa = arg;
675 sfc_ev_mgmt_qpoll(sa);
677 rc = rte_eal_alarm_set(SFC_MGMT_EV_QPOLL_PERIOD_US,
678 sfc_ev_mgmt_periodic_qpoll, sa);
679 if (rc == -ENOTSUP) {
680 sfc_warn(sa, "alarms are not supported");
681 sfc_warn(sa, "management EVQ must be polled indirectly using no-wait link status update");
682 } else if (rc != 0) {
684 "cannot rearm management EVQ polling alarm (rc=%d)",
690 sfc_ev_mgmt_periodic_qpoll_start(struct sfc_adapter *sa)
692 sfc_ev_mgmt_periodic_qpoll(sa);
696 sfc_ev_mgmt_periodic_qpoll_stop(struct sfc_adapter *sa)
698 rte_eal_alarm_cancel(sfc_ev_mgmt_periodic_qpoll, sa);
702 sfc_ev_start(struct sfc_adapter *sa)
706 sfc_log_init(sa, "entry");
708 rc = efx_ev_init(sa->nic);
712 /* Start management EVQ used for global events */
715 * Management event queue start polls the queue, but it cannot
716 * interfere with other polling contexts since mgmt_evq_running
719 rc = sfc_ev_qstart(sa->mgmt_evq, sa->mgmt_evq_index);
721 goto fail_mgmt_evq_start;
723 rte_spinlock_lock(&sa->mgmt_evq_lock);
724 sa->mgmt_evq_running = true;
725 rte_spinlock_unlock(&sa->mgmt_evq_lock);
727 if (sa->intr.lsc_intr) {
728 rc = sfc_ev_qprime(sa->mgmt_evq);
730 goto fail_mgmt_evq_prime;
734 * Start management EVQ polling. If interrupts are disabled
735 * (not used), it is required to process link status change
736 * and other device level events to avoid unrecoverable
737 * error because the event queue overflow.
739 sfc_ev_mgmt_periodic_qpoll_start(sa);
742 * Rx/Tx event queues are started/stopped when corresponding
743 * Rx/Tx queue is started/stopped.
749 sfc_ev_qstop(sa->mgmt_evq);
752 efx_ev_fini(sa->nic);
755 sfc_log_init(sa, "failed %d", rc);
760 sfc_ev_stop(struct sfc_adapter *sa)
762 sfc_log_init(sa, "entry");
764 sfc_ev_mgmt_periodic_qpoll_stop(sa);
766 rte_spinlock_lock(&sa->mgmt_evq_lock);
767 sa->mgmt_evq_running = false;
768 rte_spinlock_unlock(&sa->mgmt_evq_lock);
770 sfc_ev_qstop(sa->mgmt_evq);
772 efx_ev_fini(sa->nic);
776 sfc_ev_qinit(struct sfc_adapter *sa,
777 enum sfc_evq_type type, unsigned int type_index,
778 unsigned int entries, int socket_id, struct sfc_evq **evqp)
783 sfc_log_init(sa, "type=%s type_index=%u",
784 sfc_evq_type2str(type), type_index);
786 SFC_ASSERT(rte_is_power_of_2(entries));
789 evq = rte_zmalloc_socket("sfc-evq", sizeof(*evq), RTE_CACHE_LINE_SIZE,
796 evq->entries = entries;
798 /* Allocate DMA space */
799 rc = sfc_dma_alloc(sa, sfc_evq_type2str(type), type_index,
800 EFX_EVQ_SIZE(evq->entries), socket_id, &evq->mem);
804 evq->init_state = SFC_EVQ_INITIALIZED;
817 sfc_log_init(sa, "failed %d", rc);
822 sfc_ev_qfini(struct sfc_evq *evq)
824 struct sfc_adapter *sa = evq->sa;
826 SFC_ASSERT(evq->init_state == SFC_EVQ_INITIALIZED);
828 sfc_dma_free(sa, &evq->mem);
832 SFC_ASSERT(sa->evq_count > 0);
837 sfc_kvarg_perf_profile_handler(__rte_unused const char *key,
838 const char *value_str, void *opaque)
840 uint64_t *value = opaque;
842 if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_THROUGHPUT) == 0)
843 *value = EFX_EVQ_FLAGS_TYPE_THROUGHPUT;
844 else if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_LOW_LATENCY) == 0)
845 *value = EFX_EVQ_FLAGS_TYPE_LOW_LATENCY;
846 else if (strcasecmp(value_str, SFC_KVARG_PERF_PROFILE_AUTO) == 0)
847 *value = EFX_EVQ_FLAGS_TYPE_AUTO;
855 sfc_ev_attach(struct sfc_adapter *sa)
859 sfc_log_init(sa, "entry");
861 sa->evq_flags = EFX_EVQ_FLAGS_TYPE_THROUGHPUT;
862 rc = sfc_kvargs_process(sa, SFC_KVARG_PERF_PROFILE,
863 sfc_kvarg_perf_profile_handler,
866 sfc_err(sa, "invalid %s parameter value",
867 SFC_KVARG_PERF_PROFILE);
868 goto fail_kvarg_perf_profile;
871 sa->mgmt_evq_index = 0;
872 rte_spinlock_init(&sa->mgmt_evq_lock);
874 rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_MGMT, 0, SFC_MGMT_EVQ_ENTRIES,
875 sa->socket_id, &sa->mgmt_evq);
877 goto fail_mgmt_evq_init;
880 * Rx/Tx event queues are created/destroyed when corresponding
881 * Rx/Tx queue is created/destroyed.
888 fail_kvarg_perf_profile:
889 sfc_log_init(sa, "failed %d", rc);
894 sfc_ev_detach(struct sfc_adapter *sa)
896 sfc_log_init(sa, "entry");
898 sfc_ev_qfini(sa->mgmt_evq);
900 if (sa->evq_count != 0)
901 sfc_err(sa, "%u EvQs are not destroyed before detach",