XDP hardware hints discussion mail archive
 help / color / mirror / Atom feed
* [xdp-hints] [PATCH bpf-next V2] xdp: bpf_xdp_metadata use NODEV for no device support
@ 2023-02-17 12:11 Jesper Dangaard Brouer
  2023-02-17 17:32 ` [xdp-hints] " Stanislav Fomichev
  0 siblings, 1 reply; 8+ messages in thread
From: Jesper Dangaard Brouer @ 2023-02-17 12:11 UTC (permalink / raw)
  To: bpf
  Cc: Jesper Dangaard Brouer, netdev, Stanislav Fomichev, martin.lau,
	ast, daniel, alexandr.lobakin, larysa.zaremba, xdp-hints

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(-)

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();



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

end of thread, other threads:[~2023-02-18 14:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 12:11 [xdp-hints] [PATCH bpf-next V2] xdp: bpf_xdp_metadata use NODEV for no device support Jesper Dangaard Brouer
2023-02-17 17:32 ` [xdp-hints] " Stanislav Fomichev
2023-02-17 17:38   ` Martin KaFai Lau
2023-02-17 17:40     ` Stanislav Fomichev
2023-02-17 17:55       ` Martin KaFai Lau
2023-02-17 18:01         ` Stanislav Fomichev
2023-02-17 20:49           ` Toke Høiland-Jørgensen
2023-02-18 14:01             ` Jesper Dangaard Brouer

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