From patchwork Tue Nov 8 09:30:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 119549 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 BD239A0540; Tue, 8 Nov 2022 10:32:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F94C410EA; Tue, 8 Nov 2022 10:32:01 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) by mails.dpdk.org (Postfix) with ESMTP id B5A16400D7 for ; Tue, 8 Nov 2022 10:31:59 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEbhiSxbhz5yo7/AeuDZ8nUFqrRDQ8poftCJIIKW8OxwJxF/GOYxIpWZnk40pCBzV8t8oIhJvAFkWDcq5rVTwFrmClkGGayAqCVr2IRGDwZ6y+3z0UycrYnuP9dz/77BjvZP/Pg9F+aIcVIA4U0fwgaXTGLszYn38RO0Oay0ts1gFy1wP7b50DIfRfgXY/gTZWXKmYyhVJkI2D+5OmOnte0S6L0D59PPAMMkCdNf23FFeNWC/DjnQb3qCoHPz7WmbLJGsGjVd5GWPJZ0jw87eTuwHFaf2D0nWnscDmIzdoOwP5ggokkIK6Do8Vq4fQVg+yQeK7YdpMTIkJfQlDiVjQ== 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=S3j3w9C2g58MFHkHVE9QB84FOVfl0DxOdcswV1xwprI=; b=El9/bOjknxBKuBl1y0wQF2Gr9k0pdzhqBb537fcTDuyavTaC4ZCmrUmhjsTwLowlw3aFdvAdfrSxOVQm48TUZg4Vk/2ChlHwCi07mu+Fg2Stq9Gv7oiS1oZ0xmilc9X/UxOH9nqVZ4PcfNONlxkYjuW/6M+BImQGbG07xgfoEK5Vc1gG9NPWEI6wj/1zlbIBLN653G2r4VvXkMNnBef2IywkfWkk425TL/GfGg9fgQOVCnu5vtzkb2+k278k8yrmP3tJ9ixdcphnqQtKh6rZsRKixzhm+NjGDNJ73xc6yNV3sUGeOYt1eJc+fiNRUGRnVjewOiit3Occnl9ZonSNJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.com 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=S3j3w9C2g58MFHkHVE9QB84FOVfl0DxOdcswV1xwprI=; b=n7dSmghhqpS6NujP7zhJLs8L4Ngq9zDJSbrx3Wx4ykDTXWeQ5axasRrCbWLey2LoItW+7he/fPNfSnSXIWd4rvSgzp2Apx8yAclZhMDGKjL3p9xasEhl3moE2OyCC5aAgn3ZOIOXm6waJEuSMXRyj1gE2dS9NYk4vB8Vy4mpQs4L4S+xTuxe615KoFufps61hi+DnXJcBIqAcZhi2uQl1Kn9tQ9mLMyFe3Qy+2B3OP9tmELwT62pVCw+0a0uqbIRQvVi5LnrpBbg20QIwvUnDP6D6xu0aos7FY4ZrkBj53rvwdJc7aBwDn/1m7j6YtYpLfp972que2JinllgdzJ0SQ== Received: from DS7P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::22) by CY5PR12MB6526.namprd12.prod.outlook.com (2603:10b6:930:31::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26; Tue, 8 Nov 2022 09:31:57 +0000 Received: from DM6NAM11FT100.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::65) by DS7P222CA0013.outlook.office365.com (2603:10b6:8:2e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Tue, 8 Nov 2022 09:31:57 +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 DM6NAM11FT100.mail.protection.outlook.com (10.13.172.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Tue, 8 Nov 2022 09:31:57 +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; Tue, 8 Nov 2022 01:31:47 -0800 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; Tue, 8 Nov 2022 01:31:45 -0800 From: Dariusz Sosnowski To: Aman Singh , Yuying Zhang CC: , Ori Kam , Suanming Mou Subject: [PATCH] app/testpmd: flush flow templates when port is removed Date: Tue, 8 Nov 2022 09:30:45 +0000 Message-ID: <20221108093045.445821-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: DM6NAM11FT100:EE_|CY5PR12MB6526:EE_ X-MS-Office365-Filtering-Correlation-Id: eb46909a-07aa-46a1-1924-08dac16c14ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6cmjl9ifJ671Ezu9TKXC+Sc+UzBFUZujFzkwvGpt9MNZnG/zXP0B5WMZPrvd4QxBs80kgspNi4rdUoTHj5EkKwhwO2fHgT9gK0TZRkbv+TJvN2z4rzEntktFuJwt/ZUPL2iavkEpiGvqiWxJTlvt5J3f1moA+B1L9BUXIQyA3jn3rtvRoqP3wFXB7Jk4F6EANhDgdosnAMaOFPoAyhZckL+GAFM0Q1QIPjopjoWGhyrVV20NklvPNOW+YMCfdIQ18bxrj2TfIyu2+SRjkuF2yXBcI1qPSBGEvHBLN10CKzSSa+HcsNRsnPpcjFVGYxKk5H2xcLYlAsbpkUnDf6Pu4UkrGUf0GbcjP6a9Ifkmz3VehNJ5jDdctVVTWX7Vwm3PTH17/0AhHRBlz3gWdLmPlfYsInNRcuPa9W2OO0xfxPbP8AJmBNTwMTx6+E8j4GuxCT4PHOBOTvXl4RDyvs7l49fUcHLDz3J2+R6mpateYSIEwUPzLC5pnJaeft0ZfFfDnM5ShcnpjUe7I0wy+C+cSTuvYy3MoOrHH/d4CIj+8IW9mUh10ZwZC9sXiBlpQJ7/5oF0dlCXFQn7QBAf4aLaUULKS6jVKSRSLFGhYWsTdPdTVPYNEEd0jKadUwvCzsC9jXV3/Bs89oyMR2ICWVoHpiVsm82kzIGAsaW97r6K9UEOhGChz4VMkeqHwTwX6BttBjSxxAkpq8/Q2moPGuiCEKfqvWqwFwkTDEdKkToVFM0ecs3zt3UotsIo7ldP09xDUCAA39xkc2d2F27ZVH09Qg== 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)(396003)(376002)(136003)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(36756003)(7636003)(86362001)(82740400003)(47076005)(2906002)(5660300002)(1076003)(26005)(186003)(83380400001)(36860700001)(336012)(426003)(16526019)(7696005)(2616005)(6286002)(8676002)(4326008)(316002)(110136005)(70586007)(70206006)(41300700001)(356005)(8936002)(82310400005)(40480700001)(40460700003)(54906003)(55016003)(107886003)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2022 09:31:57.6561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb46909a-07aa-46a1-1924-08dac16c14ee 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: DM6NAM11FT100.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6526 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 From: Suanming Mou This patch adds explicit flushing of template tables, pattern and actions templates, when a port is closed or detached. Signed-off-by: Suanming Mou Acked-by: Aman Singh --- app/test-pmd/config.c | 111 +++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.c | 3 ++ app/test-pmd/testpmd.h | 3 ++ 3 files changed, 117 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index e8a1b77c2a..234d534d10 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2293,6 +2293,42 @@ port_flow_pattern_template_destroy(portid_t port_id, uint32_t n, return ret; } +/** Flush pattern template */ +int +port_flow_pattern_template_flush(portid_t port_id) +{ + struct rte_port *port; + struct port_template **tmp; + int ret = 0; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + tmp = &port->pattern_templ_list; + while (*tmp) { + struct rte_flow_error error; + struct port_template *pit = *tmp; + + /* + * Poisoning to make sure PMDs update it in case + * of error. + */ + memset(&error, 0x33, sizeof(error)); + if (pit->template.pattern_template && + rte_flow_pattern_template_destroy(port_id, + pit->template.pattern_template, &error)) { + printf("Pattern template #%u not destroyed\n", pit->id); + ret = port_flow_complain(&error); + tmp = &pit->next; + } else { + *tmp = pit->next; + free(pit); + } + } + return ret; +} + /** Create actions template */ int port_flow_actions_template_create(portid_t port_id, uint32_t id, @@ -2373,6 +2409,43 @@ port_flow_actions_template_destroy(portid_t port_id, uint32_t n, return ret; } +/** Flush actions template */ +int +port_flow_actions_template_flush(portid_t port_id) +{ + struct rte_port *port; + struct port_template **tmp; + int ret = 0; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + tmp = &port->actions_templ_list; + while (*tmp) { + struct rte_flow_error error; + struct port_template *pat = *tmp; + + /* + * Poisoning to make sure PMDs update it in case + * of error. + */ + memset(&error, 0x33, sizeof(error)); + + if (pat->template.actions_template && + rte_flow_actions_template_destroy(port_id, + pat->template.actions_template, &error)) { + ret = port_flow_complain(&error); + printf("Actions template #%u not destroyed\n", pat->id); + tmp = &pat->next; + } else { + *tmp = pat->next; + free(pat); + } + } + return ret; +} + /** Create table */ int port_flow_template_table_create(portid_t port_id, uint32_t id, @@ -2501,6 +2574,44 @@ port_flow_template_table_destroy(portid_t port_id, return ret; } +/** Flush table */ +int +port_flow_template_table_flush(portid_t port_id) +{ + struct rte_port *port; + struct port_table **tmp; + int ret = 0; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + tmp = &port->table_list; + while (*tmp) { + struct rte_flow_error error; + struct port_table *pt = *tmp; + + /* + * Poisoning to make sure PMDs update it in case + * of error. + */ + memset(&error, 0x33, sizeof(error)); + + if (pt->table && + rte_flow_template_table_destroy(port_id, + pt->table, + &error)) { + ret = port_flow_complain(&error); + printf("Template table #%u not destroyed\n", pt->id); + tmp = &pt->next; + } else { + *tmp = pt->next; + free(pt); + } + } + return ret; +} + /** Enqueue create flow rule operation. */ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index bf589c4e8d..6c5a3555b8 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3212,6 +3212,9 @@ flush_port_owned_resources(portid_t pi) mcast_addr_pool_destroy(pi); port_flow_flush(pi); port_flex_item_flush(pi); + port_flow_template_table_flush(pi); + port_flow_pattern_template_flush(pi); + port_flow_actions_template_flush(pi); port_action_handle_flush(pi); } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 93fdb9d331..277d4091ab 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -907,18 +907,21 @@ int port_flow_pattern_template_create(portid_t port_id, uint32_t id, const struct rte_flow_item *pattern); int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n, const uint32_t *template); +int port_flow_pattern_template_flush(portid_t port_id); int port_flow_actions_template_create(portid_t port_id, uint32_t id, const struct rte_flow_actions_template_attr *attr, const struct rte_flow_action *actions, const struct rte_flow_action *masks); int port_flow_actions_template_destroy(portid_t port_id, uint32_t n, const uint32_t *template); +int port_flow_actions_template_flush(portid_t port_id); int port_flow_template_table_create(portid_t port_id, uint32_t id, const struct rte_flow_template_table_attr *table_attr, uint32_t nb_pattern_templates, uint32_t *pattern_templates, uint32_t nb_actions_templates, uint32_t *actions_templates); int port_flow_template_table_destroy(portid_t port_id, uint32_t n, const uint32_t *table); +int port_flow_template_table_flush(portid_t port_id); int port_queue_flow_create(portid_t port_id, queueid_t queue_id, bool postpone, uint32_t table_id, uint32_t pattern_idx, uint32_t actions_idx,