Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10706650rwr; Fri, 12 May 2023 11:42:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6jQbqu7fZdvz8dfqQHUNyLsic9WNil6x+0QNttdH+D8mHpsR6B7WWPEc4tgT0oHphThzAN X-Received: by 2002:a05:6a21:9997:b0:104:7a4c:6c97 with SMTP id ve23-20020a056a21999700b001047a4c6c97mr4035814pzb.13.1683916960627; Fri, 12 May 2023 11:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683916960; cv=none; d=google.com; s=arc-20160816; b=mRNrkzEV2fg2f+2DgWW9JJBdgOiUQlQ56ZNQShCsUPUqEvI3aYjWeYNX8z99bf0QE7 2Q0R/e7DBcs6dRKp8SqX6eRbXSJF8wmyoQf77Av5ZDmkU4/ArClWYRnlf7K/OsGWzrhE snfTt91JGWxHI9HA4G34T3gm4/NQ8Alxjuzjig5CtQ0fZPXoQtaxePRG1xI4veQ4wqS1 P64A6ihTYNpi18nC1OM59LPUnONj3Q90XgvGYZpBPXicsYiacD9IJzMMU0U58cfEXPjt ER+oYvZDp0AAiSXxCSc0H1Ufk27U7HZv7z3DR6DRMN/f/sKq2kGSTqBQ0UUtysfiZChl Yzpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=g1YHZI5wWoilGiErbtfwlJ8t+YURSptBI7L1u7j3vVM=; b=tZQd+PKVRwj5F/TF8hY5dIrf9rfm7cEQBhelXVHfOq9WmTxf2eFyorCE/0bQfWpxdD qjdz/uSxMeUJUM5LICMQRevgTIDkw8wCM5Fim1sLRAy1nOU7mv320eeRh4H1pIN+7nOw 0QhKmUh4Nz/Tkp70BlT/1vwGG9DosEd+sw986gRvsHbdUUG4dRBWvG+dtdjW2OftX2eC fO26Dh+YBDCqFnmiIIiKQb0LotoKjYLiaHwJsYbZVu99VRBLc3M15nNeN3IoMjAGCSyi 99+WXZ15XYEMLD6deIsKVxAQYGs+M5Ndxo5VgB0KARSJEs/t0JWP6LfQTVn6jR/ju4x+ oq4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="K9UDN4B/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020a639551000000b004faf33e2755si9591000pgn.349.2023.05.12.11.42.25; Fri, 12 May 2023 11:42:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="K9UDN4B/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238676AbjELSaV (ORCPT + 99 others); Fri, 12 May 2023 14:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239291AbjELSaM (ORCPT ); Fri, 12 May 2023 14:30:12 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83572D40 for ; Fri, 12 May 2023 11:29:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba6388faf79so4790837276.0 for ; Fri, 12 May 2023 11:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683916126; x=1686508126; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=g1YHZI5wWoilGiErbtfwlJ8t+YURSptBI7L1u7j3vVM=; b=K9UDN4B/R3ogwJmxTjdrEokIDh2/U9Ke5kzESmbqsjepMS+MzvNKwdyEGaOh8hfyYz VcQYpY3OPiM7e6Xqm14UIE3Wcrh3rautsuytlTioEMN+DimMMZ7G42wrPlH8x4ZVc8Sz fuo+/gxpvp/KUvo9o514Oztnpkdh1qkembXoIYCYH5jYJm5NQ5ZZIZQC00b7uVeGlNv7 Gp/auxM9y4+WXLnOv9rj6MuMOL7vu0Unc1FhgmSmZgCB3jZjWWwZAeGMNqUty7PUZ1dv FbMgxDgd/CxxOU9sa0vqLh26yG4Mqg4eeJNw0QhTDkmuoXHoxl1Of7BF9DPmWUVWh94b Oh7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683916126; x=1686508126; 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=g1YHZI5wWoilGiErbtfwlJ8t+YURSptBI7L1u7j3vVM=; b=AnnNWkoONyMoHKtN/S5IHfnyEif6Dc/jsT9eqbqcTWt0cGk3p4gjV8CC6PeQSA9Oi2 a79MJ1fAsYOAk1hx6TD7CvLNMQFSPjJSR75GqRa4l1AMGEV0MdHT5K+qsOd0C/OVJutV gI/Fzqu5S7FX/QxQ2IT9Vrw6emXILNAraZbPzPzUNhuMH8lOR7hjPEH75pvI5uFMHZsM RRO70dZojgtAxBnHe+7Z8ErS8zf+UkxrtPqd/PP7DnUeygOIAFK5BAILe3PhawiColFm ym7nIoF1fHHt03lH5jAyVEcWQgbSqBCohKAYny6m1y7lCbi3lZKkYZ3Hf9V4rH9oe7rF Ow6Q== X-Gm-Message-State: AC+VfDyrEtZM5k4CIsZ2H6H/8aQ7HqtmTmIcY/fiDNhKh+ckV323VbCr MQcQNry6jV4TtmqyiEK5BQtoLio= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a25:874f:0:b0:b9d:fe66:a424 with SMTP id e15-20020a25874f000000b00b9dfe66a424mr16098075ybn.2.1683916126382; Fri, 12 May 2023 11:28:46 -0700 (PDT) Date: Fri, 12 May 2023 11:28:44 -0700 In-Reply-To: <20230512152607.992209-10-larysa.zaremba@intel.com> Mime-Version: 1.0 References: <20230512152607.992209-1-larysa.zaremba@intel.com> <20230512152607.992209-10-larysa.zaremba@intel.com> Message-ID: Subject: Re: [PATCH RESEND bpf-next 09/15] xdp: Add VLAN tag hint From: Stanislav Fomichev To: Larysa Zaremba 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 Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/12, Larysa Zaremba wrote: > Implement functionality that enables drivers to expose VLAN tag > to XDP code. > > Signed-off-by: Larysa Zaremba Acked-by: Stanislav Fomichev > --- > Documentation/networking/xdp-rx-metadata.rst | 11 ++++++++- > include/linux/netdevice.h | 2 ++ > include/net/xdp.h | 4 ++++ > kernel/bpf/offload.c | 4 ++++ > net/core/xdp.c | 24 ++++++++++++++++++++ > 5 files changed, 44 insertions(+), 1 deletion(-) > > diff --git a/Documentation/networking/xdp-rx-metadata.rst b/Documentation/networking/xdp-rx-metadata.rst > index 25ce72af81c2..73a78029c596 100644 > --- a/Documentation/networking/xdp-rx-metadata.rst > +++ b/Documentation/networking/xdp-rx-metadata.rst > @@ -18,7 +18,16 @@ Currently, the following kfuncs are supported. In the future, as more > metadata is supported, this set will grow: > > .. kernel-doc:: net/core/xdp.c > - :identifiers: bpf_xdp_metadata_rx_timestamp bpf_xdp_metadata_rx_hash > + :identifiers: bpf_xdp_metadata_rx_timestamp > + > +.. kernel-doc:: net/core/xdp.c > + :identifiers: bpf_xdp_metadata_rx_hash > + > +.. kernel-doc:: net/core/xdp.c > + :identifiers: bpf_xdp_metadata_rx_ctag > + > +.. kernel-doc:: net/core/xdp.c > + :identifiers: bpf_xdp_metadata_rx_stag > > 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 > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index 08fbd4622ccf..fdae37fe11f5 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -1655,6 +1655,8 @@ struct xdp_metadata_ops { > int (*xmo_rx_timestamp)(const struct xdp_md *ctx, u64 *timestamp); > int (*xmo_rx_hash)(const struct xdp_md *ctx, u32 *hash, > 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); > }; > > /** > diff --git a/include/net/xdp.h b/include/net/xdp.h > index 6381560efae2..2db7439fc60f 100644 > --- a/include/net/xdp.h > +++ b/include/net/xdp.h > @@ -389,6 +389,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info, > bpf_xdp_metadata_rx_timestamp) \ > XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_HASH, \ > bpf_xdp_metadata_rx_hash) \ > + XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_CTAG, \ > + bpf_xdp_metadata_rx_ctag) \ > + XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_STAG, \ > + bpf_xdp_metadata_rx_stag) \ > > enum { > #define XDP_METADATA_KFUNC(name, _) name, > diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c > index d9c9f45e3529..2c6b6e82cfac 100644 > --- a/kernel/bpf/offload.c > +++ b/kernel/bpf/offload.c > @@ -848,6 +848,10 @@ void *bpf_dev_bound_resolve_kfunc(struct bpf_prog *prog, u32 func_id) > p = ops->xmo_rx_timestamp; > else if (func_id == bpf_xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_HASH)) > p = ops->xmo_rx_hash; > + else if (func_id == bpf_xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_CTAG)) > + p = ops->xmo_rx_ctag; > + else if (func_id == bpf_xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_STAG)) > + p = ops->xmo_rx_stag; > out: > up_read(&bpf_devs_lock); > > diff --git a/net/core/xdp.c b/net/core/xdp.c > index 41e5ca8643ec..eff21501609f 100644 > --- a/net/core/xdp.c > +++ b/net/core/xdp.c > @@ -738,6 +738,30 @@ __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash, > return -EOPNOTSUPP; > } > > +/** > + * bpf_xdp_metadata_rx_ctag - Read XDP packet inner vlan tag. > + * @ctx: XDP context pointer. > + * @vlan_tag: Return value pointer. > + * > + * Returns 0 on success or ``-errno`` on error. > + */ > +__bpf_kfunc int bpf_xdp_metadata_rx_ctag(const struct xdp_md *ctx, u16 *vlan_tag) > +{ > + return -EOPNOTSUPP; > +} > + > +/** > + * bpf_xdp_metadata_rx_stag - Read XDP packet outer vlan tag. > + * @ctx: XDP context pointer. > + * @vlan_tag: Return value pointer. > + * > + * Returns 0 on success or ``-errno`` on error. > + */ > +__bpf_kfunc int bpf_xdp_metadata_rx_stag(const struct xdp_md *ctx, u16 *vlan_tag) > +{ > + return -EOPNOTSUPP; > +} > + > __diag_pop(); > > BTF_SET8_START(xdp_metadata_kfunc_ids) > -- > 2.35.3 >