eal: add pending interrupt callback unregister
[dpdk.git] / lib / librte_eal / common / 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 cal 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 int __rte_experimental
92 rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,
93                                 rte_intr_callback_fn cb_fn, void *cb_arg,
94                                 rte_intr_unregister_callback_fn ucb_fn);
95
96 /**
97  * It enables the interrupt for the specified handle.
98  *
99  * @param intr_handle
100  *  pointer to the interrupt handle.
101  *
102  * @return
103  *  - On success, zero.
104  *  - On failure, a negative value.
105  */
106 int rte_intr_enable(const struct rte_intr_handle *intr_handle);
107
108 /**
109  * It disables the interrupt for the specified handle.
110  *
111  * @param intr_handle
112  *  pointer to the interrupt handle.
113  *
114  * @return
115  *  - On success, zero.
116  *  - On failure, a negative value.
117  */
118 int rte_intr_disable(const struct rte_intr_handle *intr_handle);
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124 #endif