From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by mail.toke.dk (Postfix) with ESMTPS id 92B25A06577 for ; Fri, 12 May 2023 20:34:24 +0200 (CEST) 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=20221208 header.b=1qXhzjto Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-55a1427cbacso168476717b3.3 for ; Fri, 12 May 2023 11:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683916463; x=1686508463; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ksHSwdf3LwcwVL3OE9a2eYWhGDTEko4fWy0aHJsHDCU=; b=1qXhzjtoALC7LbPCjmNHDKpuDvTISdkcKIC+yZpoPn4HTlYjny8TG6ILSGhADhBXTb 2SoGAFXyKUGXpGLQzgEynaaCDq25XGTUeg4gsm9RGHc0JGRJeH5tAaubJKfewgpjW3v5 96XWVae0jmVbKjNcbFpilhqhcjAsTL+aM6qE+oEi7CHNep5VQRAr+QeMxjar7jIH0mzt coO8tZUpUzQSmyw50e7qP+CWMWv8iWDAW0qzlPwXzZCJiIEg3ymnkl+Aed6CTIBAoBKC XMkZ9kKOZLIchnpHF8BeQIZKB3I/zbMeVaQl7nhSVuQqYq9N+gOl31e3qBnnb1HIyHAQ 1XaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683916463; x=1686508463; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ksHSwdf3LwcwVL3OE9a2eYWhGDTEko4fWy0aHJsHDCU=; b=anM+d6drE2IctKrwpcoK9OceFul2pte7vnBIu8/R1fhoRz00GQEyHk68+vRzrWDkKF h7jqrQQWBZh3UTXi2haSCzaaZAUwL9cvevTxDL324/eOv32rMbU58hr9sgP2XekzLa+1 kWmlfhWcViCgGExHOYhh+Us74miPVYbo9Nh407F471Qn9G9rzGkEtsFGwOk/EPaw6nnB Hjot654Mz8UwA+tKYDOXWyuNG3Qn7rkP9NAzaFp2gGO90s4w3oWgcNgIyKQlWxogcnBW 5ZqGfrDff3pIH25iWNk+edRLasKkk2cVzFyLEz2dZDGQ5Zs2VozmuZHhgMIMnVvS12SR gcxQ== X-Gm-Message-State: AC+VfDyHFHsF1TEWsvhbDRb5JMXvfr+ag0iAAxvmD4ZqKNaO48oSHQAl 8naZxFRadItAzDD3WAwnhrr0/bI= X-Google-Smtp-Source: ACHHUZ6Sw+JVn0ptcM72e1Wp1MOw6FgFKWFiZmnTwGnuLBFu/ZagRmDQMzwhOzRPdysj3HzHBs+xUH8= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a81:ac05:0:b0:561:2078:c4cd with SMTP id k5-20020a81ac05000000b005612078c4cdmr1405616ywh.2.1683916462870; Fri, 12 May 2023 11:34:22 -0700 (PDT) Date: Fri, 12 May 2023 11:34:21 -0700 In-Reply-To: <20230512152607.992209-12-larysa.zaremba@intel.com> Mime-Version: 1.0 References: <20230512152607.992209-1-larysa.zaremba@intel.com> <20230512152607.992209-12-larysa.zaremba@intel.com> Message-ID: From: Stanislav Fomichev To: Larysa Zaremba Content-Type: text/plain; charset="utf-8" Message-ID-Hash: SNAI5OXOXZFKTU6QFUD5VMGDQBUJ375T X-Message-ID-Hash: SNAI5OXOXZFKTU6QFUD5VMGDQBUJ375T X-MailFrom: 3roZeZAMKCV8PACDLLDIB.9LJUAM-EFKQPUAM-MOLGB9Q.KBQ@flex--sdf.bounces.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, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Jakub Kicinski , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa , Jesse Brandeburg , Tony Nguyen , Anatoly Burakov , Jesper Dangaard Brouer , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH RESEND bpf-next 11/15] xdp: Add checksum level hint List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 05/12, Larysa Zaremba wrote: > Implement functionality that enables drivers to expose to XDP code, > whether checksums was checked and on what level. > > Signed-off-by: Larysa Zaremba > --- > Documentation/networking/xdp-rx-metadata.rst | 3 +++ > include/linux/netdevice.h | 1 + > include/net/xdp.h | 2 ++ > kernel/bpf/offload.c | 2 ++ > net/core/xdp.c | 12 ++++++++++++ > 5 files changed, 20 insertions(+) > > diff --git a/Documentation/networking/xdp-rx-metadata.rst b/Documentation/networking/xdp-rx-metadata.rst > index 73a78029c596..f74f0e283097 100644 > --- a/Documentation/networking/xdp-rx-metadata.rst > +++ b/Documentation/networking/xdp-rx-metadata.rst > @@ -29,6 +29,9 @@ metadata is supported, this set will grow: > .. kernel-doc:: net/core/xdp.c > :identifiers: bpf_xdp_metadata_rx_stag > > +.. kernel-doc:: net/core/xdp.c > + :identifiers: bpf_xdp_metadata_rx_csum_lvl > + > 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 > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index fdae37fe11f5..ddade3a15366 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -1657,6 +1657,7 @@ struct xdp_metadata_ops { > enum xdp_rss_hash_type *rss_type); > int (*xmo_rx_ctag)(const struct xdp_md *ctx, u16 *vlan_tag); > int (*xmo_rx_stag)(const struct xdp_md *ctx, u16 *vlan_tag); > + int (*xmo_rx_csum_lvl)(const struct xdp_md *ctx, u8 *csum_level); > }; > > /** > diff --git a/include/net/xdp.h b/include/net/xdp.h > index 2db7439fc60f..0fbd25616241 100644 > --- a/include/net/xdp.h > +++ b/include/net/xdp.h > @@ -393,6 +393,8 @@ void xdp_attachment_setup(struct xdp_attachment_info *info, > bpf_xdp_metadata_rx_ctag) \ > XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_STAG, \ > bpf_xdp_metadata_rx_stag) \ > + XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_CSUM_LVL, \ > + bpf_xdp_metadata_rx_csum_lvl) \ > > enum { > #define XDP_METADATA_KFUNC(name, _) name, > diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c > index 2c6b6e82cfac..8bd54fb4ac63 100644 > --- a/kernel/bpf/offload.c > +++ b/kernel/bpf/offload.c > @@ -852,6 +852,8 @@ void *bpf_dev_bound_resolve_kfunc(struct bpf_prog *prog, u32 func_id) > p = ops->xmo_rx_ctag; > else if (func_id == bpf_xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_STAG)) > p = ops->xmo_rx_stag; > + else if (func_id == bpf_xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_CSUM_LVL)) > + p = ops->xmo_rx_csum_lvl; > out: > up_read(&bpf_devs_lock); > > diff --git a/net/core/xdp.c b/net/core/xdp.c > index eff21501609f..7dd45fd62983 100644 > --- a/net/core/xdp.c > +++ b/net/core/xdp.c > @@ -762,6 +762,18 @@ __bpf_kfunc int bpf_xdp_metadata_rx_stag(const struct xdp_md *ctx, u16 *vlan_tag > return -EOPNOTSUPP; > } > > +/** > + * bpf_xdp_metadata_rx_csum_lvl - Get depth at which HW has checked the checksum. > + * @ctx: XDP context pointer. > + * @csum_level: Return value pointer. Let's maybe clarify what the level means here? For example, do we start counting from 0 or 1? > + * > + * Returns 0 on success (HW has checked the checksum) or ``-errno`` on error. > + */ > +__bpf_kfunc int bpf_xdp_metadata_rx_csum_lvl(const struct xdp_md *ctx, u8 *csum_level) > +{ > + return -EOPNOTSUPP; > +} > + > __diag_pop(); > > BTF_SET8_START(xdp_metadata_kfunc_ids) > -- > 2.35.3 >