---
name: "RTE_BPF_XTYPE_VAR"
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_bpf.h"
---

# RTE\_BPF\_XTYPE\_VAR(3)

Part of [rte\_bpf.h(3)](/rte_bpf.h/3.md).

## NAME

rte\_bpf.h

## SYNOPSIS

`#include <rte_common.h>`\
 `#include <rte_mbuf.h>`\
 `#include <bpf_def.h>`\

### Data Structures

struct **rte\_bpf\_arg**\
 struct **rte\_bpf\_xsym**\
 struct **rte\_bpf\_prm**\
 struct **rte\_bpf\_jit**\

### Macros

\#define **RTE\_BPF\_ARG\_PTR\_TYPE**(x)   ((x) & **RTE\_BPF\_ARG\_PTR**)\

### Enumerations

enum **rte\_bpf\_arg\_type** { **RTE\_BPF\_ARG\_UNDEF**, **RTE\_BPF\_ARG\_RAW**, **RTE\_BPF\_ARG\_PTR** = 0x10, **RTE\_BPF\_ARG\_PTR\_MBUF**, **RTE\_BPF\_ARG\_RESERVED** }\
 enum **rte\_bpf\_xtype** { **RTE\_BPF\_XTYPE\_FUNC**, **RTE\_BPF\_XTYPE\_VAR** }\

### Functions

void **rte\_bpf\_destroy** (struct rte\_bpf \*bpf)\
 struct rte\_bpf \* **rte\_bpf\_load** (const struct **rte\_bpf\_prm** \*prm)\
 struct rte\_bpf \* **rte\_bpf\_elf\_load** (const struct **rte\_bpf\_prm** \*prm, const char \*fname, const char \*sname)\
 uint64\_t **rte\_bpf\_exec** (const struct rte\_bpf \*bpf, void \*ctx)\
 uint32\_t **rte\_bpf\_exec\_burst** (const struct rte\_bpf \*bpf, void \*ctx\[\], uint64\_t rc\[\], uint32\_t num)\
 int **rte\_bpf\_get\_jit** (const struct rte\_bpf \*bpf, struct **rte\_bpf\_jit** \*jit)\
 void **rte\_bpf\_dump** (FILE \*f, const struct ebpf\_insn \*buf, uint32\_t len)\
 struct **rte\_bpf\_prm** \* **rte\_bpf\_convert** (const struct bpf\_program \*prog)\

## Detailed Description

RTE BPF support.

librte\_bpf provides a framework to load and execute eBPF bytecode inside user-space dpdk based applications. It supports basic set of features from eBPF spec (https://www.kernel.org/doc/Documentation/networking/filter.txt).

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

## Macro Definition Documentation

### #define RTE\_BPF\_ARG\_PTR\_TYPE(x) ((x) & RTE\_BPF\_ARG\_PTR)

determine is argument a pointer

Definition at line **55** of file **rte\_bpf.h**.

## Enumeration Type Documentation

### enum rte\_bpf\_arg\_type

Possible types for function/BPF program arguments.

**Enumerator**

- *RTE\_BPF\_ARG\_UNDEF*

  *undefined*

- *RTE\_BPF\_ARG\_RAW*

  *scalar value*

- *RTE\_BPF\_ARG\_PTR*

  *pointer to data buffer*

- *RTE\_BPF\_ARG\_PTR\_MBUF*

  *pointer to* **rte\_mbuf**

- *RTE\_BPF\_ARG\_RESERVED*

  *reserved for internal use*

*Definition at line* **30** *of file* **rte\_bpf.h***.*

### enum rte\_bpf\_xtype

*Possible types for external symbols.*

**Enumerator**

- *RTE\_BPF\_XTYPE\_FUNC*

  *function*

- *RTE\_BPF\_XTYPE\_VAR*

  *variable*

*Definition at line* **60** *of file* **rte\_bpf.h***.*

## Function Documentation

### void rte\_bpf\_destroy (struct rte\_bpf \* bpf)

*De-allocate all memory used by this eBPF execution context.*

**Parameters**

*bpf BPF handle to destroy.*

### struct rte\_bpf \* rte\_bpf\_load (const struct rte\_bpf\_prm \* prm)

*Create a new eBPF execution context and load given BPF code into it.*

**Parameters**

*prm Parameters used to create and initialise the BPF execution context.*

**Returns**

*BPF handle that is used in future BPF operations, or NULL on error, with error code set in rte\_errno. Possible rte\_errno errors include:*

- •

  *EINVAL - invalid parameter passed to function*

- •

  *ENOMEM - can't reserve enough memory*

### struct rte\_bpf \* rte\_bpf\_elf\_load (const struct rte\_bpf\_prm \* prm, const char \* fname, const char \* sname)

*Create a new eBPF execution context and load BPF code from given ELF file into it. Note that if the function will encounter EBPF\_PSEUDO\_CALL instruction that references external symbol, it will treat is as standard BPF\_CALL to the external helper function.*

**Parameters**

*prm Parameters used to create and initialise the BPF execution context.* \
 *fname Pathname for a ELF file.* \
 *sname Name of the executable section within the file to load.*

**Returns**

*BPF handle that is used in future BPF operations, or NULL on error, with error code set in rte\_errno. Possible rte\_errno errors include:*

- •

  *EINVAL - invalid parameter passed to function*

- •

  *ENOMEM - can't reserve enough memory*

### uint64\_t rte\_bpf\_exec (const struct rte\_bpf \* bpf, void \* ctx)

*Execute given BPF bytecode.*

**Parameters**

*bpf handle for the BPF code to execute.* \
 *ctx pointer to input context.*

**Returns**

*BPF execution return value.*

### uint32\_t rte\_bpf\_exec\_burst (const struct rte\_bpf \* bpf, void \* ctx\[\], uint64\_t rc\[\], uint32\_t num)

*Execute given BPF bytecode over a set of input contexts.*

**Parameters**

*bpf handle for the BPF code to execute.* \
 *ctx array of pointers to the input contexts.* \
 *rc array of return values (one per input).* \
 *num number of elements in ctx\[\] (and rc\[\]).*

**Returns**

*number of successfully processed inputs.*

### int rte\_bpf\_get\_jit (const struct rte\_bpf \* bpf, struct rte\_bpf\_jit \* jit)

*Provide information about natively compiled code for given BPF handle.*

**Parameters**

*bpf handle for the BPF code.* \
 *jit pointer to the* **rte\_bpf\_jit** *structure to be filled with related data.*

**Returns**

- •

  *-EINVAL if the parameters are invalid.*

- •

  *Zero if operation completed successfully.*

### void rte\_bpf\_dump (FILE \* f, const struct ebpf\_insn \* buf, uint32\_t len)

*Dump epf instructions to a file.*

**Parameters**

*f A pointer to a file for output* \
 *buf A pointer to BPF instructions* \
 *len Number of BPF instructions to dump.*

### struct rte\_bpf\_prm \* rte\_bpf\_convert (const struct bpf\_program \* prog)

*Convert a Classic BPF program from libpcap into a DPDK BPF code.*

**Parameters**

*prog Classic BPF program from pcap\_compile().*

**Returns**

*Pointer to BPF program (allocated with rte\_malloc) that is used in future BPF operations, or NULL on error, with error code set in rte\_errno. Possible rte\_errno errors include:*

- •

  *EINVAL - invalid parameter passed to function*

- •

  *ENOMEM - can't reserve enough memory*

- •

  *ENOTSUP - operation not supported*

## Author

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