From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mail.toke.dk (Postfix) with ESMTPS id B20A7A1756D for ; Thu, 6 Jul 2023 12:25:15 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZXEAeRGq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688639114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XjvjrVrcchow6hGiOnuuMtRWRueWUenkpTgXIpZAAh8=; b=ZXEAeRGq2JvVSy103LLX9SVjOu0wZIAdK9A+aPMj5c5GKtW0WIMnJSUaqhkNwfxlZthQrg y/uacwhZdpvrPgthyioik6Zeb0222dLZ7XgLXP+LNHRVv9eRdo3CxCCWU3/jedSq6HofhF dLwruUnfrCpFW7oH951jZ8SAWi8gAHM= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-375-NhxRjP4mOJepOH2ksZQnrQ-1; Thu, 06 Jul 2023 06:25:13 -0400 X-MC-Unique: NhxRjP4mOJepOH2ksZQnrQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-987ffac39e3so44111066b.0 for ; Thu, 06 Jul 2023 03:25:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688639112; x=1691231112; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XjvjrVrcchow6hGiOnuuMtRWRueWUenkpTgXIpZAAh8=; b=iq+UV1mUvJzDUSWpf1P8BWWG4EBHulbjBA6zwUfi8yz9LWj16psc7r1mzl7EyhCtqE iVwmZMcamHRASecKU4jz9QsHi4e50HfAc5rsze2dUpaiA88DopfyPJsCi0k6Hb38Bhvc d+TXgFDVM/2D/19U75/IoWWL0kGpD+ZsKhePHwmpczU2iZPCQ/65/fI7SpjGOHpjBa8Q Hns5bmHU/fKR+gjrr5eNlvcZKKs+DbUbXCwZsq+6S5na3l1+echiGpXB22EWmpptLN/c 1mCctbTSc3e2P/KLEBrKrpOuB+2pxhGixf6UhRpjADElDE/7KLhM3C7nvYMNqtpO7liy BuTQ== X-Gm-Message-State: ABy/qLZ4E2pfTVjp6/k+PYwxdRwtP0/WblCa4L8A1b/86j8z96g4RDeW dvjoyCFU0FyWB85z7SIX972iii5ZQwCcwpGSWirDqsnZa7Zo/1GFyr55IDdX41qGpk5eQJyzwND 4qfoWtEhPdUY51Tp40X8d X-Received: by 2002:a17:907:3e82:b0:992:4250:545b with SMTP id hs2-20020a1709073e8200b009924250545bmr1377620ejc.47.1688639112073; Thu, 06 Jul 2023 03:25:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlFr9Hi21IV/P3pz9UBZySRhK0MYxzr2A35i5/1bhE3Uhj9GCjFNrePH9akO1T4VJzL3KX0U0Q== X-Received: by 2002:a17:907:3e82:b0:992:4250:545b with SMTP id hs2-20020a1709073e8200b009924250545bmr1377598ejc.47.1688639111809; Thu, 06 Jul 2023 03:25:11 -0700 (PDT) Received: from [192.168.42.100] (194-45-78-10.static.kviknet.net. [194.45.78.10]) by smtp.gmail.com with ESMTPSA id jt11-20020a170906dfcb00b009883a3edcfcsm628316ejc.171.2023.07.06.03.25.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 03:25:11 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: Date: Thu, 6 Jul 2023 12:25:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: Larysa Zaremba , bpf@vger.kernel.org References: <20230703181226.19380-1-larysa.zaremba@intel.com> <20230703181226.19380-21-larysa.zaremba@intel.com> In-Reply-To: <20230703181226.19380-21-larysa.zaremba@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: MLXNGE25T6LXYLXZZDFOYUCKEENI4PF7 X-Message-ID-Hash: MLXNGE25T6LXYLXZZDFOYUCKEENI4PF7 X-MailFrom: jbrouer@redhat.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: 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 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. > + > 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); > } >