Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1259118rwl; Wed, 12 Apr 2023 10:09:30 -0700 (PDT) X-Google-Smtp-Source: AKy350ZZ5ElLZg767rH3QiN1P1xNNhswwjNXdeogom6JXC/HeqwLWPGH6FUiGuRyHFI0a7GjYOyv X-Received: by 2002:aa7:979b:0:b0:637:d692:fbda with SMTP id o27-20020aa7979b000000b00637d692fbdamr10688153pfp.6.1681319370479; Wed, 12 Apr 2023 10:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681319370; cv=none; d=google.com; s=arc-20160816; b=Va402GEzjbZXniFC5+U2Rnj21oyzCIGaJ6Wn6TJ+2EnXDrkxcrYyt4Er27j+X78tg2 TgoPxsHq/i1Wm4A3IxaGEPqBIvc60un7ZG4af07LFhXOuAZwZwtDk+iA+eEHDiBv0H7m mebGH9P3qf4UQ9DSBPYywPEr5oYc0nfs3B7I1oroPXodyBcX4mowSAgd5oGaRbdJ4bJn 5ppBcWbMc47ThK/oxf7s7SkstjUQSTZEKifhc9hlO1eS2sgh1TYVjC7Yb5PuvWzKDP/+ YLxTUxwjlW2U2LKaq88z+H+wlPf3gAZhn8slSNtZYR9VOgQjqTI1y4/DCaQLTqNsVnCB 1ZqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=r5aQP8BO2zo9XrojS0bD6j1oYwbTGaaKe2CEIkMg+Cc=; b=fxHnvz7PfL8wpN+sZdAK1mStsjzgb8bP1fmWUuwftf+Hi80so6og475rZSDj2FSv4C 2S0HJEiQSSgYNU4EhCNhXBVEB2IyTUCQbq9Vx3wt5vdNuYX7HocB7MRM/Jz5P38yOoeR UK7td5cQFdxjUPjjwyjtr97sQcrAq1CnI8CJkZltmtM6LvlPzagckvgDMP/T0Xd4XMEf ezzWprIOtT8YV1ldDbdbvOkvNQw1VcLHbu/eKwZ7QiCEYwO9WtBlgJ7ELtLtn20AxiHH +Ujb14+PG9Cof7LkP8V0sfXPM0YGuwaCj6WA7oRpynTZ7FUULa8LISvxZnp3vJ2nV2SX I2HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=oVLoNRJY; 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 y19-20020aa79433000000b0063b1f577d29si753273pfo.192.2023.04.12.10.09.17; Wed, 12 Apr 2023 10:09:30 -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=oVLoNRJY; 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 S230044AbjDLQ4i (ORCPT + 99 others); Wed, 12 Apr 2023 12:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjDLQ4e (ORCPT ); Wed, 12 Apr 2023 12:56:34 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37CA59ECB for ; Wed, 12 Apr 2023 09:56:07 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-6345d4c8b25so777633b3a.0 for ; Wed, 12 Apr 2023 09:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681318563; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=r5aQP8BO2zo9XrojS0bD6j1oYwbTGaaKe2CEIkMg+Cc=; b=oVLoNRJYCUybQHOCGDc1/+VV+Wd3aSZ7iKoewHhOxr1x7l07u7jhjgNxGtvZ+BZiGP c0df6kLIh/auurIKDofimLBIjub63gz2i2tflYknIZNj2NnK506IT3EyqDEs7OBDGJOw Du1gx6ak04OGqUV5ei38bvHmLTob16K6WNbOzXVmiZCC6zqQc5aP40cItoZfBTFJxJiR Oj7oWnxeVM3mdxoWqLd4ZHyFIzGKvXmkUTBFIJzsVjT/MUQkrsa9QNrCYmRFOXRLWd9b TEA6YsK/kVrHl8IF0FY22x7gwd2A6zHfKONJF6sMgQaCSt1EUuPHDQUfPHyBBvBBj1Nf kzrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681318563; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r5aQP8BO2zo9XrojS0bD6j1oYwbTGaaKe2CEIkMg+Cc=; b=LKTW0A97TErqPtHxb5VVK2/nEMoEwu/0wQa1wLyKKEmJJgT01LIZnYpveXAUEguXuy zcQmpMxb0yTs/mUgBKtopRW/c+Z7fBcfgMiog1qIRM0uTq0uhUgZQHsWaKR19bOeCqzI bGTnkrTywVwkda0sRibwhZMJqhAvvwJQyFrGxa75DM7pEFNwS0ahxXFtIdGxA6ix/UcR 0Ed3ss/bc+n8M7nTmd0ppX23TyLTrqJg+aAcC4f7KDrXizEgJXME8Y1g4od3r5bhPB+e P4KxIN919SdLkdu2K+EAGSnVwDRRiPDAgks2qV7jWAYRtzQZJOX+gEftmd/8u2r+cHSW LRVQ== X-Gm-Message-State: AAQBX9decoLWvj2/m83NVo1xKqEeC/+Z4X2JZnVvWouB2W3roHrS1rE9 ynHMyAB4fRUnlszTwmB0u7Kjlc0= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a05:6a00:2d15:b0:62d:afc6:c152 with SMTP id fa21-20020a056a002d1500b0062dafc6c152mr569870pfb.5.1681318563183; Wed, 12 Apr 2023 09:56:03 -0700 (PDT) Date: Wed, 12 Apr 2023 09:56:01 -0700 In-Reply-To: <168130336725.150247.12193228778654006957.stgit@firesoul> Mime-Version: 1.0 References: <168130333143.150247.11159481574477358816.stgit@firesoul> <168130336725.150247.12193228778654006957.stgit@firesoul> Message-ID: Subject: Re: [PATCH bpf V8 2/7] selftests/bpf: Add counters to xdp_hw_metadata From: Stanislav Fomichev To: Jesper Dangaard Brouer Cc: bpf@vger.kernel.org, "Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?=" , 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="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 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/tools/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 = 0; > +volatile __u64 pkts_fail = 0; > +volatile __u64 pkts_redir = 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 = NULL; > } > > - if (!udp) > + if (!udp) { > + pkts_skip++; > return XDP_PASS; > + } > > /* Forwarding UDP:9091 to AF_XDP */ > - if (udp->dest != bpf_htons(9091)) > + if (udp->dest != bpf_htons(9091)) { > + pkts_skip++; > return XDP_PASS; > + } > > ret = bpf_xdp_adjust_meta(ctx, -(int)sizeof(struct xdp_meta)); > if (ret != 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? > + pkts_fail++; > return XDP_PASS; > } > > @@ -78,6 +87,7 @@ int rx(struct xdp_md *ctx) > > if (meta + 1 > data) { > bpf_printk("bpf_xdp_adjust_meta doesn't appear to work"); > + pkts_fail++; > return XDP_PASS; > } > > @@ -91,6 +101,7 @@ int rx(struct xdp_md *ctx) > else > meta->rx_hash = 0; /* Used by AF_XDP as not avail signal */ > > + pkts_redir++; > return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); > } > > diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c > index 1c8acb68b977..3b942ef7297b 100644 > --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c > +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c > @@ -212,7 +212,9 @@ static int verify_metadata(struct xsk *rx_xsk, int rxq, int server_fd) > while (true) { > errno = 0; > ret = poll(fds, rxq + 1, 1000); > - printf("poll: %d (%d)\n", ret, errno); > + printf("poll: %d (%d) skip=%llu fail=%llu redir=%llu\n", > + ret, errno, bpf_obj->bss->pkts_skip, > + bpf_obj->bss->pkts_fail, bpf_obj->bss->pkts_redir); > if (ret < 0) > break; > if (ret == 0) > >