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 643C5A0509; Wed, 6 Apr 2022 10:54:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0209B40DF6; Wed, 6 Apr 2022 10:54:24 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2069.outbound.protection.outlook.com [40.107.101.69]) by mails.dpdk.org (Postfix) with ESMTP id 5C5AD40689; Wed, 6 Apr 2022 10:54:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oxj5O0rqjTMSGdLkaiaNpTfduK4QQfIiAEisSxCpSj8nE+4Godw4sp4sWRH6x3KLWD1FL6gRMzKSV5S9whjm7FwICON3Zj4P1y3eFdj3aYvaBUutTd0hMZE0byLotaVpJrpuWj0v3tc87spemXD4r2HH09u45PmgwwoLLD6jTiQDHksxAKImcFMtIDJg2OdvHpmfl5jD10hnbJjUi4/bpwBV2cs9H6hFysjECfUBTURgqMLenseSVvndz4LVLMJaUvZ/yOO1+aGMXiqXkPBJ3P1zuTMWnAo+EcsPYjLltESP72gWa6x9MMltk0qNVGZeFJlG5uE6HIaMh8smewx1qA== 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=XFz7KM3bULgUO/Vt2MtCiLwbhQrPlocf0IBv/NOuPVg=; b=kh1nWvOKjW3MofhPh5hWux2HI+5VSYZU8iaGO8/m8rmsPKuUyjYqYeVYpd7ze82GfpznDP/ncr9BHtl65NPuxEQG6hc/H2SkLK13t2Zmd2K8WClHG1cDsPn3Htj3jvOWuxMWviyCDZAogqpsgpAwNelVCVrcfuEuFMl55K2G5DpJ4Dql8svFVFV/yerHmhl4zz7ethhMvSmHonnfIBV9SrZgsnKD8i1CHZFYCEfmywo32RsonVp0rdis+r6F5Gbh91j0JPjHB+1OvKVSDX+a7swrqKPjGLghQvTKWCre0NuBRuxe3Ht7G5Uov4r6Qwb8wRUGURWptmDxIWjVtin8vg== 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=XFz7KM3bULgUO/Vt2MtCiLwbhQrPlocf0IBv/NOuPVg=; b=VJbBmXSfhfrYwmPFUOQWaTFi8oRaQVHGZQjtAORg0g3glpf0xHT5bdHSZqphkFU37nImaofYwkvgs344iGeF1Mauk6acPtTD6xNPrAQgjwJn8ZnWEZyEmah9oOR7cQ4gVmQ9wgzftfPnFWZskapRtNFv84p4QG7Yxqg0dpn/DFeAwUswzYLp0oyl8S2+u3OMirsJHz9s/hVDTqDj7u5/ebdRG3mmlqmjgXqGmaqY9VcNrlJ+KXqEvstpsWeFjEo7h+Mt5PVXu4rr19PKbW+OrdmXN+GN+0iCbta/JwpqctL/Mj6VVojjAdBJf3G08/jZFA7vZUomWXkTy7ZzR3JkeA== Received: from MW4PR03CA0298.namprd03.prod.outlook.com (2603:10b6:303:b5::33) by MN0PR12MB5811.namprd12.prod.outlook.com (2603:10b6:208:377::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Wed, 6 Apr 2022 08:54:20 +0000 Received: from CO1NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::94) by MW4PR03CA0298.outlook.office365.com (2603:10b6:303:b5::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.19 via Frontend Transport; Wed, 6 Apr 2022 08:54:20 +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 CO1NAM11FT015.mail.protection.outlook.com (10.13.175.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5144.20 via Frontend Transport; Wed, 6 Apr 2022 08:54:19 +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; Wed, 6 Apr 2022 08:54:18 +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; Wed, 6 Apr 2022 01:54:16 -0700 From: Shun Hao To: , , CC: , , Subject: [PATCH v1] net/mlx5: fix wrong counter in non-termination meter Date: Wed, 6 Apr 2022 11:54:01 +0300 Message-ID: <20220406085402.11639-1-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 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: d943f529-f99c-4862-f868-08da17ab0a00 X-MS-TrafficTypeDiagnostic: MN0PR12MB5811: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: na2JPF6vgCOx2K1CuS10mVHuJfvEcbtgtosID921MIAyW3b4od/IMtkRO+oqXyVFl3JFsfrFR8XMw5Ll7f5LyT19AeZD3rVgMrQQX9L7954q1ZWilVLbd7bV3U1+JsAA1SLOWS122MiNYDmW7Wu8yhzIk0a4wrSZj8vDgqHsnKduqeeBq8itsKj9W5KgHF1UIn3Gq686eM8gDgcCDyWQYpfWeoagl/J+u9IeYaCY4QRZCT6DMH4RwODVKFQ9wB95lKamPWkYnEDgvk1Z+5lMyAnak3ORdazT0NOsgnwjGDbG1Cc5ihAO/dCHtvfIRghVrS5OVSJUQN7Cns8kqfCkw3VvxFQiMiWYDiIkM62layctNtK04A+DqawHINgq6uSUQ1ocsPf7gfmUN500PgzcZh4P9J/G3wYzN4A+kZDJpnJXxFdM3KrZzZdDL28YhfehW8zVprhQORDwCMpH6ywgZ8fxm2d6ZY0oUuVsTYlP40EAIt9Q1M8xdb88KIuO9FUJIwKto7vHEQfYQPAjrqJWPmBsjXRzI8WVZPQ30PGJmXikGG/e12qkCgQBzxjcOHqDvL7FwDIvTc+u4wjojJHreWNkBd/W+jRYFe4HG/DMG3q3kd3lHgaHVW29U2dE0CQR8BM/wPf64OEONYOjltxG79VAOdmZ6LrgCsjDpfdfItj0Yky7ICRi6MfzqrtAhtj63CcQ0P4gWGz0grwUpgSRCQ== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(82310400005)(6286002)(2616005)(1076003)(7696005)(6666004)(2906002)(5660300002)(508600001)(8936002)(47076005)(40460700003)(356005)(55016003)(83380400001)(16526019)(36860700001)(186003)(86362001)(426003)(26005)(450100002)(336012)(36756003)(6636002)(81166007)(4326008)(70586007)(316002)(8676002)(110136005)(70206006)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 08:54:19.9935 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d943f529-f99c-4862-f868-08da17ab0a00 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: CO1NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5811 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 In RTE flow, if a counter action is before a meter which has non-termination policy, the counter value only includes packets not being dropped. This patch fixes this issue by differentiating the order of counter and non-termination meter: 1. counter + meter, counts all packets hitting this flow. 2. meter + counter, only counts packets not being dropped. Fixes: 51ec04dc7bcf ("net/mlx5: connect meter policy to created flows") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 78cb38d42b..28afdfe011 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -5271,6 +5271,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev, uint32_t flow_id = 0; uint32_t flow_id_reversed = 0; uint8_t flow_id_bits = 0; + bool after_meter = false; int shift; /* Prepare the suffix subflow items. */ @@ -5337,6 +5338,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev, tag_action = actions_pre++; action_cur = actions_pre++; } + after_meter = true; break; case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP: @@ -5365,6 +5367,11 @@ flow_meter_split_prep(struct rte_eth_dev *dev, MLX5_RTE_FLOW_ITEM_TYPE_VLAN; } break; + case RTE_FLOW_ACTION_TYPE_COUNT: + if (fm->def_policy) + action_cur = after_meter ? + actions_sfx++ : actions_pre++; + break; default: break; } @@ -6393,8 +6400,10 @@ flow_create_split_meter(struct rte_eth_dev *dev, if (!fm->def_policy && !is_mtr_hierarchy && (!has_modify || !fm->drop_cnt)) set_mtr_reg = false; - /* Prefix actions: meter, decap, encap, tag, jump, end. */ - act_size = sizeof(struct rte_flow_action) * (actions_n + 6) + + /* Prefix actions: meter, decap, encap, tag, jump, end, cnt. */ +#define METER_PREFIX_ACTION 7 + act_size = (sizeof(struct rte_flow_action) * + (actions_n + METER_PREFIX_ACTION)) + sizeof(struct mlx5_rte_flow_action_set_tag); /* Suffix items: tag, vlan, port id, end. */ #define METER_SUFFIX_ITEM 4 -- 2.20.0