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 797C2455AD for ; Mon, 15 Jul 2024 17:29:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 738EA40A71; Mon, 15 Jul 2024 17:29:22 +0200 (CEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mails.dpdk.org (Postfix) with ESMTP id 00BF9402DD for ; Mon, 15 Jul 2024 17:29:20 +0200 (CEST) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52e99060b0dso4702226e87.1 for ; Mon, 15 Jul 2024 08:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057360; x=1721662160; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MghbvBz6sDV0l2Hzc3V+kYfL/nF8srRt47P2uTYXiuw=; b=FVfYdK8OoZfMpkSk5cz18yk0auM+3k9LcCIPb1g6paMui7MJsbbdvaWb0/2b7AUyPU 8wRMGCfoah0aggU9GjOgS8QwZR1vD+5wdy+j/yLRl+djXR2/RsqykQj6Bi2AsDhUwgi1 5SECwk5n+htuROt0ah8bJsQfXUKOQpZc2v87TewkStUoG8IhtD+y5FNd+6qvMjZdUDRu 828p7eZweoZzdbu9JsB1Q6hFm0IvRWYz5KeJDuBJjgP8EvAUJ8ZEGHe0CB+J9ZsNdfZ/ hQ31aD9sJodn6m1Jtt0VCuMTzYM3Aqso+6A6rgC53mvwgvIGRmEQwHPEVK8yfIlbCMVb SDbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057360; x=1721662160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MghbvBz6sDV0l2Hzc3V+kYfL/nF8srRt47P2uTYXiuw=; b=Y3QBiHEjY/Pt8X035rpHHAQ5/ozmMHR9Rnj3n9U4JWWl1kugVNo0LbBroyzNFCZWf4 Z7RiLdqUjAkYxKCZfeZgvifXlGWAgxleAk8hFUbusifsU4pLXJVXq4uAbzRU71vdoKzG s29CEjUoZqES0jJ0FGaRhs/Bg56LtP+h+vC1bgg/5EZtE9GIzXCgxHVGqLHgS599arwp h/7UauvzyYNiaVUn5IrOnLD53HEcVujuMHET3kcxUahMspuNdNVmfLfpVotEXbHXhFFJ HG99NgoKYmQEijRNBByknWVyHdHLTcIkQlyguUFINe8IEZnPmaYzTzQ08OGk5nlMoeX0 eljw== X-Forwarded-Encrypted: i=1; AJvYcCWn8Synw7oC+4wmUTJOmN/P0nRbwMaIrjnjooqQMlOZJoGA2lTyb1XVKnbG6P+T94+YKfiUxzBS+HQk5lUjLMg= X-Gm-Message-State: AOJu0Yx/Kw/XDAJxxjLAz5gGZQu9N+7JWc8glLNuHKhwRphHgpwnkHb5 XY0VDhCAUfX3Zb4CQ0X2PAIk7gvR8mrSd1ZEXK/WvPSctBJaYrNIJZgmGwPP X-Google-Smtp-Source: AGHT+IE1Y5OtiDowdt5Cuj1A8W+NRrGFMEFUczGfaUxL37GAFaDUvC2/OmT8hhKRR5guZY7sqDYDnw== X-Received: by 2002:a19:7511:0:b0:52e:74f5:d13 with SMTP id 2adb3069b0e04-52eb99a2d2dmr11687060e87.30.1721057360285; Mon, 15 Jul 2024 08:29:20 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbb77sm6767986f8f.72.2024.07.15.08.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:29:19 -0700 (PDT) From: luca.boccassi@gmail.com To: Rongwei Liu Cc: Viacheslav Ovsiienko , dpdk stable Subject: patch 'net/mlx5: fix start without duplicate flow patterns' has been queued to stable release 22.11.6 Date: Mon, 15 Jul 2024 16:26:19 +0100 Message-Id: <20240715152704.2229503-41-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715152704.2229503-1-luca.boccassi@gmail.com> References: <20240624235907.885628-81-luca.boccassi@gmail.com> <20240715152704.2229503-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/17/24. 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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/3a0b6d25c07b19625ef6d6821ff4f1cd34bf81ef Thanks. Luca Boccassi --- >From 3a0b6d25c07b19625ef6d6821ff4f1cd34bf81ef Mon Sep 17 00:00:00 2001 From: Rongwei Liu Date: Thu, 13 Jun 2024 15:45:28 +0300 Subject: [PATCH] net/mlx5: fix start without duplicate flow patterns [ upstream commit 13b5713a627d313d4717923df4c37158b1cb4019 ] When devargs "allow_duplicate_pattern=0" is specified, PMD won't allow duplicated flows to be inserted and return EEXIST as rte_errno. The queue/RSS split table is shared globally by all representors and PMD didn't prepend port information into it, so all the following ports tries to insert the same flows and cause PMD insertion failure. Using the hash list to manage it can solve the issue. Fixes: ddb68e47331e ("net/mlx5: add extended metadata mode for HWS") Signed-off-by: Rongwei Liu Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_os.c | 106 +++++++++++++++++-------------- drivers/net/mlx5/mlx5.c | 2 - drivers/net/mlx5/mlx5.h | 4 +- drivers/net/mlx5/mlx5_flow.c | 16 ++--- 4 files changed, 67 insertions(+), 61 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 8477e83917..bdb2f6fb59 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -455,15 +455,16 @@ __mlx5_discovery_misc5_cap(struct mlx5_priv *priv) * Routine checks the reference counter and does actual * resources creation/initialization only if counter is zero. * - * @param[in] priv - * Pointer to the private device data structure. + * @param[in] eth_dev + * Pointer to the device. * * @return * Zero on success, positive error code otherwise. */ static int -mlx5_alloc_shared_dr(struct mlx5_priv *priv) +mlx5_alloc_shared_dr(struct rte_eth_dev *eth_dev) { + struct mlx5_priv *priv = eth_dev->data->dev_private; struct mlx5_dev_ctx_shared *sh = priv->sh; char s[MLX5_NAME_SIZE] __rte_unused; int err; @@ -575,6 +576,44 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) err = errno; goto error; } + + if (sh->config.dv_flow_en == 1) { + /* Query availability of metadata reg_c's. */ + if (!priv->sh->metadata_regc_check_flag) { + err = mlx5_flow_discover_mreg_c(eth_dev); + if (err < 0) { + err = -err; + goto error; + } + } + if (!mlx5_flow_ext_mreg_supported(eth_dev)) { + DRV_LOG(DEBUG, + "port %u extensive metadata register is not supported", + eth_dev->data->port_id); + if (sh->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { + DRV_LOG(ERR, "metadata mode %u is not supported " + "(no metadata registers available)", + sh->config.dv_xmeta_en); + err = ENOTSUP; + goto error; + } + } + if (sh->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY && + mlx5_flow_ext_mreg_supported(eth_dev) && sh->dv_regc0_mask) { + sh->mreg_cp_tbl = mlx5_hlist_create(MLX5_FLOW_MREG_HNAME, + MLX5_FLOW_MREG_HTABLE_SZ, + false, true, eth_dev, + flow_dv_mreg_create_cb, + flow_dv_mreg_match_cb, + flow_dv_mreg_remove_cb, + flow_dv_mreg_clone_cb, + flow_dv_mreg_clone_free_cb); + if (!sh->mreg_cp_tbl) { + err = ENOMEM; + goto error; + } + } + } #endif if (!sh->tunnel_hub && sh->config.dv_miss_info) err = mlx5_alloc_tunnel_hub(sh); @@ -659,6 +698,10 @@ error: mlx5_list_destroy(sh->dest_array_list); sh->dest_array_list = NULL; } + if (sh->mreg_cp_tbl) { + mlx5_hlist_destroy(sh->mreg_cp_tbl); + sh->mreg_cp_tbl = NULL; + } return err; } @@ -751,6 +794,10 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv) mlx5_list_destroy(sh->dest_array_list); sh->dest_array_list = NULL; } + if (sh->mreg_cp_tbl) { + mlx5_hlist_destroy(sh->mreg_cp_tbl); + sh->mreg_cp_tbl = NULL; + } } /** @@ -1508,13 +1555,6 @@ err_secondary: } /* Create context for virtual machine VLAN workaround. */ priv->vmwa_context = mlx5_vlan_vmwa_init(eth_dev, spawn->ifindex); - if (sh->config.dv_flow_en) { - err = mlx5_alloc_shared_dr(priv); - if (err) - goto error; - if (mlx5_flex_item_port_init(eth_dev) < 0) - goto error; - } if (mlx5_devx_obj_ops_en(sh)) { priv->obj_ops = devx_obj_ops; mlx5_queue_counter_id_prepare(eth_dev); @@ -1565,6 +1605,13 @@ err_secondary: goto error; } rte_rwlock_init(&priv->ind_tbls_lock); + if (sh->config.dv_flow_en) { + err = mlx5_alloc_shared_dr(eth_dev); + if (err) + goto error; + if (mlx5_flex_item_port_init(eth_dev) < 0) + goto error; + } if (priv->sh->config.dv_flow_en == 2) { #ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_esw_en) { @@ -1648,43 +1695,6 @@ err_secondary: err = -err; goto error; } - /* Query availability of metadata reg_c's. */ - if (!priv->sh->metadata_regc_check_flag) { - err = mlx5_flow_discover_mreg_c(eth_dev); - if (err < 0) { - err = -err; - goto error; - } - } - if (!mlx5_flow_ext_mreg_supported(eth_dev)) { - DRV_LOG(DEBUG, - "port %u extensive metadata register is not supported", - eth_dev->data->port_id); - if (sh->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { - DRV_LOG(ERR, "metadata mode %u is not supported " - "(no metadata registers available)", - sh->config.dv_xmeta_en); - err = ENOTSUP; - goto error; - } - } - if (sh->config.dv_flow_en && - sh->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY && - mlx5_flow_ext_mreg_supported(eth_dev) && - priv->sh->dv_regc0_mask) { - priv->mreg_cp_tbl = mlx5_hlist_create(MLX5_FLOW_MREG_HNAME, - MLX5_FLOW_MREG_HTABLE_SZ, - false, true, eth_dev, - flow_dv_mreg_create_cb, - flow_dv_mreg_match_cb, - flow_dv_mreg_remove_cb, - flow_dv_mreg_clone_cb, - flow_dv_mreg_clone_free_cb); - if (!priv->mreg_cp_tbl) { - err = ENOMEM; - goto error; - } - } rte_spinlock_init(&priv->shared_act_sl); mlx5_flow_counter_mode_config(eth_dev); mlx5_flow_drop_action_config(eth_dev); @@ -1703,8 +1713,6 @@ error: priv->sh->config.dv_esw_en) flow_hw_destroy_vport_action(eth_dev); #endif - if (priv->mreg_cp_tbl) - mlx5_hlist_destroy(priv->mreg_cp_tbl); if (priv->sh) mlx5_os_free_shared_dr(priv); if (priv->nl_socket_route >= 0) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 96e732950d..d66254740b 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2090,8 +2090,6 @@ mlx5_dev_close(struct rte_eth_dev *dev) mlx5_devx_cmd_destroy(priv->q_counters); priv->q_counters = NULL; } - if (priv->mreg_cp_tbl) - mlx5_hlist_destroy(priv->mreg_cp_tbl); mlx5_mprq_free_mp(dev); mlx5_os_free_shared_dr(priv); #ifdef HAVE_MLX5_HWS_SUPPORT diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index ca0e9ee647..80dcaf96a3 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1412,6 +1412,8 @@ struct mlx5_dev_ctx_shared { struct mlx5_hlist *flow_tbls; /* SWS flow table. */ struct mlx5_hlist *groups; /* HWS flow group. */ }; + struct mlx5_hlist *mreg_cp_tbl; + /* Hash table of Rx metadata register copy table. */ struct mlx5_flow_tunnel_hub *tunnel_hub; /* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action; /* Pointer to DR drop action, any domain. */ @@ -1771,8 +1773,6 @@ struct mlx5_priv { int nl_socket_rdma; /* Netlink socket (NETLINK_RDMA). */ int nl_socket_route; /* Netlink socket (NETLINK_ROUTE). */ struct mlx5_nl_vlan_vmwa_context *vmwa_context; /* VLAN WA context. */ - struct mlx5_hlist *mreg_cp_tbl; - /* Hash table of Rx metadata register copy table. */ struct mlx5_mtr_config mtr_config; /* Meter configuration */ uint8_t mtr_sfx_reg; /* Meter prefix-suffix flow match REG_C. */ uint8_t mtr_color_reg; /* Meter color match REG_C. */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 1e8d9ac978..a44ccea436 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4871,8 +4871,8 @@ flow_mreg_add_copy_action(struct rte_eth_dev *dev, uint32_t mark_id, }; /* Check if already registered. */ - MLX5_ASSERT(priv->mreg_cp_tbl); - entry = mlx5_hlist_register(priv->mreg_cp_tbl, mark_id, &ctx); + MLX5_ASSERT(priv->sh->mreg_cp_tbl); + entry = mlx5_hlist_register(priv->sh->mreg_cp_tbl, mark_id, &ctx); if (!entry) return NULL; return container_of(entry, struct mlx5_flow_mreg_copy_resource, @@ -4911,10 +4911,10 @@ flow_mreg_del_copy_action(struct rte_eth_dev *dev, return; mcp_res = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MCP], flow->rix_mreg_copy); - if (!mcp_res || !priv->mreg_cp_tbl) + if (!mcp_res || !priv->sh->mreg_cp_tbl) return; MLX5_ASSERT(mcp_res->rix_flow); - mlx5_hlist_unregister(priv->mreg_cp_tbl, &mcp_res->hlist_ent); + mlx5_hlist_unregister(priv->sh->mreg_cp_tbl, &mcp_res->hlist_ent); flow->rix_mreg_copy = 0; } @@ -4936,14 +4936,14 @@ flow_mreg_del_default_copy_action(struct rte_eth_dev *dev) uint32_t mark_id; /* Check if default flow is registered. */ - if (!priv->mreg_cp_tbl) + if (!priv->sh->mreg_cp_tbl) return; mark_id = MLX5_DEFAULT_COPY_ID; ctx.data = &mark_id; - entry = mlx5_hlist_lookup(priv->mreg_cp_tbl, mark_id, &ctx); + entry = mlx5_hlist_lookup(priv->sh->mreg_cp_tbl, mark_id, &ctx); if (!entry) return; - mlx5_hlist_unregister(priv->mreg_cp_tbl, entry); + mlx5_hlist_unregister(priv->sh->mreg_cp_tbl, entry); } /** @@ -4981,7 +4981,7 @@ flow_mreg_add_default_copy_action(struct rte_eth_dev *dev, */ mark_id = MLX5_DEFAULT_COPY_ID; ctx.data = &mark_id; - if (mlx5_hlist_lookup(priv->mreg_cp_tbl, mark_id, &ctx)) + if (mlx5_hlist_lookup(priv->sh->mreg_cp_tbl, mark_id, &ctx)) return 0; mcp_res = flow_mreg_add_copy_action(dev, mark_id, error); if (!mcp_res) -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-15 16:19:36.730951647 +0100 +++ 0041-net-mlx5-fix-start-without-duplicate-flow-patterns.patch 2024-07-15 16:19:34.556206207 +0100 @@ -1 +1 @@ -From 13b5713a627d313d4717923df4c37158b1cb4019 Mon Sep 17 00:00:00 2001 +From 3a0b6d25c07b19625ef6d6821ff4f1cd34bf81ef Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 13b5713a627d313d4717923df4c37158b1cb4019 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -28 +29 @@ -index 1753acd050..50f4810bff 100644 +index 8477e83917..bdb2f6fb59 100644 @@ -31 +32 @@ -@@ -467,15 +467,16 @@ __mlx5_discovery_misc5_cap(struct mlx5_priv *priv) +@@ -455,15 +455,16 @@ __mlx5_discovery_misc5_cap(struct mlx5_priv *priv) @@ -51 +52 @@ -@@ -590,6 +591,44 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) +@@ -575,6 +576,44 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) @@ -96 +97 @@ -@@ -674,6 +713,10 @@ error: +@@ -659,6 +698,10 @@ error: @@ -107 +108 @@ -@@ -771,6 +814,10 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv) +@@ -751,6 +794,10 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv) @@ -118 +119 @@ -@@ -1572,13 +1619,6 @@ err_secondary: +@@ -1508,13 +1555,6 @@ err_secondary: @@ -132 +133 @@ -@@ -1629,6 +1669,13 @@ err_secondary: +@@ -1565,6 +1605,13 @@ err_secondary: @@ -143,4 +144,4 @@ - if (sh->phdev->config.ipv6_tc_fallback == MLX5_IPV6_TC_UNKNOWN) { - sh->phdev->config.ipv6_tc_fallback = MLX5_IPV6_TC_OK; - if (!sh->cdev->config.hca_attr.modify_outer_ipv6_traffic_class || -@@ -1715,43 +1762,6 @@ err_secondary: + if (priv->sh->config.dv_flow_en == 2) { + #ifdef HAVE_MLX5_HWS_SUPPORT + if (priv->sh->config.dv_esw_en) { +@@ -1648,43 +1695,6 @@ err_secondary: @@ -190 +191 @@ -@@ -1770,8 +1780,6 @@ error: +@@ -1703,8 +1713,6 @@ error: @@ -200 +201 @@ -index 997b02c571..e482f7f0e5 100644 +index 96e732950d..d66254740b 100644 @@ -203 +204 @@ -@@ -2394,8 +2394,6 @@ mlx5_dev_close(struct rte_eth_dev *dev) +@@ -2090,8 +2090,6 @@ mlx5_dev_close(struct rte_eth_dev *dev) @@ -213 +214 @@ -index c9a3837bd2..bd149b43e5 100644 +index ca0e9ee647..80dcaf96a3 100644 @@ -216 +217 @@ -@@ -1542,6 +1542,8 @@ struct mlx5_dev_ctx_shared { +@@ -1412,6 +1412,8 @@ struct mlx5_dev_ctx_shared { @@ -225 +226 @@ -@@ -1968,8 +1970,6 @@ struct mlx5_priv { +@@ -1771,8 +1773,6 @@ struct mlx5_priv { @@ -233 +234 @@ - struct mlx5_legacy_flow_meters flow_meters; /* MTR list. */ + uint8_t mtr_color_reg; /* Meter color match REG_C. */ @@ -235 +236 @@ -index daf0e41c6f..833db1f320 100644 +index 1e8d9ac978..a44ccea436 100644 @@ -238 +239 @@ -@@ -5201,8 +5201,8 @@ flow_mreg_add_copy_action(struct rte_eth_dev *dev, uint32_t mark_id, +@@ -4871,8 +4871,8 @@ flow_mreg_add_copy_action(struct rte_eth_dev *dev, uint32_t mark_id, @@ -249 +250 @@ -@@ -5241,10 +5241,10 @@ flow_mreg_del_copy_action(struct rte_eth_dev *dev, +@@ -4911,10 +4911,10 @@ flow_mreg_del_copy_action(struct rte_eth_dev *dev, @@ -262 +263 @@ -@@ -5266,14 +5266,14 @@ flow_mreg_del_default_copy_action(struct rte_eth_dev *dev) +@@ -4936,14 +4936,14 @@ flow_mreg_del_default_copy_action(struct rte_eth_dev *dev) @@ -280 +281 @@ -@@ -5311,7 +5311,7 @@ flow_mreg_add_default_copy_action(struct rte_eth_dev *dev, +@@ -4981,7 +4981,7 @@ flow_mreg_add_default_copy_action(struct rte_eth_dev *dev,