New upstream version 18.02
[deb_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
10 /**
11  * @file
12  *
13  * The RTE interrupt interface provides functions to register/unregister
14  * callbacks for a specific interrupt.
15  */
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /** Interrupt handle */
22 struct rte_intr_handle;
23
24 /** Function to be registered for the specific interrupt */
25 typedef void (*rte_intr_callback_fn)(void *cb_arg);
26
27 #include "rte_eal_interrupts.h"
28
29 /**
30  * It registers the callback for the specific interrupt. Multiple
31  * callbacks cal be registered at the same time.
32  * @param intr_handle
33  *  Pointer to the interrupt handle.
34  * @param cb
35  *  callback address.
36  * @param cb_arg
37  *  address of parameter for callback.
38  *
39  * @return
40  *  - On success, zero.
41  *  - On failure, a negative value.
42  */
43 int rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
44                                 rte_intr_callback_fn cb, void *cb_arg);
45
46 /**
47  * It unregisters the callback according to the specified interrupt handle.
48  *
49  * @param intr_handle
50  *  pointer to the interrupt handle.
51  * @param cb
52  *  callback address.
53  * @param cb_arg
54  *  address of parameter for callback, (void *)-1 means to remove all
55  *  registered which has the same callback address.
56  *
57  * @return
58  *  - On success, return the number of callback entities removed.
59  *  - On failure, a negative value.
60  */
61 int rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
62                                 rte_intr_callback_fn cb, void *cb_arg);
63
64 /**
65  * It enables the interrupt for the specified handle.
66  *
67  * @param intr_handle
68  *  pointer to the interrupt handle.
69  *
70  * @return
71  *  - On success, zero.
72  *  - On failure, a negative value.
73  */
74 int rte_intr_enable(const struct rte_intr_handle *intr_handle);
75
76 /**
77  * It disables the interrupt for the specified handle.
78  *
79  * @param intr_handle
80  *  pointer to the interrupt handle.
81  *
82  * @return
83  *  - On success, zero.
84  *  - On failure, a negative value.
85  */
86 int rte_intr_disable(const struct rte_intr_handle *intr_handle);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif