]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/lib/librte_bpf/rte_bpf_ethdev.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_bpf / rte_bpf_ethdev.h
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
3 */
4
5#ifndef _RTE_BPF_ETHDEV_H_
6#define _RTE_BPF_ETHDEV_H_
7
8/**
9 * @file rte_bpf_ethdev.h
10 * @b EXPERIMENTAL: this API may change without prior notice
11 *
12 * API to install BPF filter as RX/TX callbacks for eth devices.
13 * Note that right now:
14 * - it is not MT safe, i.e. it is not allowed to do load/unload for the
15 * same port/queue from different threads in parallel.
16 * - though it allows to do load/unload at runtime
17 * (while RX/TX is ongoing on given port/queue).
18 * - allows only one BPF program per port/queue,
19 * i.e. new load will replace previously loaded for that port/queue BPF program.
20 * Filter behaviour - if BPF program returns zero value for a given packet,
21 * then it will be dropped inside callback and no further processing
22 * on RX - it will be dropped inside callback and no further processing
23 * for that packet will happen.
24 * on TX - packet will remain unsent, and it is responsibility of the user
25 * to handle such situation (drop, try to send again, etc.).
26 */
27
28#include <rte_bpf.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34enum {
35 RTE_BPF_ETH_F_NONE = 0,
36 RTE_BPF_ETH_F_JIT = 0x1, /*< use compiled into native ISA code */
37};
38
39/**
40 * Unload previously loaded BPF program (if any) from given RX port/queue
41 * and remove appropriate RX port/queue callback.
42 *
43 * @param port
44 * The identifier of the ethernet port
45 * @param queue
46 * The identifier of the RX queue on the given port
47 */
f67539c2
TL
48__rte_experimental
49void
11fdf7f2
TL
50rte_bpf_eth_rx_unload(uint16_t port, uint16_t queue);
51
52/**
53 * Unload previously loaded BPF program (if any) from given TX port/queue
54 * and remove appropriate TX port/queue callback.
55 *
56 * @param port
57 * The identifier of the ethernet port
58 * @param queue
59 * The identifier of the TX queue on the given port
60 */
f67539c2
TL
61__rte_experimental
62void
11fdf7f2
TL
63rte_bpf_eth_tx_unload(uint16_t port, uint16_t queue);
64
65/**
66 * Load BPF program from the ELF file and install callback to execute it
67 * on given RX port/queue.
68 *
69 * @param port
70 * The identifier of the ethernet port
71 * @param queue
72 * The identifier of the RX queue on the given port
73 * @param fname
74 * Pathname for a ELF file.
75 * @param sname
76 * Name of the executable section within the file to load.
77 * @param prm
9f95a23c 78 * Parameters used to create and initialise the BPF execution context.
11fdf7f2 79 * @param flags
9f95a23c 80 * Flags that define expected behavior of the loaded filter
11fdf7f2
TL
81 * (i.e. jited/non-jited version to use).
82 * @return
83 * Zero on successful completion or negative error code otherwise.
84 */
f67539c2
TL
85__rte_experimental
86int
11fdf7f2
TL
87rte_bpf_eth_rx_elf_load(uint16_t port, uint16_t queue,
88 const struct rte_bpf_prm *prm, const char *fname, const char *sname,
89 uint32_t flags);
90
91/**
92 * Load BPF program from the ELF file and install callback to execute it
93 * on given TX port/queue.
94 *
95 * @param port
96 * The identifier of the ethernet port
97 * @param queue
98 * The identifier of the TX queue on the given port
99 * @param fname
100 * Pathname for a ELF file.
101 * @param sname
102 * Name of the executable section within the file to load.
103 * @param prm
9f95a23c 104 * Parameters used to create and initialise the BPF execution context.
11fdf7f2
TL
105 * @param flags
106 * Flags that define expected expected behavior of the loaded filter
107 * (i.e. jited/non-jited version to use).
108 * @return
109 * Zero on successful completion or negative error code otherwise.
110 */
f67539c2
TL
111__rte_experimental
112int
11fdf7f2
TL
113rte_bpf_eth_tx_elf_load(uint16_t port, uint16_t queue,
114 const struct rte_bpf_prm *prm, const char *fname, const char *sname,
115 uint32_t flags);
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif /* _RTE_BPF_ETHDEV_H_ */