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 9F0ABA0C40 for ; Thu, 5 Aug 2021 11:53:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 98FDF40040; Thu, 5 Aug 2021 11:53:19 +0200 (CEST) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id 4C5D740040 for ; Thu, 5 Aug 2021 11:53:18 +0200 (CEST) Received: by mail-wm1-f48.google.com with SMTP id l8-20020a05600c1d08b02902b5acf7d8b5so2540616wms.2 for ; Thu, 05 Aug 2021 02:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2QRzGTIFuOV1v9u1091y8fe5G2MVravR9nxcEvurugc=; b=ZMQrZC1B+DRLju6aBYM9wLd6dxHC6RvzZmOtx6abOaxoIQVvELokhbMed6pcK9j4tC otb2fe46uutcrkRWv2AxdkzEJhXmo8jajT184xhYbEnnilYrI2k3IpEmnU9odlSXDPRs dxGFV4ZiI/tzi8hsc2dxihhvuEnSxXqj0OcltM68jMTPYcw655WtE2BxgF2xQad9GoDc UKpJQW+R2oJDzUsIR7P9ZyVtxyEOVz7kmCC4vtNMhlTADlWn0cjnEU4PWE85bpVRGqHg 2tuKl9H46DGeSuZxYdY3uwwlQX0EjasrPk2KpTRWMDmV7DSif6z8O3QNIB5XWRqj3b9d /nzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2QRzGTIFuOV1v9u1091y8fe5G2MVravR9nxcEvurugc=; b=CmiJedaY5Ahh7ZF6u39fWSs7A++vR34VgFVrT84NlMQiCxVYFUny6x8pmiZ8+scDCJ zcZh5juj2CHWPVLUEH2KuU7dOwlzEiAUMfIh9Ks3lLmJOZYQud9WiCNmm2q+noucaCBo 50m8fZ0bBt7UEINo8NPFh9aJbWpOp5Z2Kklo0bx3ZY/l1zhm3xnH1DbTAFxloj7EvrnK Q9f2cHpR9wRk1SYLJ3tISQU1CQhgalz6znH2Kk2qQG5mr/EK+go9VKzrHFRtfpN0Wttx x4tgLbCQeRPuDxxOTVpSRs9XN40tHAKs4Ha6IMs5XvPzngyu7YTUQgxznrJf21asskHv vpsg== X-Gm-Message-State: AOAM530EEzuVOSNEHeP/K5hsXfVwbPbT3d8iUVJHuEjGRDjWVMdBUxmO MfovPDttR1H5hsSCU/sCSxk= X-Google-Smtp-Source: ABdhPJzdUSYesJEOdYBc5Tl/v0zMUWfIS8o3TtFPO8QXvfkTSX7CGVcn07XwiAvrxM3MjYdTBKp7OQ== X-Received: by 2002:a1c:1b55:: with SMTP id b82mr14335273wmb.121.1628157198037; Thu, 05 Aug 2021 02:53:18 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id r133sm10506859wma.18.2021.08.05.02.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 02:53:17 -0700 (PDT) From: luca.boccassi@gmail.com To: Suanming Mou Cc: Matan Azrad , dpdk stable Date: Thu, 5 Aug 2021 10:53:12 +0100 Message-Id: <20210805095314.1755018-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210803122214.1094992-25-luca.boccassi@gmail.com> References: <20210803122214.1094992-25-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx5: workaround drop action with old kernel' has been queued to stable release 20.11.3 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/07/21. 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/53193aeeba442cc83bf58aec6449778ced80c465 Thanks. Luca Boccassi --- >From 53193aeeba442cc83bf58aec6449778ced80c465 Mon Sep 17 00:00:00 2001 From: Suanming Mou Date: Mon, 2 Aug 2021 17:30:24 +0300 Subject: [PATCH] net/mlx5: workaround drop action with old kernel [ upstream commit 45633c460c223a67dd1a7cc084c3eceb5e17687c ] Currently, there are two types of drop action implementation in the PMD. One is the DR (Direct Rules) dummy placeholder drop action and another is the dedicated dummy queue drop action. When creates flow on the root table with DR drop action, the action will be converted to MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs attribute in rdma-core. In some inbox systems, MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs attribute may not be supported in the kernel driver. Create flow with drop action on the root table will be failed as it is not supported. In this case, the dummy queue drop action should be used instead of DR dummy placeholder drop action. This commit adds the DR drop action support detect on the root table. If MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs is not supported in the system, a dummy queue will be used as drop action. Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs") Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 27 ++++++++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 70 +++++++++++++++++++++++++++++++- 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index b191fd740e..e4843f1c6d 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -651,6 +651,32 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) #endif } +/** + * DR flow drop action support detect. + * + * @param dev + * Pointer to rte_eth_dev structure. + * + */ +static void +mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused) +{ +#ifdef HAVE_MLX5DV_DR + struct mlx5_priv *priv = dev->data->dev_private; + + if (!priv->config.dv_flow_en || !priv->sh->dr_drop_action) + return; + /** + * DR supports drop action placeholder when it is supported; + * otherwise, use the queue drop action. + */ + if (mlx5_flow_discover_dr_action_support(dev)) + priv->root_drop_action = priv->drop_queue.hrxq->action; + else + priv->root_drop_action = priv->sh->dr_drop_action; +#endif +} + /** * Spawn an Ethernet device from Verbs information. * @@ -1587,6 +1613,7 @@ err_secondary: } rte_spinlock_init(&priv->shared_act_sl); mlx5_flow_counter_mode_config(eth_dev); + mlx5_flow_drop_action_config(eth_dev); if (priv->config.dv_flow_en) eth_dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; return eth_dev; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 831838768a..1946110f7c 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -969,6 +969,7 @@ struct mlx5_priv { unsigned int reta_idx_n; /* RETA index size. */ struct mlx5_drop drop_queue; /* Flow drop queues. */ uint32_t flows; /* RTE Flow rules. */ + void *root_drop_action; /* Pointer to root drop action. */ uint32_t ctrl_flows; /* Control flow rules. */ rte_spinlock_t flow_list_lock; struct mlx5_obj_ops obj_ops; /* HW objects operations. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 9b72cde5ff..56af30c2bb 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1429,6 +1429,7 @@ int mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error); int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev); int mlx5_shared_action_flush(struct rte_eth_dev *dev); +int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev); void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id); int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1b9637ac44..1793683421 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -10840,7 +10840,9 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, #ifdef HAVE_MLX5DV_DR /* DR supports drop action placeholder. */ MLX5_ASSERT(priv->sh->dr_drop_action); - dv->actions[n++] = priv->sh->dr_drop_action; + dv->actions[n++] = dv->group ? + priv->sh->dr_drop_action : + priv->root_drop_action; #else /* For DV we use the explicit drop queue. */ MLX5_ASSERT(priv->drop_queue.hrxq); @@ -12567,6 +12569,72 @@ error: flow_dv_destroy_policer_rules(dev, fm, attr); return -1; } +/** + * Check whether the DR drop action is supported on the root table or not. + * + * Create a simple flow with DR drop action on root table to validate + * if DR drop action on root table is supported or not. + * + * @param[in] dev + * Pointer to rte_eth_dev structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_dev_ctx_shared *sh = priv->sh; + struct mlx5_flow_dv_match_params mask = { + .size = sizeof(mask.buf), + }; + struct mlx5_flow_dv_match_params value = { + .size = sizeof(value.buf), + }; + struct mlx5dv_flow_matcher_attr dv_attr = { + .type = IBV_FLOW_ATTR_NORMAL, + .priority = 0, + .match_criteria_enable = 0, + .match_mask = (void *)&mask, + }; + struct mlx5_flow_tbl_resource *tbl = NULL; + void *matcher = NULL; + void *flow = NULL; + int ret = -1; + + tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, false, NULL, + 0, 0, NULL); + if (!tbl) + goto err; + dv_attr.match_criteria_enable = flow_dv_matcher_enable(mask.buf); + ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, tbl->obj, + &matcher); + if (ret) + goto err; + ret = mlx5_flow_os_create_flow(matcher, (void *)&value, 1, + &sh->dr_drop_action, &flow); +err: + /* + * If DR drop action is not supported on root table, flow create will + * be failed with EOPNOTSUPP or EPROTONOSUPPORT. + */ + if (!flow) { + if (matcher && + (errno == EPROTONOSUPPORT || errno == EOPNOTSUPP)) + DRV_LOG(INFO, "DR drop action is not supported in root table."); + else + DRV_LOG(ERR, "Unexpected error in DR drop action support detection"); + ret = -1; + } else { + claim_zero(mlx5_flow_os_destroy_flow(flow)); + } + if (matcher) + claim_zero(mlx5_flow_os_destroy_flow_matcher(matcher)); + if (tbl) + flow_dv_tbl_resource_release(MLX5_SH(dev), tbl); + return ret; +} /** * Validate the batch counter support in root table. -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-08-05 09:55:22.631834423 +0100 +++ 0001-net-mlx5-workaround-drop-action-with-old-kernel.patch 2021-08-05 09:55:22.594740105 +0100 @@ -1 +1 @@ -From 45633c460c223a67dd1a7cc084c3eceb5e17687c Mon Sep 17 00:00:00 2001 +From 53193aeeba442cc83bf58aec6449778ced80c465 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 45633c460c223a67dd1a7cc084c3eceb5e17687c ] + @@ -25 +26,0 @@ -Cc: stable@dpdk.org @@ -33,2 +34,2 @@ - drivers/net/mlx5/mlx5_flow_dv.c | 72 +++++++++++++++++++++++++++++++- - 4 files changed, 100 insertions(+), 1 deletion(-) + drivers/net/mlx5/mlx5_flow_dv.c | 70 +++++++++++++++++++++++++++++++- + 4 files changed, 98 insertions(+), 1 deletion(-) @@ -37 +38 @@ -index c15a44de86..eeeca27ac2 100644 +index b191fd740e..e4843f1c6d 100644 @@ -40 +41 @@ -@@ -786,6 +786,32 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) +@@ -651,6 +651,32 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) @@ -70,4 +71,4 @@ - static void - mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev) - { -@@ -1875,6 +1901,7 @@ err_secondary: + /** + * Spawn an Ethernet device from Verbs information. + * +@@ -1587,6 +1613,7 @@ err_secondary: @@ -82 +83 @@ -index faafe3d3f1..34d66e93ad 100644 +index 831838768a..1946110f7c 100644 @@ -85,2 +86 @@ -@@ -1411,6 +1411,7 @@ struct mlx5_priv { - unsigned int (*reta_idx)[]; /* RETA index table. */ +@@ -969,6 +969,7 @@ struct mlx5_priv { @@ -88,0 +89 @@ + uint32_t flows; /* RTE Flow rules. */ @@ -90,2 +90,0 @@ - struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI]; - /* RTE Flow rules. */ @@ -92,0 +92,2 @@ + rte_spinlock_t flow_list_lock; + struct mlx5_obj_ops obj_ops; /* HW objects operations. */ @@ -94 +95 @@ -index 22fa007b42..76ad53f2a1 100644 +index 9b72cde5ff..56af30c2bb 100644 @@ -97,3 +98,2 @@ -@@ -1572,6 +1572,7 @@ struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare - void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, - struct mlx5_flow_meter_policy *mtr_policy); +@@ -1429,6 +1429,7 @@ int mlx5_flow_meter_flush(struct rte_eth_dev *dev, + struct rte_mtr_error *error); @@ -100,0 +101 @@ + int mlx5_shared_action_flush(struct rte_eth_dev *dev); @@ -102 +102,0 @@ - int mlx5_action_handle_flush(struct rte_eth_dev *dev); @@ -104,0 +105 @@ + @@ -106 +107 @@ -index ae0975e8b3..4644ae46bd 100644 +index 1b9637ac44..1793683421 100644 @@ -109 +110 @@ -@@ -13786,7 +13786,9 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, +@@ -10840,7 +10840,9 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, @@ -120,3 +121,3 @@ -@@ -17100,6 +17102,74 @@ flow_dv_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, - } - rte_spinlock_unlock(&mtr_policy->sl); +@@ -12567,6 +12569,72 @@ error: + flow_dv_destroy_policer_rules(dev, fm, attr); + return -1; @@ -159 +160 @@ -+ 0, 0, 0, NULL); ++ 0, 0, NULL); @@ -163 +163,0 @@ -+ __flow_dv_adjust_buf_size(&mask.size, dv_attr.match_criteria_enable); @@ -168 +167,0 @@ -+ __flow_dv_adjust_buf_size(&value.size, dv_attr.match_criteria_enable);