1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _RTE_BPF_ETHDEV_H_
6 #define _RTE_BPF_ETHDEV_H_
9 * @file rte_bpf_ethdev.h
11 * API to install BPF filter as RX/TX callbacks for eth devices.
12 * Note that right now:
13 * - it is not MT safe, i.e. it is not allowed to do load/unload for the
14 * same port/queue from different threads in parallel.
15 * - though it allows to do load/unload at runtime
16 * (while RX/TX is ongoing on given port/queue).
17 * - allows only one BPF program per port/queue,
18 * i.e. new load will replace previously loaded for that port/queue BPF program.
19 * Filter behaviour - if BPF program returns zero value for a given packet,
20 * then it will be dropped inside callback and no further processing
21 * on RX - it will be dropped inside callback and no further processing
22 * for that packet will happen.
23 * on TX - packet will remain unsent, and it is responsibility of the user
24 * to handle such situation (drop, try to send again, etc.).
34 RTE_BPF_ETH_F_NONE = 0,
35 RTE_BPF_ETH_F_JIT = 0x1, /*< use compiled into native ISA code */
39 * Unload previously loaded BPF program (if any) from given RX port/queue
40 * and remove appropriate RX port/queue callback.
43 * The identifier of the ethernet port
45 * The identifier of the RX queue on the given port
48 rte_bpf_eth_rx_unload(uint16_t port, uint16_t queue);
51 * Unload previously loaded BPF program (if any) from given TX port/queue
52 * and remove appropriate TX port/queue callback.
55 * The identifier of the ethernet port
57 * The identifier of the TX queue on the given port
60 rte_bpf_eth_tx_unload(uint16_t port, uint16_t queue);
63 * Load BPF program from the ELF file and install callback to execute it
64 * on given RX port/queue.
67 * The identifier of the ethernet port
69 * The identifier of the RX queue on the given port
71 * Pathname for a ELF file.
73 * Name of the executable section within the file to load.
75 * Parameters used to create and initialise the BPF execution context.
77 * Flags that define expected behavior of the loaded filter
78 * (i.e. jited/non-jited version to use).
80 * Zero on successful completion or negative error code otherwise.
83 rte_bpf_eth_rx_elf_load(uint16_t port, uint16_t queue,
84 const struct rte_bpf_prm *prm, const char *fname, const char *sname,
88 * Load BPF program from the ELF file and install callback to execute it
89 * on given TX port/queue.
92 * The identifier of the ethernet port
94 * The identifier of the TX queue on the given port
96 * Pathname for a ELF file.
98 * Name of the executable section within the file to load.
100 * Parameters used to create and initialise the BPF execution context.
102 * Flags that define expected expected behavior of the loaded filter
103 * (i.e. jited/non-jited version to use).
105 * Zero on successful completion or negative error code otherwise.
108 rte_bpf_eth_tx_elf_load(uint16_t port, uint16_t queue,
109 const struct rte_bpf_prm *prm, const char *fname, const char *sname,
116 #endif /* _RTE_BPF_ETHDEV_H_ */