From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F22548B69 for ; Fri, 21 Nov 2025 12:23:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49DCB402EE; Fri, 21 Nov 2025 12:23:26 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B8E95402E5 for ; Fri, 21 Nov 2025 12:23:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763724204; 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=ypiOXudUJfyCJqiei+Rndpr3vvt9Etdi6ZLbXE7egYA=; b=M//CwlcaBP/jU32Kf9r4E5eK9wyvP+vg4X0GZCT+IgnFghnM2jPdOHuN9VqT5oCkDAjdK3 6NGYzSSIP9X5aJbF6UE97lyPKWHWN2je6yu+HMNMYDNBnfBy/b33iS6MilJ/VFRATUySTK d93aeZqNBF7fvkTuJBcHfwXZCu49Vj8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-fwDcMXxNOjKDlVF2GZBmug-1; Fri, 21 Nov 2025 06:23:21 -0500 X-MC-Unique: fwDcMXxNOjKDlVF2GZBmug-1 X-Mimecast-MFC-AGG-ID: fwDcMXxNOjKDlVF2GZBmug_1763724200 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3EC81956054; Fri, 21 Nov 2025 11:23:19 +0000 (UTC) Received: from rh.redhat.com (unknown [10.42.28.165]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2136030044DB; Fri, 21 Nov 2025 11:23:17 +0000 (UTC) From: Kevin Traynor To: Dariusz Sosnowski Cc: Bing Zhao , dpdk stable Subject: patch 'net/mlx5: fix indirect RSS action hash' has been queued to stable release 24.11.4 Date: Fri, 21 Nov 2025 11:20:31 +0000 Message-ID: <20251121112128.485623-47-ktraynor@redhat.com> In-Reply-To: <20251121112128.485623-1-ktraynor@redhat.com> References: <20251121112128.485623-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qeb63riSUZ1tcnoe2LcTf_KSPjHE0VAj2SN8K9qyCK4_1763724200 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 24.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/26/25. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/64fc7ef57758ad7b358e294df28c902a7e8b8c40 Thanks. Kevin --- >From 64fc7ef57758ad7b358e294df28c902a7e8b8c40 Mon Sep 17 00:00:00 2001 From: Dariusz Sosnowski Date: Thu, 30 Oct 2025 18:24:04 +0100 Subject: [PATCH] net/mlx5: fix indirect RSS action hash [ upstream commit 6b010880a505c5609355180a7f99df940a163385 ] Whenever indirect RSS flow action is created, mlx5 PMD creates an hrxq object (abstraction over HW object used to configure RSS hashing), for all possible and supported protocols combinations. For each combination, the hrxq configuration is adjusted based on RSS hash types provided by the user (e.g. hash on source L3 address is removed if user passed RTE_ETH_RSS_L3_SRC_ONLY in hash types). Function used for adjustment, flow_dv_action_rss_l34_hash_adjust(), had a bug. If user requested, for example, hashing over both UDP ports and only IPv6 source address, then RSS hashing was configured to hash both IPv6 addresses. Adjustment for RTE_ETH_RSS_L3_SRC_ONLY was skipped. In HW Steering mode, this resulted in failures to use such indirect RSS flow action in flow rules created through template flow API. In this mode, only a single hrxq object is selected during flow rule creation, based on actual configuration of RSS hash types in flow action. Since hrxq was created without applying RTE_ETH_RSS_L3_SRC_ONLY adjustment and RSS hash types contained RTE_ETH_RSS_L3_SRC_ONLY, then no matching hrxq could be found, resulting in rule creation failure. This issue is addressed by the following: - Missing adjustments are added to flow_dv_action_rss_l34_hash_adjust() function. This function is reworked to check each protocol type separately, instead of using switch case over all combinations. - Code for setting/looking up hrxq objects based on RSS hash types is reworked. Separate switch cases for possible combinations in each function are replaced with a single one. Additional logging and assertions are added to flag any invalid or missing combinations. Beside that, the existing set of protocols combinations set did not cover RSS hashing only over UDP or TCP ports, which is a valid configuration. These combinations are added in this patch (new elements in mlx5_rss_hash_fields array). Fixes: 212d17b6a650 ("net/mlx5: fix missing shared RSS hash types") Signed-off-by: Dariusz Sosnowski Acked-by: Bing Zhao --- drivers/net/mlx5/mlx5.h | 2 - drivers/net/mlx5/mlx5_flow.c | 15 ++ drivers/net/mlx5/mlx5_flow.h | 37 ++- drivers/net/mlx5/mlx5_flow_dv.c | 410 +++++++++++++++++++------------- 4 files changed, 287 insertions(+), 177 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index f2ddb5c7b4..56eb08bd7c 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1820,6 +1820,4 @@ struct mlx5_obj_ops { }; -#define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields) - enum mlx5_ctrl_flow_type { MLX5_CTRL_FLOW_TYPE_GENERAL, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 58ab218d1c..e5f76aae45 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -34,4 +34,19 @@ #include "rte_pmd_mlx5.h" +const uint64_t mlx5_rss_hash_fields[] = { + [MLX5_RSS_HASH_IDX_IPV4] = MLX5_RSS_HASH_IPV4, + [MLX5_RSS_HASH_IDX_IPV4_TCP] = MLX5_RSS_HASH_IPV4_TCP, + [MLX5_RSS_HASH_IDX_IPV4_UDP] = MLX5_RSS_HASH_IPV4_UDP, + [MLX5_RSS_HASH_IDX_IPV4_ESP] = MLX5_RSS_HASH_IPV4_ESP, + [MLX5_RSS_HASH_IDX_IPV6] = MLX5_RSS_HASH_IPV6, + [MLX5_RSS_HASH_IDX_IPV6_TCP] = MLX5_RSS_HASH_IPV6_TCP, + [MLX5_RSS_HASH_IDX_IPV6_UDP] = MLX5_RSS_HASH_IPV6_UDP, + [MLX5_RSS_HASH_IDX_IPV6_ESP] = MLX5_RSS_HASH_IPV6_ESP, + [MLX5_RSS_HASH_IDX_TCP] = MLX5_TCP_IBV_RX_HASH, + [MLX5_RSS_HASH_IDX_UDP] = MLX5_UDP_IBV_RX_HASH, + [MLX5_RSS_HASH_IDX_ESP_SPI] = MLX5_RSS_HASH_ESP_SPI, + [MLX5_RSS_HASH_IDX_NONE] = MLX5_RSS_HASH_NONE, +}; + /* * Shared array for quick translation between port_id and vport mask/values diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index aa8ea54c66..c8ab114655 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1865,18 +1865,29 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx, enum rte_flow_item_type type, ((func) == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT)) -/* array of valid combinations of RX Hash fields for RSS */ -static const uint64_t mlx5_rss_hash_fields[] = { - MLX5_RSS_HASH_IPV4, - MLX5_RSS_HASH_IPV4_TCP, - MLX5_RSS_HASH_IPV4_UDP, - MLX5_RSS_HASH_IPV4_ESP, - MLX5_RSS_HASH_IPV6, - MLX5_RSS_HASH_IPV6_TCP, - MLX5_RSS_HASH_IPV6_UDP, - MLX5_RSS_HASH_IPV6_ESP, - MLX5_RSS_HASH_ESP_SPI, - MLX5_RSS_HASH_NONE, + +/** + * Each enum variant corresponds to a single valid protocols combination for hrxq configuration + * Each variant serves as an index into #mlx5_rss_hash_fields array containing default + * bitmaps of ibv_rx_hash_fields flags for given protocols combination. + */ +enum { + MLX5_RSS_HASH_IDX_IPV4, + MLX5_RSS_HASH_IDX_IPV4_TCP, + MLX5_RSS_HASH_IDX_IPV4_UDP, + MLX5_RSS_HASH_IDX_IPV4_ESP, + MLX5_RSS_HASH_IDX_IPV6, + MLX5_RSS_HASH_IDX_IPV6_TCP, + MLX5_RSS_HASH_IDX_IPV6_UDP, + MLX5_RSS_HASH_IDX_IPV6_ESP, + MLX5_RSS_HASH_IDX_TCP, + MLX5_RSS_HASH_IDX_UDP, + MLX5_RSS_HASH_IDX_ESP_SPI, + MLX5_RSS_HASH_IDX_NONE, + MLX5_RSS_HASH_IDX_MAX, }; +/** Array of valid combinations of RX Hash fields for RSS. */ +extern const uint64_t mlx5_rss_hash_fields[]; + /* Shared RSS action structure */ struct mlx5_shared_action_rss { @@ -1887,5 +1898,5 @@ struct mlx5_shared_action_rss { struct mlx5_ind_table_obj *ind_tbl; /**< Hash RX queues (hrxq, hrxq_tunnel fields) indirection table. */ - uint32_t hrxq[MLX5_RSS_HASH_FIELDS_LEN]; + uint32_t hrxq[MLX5_RSS_HASH_IDX_MAX]; /**< Hash RX queue indexes mapped to mlx5_rss_hash_fields */ rte_spinlock_t action_rss_sl; /**< Shared RSS action spinlock. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 192dfd282d..006684d5bd 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15775,4 +15775,143 @@ flow_dv_translate(struct rte_eth_dev *dev, } +/* + * Protocol selector bitmap + * Each flag is used as an indicator that given protocol is specified in given RSS hash fields. + */ +#define RX_HASH_SELECTOR_IPV4 RTE_BIT32(0) +#define RX_HASH_SELECTOR_IPV6 RTE_BIT32(1) +#define RX_HASH_SELECTOR_UDP RTE_BIT32(2) +#define RX_HASH_SELECTOR_TCP RTE_BIT32(3) +#define RX_HASH_SELECTOR_ESP_SPI RTE_BIT32(4) +#define RX_HASH_SELECTOR_NONE (0) + +#define RX_HASH_SELECTOR_IPV4_TCP (RX_HASH_SELECTOR_IPV4 | RX_HASH_SELECTOR_TCP) +#define RX_HASH_SELECTOR_IPV4_UDP (RX_HASH_SELECTOR_IPV4 | RX_HASH_SELECTOR_UDP) +#define RX_HASH_SELECTOR_IPV4_ESP (RX_HASH_SELECTOR_IPV4 | RX_HASH_SELECTOR_ESP_SPI) + +#define RX_HASH_SELECTOR_IPV6_TCP (RX_HASH_SELECTOR_IPV6 | RX_HASH_SELECTOR_TCP) +#define RX_HASH_SELECTOR_IPV6_UDP (RX_HASH_SELECTOR_IPV6 | RX_HASH_SELECTOR_UDP) +#define RX_HASH_SELECTOR_IPV6_ESP (RX_HASH_SELECTOR_IPV6 | RX_HASH_SELECTOR_ESP_SPI) + +static bool +rx_hash_selector_has_valid_l3(const uint32_t selectors) +{ + /* In TIR configuration, RSS hashing on both IPv4 and IPv6 is mutually exclusive. */ + return !((selectors & RX_HASH_SELECTOR_IPV4) && (selectors & RX_HASH_SELECTOR_IPV6)); +} + +static bool +rx_hash_selector_has_valid_l4(const uint32_t selectors) +{ + /* In TIR configuration, RSS hashing on both UDP and TCP is mutually exclusive. */ + return !((selectors & RX_HASH_SELECTOR_UDP) && (selectors & RX_HASH_SELECTOR_TCP)); +} + +static bool +rx_hash_selector_has_valid_esp(const uint32_t selectors) +{ + /* In TIR configuration, RSS hashing on ESP and other L4 protocol is mutually exclusive. */ + if (selectors & RX_HASH_SELECTOR_ESP_SPI) + return !((selectors & RX_HASH_SELECTOR_UDP) || (selectors & RX_HASH_SELECTOR_TCP)); + + return true; +} + +/** + * Calculate protocol combination based on provided RSS hashing fields. + * + * @param[in] hash_fields + * Requested RSS hashing fields specified as a flags bitmap, based on ibv_rx_hash_fields. + * @param[out] selectors_out + * Calculated protocol combination will be written here. + * Result will be a bitmap of RX_HASH_SELECTOR_* flags. + * + * @return + * 0 if conversion is successful and protocol combination written to @p selectors_out. + * (-EINVAL) otherwise. + */ +static int +rx_hash_calc_selector(const uint64_t hash_fields, uint32_t *selectors_out) +{ + const uint64_t filtered_hf = hash_fields & ~IBV_RX_HASH_INNER; + uint32_t selectors = 0; + + if (filtered_hf & MLX5_RSS_HASH_IPV4) + selectors |= RX_HASH_SELECTOR_IPV4; + if (filtered_hf & MLX5_RSS_HASH_IPV6) + selectors |= RX_HASH_SELECTOR_IPV6; + if (!rx_hash_selector_has_valid_l3(selectors)) { + DRV_LOG(NOTICE, "hrxq hashing on both IPv4 and IPv6 is invalid: " + "selectors=0x%" PRIx32, selectors); + return -EINVAL; + } + + if (filtered_hf & MLX5_UDP_IBV_RX_HASH) + selectors |= RX_HASH_SELECTOR_UDP; + if (filtered_hf & MLX5_TCP_IBV_RX_HASH) + selectors |= RX_HASH_SELECTOR_TCP; + if (!rx_hash_selector_has_valid_l4(selectors)) { + DRV_LOG(NOTICE, "hrxq hashing on both UDP and TCP is invalid: " + "selectors=0x%" PRIx32, selectors); + return -EINVAL; + } + + if (filtered_hf & MLX5_RSS_HASH_ESP_SPI) + selectors |= RX_HASH_SELECTOR_ESP_SPI; + if (!rx_hash_selector_has_valid_esp(selectors)) { + DRV_LOG(NOTICE, "hrxq hashing on ESP SPI and UDP or TCP is mutually exclusive: " + "selectors=0x%" PRIx32, selectors); + return -EINVAL; + } + + *selectors_out = selectors; + return 0; +} + +/** + * Calculate the hrxq object index based on protocol combination. + * + * @param[in] selectors + * Protocol combination specified as bitmap of RX_HASH_SELECTOR_* flags. + * + * @return + * Index into hrxq array in #mlx5_shared_action_rss based on ginve protocol combination. + * (-EINVAL) if given protocol combination is not supported or is invalid. + */ +static int +get_rss_hash_idx(const uint32_t selectors) +{ + switch (selectors) { + case RX_HASH_SELECTOR_IPV4: + return MLX5_RSS_HASH_IDX_IPV4; + case RX_HASH_SELECTOR_IPV4_TCP: + return MLX5_RSS_HASH_IDX_IPV4_TCP; + case RX_HASH_SELECTOR_IPV4_UDP: + return MLX5_RSS_HASH_IDX_IPV4_UDP; + case RX_HASH_SELECTOR_IPV4_ESP: + return MLX5_RSS_HASH_IDX_IPV4_ESP; + case RX_HASH_SELECTOR_IPV6: + return MLX5_RSS_HASH_IDX_IPV6; + case RX_HASH_SELECTOR_IPV6_TCP: + return MLX5_RSS_HASH_IDX_IPV6_TCP; + case RX_HASH_SELECTOR_IPV6_UDP: + return MLX5_RSS_HASH_IDX_IPV6_UDP; + case RX_HASH_SELECTOR_IPV6_ESP: + return MLX5_RSS_HASH_IDX_IPV6_ESP; + case RX_HASH_SELECTOR_TCP: + return MLX5_RSS_HASH_IDX_TCP; + case RX_HASH_SELECTOR_UDP: + return MLX5_RSS_HASH_IDX_UDP; + case RX_HASH_SELECTOR_ESP_SPI: + return MLX5_RSS_HASH_IDX_ESP_SPI; + case RX_HASH_SELECTOR_NONE: + return MLX5_RSS_HASH_IDX_NONE; + default: + DRV_LOG(ERR, "invalid hrxq hash fields combination: " + "selectors=0x%" PRIx32, selectors); + return -EINVAL; + } +} + /** * Set hash RX queue by hash fields (see enum ibv_rx_hash_fields) @@ -15782,5 +15921,6 @@ flow_dv_translate(struct rte_eth_dev *dev, * Shred RSS action holding hash RX queue objects. * @param[in] hash_fields - * Defines combination of packet fields to participate in RX hash. + * Defines combination of packet fields to participate in RX hash, + * specified as a bitmap of #ibv_rx_hash_fields flags. * @param[in] tunnel * Tunnel type @@ -15797,63 +15937,24 @@ __flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action, { uint32_t *hrxqs = action->hrxq; + uint32_t selectors = 0; + int ret; - switch (hash_fields & ~IBV_RX_HASH_INNER) { - case MLX5_RSS_HASH_IPV4: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_SRC_ONLY: - hrxqs[0] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV4_TCP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_TCP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_TCP_SRC_ONLY: - hrxqs[1] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV4_UDP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_UDP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_UDP_SRC_ONLY: - hrxqs[2] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV6: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_SRC_ONLY: - hrxqs[3] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV6_TCP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_TCP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_TCP_SRC_ONLY: - hrxqs[4] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV6_UDP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_UDP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_UDP_SRC_ONLY: - hrxqs[5] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_NONE: - hrxqs[6] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV4_ESP: - hrxqs[7] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_IPV6_ESP: - hrxqs[8] = hrxq_idx; - return 0; - case MLX5_RSS_HASH_ESP_SPI: - hrxqs[9] = hrxq_idx; - return 0; - default: - return -1; - } + ret = rx_hash_calc_selector(hash_fields, &selectors); + /* + * Hash fields passed to this function are constructed internally. + * If this fails, then this is a PMD bug. + */ + MLX5_ASSERT(ret == 0); + + ret = get_rss_hash_idx(selectors); + /* + * Based on above assert, selectors should always yield correct index + * in mlx5_rss_hash_fields array. + * If this fails, then this is a PMD bug. + */ + MLX5_ASSERT(ret >= 0 && ret < MLX5_RSS_HASH_IDX_MAX); + hrxqs[ret] = hrxq_idx; + + return 0; } @@ -15867,5 +15968,6 @@ __flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action, * Shared RSS action ID holding hash RX queue objects. * @param[in] hash_fields - * Defines combination of packet fields to participate in RX hash. + * Defines combination of packet fields to participate in RX hash, + * specified as a bitmap of #ibv_rx_hash_fields flags. * @param[in] tunnel * Tunnel type @@ -15882,54 +15984,24 @@ flow_dv_action_rss_hrxq_lookup(struct rte_eth_dev *dev, uint32_t idx, mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS], idx); const uint32_t *hrxqs = shared_rss->hrxq; + uint32_t selectors = 0; + int ret; - switch (hash_fields & ~IBV_RX_HASH_INNER) { - case MLX5_RSS_HASH_IPV4: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_SRC_ONLY: - return hrxqs[0]; - case MLX5_RSS_HASH_IPV4_TCP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_TCP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_TCP_SRC_ONLY: - return hrxqs[1]; - case MLX5_RSS_HASH_IPV4_UDP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_UDP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV4_UDP_SRC_ONLY: - return hrxqs[2]; - case MLX5_RSS_HASH_IPV6: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_SRC_ONLY: - return hrxqs[3]; - case MLX5_RSS_HASH_IPV6_TCP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_TCP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_TCP_SRC_ONLY: - return hrxqs[4]; - case MLX5_RSS_HASH_IPV6_UDP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_UDP_DST_ONLY: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_UDP_SRC_ONLY: - return hrxqs[5]; - case MLX5_RSS_HASH_NONE: - return hrxqs[6]; - case MLX5_RSS_HASH_IPV4_ESP: - return hrxqs[7]; - case MLX5_RSS_HASH_IPV6_ESP: - return hrxqs[8]; - case MLX5_RSS_HASH_ESP_SPI: - return hrxqs[9]; - default: + ret = rx_hash_calc_selector(hash_fields, &selectors); + if (ret < 0) { + DRV_LOG(ERR, "port %u Rx hash selector calculation failed: " + "rss_act_idx=%u hash_fields=0x%" PRIx64 " selectors=0x%" PRIx32, + dev->data->port_id, idx, hash_fields, selectors); return 0; } + ret = get_rss_hash_idx(selectors); + if (ret < 0) { + DRV_LOG(ERR, "port %u failed hrxq index lookup: " + "rss_act_idx=%u hash_fields=0x%" PRIx64 " selectors=0x%" PRIx32, + dev->data->port_id, idx, hash_fields, selectors); + return 0; + } + + return hrxqs[ret]; } @@ -16621,5 +16693,5 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) static int __flow_dv_hrxqs_release(struct rte_eth_dev *dev, - uint32_t (*hrxqs)[MLX5_RSS_HASH_FIELDS_LEN]) + uint32_t (*hrxqs)[MLX5_RSS_HASH_IDX_MAX]) { size_t i; @@ -16656,4 +16728,60 @@ __flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev, } +static inline void +filter_ipv4_types(uint64_t rss_types, uint64_t *hash_fields) +{ + if (rss_types & MLX5_IPV4_LAYER_TYPES) { + *hash_fields &= ~MLX5_RSS_HASH_IPV4; + if (rss_types & RTE_ETH_RSS_L3_DST_ONLY) + *hash_fields |= IBV_RX_HASH_DST_IPV4; + else if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY) + *hash_fields |= IBV_RX_HASH_SRC_IPV4; + else + *hash_fields |= MLX5_RSS_HASH_IPV4; + } +} + +static inline void +filter_ipv6_types(uint64_t rss_types, uint64_t *hash_fields) +{ + if (rss_types & MLX5_IPV6_LAYER_TYPES) { + *hash_fields &= ~MLX5_RSS_HASH_IPV6; + if (rss_types & RTE_ETH_RSS_L3_DST_ONLY) + *hash_fields |= IBV_RX_HASH_DST_IPV6; + else if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY) + *hash_fields |= IBV_RX_HASH_SRC_IPV6; + else + *hash_fields |= MLX5_RSS_HASH_IPV6; + } +} + +static inline void +filter_udp_types(uint64_t rss_types, uint64_t *hash_fields) +{ + if (rss_types & RTE_ETH_RSS_UDP) { + *hash_fields &= ~MLX5_UDP_IBV_RX_HASH; + if (rss_types & RTE_ETH_RSS_L4_DST_ONLY) + *hash_fields |= IBV_RX_HASH_DST_PORT_UDP; + else if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY) + *hash_fields |= IBV_RX_HASH_SRC_PORT_UDP; + else + *hash_fields |= MLX5_UDP_IBV_RX_HASH; + } +} + +static inline void +filter_tcp_types(uint64_t rss_types, uint64_t *hash_fields) +{ + if (rss_types & RTE_ETH_RSS_TCP) { + *hash_fields &= ~MLX5_TCP_IBV_RX_HASH; + if (rss_types & RTE_ETH_RSS_L4_DST_ONLY) + *hash_fields |= IBV_RX_HASH_DST_PORT_TCP; + else if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY) + *hash_fields |= IBV_RX_HASH_SRC_PORT_TCP; + else + *hash_fields |= MLX5_TCP_IBV_RX_HASH; + } +} + /** * Adjust L3/L4 hash value of pre-created shared RSS hrxq according to @@ -16667,7 +16795,7 @@ __flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev, * * @param[in] orig_rss_types - * RSS type as provided in shared RSS action. + * RSS type as provided in shared RSS action, specified as a bitmap of RTE_ETH_RSS_* flags. * @param[in, out] hash_field - * hash_field variable needed to be adjusted. + * hash_field variable needed to be adjusted, specified as a bitmap of #ibv_rx_hash_fields flags. * * @return @@ -16678,58 +16806,16 @@ flow_dv_action_rss_l34_hash_adjust(uint64_t orig_rss_types, uint64_t *hash_field) { + uint64_t hash_field_protos = *hash_field & ~IBV_RX_HASH_INNER; uint64_t rss_types = rte_eth_rss_hf_refine(orig_rss_types); - switch (*hash_field & ~IBV_RX_HASH_INNER) { - case MLX5_RSS_HASH_IPV4: - if (rss_types & MLX5_IPV4_LAYER_TYPES) { - *hash_field &= ~MLX5_RSS_HASH_IPV4; - if (rss_types & RTE_ETH_RSS_L3_DST_ONLY) - *hash_field |= IBV_RX_HASH_DST_IPV4; - else if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY) - *hash_field |= IBV_RX_HASH_SRC_IPV4; - else - *hash_field |= MLX5_RSS_HASH_IPV4; - } - return; - case MLX5_RSS_HASH_IPV6: - if (rss_types & MLX5_IPV6_LAYER_TYPES) { - *hash_field &= ~MLX5_RSS_HASH_IPV6; - if (rss_types & RTE_ETH_RSS_L3_DST_ONLY) - *hash_field |= IBV_RX_HASH_DST_IPV6; - else if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY) - *hash_field |= IBV_RX_HASH_SRC_IPV6; - else - *hash_field |= MLX5_RSS_HASH_IPV6; - } - return; - case MLX5_RSS_HASH_IPV4_UDP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_UDP: - if (rss_types & RTE_ETH_RSS_UDP) { - *hash_field &= ~MLX5_UDP_IBV_RX_HASH; - if (rss_types & RTE_ETH_RSS_L4_DST_ONLY) - *hash_field |= IBV_RX_HASH_DST_PORT_UDP; - else if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY) - *hash_field |= IBV_RX_HASH_SRC_PORT_UDP; - else - *hash_field |= MLX5_UDP_IBV_RX_HASH; - } - return; - case MLX5_RSS_HASH_IPV4_TCP: - /* fall-through. */ - case MLX5_RSS_HASH_IPV6_TCP: - if (rss_types & RTE_ETH_RSS_TCP) { - *hash_field &= ~MLX5_TCP_IBV_RX_HASH; - if (rss_types & RTE_ETH_RSS_L4_DST_ONLY) - *hash_field |= IBV_RX_HASH_DST_PORT_TCP; - else if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY) - *hash_field |= IBV_RX_HASH_SRC_PORT_TCP; - else - *hash_field |= MLX5_TCP_IBV_RX_HASH; - } - return; - default: - return; - } + if (hash_field_protos & MLX5_RSS_HASH_IPV4) + filter_ipv4_types(rss_types, hash_field); + else if (hash_field_protos & MLX5_RSS_HASH_IPV6) + filter_ipv6_types(rss_types, hash_field); + + if (hash_field_protos & MLX5_UDP_IBV_RX_HASH) + filter_udp_types(rss_types, hash_field); + else if (hash_field_protos & MLX5_TCP_IBV_RX_HASH) + filter_tcp_types(rss_types, hash_field); } @@ -16783,5 +16869,5 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev, if (priv->sh->config.dv_flow_en == 2) rss_desc.hws_flags = MLX5DR_ACTION_FLAG_HWS_RX; - for (i = 0; i < MLX5_RSS_HASH_FIELDS_LEN; i++) { + for (i = 0; i < MLX5_RSS_HASH_IDX_MAX; i++) { struct mlx5_hrxq *hrxq; uint64_t hash_fields = mlx5_rss_hash_fields[i]; -- 2.51.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-11-21 11:05:11.075027049 +0000 +++ 0047-net-mlx5-fix-indirect-RSS-action-hash.patch 2025-11-21 11:05:09.479201238 +0000 @@ -1 +1 @@ -From 6b010880a505c5609355180a7f99df940a163385 Mon Sep 17 00:00:00 2001 +From 64fc7ef57758ad7b358e294df28c902a7e8b8c40 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 6b010880a505c5609355180a7f99df940a163385 ] + @@ -49 +50,0 @@ -Cc: stable@dpdk.org @@ -61 +62 @@ -index 203cf00596..7e4bfacd11 100644 +index f2ddb5c7b4..56eb08bd7c 100644 @@ -64 +65 @@ -@@ -1843,6 +1843,4 @@ struct mlx5_obj_ops { +@@ -1820,6 +1820,4 @@ struct mlx5_obj_ops { @@ -72 +73 @@ -index 098ef9d034..ed67a90a22 100644 +index 58ab218d1c..e5f76aae45 100644 @@ -75 +76 @@ -@@ -35,4 +35,19 @@ +@@ -34,4 +34,19 @@ @@ -96 +97 @@ -index ef743fc3cb..2de0f35815 100644 +index aa8ea54c66..c8ab114655 100644 @@ -99 +100 @@ -@@ -1898,18 +1898,29 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx, enum rte_flow_item_type type, +@@ -1865,18 +1865,29 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx, enum rte_flow_item_type type, @@ -141 +142 @@ -@@ -1920,5 +1931,5 @@ struct mlx5_shared_action_rss { +@@ -1887,5 +1898,5 @@ struct mlx5_shared_action_rss { @@ -149 +150 @@ -index 1564bd7cbe..f765f94116 100644 +index 192dfd282d..006684d5bd 100644 @@ -152 +153 @@ -@@ -15789,4 +15789,143 @@ flow_dv_translate(struct rte_eth_dev *dev, +@@ -15775,4 +15775,143 @@ flow_dv_translate(struct rte_eth_dev *dev, @@ -296 +297 @@ -@@ -15796,5 +15935,6 @@ flow_dv_translate(struct rte_eth_dev *dev, +@@ -15782,5 +15921,6 @@ flow_dv_translate(struct rte_eth_dev *dev, @@ -304 +305 @@ -@@ -15811,63 +15951,24 @@ __flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action, +@@ -15797,63 +15937,24 @@ __flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action, @@ -387 +388 @@ -@@ -15881,5 +15982,6 @@ __flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action, +@@ -15867,5 +15968,6 @@ __flow_dv_action_rss_hrxq_set(struct mlx5_shared_action_rss *action, @@ -395 +396 @@ -@@ -15896,54 +15998,24 @@ flow_dv_action_rss_hrxq_lookup(struct rte_eth_dev *dev, uint32_t idx, +@@ -15882,54 +15984,24 @@ flow_dv_action_rss_hrxq_lookup(struct rte_eth_dev *dev, uint32_t idx, @@ -466 +467 @@ -@@ -16635,5 +16707,5 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) +@@ -16621,5 +16693,5 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) @@ -473 +474 @@ -@@ -16670,4 +16742,60 @@ __flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev, +@@ -16656,4 +16728,60 @@ __flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev, @@ -534 +535 @@ -@@ -16681,7 +16809,7 @@ __flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev, +@@ -16667,7 +16795,7 @@ __flow_dv_action_rss_hrxqs_release(struct rte_eth_dev *dev, @@ -544 +545 @@ -@@ -16692,58 +16820,16 @@ flow_dv_action_rss_l34_hash_adjust(uint64_t orig_rss_types, +@@ -16678,58 +16806,16 @@ flow_dv_action_rss_l34_hash_adjust(uint64_t orig_rss_types, @@ -613 +614 @@ -@@ -16797,5 +16883,5 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev, +@@ -16783,5 +16869,5 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev,