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 5CDD342B2F; Wed, 17 May 2023 22:36:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DFFA640EE1; Wed, 17 May 2023 22:36:53 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2059.outbound.protection.outlook.com [40.107.102.59]) by mails.dpdk.org (Postfix) with ESMTP id 08E56406B7; Wed, 17 May 2023 22:36:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l5O6Ke7F9ILhESRfUbbh0bwy1epI9j3qDXvvoB1v7z9ZFxoZP5bh5RTKjLydfsZc1zDSYoxVxy/0zrON1vJ5iS5G0i0E81Gz+SeJgdvplQ/IXUEtudkFR++A8bicuUqrPWn1kGkCzkldRMmA0s/W791yz9M3Wb44c95q9iQXBfkrlV2oIedEQEFhoMBHzvocUTsWNSZPCVwO8ZZ3Of4EGJlxz83OYuuruhq18vhPz/mmMReFOj0Ci99sqTdtajzE1DJOO/NnPQEKm6HmKsA6jRyjnCyvIqRa2kd4wocf2TAesXLwaNXoh79wY2D6zomh1XEVc/JwosaQ9F0fA6XfDw== 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=rO9C+0jE2nTnj+iiVLaEEkgwsmWIDkuqkQ1T1ZLAWC8=; b=ln51jb4eKdttPDg88mrdKbJLO1bBMn9M7IurSKy9Toz5Opp6X7FLNUqISUjMLLnu0ydH1rC87WM0S8gQehas57yPMqPlhPm3ePaymmkCq0iJTDX/llhIoRSNlQiRKbkhgFE8SwcF+a9/WUbM6cm7iylieDpFhh5h0kE5c5bDvmWjWd00+sVekjZNch4tad9wx1G++QbEWxxEKkV1uLcAVE/31qIyyUASu3TNO1+kYfmQiljwAbYys3Z6wd5byA+VEfjHz3kWlYD/f5/jhFlyJTaHeTgmpvAbt47i9QBQCbxgLELV//KjaCAzIRmMGVjCZZk8I5D0NoUhdKxglpvhSw== 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=rO9C+0jE2nTnj+iiVLaEEkgwsmWIDkuqkQ1T1ZLAWC8=; b=lsYtLfHMUjimpjZr5XYfTjlsuW2OL7dzR4AQ8Tj2fHTv3820UyfYYK1zOX3wV6ssj/D5itaiTtuCFMP2iXBs/+ko9l9PRoDZEwv1ZR1KFl6UqWFfMdZDc+BHuaiIEizmgJ0w6vVuzi9D5ptgcf94dcSjo2VH/FeodXA0gvDAE+uvHw0klQrw8FAMoYkgDrGnPhwKvtknVlLPAxaZEpRSFSX7qqxblrv6ylZ1kSVD/ikwdywxyx+q2Vo+2O5nTWV7mNpgNNEoVGw7pLfCXQMpLBYTQOpN6Wk4+YxA2G13DS+4cx10blCXMlw7oUpVccSQpjUOywvPpc4IGAr69t7b7A== Received: from BN9PR03CA0152.namprd03.prod.outlook.com (2603:10b6:408:f4::7) by SJ2PR12MB8009.namprd12.prod.outlook.com (2603:10b6:a03:4c7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 20:36:49 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::2) by BN9PR03CA0152.outlook.office365.com (2603:10b6:408:f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 20:36:49 +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 BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 20:36:49 +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; Wed, 17 May 2023 13:36:33 -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; Wed, 17 May 2023 13:36:30 -0700 From: Dariusz Sosnowski To: Ori Kam , Suanming Mou , "Matan Azrad" , Viacheslav Ovsiienko , Jiawei Wang CC: , Subject: [PATCH] net/mlx5: fix drop action attribute validation Date: Wed, 17 May 2023 20:36:14 +0000 Message-ID: <20230517203614.538262-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT052:EE_|SJ2PR12MB8009:EE_ X-MS-Office365-Filtering-Correlation-Id: 67647bb0-80e1-4223-2a3d-08db57167088 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pu7usFWxhdBy4saXPnGBDl9V3GJAekBIF5BAeC+w5M4qhyKWjPEUPWZRKq8Lm+JQA+tSkKuizP6mvHb5mPJNnNx+sPjL5hy7i+/VLSeMO78fgytpZrZ6rhIEiQLDpIBG0sX5NBkovY2HCNzBcbnc6kHYGyXMOU1nqrFzWy9ta4WPVGcUqlwnrAOU1KqaWEXUbc9Ccq0ZaHLizAAteHdzOxPcRdTfYQYRpC/ojtSonzJyGu4Upp3lavwMgNfZMK7f4xM24OOsyC2b2hzEF1Yk6r8lQf9mhpTptzrVCN+yEBIl8S3zlW/gfUXdcD9KnSI4TlUAQoy8KRlsWZzRilgLdWNvqwBPRW28QGZAzyauRET88T/TDQmWC7j0Fy5JYKpcdp+t5KqQCJJoa2R0Vs+Z2nwyTzc6RF3ENhfPY4OP+wWYYHOJ7eLFbnkSso1lQSmH3kvJAF1JTe7bcEWRb9YVdkhD8c+TyIMXIaDvoTPKZbm9N0IdBaDk1O4pVwfpqNHBIdD/kpFNupSODrPxe8Hpran68Hf2LX5UNfUtU9LFDHB/O5E7CgSsKEdojHPUra1wNw54NaXE3nlMxwbqvXuhQRUZeP4XADeLTs/S7r3nZVS414pPLwOVSsgqM+bknttRsiG9RgArECXYIBjJoiK8e/pfXmbZV6vex9gCgoBYOLLOcsdMC/DIL5PCaM+3zHr0KTrVEzaMypm2lFPA4U/LXpYN7+ohTWUNkof8qGtRbvsf3ae3SINT+giay1mQanGM 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)(39860400002)(376002)(396003)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(2906002)(8936002)(5660300002)(41300700001)(8676002)(82310400005)(70206006)(70586007)(6636002)(4326008)(450100002)(54906003)(110136005)(478600001)(6666004)(7696005)(83380400001)(336012)(36756003)(47076005)(426003)(316002)(2616005)(186003)(40460700003)(26005)(16526019)(36860700001)(6286002)(1076003)(7636003)(356005)(82740400003)(55016003)(86362001)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 20:36:49.0051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67647bb0-80e1-4223-2a3d-08db57167088 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: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8009 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 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: suanmingm@nvidia.com Cc: viacheslavo@nvidia.com Cc: jiaweiw@nvidia.com 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 | 7 ++++--- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 980234e2ac..d8f1adfe3d 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -876,10 +876,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 9eae692037..785ca96a8a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1377,7 +1377,7 @@ struct mlx5_dev_ctx_shared { uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */ uint32_t tunnel_header_2_3:1; /* tunnel_header_2_3 is supported. */ uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */ - 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 19f7f92717..5f88eb5c06 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1924,8 +1924,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 @@ -1935,15 +1937,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->sh->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->sh->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 1d116ea0f6..65bfc2f2d0 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2252,7 +2252,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 f136f43b0a..679bd3b405 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7819,7 +7819,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; @@ -19256,7 +19256,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 b363fb4ad3..fe9c818abc 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1317,14 +1317,14 @@ flow_verbs_validate(struct rte_eth_dev *dev, uint16_t ether_type = 0; bool is_empty_vlan = false; uint16_t udp_dport = 0; - bool is_root; + /* Verbs interface does not support groups higher than 0. */ + bool is_root = true; if (items == NULL) return -1; ret = flow_verbs_validate_attributes(dev, attr, error); if (ret < 0) return ret; - is_root = ret; for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) { int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); int ret = 0; @@ -1531,7 +1531,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