summaryrefslogtreecommitdiffstats
path: root/tools/include
diff options
context:
space:
mode:
authorEelco Chaudron <echaudro@redhat.com>2020-03-06 09:59:23 +0100
committerAlexei Starovoitov <ast@kernel.org>2020-03-13 01:47:38 +0100
commitd831ee84bfc9173eecf30dbbc2553ae81b996c60 (patch)
tree52c110beaf9330261d28ed885ea246cb66e39ee8 /tools/include
parentMerge branch 'bpf_get_ns_current_pid_tgid' (diff)
downloadlinux-d831ee84bfc9173eecf30dbbc2553ae81b996c60.tar.xz
linux-d831ee84bfc9173eecf30dbbc2553ae81b996c60.zip
bpf: Add bpf_xdp_output() helper
Introduce new helper that reuses existing xdp perf_event output implementation, but can be called from raw_tracepoint programs that receive 'struct xdp_buff *' as a tracepoint argument. Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://lore.kernel.org/bpf/158348514556.2239.11050972434793741444.stgit@xdp-tutorial
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/uapi/linux/bpf.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 15b239da775b..5d01c5c7e598 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -2927,6 +2927,29 @@ union bpf_attr {
*
* **-ENOENT** if pidns does not exists for the current task.
*
+ * int bpf_xdp_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size)
+ * Description
+ * Write raw *data* blob into a special BPF perf event held by
+ * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf
+ * event must have the following attributes: **PERF_SAMPLE_RAW**
+ * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and
+ * **PERF_COUNT_SW_BPF_OUTPUT** as **config**.
+ *
+ * The *flags* are used to indicate the index in *map* for which
+ * the value must be put, masked with **BPF_F_INDEX_MASK**.
+ * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU**
+ * to indicate that the index of the current CPU core should be
+ * used.
+ *
+ * The value to write, of *size*, is passed through eBPF stack and
+ * pointed by *data*.
+ *
+ * *ctx* is a pointer to in-kernel struct xdp_buff.
+ *
+ * This helper is similar to **bpf_perf_eventoutput**\ () but
+ * restricted to raw_tracepoint bpf programs.
+ * Return
+ * 0 on success, or a negative error in case of failure.
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -3049,7 +3072,8 @@ union bpf_attr {
FN(send_signal_thread), \
FN(jiffies64), \
FN(read_branch_records), \
- FN(get_ns_current_pid_tgid),
+ FN(get_ns_current_pid_tgid), \
+ FN(xdp_output),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call