1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef _RTE_INTERRUPTS_H_
6 #define _RTE_INTERRUPTS_H_
8 #include <rte_common.h>
9 #include <rte_compat.h>
14 * The RTE interrupt interface provides functions to register/unregister
15 * callbacks for a specific interrupt.
22 /** Interrupt handle */
23 struct rte_intr_handle;
25 /** Function to be registered for the specific interrupt */
26 typedef void (*rte_intr_callback_fn)(void *cb_arg);
29 * Function to call after a callback is unregistered.
30 * Can be used to close fd and free cb_arg.
32 typedef void (*rte_intr_unregister_callback_fn)(struct rte_intr_handle *intr_handle,
35 #include "rte_eal_interrupts.h"
38 * It registers the callback for the specific interrupt. Multiple
39 * callbacks can be registered at the same time.
41 * Pointer to the interrupt handle.
45 * address of parameter for callback.
49 * - On failure, a negative value.
51 int rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
52 rte_intr_callback_fn cb, void *cb_arg);
55 * It unregisters the callback according to the specified interrupt handle.
58 * pointer to the interrupt handle.
62 * address of parameter for callback, (void *)-1 means to remove all
63 * registered which has the same callback address.
66 * - On success, return the number of callback entities removed.
67 * - On failure, a negative value.
69 int rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
70 rte_intr_callback_fn cb, void *cb_arg);
73 * Unregister the callback according to the specified interrupt handle,
74 * after it's no longer active. Fail if source is not active.
77 * pointer to the interrupt handle.
81 * address of parameter for callback, (void *)-1 means to remove all
82 * registered which has the same callback address.
84 * callback to call before cb is unregistered (optional).
85 * can be used to close fd and free cb_arg.
88 * - On success, return the number of callback entities marked for remove.
89 * - On failure, a negative value.
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);
99 * @b EXPERIMENTAL: this API may change without prior notice
101 * Loop until rte_intr_callback_unregister() succeeds.
102 * After a call to this function,
103 * the callback provided by the specified interrupt handle is unregistered.
106 * pointer to the interrupt handle.
110 * address of parameter for callback, (void *)-1 means to remove all
111 * registered which has the same callback address.
114 * - On success, return the number of callback entities removed.
115 * - On failure, a negative value.
119 rte_intr_callback_unregister_sync(const struct rte_intr_handle *intr_handle,
120 rte_intr_callback_fn cb, void *cb_arg);
123 * It enables the interrupt for the specified handle.
126 * pointer to the interrupt handle.
129 * - On success, zero.
130 * - On failure, a negative value.
132 int rte_intr_enable(const struct rte_intr_handle *intr_handle);
135 * It disables the interrupt for the specified handle.
138 * pointer to the interrupt handle.
141 * - On success, zero.
142 * - On failure, a negative value.
144 int rte_intr_disable(const struct rte_intr_handle *intr_handle);
148 * @b EXPERIMENTAL: this API may change without prior notice
150 * It acknowledges an interrupt raised for the specified handle.
152 * This function should be called at the end of each interrupt handler either
153 * from application or driver, so that currently raised interrupt is acked and
154 * further new interrupts are raised.
157 * pointer to the interrupt handle.
160 * - On success, zero.
161 * - On failure, a negative value.
164 int rte_intr_ack(const struct rte_intr_handle *intr_handle);