From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mail.toke.dk (Postfix) with ESMTPS id 3CE63A158C0 for ; Mon, 3 Jul 2023 20:17:28 +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=MsgeRqns DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688408248; x=1719944248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=obF8cE3WIxLq5/vrUYreESvQgCSY6lL903Yd98z0GV0=; b=MsgeRqnsWb7f5Bxy5dhazpssFBfbtaidbFbj+6vtiYlddKjb0h8VxH+N lejwpFM4KHCNDmFc3cKRBpSL7659qD4DkuW00qXirmCyILcyA7TbPRhAB bkcSHIh/wqc6nfUUNIpKGGiuoU2ZiBSxHVxpLyo5QPtQwLoOw5z4POtDR o+NbS8kOvK2qvwl0XfDlat0GE4gsDSonVvKPo6GRmyHuF8VjWqoTqmD45 8JYeIrtqKJbB3jBVJ56hLPZECiuMbZW3z4CSbfzdJEeT0gCjUYBq2VVh5 Tl4uKMqGmp21v/BreERZYfmCK5oldbjBsK62ApisLCHDlsli5Xwptqykn A==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="393682788" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="393682788" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:17:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="892615173" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="892615173" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga005.jf.intel.com with ESMTP; 03 Jul 2023 11:17:22 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id C899335833; Mon, 3 Jul 2023 19:17:20 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Mon, 3 Jul 2023 20:12:26 +0200 Message-ID: <20230703181226.19380-21-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703181226.19380-1-larysa.zaremba@intel.com> References: <20230703181226.19380-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: VULDE6673L7CVHQKN4AV7YVN3RFDNZLA X-Message-ID-Hash: VULDE6673L7CVHQKN4AV7YVN3RFDNZLA 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 v2 20/20] selftests/bpf: check checksum level in xdp_metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Verify, whether kfunc in xdp_metadata test correctly returns checksum level of zero. Signed-off-by: Larysa Zaremba --- tools/testing/selftests/bpf/prog_tests/xdp_metadata.c | 3 +++ tools/testing/selftests/bpf/progs/xdp_metadata.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c index 50ac9f570bc5..6c71d712932e 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c @@ -228,6 +228,9 @@ static int verify_xsk_metadata(struct xsk *xsk) if (!ASSERT_EQ(meta->rx_vlan_proto, VLAN_PID, "rx_vlan_proto")) return -1; + if (!ASSERT_NEQ(meta->rx_csum_lvl, 0, "rx_csum_lvl")) + return -1; + xsk_ring_cons__release(&xsk->rx, 1); refill_rx(xsk, comp_addr); diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools/testing/selftests/bpf/progs/xdp_metadata.c index 382984a5d1c9..6f7223d581b7 100644 --- a/tools/testing/selftests/bpf/progs/xdp_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_metadata.c @@ -26,6 +26,8 @@ extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash, extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx, __u16 *vlan_tag, __be16 *vlan_proto) __ksym; +extern int bpf_xdp_metadata_rx_csum_lvl(const struct xdp_md *ctx, + __u8 *csum_level) __ksym; SEC("xdp") int rx(struct xdp_md *ctx) @@ -62,6 +64,11 @@ int rx(struct xdp_md *ctx) bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash, &meta->rx_hash_type); bpf_xdp_metadata_rx_vlan_tag(ctx, &meta->rx_vlan_tag, &meta->rx_vlan_proto); + /* Same as with timestamp, zero is expected */ + ret = bpf_xdp_metadata_rx_csum_lvl(ctx, &meta->rx_csum_lvl); + if (!ret && meta->rx_csum_lvl == 0) + meta->rx_csum_lvl = 1; + return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); } -- 2.41.0