Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1324303rwl; Wed, 12 Apr 2023 11:03:43 -0700 (PDT) X-Google-Smtp-Source: AKy350a82JcPCNjjz6g3HnO2wjMe7EvUbxMxCsHqQGmEEMdyNAb7a/2LD3+e9V5NCO0H0E8MfW/2 X-Received: by 2002:a17:907:7714:b0:94a:52b0:52a7 with SMTP id kw20-20020a170907771400b0094a52b052a7mr14015902ejc.24.1681322622750; Wed, 12 Apr 2023 11:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681322622; cv=none; d=google.com; s=arc-20160816; b=M9fGVWAVECX6pxyzwe5XqBkHgiwhvvNfY0hMSH2eC2BKDfbrmwflIPG9l8kQUWuR5R gegPkXxfCqNZaX9I3ExxtcGgnKO2XUNg739CsjglW4fWbBDUEHynVY80JHpoAM6LFvr9 DI5rrkOXm43TlJub57kWeYRqFPbnTgUHzCfhIYRZdIn/jLeFx3LczKX5+Q3K8I0AeKh/ sRCbKqzRDbysKORFqkafh/oqHM2gRht+AkexjW+nZuFh3hFwE/QUmsEQlW1VP+oV+63X 3iKvQimBE0rzXP1ZzZPNyxkU1acClVR//N0SN1XOT2ywpIz79thZc5GOUZm0zs4KhDW7 E3cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=qC0J8ipO5xQolwxkiv40AtEnP8cuuUuoL3jFk2sT+xU=; b=b+qijzIjp0gvxZSpTxCizEmj4JRE8CqqvkOXZRJLSAurgw+Bo89sk3dVTay/J/zN2G Kee9zHtRNPQ43Z1YB2M/MVh2QCYoSLGyDMs8mU9lFN9RTkx1y0RQeJy09mcEy18DV+Ja IXIr0JC+xw1Dp9jXjmPyHLCrbnCJDiUh5fsA2notHVLprf4fY8Mrugy0k3jvs5/Bll/r 0B0wOU1t0cDbrwdbMLbvaNZg9A6gZMCypxCLshwhMI8hqWXrfvKPB7AI4qZq78iRNk2F dXVWBaBVnKapjam0Fwvjf3iEPYRhj1Mhijzj4hLxVqi863dSTXX4gTxyx4E5RT0C6WTQ tq2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=av8In+Ii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wu1-20020a170906eec100b0094a48329974si6663395ejb.281.2023.04.12.11.03.16; Wed, 12 Apr 2023 11:03:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=av8In+Ii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbjDLR4a (ORCPT + 99 others); Wed, 12 Apr 2023 13:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjDLR42 (ORCPT ); Wed, 12 Apr 2023 13:56:28 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86F4B59F3 for ; Wed, 12 Apr 2023 10:56:26 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-63b145b3b03so1135788b3a.1 for ; Wed, 12 Apr 2023 10:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681322186; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qC0J8ipO5xQolwxkiv40AtEnP8cuuUuoL3jFk2sT+xU=; b=av8In+IitDjEfmXBb9r8y8s0KgzNn33ghSZo9Q/jk4j+WAQ5n6xIBxI+GILpW98Qjw oKqYBzlcPSNfQuz1T69VJyUyRwvNF/j1lnG0AMnQtClFfd7W6vLOWA8ExKcFUGkAMoiL c+KXy6wLSah2RlGIMcie47xhVxhomLX2VJIb3ltpPCiVYD5+ca2hswJ9XChNykGs4tdB VwdC+KKIT3eSVFNuUeV4lTAhDPDqIXvieEuOSL97MDHwy0um3O9kg91OHYu2xjAT975e VAVOVzTiaIMUEkK7ELglagPtiCc/pLzAjvdlMLzVHhW6Pajbj2DDxksiWeVuMvgLYttB KqPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681322186; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qC0J8ipO5xQolwxkiv40AtEnP8cuuUuoL3jFk2sT+xU=; b=Aox7+M6FBz9DWAEML+h0GxX7YeNd9uJbxJ6Po6fHkvgAVLqnF4ea0doaTuKkBUcZYz 968To/poW6goOdEjlIW6ZYZJfE+7bWmcOVsIjKutOOmhlzGKIYddFBUCYAO/PE9SCnB6 T61e/GuObAVfu4pXPO25NJhg+N3qJ+UTqvVxxPODBIT3aUO0CEnFzTpzD7C5X6OO6cMm WqqNMA6Ryoz4Ul2lJLHaKNtgNqlM082howGvj7ARZBFTvp38TYZkJtMc18cJ+TA8e7iz xsWjf7cXq6dtOkKx7WDzQdtVuEA7h/VmeYlndAXW3moyCAvy2T0Cpc5iQIKaI6LUrFTt hkeg== X-Gm-Message-State: AAQBX9f/uH5AgNVWqtfsZ0CD7EIs2hD+GOKka3KOgOcTnhlCQOhDkGt2 cPwJ0FvFy+biyaq1Ip8KVX5G7FbriPBPDlDDMwexhw== X-Received: by 2002:a05:6a00:2d22:b0:632:e692:55b2 with SMTP id fa34-20020a056a002d2200b00632e69255b2mr1762332pfb.2.1681322185562; Wed, 12 Apr 2023 10:56:25 -0700 (PDT) MIME-Version: 1.0 References: <168130333143.150247.11159481574477358816.stgit@firesoul> <168130336725.150247.12193228778654006957.stgit@firesoul> <34152b76-88c8-0848-9f30-bd9755b1ee25@redhat.com> In-Reply-To: <34152b76-88c8-0848-9f30-bd9755b1ee25@redhat.com> From: Stanislav Fomichev Date: Wed, 12 Apr 2023 10:56:14 -0700 Message-ID: Subject: Re: [PATCH bpf V8 2/7] selftests/bpf: Add counters to xdp_hw_metadata To: Jesper Dangaard Brouer Cc: brouer@redhat.com, bpf@vger.kernel.org, =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, martin.lau@kernel.org, ast@kernel.org, daniel@iogearbox.net, alexandr.lobakin@intel.com, larysa.zaremba@intel.com, xdp-hints@xdp-project.net, anthony.l.nguyen@intel.com, yoong.siang.song@intel.com, boon.leong.ong@intel.com, intel-wired-lan@lists.osuosl.org, pabeni@redhat.com, jesse.brandeburg@intel.com, kuba@kernel.org, edumazet@google.com, john.fastabend@gmail.com, hawk@kernel.org, davem@davemloft.net, tariqt@nvidia.com, saeedm@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 12, 2023 at 10:52=E2=80=AFAM Jesper Dangaard Brouer wrote: > > > On 12/04/2023 18.56, Stanislav Fomichev wrote: > > On 04/12, Jesper Dangaard Brouer wrote: > >> Add counters for skipped, failed and redirected packets. > >> The xdp_hw_metadata program only redirects UDP port 9091. > >> This helps users to quickly identify then packets are > >> skipped and identify failures of bpf_xdp_adjust_meta. > >> > >> Signed-off-by: Jesper Dangaard Brouer > >> --- > >> .../testing/selftests/bpf/progs/xdp_hw_metadata.c | 15 ++++++++++= +++-- > >> tools/testing/selftests/bpf/xdp_hw_metadata.c | 4 +++- > >> 2 files changed, 16 insertions(+), 3 deletions(-) > >> > >> diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/too= ls/testing/selftests/bpf/progs/xdp_hw_metadata.c > >> index b0104763405a..a07ef7534013 100644 > >> --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > >> +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > >> @@ -25,6 +25,10 @@ struct { > >> __type(value, __u32); > >> } xsk SEC(".maps"); > >> > >> +volatile __u64 pkts_skip =3D 0; > >> +volatile __u64 pkts_fail =3D 0; > >> +volatile __u64 pkts_redir =3D 0; > >> + > >> extern int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, > >> __u64 *timestamp) __ksym; > >> extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, > >> @@ -59,16 +63,21 @@ int rx(struct xdp_md *ctx) > >> udp =3D NULL; > >> } > >> > >> - if (!udp) > >> + if (!udp) { > >> + pkts_skip++; > >> return XDP_PASS; > >> + } > >> > >> /* Forwarding UDP:9091 to AF_XDP */ > >> - if (udp->dest !=3D bpf_htons(9091)) > >> + if (udp->dest !=3D bpf_htons(9091)) { > >> + pkts_skip++; > >> return XDP_PASS; > >> + } > >> > >> ret =3D bpf_xdp_adjust_meta(ctx, -(int)sizeof(struct xdp_meta)); > >> if (ret !=3D 0) { > > > > [..] > > > >> bpf_printk("bpf_xdp_adjust_meta returned %d", ret); > > > > Maybe let's remove these completely? Merge patch 1 and 2, remove printk= , > > add counters. We can add more counters in the future if the existing > > ones are not enough.. WDYT? > > > > Sure, lets just remove all of the bpf_printk, and add these counter inste= ad. > Rolling V9. > > >> + pkts_fail++; > > This fail counter should be enough for driver devel to realize that they > also need to implement/setup XDP metadata pointers correctly (for > bpf_xdp_adjust_meta to work). Agreed. As long as we have a clear signal "something's not working" (instead of failing silently), that should be enough to get to the bottom of it.. > >> return XDP_PASS; > >> } >