bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Eelco Chaudron <echaudro@redhat.com>, bpf@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, ast@kernel.org,
	daniel@iogearbox.net, kafai@fb.com, songliubraving@fb.com,
	yhs@fb.com, andriin@fb.com, toke@redhat.com
Subject: RE: [PATCH bpf-next] bpf: add bpf_xdp_output() helper
Date: Fri, 06 Mar 2020 18:57:00 -0800	[thread overview]
Message-ID: <5e630d7c42319_5f672ade5903a5b8c5@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <158348514556.2239.11050972434793741444.stgit@xdp-tutorial>

Eelco Chaudron wrote:
> 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>
> ---
>  include/uapi/linux/bpf.h                           |   27 ++++++++++
>  kernel/bpf/verifier.c                              |    4 +-
>  kernel/trace/bpf_trace.c                           |    3 +
>  net/core/filter.c                                  |   16 ++++++
>  tools/include/uapi/linux/bpf.h                     |   27 ++++++++++
>  .../testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c |   53 ++++++++++++++++++++
>  .../testing/selftests/bpf/progs/test_xdp_bpf2bpf.c |   24 +++++++++
>  7 files changed, 150 insertions(+), 4 deletions(-)
> 
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 40b2d9476268..41a90e2d5821 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -2914,6 +2914,30 @@ union bpf_attr {
>   *		of sizeof(struct perf_branch_entry).
>   *
>   *		**-ENOENT** if architecture does not support branch records.
> + *
> + * int bpf_xdp_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size)
> + *	Description

feels a bit odd to have flags in the middle of a signature but it follows
bpf_perf_event_output() so I guess its better to have the two use the
same signature vs break it here.

> + *		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.
>   */

Otherwise,

Acked-by: John Fastabend <john.fastabend@gmail.com>

  reply	other threads:[~2020-03-07  2:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06  8:59 [PATCH bpf-next] bpf: add bpf_xdp_output() helper Eelco Chaudron
2020-03-07  2:57 ` John Fastabend [this message]
2020-03-09 10:06 ` Toke Høiland-Jørgensen
2020-03-13  1:06 ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e630d7c42319_5f672ade5903a5b8c5@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=echaudro@redhat.com \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).