From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mail.toke.dk (Postfix) with ESMTPS id 76D1CA17637 for ; Thu, 6 Jul 2023 14:06:10 +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=UANCaz0h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688645170; x=1720181170; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=F7mJtOnOCj5Y4V22tVM5iUeytiAQYiX6kkpuJpAe2PE=; b=UANCaz0huAZ0gLNgSj7YMJ1akq+Dg/HW1K7hUhFFvhIHH9PYnQJC1Uak MKzU328Zrmu97CzWmOZhAuPiGTN0GkNNdRs3CWCFZUJgqg64nv1p/tMpr NBHiZlUpsOstzX7tH7SWCgKmMaJtbnUEpXvy2WkTcBSTuEhYXJD1p2mGD Cq+9zzLq/EKk36foUHlj461iofSR3z/lg4HLeJlpNDnAfCZSu7GIdNoy3 PHmidGfFvOnubnnFN4M2TIir79+e2I7MPEDv8KeK7lcV9ha6PUY/I2nx8 Bu2j2n9S9+2pSybGZKd03HNkweV8Y9Sk45cxxyzfApdJFpdqGb12Ni80d w==; X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="343174271" X-IronPort-AV: E=Sophos;i="6.01,185,1684825200"; d="scan'208";a="343174271" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 05:06:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="722766831" X-IronPort-AV: E=Sophos;i="6.01,185,1684825200"; d="scan'208";a="722766831" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga007.fm.intel.com with ESMTP; 06 Jul 2023 05:06:06 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 6 Jul 2023 05:06:06 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 6 Jul 2023 05:06:05 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Thu, 6 Jul 2023 05:06:05 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.177) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Thu, 6 Jul 2023 05:06:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kNkKIA+Elq8s4JtGhVaYdI7bv5Aw0QcfXIoFvdys8J2uNj0QpR44RAUegp2iIib3fiCNxsbHg2x6CVlgcPQdYNI041+ZTcgrkvjWLnjySdHwsZnTitp2UfWNjjFUH3Rcu+crEidn8xUu/19oNoXcDLJynqOR7Lz59nJqniNHkcPSSK7cgyrPM49I8p4BCAGt/60pnNpFYptGLSs6+kA+i2uUhruOX4v16B8RdlGuh2Ymz6AOa9Q8thc/ZhLOw2SG5opqPEeNnemFclyq8hkhnvZoEvm6z1BANFoDl4Pq2A3ALjHltYaohfp+9eH039l6E0RrbvZEheqL6TA5yzWZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cgOAVpOeEXM8sr9DyNJY1AdYjXXOqry624BnT5LG+uc=; b=gQZ0KxR3Tbzdjyj0C9rtypFr2o1Z+qbQW3lvk7pt/Pz5J/s+Dg1ilQS+mk7pOe97p4lB1vqlQhA1fKjBGudy/jeQkCf4AoY3TaNI+9UcN1uLfT9OShjRaqd/XNPNQNuaOGhNTLeXF8R0KHyoL561ZOzLHT+KUvxqg7r1V3Jwdi/m+A3NRk3es0UhjQCfdmp2k5Lrg3Ra2CAkZK6Z5xQLVXoNX7o7PSQmVedSt2XAqNERZs4cAA81p+F4Y3sPwnr4jwUqHRKTq5uwAjpG+PiabLf3B6e0FC22SrfEoXBNKoyJcwZj8ttEie+5S0blJff+saDcFOt10j0StQNQFZ0oxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SN7PR11MB7540.namprd11.prod.outlook.com (2603:10b6:806:340::7) by PH8PR11MB7022.namprd11.prod.outlook.com (2603:10b6:510:222::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Thu, 6 Jul 2023 12:06:01 +0000 Received: from SN7PR11MB7540.namprd11.prod.outlook.com ([fe80::9376:9c9d:424a:a0fe]) by SN7PR11MB7540.namprd11.prod.outlook.com ([fe80::9376:9c9d:424a:a0fe%6]) with mapi id 15.20.6565.016; Thu, 6 Jul 2023 12:06:01 +0000 Date: Thu, 6 Jul 2023 14:02:00 +0200 From: Larysa Zaremba To: Jesper Dangaard Brouer Message-ID: References: <20230703181226.19380-1-larysa.zaremba@intel.com> <20230703181226.19380-21-larysa.zaremba@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BE1P281CA0289.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8a::16) To SN7PR11MB7540.namprd11.prod.outlook.com (2603:10b6:806:340::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR11MB7540:EE_|PH8PR11MB7022:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ee354fe-7dfc-472e-ae21-08db7e195c99 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FTEyHhi7FDYTa1Ne/zRpL8jt/TTxDFU61F7MW12eeVgJo9TJofPGB/FnbeIMS6yfdq+TE3n91fq9e+MxnX9hGOzOp4aJBmxu0rwCNf1fCpTTVATOrOQzlgXNXzN8cdPM2QZOCCVLJueS7D92imSVpqiC8Da4xZhrCwQ9/rkzB3YHWXEoSIFWWROkS1GufphGUEaWKctKB3aaiBtfA3didk24cHlRuGTcRa78nHN/YmA84YlDFSmA0sheXape/DmNVpAoiDPK/XrKqcGnxvsLaB1K2bSgZpSaMEKm+1RqZkrwYn7Ei0mFUcL1Cq3oswjHZyY6FhV3BYTOMj6nJEHLxDjB66gV9d3IAe4WPwwTyIm0lNJ6KbkK+1VwkdDHnL2YG8B5xFgraV7o5hi++NjptS+6ndMXoSAYT0BjkS0ZNAeoCKt4uSSkbvecjnGgiSPVbIIECxdeHDjDXZjUUdy3uq4vDtgxMCdl3VLIP7JTj+e2Vus0RNVIxMWquK9pa/dw02l73BXaRK7/zMxlReX2lqMTyb00OmvTAjE7tcS4WFQqdFMyJvlRMW5sMpLh7yOZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR11MB7540.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(7916004)(366004)(39860400002)(396003)(376002)(136003)(346002)(451199021)(33716001)(2906002)(41300700001)(7416002)(44832011)(8936002)(8676002)(186003)(6506007)(478600001)(5660300002)(26005)(6512007)(9686003)(82960400001)(86362001)(6486002)(316002)(4326008)(6916009)(66946007)(66556008)(38100700002)(66476007)(54906003)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bqKCKiyfkxkmcmGvHIkn/TfU2Z0FLhQ3UnWLTrrXAXgFhf/g0gRTkHyKuSS4?= =?us-ascii?Q?QB5ZYCJ7yWB9sSJgcLhM18ALtKAG8JocgBsKTmnwhSmTDxvtKqilUDP/ykl+?= =?us-ascii?Q?pZW8qEAJzuGCZEeyWAWl6g3a8pFrjRp1CBaDlCjQ0N08oEtHLtioUWKf1g43?= =?us-ascii?Q?fnJw9qkKwkI6UZ+pEwkDJFUhZyZ4W4BGEcbyic0L1X0bRhzW0XXTKaQHmBRg?= =?us-ascii?Q?6dhPOFtukmXFabigO5MamN/Gy8UA732CWye+maes6lbfZAHfsflNEnyTgyuc?= =?us-ascii?Q?Uiy/b2SVwHcPOWLW5FgQv1q5Kc22slzfyFIFKDCJhrNhtR7iYm0jb/Hr93IU?= =?us-ascii?Q?SblLZ4nmD6v55v8LOruSUeWiArFODSsg6arOVWXV1K3QWddjFs+tw9DaepHI?= =?us-ascii?Q?xwROrttqF/d5b+FzFp0W0RKO6U8vxoqM0jrzyZrYtIeG6pHoN2Ezyh+uHIrD?= =?us-ascii?Q?OCTdcqpyZ2yxF35xo0GmHlw+WOTM752M/rHFmOQBSUuxqMsG1QFBzu0atMJJ?= =?us-ascii?Q?zRWZwfT0gRJZ6lAeJloHDYKAA/8kzkt/pa5iZTFAnl+vzIpkMlfdJ+D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EfIoRKybEd93bZEaVUcqDjJdtU5fMJ3LwLt?= =?us-ascii?Q?Es3UaJ9jiL/kQu0uwPs/dBs82EWbPBeMuzYLMIP6KwAErtrWFTUKg5/ilg5D?= =?us-ascii?Q?zOZHadpPVzbaXwqllk76sVAPcngfyLFEsnNcRsnnP2ORoezNC1Ub7CUF70zh?= =?us-ascii?Q?QA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7ee354fe-7dfc-472e-ae21-08db7e195c99 X-MS-Exchange-CrossTenant-AuthSource: SN7PR11MB7540.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2023 12:06:00.5609 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c/XPLeTZRXeVuKacuk4Hpj59fZNQeYgpH16iDo/5Uk5XeWyih7L3E0sUBVZThLzpOXkmU42uBdDXzlfUsqVIUAnuU87aPEYGrkq6lnouwJo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7022 X-OriginatorOrg: intel.com Message-ID-Hash: RDJBKI74O4S4CZPA4HT7CD3ZR7ALEDZW X-Message-ID-Hash: RDJBKI74O4S4CZPA4HT7CD3ZR7ALEDZW 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: bpf@vger.kernel.org, brouer@redhat.com, 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 , 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 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: On Thu, Jul 06, 2023 at 12:25:10PM +0200, Jesper Dangaard Brouer wrote: > > > On 03/07/2023 20.12, Larysa Zaremba wrote: > > 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; > > Not-equal ("NEQ") to 0 feels weird here. > Below you set meta->rx_csum_lvl=1 in case meta->rx_csum_lvl==0. > > Thus, test can pass if meta->rx_csum_lvl happens to be a random value. > We could set meta->rx_csum_lvl to 42 in case meta->rx_csum_lvl==0, and > then use a ASSERT_EQ==42 to be more certain of the case we are testing are > fulfilled. > I just copied the approach used for timestamp. I think you are right and I should have make the new code better. ASSERT_NEQ(0) is also used for rx_hash. It would be a good idea to go and fix those too, but the patchset has already ballooned too much for me, so I would leave it for later. With ASSERT_EQ for checksum level, I think comparing it to "1" should be enough. Do I guess correctly, the main problem with ASSERT_NEQ is uninitialized memory? Another value that is less magical than 42 would be "4", because csum_level takes 2 bits, so it is the smallest value that does not correspod to any valid checksum level. > > > + > > 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; > > + > > IMHO it is more human-readable-code to rename "ret" variable "err". > > I know you are just reusing variable "ret", so it's not really your fault. > > > > > return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); > > } >