public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together
@ 2023-09-15  8:39 Larysa Zaremba
  2023-09-15 16:21 ` Stanislav Fomichev
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Larysa Zaremba @ 2023-09-15  8:39 UTC (permalink / raw)
  To: bpf
  Cc: Larysa Zaremba, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	linux-kernel, Maciej Fijalkowski

There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints
cannot coexist in a single program.

Allow those features to be used together by modifying the flags condition
for dev-bound-only programs, segments are still prohibited for fully
offloaded programs, hence additional check.

Suggested-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=OKMdsxEkyML36VsAuZpcrsXcyqjdKXSJCBq=Q@mail.gmail.com/
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
 kernel/bpf/offload.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index ee35f33a96d1..9d8e508c9b86 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -232,7 +232,14 @@ int bpf_prog_dev_bound_init(struct bpf_prog *prog, union bpf_attr *attr)
 	    attr->prog_type != BPF_PROG_TYPE_XDP)
 		return -EINVAL;
 
-	if (attr->prog_flags & ~BPF_F_XDP_DEV_BOUND_ONLY)
+	if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY | BPF_F_XDP_HAS_FRAGS))
+		return -EINVAL;
+
+	/* Frags are allowed only if program is dev-bound-only, but not
+	 * if it is requesting bpf offload.
+	 */
+	if (attr->prog_flags & BPF_F_XDP_HAS_FRAGS &&
+	    !(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY))
 		return -EINVAL;
 
 	if (attr->prog_type == BPF_PROG_TYPE_SCHED_CLS &&
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together
  2023-09-15  8:39 [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together Larysa Zaremba
@ 2023-09-15 16:21 ` Stanislav Fomichev
  2023-09-15 19:20 ` patchwork-bot+netdevbpf
  2023-09-15 19:26 ` Martin KaFai Lau
  2 siblings, 0 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2023-09-15 16:21 UTC (permalink / raw)
  To: Larysa Zaremba
  Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Hao Luo, Jiri Olsa, linux-kernel, Maciej Fijalkowski

On Fri, Sep 15, 2023 at 1:45 AM Larysa Zaremba <larysa.zaremba@intel.com> wrote:
>
> There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints
> cannot coexist in a single program.
>
> Allow those features to be used together by modifying the flags condition
> for dev-bound-only programs, segments are still prohibited for fully
> offloaded programs, hence additional check.
>
> Suggested-by: Stanislav Fomichev <sdf@google.com>
> Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=OKMdsxEkyML36VsAuZpcrsXcyqjdKXSJCBq=Q@mail.gmail.com/
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>

Acked-by: Stanislav Fomichev <sdf@google.com>

Thank you!

> ---
>  kernel/bpf/offload.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
> index ee35f33a96d1..9d8e508c9b86 100644
> --- a/kernel/bpf/offload.c
> +++ b/kernel/bpf/offload.c
> @@ -232,7 +232,14 @@ int bpf_prog_dev_bound_init(struct bpf_prog *prog, union bpf_attr *attr)
>             attr->prog_type != BPF_PROG_TYPE_XDP)
>                 return -EINVAL;
>
> -       if (attr->prog_flags & ~BPF_F_XDP_DEV_BOUND_ONLY)
> +       if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY | BPF_F_XDP_HAS_FRAGS))
> +               return -EINVAL;
> +
> +       /* Frags are allowed only if program is dev-bound-only, but not
> +        * if it is requesting bpf offload.
> +        */
> +       if (attr->prog_flags & BPF_F_XDP_HAS_FRAGS &&
> +           !(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY))
>                 return -EINVAL;
>
>         if (attr->prog_type == BPF_PROG_TYPE_SCHED_CLS &&
> --
> 2.41.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together
  2023-09-15  8:39 [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together Larysa Zaremba
  2023-09-15 16:21 ` Stanislav Fomichev
@ 2023-09-15 19:20 ` patchwork-bot+netdevbpf
  2023-09-15 19:26 ` Martin KaFai Lau
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-09-15 19:20 UTC (permalink / raw)
  To: Larysa Zaremba
  Cc: bpf, ast, daniel, andrii, martin.lau, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-kernel,
	maciej.fijalkowski

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Fri, 15 Sep 2023 10:39:10 +0200 you wrote:
> There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints
> cannot coexist in a single program.
> 
> Allow those features to be used together by modifying the flags condition
> for dev-bound-only programs, segments are still prohibited for fully
> offloaded programs, hence additional check.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v2] bpf: Allow to use kfunc XDP hints and frags together
    https://git.kernel.org/bpf/bpf-next/c/9b2b86332a9b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together
  2023-09-15  8:39 [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together Larysa Zaremba
  2023-09-15 16:21 ` Stanislav Fomichev
  2023-09-15 19:20 ` patchwork-bot+netdevbpf
@ 2023-09-15 19:26 ` Martin KaFai Lau
  2 siblings, 0 replies; 4+ messages in thread
From: Martin KaFai Lau @ 2023-09-15 19:26 UTC (permalink / raw)
  To: Larysa Zaremba
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, linux-kernel, Maciej Fijalkowski, bpf

On 9/15/23 1:39 AM, Larysa Zaremba wrote:
> There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints
> cannot coexist in a single program.
> 
> Allow those features to be used together by modifying the flags condition
> for dev-bound-only programs, segments are still prohibited for fully
> offloaded programs, hence additional check.

Applied. Please do follow up with a test. Thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-15 19:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-15  8:39 [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together Larysa Zaremba
2023-09-15 16:21 ` Stanislav Fomichev
2023-09-15 19:20 ` patchwork-bot+netdevbpf
2023-09-15 19:26 ` Martin KaFai Lau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox