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 06424A0350; Mon, 28 Feb 2022 08:10:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D58E04115F; Mon, 28 Feb 2022 08:10:15 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2074.outbound.protection.outlook.com [40.107.93.74]) by mails.dpdk.org (Postfix) with ESMTP id 0F5C44115D; Mon, 28 Feb 2022 08:10:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwPoQhv/+nrO1YOoyY4kCqZ+CfT/s3wrTBbTtiB3jFMTX7bg+6xYdhwAX4tA+VDUWpMeIhsTeLc/4GWPzgV6v7u44yCgYKy+FNIxyRY4vxzGFixZ4DuaxPVIqt+zePchvXfvc7DrP221/Z0PA1tY3zjrQfSSjn2QfG+tWwHlkr8ZEZbhPTY4JH5SNehTHityJgvTuIIN/TpDZrtgWJPAUbuHrIjyRPz1hhD8mZQd+i1xPfvyhOTl6kD7x78HX0TI4JB0q6Cg47z/dpdSIb3dd/sOf5NIasXHv48cijk47YDbl+4bl8kv3Zk2vyi8ijgLIcaE917G2/+CMJxO4PMJPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V6OOoimpfg2CER1P5z6Fz2Z2PgsePdLcRMNBPQqSt28=; b=C+KmIjilABx7c/wdX6W4yL8TmQ7pq/kESOTlqPe826JVIf1zqs4c5TjlDPJPfXrsOrBCVw/GaaK/2i0Fz8U99S5PEHCjpSyXVtvL4ySrSDhgMqqhamOELy0bIQDmeFEDp/hiUr9XTkPfQ7MLR4BF5Oks+iUNx01ApAHSHLGBb7UTRYaze9iIUcTlb67TNM7drkywY/Ul8GJutMKTY98dcst5VbbLDPssi7i9+mqlag2qKavW/SywTCCZd9LJ5/s2z/qziJy0/yqwNzxvGv5uX7+b9ng3NLn02MVaQIgfqiGbuZrGh6aoRUGU3rNPDLypH/nhwyfOKu6FVb1FAbSPUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V6OOoimpfg2CER1P5z6Fz2Z2PgsePdLcRMNBPQqSt28=; b=bep28tboBySVxxSxe/PhWuPMXF9Ya9w6D3ffE/R+OEosJLowfdWoZxYBrt3vtI7QGYjeMRlH5DYH3OgQMVF4U2aJO+2X+N82Zsf7V3KS1qcQhEociEzw6qGntvuYOvTLJq+G+py4F/lP3Gdnvdf7j8KJNk9CW7DMFCcyINwxp/81yCxSZiViHyEgIVsNwanwb8IZM8ZX05tAe1QN+MNJJr+mNLWmbf4ITujZY0Fwi9S/YrH6yGeHmvWBE1TEmr95HPnUKZvNjMxQU60vfF2TEBE/0kKqOK+uPnpNPNHh1Zzlq2iMvJWySMSnZRdwVmXShehCXGLoyZ6pDZQFHrzF4w== Received: from BN6PR13CA0053.namprd13.prod.outlook.com (2603:10b6:404:11::15) by BY5PR12MB5527.namprd12.prod.outlook.com (2603:10b6:a03:1d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.24; Mon, 28 Feb 2022 07:10:12 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:404:11:cafe::11) by BN6PR13CA0053.outlook.office365.com (2603:10b6:404:11::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.10 via Frontend Transport; Mon, 28 Feb 2022 07:10:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5017.22 via Frontend Transport; Mon, 28 Feb 2022 07:10:12 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 28 Feb 2022 07:10:06 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Sun, 27 Feb 2022 23:10:05 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Sun, 27 Feb 2022 23:10:03 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Subject: [PATCH 2/2] net/mlx5: fix insufficient check in count action validation Date: Mon, 28 Feb 2022 09:09:54 +0200 Message-ID: <20220228070954.3813602-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228070954.3813602-1-michaelba@nvidia.com> References: <20220228070954.3813602-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15c5ccc5-bac4-4431-dfdf-08d9fa895cc6 X-MS-TrafficTypeDiagnostic: BY5PR12MB5527:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fc9JD1ntvuyEYRavDqWIAT87bx9qlJQakIszjcXi4k8hilUlQ+YWIhGOdeQkR+Ic/+bmRQ0LS6ojNbh3+2dLjQ55MjG1/sisDFmq9pHkpcdSAuzXWM0CyXpF8aOCRApapshUkDyHsPta+YJcC39C7bYdHku+VsqEaL9R0+LXyGQKrzwHS6+rfiS0wrwcJ08z16QcPRbrmoPTcWDlIWo0YmqNryZJ3YfTfYOwTytxhSz7Vzn0GV5bj+szhWweYyLfySAMt5G3FRjSGEoEIwyG/RkLFa7GgCExofX7WXWhIwLLoPHPrrGfu89brysVMB0JWpuhBpE1d85WrX+df0e2nSYKE65Wa4cQt4yOE7YNjir1ukyBwvxWo21YN0jsfv0myv6APrMi+KP3rtIzBuDy9rcdgNA8x0OFUJpyfc87EcN/Q6rp50IgO8IylkXFHV3ex//iwL4GkmZdbz1SRqjTwUvpki2MeLEdseOTybSIao1gfGkN32Cq3sIPHrtLiV8kSaJS1l6q5zaWCFQ59PZrboVk/aa0p/Tfk/+kOayrXbuf09QMxnZL3wCkOMKPfIGaqtrpGRWf2mAatJ1sKxeUto+2Ysxzb7Zsp8dmsnlvspJ8AumNDkMzHLhZOKEZ0AGSwIzqaH8D7+pB6MNo0upMsI8VS7VrYIHv5WLPVfDlTZIx7XCzbuykPFZheDnduhQTfQfguFGyMJyuWvj1gPbpzQ== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(81166007)(356005)(2906002)(86362001)(55016003)(36756003)(82310400004)(40460700003)(6286002)(2616005)(186003)(26005)(426003)(508600001)(336012)(1076003)(36860700001)(6666004)(7696005)(8676002)(6916009)(4326008)(47076005)(8936002)(5660300002)(83380400001)(316002)(70206006)(70586007)(54906003)(450100002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 07:10:12.1136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15c5ccc5-bac4-4431-dfdf-08d9fa895cc6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB5527 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The AGE action can be implemented by either counters or ASO mechanism. ASO is more efficient than generating counters just for the purpose of aging, so when ASO is supported its use is preferable. On the other hand, when there is count in the list of actions, the counter is already generated, and it is best to use it for aging even if ASO is supported. On the other hand, when the count action is "indirect", it cannot be used for aging since it may be updated from other flow rules in which it participates. Checking whether ASO is supported depends on both the capability of the device and the flow rule group number, ASO is not supported for group 0. However, the flow_dv_validate() function only checks the capability and ignores the group, allowing inadmissible flow rules. For example, when the device supports ASO and a flow rule is set that combines an indirect counter with aging for group 0, the rule should be rejected, but it is created and does not function properly. This patch updates the counter validation which will also consider the group number when deciding if there is ASO support. Fixes: daed4b6e3db2 ("net/mlx5: use aging by counter when counter exists") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 41 +++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index de6bf8c660..e5be435e32 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3277,6 +3277,25 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev, return 0; } +/** + * Indicates whether ASO aging is supported. + * + * @param[in] sh + * Pointer to shared device context structure. + * @param[in] attr + * Attributes of flow that includes AGE action. + * + * @return + * True when ASO aging is supported, false otherwise. + */ +static inline bool +flow_hit_aso_supported(const struct mlx5_dev_ctx_shared *sh, + const struct rte_flow_attr *attr) +{ + MLX5_ASSERT(sh && attr); + return (sh->flow_hit_aso_en && (attr->transfer || attr->group)); +} + /** * Validate count action. * @@ -3286,6 +3305,8 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev, * Indicator if action is shared. * @param[in] action_flags * Holds the actions detected until now. + * @param[in] attr + * Attributes of flow that includes this action. * @param[out] error * Pointer to error structure. * @@ -3295,6 +3316,7 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev, static int flow_dv_validate_action_count(struct rte_eth_dev *dev, bool shared, uint64_t action_flags, + const struct rte_flow_attr *attr, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; @@ -3306,10 +3328,10 @@ flow_dv_validate_action_count(struct rte_eth_dev *dev, bool shared, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "duplicate count actions set"); if (shared && (action_flags & MLX5_FLOW_ACTION_AGE) && - !priv->sh->flow_hit_aso_en) + !flow_hit_aso_supported(priv->sh, attr)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "old age and shared count combination is not supported"); + "old age and indirect count combination is not supported"); #ifdef HAVE_IBV_FLOW_DEVX_COUNTERS return 0; #endif @@ -5679,7 +5701,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, case RTE_FLOW_ACTION_TYPE_COUNT: ret = flow_dv_validate_action_count (dev, false, *action_flags | sub_action_flags, - error); + attr, error); if (ret < 0) return ret; *count = act->conf; @@ -7441,7 +7463,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, case RTE_FLOW_ACTION_TYPE_COUNT: ret = flow_dv_validate_action_count(dev, shared_count, action_flags, - error); + attr, error); if (ret < 0) return ret; action_flags |= MLX5_FLOW_ACTION_COUNT; @@ -7756,15 +7778,15 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, return ret; /* * Validate the regular AGE action (using counter) - * mutual exclusion with share counter actions. + * mutual exclusion with indirect counter actions. */ - if (!priv->sh->flow_hit_aso_en) { + if (!flow_hit_aso_supported(priv->sh, attr)) { if (shared_count) return rte_flow_error_set (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "old age and shared count combination is not supported"); + "old age and indirect count combination is not supported"); if (sample_count) return rte_flow_error_set (error, EINVAL, @@ -13415,8 +13437,7 @@ flow_dv_translate(struct rte_eth_dev *dev, */ if (action_flags & MLX5_FLOW_ACTION_AGE) { if ((non_shared_age && count) || - !(priv->sh->flow_hit_aso_en && - (attr->group || attr->transfer))) { + !flow_hit_aso_supported(priv->sh, attr)) { /* Creates age by counters. */ cnt_act = flow_dv_prepare_counter (dev, dev_flow, @@ -17709,7 +17730,7 @@ flow_dv_action_validate(struct rte_eth_dev *dev, "Indirect age action not supported"); return flow_dv_validate_action_age(0, action, dev, err); case RTE_FLOW_ACTION_TYPE_COUNT: - return flow_dv_validate_action_count(dev, true, 0, err); + return flow_dv_validate_action_count(dev, true, 0, NULL, err); case RTE_FLOW_ACTION_TYPE_CONNTRACK: if (!priv->sh->ct_aso_en) return rte_flow_error_set(err, ENOTSUP, -- 2.25.1