---
name: "rte_intr_instance_free"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_interrupts.h"
---

# rte\_intr\_instance\_free(3)

Part of [rte\_interrupts.h(3)](/rte_interrupts.h/3.md).

## NAME

rte\_interrupts.h

## SYNOPSIS

`#include <stdbool.h>`\
 `#include <rte_bitops.h>`\
 `#include <rte_common.h>`\
 `#include <rte_compat.h>`\
 `#include <rte_epoll.h>`\

### Macros

\#define **RTE\_INTR\_INSTANCE\_F\_PRIVATE**   UINT32\_C(0)\
 \#define **RTE\_INTR\_INSTANCE\_F\_SHARED**   **RTE\_BIT32**(0)\

### Typedefs

**typedef** void(\* **rte\_intr\_callback\_fn**) (void \*cb\_arg)\
 **typedef** void(\* **rte\_intr\_unregister\_callback\_fn**) (struct rte\_intr\_handle \*intr\_handle, void \*cb\_arg)\

### Enumerations

enum **rte\_intr\_handle\_type** { **RTE\_INTR\_HANDLE\_UNKNOWN** = 0, **RTE\_INTR\_HANDLE\_UIO**, **RTE\_INTR\_HANDLE\_UIO\_INTX**, **RTE\_INTR\_HANDLE\_VFIO\_LEGACY**, **RTE\_INTR\_HANDLE\_VFIO\_MSI**, **RTE\_INTR\_HANDLE\_VFIO\_MSIX**, **RTE\_INTR\_HANDLE\_ALARM**, **RTE\_INTR\_HANDLE\_EXT**, **RTE\_INTR\_HANDLE\_VDEV**, **RTE\_INTR\_HANDLE\_DEV\_EVENT**, **RTE\_INTR\_HANDLE\_VFIO\_REQ**, **RTE\_INTR\_HANDLE\_MAX** }\

### Functions

int **rte\_intr\_callback\_register** (const struct rte\_intr\_handle \*intr\_handle, **rte\_intr\_callback\_fn** cb, void \*cb\_arg)\
 int **rte\_intr\_callback\_unregister** (const struct rte\_intr\_handle \*intr\_handle, **rte\_intr\_callback\_fn** cb, void \*cb\_arg)\
 int **rte\_intr\_callback\_unregister\_pending** (const struct rte\_intr\_handle \*intr\_handle, **rte\_intr\_callback\_fn** cb\_fn, void \*cb\_arg, **rte\_intr\_unregister\_callback\_fn** ucb\_fn)\
 int **rte\_intr\_callback\_unregister\_sync** (const struct rte\_intr\_handle \*intr\_handle, **rte\_intr\_callback\_fn** cb, void \*cb\_arg)\
 int **rte\_intr\_enable** (const struct rte\_intr\_handle \*intr\_handle)\
 int **rte\_intr\_disable** (const struct rte\_intr\_handle \*intr\_handle)\
 int **rte\_intr\_ack** (const struct rte\_intr\_handle \*intr\_handle)\
 int **rte\_thread\_is\_intr** (void)\
 struct rte\_intr\_handle \* **rte\_intr\_instance\_alloc** (uint32\_t flags)\
 void **rte\_intr\_instance\_free** (struct rte\_intr\_handle \*intr\_handle)\
 int **rte\_intr\_fd\_set** (struct rte\_intr\_handle \*intr\_handle, int fd)\
 int **rte\_intr\_fd\_get** (const struct rte\_intr\_handle \*intr\_handle)\
 int **rte\_intr\_type\_set** (struct rte\_intr\_handle \*intr\_handle, enum **rte\_intr\_handle\_type** type)\
 enum **rte\_intr\_handle\_type** **rte\_intr\_type\_get** (const struct rte\_intr\_handle \*intr\_handle)\

## Detailed Description

The RTE interrupt interface provides functions to register/unregister callbacks for a specific interrupt.

Definition in file **rte\_interrupts.h**.

## Macro Definition Documentation

### #define RTE\_INTR\_INSTANCE\_F\_PRIVATE UINT32\_C(0)

Interrupt instance allocation flags

**See also**

**rte\_intr\_instance\_alloc** Interrupt instance will not be shared between primary and secondary processes.

Definition at line **34** of file **rte\_interrupts.h**.

### #define RTE\_INTR\_INSTANCE\_F\_SHARED RTE\_BIT32(0)

Interrupt instance will be shared between primary and secondary processes.

Definition at line **36** of file **rte\_interrupts.h**.

## Typedef Documentation

### typedef void(\* rte\_intr\_callback\_fn) (void \*cb\_arg)

Function to be registered for the specific interrupt

Definition at line **61** of file **rte\_interrupts.h**.

### typedef void(\* rte\_intr\_unregister\_callback\_fn) (struct rte\_intr\_handle \*intr\_handle, void \*cb\_arg)

Function to call after a callback is unregistered. Can be used to close fd and free cb\_arg.

Definition at line **67** of file **rte\_interrupts.h**.

## Enumeration Type Documentation

### enum rte\_intr\_handle\_type

The interrupt source type, e.g. UIO, VFIO, ALARM etc.

**Enumerator**

- *RTE\_INTR\_HANDLE\_UNKNOWN*

  *generic unknown handle*

- *RTE\_INTR\_HANDLE\_UIO*

  *uio device handle*

- *RTE\_INTR\_HANDLE\_UIO\_INTX*

  *uio generic handle*

- *RTE\_INTR\_HANDLE\_VFIO\_LEGACY*

  *vfio device handle (legacy)*

- *RTE\_INTR\_HANDLE\_VFIO\_MSI*

  *vfio device handle (MSI)*

- *RTE\_INTR\_HANDLE\_VFIO\_MSIX*

  *vfio device handle (MSIX)*

- *RTE\_INTR\_HANDLE\_ALARM*

  *alarm handle*

- *RTE\_INTR\_HANDLE\_EXT*

  *external handler*

- *RTE\_INTR\_HANDLE\_VDEV*

  *virtual device*

- *RTE\_INTR\_HANDLE\_DEV\_EVENT*

  *device event handle*

- *RTE\_INTR\_HANDLE\_VFIO\_REQ*

  *VFIO request handle*

- *RTE\_INTR\_HANDLE\_MAX*

  *count of elements*

*Definition at line* **45** *of file* **rte\_interrupts.h***.*

## Function Documentation

### int rte\_intr\_callback\_register (const struct rte\_intr\_handle \* intr\_handle, rte\_intr\_callback\_fn cb, void \* cb\_arg)

*It registers the callback for the specific interrupt. Multiple callbacks can be registered at the same time.*

**Parameters**

*intr\_handle Pointer to the interrupt handle.* \
 *cb callback address.* \
 *cb\_arg address of parameter for callback.*

**Returns**

- •

  *On success, zero.*

- •

  *On failure, a negative value.*

### int rte\_intr\_callback\_unregister (const struct rte\_intr\_handle \* intr\_handle, rte\_intr\_callback\_fn cb, void \* cb\_arg)

*It unregisters the callback according to the specified interrupt handle.*

**Parameters**

*intr\_handle pointer to the interrupt handle.* \
 *cb callback address.* \
 *cb\_arg address of parameter for callback, (void \*)-1 means to remove all registered which has the same callback address.*

**Returns**

- •

  *On success, return the number of callback entities removed.*

- •

  *On failure, a negative value.*

### int rte\_intr\_callback\_unregister\_pending (const struct rte\_intr\_handle \* intr\_handle, rte\_intr\_callback\_fn cb\_fn, void \* cb\_arg, rte\_intr\_unregister\_callback\_fn ucb\_fn)

*Unregister the callback according to the specified interrupt handle, after it's no longer active. Fail if source is not active.*

**Parameters**

*intr\_handle pointer to the interrupt handle.* \
 *cb\_fn callback address.* \
 *cb\_arg address of parameter for callback, (void \*)-1 means to remove all registered which has the same callback address.* \
 *ucb\_fn callback to call before cb is unregistered (optional). can be used to close fd and free cb\_arg.*

**Returns**

- •

  *On success, return the number of callback entities marked for remove.*

- •

  *On failure, a negative value.*

### int rte\_intr\_callback\_unregister\_sync (const struct rte\_intr\_handle \* intr\_handle, rte\_intr\_callback\_fn cb, void \* cb\_arg)

*Loop until* **rte\_intr\_callback\_unregister()** *succeeds. After a call to this function, the callback provided by the specified interrupt handle is unregistered.*

**Parameters**

*intr\_handle pointer to the interrupt handle.* \
 *cb callback address.* \
 *cb\_arg address of parameter for callback, (void \*)-1 means to remove all registered which has the same callback address.*

**Returns**

- •

  *On success, return the number of callback entities removed.*

- •

  *On failure, a negative value.*

### int rte\_intr\_enable (const struct rte\_intr\_handle \* intr\_handle)

*It enables the interrupt for the specified handle.*

**Parameters**

*intr\_handle pointer to the interrupt handle.*

**Returns**

- •

  *On success, zero.*

- •

  *On failure, a negative value.*

### int rte\_intr\_disable (const struct rte\_intr\_handle \* intr\_handle)

*It disables the interrupt for the specified handle.*

**Parameters**

*intr\_handle pointer to the interrupt handle.*

**Returns**

- •

  *On success, zero.*

- •

  *On failure, a negative value.*

### int rte\_intr\_ack (const struct rte\_intr\_handle \* intr\_handle)

*It acknowledges an interrupt raised for the specified handle.*

*This function should be called at the end of each interrupt handler either from application or driver, so that currently raised interrupt is acked and further new interrupts are raised.*

**Parameters**

*intr\_handle pointer to the interrupt handle.*

**Returns**

- •

  *On success, zero.*

- •

  *On failure, a negative value.*

### int rte\_thread\_is\_intr (void)

*Check if currently executing in interrupt context*

**Returns**

- •

  *non zero in case of interrupt context*

- •

  *zero in case of process context*

### struct rte\_intr\_handle \* rte\_intr\_instance\_alloc (uint32\_t flags)

*It allocates memory for interrupt instance. API takes flag as an argument which define from where memory should be allocated i.e. using DPDK memory management library APIs or normal heap allocation. Default memory allocation for event fds and event list array is done which can be realloced later based on size of MSIX interrupts supported by a PCI device.*

*This function should be called from application or driver, before calling any of the interrupt APIs.*

**Parameters**

*flags See RTE\_INTR\_INSTANCE\_F\_\* flags definitions.*

**Returns**

- •

  *On success, address of interrupt handle.*

- •

  *On failure, NULL.*

### void rte\_intr\_instance\_free (struct rte\_intr\_handle \* intr\_handle)

*Free the memory allocated for interrupt handle resources.*

**Parameters**

*intr\_handle Interrupt handle allocated with* **rte\_intr\_instance\_alloc()***. If intr\_handle is NULL, no operation is performed.*

### int rte\_intr\_fd\_set (struct rte\_intr\_handle \* intr\_handle, int fd)

*Set the fd field of interrupt handle with user provided file descriptor.*

**Parameters**

*intr\_handle pointer to the interrupt handle.* \
 *fd file descriptor value provided by user.*

**Returns**

- •

  *On success, zero.*

- •

  *On failure, a negative value and rte\_errno is set.*

### int rte\_intr\_fd\_get (const struct rte\_intr\_handle \* intr\_handle)

*Returns the fd field of the given interrupt handle instance.*

**Parameters**

*intr\_handle pointer to the interrupt handle.*

**Returns**

- •

  *On success, fd field.*

- •

  *On failure, a negative value.*

### int rte\_intr\_type\_set (struct rte\_intr\_handle \* intr\_handle, enum rte\_intr\_handle\_type type)

*Set the type field of interrupt handle with user provided interrupt type.*

**Parameters**

*intr\_handle pointer to the interrupt handle.* \
 *type interrupt type*

**Returns**

- •

  *On success, zero.*

- •

  *On failure, a negative value and rte\_errno is set.*

### enum rte\_intr\_handle\_type rte\_intr\_type\_get (const struct rte\_intr\_handle \* intr\_handle)

*Returns the type field of the given interrupt handle instance.*

**Parameters**

*intr\_handle pointer to the interrupt handle.*

**Returns**

- •

  *On success, interrupt type*

- •

  *On failure, RTE\_INTR\_HANDLE\_UNKNOWN.*

## Author

*Generated automatically by Doxygen for DPDK from the source code.*
