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 60B8242F70 for ; Fri, 28 Jul 2023 20:25:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3956440685; Fri, 28 Jul 2023 20:25:47 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2087.outbound.protection.outlook.com [40.107.243.87]) by mails.dpdk.org (Postfix) with ESMTP id 58A324021E for ; Fri, 28 Jul 2023 20:25:45 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCRcNBONbIurujly5vIfJon24fUEusoYEUQcb0a+xg1sC5ETcmG6BI/WiFnhwQ8NcsHvXl9Kvmc7BOmOaiM9oeiHAX9WH7SAO4mIEDwN3ju2RVuF4JXM/IZssZ/phJyfr/oQbmk/3pCVBY85N9ACYYVYpoLd2/y8pb8VBTRgIe6E4zLnBu/XPLySoTy81AYBDab1xWeWqfezsfBCKTMRfM9tlMopfvjVKfaGttpt/oHRrInfdI72UImPi7Yig2o7m1MKnyhOOGCXm2+fQjtmvqh6mq/620hQEg0nJJlMXVuLgEKExIu3yIdau7ez+Be0KKrT1VDhnigGKD7fpjB0MA== 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=K3QeglE1XtrWMxiPj+xoWNsQePqoNrBIvc3vZOCQnPI=; b=N5RaKfzJH1SJIvLTVDdff1dh3QIE6wOdW4wN71am0zp/LuOLIPKLzr/y9dSkEswq5YCaxGVIb33f9AsVLFrUAkyXPntIXz5lKDAucjeJu4asgDLepJWuHJNjOvbi8vABXTgl5an8nHqkHDWkztU2q/boRHC30ssiVV9GYxGE8Ovbaw31z5adVymBbKg2Wcbo2HPaLmrG9MmY/nveg1DQpeklTx+5uzMeXqK0kcCOFd9m9FVNN2phIp/2y2oY7XVUj+e2fzMpl5fh7cyMjR+bLcf/M2bpMAa2rcR5XpA/gk/wFwCfLj2es/dOuIyeE7AL0czRsxbqo0VMcKIghPhbEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=K3QeglE1XtrWMxiPj+xoWNsQePqoNrBIvc3vZOCQnPI=; b=mK98bvzCQPLX8IS+RovVpx0Z2XhrNwSy7yo2MwQk1+m4SYA2H0ft3wm9Xwszv39haJs0jtvZsFcZRYM1hcGVWsab4yOhG0dHEVMaI/94qsS1kwZCygLPtD8LeiY7NFRZxun5pkLuZsfGG0uBJN+LT3j8UD8UOCpPXDX8IRRzDFTK2UBzzSZT+nCFGJJKQXlgIva563e6Nx2OukvhildT/+WWCytkNv1Ijh1mq4xlMeYdTRrY3WiwD3Fg+0RxUy+sIoBcme8AO+22JOEYwYDSydGXOrUfMHQa7OzyiJfydXwZHMYM2IcCs0lNR18gCZv+nX0dI9jUFTxcdNsyI5nrwA== Received: from CY5PR15CA0073.namprd15.prod.outlook.com (2603:10b6:930:18::21) by CY5PR12MB6083.namprd12.prod.outlook.com (2603:10b6:930:29::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Fri, 28 Jul 2023 18:25:43 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:930:18:cafe::a2) by CY5PR15CA0073.outlook.office365.com (2603:10b6:930:18::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.34 via Frontend Transport; Fri, 28 Jul 2023 18:25:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Fri, 28 Jul 2023 18:25:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Fri, 28 Jul 2023 11:25:35 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Fri, 28 Jul 2023 11:25:32 -0700 From: Dariusz Sosnowski To: CC: Kevin Traynor , Viacheslav Ovsiienko , Matan Azrad , Jiawei Wang , Suanming Mou Subject: [PATCH 21.11] net/mlx5: fix drop action attribute validation Date: Fri, 28 Jul 2023 21:25:18 +0300 Message-ID: <20230728182518.1302464-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE30:EE_|CY5PR12MB6083:EE_ X-MS-Office365-Filtering-Correlation-Id: 46798742-c8bf-4425-0e6f-08db8f980daa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HtwIuT0h8wvxHuXkAzVpRmPwOBQ1DF4WB6RiRXbQqAO98ldk/vze0kXsdHf3Coc3SNzLqyNDdVtOTH1HCCStKHvrFGa1FNoBODSLBkHd6601ZBlfNob1I/QIrpqpImUIr+FA8AlLUQIcvlBuVVyvPSH1+CguNLG+zsEPDnW7kXDLyESjXaZngCj+FgLcv3jCkBTzm/GcqzRUICllEzI7MruTeX2vmjhOOKBlOo4p71yZ6NktNZTqw5cDoCrcX/0jtuKRoRfY6mPVeXgptVzpGV6ls0GHKV9m4poQthCfkr0yPhez+22S+OXYhy5cAA11cWli0e2Nzg1ObszUuA8vSjpzD8WEPu2ZAwcEqqDwcpFcfnu4OCCvdZLvgtKjVda0PcCJ2D41n6ZIDC7zXmQd1MSCXDoPnDJfQMgomok2EMJ8yh74/t5pUfWdBnOaP56yc9dxemOM9Zk6O87t1DyBKiHjQsLGz5j2kovEppgVMuQt25Ss0WREj6/fRDcvoRHtvhLn0Eqst8d5TN9SgJm7UDtjxBVeWZnt1knyoa7gRcyc4Q2JueZ6038Wfr48bNG/eLrtpGpdjPO3IWiSxfBB+RDZMnCggKDK9a1jeFopor/DqdGVCnE13ttx/s9Ng3mcE638oRCdg9ftVdOI8wB2hKjueOMNaNc0aCEMd88yyMLgZEBHFFZTRrYWiqkhY39/x7WWdRraj7kRZuh/ZIlNBQKx62P4VftbmPp0i9nzhARwDEfhR7tHN5lnLNd/xDcS X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(376002)(136003)(396003)(82310400008)(451199021)(46966006)(36840700001)(40470700004)(2906002)(7636003)(47076005)(426003)(83380400001)(40480700001)(2616005)(6286002)(70206006)(186003)(26005)(70586007)(336012)(16526019)(6666004)(1076003)(478600001)(54906003)(7696005)(55016003)(356005)(86362001)(82740400003)(36860700001)(41300700001)(316002)(40460700003)(4326008)(6916009)(8936002)(8676002)(36756003)(5660300002)(107886003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2023 18:25:42.9169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46798742-c8bf-4425-0e6f-08db8f980daa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6083 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 [ upstream commit c1f0cdae14c5399cd6201e6cf39d5e51f60c6efb ] Before this patch, DROP flow action was rejected for all egress flow rules, which was not correct for all cases. When Verbs flow engine is used (dv_flow_en=0) DROP flow action is implemented using IBV_FLOW_SPEC_ACTION_DROP IBV action. This action is supported on ingress only. This patch amends the DROP flow action validation to allow it only on ingress. When DV flow engine is used (dv_flow_en=1) there are 2 implementation options for DROP flow action: - DR drop action (allocated through mlx5dv_dr_action_create_drop() API), - dedicated drop queue. When flow rules are created on non-root flow tables DR drop action can be used on all steering domains. On root flow table however, this action ca be used if and only if it is supported by rdma-core and kernel drivers. mlx5 PMD dynamically checks if DR drop action is supported on root tables during device probing (it is checked in mlx5_flow_discover_dr_action_support()). If DR drop action is not supported on root table, then dedicated drop queue must be used and as a result, DROP flow action on root is supported only for ingress flow rules. This patch amends the DROP flow action validation with this logic for DV flow engine. This patch also renames the dr_drop_action_en field in device's private data to dr_root_drop_action_en to align the name with field's meaning. Fixes: 3c4338a42134 ("net/mlx5: optimize device spawn time with representors") Fixes: 45633c460c22 ("net/mlx5: workaround drop action with old kernel") Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs") Cc: stable@dpdk.org Signed-off-by: Dariusz Sosnowski Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_os.c | 4 ++-- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 20 ++++++++++++++++---- drivers/net/mlx5/mlx5_flow.h | 3 ++- drivers/net/mlx5/mlx5_flow_dv.c | 4 ++-- drivers/net/mlx5/mlx5_flow_verbs.c | 5 ++++- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 2fee13d50f..45f96e0eff 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -722,10 +722,10 @@ mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused) */ if (!priv->sh->drop_action_check_flag) { if (!mlx5_flow_discover_dr_action_support(dev)) - priv->sh->dr_drop_action_en = 1; + priv->sh->dr_root_drop_action_en = 1; priv->sh->drop_action_check_flag = 1; } - if (priv->sh->dr_drop_action_en) + if (priv->sh->dr_root_drop_action_en) priv->root_drop_action = priv->sh->dr_drop_action; else priv->root_drop_action = priv->drop_queue.hrxq->action; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 7caf27a7aa..6a3c48eaeb 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1159,7 +1159,7 @@ struct mlx5_dev_ctx_shared { uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */ uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */ uint32_t reclaim_mode:1; /* Reclaim memory. */ - uint32_t dr_drop_action_en:1; /* Use DR drop action. */ + uint32_t dr_root_drop_action_en:1; /* DR drop action is usable on root tables. */ uint32_t drop_action_check_flag:1; /* Check Flag for drop action. */ uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */ uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index c11ccf91f6..42229ede78 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1606,8 +1606,10 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action, /* * Validate the drop action. * - * @param[in] action_flags - * Bit-fields that holds the actions detected until now. + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] is_root + * True if flow is validated for root table. False otherwise. * @param[in] attr * Attributes of flow that includes this action. * @param[out] error @@ -1617,15 +1619,25 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action, * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_flow_validate_action_drop(uint64_t action_flags __rte_unused, +mlx5_flow_validate_action_drop(struct rte_eth_dev *dev, + bool is_root, const struct rte_flow_attr *attr, struct rte_flow_error *error) { - if (attr->egress) + struct mlx5_priv *priv = dev->data->dev_private; + + if (priv->config.dv_flow_en == 0 && attr->egress) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "drop action not supported for " "egress"); + if (priv->config.dv_flow_en == 1 && is_root && (attr->egress || attr->transfer) && + !priv->sh->dr_root_drop_action_en) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR, NULL, + "drop action not supported for " + "egress and transfer on group 0"); + } return 0; } diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 8a571f977e..6482ef708c 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1519,7 +1519,8 @@ int mlx5_validate_action_rss(struct rte_eth_dev *dev, int mlx5_flow_validate_action_count(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, struct rte_flow_error *error); -int mlx5_flow_validate_action_drop(uint64_t action_flags, +int mlx5_flow_validate_action_drop(struct rte_eth_dev *dev, + bool is_root, const struct rte_flow_attr *attr, struct rte_flow_error *error); int mlx5_flow_validate_action_flag(uint64_t action_flags, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 356248d51d..2896bed5dc 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7354,7 +7354,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, rw_act_num += MLX5_ACT_NUM_SET_TAG; break; case RTE_FLOW_ACTION_TYPE_DROP: - ret = mlx5_flow_validate_action_drop(action_flags, + ret = mlx5_flow_validate_action_drop(dev, is_root, attr, error); if (ret < 0) return ret; @@ -17987,7 +17987,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, break; case RTE_FLOW_ACTION_TYPE_DROP: ret = mlx5_flow_validate_action_drop - (action_flags[i], attr, &flow_err); + (dev, false, attr, &flow_err); if (ret < 0) return -rte_mtr_error_set(error, ENOTSUP, diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 1d8f053d83..0fe2c9af5a 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1232,6 +1232,8 @@ flow_verbs_validate(struct rte_eth_dev *dev, uint16_t ether_type = 0; bool is_empty_vlan = false; uint16_t udp_dport = 0; + /* Verbs interface does not support groups higher than 0. */ + bool is_root = true; if (items == NULL) return -1; @@ -1434,7 +1436,8 @@ flow_verbs_validate(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_MARK; break; case RTE_FLOW_ACTION_TYPE_DROP: - ret = mlx5_flow_validate_action_drop(action_flags, + ret = mlx5_flow_validate_action_drop(dev, + is_root, attr, error); if (ret < 0) -- 2.25.1