From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; spf=pass (mailfrom) smtp.mailfrom=intel.com (client-ip=134.134.136.126; helo=mgamail.intel.com; envelope-from=larysa.zaremba@intel.com; receiver=) 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=MF+ngF9a Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mail.toke.dk (Postfix) with ESMTPS id 45255A2CBB2 for ; Wed, 27 Sep 2023 09:58:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695801510; x=1727337510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TUCra0VQt36VV4IdHiSrlZOdvZoSF4aLO7LlatDcyz0=; b=MF+ngF9a8SngnlYtTuj1tFcO9OcodqoKqPE0erJDy/Ao3brCE1J9OeWN ROc26ahk/SR2hCTIPmBZ2WsbLKRgwesNdARgk8ee0dfFrWfX6OqkummHc yin+IZ7rPymuifcMCJLjr54iARsB/7InxiT9AObJuLOwWETpiF4r4JgNc Hc9rvcBXRvQ0IkQQQQQEP5qyIXnZDLRjd3j9qA0J86iAYT4yk2OB0GYeB W4/Z2iGEhT1CWwjtNVi6mTTJhHUsUG4B6Ng98ZadfOl0UVLZn8pWGw3+G P7ktHStLLkpEfkAF7LZ4fL/4incJNSNFjVPKpd81pdzQ/mpY1UolDUxF8 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="366818183" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="366818183" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 00:58:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="725714074" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="725714074" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga006.jf.intel.com with ESMTP; 27 Sep 2023 00:58:23 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 857777EAC1; Wed, 27 Sep 2023 08:58:21 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Wed, 27 Sep 2023 09:51:18 +0200 Message-ID: <20230927075124.23941-19-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230927075124.23941-1-larysa.zaremba@intel.com> References: <20230927075124.23941-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: D2A6ANGBP7VU3SLHCTX5QIEWKHL5OOSI X-Message-ID-Hash: D2A6ANGBP7VU3SLHCTX5QIEWKHL5OOSI X-MailFrom: larysa.zaremba@intel.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address 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, Willem de Bruijn , Alexei Starovoitov , Simon Horman , Tariq Toukan , Saeed Mahameed , Maciej Fijalkowski X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [RFC bpf-next v2 18/24] 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 selftests, implement newly added XDP hints in veth driver. Acked-by: Stanislav Fomichev Signed-off-by: Larysa Zaremba --- drivers/net/veth.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 0deefd1573cf..b17938a43f98 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1736,6 +1736,46 @@ 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, __be16 *vlan_proto, + u16 *vlan_tci) +{ + 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, + __wsum *csum) +{ + 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 = XDP_CHECKSUM_VERIFIED; + } else if (skb->ip_summed == CHECKSUM_COMPLETE) { + *csum_status = XDP_CHECKSUM_COMPLETE; + *csum = 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, @@ -1760,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