Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp899035rwl; Wed, 12 Apr 2023 05:50:27 -0700 (PDT) X-Google-Smtp-Source: AKy350bcsnrLflZgWSlvFK2nNaxkYhPPqugMOjamBZQIgmkd2e1ju74wVrkmhdwv/Z0kBJD742NF X-Received: by 2002:a17:90a:fe85:b0:23d:500f:e826 with SMTP id co5-20020a17090afe8500b0023d500fe826mr8771291pjb.14.1681303827600; Wed, 12 Apr 2023 05:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681303827; cv=none; d=google.com; s=arc-20160816; b=Pm53zh3gR73Vpqw5Qd3vemJlWvsAqF6aiROxTNj87TPMGJH+mRbJr2EjlkupEgN+IM VskYLE7IN8hPACJJy3T55Xpqujx+ZyXCprGgWxMfqK2XhY4oJ6O8ekJ+OvTn1h0wAxTV 5Mqo0dHzGyuCiNKOY72jnwRhDxWQEEtZRH4OuZEhGpg/3x2S9dVRhbtiUX+gBeDt4oJe eErUTC7QdbiF6Swd46///cO7BLApF7+UBQ4Gqfk75xo14p0COrbzVctTuVpHj1K6y0wR EW9RnuWFKYegWtv+bM/HXmln6m870zrl7v4ZTESI2LKfAmHsqsurfZAHlzgUBX8xgb3A QMtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=xPA/2DPgV7DkzsAGv07BeNJ4vzcmIchr5dPwJsagFdw=; b=msvgIqFFhXqYcTdC2rw2d9CblpvtFnNIzeO1wdHyqMPa8VtVQuK9dt/bdPbO4sJpjX 3hAv6C1b2odJveIFEOAXEg9w2gpsc1mDTI6n6rhACsxknzA14V4qRQciAl/2i0Wq5GAc GoC2SvcqTqeBrNm1glr9XfJz87ZVbD94oVMJrno3mV6o4pXMPIY2wDTqGTaWkMTbbvfT O+bAFur58r8ubPY4pIVD+F8LETths3mKn/FJjWwiwqGicU1iN/TFlxNy4Dpd0YWvHLvF ms7bxO4IXz0SNMVNVI22X4nXrCzwbasCGJVH9CutyoAHTGTnYF1OTPO+YFXTHIg0HYjE g/hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XlwodiYr; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j185-20020a638bc2000000b005193a2c7b24si9336887pge.473.2023.04.12.05.50.15; Wed, 12 Apr 2023 05:50:27 -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=@redhat.com header.s=mimecast20190719 header.b=XlwodiYr; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231557AbjDLMqC (ORCPT + 99 others); Wed, 12 Apr 2023 08:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbjDLMpP (ORCPT ); Wed, 12 Apr 2023 08:45:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B65C34C1F for ; Wed, 12 Apr 2023 05:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681303376; 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=xPA/2DPgV7DkzsAGv07BeNJ4vzcmIchr5dPwJsagFdw=; b=XlwodiYr12UVAuMWfvA3KpNXWizAyf2OeVQdMMK/CbND018iiPnuxs8ZAXHlGBGUdVDAlM SKKnoidbs+O2AtomTwX0QVZcoT6+tNJVT/OnyWbK5nru8gyAUZcCR6S/aslAX6Nal6khCw KO7lfVfph/cRQyaiaanWhLv+2KwWquk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-427-Zz-IJwvuPi6Z5sEwkERDlA-1; Wed, 12 Apr 2023 08:42:51 -0400 X-MC-Unique: Zz-IJwvuPi6Z5sEwkERDlA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 758671C09079; Wed, 12 Apr 2023 12:42:43 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2405B40BC797; Wed, 12 Apr 2023 12:42:43 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 38F48307372E8; Wed, 12 Apr 2023 14:42:42 +0200 (CEST) Subject: [PATCH bpf V8 1/7] selftests/bpf: xdp_hw_metadata default disable bpf_printk From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= Cc: Jesper Dangaard Brouer , 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 Date: Wed, 12 Apr 2023 14:42:42 +0200 Message-ID: <168130336215.150247.1088133245386431977.stgit@firesoul> In-Reply-To: <168130333143.150247.11159481574477358816.stgit@firesoul> References: <168130333143.150247.11159481574477358816.stgit@firesoul> User-Agent: StGit/1.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 The tool xdp_hw_metadata can be used by driver developers implementing XDP-hints kfuncs. The tool transfers the XDP-hints via metadata information to an AF_XDP userspace process. When everything works the bpf_printk calls are unncesssary. Thus, disable bpf_printk by default, but make it easy to reenable for driver developers to use when debugging their driver implementation. Next patch will add counters to track some of these cases. That will provide a hint to re-enable bpf_printk. This also converts bpf_printk "forwarding UDP:9091 to AF_XDP" into a code comment. The bpf_printk's that are important to the driver developers is when bpf_xdp_adjust_meta fails. The likely mistake from driver developers is expected to be that they didn't implement XDP metadata adjust support. Signed-off-by: Jesper Dangaard Brouer --- .../testing/selftests/bpf/progs/xdp_hw_metadata.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 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..b0104763405a 100644 --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c @@ -5,6 +5,19 @@ #include #include +/* Per default below bpf_printk() calls are disabled. Can be + * reenabled manually for convenience by XDP-hints driver developer, + * when troubleshooting the drivers kfuncs implementation details. + * + * Remember BPF-prog bpf_printk info output can be access via: + * /sys/kernel/debug/tracing/trace_pipe + */ +//#define DEBUG 1 +#ifndef DEBUG +#undef bpf_printk +#define bpf_printk(fmt, ...) ({}) +#endif + struct { __uint(type, BPF_MAP_TYPE_XSKMAP); __uint(max_entries, 256); @@ -49,11 +62,10 @@ int rx(struct xdp_md *ctx) if (!udp) return XDP_PASS; + /* Forwarding UDP:9091 to AF_XDP */ if (udp->dest != bpf_htons(9091)) return XDP_PASS; - bpf_printk("forwarding UDP:9091 to AF_XDP"); - ret = bpf_xdp_adjust_meta(ctx, -(int)sizeof(struct xdp_meta)); if (ret != 0) { bpf_printk("bpf_xdp_adjust_meta returned %d", ret);