From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mail.toke.dk (Postfix) with ESMTPS id D473EA1ADB9 for ; Wed, 19 Jul 2023 20:42:21 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mm1h3r3/ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689792142; x=1721328142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6eCqrd/tJrcNtkU6ENkNwLxTMLeRwomH1yS2pbkdiRM=; b=mm1h3r3/jiq4hgf3naxLy6lUIix7W9f8aCIMIL/hWm73COz/t4xtL+Cv IzCmvYAy+mZA08RS9MciHPqPjpDVtkTTsdYJsUIneg2zLHEy7QoQ2NTzM EESFcS+kI7rnzLsgkPjM+VvXq23jb6pu3XUzXNb3PpIEpoFaLDBRYZUX6 9unmnjxADE4PC53riztoEqqy15KQl2MrCwOZMKglbnQcA55MPC28NXcgy f9rT8pHvilni5UzhMdcycHWobYFtawBWOHAKo5pbvIMpWuwYb5WFAjlIk RvmpIq8WXQSGLfdMWHkkU5SS2I4H/ayGxn5/pUAcNpRMp7Fy8+pWEKag7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="370111330" X-IronPort-AV: E=Sophos;i="6.01,216,1684825200"; d="scan'208";a="370111330" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2023 11:42:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="794146732" X-IronPort-AV: E=Sophos;i="6.01,216,1684825200"; d="scan'208";a="794146732" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga004.fm.intel.com with ESMTP; 19 Jul 2023 11:42:16 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id AB84B3581B; Wed, 19 Jul 2023 19:42:14 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Wed, 19 Jul 2023 20:37:30 +0200 Message-ID: <20230719183734.21681-18-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719183734.21681-1-larysa.zaremba@intel.com> References: <20230719183734.21681-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: JCGDHR4NKSPBEVUOHQ574ELPTXN3M7P2 X-Message-ID-Hash: JCGDHR4NKSPBEVUOHQ574ELPTXN3M7P2 X-MailFrom: larysa.zaremba@intel.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: Larysa Zaremba , 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, sdf@google.com, 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] [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: 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 --- 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