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 BB708A0032 for ; Sat, 17 Sep 2022 08:02:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE0014280D; Sat, 17 Sep 2022 08:02:45 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2041.outbound.protection.outlook.com [40.107.93.41]) by mails.dpdk.org (Postfix) with ESMTP id A9E2E4114B; Sat, 17 Sep 2022 08:02:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaXoQrfexzLE57fjJzKEYnLDZWEKvnjNAjhinP+0cFgofzIvPDpCqLgR5m65AXFT8/4ESO9z5tb0amPP8rCf8uEMVkOePlVWATgn2SplvCHpZpeiYsaUIZohuZt95VDoTPA4CSzl5uKUuop3UJScUbb1eRsClpOraB6d7gVPJDVNjIQOfNd2PS0lKYdeoQqTMmm/quyI36DOpILKeu5luTAHKW08NCZCyKTWw/D2xZCkAS+nv3GpeVkHukTbsPOsL5XYmC0CuiobhzxoGWNf6K7TPlCRcXiDz0PuAewZ4aKMaxW5RAZ7TUOVpjMLhuDnDvws4cKjZXfgh30t4q6+mQ== 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=uML6phj2rm9TRJ+lLt8IbaprhhW1fGxQ0ebj3+ex0ro=; b=kVvYzcredlUr933drTNRT1fa5W4mXAq7O2p8STTFBh+95p0sghOwiJHqIs902J9gCzVmbKw4Xepn2YiT2KBrxwDwCuid2bmXw4Lix8VX1iLQf/FP4zR/1PYQrMcnyvNdG0ye2FRWm1za7U7x6GDIG7JMUZmw4Y2/u7SGvyJoqBOV/KvB2kxm5d7XbYuRDHWQEo9dqKXxhY8iYwsmtg1bibioHZQOVV+LASPEZf6M9KP4Ie9zvJhePEbNYsHJaFzSbruiEkFSh9c6V0b7Y+805y57jjIiUlotwqVWbRS8yS6Nms0oqrUlaNJc3MQLMBYGSfc4Dd9EDC4D6fPTfBEC7A== 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=uML6phj2rm9TRJ+lLt8IbaprhhW1fGxQ0ebj3+ex0ro=; b=ilQTI8+RAAkNuafquEH/XnzhE60hRFCCKlq3wqjqhqDyGd3i4thCWUFUNVEHGpxaXp0EQZBHjx7Dx5/rQv0/cKwy9RvkTu+eQAsXGYUhq1fMwV1fj96ZyYXKEfU+1P5ramutmzdUBHS90xrQXVG6lnrBH067i21rDA6BjkWmpYRd7qP2yeyf9miGI+Lu6warBZJ4HkNCowwQrHsI2cJ26fFvR9pD7AprWYPS8PrDKdzSIy5k1MH5hvz8uHTZ+SWoJYd9Oc7GDxB6sid/NkAo59pF0Ycltd49RDOtEEMPJ9kLUL/WBRM/U05zdPIH7HUSExywaVxtchT+0tZn1GcuUw== Received: from DS7PR03CA0118.namprd03.prod.outlook.com (2603:10b6:5:3b7::33) by DS0PR12MB6462.namprd12.prod.outlook.com (2603:10b6:8:c6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Sat, 17 Sep 2022 06:02:42 +0000 Received: from DM6NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::3d) by DS7PR03CA0118.outlook.office365.com (2603:10b6:5:3b7::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.16 via Frontend Transport; Sat, 17 Sep 2022 06:02:42 +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 DM6NAM11FT085.mail.protection.outlook.com (10.13.172.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Sat, 17 Sep 2022 06:02:41 +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.26; Fri, 16 Sep 2022 23:02:32 -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.29; Fri, 16 Sep 2022 23:02:30 -0700 From: Shun Hao To: , , , "Sean Zhang" CC: , , Subject: [PATCH v1 2/3] net/mlx5: add meter flow limitation when matching all ports Date: Sat, 17 Sep 2022 09:02:09 +0300 Message-ID: <20220917060210.3332529-3-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20220917060210.3332529-1-shunh@nvidia.com> References: <20220917060210.3332529-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-TrafficTypeDiagnostic: DM6NAM11FT085:EE_|DS0PR12MB6462:EE_ X-MS-Office365-Filtering-Correlation-Id: c8b75e6c-e566-4110-a81e-08da98723ba2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WZEt+CftJcnWDInJwha4IfF0Rdwhjm/PjibpeD1vrVpCFlpd0SlRZTIS2D3T/scaXbbmLUObpRtnxwCVNC0iVUkh7w09n+hdB5yep/kv0hhMsxF4xXg8Ss5BWYQg/3Mpaj5IgFqfqfEoV4uZqVypATHzIi/QzvFzR2EXJOFBIctmn7Htv2HcdjaedVZqdCFBdU6tPldVwBMBTvqBAr2y2WG9gj9AhhB3RwOmCkoCZhgTWBKt6chMTsLV4CwKkPWGL7mKWEaVDtND1aqiXQKrzPGOfY6E9WYSdJG23d2BIRfM+rONDBfhxmPhPDp/cPsdgOBC3Rftb1Zebbn2ISPPv1juZSGKCiBq4hTJvoO5jWv+C2RtcnY/ZpOqvFjNRZnevJXfP53Odtv1fH/3FZI87CYE2enxZ+jUX6IJ/wGU/VWn2yqERyWQbXO7X0b8ZB69Ksl03ZFA1anltI9e338UoZmb5lZBxrE0X801/iEy588pPyqIXRGpOWShVwPPRwe7HOBc/ZMCoChQEH6MaX8lPApZG0hk3MvZb+rFcsA3//EvS5rSh4Fzn3oLpY2MtcsjEu3pZ2+mrAKuE2cm+AiZ1CULzRx+fuSqsb0O8kFZrbEb8gg2+yU5yk1daO1Vjlxgu8YpBsDkkwd5HY3KuLEtH9+rI0Ly0Hbke0wJApu8usIRJK/a1eZbkCaYWpNW1kh0e/oROqaWs2auduG9IWJ0uaRP3nTO64uhRqrirPL7MUPM2GWfeyXA+ZqsGjBIL51Uj6MS9+CHlJ6B7PIBapewyw== 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:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199015)(40470700004)(36840700001)(46966006)(2906002)(83380400001)(5660300002)(36860700001)(40460700003)(7636003)(450100002)(478600001)(86362001)(82740400003)(26005)(70206006)(70586007)(6636002)(6666004)(8676002)(336012)(110136005)(6286002)(47076005)(426003)(16526019)(36756003)(8936002)(40480700001)(4326008)(186003)(316002)(7696005)(55016003)(41300700001)(54906003)(356005)(2616005)(82310400005)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2022 06:02:41.8993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8b75e6c-e566-4110-a81e-08da98723ba2 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: DM6NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6462 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 If there's no param in represented_port item, it will be treated as matching all ports by default. But there's some limitation when using it with meter hierarchy. This patch adds the limitation that when matching all ports, the meter hierarchy should not contain any meter having drop count. Fixes: e8146c63 ("net/mlx5: support represented port item in flow rules") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- doc/guides/nics/mlx5.rst | 1 + drivers/net/mlx5/mlx5.h | 2 ++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 51 ++++++++++++++++++++------------- 5 files changed, 45 insertions(+), 21 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index d331e48ce7..631f0840eb 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -473,6 +473,7 @@ Limitations - 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. + - When using DV flow engine (``dv_flow_en`` = 1), if meter has drop count or meter hierarchy contains any meter that uses drop count, it cannot be used by flow matching all ports. - Integrity: diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index a56ee83d99..9300dc02ff 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -775,6 +775,8 @@ struct mlx5_flow_meter_policy { /* Is queue action in policy table. */ uint32_t is_hierarchy:1; /* Is meter action in policy table. */ + uint32_t hierarchy_drop_cnt:1; + /* Is any meter in hierarchy contains drop_cnt. */ uint32_t skip_y:1; /* If yellow color policy is skipped. */ uint32_t skip_g:1; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index e93b6e144c..2038c4a6c0 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -5338,6 +5338,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev, switch (item_type) { case RTE_FLOW_ITEM_TYPE_PORT_ID: case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: + if (mlx5_flow_get_item_vport_id(dev, items, &flow_src_port, NULL, error)) return -rte_errno; if (!fm->def_policy && wks->policy->is_hierarchy && flow_src_port != priv->representor_id) { @@ -11012,6 +11013,8 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev) * The src port id match item. * @param[out] vport_id * Pointer to put the vport id. + * @param[out] all_ports + * Indicate if the item matches all ports. * @param[out] error * Pointer to error structure. * @@ -11021,6 +11024,7 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev) int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, const struct rte_flow_item *item, uint16_t *vport_id, + bool *all_ports, struct rte_flow_error *error) { struct mlx5_priv *port_priv; @@ -11032,8 +11036,13 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL, "Incorrect item type."); pid_v = item->spec; - if (!pid_v) + if (!pid_v) { + if (all_ports) + *all_ports = (item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT); return 0; + } + if (all_ports) + *all_ports = false; esw_mgr_port = (item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) ? MLX5_REPRESENTED_PORT_ESW_MGR : MLX5_PORT_ESW_MGR; if (pid_v->id == esw_mgr_port) { diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 2f265763a9..0fa1735b1a 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2087,6 +2087,7 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev); int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, const struct rte_flow_item *item, uint16_t *vport_id, + bool *all_ports, struct rte_flow_error *error); #endif /* RTE_PMD_MLX5_FLOW_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f7a5e479b6..5a382b66a4 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -5245,6 +5245,8 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, struct mlx5_flow_meter_info *fm; struct mlx5_flow_meter_policy *mtr_policy; struct mlx5_flow_mtr_mng *mtrmng = priv->sh->mtrmng; + uint16_t flow_src_port = priv->representor_id; + bool all_ports = false; if (!am) return rte_flow_error_set(error, EINVAL, @@ -5307,27 +5309,34 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, "Flow attributes domain " "have a conflict with current " "meter domain attributes"); - if (attr->transfer && mtr_policy->dev) { - /** - * When policy has fate action of port_id, - * the flow should have the same src port as policy. - */ - struct mlx5_priv *policy_port_priv = - mtr_policy->dev->data->dev_private; - uint16_t flow_src_port = priv->representor_id; - - if (port_id_item) { - if (mlx5_flow_get_item_vport_id(dev, port_id_item, - &flow_src_port, error)) - return -rte_errno; + if (port_id_item) { + if (mlx5_flow_get_item_vport_id(dev, port_id_item, &flow_src_port, + &all_ports, error)) + return -rte_errno; + } + if (attr->transfer) { + if (mtr_policy->dev) { + /** + * When policy has fate action of port_id, + * the flow should have the same src port as policy. + */ + struct mlx5_priv *policy_port_priv = + mtr_policy->dev->data->dev_private; + + if (all_ports || flow_src_port != policy_port_priv->representor_id) + return rte_flow_error_set(error, + rte_errno, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, + NULL, + "Flow and meter policy " + "have different src port."); } - if (flow_src_port != policy_port_priv->representor_id) - return rte_flow_error_set(error, - rte_errno, - RTE_FLOW_ERROR_TYPE_ITEM_SPEC, - NULL, - "Flow and meter policy " - "have different src port."); + /* When flow matching all src ports, meter should not have drop count. */ + if (all_ports && (fm->drop_cnt || mtr_policy->hierarchy_drop_cnt)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL, + "Meter drop count not supported " + "when matching all ports."); } else if (mtr_policy->is_rss) { struct mlx5_flow_meter_policy *fp; struct mlx5_meter_policy_action_container *acg; @@ -16251,6 +16260,8 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, mtr_policy->dev = next_policy->dev; if (next_policy->mark) mtr_policy->mark = 1; + if (next_fm->drop_cnt || next_policy->hierarchy_drop_cnt) + mtr_policy->hierarchy_drop_cnt = 1; action_flags |= MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY; break; -- 2.20.0