1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright (c) 2016-2018 Solarflare Communications Inc. 4 * All rights reserved. 5 * 6 * This software was jointly developed between OKTET Labs (under contract 7 * for Solarflare) and Solarflare Communications, Inc. 8 */ 9 10 #ifndef _SFC_EV_H_ 11 #define _SFC_EV_H_ 12 13 #include <rte_ethdev_driver.h> 14 15 #include "efx.h" 16 17 #include "sfc.h" 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 struct sfc_adapter; 24 struct sfc_dp_rxq; 25 struct sfc_dp_txq; 26 27 enum sfc_evq_state { 28 SFC_EVQ_UNINITIALIZED = 0, 29 SFC_EVQ_INITIALIZED, 30 SFC_EVQ_STARTING, 31 SFC_EVQ_STARTED, 32 33 SFC_EVQ_NSTATES 34 }; 35 36 enum sfc_evq_type { 37 SFC_EVQ_TYPE_MGMT = 0, 38 SFC_EVQ_TYPE_RX, 39 SFC_EVQ_TYPE_TX, 40 41 SFC_EVQ_NTYPES 42 }; 43 44 struct sfc_evq { 45 /* Used on datapath */ 46 efx_evq_t *common; 47 const efx_ev_callbacks_t *callbacks; 48 unsigned int read_ptr; 49 boolean_t exception; 50 efsys_mem_t mem; 51 struct sfc_dp_rxq *dp_rxq; 52 struct sfc_dp_txq *dp_txq; 53 54 /* Not used on datapath */ 55 struct sfc_adapter *sa; 56 unsigned int evq_index; 57 enum sfc_evq_state init_state; 58 enum sfc_evq_type type; 59 unsigned int entries; 60 }; 61 62 /* 63 * Functions below define event queue to transmit/receive queue and vice 64 * versa mapping. 65 * Own event queue is allocated for management, each Rx and each Tx queue. 66 * Zero event queue is used for management events. 67 * Rx event queues from 1 to RxQ number follow management event queue. 68 * Tx event queues follow Rx event queues. 69 */ 70 71 static inline unsigned int 72 sfc_evq_index_by_rxq_sw_index(__rte_unused struct sfc_adapter *sa, 73 unsigned int rxq_sw_index) 74 { 75 return 1 + rxq_sw_index; 76 } 77 78 static inline unsigned int 79 sfc_evq_index_by_txq_sw_index(struct sfc_adapter *sa, unsigned int txq_sw_index) 80 { 81 return 1 + sa->eth_dev->data->nb_rx_queues + txq_sw_index; 82 } 83 84 int sfc_ev_attach(struct sfc_adapter *sa); 85 void sfc_ev_detach(struct sfc_adapter *sa); 86 int sfc_ev_start(struct sfc_adapter *sa); 87 void sfc_ev_stop(struct sfc_adapter *sa); 88 89 int sfc_ev_qinit(struct sfc_adapter *sa, 90 enum sfc_evq_type type, unsigned int type_index, 91 unsigned int entries, int socket_id, struct sfc_evq **evqp); 92 void sfc_ev_qfini(struct sfc_evq *evq); 93 int sfc_ev_qstart(struct sfc_evq *evq, unsigned int hw_index); 94 void sfc_ev_qstop(struct sfc_evq *evq); 95 96 int sfc_ev_qprime(struct sfc_evq *evq); 97 void sfc_ev_qpoll(struct sfc_evq *evq); 98 99 void sfc_ev_mgmt_qpoll(struct sfc_adapter *sa); 100 101 #ifdef __cplusplus 102 } 103 #endif 104 #endif /* _SFC_EV_H_ */ 105