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 67120A0501; Sat, 2 Apr 2022 09:12:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59CDD42868; Sat, 2 Apr 2022 09:12:36 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2050.outbound.protection.outlook.com [40.107.96.50]) by mails.dpdk.org (Postfix) with ESMTP id F227E41145 for ; Sat, 2 Apr 2022 09:12:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cxI9B/nWRXI3WGEFXlz3cptuMxYExNG2RI5j3x/JaP7XmwYIQ1zFc+yd16WpTig6bWyTx7RnMyRaxsyvSgk+sT2QC3ZV2Y/QIRZRAzm4aCp9cAMlTFqPj/1T5aleUUDICOQbzCTpB0kmVbOpzxscPCkvQtDL9f3pM5A618569lpqP+zz2vpJPFCECtMknGp11QBug7vzuhCdZE4AAL8p5/DxBcFpnn1DvGkB2s4cS7mCYoTUzWn4sy4oYK6X6HodqRr6pcRiiVoQ1U8CKaYW8WwLW2NtassuHsERdbKGYPjJVr58J2CmS9/covz97PITbx4YL1A5wxYsIVbNDk2ehg== 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=CnyG0tD61IGhX7B0+dryg/mzfirgZIQYPmebvADQiHE=; b=ebeB6jXWHvxA4j/EwbDPFPEIwAGwjI5TrzwV37Pb5Ecc9DaNaPT+MkgzQ3fPTMrSLqR62q/0Q/s6kiFVQFNp7OxtAEzMmZythtq3QWldKN7uC0XWz1p48OmUSBqt/GoaiYuTicru0SXKNqQCfVdMcS4dfAvSoeLqQbqjEALk3TRuYPrjhvtK8BcuGrcsjXBH5iT8DBQIEAYBXYW00zCAV0E7cN59Sqq7wNi5xSFbIU4ENLekPeMFHEhmXtM0Z5Eim7P8TK2ytwnQBmfYVayYlLl+HsaDN5YsHXN5sU7EuJ6315zVVjFTCa9rKXtgMZqopK7/yd+EtgcmNJbNwgMdEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=CnyG0tD61IGhX7B0+dryg/mzfirgZIQYPmebvADQiHE=; b=ZitUsAO7+1JTvfU9p4757yFJuFOZbgeTkyDkgic/c+9sEXYc1GE4zlD6rvHs5MqSVavtwxdpvXFjoLDm2O2469yAYoCI3ZKUUodrqW1oyjU/wQ4/y0Fm+4v5Dc3D0UbpqGVGa2jc4k56bIU3XSenv7qMC+/nCmcAJuG+4dWW+zFPh9st34B4oNsScOw/0ToVc/311tltJ1A+BhwfCYZyavWMdKg/RYHhMlQR8XtRMipe+5lzrjrNsfSu72Q0giV+u1BnXOZlo8KBM58zpkcMr+VAtEaqrHKBdSyTl1xV0I3krR4DrflhgKp+r6u3/4C5VOL8Y3QF7J0qKMvJ95S4Cg== Received: from BN6PR19CA0056.namprd19.prod.outlook.com (2603:10b6:404:e3::18) by CH2PR12MB4166.namprd12.prod.outlook.com (2603:10b6:610:78::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.25; Sat, 2 Apr 2022 07:12:32 +0000 Received: from BN8NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:404:e3:cafe::ab) by BN6PR19CA0056.outlook.office365.com (2603:10b6:404:e3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.28 via Frontend Transport; Sat, 2 Apr 2022 07:12:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT055.mail.protection.outlook.com (10.13.177.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5123.19 via Frontend Transport; Sat, 2 Apr 2022 07:12:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Sat, 2 Apr 2022 07:12:15 +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; Sat, 2 Apr 2022 00:12:14 -0700 From: Sean Zhang To: Matan Azrad , Viacheslav Ovsiienko CC: Subject: [v1 4/4] net/mlx5: add modify field support in meter Date: Sat, 2 Apr 2022 10:11:50 +0300 Message-ID: <20220402071150.9392-5-xiazhang@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220402071150.9392-1-xiazhang@nvidia.com> References: <20220402071150.9392-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4a0ee0c1-1e44-422b-1e4a-08da147827a8 X-MS-TrafficTypeDiagnostic: CH2PR12MB4166: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: scCr0hiVVR9gSyj6i5v23tWEKWImDKOYe+ntukth5gUxhy7MhFfR0NDy9W4XAA062qPu8wfmS7Z4GGUyoakWq+N799TXPhewSxT+rSnhq7W6UoLJXLgIaOOyoHced9CaoNILi9uTozPxzzw+EPbNZnzU1zOgTvAs9d301O89Fjvf6C6TCYBaj38nEu/bEL2mX0JTKXCZm6q2u/K6/nfFw/ordn9pM/Vpbn2Vx65PWVPZhSi6i4lRvGGrfudBtsjhdqEyTKN370u3+8DYLugJ49uVJ2M7sDb4SIRpUUtX106IIOScY2E3H1cGT7j+qcnhDl/ci5Y1cCeYxgiQLVWuEBcLjSg+AuIsHiO3IQH3cnU7xsHKOJWWyFrBRaLc8cNZtwX/uXPSMro7A8UykpSdK7lm0w43XBeTnKpeNEzq+oj0cBd6QahvRw7Gcr42zYG+l1mblePzQLb6QK9mxKd44PwfNVhvmgUQk9t083rcqOGu6uDM1Avia3soUAtWRUM1+2TJnkBl6++n/+ROsH2pbtzp+HpzsxOE++PHQiV/s+wkPzJm/0pSuryblJX2UornCw7guydXzeyiqwstcvwG1R72GghgabVuezuIaY98dvDs0sTCWfTGyAtQMO7RymGqnE/lzzkrplGxGjO7evLSKxHRO4+n2kC1MNr9XSydP4Sna6JeC86lXpzuULqLV5AenLtvSG15UWIT0z4hdHpHNA== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(83380400001)(5660300002)(70206006)(8676002)(47076005)(508600001)(4326008)(8936002)(40460700003)(82310400004)(26005)(16526019)(186003)(2616005)(86362001)(6286002)(70586007)(1076003)(6666004)(2906002)(336012)(36860700001)(316002)(36756003)(6636002)(7696005)(81166007)(426003)(356005)(110136005)(55016003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2022 07:12:31.7806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a0ee0c1-1e44-422b-1e4a-08da147827a8 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4166 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 --- 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 4805d08a76..b6d51dc7c9 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -443,8 +443,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 and SET_TAG. - - yellow: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MARK and SET_TAG. + - green: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MODIFY_FIELD, MARK and SET_TAG. + - yellow: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, MODIFY_FIELD, MARK 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 78cb38d42b..52b5463648 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7867,6 +7867,8 @@ mlx5_flow_destroy_mtr_acts(struct rte_eth_dev *dev, * 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. @@ -7878,12 +7880,13 @@ 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) { 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 f56115dd11..ed9b9e4876 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1359,6 +1359,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, @@ -2017,6 +2018,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 e416eb5701..a01ba04c3b 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15579,6 +15579,8 @@ flow_dv_destroy_mtr_policy_acts(struct rte_eth_dev *dev, * 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. @@ -15590,6 +15592,7 @@ static int __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) { @@ -15886,6 +15889,28 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, 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 Y or R colors * here since it is done in the validation stage. @@ -15954,7 +15979,8 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, 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 @@ -15962,8 +15988,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, 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; } @@ -15983,6 +16008,8 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, * 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. @@ -15994,6 +16021,7 @@ static int 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; @@ -16005,7 +16033,7 @@ flow_dv_create_mtr_policy_acts(struct rte_eth_dev *dev, 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) @@ -18176,6 +18204,19 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, action_flags[i] |= MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY; 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 a3d1f2c08d..75672a4cd2 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -885,7 +885,7 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, } 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) { -- 2.31.1