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);
98 * It enables the interrupt for the specified handle.
101 * pointer to the interrupt handle.
104 * - On success, zero.
105 * - On failure, a negative value.
107 int rte_intr_enable(const struct rte_intr_handle *intr_handle);
110 * It disables the interrupt for the specified handle.
113 * pointer to the interrupt handle.
116 * - On success, zero.
117 * - On failure, a negative value.
119 int rte_intr_disable(const struct rte_intr_handle *intr_handle);