eal: move common header files
[dpdk.git] / lib / librte_eal / include / rte_interrupts.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _RTE_INTERRUPTS_H_
6 #define _RTE_INTERRUPTS_H_
7
8 #include <rte_common.h>
9 #include <rte_compat.h>
10
11 /**
12  * @file
13  *
14  * The RTE interrupt interface provides functions to register/unregister
15  * callbacks for a specific interrupt.
16  */
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /** Interrupt handle */
23 struct rte_intr_handle;
24
25 /** Function to be registered for the specific interrupt */
26 typedef void (*rte_intr_callback_fn)(void *cb_arg);
27
28 /**
29  * Function to call after a callback is unregistered.
30  * Can be used to close fd and free cb_arg.
31  */
32 typedef void (*rte_intr_unregister_callback_fn)(struct rte_intr_handle *intr_handle,
33                                                 void *cb_arg);
34
35 #include "rte_eal_interrupts.h"
36
37 /**
38  * It registers the callback for the specific interrupt. Multiple
39  * callbacks can be registered at the same time.
40  * @param intr_handle
41  *  Pointer to the interrupt handle.
42  * @param cb
43  *  callback address.
44  * @param cb_arg
45  *  address of parameter for callback.
46  *
47  * @return
48  *  - On success, zero.
49  *  - On failure, a negative value.
50  */
51 int rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
52                                 rte_intr_callback_fn cb, void *cb_arg);
53
54 /**
55  * It unregisters the callback according to the specified interrupt handle.
56  *
57  * @param intr_handle
58  *  pointer to the interrupt handle.
59  * @param cb
60  *  callback address.
61  * @param cb_arg
62  *  address of parameter for callback, (void *)-1 means to remove all
63  *  registered which has the same callback address.
64  *
65  * @return
66  *  - On success, return the number of callback entities removed.
67  *  - On failure, a negative value.
68  */
69 int rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
70                                 rte_intr_callback_fn cb, void *cb_arg);
71
72 /**
73  * Unregister the callback according to the specified interrupt handle,
74  * after it's no longer active. Fail if source is not active.
75  *
76  * @param intr_handle
77  *  pointer to the interrupt handle.
78  * @param cb_fn
79  *  callback address.
80  * @param cb_arg
81  *  address of parameter for callback, (void *)-1 means to remove all
82  *  registered which has the same callback address.
83  * @param ucb_fn
84  *  callback to call before cb is unregistered (optional).
85  *  can be used to close fd and free cb_arg.
86  *
87  * @return
88  *  - On success, return the number of callback entities marked for remove.
89  *  - On failure, a negative value.
90  */
91 __rte_experimental
92 int
93 rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,
94                                 rte_intr_callback_fn cb_fn, void *cb_arg,
95                                 rte_intr_unregister_callback_fn ucb_fn);
96
97 /**
98  * It enables the interrupt for the specified handle.
99  *
100  * @param intr_handle
101  *  pointer to the interrupt handle.
102  *
103  * @return
104  *  - On success, zero.
105  *  - On failure, a negative value.
106  */
107 int rte_intr_enable(const struct rte_intr_handle *intr_handle);
108
109 /**
110  * It disables the interrupt for the specified handle.
111  *
112  * @param intr_handle
113  *  pointer to the interrupt handle.
114  *
115  * @return
116  *  - On success, zero.
117  *  - On failure, a negative value.
118  */
119 int rte_intr_disable(const struct rte_intr_handle *intr_handle);
120
121 /**
122  * @warning
123  * @b EXPERIMENTAL: this API may change without prior notice
124  *
125  * It acknowledges an interrupt raised for the specified handle.
126  *
127  * This function should be called at the end of each interrupt handler either
128  * from application or driver, so that currently raised interrupt is acked and
129  * further new interrupts are raised.
130  *
131  * @param intr_handle
132  *  pointer to the interrupt handle.
133  *
134  * @return
135  *  - On success, zero.
136  *  - On failure, a negative value.
137  */
138 __rte_experimental
139 int rte_intr_ack(const struct rte_intr_handle *intr_handle);
140
141 #ifdef __cplusplus
142 }
143 #endif
144
145 #endif