From patchwork Wed Aug 4 07:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shun Hao X-Patchwork-Id: 96655 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D986A0C45; Wed, 4 Aug 2021 09:27:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E09E841211; Wed, 4 Aug 2021 09:27:40 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2067.outbound.protection.outlook.com [40.107.237.67]) by mails.dpdk.org (Postfix) with ESMTP id 557EB4014F; Wed, 4 Aug 2021 09:27:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BjbAZ0Sf2fyz5sdV/FnR1oyzH+LlNzqyO+g+pXNApeWyuM7G6NtSI7vCE+zFHfrnn6NEqxZww3tkIZfz0kPfQ+4DRGT/eqYy3hb6mH2FGzF1sTvzaxpKsAuuHblmDr+SpfBVyUI1n+t3PQvKDBBBO7eckifOJplZ7ts/vmOmM4pBY4XhTXgDiObqOqSdPE7XDl5Yb5SXyDqwGz2gyiNoKOvyfCI2SoiT/Sb/vPWDOKBGJqv8U/pnH1dLeCq38exV3+2JqzLi6/PzHjro/iU/TcKtMXZWN3GU6d29u8rTrwFWq8KnpMtkqOuK6svr+CKbHyghe9K0d5fP1qL20OolvQ== 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-SenderADCheck; bh=UMGCg/eYZlYkfHi55FxQ3o9n+qmLbqMal3JAPhn8PWk=; b=kKHA8Y3f8RA4fXjVjWLxYVnKoAeXbpFv7X/E1D2m/rEJxuZ55wMNrOrcXHNchfezSnmqE2E7+NuqL+gFolaYyHdYkiPpq/463t7d2Yqwwou8IMthRaC/2wFlqRMU/8ziOT2HBIAiL9CZXJnQ/65mO2lzI6xrpoeO5B+OuJZ+EG5QwtVLE4/sh4d+ybnvK8VUgF09wXx8MEx1awGGF/8M1euIffUXPXk8WucvscMBgPwVK9hcxdwqnUlhtOd+3FyB1/qPxYFPVcc82WYM1XxQdz8wryy024uuVGBn3sQ77w0wvJTHP/OHw7mXBoox0kLekd4/Ntf+WQVmCrpC21r6ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=UMGCg/eYZlYkfHi55FxQ3o9n+qmLbqMal3JAPhn8PWk=; b=gLVpdTGQMPDuEvRbDVimOK83xxtvUjWA76hhk9V9HqQrEJWXr4KRwvzWNCW7WFW1OkSgGLtz0YBWGyWlptVLvh5I9f6CcQP/HXbyCbLmmtK2hInJfahvTJU+E7mfsY/2Yf3EBdqY4/R8UsnQ+3VkzHm2YsJN2e7B8WLT2OGb/sjvA41i4ZtG37KY4W/jY3nZ5v7R76eU+rYR9p+7SkcMyTE5YfMwYMThzMj7wYBbGFnILKN1SvRhOi7sCBztnqeYH3B8XqRx8FZaQWpq7Tvkk8gkXoBzSWVnUyCehzr3gxFrMkrehV0Uz8k2L3/N2LeMZ2r/kxbbLPNOucwdJ3Ji1g== Received: from DM6PR02CA0041.namprd02.prod.outlook.com (2603:10b6:5:177::18) by BYAPR12MB4743.namprd12.prod.outlook.com (2603:10b6:a03:a5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Wed, 4 Aug 2021 07:27:37 +0000 Received: from DM6NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::20) by DM6PR02CA0041.outlook.office365.com (2603:10b6:5:177::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Wed, 4 Aug 2021 07:27:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by DM6NAM11FT056.mail.protection.outlook.com (10.13.173.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 4 Aug 2021 07:27:37 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 4 Aug 2021 00:27:36 -0700 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 4 Aug 2021 07:27:34 +0000 From: Shun Hao To: , , , "Shahaf Shuler" , Michael Baum CC: , , , Date: Wed, 4 Aug 2021 10:26:46 +0300 Message-ID: <20210804072647.2077832-2-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20210804072647.2077832-1-shunh@nvidia.com> References: <20210804072647.2077832-1-shunh@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7cc9529c-c687-48ad-1624-08d9571955fb X-MS-TrafficTypeDiagnostic: BYAPR12MB4743: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DBBGdd5Z+tLxMu9f9IJcjgmn/cW6aw6QHDEXMRdn3C3YGUW4gXOZPfHQCtMobz2tkhr+7fh/0EJ7YwXJUJ0lkIKxhzy3r6pZex/NlQJcsttt5JRAoHGhz5TFV1OOTHWcq2gH2C7QMNqbSh7JtwZkDC9oaI3UiFqcdjbhYq2wM3HL5qSBp6WU3IOLkhh5MT+qJO1v6BEEDid8/XusqpllS2SnuwPXHKDzYCvVB1lz5xHi6zWdTN3t/Wi5PihcxA0iFTjCl7aw7rf1eYpbq/Fc383xf5phEgycwKtcUfE16um6oNhTDTZ9tY39rpzjwoAeVNd6gRBU+xHxWDOyxl4oBRQBpwqwXKXgJKov8fRcsvnHlgMk6hwa4fR6VAeeClyzc2yoWEov7Q3XE8WATjj1S+Zfs47qGqYMA8CwFzCvyqHsaALMO6DGeMnr+glJlhcdLXUtkzE1VkM9Bwb7GRVDqUk6gsSzUQ6o9xvnFahWEi1AZq/Q5hofhRs5rDnzm0mJa+Bq5X+UNVQ/v03pPbWma/e4qYEAa/0QpSKOH33z2zUYT4XoRIlBM3Tw5ZVPIStSUZAtSyWzCPSA7cAjX+qwXeMcYgciUubXWjgL+bQI96we7abXfmTBE1W5ZV4Nw7KpPrsxfZ7DG/XPb5g62W66dQYcHggCJXveiMOvQ2F2lpajaQ4CKRR+EBG6m0wUgryWAHWOAD+bJcf2yvLJTN7zBQ== X-Forefront-Antispam-Report: CIP:216.228.112.32; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid01.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(36840700001)(46966006)(5660300002)(36860700001)(336012)(2616005)(316002)(1076003)(36756003)(426003)(7636003)(110136005)(82740400003)(478600001)(356005)(8676002)(6666004)(6286002)(54906003)(6636002)(26005)(186003)(16526019)(70586007)(2906002)(86362001)(8936002)(70206006)(7696005)(82310400003)(83380400001)(4326008)(55016002)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 07:27:37.6833 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cc9529c-c687-48ad-1624-08d9571955fb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.32]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4743 Subject: [dpdk-dev] [PATCH v1 1/2] net/mlx5: fix meter flow counter traslation 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 Sender: "dev" When an RTE flow uses a meter without any modify packet action, there will be an internal drop flow with meter counter created, matching the same 5-tuple as the original flow. In this case, the meter flow count action is wrongly reused as the original flow counter, leading to wrong flow statistics. Add a check in the count action translation to detect the meter case and use the meter drop dedicated counter in the meter 5-tuple flow only. Fixes: f3191849f2c2 ("net/mlx5: support flow count action handle") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 4644ae46bd..f54440c6f5 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -12824,13 +12824,26 @@ flow_dv_translate(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_AGE; break; case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: - flow->counter = (uint32_t)(uintptr_t)(action->conf); - cnt_act = flow_dv_counter_get_by_idx(dev, flow->counter, - NULL); - __atomic_fetch_add(&cnt_act->shared_info.refcnt, 1, - __ATOMIC_RELAXED); - /* Save information first, will apply later. */ - action_flags |= MLX5_FLOW_ACTION_COUNT; + cnt_act = flow_dv_counter_get_by_idx(dev, + (uint32_t)(uintptr_t)action->conf, + NULL); + MLX5_ASSERT(cnt_act != NULL); + /** + * When creating meter drop flow in drop table, the + * counter should not overwrite the rte flow counter. + */ + if (attr->group == MLX5_FLOW_TABLE_LEVEL_METER && + dev_flow->dv.table_id == MLX5_MTR_TABLE_ID_DROP) { + dev_flow->dv.actions[actions_n++] = + cnt_act->action; + } else { + flow->counter = + (uint32_t)(uintptr_t)(action->conf); + __atomic_fetch_add(&cnt_act->shared_info.refcnt, + 1, __ATOMIC_RELAXED); + /* Save information first, will apply later. */ + action_flags |= MLX5_FLOW_ACTION_COUNT; + } break; case RTE_FLOW_ACTION_TYPE_COUNT: if (!dev_conf->devx) { From patchwork Wed Aug 4 07:26:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shun Hao X-Patchwork-Id: 96656 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 373C2A0C45; Wed, 4 Aug 2021 09:27:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5F3B41224; Wed, 4 Aug 2021 09:27:45 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2079.outbound.protection.outlook.com [40.107.236.79]) by mails.dpdk.org (Postfix) with ESMTP id 9C0504121E; Wed, 4 Aug 2021 09:27:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ccctwJ9QSvNurP01QWqZl3hhMog4Svh9G7lHHTKaMlgXrlaJP57tQAu/CSphUhQNN/wMIZYClhB55OvYZbQ5heh4vgVUbeAWsqT3V18Re33aQ6P4BwbCvWMmAw3UOnAG/OLGx4HviU2Fib1E+XbE04r9Ws5aQE9ZwbcPUTJdJGl+l+bZPJ4aZ0azjO+kXr/80I7ASmsBR2oXCJC6OZp5wlFonk4rfgy4P61YYz4HETxFwkI02VN7nXFD8XARKNKOcdjVid7S408k/+IEu7EYJXlN4G6LjBF0rlNjRllX0i4ewiAKBpgiPQHQSFbq4JhIWEaCnDahYYudio4lA261sw== 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-SenderADCheck; bh=HvRzXxugb8xnPPt7dB6NkHpL3ibe4xL239B1CGuObWk=; b=ATS647twqXuR+zBYD2Q6RuGmgxh7hjbUgaZTpVS2MeegqHtHkOG9XFX0OYwNNKU85zj1Jh9ag5VfpyEYD3ju6jO7aFKMqtI96D5xon+b4GL5tJEW4wnIJCklW0qumlqT12zWNlbYMLGCbrmjCWFiUM8ofAahV5HXexcrQTt1OxMEYfI0TpEg/Cy4Q4xQpNvZivOS8BS0VmhQXqyMhlbW79WA9VxoaPWnql18sL03OoJa5YtTnqIgNyv5bADeCYODKCvgOZZxmHvpoW9pfAvZF+3/6u9AwRhFN9E1X4KsAGq0NT6GhWxGa8xvk5LmT9Mec/edvjaWuHDZRpDPSNHXKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=HvRzXxugb8xnPPt7dB6NkHpL3ibe4xL239B1CGuObWk=; b=rZk4a5yQf3ZPB9cluy3BDI6eHRMUyfzsRjIWWlosXY9H0JeL5/J4lU+z+kPAyeEF03/gAa9JPOAHCDhkEB2lSJg3VxXOZko/ELdwmmSG8sRt3Od+/7jv8WT5Rc0zE/MFpDlF0RfcV74ycfoHUX3JhDNvDtzzJ3dwKY6hhKSU5ZLJyihonzmbx0Azm6CmaW/Psn948h3U6ka+DwJLoBhr8SzFZKJMlnEeY+NaNfEw3h3n6TtAbJG/7u76fkcKtdqwwJvE+uRVZu8yqOtL+zJiyIJBbMb02UKFPggl0n/hLIoP2vWGZopHytkX7JJ3Tl/VvwBemQjhvVRFiUCb+00C6g== Received: from BN9P222CA0003.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::8) by DM5PR12MB1658.namprd12.prod.outlook.com (2603:10b6:4:5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20; Wed, 4 Aug 2021 07:27:42 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::6) by BN9P222CA0003.outlook.office365.com (2603:10b6:408:10c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 4 Aug 2021 07:27:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 07:27:41 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 4 Aug 2021 07:27:41 +0000 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 4 Aug 2021 07:27:38 +0000 From: Shun Hao To: , , , "Shahaf Shuler" CC: , , , Date: Wed, 4 Aug 2021 10:26:47 +0300 Message-ID: <20210804072647.2077832-3-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20210804072647.2077832-1-shunh@nvidia.com> References: <20210804072647.2077832-1-shunh@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29d30f22-dfc6-4e8d-7328-08d957195877 X-MS-TrafficTypeDiagnostic: DM5PR12MB1658: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZP3zf9Pui8suFq44tF6YZ+bHbS49JtZ+uowIIAHPXSY3xQg0fRE7hHTRLwE5lzufD3xf74nY5sowhovTAGHgmFewafgnspW8NArN+biIc2xxwnbfIUjlIln9E178SBQLIbNX0GtxPJl/1jImCrk8JOHk1poztjg/vZSKpS85VpjvF01+2/Q3Tz7PyNOJNabBlyfUerCbxqsVjVekdwNY4eTt+DwncyOaAxfvLQXDncPiZQe+ZcDSFRsbLemuDqIzfO6m1aBpcZhtWVwiNWqrtVJ5uAxAe0NdFD1+TQni6J1d66lj7cr64ZdR8PTmoAKe8v9UNr3RdRoh0LOjmPp/uH2T3R3QPzNi3nLqr60iEWR5WbDxIC+wSQC+Bed/hFAzRK2Kw8V98BnPb3BGGBaNZ70rrf4jmsRf3jUPpE4eGIpqXTFEOt7ufHD21kPH087MZm+xmSFhXa4zJTYeeuVzgCtueMgCnQY84kB9bna7WJ7WZNwKBbhju5g08H4Ri9hrclCSSFPv/DyLCIEM5VpR7NPb+4T/fokiFqYpzZw/7UUz3kgVa/+pvA4w5NMLpREv2FQ0mvyF+UR+9S7k79p8OfP5h3rRVE3a8cHnquNMyjL6Wmr0VjvlByHYn+W9veyWn4GBgt6odiUA2n+oDm7EQYZOSYp07+TmRNDHuG8YEtARHUABxzq3FhuqPOWKnnWO/FM/TG0Aqn/MII/20SU5fQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(396003)(376002)(346002)(39860400002)(36840700001)(46966006)(6636002)(186003)(26005)(36906005)(6286002)(8676002)(16526019)(36860700001)(86362001)(2616005)(316002)(336012)(110136005)(54906003)(83380400001)(55016002)(82310400003)(36756003)(7696005)(8936002)(356005)(47076005)(426003)(1076003)(5660300002)(4326008)(478600001)(70206006)(70586007)(82740400003)(2906002)(7636003)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 07:27:41.8008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29d30f22-dfc6-4e8d-7328-08d957195877 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1658 Subject: [dpdk-dev] [PATCH v1 2/2] net/mlx5: fix domains detection in meter hierarchy 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 Sender: "dev" Meters in one hierarchy might support different domains. For example, one meter may support ingress only, but the root meter can support all the domains. If the later meter in the meter hierarchy wrongly doesn't inherit the first meter's domains, it will lead to invalid domain table access. Fix is when creating meter hierarchy, try to inherit the first meter domains in the meter hierarchy. Fixes: a3b7af90baba ("net/mlx5: validate meter action in policy") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f54440c6f5..31d857030f 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -17527,6 +17527,7 @@ flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN, NULL, "Multiple fate actions not supported."); + *hierarchy_domain = 0; while (true) { fm = mlx5_flow_meter_find(priv, meter_id, NULL); if (!fm) @@ -17539,7 +17540,12 @@ flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, "Non termination meter not supported in hierarchy."); policy = mlx5_flow_meter_policy_find(dev, fm->policy_id, NULL); MLX5_ASSERT(policy); - if (!policy->is_hierarchy) { + /** + * Only inherit the supported domains of the first meter in + * hierarchy. + * One meter supports at least one domain. + */ + if (!*hierarchy_domain) { if (policy->transfer) *hierarchy_domain |= MLX5_MTR_DOMAIN_TRANSFER_BIT; @@ -17548,6 +17554,8 @@ flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, MLX5_MTR_DOMAIN_INGRESS_BIT; if (policy->egress) *hierarchy_domain |= MLX5_MTR_DOMAIN_EGRESS_BIT; + } + if (!policy->is_hierarchy) { *is_rss = policy->is_rss; break; } @@ -17825,11 +17833,11 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, * so MARK action is only in ingress domain. */ domain_color[i] = MLX5_MTR_DOMAIN_INGRESS_BIT; - else if (action_flags[i] & - MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY) - domain_color[i] = hierarchy_domain; else domain_color[i] = def_domain; + if (action_flags[i] & + MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY) + domain_color[i] &= hierarchy_domain; /* * Non-termination actions only support NIC Tx domain. * The adjustion should be skipped when there is no