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 611CEA00C3; Fri, 13 May 2022 09:33:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 651D542853; Fri, 13 May 2022 09:33:41 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) by mails.dpdk.org (Postfix) with ESMTP id 40A854283E for ; Fri, 13 May 2022 09:33:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ENaybmtoCTVNRlQ5exLYeUSgacwIXLlLgrpOWXK1ZfsHdE6eVs1K4C/rHVWaf3gBVmtpSm7121mG2iMrBDFHNn0o9AgQkINsQKmBdKJaxxJheFADX90AQMNRqlAdiwG+6uLhuzwBn8+/5d3BMF/bsF6sKartHEAT6dzWISe2aIZB/NR/wmOkUObgDXE3gL+Er8iOWz/dLWOcTjGED++NHk5RFqdAs1vtP+jcRaA/qsPRN9hi7y+TY6NOYx562AxBY4ZYghGbSlN0E4NaVjUNvNMVWqHFDCbLfM5EUWFttjgeAjw2Eaj16AfBHN6rbVt/j5rA80855p+5uDmOVsj84g== 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=PJbNTT/E8NXmGKE6XLunFZ/lQLb6xowggS0A8wVvR9c=; b=AffVMOZF1QSPFSDqHBFfD3h/GRoQUNeHYBwtjaWpid63EBeJTd1u11/xGf+iXH/t58POXUPa86nsThRU2lJWd9CACnyJ+U+RBstlc39arXd+IKQRkgUppoZWrmIcx8TH+iTYP0vJ5/2IYjhh7W8Ius9005weILBZyDYJtm+TdXgmlx1iWgEV8mmR/9ncRXNntZJCA/na19wO9hFO/mwwBInb8YJEdpRBozr2MZGcUug6Cz29ySNpwKUkgWaQi7tw5vz4qNNsxd95DrzcSEjUnHeIC4m3hHPIva8kA3i7MaQb2iYexm7Ttd/DDtyMoblULMacad+jyBkN9l2VcCdHBw== 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=PJbNTT/E8NXmGKE6XLunFZ/lQLb6xowggS0A8wVvR9c=; b=i3WUWTek41Zeqye9EowX4LJNuT7dNt7AE0B2xVyskw6JcGoQSUeVh/BzPBdjfw5uvYt5dDloK8acgsscGDiTqIUr21xeKb52qp4BSeStF9IUW02lEFA3QDKSnF5QC4s4pz3d35rQXpTZqGMt6/wBkKMtHqnvcKwht/YdgG+NW6WuC0jNnQp7C3dtLAtZgA4Hz8f09BSLSPzH3pPAVBkdCHVPvyfYSbv9YrX+/knFKiEOROao+i/Pp98EDbVdOKnKHkRYW/0abMXocwmtoyri1LgjqFt+uAlMhT9lFA/ECMKUdey2L0U/6QcaSlYqCPaIlfXleO2re1PeCGaSpACQMw== Received: from MWHPR15CA0072.namprd15.prod.outlook.com (2603:10b6:301:4c::34) by BN9PR12MB5148.namprd12.prod.outlook.com (2603:10b6:408:119::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14; Fri, 13 May 2022 07:33:36 +0000 Received: from CO1NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:301:4c:cafe::5e) by MWHPR15CA0072.outlook.office365.com (2603:10b6:301:4c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.15 via Frontend Transport; Fri, 13 May 2022 07:33:35 +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; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT009.mail.protection.outlook.com (10.13.175.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 07:33:36 +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; Fri, 13 May 2022 07:33:34 +0000 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.22; Fri, 13 May 2022 00:33:33 -0700 From: Shun Hao To: , , CC: , Subject: [PATCH v1 4/4] net/mlx5: add validation for yellow meter action Date: Fri, 13 May 2022 10:33:08 +0300 Message-ID: <20220513073308.10762-5-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20220513073308.10762-1-shunh@nvidia.com> References: <20220513073308.10762-1-shunh@nvidia.com> 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-Office365-Filtering-Correlation-Id: 3fe0ecf6-3b15-470b-98db-08da34b2e424 X-MS-TrafficTypeDiagnostic: BN9PR12MB5148: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: v4wJ23T9sS1C9rr/4sVmwQuU7oAlXfU5bDi901LfH7n7zEtkSLvx0tAY07lCc7Jftj94ta5japhDybmLky71z3c96fcrJ3ymoFh607KWT/c7OFqltOtjqqnuBJMwj6ioV06lA0FvjjYRjaXd2El1e6uq4Wj88U1fFyLuqFStq9F+xagebHmmuidl4VcA40U5LGqDFRVPg7BLOX4d7UjzPjhcKCIi9KzJpdVNE+q7flQJ0cB7KMhLlFi1AoLR31rsggou4IkLiTNF7NzTWNzTlBnP95bx0pqluAlo34nJuYoZXxRGJJV2dyltFbBj9g5rELTYITHlOVBEUcU/epHr3aAcLcFlmL3HaYsfZ9O6zmltGX8TW5gmRbR9QHDQA5thDGiiheeNZOvMVYU/biQZy7EyDynS+bwgOp+ejPVp61V1I3ptZ4p9VzxbxgGmV50D1nzTlGmZXbWVJWboVJQwqbXfCip6criLXqnPAqSLRUhpI5Mn6VVSbMKjjMtgrXiWsJYr8y6FAdWLMmTXMWPAWOrJ4hNg5X/pcxoV87a6EBKpdQPlrLT3tIaWKQxjFxBKtZUkr6gseaX+/yvSKquODv8do9v7+eiGqGcnn1mt9+UCftfkpterjh6OjtOPME0UfBCRpAjuYqiSBh/HPn6pwo5TJmB08W5uRBkUjdbrOqrHQdrHUl0UGcW4OqyIzSFeWdlrFRy87e09M2y04+r/Tg== 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:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(8936002)(36860700001)(83380400001)(82310400005)(6636002)(36756003)(8676002)(4326008)(110136005)(54906003)(2906002)(70586007)(70206006)(316002)(5660300002)(508600001)(6286002)(2616005)(107886003)(26005)(1076003)(6666004)(336012)(426003)(16526019)(47076005)(7696005)(186003)(86362001)(40460700003)(55016003)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 07:33:36.1679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fe0ecf6-3b15-470b-98db-08da34b2e424 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: CO1NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5148 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 Yellow meter action support is added in meter hierarchy validation. If one color uses meter action, the other can only use NULL action or the same meter action. And only shared meter is supported. Signed-off-by: Shun Hao Acked-by: Matan Azard --- doc/guides/nics/mlx5.rst | 6 +++-- drivers/net/mlx5/mlx5_flow_dv.c | 40 +++++++++++++++++---------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 4805d08a76..a47a3fc576 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -443,13 +443,15 @@ 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, MARK, METER and SET_TAG. + - yellow: QUEUE, RSS, PORT_ID, REPRESENTED_PORT, JUMP, DROP, 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. + - If green action is METER, yellow action must be the same METER action or NULL. - meter profile packet mode is supported. - meter profiles of RFC2697, RFC2698 and RFC4115 are supported. + - RFC4115 implementation is following MEF, meaning yellow traffic may reclaim unused green bandwidth when green token bucket is full. - Integrity: diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 287095cceb..9354675e97 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -18003,8 +18003,8 @@ flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, NULL, "Multiple fate actions not supported."); *hierarchy_domain = 0; + fm = mlx5_flow_meter_find(priv, meter_id, NULL); while (true) { - fm = mlx5_flow_meter_find(priv, meter_id, NULL); if (!fm) return -rte_mtr_error_set(error, EINVAL, RTE_MTR_ERROR_TYPE_MTR_ID, NULL, @@ -18013,6 +18013,10 @@ flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, return -rte_mtr_error_set(error, EINVAL, RTE_MTR_ERROR_TYPE_MTR_ID, NULL, "Non termination meter not supported in hierarchy."); + if (!fm->shared) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Only shared meter supported in hierarchy."); policy = mlx5_flow_meter_policy_find(dev, fm->policy_id, NULL); MLX5_ASSERT(policy); /** @@ -18034,7 +18038,9 @@ flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, *is_rss = policy->is_rss; break; } - meter_id = policy->act_cnt[RTE_COLOR_GREEN].next_mtr_id; + rte_spinlock_lock(&policy->sl); + fm = mlx5_flow_meter_hierarchy_next_meter(priv, policy, NULL); + rte_spinlock_unlock(&policy->sl); if (++cnt >= MLX5_MTR_CHAIN_MAX_NUM) return -rte_mtr_error_set(error, EINVAL, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, @@ -18080,6 +18086,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, uint8_t def_domain = MLX5_MTR_ALL_DOMAIN_BIT; uint8_t hierarchy_domain = 0; const struct rte_flow_action_meter *mtr; + const struct rte_flow_action_meter *next_mtr = NULL; bool def_green = false; bool def_yellow = false; const struct rte_flow_action_rss *rss_color[RTE_COLORS] = {NULL}; @@ -18263,25 +18270,12 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, ++actions_n; action_flags[i] |= MLX5_FLOW_ACTION_JUMP; break; - /* - * Only the last meter in the hierarchy will support - * the YELLOW color steering. Then in the meter policy - * actions list, there should be no other meter inside. - */ case RTE_FLOW_ACTION_TYPE_METER: - if (i != RTE_COLOR_GREEN) - return -rte_mtr_error_set(error, - ENOTSUP, - RTE_MTR_ERROR_TYPE_METER_POLICY, - NULL, - "Meter hierarchy only supports GREEN color."); - if (*policy_mode != MLX5_MTR_POLICY_MODE_OG) - return -rte_mtr_error_set(error, - ENOTSUP, - RTE_MTR_ERROR_TYPE_METER_POLICY, - NULL, - "No yellow policy should be provided in meter hierarchy."); mtr = act->conf; + if (next_mtr && next_mtr->mtr_id != mtr->mtr_id) + return -rte_mtr_error_set(error, ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, + "Green and Yellow must use the same meter."); ret = flow_dv_validate_policy_mtr_hierarchy(dev, mtr->mtr_id, action_flags[i], @@ -18293,6 +18287,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, ++actions_n; action_flags[i] |= MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY; + next_mtr = mtr; break; default: return -rte_mtr_error_set(error, ENOTSUP, @@ -18378,6 +18373,13 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, } } } + if (next_mtr && *policy_mode == MLX5_MTR_POLICY_MODE_ALL) { + if (!(action_flags[RTE_COLOR_GREEN] & action_flags[RTE_COLOR_YELLOW] & + MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)) + return -rte_mtr_error_set(error, EINVAL, RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, + "Meter hierarchy supports meter action only."); + } /* If both colors have RSS, the attributes should be the same. */ if (flow_dv_mtr_policy_rss_compare(rss_color[RTE_COLOR_GREEN], rss_color[RTE_COLOR_YELLOW])) -- 2.20.0