From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by mail.toke.dk (Postfix) with ESMTPS id 9B65A9F6EA8 for ; Tue, 21 Mar 2023 19:41:57 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=XMv6/qI7 Received: by mail-pj1-x1031.google.com with SMTP id p3-20020a17090a74c300b0023f69bc7a68so12337494pjl.4 for ; Tue, 21 Mar 2023 11:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679424115; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QhY7Zex6hyzqegpd5VgFoVLv7FRdLDof3Jtch1qYh1M=; b=XMv6/qI7Scp6XV+eP33j1iv4T3/xyHBVKBbW7vMa1s4FWH07uwC1m/FNhBqxtIImBI YKgbmv8diP80jUJQlwWc/ZcEmCsfuzaZVxJcn3lZRS4Ex0rk6ye8tOiqs4xZgRijKlNy 4rEjJXq5voTLyz3cc3seU+EM7ljP1Kz1VI+BOiGrlh6YTA71uc1ISQvtQqUTDVWoQUju k+1ztfr4hixFuNZgk2wJRmspLUF8P/L8s6uXZnV87UpUkJScjB7fXSWDtQ5YHsgsSF0K 8PRZyf/HjVtVt4tCouMwaAbx14cOccpItd+ed9rOU1rQowJYtUNLREtNPEDGLcVRRliu GALg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679424115; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QhY7Zex6hyzqegpd5VgFoVLv7FRdLDof3Jtch1qYh1M=; b=3dLfhHXU0tuyD419sx16/OSEEWIJ7xEfhwxOpW+f4I9MkNixG9D6fPSvgHrBSfJtPb fEwVFEDm+ycuy1WXQKcdRjRz5in6y9bCz6saB05+NAJPp4DzYpF+KEkAnSdrSmkORODy Y424VAKDGK0oLNvd7E00DAcQhN5Z79YYch7CCq5um6jdPZ19vQ5rpzgKUas/xyxTEq40 pDZ9IZV5XxUFXM8UpFjJjE1I03/5tQg0bhpmhd55UGSt7nbta7UFlB9BHd8P2yR6yGgD tK0bo49Qc75A20Ws7LdpQ6IiCmLAGGWPaZNr0uCreYVvZrInWAEvcEU6CcXLvycM5gth DMBA== X-Gm-Message-State: AO0yUKVaNk5GG0e7LxhtY9gX8SxXdo6NUQLBUdCmXMosAHF373A6C4ft 14InAZs/QPuPKNxx8ztPpP2fGJ/kDaQyFLLUGmAGWQ== X-Google-Smtp-Source: AK7set+5gjgppMNfTX5jYGAV+yB0SMlKUPDs49QdhUJDPR6i2bZA3Bm6KvlYJPkPM5kKYGCgo8lQUvsm4Ob9yPnemw0= X-Received: by 2002:a17:902:e543:b0:19c:d14b:ee20 with SMTP id n3-20020a170902e54300b0019cd14bee20mr44564plf.8.1679424114956; Tue, 21 Mar 2023 11:41:54 -0700 (PDT) MIME-Version: 1.0 References: <167940675120.2718408.8176058626864184420.stgit@firesoul> In-Reply-To: <167940675120.2718408.8176058626864184420.stgit@firesoul> From: Stanislav Fomichev Date: Tue, 21 Mar 2023 11:41:43 -0700 Message-ID: To: Jesper Dangaard Brouer Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YPHZWHTFPIO3P3EVM2SJ34VEE5EU3NFM X-Message-ID-Hash: YPHZWHTFPIO3P3EVM2SJ34VEE5EU3NFM X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: bpf@vger.kernel.org, netdev@vger.kernel.org, martin.lau@kernel.org, ast@kernel.org, daniel@iogearbox.net, alexandr.lobakin@intel.com, larysa.zaremba@intel.com, xdp-hints@xdp-project.net, anthony.l.nguyen@intel.com, yoong.siang.song@intel.com, boon.leong.ong@intel.com, intel-wired-lan@lists.osuosl.org, pabeni@redhat.com, jesse.brandeburg@intel.com, kuba@kernel.org, edumazet@google.com, john.fastabend@gmail.com, hawk@kernel.org, davem@davemloft.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf V2] xdp: bpf_xdp_metadata use EOPNOTSUPP for no driver support List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Mar 21, 2023 at 6:52=E2=80=AFAM Jesper Dangaard Brouer wrote: > > When driver doesn't implement a bpf_xdp_metadata kfunc the fallback > implementation returns EOPNOTSUPP, which indicate device driver doesn't > implement this kfunc. > > Currently many drivers also return EOPNOTSUPP when the hint isn't > available, which is ambiguous from an API point of view. Instead > change drivers to return ENODATA in these cases. > > There can be natural cases why a driver doesn't provide any hardware > info for a specific hint, even on a frame to frame basis (e.g. PTP). > Lets keep these cases as separate return codes. > > When describing the return values, adjust the function kernel-doc layout > to get proper rendering for the return values. > > Fixes: ab46182d0dcb ("net/mlx4_en: Support RX XDP metadata") > Fixes: bc8d405b1ba9 ("net/mlx5e: Support RX XDP metadata") > Fixes: 306531f0249f ("veth: Support RX XDP metadata") > Fixes: 3d76a4d3d4e5 ("bpf: XDP metadata RX kfuncs") > Signed-off-by: Jesper Dangaard Brouer Acked-by: Stanislav Fomichev > --- > Documentation/networking/xdp-rx-metadata.rst | 7 +++++-- > drivers/net/ethernet/mellanox/mlx4/en_rx.c | 4 ++-- > drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 4 ++-- > drivers/net/veth.c | 4 ++-- > net/core/xdp.c | 10 ++++++++-- > 5 files changed, 19 insertions(+), 10 deletions(-) > > diff --git a/Documentation/networking/xdp-rx-metadata.rst b/Documentation= /networking/xdp-rx-metadata.rst > index aac63fc2d08b..25ce72af81c2 100644 > --- a/Documentation/networking/xdp-rx-metadata.rst > +++ b/Documentation/networking/xdp-rx-metadata.rst > @@ -23,10 +23,13 @@ metadata is supported, this set will grow: > An XDP program can use these kfuncs to read the metadata into stack > variables for its own consumption. Or, to pass the metadata on to other > consumers, an XDP program can store it into the metadata area carried > -ahead of the packet. > +ahead of the packet. Not all packets will necessary have the requested > +metadata available in which case the driver returns ``-ENODATA``. > > 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 ``-EOPNOTSUPP`` 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/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/eth= ernet/mellanox/mlx4/en_rx.c > index 0869d4fff17b..4b5e459b6d49 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c > +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c > @@ -674,7 +674,7 @@ int mlx4_en_xdp_rx_timestamp(const struct xdp_md *ctx= , u64 *timestamp) > struct mlx4_en_xdp_buff *_ctx =3D (void *)ctx; > > if (unlikely(_ctx->ring->hwtstamp_rx_filter !=3D HWTSTAMP_FILTER_= ALL)) > - return -EOPNOTSUPP; > + return -ENODATA; > > *timestamp =3D mlx4_en_get_hwtstamp(_ctx->mdev, > mlx4_en_get_cqe_ts(_ctx->cqe)); > @@ -686,7 +686,7 @@ int mlx4_en_xdp_rx_hash(const struct xdp_md *ctx, u32= *hash) > struct mlx4_en_xdp_buff *_ctx =3D (void *)ctx; > > if (unlikely(!(_ctx->dev->features & NETIF_F_RXHASH))) > - return -EOPNOTSUPP; > + return -ENODATA; > > *hash =3D be32_to_cpu(_ctx->cqe->immed_rss_invalid); > return 0; > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/n= et/ethernet/mellanox/mlx5/core/en/xdp.c > index bcd6370de440..c5dae48b7932 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c > @@ -162,7 +162,7 @@ static int mlx5e_xdp_rx_timestamp(const struct xdp_md= *ctx, u64 *timestamp) > const struct mlx5e_xdp_buff *_ctx =3D (void *)ctx; > > if (unlikely(!mlx5e_rx_hw_stamp(_ctx->rq->tstamp))) > - return -EOPNOTSUPP; > + return -ENODATA; > > *timestamp =3D mlx5e_cqe_ts_to_ns(_ctx->rq->ptp_cyc2time, > _ctx->rq->clock, get_cqe_ts(_ctx= ->cqe)); > @@ -174,7 +174,7 @@ static int mlx5e_xdp_rx_hash(const struct xdp_md *ctx= , u32 *hash) > const struct mlx5e_xdp_buff *_ctx =3D (void *)ctx; > > if (unlikely(!(_ctx->xdp.rxq->dev->features & NETIF_F_RXHASH))) > - return -EOPNOTSUPP; > + return -ENODATA; > > *hash =3D be32_to_cpu(_ctx->cqe->rss_hash_result); > return 0; > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 1bb54de7124d..046461ee42ea 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -1610,7 +1610,7 @@ static int veth_xdp_rx_timestamp(const struct xdp_m= d *ctx, u64 *timestamp) > struct veth_xdp_buff *_ctx =3D (void *)ctx; > > if (!_ctx->skb) > - return -EOPNOTSUPP; > + return -ENODATA; > > *timestamp =3D skb_hwtstamps(_ctx->skb)->hwtstamp; > return 0; > @@ -1621,7 +1621,7 @@ static int veth_xdp_rx_hash(const struct xdp_md *ct= x, u32 *hash) > struct veth_xdp_buff *_ctx =3D (void *)ctx; > > if (!_ctx->skb) > - return -EOPNOTSUPP; > + return -ENODATA; > > *hash =3D skb_get_hash(_ctx->skb); > return 0; > diff --git a/net/core/xdp.c b/net/core/xdp.c > index 8d3ad315f18d..7133017bcd74 100644 > --- a/net/core/xdp.c > +++ b/net/core/xdp.c > @@ -705,7 +705,10 @@ __diag_ignore_all("-Wmissing-prototypes", > * @ctx: XDP context pointer. > * @timestamp: Return value pointer. > * > - * Returns 0 on success or ``-errno`` on error. > + * Return: > + * * Returns 0 on success or ``-errno`` on error. > + * * ``-EOPNOTSUPP`` : means device driver does not implement kfunc > + * * ``-ENODATA`` : means no RX-timestamp available for this frame > */ > __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, = u64 *timestamp) > { > @@ -717,7 +720,10 @@ __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const = struct xdp_md *ctx, u64 *tim > * @ctx: XDP context pointer. > * @hash: Return value pointer. > * > - * Returns 0 on success or ``-errno`` on error. > + * Return: > + * * Returns 0 on success or ``-errno`` on error. > + * * ``-EOPNOTSUPP`` : means device driver doesn't implement kfunc > + * * ``-ENODATA`` : means no RX-hash available for this frame > */ > __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *= hash) > { > >