Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3188156rwl; Sun, 2 Apr 2023 02:13:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2vfeOuWclGf7YB89+ypjYZMuvTWonW+aT1AAiMezk0fCT0M40CTkD/prZsNbCg7kkEbFM X-Received: by 2002:a17:902:da81:b0:1a2:914e:2d2b with SMTP id j1-20020a170902da8100b001a2914e2d2bmr13881313plx.19.1680426815974; Sun, 02 Apr 2023 02:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680426815; cv=none; d=google.com; s=arc-20160816; b=j9XJ84yKVwYeuefIFyy7RlhBA6dfNMsMC+26ce+iX0gI35Yp9gYWrjTU/VyPPLvPap n6iJC74YvYaYdifXGe5b3RKM5FMMQaQvT5aKmpId99q00H9AEsET+r9E8limoZsPcwrf +eHbUeAQeikLyLFruDsVPCDK66L0sc3dVRkyfH5MdzNhDxK+050pPTO0lY+UWsluRzSM L8kbVQ2NXvuOZhArQ6aRj9QHntl2l/rCdAFhsIFonWhfCyNSbM4btSvxu6S4xS4OunFq SLkKjivPilEB8cOq4ibPPxSDSTjxoUwmHmO+3Bnk+3JeRAfA3n+4jUS6kfYgP1rnPqMC k1oA== 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=7ph+xCj8xMhhOD/k6lU+woQ5fwdBlFQod/UuSdGSJc0=; b=RvqLfRs3oUei7vIkoUIKox12S/yZokTnRU3le6gGLXR2AnrkeGeqjA58F7dgFn6eeg 4xImzMuDifdptNKE9++WrAwxYs27Cp3MANnRw3kPRzyLAGm32M3sjOjto9xX5Te7UdRn BdIuS6umrdw2qUBWrS9xD1aTqudS4iPABmJsLiCDGGFknrXYS6H9zUrCL8/ud35kH19r T1/DAelFLHfg4TNkztKrNR4KQaQUM07U0sIvqQ5Tu61LmXW6ErwUApkWqR5XpKVy3hsd hjOQFuracYrjRIt/h6esN3Ekx6oWGuvVlWbf2b73XN05+O9tHerzJBEa8eOGXMJZQRoU tClw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hzOmHLLZ; 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 w9-20020a170902a70900b00194bdcf1aafsi5721073plq.541.2023.04.02.02.13.25; Sun, 02 Apr 2023 02:13:35 -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=hzOmHLLZ; 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 S230053AbjDBIcU (ORCPT + 99 others); Sun, 2 Apr 2023 04:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjDBIcH (ORCPT ); Sun, 2 Apr 2023 04:32:07 -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 361DE1B7EE for ; Sun, 2 Apr 2023 01:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680424209; 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=7ph+xCj8xMhhOD/k6lU+woQ5fwdBlFQod/UuSdGSJc0=; b=hzOmHLLZDGIhSbzVafufu0x0KADFuKsCpoyxNZ+Huk3OjntvhcZllaJXm6/JWJXfBhf0v8 QGrXIX22OI7NP4xfpLIK44+52C8ojqF8gOHz2KKRTgKLNHZPj07QG1cLcqN7DLK5itWWqj RpE4TGW1XQylGWw8g0R1Iimho/SD2XQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-y1d6fe74O4W305DMg0LcGQ-1; Sun, 02 Apr 2023 04:30:06 -0400 X-MC-Unique: y1d6fe74O4W305DMg0LcGQ-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 E1449811E7C; Sun, 2 Apr 2023 08:30:04 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62DFF40C6EC4; Sun, 2 Apr 2023 08:30:04 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 77EA030736C72; Sun, 2 Apr 2023 10:30:03 +0200 (CEST) Subject: [PATCH bpf V6 5/5] selftests/bpf: Adjust bpf_xdp_metadata_rx_hash for new arg 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: Sun, 02 Apr 2023 10:30:03 +0200 Message-ID: <168042420344.4051476.9107061652824513113.stgit@firesoul> In-Reply-To: <168042409059.4051476.8176861613304493950.stgit@firesoul> References: <168042409059.4051476.8176861613304493950.stgit@firesoul> User-Agent: StGit/1.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=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 Update BPF selftests to use the new RSS type argument for kfunc bpf_xdp_metadata_rx_hash. Signed-off-by: Jesper Dangaard Brouer Acked-by: Toke Høiland-Jørgensen Acked-by: Stanislav Fomichev --- .../selftests/bpf/prog_tests/xdp_metadata.c | 2 ++ .../testing/selftests/bpf/progs/xdp_hw_metadata.c | 14 +++++++++----- tools/testing/selftests/bpf/progs/xdp_metadata.c | 6 +++--- tools/testing/selftests/bpf/progs/xdp_metadata2.c | 7 ++++--- tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 +- tools/testing/selftests/bpf/xdp_metadata.h | 1 + 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c index aa4beae99f4f..8c5e98da9ae9 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c @@ -273,6 +273,8 @@ static int verify_xsk_metadata(struct xsk *xsk) if (!ASSERT_NEQ(meta->rx_hash, 0, "rx_hash")) return -1; + ASSERT_EQ(meta->rx_hash_type, 0, "rx_hash_type"); + xsk_ring_cons__release(&xsk->rx, 1); refill_rx(xsk, comp_addr); diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c index 4c55b4d79d3d..7b3fc12e96d6 100644 --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c @@ -14,8 +14,8 @@ struct { 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, - __u32 *hash) __ksym; +extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash, + enum xdp_rss_hash_type *rss_type) __ksym; SEC("xdp") int rx(struct xdp_md *ctx) @@ -74,10 +74,14 @@ int rx(struct xdp_md *ctx) else meta->rx_timestamp = 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 + if (!bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash, &meta->rx_hash_type)) { + bpf_printk("populated rx_hash:0x%X type:0x%X", + meta->rx_hash, meta->rx_hash_type); + if (!(meta->rx_hash_type & XDP_RSS_L4)) + bpf_printk("rx_hash low quality L3 hash type"); + } else { meta->rx_hash = 0; /* Used by AF_XDP as not avail signal */ + } return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); } diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools/testing/selftests/bpf/progs/xdp_metadata.c index 77678b034389..d151d406a123 100644 --- a/tools/testing/selftests/bpf/progs/xdp_metadata.c +++ b/tools/testing/selftests/bpf/progs/xdp_metadata.c @@ -21,8 +21,8 @@ struct { 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, - __u32 *hash) __ksym; +extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash, + enum xdp_rss_hash_type *rss_type) __ksym; SEC("xdp") int rx(struct xdp_md *ctx) @@ -56,7 +56,7 @@ int rx(struct xdp_md *ctx) if (timestamp == 0) meta->rx_timestamp = 1; - bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash); + bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash, &meta->rx_hash_type); return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); } diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata2.c b/tools/testing/selftests/bpf/progs/xdp_metadata2.c index cf69d05451c3..85f88d9d7a78 100644 --- a/tools/testing/selftests/bpf/progs/xdp_metadata2.c +++ b/tools/testing/selftests/bpf/progs/xdp_metadata2.c @@ -5,17 +5,18 @@ #include #include -extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, - __u32 *hash) __ksym; +extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash, + enum xdp_rss_hash_type *rss_type) __ksym; int called; SEC("freplace/rx") int freplace_rx(struct xdp_md *ctx) { + enum xdp_rss_hash_type type = 0; u32 hash = 0; /* Call _any_ metadata function to make sure we don't crash. */ - bpf_xdp_metadata_rx_hash(ctx, &hash); + bpf_xdp_metadata_rx_hash(ctx, &hash, &type); called++; return XDP_PASS; } diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c index 1c8acb68b977..4ca29e0c9646 100644 --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c @@ -141,7 +141,7 @@ static void verify_xdp_metadata(void *data) meta = data - sizeof(*meta); printf("rx_timestamp: %llu\n", meta->rx_timestamp); - printf("rx_hash: %u\n", meta->rx_hash); + printf("rx_hash: 0x%X RSS type:0x%X\n", meta->rx_hash, meta->rx_hash_type); } static void verify_skb_metadata(int fd) diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h index f6780fbb0a21..899da872fee1 100644 --- a/tools/testing/selftests/bpf/xdp_metadata.h +++ b/tools/testing/selftests/bpf/xdp_metadata.h @@ -12,4 +12,5 @@ struct xdp_meta { __u64 rx_timestamp; __u32 rx_hash; + __u32 rx_hash_type; };