Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1390596rwl; Wed, 12 Apr 2023 12:04:20 -0700 (PDT) X-Google-Smtp-Source: AKy350ZIs/WutewskCnX3dr1tq1VUe/itiQQAPuLmacfSY1XG2p8ef8mqCMQkU9bfoAzUPsCpGUs X-Received: by 2002:a05:6a20:b056:b0:da:4be2:caff with SMTP id dx22-20020a056a20b05600b000da4be2caffmr7404528pzb.56.1681326260039; Wed, 12 Apr 2023 12:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681326260; cv=none; d=google.com; s=arc-20160816; b=v/Fxeq8D9JACFso0YDElp2J5a8yIJAFwBTDgeASAbdv5Jx/5ETlKkvNh1fK6WwKvaR loW16TLh7lTGuy3mRxmK/eAIdHTU4v0+zoQ8UXttEeJtEsNO0zILkay6jeGPvA+OHo4/ nfpK6Q1nCMvxRtNA+90rOVEb8G1bkU5ldU7vafMOhB1L8UKAlnmvrsjriR2vgWuj6jEc yHjAQ/lcssPVXrKf+Z51slEW6ERdn7aPfhDJE6TVTsnK6mECVo7vGDc7Guqj+YhNiceI wUCTCD8f328O2o+VcN8ltvYoB6V1WhOIgeOgVgBwo6jo8NwhbMxtfF08rTvjKA2vcQPJ /a3Q== 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=sHYXkYaef6xMNFmaZnkKzH+IKK7bhNbi9t2F6EAC6M8=; b=d1rO/6rgDRKEeRKd/DfH4TI+a/B8amxiBzz0kRSEXz4dEX903SxS+aUqRKa3q22xDu 8wg9WlQdOX3g8I67s8TO+ILAGQA5S2/rMOpKt+6zoDnJrs0Q1hw8QJzf2N3twmb3XazT atq+Z/klosgUjCeyGPhn4+dWy+TMxHVIGQTkXDg7GiWvhdipxvugk6i+0IZB4F2v7nt3 gClfKojqUGo+XFxK/hvInZ4rSBnv/sBO5gHMFWPj3UfDaa7Be/coA5xQA4TNGfKxL0dj /0bdqtPSaBd+Z9vO1/H0AY+59YaRErhuRQ8RmidJ4cd/4SAWDB7o6YCcIm0ZGfePEopd 9CQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=TuoQ6JVK; 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 c85-20020a621c58000000b00636d348c55asi9714738pfc.18.2023.04.12.12.04.08; Wed, 12 Apr 2023 12:04:20 -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=TuoQ6JVK; 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 S230291AbjDLS5d (ORCPT + 99 others); Wed, 12 Apr 2023 14:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjDLS5b (ORCPT ); Wed, 12 Apr 2023 14:57:31 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B493565B6 for ; Wed, 12 Apr 2023 11:57:04 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id e63so6253053pgc.4 for ; Wed, 12 Apr 2023 11:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681325821; 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=sHYXkYaef6xMNFmaZnkKzH+IKK7bhNbi9t2F6EAC6M8=; b=TuoQ6JVKp2k/cFPXNyeuO/F/TOiztKMjN9sXg8H64JYl6kg3bdh2aWRaJL6RRsNcKW DJOzoEtWM9RiDETkmdPHNEJQUN+f4QvXeR28ACr0ns+ASVmBQTaFxSYOJguvjPSXOf/L 1A4RSQ6Q16cm87R23Tqns/d9AfqB7Tb41aTuaFulG/wxXXKGEK8DcriRQVZne1xIxoIa wrOUXDRrrYKApE4p6AVzkwq942bKDane/X3ICADPACDDMki5/AEJkV0+9eHSOdLC/1ni j8Y+H2FjR7EyDfl1hNal8++dP0IIQNIgQHybab0EHhxH23u5mcmzQakJzPmfMb5rsN4f FtUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681325821; 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=sHYXkYaef6xMNFmaZnkKzH+IKK7bhNbi9t2F6EAC6M8=; b=jp7f1XN6126OkjVgh09AMLgTwQAGGvO4JUDVo/u6YBjIpNd6fDMBPCr/eEdukCR7RL Vfk0dpV1ZvTRZEwwU7WND7oiY418ISvZYEv+WFwjNwYvsQyKPPGAoM6py9RcLTQc5QV4 IyrbDtFTBOYl8BrY5vJdpgxSyqAzVDL6s7zWb79NjYf/OMDXecEbxp2u8ICeugLLLH8c HFZuSAy45TteTSDshn1Jaz6uoC4KsxCJqGH+hZU1OhE9s3P7VoQ1qVNl/dJg8ZrPQX3H ILaQ/yMI1/KVPP5we2yTiB7Jbx9g8fP6+rTjlKeiYR+J6gG/XTwSECGwKM80mL+uzi9B A64w== X-Gm-Message-State: AAQBX9fcisdQKLwR6NRGI2xZlIjXsclhXxicxSc4S3z8bT+pnozYzwM3 Zo/SdDiGUio5KGdKWw84h3FTbf63LTEsr80jCvos9w== X-Received: by 2002:a65:4681:0:b0:513:6b94:8907 with SMTP id h1-20020a654681000000b005136b948907mr880151pgr.1.1681325820765; Wed, 12 Apr 2023 11:57:00 -0700 (PDT) MIME-Version: 1.0 References: <168132448251.317773.2526885806604122764.stgit@firesoul> <168132451707.317773.15960209122204110352.stgit@firesoul> In-Reply-To: <168132451707.317773.15960209122204110352.stgit@firesoul> From: Stanislav Fomichev Date: Wed, 12 Apr 2023 11:56:49 -0700 Message-ID: Subject: Re: [PATCH bpf V9 1/6] selftests/bpf: xdp_hw_metadata remove bpf_printk and add counters To: Jesper Dangaard Brouer Cc: 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 11:35=E2=80=AFAM Jesper Dangaard Brouer wrote: > > The tool xdp_hw_metadata can be used by driver developers > implementing XDP-hints metadata kfuncs. > > Remove all bpf_printk calls, as the tool already transfers all the > XDP-hints related information via metadata area to AF_XDP > userspace process. > > Add counters for providing remaining information about failure and > skipped packet events. > > Signed-off-by: Jesper Dangaard Brouer Acked-by: Stanislav Fomichev nit: maybe those ++ should be __sync_add_and_fetch instead? Then you should be able to drop volatile.. > --- > .../testing/selftests/bpf/progs/xdp_hw_metadata.c | 36 ++++++++++++--= ------ > tools/testing/selftests/bpf/xdp_hw_metadata.c | 4 ++ > 2 files changed, 24 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/= testing/selftests/bpf/progs/xdp_hw_metadata.c > index 4c55b4d79d3d..8a042343cb0c 100644 > --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > @@ -12,6 +12,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, > @@ -26,7 +30,7 @@ int rx(struct xdp_md *ctx) > struct udphdr *udp =3D NULL; > struct iphdr *iph =3D NULL; > struct xdp_meta *meta; > - int ret; > + int err; > > data =3D (void *)(long)ctx->data; > data_end =3D (void *)(long)ctx->data_end; > @@ -46,17 +50,20 @@ int rx(struct xdp_md *ctx) > udp =3D NULL; > } > > - if (!udp) > + if (!udp) { > + pkts_skip++; > return XDP_PASS; > + } > > - if (udp->dest !=3D bpf_htons(9091)) > + /* Forwarding UDP:9091 to AF_XDP */ > + if (udp->dest !=3D bpf_htons(9091)) { > + pkts_skip++; > return XDP_PASS; > + } > > - bpf_printk("forwarding UDP:9091 to AF_XDP"); > - > - 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); > + err =3D bpf_xdp_adjust_meta(ctx, -(int)sizeof(struct xdp_meta)); > + if (err) { > + pkts_fail++; > return XDP_PASS; > } > > @@ -65,20 +72,19 @@ int rx(struct xdp_md *ctx) > meta =3D data_meta; > > if (meta + 1 > data) { > - bpf_printk("bpf_xdp_adjust_meta doesn't appear to work"); > + pkts_fail++; > return XDP_PASS; > } > > - if (!bpf_xdp_metadata_rx_timestamp(ctx, &meta->rx_timestamp)) > - bpf_printk("populated rx_timestamp with %llu", meta->rx_t= imestamp); > - else > + err =3D bpf_xdp_metadata_rx_timestamp(ctx, &meta->rx_timestamp); > + if (err) > meta->rx_timestamp =3D 0; /* Used by AF_XDP as not avail = signal */ > > - if (!bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash)) > - bpf_printk("populated rx_hash with %u", meta->rx_hash); > - else > + err =3D bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash); > + if (err) > meta->rx_hash =3D 0; /* Used by AF_XDP as not avail signa= l */ > > + 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/testin= g/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 rx= q, int server_fd) > while (true) { > errno =3D 0; > ret =3D poll(fds, rxq + 1, 1000); > - printf("poll: %d (%d)\n", ret, errno); > + printf("poll: %d (%d) skip=3D%llu fail=3D%llu redir=3D%ll= u\n", > + ret, errno, bpf_obj->bss->pkts_skip, > + bpf_obj->bss->pkts_fail, bpf_obj->bss->pkts_redir)= ; > if (ret < 0) > break; > if (ret =3D=3D 0) > >