diff mbox series

[bpf-next,V2] xdp: bpf_xdp_metadata use NODEV for no device support

Message ID 167663589722.1933643.15760680115820248363.stgit@firesoul (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next,V2] xdp: bpf_xdp_metadata use NODEV for no device support | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4 this patch: 4
netdev/cc_maintainers warning 8 maintainers not CCed: john.fastabend@gmail.com pabeni@redhat.com corbet@lwn.net linux-doc@vger.kernel.org kuba@kernel.org edumazet@google.com hawk@kernel.org davem@davemloft.net
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc

Commit Message

Jesper Dangaard Brouer Feb. 17, 2023, 12:11 p.m. UTC
With our XDP-hints kfunc approach, where individual drivers overload the
default implementation, it can be hard for API users to determine
whether or not the current device driver have this kfunc available.

Change the default implementations to use an errno (ENODEV), that
drivers shouldn't return, to make it possible for BPF runtime to
determine if bpf kfunc for xdp metadata isn't implemented by driver.

This is intended to ease supporting and troubleshooting setups. E.g.
when users on mailing list report -19 (ENODEV) as an error, then we can
immediately tell them their device driver is too old.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 Documentation/networking/xdp-rx-metadata.rst |    3 ++-
 net/core/xdp.c                               |    8 ++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Stanislav Fomichev Feb. 17, 2023, 5:32 p.m. UTC | #1
On 02/17, Jesper Dangaard Brouer wrote:
> With our XDP-hints kfunc approach, where individual drivers overload the
> default implementation, it can be hard for API users to determine
> whether or not the current device driver have this kfunc available.

> Change the default implementations to use an errno (ENODEV), that
> drivers shouldn't return, to make it possible for BPF runtime to
> determine if bpf kfunc for xdp metadata isn't implemented by driver.

> This is intended to ease supporting and troubleshooting setups. E.g.
> when users on mailing list report -19 (ENODEV) as an error, then we can
> immediately tell them their device driver is too old.

I agree with the v1 comments that I'm not sure how it helps.
Why can't we update the doc in the same fashion and say that
the drivers shouldn't return EOPNOTSUPP?

I'm fine with the change if you think it makes your/users life
easier. Although I don't really understand how. We can, as Toke
mentioned, ask the users to provide jited program dump if it's
mostly about user reports.

> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
>   Documentation/networking/xdp-rx-metadata.rst |    3 ++-
>   net/core/xdp.c                               |    8 ++++++--
>   2 files changed, 8 insertions(+), 3 deletions(-)

> diff --git a/Documentation/networking/xdp-rx-metadata.rst  
> b/Documentation/networking/xdp-rx-metadata.rst
> index aac63fc2d08b..89f6a7d1be38 100644
> --- a/Documentation/networking/xdp-rx-metadata.rst
> +++ b/Documentation/networking/xdp-rx-metadata.rst
> @@ -26,7 +26,8 @@ consumers, an XDP program can store it into the  
> metadata area carried
>   ahead of the packet.

>   Not all kfuncs have to be implemented by the device driver; when not
> -implemented, the default ones that return ``-EOPNOTSUPP`` will be used.
> +implemented, the default ones that return ``-ENODEV`` will be used to
> +indicate the device driver have not implemented this kfunc.

>   Within an XDP frame, the metadata layout (accessed via ``xdp_buff``) is
>   as follows::
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 26483935b7a4..7bb5984ae4f7 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -722,10 +722,12 @@ __diag_ignore_all("-Wmissing-prototypes",
>    * @timestamp: Return value pointer.
>    *
>    * Returns 0 on success or ``-errno`` on error.
> + *
> + *  -ENODEV (19): means device driver doesn't implement kfunc
>    */
>   __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx,  
> u64 *timestamp)
>   {
> -	return -EOPNOTSUPP;
> +	return -ENODEV;
>   }

>   /**
> @@ -734,10 +736,12 @@ __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const  
> struct xdp_md *ctx, u64 *tim
>    * @hash: Return value pointer.
>    *
>    * Returns 0 on success or ``-errno`` on error.
> + *
> + *  -ENODEV (19): means device driver doesn't implement kfunc
>    */
>   __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32  
> *hash)
>   {
> -	return -EOPNOTSUPP;
> +	return -ENODEV;
>   }

>   __diag_pop();
Martin KaFai Lau Feb. 17, 2023, 5:38 p.m. UTC | #2
On 2/17/23 9:32 AM, Stanislav Fomichev wrote:
> On 02/17, Jesper Dangaard Brouer wrote:
>> With our XDP-hints kfunc approach, where individual drivers overload the
>> default implementation, it can be hard for API users to determine
>> whether or not the current device driver have this kfunc available.
> 
>> Change the default implementations to use an errno (ENODEV), that
>> drivers shouldn't return, to make it possible for BPF runtime to
>> determine if bpf kfunc for xdp metadata isn't implemented by driver.
> 
>> This is intended to ease supporting and troubleshooting setups. E.g.
>> when users on mailing list report -19 (ENODEV) as an error, then we can
>> immediately tell them their device driver is too old.
> 
> I agree with the v1 comments that I'm not sure how it helps.
> Why can't we update the doc in the same fashion and say that
> the drivers shouldn't return EOPNOTSUPP?
> 
> I'm fine with the change if you think it makes your/users life
> easier. Although I don't really understand how. We can, as Toke
> mentioned, ask the users to provide jited program dump if it's
> mostly about user reports.

and there is xdp-features also.
Stanislav Fomichev Feb. 17, 2023, 5:40 p.m. UTC | #3
On Fri, Feb 17, 2023 at 9:39 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> On 2/17/23 9:32 AM, Stanislav Fomichev wrote:
> > On 02/17, Jesper Dangaard Brouer wrote:
> >> With our XDP-hints kfunc approach, where individual drivers overload the
> >> default implementation, it can be hard for API users to determine
> >> whether or not the current device driver have this kfunc available.
> >
> >> Change the default implementations to use an errno (ENODEV), that
> >> drivers shouldn't return, to make it possible for BPF runtime to
> >> determine if bpf kfunc for xdp metadata isn't implemented by driver.
> >
> >> This is intended to ease supporting and troubleshooting setups. E.g.
> >> when users on mailing list report -19 (ENODEV) as an error, then we can
> >> immediately tell them their device driver is too old.
> >
> > I agree with the v1 comments that I'm not sure how it helps.
> > Why can't we update the doc in the same fashion and say that
> > the drivers shouldn't return EOPNOTSUPP?
> >
> > I'm fine with the change if you think it makes your/users life
> > easier. Although I don't really understand how. We can, as Toke
> > mentioned, ask the users to provide jited program dump if it's
> > mostly about user reports.
>
> and there is xdp-features also.

Yeah, I was going to suggest it, but then I wasn't sure how to
reconcile our 'kfunc is not a uapi' with xdp-features (that probably
is a uapi)?
Martin KaFai Lau Feb. 17, 2023, 5:55 p.m. UTC | #4
On 2/17/23 9:40 AM, Stanislav Fomichev wrote:
> On Fri, Feb 17, 2023 at 9:39 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>
>> On 2/17/23 9:32 AM, Stanislav Fomichev wrote:
>>> On 02/17, Jesper Dangaard Brouer wrote:
>>>> With our XDP-hints kfunc approach, where individual drivers overload the
>>>> default implementation, it can be hard for API users to determine
>>>> whether or not the current device driver have this kfunc available.
>>>
>>>> Change the default implementations to use an errno (ENODEV), that
>>>> drivers shouldn't return, to make it possible for BPF runtime to
>>>> determine if bpf kfunc for xdp metadata isn't implemented by driver.
>>>
>>>> This is intended to ease supporting and troubleshooting setups. E.g.
>>>> when users on mailing list report -19 (ENODEV) as an error, then we can
>>>> immediately tell them their device driver is too old.
>>>
>>> I agree with the v1 comments that I'm not sure how it helps.
>>> Why can't we update the doc in the same fashion and say that
>>> the drivers shouldn't return EOPNOTSUPP?
>>>
>>> I'm fine with the change if you think it makes your/users life
>>> easier. Although I don't really understand how. We can, as Toke
>>> mentioned, ask the users to provide jited program dump if it's
>>> mostly about user reports.
>>
>> and there is xdp-features also.
> 
> Yeah, I was going to suggest it, but then I wasn't sure how to
> reconcile our 'kfunc is not a uapi' with xdp-features (that probably
> is a uapi)?

uapi concern is a bit in xdp-features may go away because the kfunc may go away ?

May be a list of xdp kfunc names that it supports? A list of kfunc btf id will 
do also and the user space will need to map it back. Not sure if it is easily 
doable in xdp-features.
Stanislav Fomichev Feb. 17, 2023, 6:01 p.m. UTC | #5
On Fri, Feb 17, 2023 at 9:55 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> On 2/17/23 9:40 AM, Stanislav Fomichev wrote:
> > On Fri, Feb 17, 2023 at 9:39 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
> >>
> >> On 2/17/23 9:32 AM, Stanislav Fomichev wrote:
> >>> On 02/17, Jesper Dangaard Brouer wrote:
> >>>> With our XDP-hints kfunc approach, where individual drivers overload the
> >>>> default implementation, it can be hard for API users to determine
> >>>> whether or not the current device driver have this kfunc available.
> >>>
> >>>> Change the default implementations to use an errno (ENODEV), that
> >>>> drivers shouldn't return, to make it possible for BPF runtime to
> >>>> determine if bpf kfunc for xdp metadata isn't implemented by driver.
> >>>
> >>>> This is intended to ease supporting and troubleshooting setups. E.g.
> >>>> when users on mailing list report -19 (ENODEV) as an error, then we can
> >>>> immediately tell them their device driver is too old.
> >>>
> >>> I agree with the v1 comments that I'm not sure how it helps.
> >>> Why can't we update the doc in the same fashion and say that
> >>> the drivers shouldn't return EOPNOTSUPP?
> >>>
> >>> I'm fine with the change if you think it makes your/users life
> >>> easier. Although I don't really understand how. We can, as Toke
> >>> mentioned, ask the users to provide jited program dump if it's
> >>> mostly about user reports.
> >>
> >> and there is xdp-features also.
> >
> > Yeah, I was going to suggest it, but then I wasn't sure how to
> > reconcile our 'kfunc is not a uapi' with xdp-features (that probably
> > is a uapi)?
>
> uapi concern is a bit in xdp-features may go away because the kfunc may go away ?

Yeah, if it's another kind of bitmask we'd have to retain those bits
(in case of a particular kfunc ever going away)..

> May be a list of xdp kfunc names that it supports? A list of kfunc btf id will
> do also and the user space will need to map it back. Not sure if it is easily
> doable in xdp-features.

Good point. A string list / btf_id list of kfuncs implemented by
netdev might be a good alternative.
Toke Høiland-Jørgensen Feb. 17, 2023, 8:49 p.m. UTC | #6
Stanislav Fomichev <sdf@google.com> writes:

> On Fri, Feb 17, 2023 at 9:55 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>
>> On 2/17/23 9:40 AM, Stanislav Fomichev wrote:
>> > On Fri, Feb 17, 2023 at 9:39 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>> >>
>> >> On 2/17/23 9:32 AM, Stanislav Fomichev wrote:
>> >>> On 02/17, Jesper Dangaard Brouer wrote:
>> >>>> With our XDP-hints kfunc approach, where individual drivers overload the
>> >>>> default implementation, it can be hard for API users to determine
>> >>>> whether or not the current device driver have this kfunc available.
>> >>>
>> >>>> Change the default implementations to use an errno (ENODEV), that
>> >>>> drivers shouldn't return, to make it possible for BPF runtime to
>> >>>> determine if bpf kfunc for xdp metadata isn't implemented by driver.
>> >>>
>> >>>> This is intended to ease supporting and troubleshooting setups. E.g.
>> >>>> when users on mailing list report -19 (ENODEV) as an error, then we can
>> >>>> immediately tell them their device driver is too old.
>> >>>
>> >>> I agree with the v1 comments that I'm not sure how it helps.
>> >>> Why can't we update the doc in the same fashion and say that
>> >>> the drivers shouldn't return EOPNOTSUPP?
>> >>>
>> >>> I'm fine with the change if you think it makes your/users life
>> >>> easier. Although I don't really understand how. We can, as Toke
>> >>> mentioned, ask the users to provide jited program dump if it's
>> >>> mostly about user reports.
>> >>
>> >> and there is xdp-features also.
>> >
>> > Yeah, I was going to suggest it, but then I wasn't sure how to
>> > reconcile our 'kfunc is not a uapi' with xdp-features (that probably
>> > is a uapi)?
>>
>> uapi concern is a bit in xdp-features may go away because the kfunc may go away ?
>
> Yeah, if it's another kind of bitmask we'd have to retain those bits
> (in case of a particular kfunc ever going away)..
>
>> May be a list of xdp kfunc names that it supports? A list of kfunc btf id will
>> do also and the user space will need to map it back. Not sure if it is easily
>> doable in xdp-features.
>
> Good point. A string list / btf_id list of kfuncs implemented by
> netdev might be a good alternative.

Yup, Lorenzo and I discussed something similar at one point, I think
having this as part of the feature thing would be useful!

-Toke
Jesper Dangaard Brouer Feb. 18, 2023, 2:01 p.m. UTC | #7
On 17/02/2023 21.49, Toke Høiland-Jørgensen wrote:
> Stanislav Fomichev <sdf@google.com> writes:
> 
>> On Fri, Feb 17, 2023 at 9:55 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>>
>>> On 2/17/23 9:40 AM, Stanislav Fomichev wrote:
>>>> On Fri, Feb 17, 2023 at 9:39 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>>>>
>>>>> On 2/17/23 9:32 AM, Stanislav Fomichev wrote:
>>>>>> On 02/17, Jesper Dangaard Brouer wrote:
>>>>>>> With our XDP-hints kfunc approach, where individual drivers overload the
>>>>>>> default implementation, it can be hard for API users to determine
>>>>>>> whether or not the current device driver have this kfunc available.
>>>>>>
>>>>>>> Change the default implementations to use an errno (ENODEV), that
>>>>>>> drivers shouldn't return, to make it possible for BPF runtime to
>>>>>>> determine if bpf kfunc for xdp metadata isn't implemented by driver.
>>>>>>
>>>>>>> This is intended to ease supporting and troubleshooting setups. E.g.
>>>>>>> when users on mailing list report -19 (ENODEV) as an error, then we can
>>>>>>> immediately tell them their device driver is too old.
>>>>>>
>>>>>> I agree with the v1 comments that I'm not sure how it helps.
>>>>>> Why can't we update the doc in the same fashion and say that
>>>>>> the drivers shouldn't return EOPNOTSUPP?

Okay, lets go in this direction then.
I will update the drivers to not return EOPNOTSUPP.

What should drivers then return instead.
I will propose that driver return ENODATA instead?

--Jesper
diff mbox series

Patch

diff --git a/Documentation/networking/xdp-rx-metadata.rst b/Documentation/networking/xdp-rx-metadata.rst
index aac63fc2d08b..89f6a7d1be38 100644
--- a/Documentation/networking/xdp-rx-metadata.rst
+++ b/Documentation/networking/xdp-rx-metadata.rst
@@ -26,7 +26,8 @@  consumers, an XDP program can store it into the metadata area carried
 ahead of the packet.
 
 Not all kfuncs have to be implemented by the device driver; when not
-implemented, the default ones that return ``-EOPNOTSUPP`` will be used.
+implemented, the default ones that return ``-ENODEV`` will be used to
+indicate the device driver have not implemented this kfunc.
 
 Within an XDP frame, the metadata layout (accessed via ``xdp_buff``) is
 as follows::
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 26483935b7a4..7bb5984ae4f7 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -722,10 +722,12 @@  __diag_ignore_all("-Wmissing-prototypes",
  * @timestamp: Return value pointer.
  *
  * Returns 0 on success or ``-errno`` on error.
+ *
+ *  -ENODEV (19): means device driver doesn't implement kfunc
  */
 __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp)
 {
-	return -EOPNOTSUPP;
+	return -ENODEV;
 }
 
 /**
@@ -734,10 +736,12 @@  __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, u64 *tim
  * @hash: Return value pointer.
  *
  * Returns 0 on success or ``-errno`` on error.
+ *
+ *  -ENODEV (19): means device driver doesn't implement kfunc
  */
 __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash)
 {
-	return -EOPNOTSUPP;
+	return -ENODEV;
 }
 
 __diag_pop();