net/sfc: support initialising different Rx queue types
[dpdk.git] / drivers / net / sfc / sfc_ev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2021 Xilinx, Inc.
4  * Copyright(c) 2016-2019 Solarflare Communications Inc.
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 <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         unsigned int                    read_ptr_primed;
50         boolean_t                       exception;
51         efsys_mem_t                     mem;
52         struct sfc_dp_rxq               *dp_rxq;
53         struct sfc_dp_txq               *dp_txq;
54
55         /* Not used on datapath */
56         struct sfc_adapter              *sa;
57         unsigned int                    evq_index;
58         enum sfc_evq_state              init_state;
59         enum sfc_evq_type               type;
60         unsigned int                    entries;
61 };
62
63 static inline sfc_sw_index_t
64 sfc_mgmt_evq_sw_index(__rte_unused const struct sfc_adapter_shared *sas)
65 {
66         return 0;
67 }
68
69 /*
70  * Functions below define event queue to transmit/receive queue and vice
71  * versa mapping.
72  * Own event queue is allocated for management, each Rx and each Tx queue.
73  * Zero event queue is used for management events.
74  * Rx event queues from 1 to RxQ number follow management event queue.
75  * Tx event queues follow Rx event queues.
76  */
77
78 static inline sfc_ethdev_qid_t
79 sfc_ethdev_rx_qid_by_rxq_sw_index(__rte_unused struct sfc_adapter_shared *sas,
80                                   sfc_sw_index_t rxq_sw_index)
81 {
82         /* Only ethdev queues are present for now */
83         return rxq_sw_index;
84 }
85
86 static inline sfc_sw_index_t
87 sfc_rxq_sw_index_by_ethdev_rx_qid(__rte_unused struct sfc_adapter_shared *sas,
88                                   sfc_ethdev_qid_t ethdev_qid)
89 {
90         /* Only ethdev queues are present for now */
91         return ethdev_qid;
92 }
93
94 static inline sfc_sw_index_t
95 sfc_evq_sw_index_by_rxq_sw_index(__rte_unused struct sfc_adapter *sa,
96                                  sfc_sw_index_t rxq_sw_index)
97 {
98         return 1 + rxq_sw_index;
99 }
100
101 static inline sfc_ethdev_qid_t
102 sfc_ethdev_tx_qid_by_txq_sw_index(__rte_unused struct sfc_adapter_shared *sas,
103                                   sfc_sw_index_t txq_sw_index)
104 {
105         /* Only ethdev queues are present for now */
106         return txq_sw_index;
107 }
108
109 static inline sfc_sw_index_t
110 sfc_txq_sw_index_by_ethdev_tx_qid(__rte_unused struct sfc_adapter_shared *sas,
111                                   sfc_ethdev_qid_t ethdev_qid)
112 {
113         /* Only ethdev queues are present for now */
114         return ethdev_qid;
115 }
116
117 static inline sfc_sw_index_t
118 sfc_evq_sw_index_by_txq_sw_index(struct sfc_adapter *sa,
119                                  sfc_sw_index_t txq_sw_index)
120 {
121         return 1 + sa->eth_dev->data->nb_rx_queues + txq_sw_index;
122 }
123
124 int sfc_ev_attach(struct sfc_adapter *sa);
125 void sfc_ev_detach(struct sfc_adapter *sa);
126 int sfc_ev_start(struct sfc_adapter *sa);
127 void sfc_ev_stop(struct sfc_adapter *sa);
128
129 int sfc_ev_qinit(struct sfc_adapter *sa,
130                  enum sfc_evq_type type, unsigned int type_index,
131                  unsigned int entries, int socket_id, struct sfc_evq **evqp);
132 void sfc_ev_qfini(struct sfc_evq *evq);
133 int sfc_ev_qstart(struct sfc_evq *evq, unsigned int hw_index);
134 void sfc_ev_qstop(struct sfc_evq *evq);
135
136 int sfc_ev_qprime(struct sfc_evq *evq);
137 void sfc_ev_qpoll(struct sfc_evq *evq);
138
139 void sfc_ev_mgmt_qpoll(struct sfc_adapter *sa);
140
141 #ifdef __cplusplus
142 }
143 #endif
144 #endif /* _SFC_EV_H_ */