Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2445529rwl; Thu, 30 Mar 2023 10:21:14 -0700 (PDT) X-Google-Smtp-Source: AKy350basexJiO9lodPKqhf8thH7jqARR3/iO24f+TIG7XJ97OdmQbhK267J8H7bvpUlpk9UEgNG X-Received: by 2002:a05:6a00:22cb:b0:627:ff64:85cc with SMTP id f11-20020a056a0022cb00b00627ff6485ccmr3425309pfj.0.1680196873825; Thu, 30 Mar 2023 10:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680196873; cv=none; d=google.com; s=arc-20160816; b=zOtLD6cnzGzDUtp32awLLWd/ZBgNb+bYl1/VsNRY+XhH4gBWLRjrSVLquN6pqZFC3F Xm76uKIdpWyN5IfMgqFLyi8vnkV9S1/4COwQGytm2K42k7HiBOascVuRtLnd/RgN2bBH AK8flZJYXdAQ8HvQGIod1ftoHlLa98gtSt0xjJqO6E6aUOIJq2H1/YkazJYTjixVHpzg ZXb1gMcJJhrcojam+lYyRrg5T9HovXubK6Z4b73ntO3MJlY1d37jjaifFR/Dt3cFboad OmTltYjY77oCWuB6YNR6mXBJD2KHxW0sCpUIxSkonYvJtZxJGKm9Lih1nppPUFy6lHLV bWXA== 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=ZEaVmBgKlRrwoGWi/NgZd7GVisuKZ6nuXro4uZDEt98=; b=MPhzHtKXZtr7Ag4/UNqBFHasazL6DTtRD6Ztojzki5ixlyzZSbI1tIf6yAvcCB1c3B 5tnV8TwLbFDJcCg8zqw5Bh03tdUQNKwbRbW6Rw8xKSZEJv742Mv/Pat5zHOKBfafw8fm 3cfw3VoXKC69AiB8UwQTQNxIfhZHtH4+VCxL7Aw2fPVJeU4AmQgld1b2EqE2shnFILAO Bn9SBbFrsRXRwid5bCYOLf6VM/AZNQta4vsBVU4qabUSiUuzaSiiiOos3MKwvkvhPhdj tyT/7O2OJtEfXs7ysW6i4UUBVSZzNI0ZQNk0JeHSBb8qLzUPuynV5kbSWHnpPLr33Iso mK5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZmyRCz40; 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 o125-20020a634183000000b005139ef2fc1dsi192298pga.58.2023.03.30.10.20.35; Thu, 30 Mar 2023 10:21:13 -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=ZmyRCz40; 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 S231603AbjC3RJy (ORCPT + 99 others); Thu, 30 Mar 2023 13:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232283AbjC3RJ2 (ORCPT ); Thu, 30 Mar 2023 13:09:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B315B8E for ; Thu, 30 Mar 2023 10:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680196120; 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=ZEaVmBgKlRrwoGWi/NgZd7GVisuKZ6nuXro4uZDEt98=; b=ZmyRCz40M1v+YIls8ZHcXRis9EU5j4ur2mopdSkFSAECSlylQROgBfAdRC6zzh5azlKIEv yaLeinh2A7TzYb0cZTst0xQ34OGKxp3aXyfGOGqg70ZRiRkrwfbEmDw6V1fFuoUeEeTP6X W2yqX1Mtp/N1g3cM7sLp0dizZcAG/p8= 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-384-X2d2XH2iOje-FwJDF9HbgA-1; Thu, 30 Mar 2023 13:08:05 -0400 X-MC-Unique: X2d2XH2iOje-FwJDF9HbgA-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 3B77F3810B0E; Thu, 30 Mar 2023 17:08:02 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE2ED407D441; Thu, 30 Mar 2023 17:08:01 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id F1AC330736C72; Thu, 30 Mar 2023 19:08:00 +0200 (CEST) Subject: [PATCH bpf RFC-V3 4/5] mlx4: bpf_xdp_metadata_rx_hash add xdp rss hash type From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev 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 Date: Thu, 30 Mar 2023 19:08:00 +0200 Message-ID: <168019608094.3557870.11753259102366277974.stgit@firesoul> In-Reply-To: <168019602958.3557870.9960387532660882277.stgit@firesoul> References: <168019602958.3557870.9960387532660882277.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=-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 API for bpf_xdp_metadata_rx_hash() with arg for xdp rss hash type via matching indiviual Completion Queue Entry (CQE) status bits. Signed-off-by: Jesper Dangaard Brouer --- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 22 ++++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 4b5e459b6d49..d3f46d8b4160 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -681,14 +681,32 @@ int mlx4_en_xdp_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp) return 0; } -int mlx4_en_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash) +int mlx4_en_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash, + enum xdp_rss_hash_type *rss_type) { struct mlx4_en_xdp_buff *_ctx = (void *)ctx; + struct mlx4_cqe *cqe = _ctx->cqe; + enum xdp_rss_hash_type xht = 0; + __be16 status; if (unlikely(!(_ctx->dev->features & NETIF_F_RXHASH))) return -ENODATA; - *hash = be32_to_cpu(_ctx->cqe->immed_rss_invalid); + *hash = be32_to_cpu(cqe->immed_rss_invalid); + status = cqe->status; + if (status & cpu_to_be16(MLX4_CQE_STATUS_TCP)) + xht = XDP_RSS_L4_TCP; + if (status & cpu_to_be16(MLX4_CQE_STATUS_UDP)) + xht = XDP_RSS_L4_UDP; + if (status & cpu_to_be16(MLX4_CQE_STATUS_IPV4|MLX4_CQE_STATUS_IPV4F)) + xht |= XDP_RSS_L3_IPV4; + if (status & cpu_to_be16(MLX4_CQE_STATUS_IPV6)) { + xht |= XDP_RSS_L3_IPV6; + if (cqe->ipv6_ext_mask) + xht |= XDP_RSS_L3_DYNHDR; + } + *rss_type = xht; + return 0; } diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index 544e09b97483..4ac4d883047b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -798,7 +798,8 @@ int mlx4_en_netdev_event(struct notifier_block *this, struct xdp_md; int mlx4_en_xdp_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp); -int mlx4_en_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash); +int mlx4_en_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash, + enum xdp_rss_hash_type *rss_type); /* * Functions for time stamping