From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by mail.toke.dk (Postfix) with ESMTPS id 7B50FA1633D for ; Wed, 5 Jul 2023 19:25:05 +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=c+UJldqO Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-56942442eb0so74975217b3.1 for ; Wed, 05 Jul 2023 10:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688577903; x=1691169903; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CxfUFrp22faM6yocaPqFBZtPAz5DjOt4ynE8IBV8bNM=; b=c+UJldqODstcg5PwT6EPmiSS4mdL3PxWjeRwNOb1AH1Rojzk7MXulMdZQUxXtogiE7 Uh8GR7IEJBMLxj/m+dyp5SrFkktba2THXAKRLvcaiBrVtNW3Cdi0KWKnbaC78OtXwaIG hIJ844MYhe1sWdLyGRuEES/N3MgrA8EdL7Kg6C7nf+OF+4kRwuGnuz+4vA+mqiARYIal B5iz2WAH5b+e3oP9RWrINtr/9JrwoofMjnQVl83SneiDJ1TeFruj6sALS0fEN23k8G4f d+6z0aC77RtAVomwW+HsvrklfNH0BBuhsOeA6XSaKNNvy62s2iFpZIGaea5v0mEiBv45 g6Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688577903; x=1691169903; 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=CxfUFrp22faM6yocaPqFBZtPAz5DjOt4ynE8IBV8bNM=; b=k/wmq/yoVlGptj578PNKBY3e4AlNzj1RJji6zsUoJRHME6zViY8Ry2bXS1Nhyx5Ett 80wr1B1OeGUFyHYyNTe87NxdDDhYQS6ct2yU7s4Q0R9f1ohUOeq0lcziUmd/N9DpgrML 7CyixIn3szHUAPg+Eqmeo2sedVYyx31JL7w8dddsW4ogfSi1CUSf9PtvKyHNlfhnR5TI bZ9vW+aEH75yUSAeSEaJmb5Pc7TveR7QEfAeHaTizpi6T+J4ZGIyM0GCaSi0JgPG6l0H 2F6axuXRJfDWl9fekY5MbHczO7+wMm+32cy/JC+YuWwMDoYSWYqrAFeR/KpwFcRuciSk +B/Q== X-Gm-Message-State: ABy/qLZkf2p6vFwBcHLMJlQoPJdJeNpCU4lK4IHEaHUwHel4PjpouhXH h3L099P0r/cGs9rSQw5wdj9G1tw= X-Google-Smtp-Source: APBJJlHBEGfmPdf09pEer+j0AZfp8LuqWeR7ikx6GC0fxeCkefYmRn5l3kF99n0QHWUZN9azdCZXqMU= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a25:a249:0:b0:c39:d6f6:481f with SMTP id b67-20020a25a249000000b00c39d6f6481fmr138970ybi.10.1688577902793; Wed, 05 Jul 2023 10:25:02 -0700 (PDT) Date: Wed, 5 Jul 2023 10:25:01 -0700 In-Reply-To: <20230703181226.19380-18-larysa.zaremba@intel.com> Mime-Version: 1.0 References: <20230703181226.19380-1-larysa.zaremba@intel.com> <20230703181226.19380-18-larysa.zaremba@intel.com> Message-ID: From: Stanislav Fomichev To: Larysa Zaremba Content-Type: text/plain; charset="utf-8" Message-ID-Hash: XHEEH7FOD3RPF6Q6ZGHEKDDGRVT6SXSR X-Message-ID-Hash: XHEEH7FOD3RPF6Q6ZGHEKDDGRVT6SXSR X-MailFrom: 3bqelZAMKCX8vgijrrjoh.frp0gs-klqwv0gs-surmhfw.qhw@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, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v2 17/20] veth: Implement VLAN tag and checksum level XDP hint List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 07/03, Larysa Zaremba wrote: > In order to test VLAN tag and checksum level XDP hints in > hardware-independent selfttests, implement newly added XDP hints in veth > driver. > > Signed-off-by: Larysa Zaremba > --- > drivers/net/veth.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 614f3e3efab0..a7f2b679551d 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -1732,6 +1732,44 @@ static int veth_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash, > return 0; > } > > +static int veth_xdp_rx_vlan_tag(const struct xdp_md *ctx, u16 *vlan_tag, > + __be16 *vlan_proto) > +{ > + struct veth_xdp_buff *_ctx = (void *)ctx; > + struct sk_buff *skb = _ctx->skb; > + int err; > + > + if (!skb) > + return -ENODATA; > + [..] > + err = __vlan_hwaccel_get_tag(skb, vlan_tag); We probably need to open code __vlan_hwaccel_get_tag here. Because it returns -EINVAL on !skb_vlan_tag_present where the expectation, for us, I'm assuming is -ENODATA? > + if (err) > + return err; > + > + *vlan_proto = skb->vlan_proto; > + return err; > +} > + > +static int veth_xdp_rx_csum_lvl(const struct xdp_md *ctx, u8 *csum_level) > +{ > + struct veth_xdp_buff *_ctx = (void *)ctx; > + struct sk_buff *skb = _ctx->skb; > + > + if (!skb) > + return -ENODATA; > + > + if (skb->ip_summed == CHECKSUM_UNNECESSARY) > + *csum_level = skb->csum_level; > + else if (skb->ip_summed == CHECKSUM_PARTIAL && > + skb_checksum_start_offset(skb) == skb_transport_offset(skb) || > + skb->csum_valid) > + *csum_level = 0; > + else > + return -ENODATA; > + > + return 0; > +} > + > static const struct net_device_ops veth_netdev_ops = { > .ndo_init = veth_dev_init, > .ndo_open = veth_open, > @@ -1756,6 +1794,8 @@ static const struct net_device_ops veth_netdev_ops = { > static const struct xdp_metadata_ops veth_xdp_metadata_ops = { > .xmo_rx_timestamp = veth_xdp_rx_timestamp, > .xmo_rx_hash = veth_xdp_rx_hash, > + .xmo_rx_vlan_tag = veth_xdp_rx_vlan_tag, > + .xmo_rx_csum_lvl = veth_xdp_rx_csum_lvl, > }; > > #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ > -- > 2.41.0 >