]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/lib/librte_eal/include/rte_eal_interrupts.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / include / rte_eal_interrupts.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
3 */
4
5 #ifndef _RTE_INTERRUPTS_H_
6 #error "don't include this file directly, please include generic <rte_interrupts.h>"
7 #endif
8
9 /**
10 * @file rte_eal_interrupts.h
11 * @internal
12 *
13 * Contains function prototypes exposed by the EAL for interrupt handling by
14 * drivers and other DPDK internal consumers.
15 */
16
17 #ifndef _RTE_EAL_INTERRUPTS_H_
18 #define _RTE_EAL_INTERRUPTS_H_
19
20 #define RTE_MAX_RXTX_INTR_VEC_ID 512
21 #define RTE_INTR_VEC_ZERO_OFFSET 0
22 #define RTE_INTR_VEC_RXTX_OFFSET 1
23
24 /**
25 * The interrupt source type, e.g. UIO, VFIO, ALARM etc.
26 */
27 enum rte_intr_handle_type {
28 RTE_INTR_HANDLE_UNKNOWN = 0, /**< generic unknown handle */
29 RTE_INTR_HANDLE_UIO, /**< uio device handle */
30 RTE_INTR_HANDLE_UIO_INTX, /**< uio generic handle */
31 RTE_INTR_HANDLE_VFIO_LEGACY, /**< vfio device handle (legacy) */
32 RTE_INTR_HANDLE_VFIO_MSI, /**< vfio device handle (MSI) */
33 RTE_INTR_HANDLE_VFIO_MSIX, /**< vfio device handle (MSIX) */
34 RTE_INTR_HANDLE_ALARM, /**< alarm handle */
35 RTE_INTR_HANDLE_EXT, /**< external handler */
36 RTE_INTR_HANDLE_VDEV, /**< virtual device */
37 RTE_INTR_HANDLE_DEV_EVENT, /**< device event handle */
38 RTE_INTR_HANDLE_VFIO_REQ, /**< VFIO request handle */
39 RTE_INTR_HANDLE_MAX /**< count of elements */
40 };
41
42 #define RTE_INTR_EVENT_ADD 1UL
43 #define RTE_INTR_EVENT_DEL 2UL
44
45 typedef void (*rte_intr_event_cb_t)(int fd, void *arg);
46
47 struct rte_epoll_data {
48 uint32_t event; /**< event type */
49 void *data; /**< User data */
50 rte_intr_event_cb_t cb_fun; /**< IN: callback fun */
51 void *cb_arg; /**< IN: callback arg */
52 };
53
54 enum {
55 RTE_EPOLL_INVALID = 0,
56 RTE_EPOLL_VALID,
57 RTE_EPOLL_EXEC,
58 };
59
60 /** interrupt epoll event obj, taken by epoll_event.ptr */
61 struct rte_epoll_event {
62 volatile uint32_t status; /**< OUT: event status */
63 int fd; /**< OUT: event fd */
64 int epfd; /**< OUT: epoll instance the ev associated with */
65 struct rte_epoll_data epdata;
66 };
67
68 /** Handle for interrupts. */
69 struct rte_intr_handle {
70 RTE_STD_C11
71 union {
72 int vfio_dev_fd; /**< VFIO device file descriptor */
73 int uio_cfg_fd; /**< UIO cfg file desc for uio_pci_generic */
74 };
75 int fd; /**< interrupt event file descriptor */
76 enum rte_intr_handle_type type; /**< handle type */
77 uint32_t max_intr; /**< max interrupt requested */
78 uint32_t nb_efd; /**< number of available efd(event fd) */
79 uint8_t efd_counter_size; /**< size of efd counter, used for vdev */
80 int efds[RTE_MAX_RXTX_INTR_VEC_ID]; /**< intr vectors/efds mapping */
81 struct rte_epoll_event elist[RTE_MAX_RXTX_INTR_VEC_ID];
82 /**< intr vector epoll event */
83 int *intr_vec; /**< intr vector number array */
84 };
85
86 #define RTE_EPOLL_PER_THREAD -1 /**< to hint using per thread epfd */
87
88 /**
89 * It waits for events on the epoll instance.
90 *
91 * @param epfd
92 * Epoll instance fd on which the caller wait for events.
93 * @param events
94 * Memory area contains the events that will be available for the caller.
95 * @param maxevents
96 * Up to maxevents are returned, must greater than zero.
97 * @param timeout
98 * Specifying a timeout of -1 causes a block indefinitely.
99 * Specifying a timeout equal to zero cause to return immediately.
100 * @return
101 * - On success, returns the number of available event.
102 * - On failure, a negative value.
103 */
104 int
105 rte_epoll_wait(int epfd, struct rte_epoll_event *events,
106 int maxevents, int timeout);
107
108 /**
109 * It performs control operations on epoll instance referred by the epfd.
110 * It requests that the operation op be performed for the target fd.
111 *
112 * @param epfd
113 * Epoll instance fd on which the caller perform control operations.
114 * @param op
115 * The operation be performed for the target fd.
116 * @param fd
117 * The target fd on which the control ops perform.
118 * @param event
119 * Describes the object linked to the fd.
120 * Note: The caller must take care the object deletion after CTL_DEL.
121 * @return
122 * - On success, zero.
123 * - On failure, a negative value.
124 */
125 int
126 rte_epoll_ctl(int epfd, int op, int fd,
127 struct rte_epoll_event *event);
128
129 /**
130 * The function returns the per thread epoll instance.
131 *
132 * @return
133 * epfd the epoll instance referred to.
134 */
135 int
136 rte_intr_tls_epfd(void);
137
138 /**
139 * @param intr_handle
140 * Pointer to the interrupt handle.
141 * @param epfd
142 * Epoll instance fd which the intr vector associated to.
143 * @param op
144 * The operation be performed for the vector.
145 * Operation type of {ADD, DEL}.
146 * @param vec
147 * RX intr vector number added to the epoll instance wait list.
148 * @param data
149 * User raw data.
150 * @return
151 * - On success, zero.
152 * - On failure, a negative value.
153 */
154 int
155 rte_intr_rx_ctl(struct rte_intr_handle *intr_handle,
156 int epfd, int op, unsigned int vec, void *data);
157
158 /**
159 * It deletes registered eventfds.
160 *
161 * @param intr_handle
162 * Pointer to the interrupt handle.
163 */
164 void
165 rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle);
166
167 /**
168 * It enables the packet I/O interrupt event if it's necessary.
169 * It creates event fd for each interrupt vector when MSIX is used,
170 * otherwise it multiplexes a single event fd.
171 *
172 * @param intr_handle
173 * Pointer to the interrupt handle.
174 * @param nb_efd
175 * Number of interrupt vector trying to enable.
176 * The value 0 is not allowed.
177 * @return
178 * - On success, zero.
179 * - On failure, a negative value.
180 */
181 int
182 rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd);
183
184 /**
185 * It disables the packet I/O interrupt event.
186 * It deletes registered eventfds and closes the open fds.
187 *
188 * @param intr_handle
189 * Pointer to the interrupt handle.
190 */
191 void
192 rte_intr_efd_disable(struct rte_intr_handle *intr_handle);
193
194 /**
195 * The packet I/O interrupt on datapath is enabled or not.
196 *
197 * @param intr_handle
198 * Pointer to the interrupt handle.
199 */
200 int
201 rte_intr_dp_is_en(struct rte_intr_handle *intr_handle);
202
203 /**
204 * The interrupt handle instance allows other causes or not.
205 * Other causes stand for any none packet I/O interrupts.
206 *
207 * @param intr_handle
208 * Pointer to the interrupt handle.
209 */
210 int
211 rte_intr_allow_others(struct rte_intr_handle *intr_handle);
212
213 /**
214 * The multiple interrupt vector capability of interrupt handle instance.
215 * It returns zero if no multiple interrupt vector support.
216 *
217 * @param intr_handle
218 * Pointer to the interrupt handle.
219 */
220 int
221 rte_intr_cap_multiple(struct rte_intr_handle *intr_handle);
222
223 /**
224 * @warning
225 * @b EXPERIMENTAL: this API may change without prior notice
226 *
227 * @internal
228 * Check if currently executing in interrupt context
229 *
230 * @return
231 * - non zero in case of interrupt context
232 * - zero in case of process context
233 */
234 __rte_experimental
235 int
236 rte_thread_is_intr(void);
237
238 #endif /* _RTE_EAL_INTERRUPTS_H_ */