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 87494A0544; Tue, 7 Jun 2022 13:19:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8AB96406B4; Tue, 7 Jun 2022 13:19:29 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by mails.dpdk.org (Postfix) with ESMTP id 4CFC6427F9 for ; Tue, 7 Jun 2022 13:19:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WfiWTdPKI76PzrlYgvNiemz1jPu9A+JoXwp7N1yJvZ1K1qAmgPtp5XH5UmT1+HN1Jj1FcFNvNDhBGbYCUXvNljGUUMfcDErlFHfEQ3pU2Z+1P4XT1pRHisG4Gc6jSMOyZWHKRk5yGW5ij0kLnIIVxtNc5zoL2a18Bsr7/UCrlSG/LjowLHp/hBlzGcUDBpYxI3/jcYUkpOgVAN5J3MZtq1cXLwj4/K+BescAy1rtj+pC7M52TEGqz/HmR8MXdaCPEs5dxeaj2lMq5paXCHapluN3JY3o5o+OBULPBm+OsyQn1H/oRp9ULEoUyfIWTsV2VimRWRMHIRJWrJDAtG/q9A== 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=EvH+nvoxKj6lTC9SYX0OYJGdqBgyS2e+kuE0Ay97RYw=; b=AIYzn+pwKc4x0Dz7r9xVcREZKZr5xNK+awxounFUxtrfQZBJ4IIbxDZnbknyu0Vt726oxe2d/k1Z9WdZTmajNKBcP3zFeI6KMW0G75Fr41vZMISWaGbdxGVUCA3xGfQ/y1S0cTqzGhR/xA4DbxX2IMnl0ZWrH2nCErZ5t8hG5WNxowq56FqghjD5uP5WdLSHDeowGNsKeYy+EHR2vkoSlNeFoOwg4NBdtc05q19ggh2Y2B3hLQowKuMGYxFMFIPl2TrGh+gSdpF0x1sTGcgftQ0yffOpym8+7JZdr0jIjKBnG7G3XuareseEIM0ekyeVcwJnhbxOagWWksq3QSFVSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) 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=EvH+nvoxKj6lTC9SYX0OYJGdqBgyS2e+kuE0Ay97RYw=; b=LGXeXGN7lLZSZIvnh6gOfB7WMLhidzZ7wqBx9DJJVDmCzSqcf/KlJOBRDNBiz/Tc6UD1+Tg0F3AgZD8Ud4KBpFffg4rC1WyLnW1t2rqPEic+KpDcWNNBl+x5Xa2/XOlJ4tG7C0JcebCMLZQqHqoeNyLvMrzMlBhNhTouc11S3wuzP0AXqMyM9w/Wwcrnrh2mnBkn5P9XxWNxNaKJ6qu1QOtYzHsJ8yzyU62ojvVBnf8NeM27SswLoSruOivLIsofcn2Nc4s0uyArfnOJ1F+0Rw02XSYMCpF0e4pO/3xZLtoQ4/3xl5CwaWqcSz77AO6dN7twY5nYTE9lwBzrSLv7bQ== Received: from DS7PR07CA0012.namprd07.prod.outlook.com (2603:10b6:5:3af::20) by CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.16; Tue, 7 Jun 2022 11:19:26 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::8f) by DS7PR07CA0012.outlook.office365.com (2603:10b6:5:3af::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 11:19:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 11:19:25 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 7 Jun 2022 11:19:24 +0000 Received: from nvidia.com (10.126.230.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.22; Tue, 7 Jun 2022 04:19:22 -0700 From: Sean Zhang To: , Matan Azrad , "Viacheslav Ovsiienko" CC: Subject: [v2 3/3] net/mlx5: add modify field support in meter Date: Tue, 7 Jun 2022 14:19:00 +0300 Message-ID: <20220607111900.23432-4-xiazhang@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220607111900.23432-1-xiazhang@nvidia.com> References: <20220402064000.8772-1-xiazhang@nvidia.com> <20220607111900.23432-1-xiazhang@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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-Office365-Filtering-Correlation-Id: f2e3139e-e4a3-422d-d70b-08da48779467 X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr 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: d2HtLgtmck0UuOhhcyGHf/Dcgwe8l6Il4BIKqwTmAQxn6ZSVWZ+VHMqURnauM5ThWhDtvCL5ZFieJ2NeMKRzLMuUyBrAsOYgJo+em3OKo06o1GbjxsA0qRXnoAKr4Epl/O3al/HJUbUGmC/XYUaXhPk6pO5Z8BrKRX+hDiIj10j4SiPInfKVUso0D5KGMUUyK51bNzEoHEPkovMq//Tsd1hOGWHkGl/DNUR2mAf0tRO12KnMRj58MoEinBpP5LEIQnFeMx4iuEEJipbVtqo7ajZ1MEPaMmsZV2KuJ3gjOqqObkoNCRljF6Jdk1epA2CPHWWIASktRUuERRzkhI8DdiDLsz23Pf7Y/QjasrqO11ZQcath3UFg/7t5hc5648y/vXyz1e7l40DEewPlzWQlqNzmhvn1OI02UAww/RdAULcsP1uP8x7SK3xFPcCDd+RuX7MxU3CRETJ9jnB15x4y2Jn5TUmTJKUmtTkpXizOb+H9lujGUCaSoGZQcoi/MZTzdgitGXSWyi566EMBcTfShX/GdGiEJ4PXd6LR6z/4nkz7n3TuPJmpYpy4ax8x4FoCSh3wDpJMuCmgVEBBzYeLL7sI0vmKjsEKP91cKx33cYii3DYiIsEIVwiyR+IDih1aGUzfXmWSOh1sS336jF9Oh3M8H8JL4GYeTBSPAmhvlbpodppTvnRIcqR8ZcxvaKAFjeWgrbAzICyzAVcuMLP//g== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:ErrorRetry; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(6666004)(70206006)(426003)(4326008)(47076005)(5660300002)(70586007)(36756003)(8676002)(7696005)(81166007)(26005)(36860700001)(110136005)(508600001)(40460700003)(6636002)(336012)(55016003)(82310400005)(316002)(83380400001)(6286002)(8936002)(16526019)(2906002)(1076003)(186003)(356005)(2616005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 11:19:25.3394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2e3139e-e4a3-422d-d70b-08da48779467 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.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4294 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 This patch introduces MODIFY_FIELD action support in meter. User can create meter policy with MODIFY_FIELD action in green/yellow action. For example: testpmd> add port meter policy 0 21 g_actions modify_field op set dst_type ipv4_ecn src_type value src_value 3 width 2 / ... Signed-off-by: Sean Zhang Acked-by: Viacheslav Ovsiienko --- doc/guides/nics/mlx5.rst | 4 ++-- drivers/net/mlx5/mlx5_flow.c | 5 +++- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 49 ++++++++++++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 2 +- 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 7ecf11e..3c9015f 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -445,8 +445,8 @@ Limitations - yellow: NULL or END. - RED: DROP / END. - The only supported meter policy actions: - - green: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MARK, METER and SET_TAG. - - yellow: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MARK, METER and SET_TAG. + - green: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MODIFY_FIELD, MARK, METER and SET_TAG. + - yellow: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MODIFY_FIELD, MARK, METER and SET_TAG. - RED: must be DROP. - Policy actions of RSS for green and yellow should have the same configuration except queues. - Policy with RSS/queue action is not supported when ``dv_xmeta_en`` enabled. diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 5d6c321..090de03 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7910,6 +7910,8 @@ struct mlx5_flow_workspace* * Meter policy struct. * @param[in] action * Action specification used to create meter actions. + * @param[in] attr + * Flow rule attributes. * @param[out] error * Perform verbose error reporting if not NULL. Initialized in case of * error only. @@ -7921,12 +7923,13 @@ struct mlx5_flow_workspace* mlx5_flow_create_mtr_acts(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, const struct rte_flow_action *actions[RTE_COLORS], + struct rte_flow_attr *attr, struct rte_mtr_error *error) { const struct mlx5_flow_driver_ops *fops; fops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV); - return fops->create_mtr_acts(dev, mtr_policy, actions, error); + return fops->create_mtr_acts(dev, mtr_policy, actions, attr, error); } /** diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index eb13365..c3a554c 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1375,6 +1375,7 @@ typedef int (*mlx5_flow_create_mtr_acts_t) (struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, const struct rte_flow_action *actions[RTE_COLORS], + struct rte_flow_attr *attr, struct rte_mtr_error *error); typedef void (*mlx5_flow_destroy_mtr_acts_t) (struct rte_eth_dev *dev, @@ -2033,6 +2034,7 @@ void mlx5_flow_destroy_mtr_acts(struct rte_eth_dev *dev, int mlx5_flow_create_mtr_acts(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, const struct rte_flow_action *actions[RTE_COLORS], + struct rte_flow_attr *attr, struct rte_mtr_error *error); int mlx5_flow_create_policy_rules(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 0f028de..db9c831 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15713,6 +15713,8 @@ struct rte_flow_action_handle * * Meter policy struct. * @param[in] action * Action specification used to create meter actions. + * @param[in] attr + * Pointer to the flow attributes. * @param[out] error * Perform verbose error reporting if not NULL. Initialized in case of * error only. @@ -15724,6 +15726,7 @@ struct rte_flow_action_handle * __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, const struct rte_flow_action *actions[RTE_COLORS], + struct rte_flow_attr *attr, enum mlx5_meter_domain domain, struct rte_mtr_error *error) { @@ -16020,6 +16023,28 @@ struct rte_flow_action_handle * action_flags |= MLX5_FLOW_ACTION_JUMP; break; } + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: + { + if (i >= MLX5_MTR_RTE_COLORS) + return -rte_mtr_error_set(error, + ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, + "cannot create policy modify field for this color"); + if (flow_dv_convert_action_modify_field + (dev, mhdr_res, act, attr, &flow_err)) + return -rte_mtr_error_set(error, + ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, "cannot setup policy modify field action"); + if (!mhdr_res->actions_num) + return -rte_mtr_error_set(error, + ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, "cannot find policy modify field action"); + action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD; + break; + } /* * No need to check meter hierarchy for R colors * here since it is done in the validation stage. @@ -16092,7 +16117,8 @@ struct rte_flow_action_handle * RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "action type not supported"); } - if (action_flags & MLX5_FLOW_ACTION_SET_TAG) { + if ((action_flags & MLX5_FLOW_ACTION_SET_TAG) || + (action_flags & MLX5_FLOW_ACTION_MODIFY_FIELD)) { /* create modify action if needed. */ dev_flow.dv.group = 1; if (flow_dv_modify_hdr_resource_register @@ -16100,8 +16126,7 @@ struct rte_flow_action_handle * return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, - NULL, "cannot register policy " - "set tag action"); + NULL, "cannot register policy set tag/modify field action"); act_cnt->modify_hdr = dev_flow.handle->dvh.modify_hdr; } @@ -16121,6 +16146,8 @@ struct rte_flow_action_handle * * Meter policy struct. * @param[in] action * Action specification used to create meter actions. + * @param[in] attr + * Pointer to the flow attributes. * @param[out] error * Perform verbose error reporting if not NULL. Initialized in case of * error only. @@ -16132,6 +16159,7 @@ struct rte_flow_action_handle * flow_dv_create_mtr_policy_acts(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, const struct rte_flow_action *actions[RTE_COLORS], + struct rte_flow_attr *attr, struct rte_mtr_error *error) { int ret, i; @@ -16143,7 +16171,7 @@ struct rte_flow_action_handle * MLX5_MTR_SUB_POLICY_NUM_MASK; if (sub_policy_num) { ret = __flow_dv_create_domain_policy_acts(dev, - mtr_policy, actions, + mtr_policy, actions, attr, (enum mlx5_meter_domain)i, error); /* Cleaning resource is done in the caller level. */ if (ret) @@ -18395,6 +18423,19 @@ struct rte_flow_action_handle * MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY; next_mtr = mtr; break; + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: + ret = flow_dv_validate_action_modify_field(dev, + action_flags[i], act, attr, &flow_err); + if (ret < 0) + return -rte_mtr_error_set(error, + ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, flow_err.message ? + flow_err.message : + "Modify field action validate check fail"); + ++actions_n; + action_flags[i] |= MLX5_FLOW_ACTION_MODIFY_FIELD; + break; default: return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 22f6ca7..7c0d849 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -916,7 +916,7 @@ struct mlx5_flow_meter_policy * } rte_spinlock_init(&mtr_policy->sl); ret = mlx5_flow_create_mtr_acts(dev, mtr_policy, - policy->actions, error); + policy->actions, &attr, error); if (ret) goto policy_add_err; if (mtr_policy->is_hierarchy) { -- 1.8.3.1