From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by mail.toke.dk (Postfix) with ESMTPS id 6F602A1B2E9 for ; Fri, 21 Jul 2023 00:02:35 +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=3AbNINHL Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-55c475c6da6so654839a12.2 for ; Thu, 20 Jul 2023 15:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689890549; x=1690495349; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=MKkV/hvl8zsv9VEF8qSlJkJZ3nqSZuQ1lQ6/GJnu7hQ=; b=3AbNINHLLCKgzOX8OtpaOXEae3IR0N6cMtWa3+PYwW0ptaG+g8yQz2w9YvyusK26CO WMoxAwxDr45CXuT4Ld3gt18lvSvjuvMZali1nScoXOFKCA2u/sd1xTF8/akW+w5/ot6o BVT78J0sXyMd+oS3urUSStGbuRxmjHKOidJu54CM0Kt7F11E7iLZ7emDZgkKoVX7BvUA FtZixb2Ocmz/ufD+Q9McpKLDm9CQ2FMjsDda1yOw8HoN2NBDnu+bHLJ7AVyk6qXA4lqc Rr2c8+7PgSrcbYaxcl8hs6CfLoE/fba5ApbiGOOWL1rojtw0H/wCcPtvwSjkZ/GiT1z4 i/Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689890549; x=1690495349; 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=MKkV/hvl8zsv9VEF8qSlJkJZ3nqSZuQ1lQ6/GJnu7hQ=; b=NiyxyizcP9L3lzAtAB6z03UpjKCOlqItTBVuiNVSlz/LvVEx37ReZ19ho+5nEEOJTb NBHMy4vTuO7olu7Hl4y54eTlnzNCEvthphJ1S3vmsxjO8HNTw/7wTMbetPuJ8e1wQjqc iVcU3hGboQY66Xn4rfYygHyVUA3nuheDawTcZtvFdiGIDh4UHsIFNTkDiSTRiWgBn4WW oWwpROPRYPm4HDP+C1P/Mx2hwsF4DWgEDzp5jmdl8kFvGbKQiwfPDeOyHrnfIpb+uEnp TW1WCwCOwn+9xP8pX2CubY0MzFymW0MB7TUWvvxTPNVsZLntqps0sjWwa7v1RSxuPn+h oLOQ== X-Gm-Message-State: ABy/qLbvfPBPCpVtON/i/yv0OCzP3pp3XXBlkbaFU48gUn5P04jfF/B6 8bpyh2gqmouPy9rFaax68jUrgTo= X-Google-Smtp-Source: APBJJlHbKJzJBb962pqujdHLwOt8POeol8cf8FuiBme1npkxEvJgBOtXGPlBT0AIksLvSyslDoLEuL4= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:9507:0:b0:55c:2f9e:af2b with SMTP id p7-20020a639507000000b0055c2f9eaf2bmr34376pgd.12.1689890548729; Thu, 20 Jul 2023 15:02:28 -0700 (PDT) Date: Thu, 20 Jul 2023 15:02:27 -0700 In-Reply-To: <20230719183734.21681-18-larysa.zaremba@intel.com> Mime-Version: 1.0 References: <20230719183734.21681-1-larysa.zaremba@intel.com> <20230719183734.21681-18-larysa.zaremba@intel.com> Message-ID: From: Stanislav Fomichev To: Larysa Zaremba Content-Type: text/plain; charset="utf-8" Message-ID-Hash: 467ZO6QU5JVIRLMWBFEF2JLXRDN6AIDN X-Message-ID-Hash: 467ZO6QU5JVIRLMWBFEF2JLXRDN6AIDN X-MailFrom: 39K65ZAMKCWUVGIJRRJOH.FRPaGS-KLQWVaGS-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 v3 17/21] veth: Implement VLAN tag and checksum 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/19, Larysa Zaremba wrote: > In order to test VLAN tag and checksum XDP hints in hardware-independent > selfttests, implement newly added XDP hints in veth driver. > > Signed-off-by: Larysa Zaremba Acked-by: Stanislav Fomichev > --- > drivers/net/veth.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 614f3e3efab0..86239549120d 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -1732,6 +1732,50 @@ 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_tci, > + __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_tci); > + if (err) > + return err; > + > + *vlan_proto = skb->vlan_proto; > + return err; > +} > + > +static int veth_xdp_rx_csum(const struct xdp_md *ctx, > + enum xdp_csum_status *csum_status, > + union xdp_csum_info *csum_info) > +{ > + struct veth_xdp_buff *_ctx = (void *)ctx; > + struct sk_buff *skb = _ctx->skb; > + > + if (!skb) > + return -ENODATA; > + > + if (skb->ip_summed == CHECKSUM_UNNECESSARY) { > + *csum_status = skb->csum_level + 1; > + } else if (skb->ip_summed == CHECKSUM_PARTIAL) { > + *csum_status = XDP_CHECKSUM_PARTIAL; > + csum_info->csum_start = skb_checksum_start_offset(skb); > + csum_info->csum_offset = skb->csum_offset; > + } else if (skb->ip_summed == CHECKSUM_COMPLETE) { > + *csum_status = XDP_CHECKSUM_COMPLETE; > + csum_info->checksum = skb->csum; > + } 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 +1800,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 = veth_xdp_rx_csum, > }; > > #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ > -- > 2.41.0 >