DPDK  22.11.0-rc4
Macros | Typedefs | Enumerations | Functions
rte_interrupts.h File Reference
#include <stdbool.h>
#include <rte_bitops.h>
#include <rte_common.h>
#include <rte_compat.h>
#include <rte_epoll.h>

Go to the source code of this file.

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)
 
__rte_experimental 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)
 
__rte_experimental struct rte_intr_handle * rte_intr_instance_alloc (uint32_t flags)
 
__rte_experimental void rte_intr_instance_free (struct rte_intr_handle *intr_handle)
 
__rte_experimental int rte_intr_fd_set (struct rte_intr_handle *intr_handle, int fd)
 
__rte_experimental int rte_intr_fd_get (const struct rte_intr_handle *intr_handle)
 
__rte_experimental int rte_intr_type_set (struct rte_intr_handle *intr_handle, enum rte_intr_handle_type type)
 
__rte_experimental 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

◆ RTE_INTR_INSTANCE_F_PRIVATE

#define RTE_INTR_INSTANCE_F_PRIVATE   UINT32_C(0)

Interrupt instance allocation flags

See also
rte_intr_instance_allocInterrupt instance will not be shared between primary and secondary processes.

Definition at line 34 of file rte_interrupts.h.

◆ RTE_INTR_INSTANCE_F_SHARED

#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

◆ rte_intr_callback_fn

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.

◆ rte_intr_unregister_callback_fn

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

◆ 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

◆ rte_intr_callback_register()

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_handlePointer to the interrupt handle.
cbcallback address.
cb_argaddress of parameter for callback.
Returns
  • On success, zero.
  • On failure, a negative value.

◆ rte_intr_callback_unregister()

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_handlepointer to the interrupt handle.
cbcallback address.
cb_argaddress 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.

◆ rte_intr_callback_unregister_pending()

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_handlepointer to the interrupt handle.
cb_fncallback address.
cb_argaddress of parameter for callback, (void *)-1 means to remove all registered which has the same callback address.
ucb_fncallback 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.

◆ rte_intr_callback_unregister_sync()

__rte_experimental int rte_intr_callback_unregister_sync ( const struct rte_intr_handle *  intr_handle,
rte_intr_callback_fn  cb,
void *  cb_arg 
)
Warning
EXPERIMENTAL: this API may change without prior notice

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_handlepointer to the interrupt handle.
cbcallback address.
cb_argaddress 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.

◆ rte_intr_enable()

int rte_intr_enable ( const struct rte_intr_handle *  intr_handle)

It enables the interrupt for the specified handle.

Parameters
intr_handlepointer to the interrupt handle.
Returns
  • On success, zero.
  • On failure, a negative value.

◆ rte_intr_disable()

int rte_intr_disable ( const struct rte_intr_handle *  intr_handle)

It disables the interrupt for the specified handle.

Parameters
intr_handlepointer to the interrupt handle.
Returns
  • On success, zero.
  • On failure, a negative value.

◆ rte_intr_ack()

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_handlepointer to the interrupt handle.
Returns
  • On success, zero.
  • On failure, a negative value.

◆ rte_thread_is_intr()

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

◆ rte_intr_instance_alloc()

__rte_experimental struct rte_intr_handle* rte_intr_instance_alloc ( uint32_t  flags)
Warning
EXPERIMENTAL: this API may change without prior notice

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
flagsSee RTE_INTR_INSTANCE_F_* flags definitions.
Returns
  • On success, address of interrupt handle.
  • On failure, NULL.

◆ rte_intr_instance_free()

__rte_experimental void rte_intr_instance_free ( struct rte_intr_handle *  intr_handle)
Warning
EXPERIMENTAL: this API may change without prior notice

Free the memory allocated for interrupt handle resources.

Parameters
intr_handleInterrupt handle allocated with rte_intr_instance_alloc(). If intr_handle is NULL, no operation is performed.

◆ rte_intr_fd_set()

__rte_experimental int rte_intr_fd_set ( struct rte_intr_handle *  intr_handle,
int  fd 
)
Warning
EXPERIMENTAL: this API may change without prior notice

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

Parameters
intr_handlepointer to the interrupt handle.
fdfile descriptor value provided by user.
Returns
  • On success, zero.
  • On failure, a negative value and rte_errno is set.

◆ rte_intr_fd_get()

__rte_experimental int rte_intr_fd_get ( const struct rte_intr_handle *  intr_handle)
Warning
EXPERIMENTAL: this API may change without prior notice

Returns the fd field of the given interrupt handle instance.

Parameters
intr_handlepointer to the interrupt handle.
Returns
  • On success, fd field.
  • On failure, a negative value.

◆ rte_intr_type_set()

__rte_experimental int rte_intr_type_set ( struct rte_intr_handle *  intr_handle,
enum rte_intr_handle_type  type 
)
Warning
EXPERIMENTAL: this API may change without prior notice

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

Parameters
intr_handlepointer to the interrupt handle.
typeinterrupt type
Returns
  • On success, zero.
  • On failure, a negative value and rte_errno is set.

◆ rte_intr_type_get()

__rte_experimental enum rte_intr_handle_type rte_intr_type_get ( const struct rte_intr_handle *  intr_handle)
Warning
EXPERIMENTAL: this API may change without prior notice

Returns the type field of the given interrupt handle instance.

Parameters
intr_handlepointer to the interrupt handle.
Returns
  • On success, interrupt type
  • On failure, RTE_INTR_HANDLE_UNKNOWN.