Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp897725rwl; Wed, 29 Mar 2023 09:48:02 -0700 (PDT) X-Google-Smtp-Source: AKy350b8vRDlWdCeNVHhI1VsKVtUMcN716+hiiZnTA30lVjoQELP14Lv17Gn/+MwuX6BQ1w/tKOq X-Received: by 2002:a62:7b52:0:b0:622:8a8e:8cf8 with SMTP id w79-20020a627b52000000b006228a8e8cf8mr2956553pfc.14.1680108482201; Wed, 29 Mar 2023 09:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680108482; cv=none; d=google.com; s=arc-20160816; b=eb50dct10DeVTOnAKAWOI7M6HCpRfdMbOS8rOxR9Vng4M1TVIIRj/ZF6SLGFGZuiwf kJT/z8VG/T/vZl4BAyJqXjx1gm5mIN7M9tpZxgJG1aXWF+jKALk5jsA4Jvh5V5RE9mAg iR5L/QXVl/Pk9cq/SazGSsFtCKkdk1XaGIBJSrUDiVc7kAqyYvLE275WdShU5KjFVOsC P7K2MzxgYnW4Gm1WXDF9wd+bdf0d13DKRW5v4Lu1beisZZccIzjuAGMX2cvRWT0hX5yx gYYTTfMpEk5IcqitvPQ8OPqcPd+vDxYrIX0aLY5soJ+pDAFy+YZSkvX+Vfh8/g6eEEKl PfHA== 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=R04Vq+TEHO0b9S0yy8Ip00yZxPQlDgdJbbW0Gf6DdUk=; b=JR+ax7kEciwq9Kn1J7G6eSeYU2iSyaEHB/E8qdRkk75I9HLZDZ6DHjWlg2hlulvXRF RZKM1O2HQVOTJilnGBotKU2hx0+Mdi4FymMwjHJwIfMPUp2tpHu9TZhuYiLuN6HgAiwP H66z/MzBYYUwEg8kbdX3y9Tk9oodKvkhD4C82PZ1CnkpPayHWox43HclKtWBZuXXiFlK Pa+GefdyxlIqgGh/b8dYbYaJsriEk4aNzoHK1wxP4YVt1/cvgQhmTd4+ZnhZ2AVtNGbD u7Cj8fKKkWBHE7kaFUoAziNDcc6vlHFhu5I14ajcHSvspvPwzInncHkj7WH8E7s3234z Pk5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RpiYjKiJ; 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 q19-20020a056a00085300b005907636f4bfsi32338460pfk.48.2023.03.29.09.47.47; Wed, 29 Mar 2023 09:48:02 -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=RpiYjKiJ; 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 S230103AbjC2Qau (ORCPT + 99 others); Wed, 29 Mar 2023 12:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbjC2QaV (ORCPT ); Wed, 29 Mar 2023 12:30:21 -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 2B4955BBD for ; Wed, 29 Mar 2023 09:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680107371; 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=R04Vq+TEHO0b9S0yy8Ip00yZxPQlDgdJbbW0Gf6DdUk=; b=RpiYjKiJ1aEW/e12tza0fqWNpwZQ/nMO4i7+qVWCUeMC55zJOEBkl0OG05mY180uhHOkht EfpvautIZsFnmZWO3OcTuMydUmOk5WVt5PqNRV/kRwhgI28FmhhrJR1HOTzdFpcKo9Il2t JKIo8TJR8ZnRVfY1zCaksDcREIJSGbU= 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-12-58AnzNzGPmqO-eeEuGEBpA-1; Wed, 29 Mar 2023 12:29:25 -0400 X-MC-Unique: 58AnzNzGPmqO-eeEuGEBpA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D546885622; Wed, 29 Mar 2023 16:29:24 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60F541121330; Wed, 29 Mar 2023 16:29:24 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 8349430736C72; Wed, 29 Mar 2023 18:29:23 +0200 (CEST) Subject: [PATCH bpf RFC-V2 5/5] mlx4: bpf_xdp_metadata_rx_hash return 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: Wed, 29 Mar 2023 18:29:23 +0200 Message-ID: <168010736349.3039990.15736472596192726923.stgit@firesoul> In-Reply-To: <168010726310.3039990.2753040700813178259.stgit@firesoul> References: <168010726310.3039990.2753040700813178259.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.3 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() by returning 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 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 4b5e459b6d49..f3b7351daa05 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -684,12 +684,28 @@ 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) { 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); - return 0; + 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_BIT_EX; + } + + *hash = be32_to_cpu(cqe->immed_rss_invalid); + return xht; } int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget)