From patchwork Wed Mar 29 16:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 1762911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=C4Bmo3g7; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PmsSv2rP6z1yYb for ; Thu, 30 Mar 2023 03:29:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 865BB83D10; Wed, 29 Mar 2023 16:29:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 865BB83D10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1680107357; bh=H0gItH/cgYpRub7m3xWlgY+jtOFfEvN5tE6y+jccPLM=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=C4Bmo3g7MBJPU7hjbE8gT0tHTKJsgS3mbmoEWx78Y718lKirZ0pULCMDx/eEeC1vg g5LFDZwMfnzel9HKVtLhjdyGgkQtdrBq8Ua/PgndPk0y4S4W5QIzNnrSj4Z8Ue5Mx/ bVsyrau1vm3ww5ezv267fe2MC8zSLzyI/LCQuVdVYBRPqDW9se0iLKDGAAYEszyNRe jiSXDpWveul0w7/b45W7o0HkqLk3pHbuSXHR3mbA52ESfOxbrhaFhdmw6TifJJ5wxF /PvptgCM5KETAkVJEqx4IMvJeRQEK896dtENeDevpomlD+feKevJr7w/uVTP1mqyLp TPZ7hWyWKrEFQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZBjgbRBQDUAM; Wed, 29 Mar 2023 16:29:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 7AE0883F6B; Wed, 29 Mar 2023 16:29:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7AE0883F6B X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 71A231BF294 for ; Wed, 29 Mar 2023 16:29:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 57D5161474 for ; Wed, 29 Mar 2023 16:29:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 57D5161474 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vnnv4np1B7uB for ; Wed, 29 Mar 2023 16:29:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 28EE260FE7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 28EE260FE7 for ; Wed, 29 Mar 2023 16:29:12 +0000 (UTC) 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-125-NmKGvAtlNLKqAHdQTB3maw-1; Wed, 29 Mar 2023 12:29:05 -0400 X-MC-Unique: NmKGvAtlNLKqAHdQTB3maw-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 6D87B885627; Wed, 29 Mar 2023 16:29:04 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1281C4020C83; Wed, 29 Mar 2023 16:29:04 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 4B4A830736C72; Wed, 29 Mar 2023 18:29:03 +0200 (CEST) From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev Date: Wed, 29 Mar 2023 18:29:03 +0200 Message-ID: <168010734324.3039990.16454026957159811204.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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680107351; 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=vnayASVoGfkPCqyQK+FSloIGuh996kv6+G+Hk7krqE4=; b=LqHmOMGjibwE5mbPdjF7EdrMP5ZbH73E7dML8xS/lDAuSXq/TA9732VPXaTb9r1OndJtOE t9foUWZLXY/Tiu5wjFxSFEJGHl2soCR8Vzf6nBg+4lJDK/iiELZq9Hy7ZdlE2ZaIOYiR5m oJvRgoqy48ZJk0txuGn6vO26YNZ4CaQ= X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LqHmOMGj Subject: [Intel-wired-lan] [PATCH bpf RFC-V2 1/5] xdp: rss hash types representation X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xdp-hints@xdp-project.net, martin.lau@kernel.org, daniel@iogearbox.net, larysa.zaremba@intel.com, netdev@vger.kernel.org, john.fastabend@gmail.com, ast@kernel.org, linux-kernel@vger.kernel.org, jesse.brandeburg@intel.com, kuba@kernel.org, pabeni@redhat.com, yoong.siang.song@intel.com, Jesper Dangaard Brouer , boon.leong.ong@intel.com, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org, davem@davemloft.net, edumazet@google.com, hawk@kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" The RSS hash type specifies what portion of packet data NIC hardware used when calculating RSS hash value. The RSS types are focused on Internet traffic protocols at OSI layers L3 and L4. L2 (e.g. ARP) often get hash value zero and no RSS type. For L3 focused on IPv4 vs. IPv6, and L4 primarily TCP vs UDP, but some hardware supports SCTP. Hardware RSS types are differently encoded for each hardware NIC. Most hardware represent RSS hash type as a number. Determining L3 vs L4 often requires a mapping table as there often isn't a pattern or sorting according to ISO layer. The patch introduce a XDP RSS hash type (xdp_rss_hash_type) that can both be seen as a number that is ordered according by ISO layer, and can be bit masked to separate IPv4 and IPv6 types for L4 protocols. Room is available for extending later while keeping these properties. This maps and unifies difference to hardware specific hashes. This proposal change the kfunc API bpf_xdp_metadata_rx_hash() to return this RSS hash type on success. Signed-off-by: Jesper Dangaard Brouer --- include/net/xdp.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ net/core/xdp.c | 4 ++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/include/net/xdp.h b/include/net/xdp.h index 5393b3ebe56e..1b2b17625c26 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -8,6 +8,7 @@ #include /* skb_shared_info */ #include +#include /** * DOC: XDP RX-queue information @@ -396,6 +397,81 @@ XDP_METADATA_KFUNC_xxx MAX_XDP_METADATA_KFUNC, }; +/* For partitioning of xdp_rss_hash_type */ +#define RSS_L3 GENMASK(2,0) /* 3-bits = values between 1-7 */ +#define L4_BIT BIT(3) /* 1-bit - L4 indication */ +#define RSS_L4_IPV4 GENMASK(6,4) /* 3-bits */ +#define RSS_L4_IPV6 GENMASK(9,7) /* 3-bits */ +#define RSS_L4 GENMASK(9,3) /* = 7-bits - covering L4 IPV4+IPV6 */ +#define L4_IPV6_EX_BIT BIT(9) /* 1-bit - L4 IPv6 with Extension hdr */ + /* 11-bits in total */ + +/* Lower 4-bits value of xdp_rss_hash_type */ +enum xdp_rss_L4 { + XDP_RSS_L4_MASK = GENMASK(3,0), /* 4-bits = values between 0-15 */ + XDP_RSS_L4_NONE = 0, /* Not L4 based hash */ + XDP_RSS_L4_ANY = 1, /* L4 based hash but protocol unknown */ + XDP_RSS_L4_TCP = 2, + XDP_RSS_L4_UDP = 3, + XDP_RSS_L4_SCTP = 4, + XDP_RSS_L4_IPSEC = 5, /* L4 based hash include IPSEC SPI */ +/* + RFC: We don't care about vasting space, then we could just store the + protocol number (8-bits) directly. See /etc/protocols + XDP_RSS_L4_TCP = 6, + XDP_RSS_L4_UDP = 17, + XDP_RSS_L4_SCTP = 132, + XDP_RSS_L4_IPSEC_ESP = 50, // Issue: mlx5 didn't say ESP or AH + XDP_RSS_L4_IPSEC_AH = 51, // both ESP+AH just include SPI in hash + */ +}; + +/* Values shifted for use in xdp_rss_hash_type */ +enum xdp_rss_L3 { + XDP_RSS_L3_MASK = GENMASK(5,4), /* 2-bits = values between 1-3 */ + XDP_RSS_L3_IPV4 = FIELD_PREP_CONST(XDP_RSS_L3_MASK, 1), + XDP_RSS_L3_IPV6 = FIELD_PREP_CONST(XDP_RSS_L3_MASK, 2), +}; + +/* Bits shifted for use in xdp_rss_hash_type */ +enum xdp_rss_bit { + XDP_RSS_BIT_MASK = GENMASK(7,6), /* 2-bits */ + /* IPv6 Extension Hdr */ + XDP_RSS_BIT_EX = FIELD_PREP_CONST(XDP_RSS_BIT_MASK, BIT(0)), + /* XDP_RSS_BIT_VLAN ??? = FIELD_PREP_CONST(XDP_RSS_BIT_MASK, BIT(1)), */ +}; + +/* RSS hash type combinations used for driver HW mapping */ +enum xdp_rss_hash_type { + XDP_RSS_TYPE_NONE = 0, + XDP_RSS_TYPE_L2 = XDP_RSS_TYPE_NONE, + + XDP_RSS_TYPE_L3_MASK = XDP_RSS_L3_MASK, + XDP_RSS_TYPE_L3_IPV4 = XDP_RSS_L3_IPV4, + XDP_RSS_TYPE_L3_IPV6 = XDP_RSS_L3_IPV6, + XDP_RSS_TYPE_L3_IPV6_EX = XDP_RSS_L3_IPV6 | XDP_RSS_BIT_EX, + + XDP_RSS_TYPE_L4_MASK = XDP_RSS_L4_MASK, + XDP_RSS_TYPE_L4_ANY = XDP_RSS_L4_ANY, + XDP_RSS_TYPE_L4_IPV4_TCP = XDP_RSS_L3_IPV4 | XDP_RSS_L4_TCP, + XDP_RSS_TYPE_L4_IPV4_UDP = XDP_RSS_L3_IPV4 | XDP_RSS_L4_UDP, + XDP_RSS_TYPE_L4_IPV4_SCTP = XDP_RSS_L3_IPV4 | XDP_RSS_L4_SCTP, + + XDP_RSS_TYPE_L4_IPV6_TCP = XDP_RSS_L3_IPV6 | XDP_RSS_L4_TCP, + XDP_RSS_TYPE_L4_IPV6_UDP = XDP_RSS_L3_IPV6 | XDP_RSS_L4_UDP, + XDP_RSS_TYPE_L4_IPV6_SCTP = XDP_RSS_L3_IPV6 | XDP_RSS_L4_UDP, + + XDP_RSS_TYPE_L4_IPV6_TCP_EX = XDP_RSS_TYPE_L4_IPV6_TCP |XDP_RSS_BIT_EX, + XDP_RSS_TYPE_L4_IPV6_UDP_EX = XDP_RSS_TYPE_L4_IPV6_UDP |XDP_RSS_BIT_EX, + XDP_RSS_TYPE_L4_IPV6_SCTP_EX = XDP_RSS_TYPE_L4_IPV6_SCTP|XDP_RSS_BIT_EX, +}; +#undef RSS_L3 +#undef L4_BIT +#undef RSS_L4_IPV4 +#undef RSS_L4_IPV6 +#undef RSS_L4 +#undef L4_IPV6_EX_BIT + #ifdef CONFIG_NET u32 bpf_xdp_metadata_kfunc_id(int id); bool bpf_dev_bound_kfunc_id(u32 btf_id); diff --git a/net/core/xdp.c b/net/core/xdp.c index 7133017bcd74..81d41df30695 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -721,12 +721,14 @@ __bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, u64 *tim * @hash: Return value pointer. * * Return: - * * Returns 0 on success or ``-errno`` on error. + * * Returns (positive) RSS hash **type** on success or ``-errno`` on error. + * * ``enum xdp_rss_hash_type`` : RSS hash type * * ``-EOPNOTSUPP`` : means device driver doesn't implement kfunc * * ``-ENODATA`` : means no RX-hash available for this frame */ __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash) { + BTF_TYPE_EMIT(enum xdp_rss_hash_type); return -EOPNOTSUPP; } From patchwork Wed Mar 29 16:29:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 1762912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=BzB9YT98; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PmsSz1R34z1yYb for ; Thu, 30 Mar 2023 03:29:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9728E83D23; Wed, 29 Mar 2023 16:29:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 9728E83D23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1680107361; bh=jt5/qxNNwL2aj3mvk4rs+SMkb28h17WQ5wyA0Wk4Slo=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=BzB9YT98nVRVuO1gyERFGIcVyUcderKlqOBGbRv8jhZdFbKuieGE1Ym668ce2ulWR nxgkEMoU9JtJHaFKY/Llo/eYm92KGCEqBJf/Y/Lsjyw5lcEh2lxbQfSUNZP73+7VSe 30r3IDQcffTCSpvW8l49VHcXtEH9F+VcmppZsy48xYfLvrJeNoJges1aUfMpb6uint +HTF2VdmU9pd5LjsXt3EnWf5P+uz0xzllBV/9gETAa/Pmmmcj3GwpRKbbUlmmIa1B2 kEdEqENeG6nKAxI/+nLvqpyFlyAAbqEc4tOwMxg0shQ0xND8QEVcsb7WCtACmYIa9y a5WSBIIHsOg+w== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fy5rjJXS2roQ; Wed, 29 Mar 2023 16:29:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 7BDED8413D; Wed, 29 Mar 2023 16:29:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7BDED8413D X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 08D251BF294 for ; Wed, 29 Mar 2023 16:29:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D6A0161474 for ; Wed, 29 Mar 2023 16:29:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D6A0161474 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9qDW2Xa0-uCo for ; Wed, 29 Mar 2023 16:29:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2A12460FE7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2A12460FE7 for ; Wed, 29 Mar 2023 16:29:17 +0000 (UTC) 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-147-lMCce-KrNl6Ba0Qy_Vxf1Q-1; Wed, 29 Mar 2023 12:29:10 -0400 X-MC-Unique: lMCce-KrNl6Ba0Qy_Vxf1Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82961857F81; Wed, 29 Mar 2023 16:29:09 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3913F2027040; Wed, 29 Mar 2023 16:29:09 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 5A33E30736C72; Wed, 29 Mar 2023 18:29:08 +0200 (CEST) From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev Date: Wed, 29 Mar 2023 18:29:08 +0200 Message-ID: <168010734832.3039990.11189218865563948327.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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680107356; 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=vdLO4Y9b3BsmrzeQcmRa2KtBaNDjkTa0G8yC7xzEAHs=; b=b/cVnc7BnRjDWNiS80s0Sow4JopFZ8mba1bVWuA16UUtUeZ61cQxDXbZLnOi12xAKUpTV5 aL3HnJ8chAFbUWaYQUwyhCqgdwSw783QkIVYXFYqueZjvoUOFvyvJPqMV76zqYLQv3/soP Hm0uqY/150uYmH7LcT2mXM8sgdnslpk= X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=b/cVnc7B Subject: [Intel-wired-lan] [PATCH bpf RFC-V2 2/5] igc: bpf_xdp_metadata_rx_hash return xdp rss hash type X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xdp-hints@xdp-project.net, martin.lau@kernel.org, daniel@iogearbox.net, larysa.zaremba@intel.com, netdev@vger.kernel.org, john.fastabend@gmail.com, ast@kernel.org, linux-kernel@vger.kernel.org, jesse.brandeburg@intel.com, kuba@kernel.org, pabeni@redhat.com, yoong.siang.song@intel.com, Jesper Dangaard Brouer , boon.leong.ong@intel.com, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org, davem@davemloft.net, edumazet@google.com, hawk@kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Update API for bpf_xdp_metadata_rx_hash() by returning xdp rss hash type via mapping table. Signed-off-by: Jesper Dangaard Brouer --- drivers/net/ethernet/intel/igc/igc_main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index b382476f347c..a14f0597524a 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6496,6 +6496,26 @@ static int igc_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp) return -ENODATA; } +/* Mapping HW RSS Type to enum xdp_rss_hash_type */ +enum xdp_rss_hash_type igc_xdp_rss_type[IGC_RSS_TYPE_MAX_TABLE] = { + [IGC_RSS_TYPE_NO_HASH] = XDP_RSS_TYPE_L2, + [IGC_RSS_TYPE_HASH_TCP_IPV4] = XDP_RSS_TYPE_L4_IPV4_TCP, + [IGC_RSS_TYPE_HASH_IPV4] = XDP_RSS_TYPE_L3_IPV4, + [IGC_RSS_TYPE_HASH_TCP_IPV6] = XDP_RSS_TYPE_L4_IPV6_TCP, + [IGC_RSS_TYPE_HASH_IPV6_EX] = XDP_RSS_TYPE_L3_IPV6_EX, + [IGC_RSS_TYPE_HASH_IPV6] = XDP_RSS_TYPE_L3_IPV6, + [IGC_RSS_TYPE_HASH_TCP_IPV6_EX] = XDP_RSS_TYPE_L4_IPV6_TCP_EX, + [IGC_RSS_TYPE_HASH_UDP_IPV4] = XDP_RSS_TYPE_L4_IPV4_UDP, + [IGC_RSS_TYPE_HASH_UDP_IPV6] = XDP_RSS_TYPE_L4_IPV6_UDP, + [IGC_RSS_TYPE_HASH_UDP_IPV6_EX] = XDP_RSS_TYPE_L4_IPV6_UDP_EX, + [10] = XDP_RSS_TYPE_NONE, /* RSS Type above 9 "Reserved" by HW */ + [11] = XDP_RSS_TYPE_NONE, /* keep array sized for SW bit-mask */ + [12] = XDP_RSS_TYPE_NONE, /* to handle future HW revisons */ + [13] = XDP_RSS_TYPE_NONE, + [14] = XDP_RSS_TYPE_NONE, + [15] = XDP_RSS_TYPE_NONE, +}; + static int igc_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash) { const struct igc_xdp_buff *ctx = (void *)_ctx; @@ -6505,7 +6525,7 @@ static int igc_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash) *hash = le32_to_cpu(ctx->rx_desc->wb.lower.hi_dword.rss); - return 0; + return igc_xdp_rss_type[igc_rss_type(ctx->rx_desc)]; } const struct xdp_metadata_ops igc_xdp_metadata_ops = { From patchwork Wed Mar 29 16:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 1762913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=bh7oIY/l; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PmsT2700Xz1yYb for ; Thu, 30 Mar 2023 03:29:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 6119D8405B; Wed, 29 Mar 2023 16:29:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6119D8405B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1680107365; bh=ZSlBqdU8H9P2kXa5hLVpjWmyQMpBTplFyBrQgitsTpw=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=bh7oIY/l5REy1Bx1B7jNUx5mKjHa1vu7cWE9pcZ1UIkJMi3cBs9dpev089KfSBxGJ WwB0/mVjVWiCJrYsvpUDx25nCENwqZhvmMlmnDRdGRbzSb0E2QMDZVEnuX+QK5OIL5 KiAF5IkZ0umdhSVgqJr3G6JYfSe3f4PxM84i9jwrwgs6yQxYt8YbfhjxikE8iOc0/o AuGMOwEvQ1JFYeQ3KdIYIV9q9x7uZNMGBwCDng7easgU3VJ70ukG8cf+tYcPG8F8iH LJ2FfItKiqd7l4s1OHoWxmIti4B/KTGJZ0+jvFjuXJ+G4cKnOuvyTXjwEsyOqv6ELn WaZa0W9A35iOQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mPzdugJVVoVQ; Wed, 29 Mar 2023 16:29:24 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 694348413D; Wed, 29 Mar 2023 16:29:24 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 694348413D X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id CBD211BF294 for ; Wed, 29 Mar 2023 16:29:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A48FD41D3A for ; Wed, 29 Mar 2023 16:29:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A48FD41D3A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h7x9aCOCZw4K for ; Wed, 29 Mar 2023 16:29:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EEF5C4000B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id EEF5C4000B for ; Wed, 29 Mar 2023 16:29:20 +0000 (UTC) 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-216-22tuEMDwMvKNnNE4IGw0gw-1; Wed, 29 Mar 2023 12:29:15 -0400 X-MC-Unique: 22tuEMDwMvKNnNE4IGw0gw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 806CE3C0F22C; Wed, 29 Mar 2023 16:29:14 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45C45492B02; Wed, 29 Mar 2023 16:29:14 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 6815230736C72; Wed, 29 Mar 2023 18:29:13 +0200 (CEST) From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev Date: Wed, 29 Mar 2023 18:29:13 +0200 Message-ID: <168010735338.3039990.5752685085641326312.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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680107360; 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=phrCwuF2IZNqe/IWguOcg/v1PLS/jorujG/kF7C6s+4=; b=LXyV5LA0G10WKeXhsZ3o/XxzgxMDrgvsrGlvMnnRW7qO3SrvznAJkPTtbfT9pg4ebZus4k fMR4x/2p5h1TsI846KEEb6qnG60OXp/CaEzMVqdOfBeWzx4nlTwI1LNDC13Em/P7XfeI2T N48PguBX0ujy+L3JTDsoVne0jHGDP8Q= X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LXyV5LA0 Subject: [Intel-wired-lan] [PATCH bpf RFC-V2 3/5] veth: bpf_xdp_metadata_rx_hash return xdp rss hash type X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xdp-hints@xdp-project.net, martin.lau@kernel.org, daniel@iogearbox.net, larysa.zaremba@intel.com, netdev@vger.kernel.org, john.fastabend@gmail.com, ast@kernel.org, linux-kernel@vger.kernel.org, jesse.brandeburg@intel.com, kuba@kernel.org, pabeni@redhat.com, yoong.siang.song@intel.com, Jesper Dangaard Brouer , boon.leong.ong@intel.com, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org, davem@davemloft.net, edumazet@google.com, hawk@kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Update API for bpf_xdp_metadata_rx_hash() by returning xdp rss hash type. The veth driver currently only support XDP-hints based on SKB code path. The SKB have lost information about the RSS hash type, by compressing the information down to a single bitfield skb->l4_hash, that only knows if this was a L4 hash value. In preparation for veth, the xdp_rss_hash_type have an L4 indication bit that allow us to return a meaningful L4 indication when working with SKB based packets. Signed-off-by: Jesper Dangaard Brouer --- drivers/net/veth.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 046461ee42ea..770eee664b4c 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1619,12 +1619,13 @@ static int veth_xdp_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp) static int veth_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash) { struct veth_xdp_buff *_ctx = (void *)ctx; + struct sk_buff *skb = _ctx->skb; - if (!_ctx->skb) + if (!skb) return -ENODATA; - *hash = skb_get_hash(_ctx->skb); - return 0; + *hash = skb_get_hash(skb); + return skb->l4_hash ? XDP_RSS_TYPE_L4_ANY : XDP_RSS_TYPE_NONE; } static const struct net_device_ops veth_netdev_ops = { From patchwork Wed Mar 29 16:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 1762914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=Cm5W/1SW; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PmsT7198xz1yYt for ; Thu, 30 Mar 2023 03:29:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8A5AF83D10; Wed, 29 Mar 2023 16:29:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8A5AF83D10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1680107369; bh=bdyJOQdMHLtomFIeMOKuI42n38tVNEpwxyOQowsong8=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Cm5W/1SW/ymPemqrtbB+mMUOkRLf25BPc3WGA2Y1fACCTbn090NQPB2bB8Eun6ryF GdJdtSmNCPEXjE8J3SDZyRqtaqtmQZAKLdYBQYHTxdxS8qGYDa4rO+wC46lPiOi7ZZ PEx6MLQyn9HY0vIh+odFutI0cCuW2YOI0kr5+LDA0MmzEgICtLzpsJhv5cKyt9yU3U TKgxp8xGYsEvQ0c0u0LRyAp5pQH1jR3ymGN1Hsp0QB0p7OHWN1DHWJo9ON1/p/Olm7 Y8laqFt0sgPpNQwUAQJop5h+BPxN5lcJRrPLG2QbbIzJRnydo0i4egRR4qVNHn/lxK URYfvW7ZEAhzw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9zccxeVu_s9g; Wed, 29 Mar 2023 16:29:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 6B4B484235; Wed, 29 Mar 2023 16:29:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6B4B484235 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 84A9A1BF294 for ; Wed, 29 Mar 2023 16:29:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5E8A661474 for ; Wed, 29 Mar 2023 16:29:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5E8A661474 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3e1UaA2vhYhd for ; Wed, 29 Mar 2023 16:29:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7833460FE7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7833460FE7 for ; Wed, 29 Mar 2023 16:29:25 +0000 (UTC) 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-649-Z5bn9iCzPqqZUhygrV6jvQ-1; Wed, 29 Mar 2023 12:29:20 -0400 X-MC-Unique: Z5bn9iCzPqqZUhygrV6jvQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC7B22806044; Wed, 29 Mar 2023 16:29:19 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51863202701E; Wed, 29 Mar 2023 16:29:19 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 7667430736C72; Wed, 29 Mar 2023 18:29:18 +0200 (CEST) From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev Date: Wed, 29 Mar 2023 18:29:18 +0200 Message-ID: <168010735844.3039990.17106215605594751233.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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680107364; 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=LbBo3JUiU9snSoTMFxXc90++kUXU++le4jRZXCUg2Kk=; b=d5Yq8yzOlD/bKAzr8EWFZDYYe8b+t/+M8UdcXHZ5zMAlugVvJxYZ8QzU8RptcLNJZjl1EQ zs0D+BqVmnC1yAsCmyX0o6SJlbWNmeBwazxxNJN2EfM81us9NMhVv0kUyCOrMP6Vjz30n/ Gq1FKXUlUVOIk4ZZ+CyeEYWcitcuOUw= X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d5Yq8yzO Subject: [Intel-wired-lan] [PATCH bpf RFC-V2 4/5] mlx5: bpf_xdp_metadata_rx_hash return xdp rss hash type X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xdp-hints@xdp-project.net, martin.lau@kernel.org, daniel@iogearbox.net, larysa.zaremba@intel.com, netdev@vger.kernel.org, john.fastabend@gmail.com, ast@kernel.org, linux-kernel@vger.kernel.org, jesse.brandeburg@intel.com, kuba@kernel.org, pabeni@redhat.com, yoong.siang.song@intel.com, Jesper Dangaard Brouer , boon.leong.ong@intel.com, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org, davem@davemloft.net, edumazet@google.com, hawk@kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Update API for bpf_xdp_metadata_rx_hash() by returning xdp rss hash type via mapping table. The mlx5 hardware can also identify and RSS hash IPSEC. This indicate hash includes SPI (Security Parameters Index) as part of IPSEC hash. Extend xdp core enum xdp_rss_hash_type with IPSEC hash type. Signed-off-by: Jesper Dangaard Brouer --- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 61 +++++++++++++++++++++- include/linux/mlx5/device.h | 14 ++++- include/net/xdp.h | 3 + 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c index c5dae48b7932..d3dfe11f4d50 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c @@ -34,6 +34,7 @@ #include #include "en/xdp.h" #include "en/params.h" +#include int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk) { @@ -169,15 +170,71 @@ static int mlx5e_xdp_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp) return 0; } +/* Mapping HW RSS Type bits CQE_RSS_HTYPE_IP + CQE_RSS_HTYPE_L4 into 4-bits*/ +#define RSS_TYPE_MAX_TABLE 16 /* 4-bits max 16 entries */ +#define RSS_L4 GENMASK(1,0) +#define RSS_L3 GENMASK(3,2) /* Same as CQE_RSS_HTYPE_IP */ + +/* Valid combinations of CQE_RSS_HTYPE_IP + CQE_RSS_HTYPE_L4 sorted numerical */ +enum mlx5_rss_hash_type { + RSS_TYPE_NO_HASH = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IP_NONE)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_NONE)), + RSS_TYPE_L3_IPV4 = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV4)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_NONE)), + RSS_TYPE_L4_IPV4_TCP = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV4)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_TCP)), + RSS_TYPE_L4_IPV4_UDP = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV4)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_UDP)), + RSS_TYPE_L4_IPV4_IPSEC = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV4)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_IPSEC)), + RSS_TYPE_L3_IPV6 = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV6)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_NONE)), + RSS_TYPE_L4_IPV6_TCP = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV6)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_TCP)), + RSS_TYPE_L4_IPV6_UDP = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV6)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_UDP)), + RSS_TYPE_L4_IPV6_IPSEC = (FIELD_PREP_CONST(RSS_L3, CQE_RSS_IPV6)| \ + FIELD_PREP_CONST(RSS_L4, CQE_RSS_L4_IPSEC)), +} mlx5_rss_hash_type; + +/* Invalid combinations will simply return zero, allows no boundry checks */ +static const enum xdp_rss_hash_type mlx5_xdp_rss_type[RSS_TYPE_MAX_TABLE] = { + [RSS_TYPE_NO_HASH] = XDP_RSS_TYPE_NONE, + [1] = XDP_RSS_TYPE_NONE, /* Implicit zero */ + [2] = XDP_RSS_TYPE_NONE, /* Implicit zero */ + [3] = XDP_RSS_TYPE_NONE, /* Implicit zero */ + [RSS_TYPE_L3_IPV4] = XDP_RSS_TYPE_L3_IPV4, + [RSS_TYPE_L4_IPV4_TCP] = XDP_RSS_TYPE_L4_IPV4_TCP, + [RSS_TYPE_L4_IPV4_UDP] = XDP_RSS_TYPE_L4_IPV4_UDP, + [RSS_TYPE_L4_IPV4_IPSEC]= XDP_RSS_TYPE_L4_IPV4_IPSEC, + [RSS_TYPE_L3_IPV6] = XDP_RSS_TYPE_L3_IPV6, + [RSS_TYPE_L4_IPV6_TCP] = XDP_RSS_TYPE_L4_IPV6_TCP, + [RSS_TYPE_L4_IPV6_UDP] = XDP_RSS_TYPE_L4_IPV6_UDP, + [RSS_TYPE_L4_IPV6_IPSEC]= XDP_RSS_TYPE_L4_IPV6_IPSEC, + [12] = XDP_RSS_TYPE_NONE, /* Implicit zero */ + [13] = XDP_RSS_TYPE_NONE, /* Implicit zero */ + [14] = XDP_RSS_TYPE_NONE, /* Implicit zero */ + [15] = XDP_RSS_TYPE_NONE, /* Implicit zero */ +}; + static int mlx5e_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash) { const struct mlx5e_xdp_buff *_ctx = (void *)ctx; + const struct mlx5_cqe64 *cqe = _ctx->cqe; + u32 hash_type, l4_type, ip_type, lookup; if (unlikely(!(_ctx->xdp.rxq->dev->features & NETIF_F_RXHASH))) return -ENODATA; - *hash = be32_to_cpu(_ctx->cqe->rss_hash_result); - return 0; + *hash = be32_to_cpu(cqe->rss_hash_result); + + hash_type = cqe->rss_hash_type; + BUILD_BUG_ON(CQE_RSS_HTYPE_IP != RSS_L3); /* same mask */ + ip_type = hash_type & CQE_RSS_HTYPE_IP; + l4_type = FIELD_GET(CQE_RSS_HTYPE_L4, hash_type); + lookup = ip_type | l4_type; + + return mlx5_xdp_rss_type[lookup]; } const struct xdp_metadata_ops mlx5e_xdp_metadata_ops = { diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 71b06ebad402..27aa9ae10996 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -36,6 +36,7 @@ #include #include #include +#include #if defined(__LITTLE_ENDIAN) #define MLX5_SET_HOST_ENDIANNESS 0 @@ -980,14 +981,23 @@ enum { }; enum { - CQE_RSS_HTYPE_IP = 0x3 << 2, + CQE_RSS_HTYPE_IP = GENMASK(3,2), /* cqe->rss_hash_type[3:2] - IP destination selected for hash * (00 = none, 01 = IPv4, 10 = IPv6, 11 = Reserved) */ - CQE_RSS_HTYPE_L4 = 0x3 << 6, + CQE_RSS_IP_NONE = 0x0, + CQE_RSS_IPV4 = 0x1, + CQE_RSS_IPV6 = 0x2, + CQE_RSS_RESERVED = 0x3, + + CQE_RSS_HTYPE_L4 = GENMASK(7,6), /* cqe->rss_hash_type[7:6] - L4 destination selected for hash * (00 = none, 01 = TCP. 10 = UDP, 11 = IPSEC.SPI */ + CQE_RSS_L4_NONE = 0x0, + CQE_RSS_L4_TCP = 0x1, + CQE_RSS_L4_UDP = 0x2, + CQE_RSS_L4_IPSEC = 0x3, }; enum { diff --git a/include/net/xdp.h b/include/net/xdp.h index 1b2b17625c26..b9837cb378b2 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -456,14 +456,17 @@ enum xdp_rss_hash_type { XDP_RSS_TYPE_L4_IPV4_TCP = XDP_RSS_L3_IPV4 | XDP_RSS_L4_TCP, XDP_RSS_TYPE_L4_IPV4_UDP = XDP_RSS_L3_IPV4 | XDP_RSS_L4_UDP, XDP_RSS_TYPE_L4_IPV4_SCTP = XDP_RSS_L3_IPV4 | XDP_RSS_L4_SCTP, + XDP_RSS_TYPE_L4_IPV4_IPSEC = XDP_RSS_L3_IPV4 | XDP_RSS_L4_IPSEC, XDP_RSS_TYPE_L4_IPV6_TCP = XDP_RSS_L3_IPV6 | XDP_RSS_L4_TCP, XDP_RSS_TYPE_L4_IPV6_UDP = XDP_RSS_L3_IPV6 | XDP_RSS_L4_UDP, XDP_RSS_TYPE_L4_IPV6_SCTP = XDP_RSS_L3_IPV6 | XDP_RSS_L4_UDP, + XDP_RSS_TYPE_L4_IPV6_IPSEC = XDP_RSS_L3_IPV6 | XDP_RSS_L4_IPSEC, XDP_RSS_TYPE_L4_IPV6_TCP_EX = XDP_RSS_TYPE_L4_IPV6_TCP |XDP_RSS_BIT_EX, XDP_RSS_TYPE_L4_IPV6_UDP_EX = XDP_RSS_TYPE_L4_IPV6_UDP |XDP_RSS_BIT_EX, XDP_RSS_TYPE_L4_IPV6_SCTP_EX = XDP_RSS_TYPE_L4_IPV6_SCTP|XDP_RSS_BIT_EX, + XDP_RSS_TYPE_L4_IPV6_IPSEC_EX= XDP_RSS_TYPE_L4_IPV6_IPSEC|XDP_RSS_BIT_EX, }; #undef RSS_L3 #undef L4_BIT From patchwork Wed Mar 29 16:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 1762915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=45wC6ktU; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PmsTC5NmBz1yYb for ; Thu, 30 Mar 2023 03:29:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D0C698423B; Wed, 29 Mar 2023 16:29:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D0C698423B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1680107373; bh=Hv76ZpwlVk8fsFMAHQCnJxeo2ZSyLh45jxXYunh7mu0=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=45wC6ktUOxYOQunXDoJQuMpXCCCiUBcBXd7fkyHiiqXoM/WHiSCCLegOTFZc1shWr VJqSATSdw9nj401iOzi6iuXjZLHxBEJbA0E2SJ/WCeXylQv9powLi0Q2qWHxIjbwcJ tKRvTRbIEgz0g4HnNZ6j0PoPluJkjc/IQVyvfpsrzffTZPFVTBTxQ1NPtb3kzlgkgw UVAWSzySHnZgzwx2iAU+7XTZx3jHsCCDt82wCUDdy4Frlqse0uBUtvxNKb2SxNJLzZ oUFw25NugepZqgPxcftOvUV6H3RLWCGNyaG1twOcMl9Zz9V6ZYFEhfVqNEzbaLqStb oE06LGq0Tgrlw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rsIMuPq8wqOu; Wed, 29 Mar 2023 16:29:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id D87458423C; Wed, 29 Mar 2023 16:29:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D87458423C X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 640731BF294 for ; Wed, 29 Mar 2023 16:29:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 49D0741D3A for ; Wed, 29 Mar 2023 16:29:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 49D0741D3A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EZUI-wv8CNtl for ; Wed, 29 Mar 2023 16:29:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7D62D4000B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7D62D4000B for ; Wed, 29 Mar 2023 16:29:30 +0000 (UTC) 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) From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680107369; 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=NGJyHiKL1mydJ4gka7gOlrXv64WpQ1SmJw89CIesf/pS8zgiiKVNMe9pWsYf3L3g1yuKu7 OlVxj9ngjzV/RthUhCd6f/Ati9v5T5ym5AkQiU7bxjTco1xBMS2QzqTrmjGeBnYtqVVfqJ gx7/LtcpJ+x5ooC3ZPgqhiAIzBYDP50= X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NGJyHiKL Subject: [Intel-wired-lan] [PATCH bpf RFC-V2 5/5] mlx4: bpf_xdp_metadata_rx_hash return xdp rss hash type X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xdp-hints@xdp-project.net, martin.lau@kernel.org, daniel@iogearbox.net, larysa.zaremba@intel.com, netdev@vger.kernel.org, john.fastabend@gmail.com, ast@kernel.org, linux-kernel@vger.kernel.org, jesse.brandeburg@intel.com, kuba@kernel.org, pabeni@redhat.com, yoong.siang.song@intel.com, Jesper Dangaard Brouer , boon.leong.ong@intel.com, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org, davem@davemloft.net, edumazet@google.com, hawk@kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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)