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 3DD2D45BA3; Tue, 22 Oct 2024 19:01:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C59841144; Tue, 22 Oct 2024 18:57:04 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id A6E9C40E3A for ; Tue, 22 Oct 2024 18:56:46 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MVujjAxImcZ1IEvRVWceu8vGB4n5r0mAZ8rj+rQjpkPsi73XSynsDQUkC2Li52oN7ZE4Vk18voNEDer8i5oo7RqstNEho9Qa2qSoCpMhvBCC0tKOa4R1P4WQ9bSjstvq0YRcz2VgWP5rCM/jt9B31n+xWkBD74kJrf8Q2FT2VAiCWyvOeXI49sGpe4eVDVw/i378NkXynxNuauswGZQtG71n/4UF/y0i+G4hpLJ1VetqfQGruoXMkAtSHJbGVRRTp1ETdM7RwXlaiZAHvheiglbMnUS6Cru8PlIByvlZ+AS8Q2U397fYqstaw/PcbvLbw7/CPJNVyAmYTcP/i+iXxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TWoEUiR+fKAogAETL+XW7p5Fj5jcqBmARY8aQ6ZuvkQ=; b=w08N2/4qqN9SgUVq4SS01ccntnGTNLJ0PYNmE3QPwaa3o/cVWc2HjmANu6bFQTtwro+PgzwMfAo/nKfJ/OooObc96+ZHZ90jDD6llMekxQubnVGezucF9Xv7MxH+rXxSowZvWA8NJzIvxnUioygfcziT7+T3rhnCFCDMhsYsa59GKQuYNMmixU2oZokVVYb0jz/iRBmtnPxnFA8pNIGuxH+BoXfqZtqu/EOkC3in0Nmb3bfEEEvd3W9u2BYg4LZxnS+n6UbMEdBxY0NcUgGUYDXQvkRGcdfKIZcZxZc0XeJQH8pI2xkdcYO2BI166HVWCHSvjv3/hYBpEfXhfQKnAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TWoEUiR+fKAogAETL+XW7p5Fj5jcqBmARY8aQ6ZuvkQ=; b=ntPORxQFMI9llLqN/aSTzHXhA9wfRLuxu2iE30htprUXMhGCmhJflNXyySZC+OVQk7vLp27kxnsvBbh44tUcUqFns43dOl4njLQrne4KlDsDDsJCoFpCzcxlU2AbycnxCRYQxPExySUnCwKK1zlkVa7V+IhpyRvIXgH+WNAZVgk= Received: from DB9PR06CA0027.eurprd06.prod.outlook.com (2603:10a6:10:1db::32) by AS4P190MB1904.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:513::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 16:56:41 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::41) by DB9PR06CA0027.outlook.office365.com (2603:10a6:10:1db::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56:41 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:41 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org, Oleksandr Kolomeiets Subject: [PATCH v2 38/73] net/ntnic: add flow flush Date: Tue, 22 Oct 2024 18:54:55 +0200 Message-ID: <20241022165541.3186140-39-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|AS4P190MB1904:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: cd6c6f8d-e905-4ba8-3ef2-08dcf2ba808d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MOVyDQ5peFmYdLpGBs6RoFM1Ftf7V2C2dg/Xvl4E8sk7PDK9wAovfDni/gj5?= =?us-ascii?Q?oHfUDKqbvQNF53Na8Uajl36NAUMiOLsQNuBBlXXEUGyTX6ak264Si+vEKU3D?= =?us-ascii?Q?MAheU7ctvaYiMySNcPw2vuJylrmHWjArpx5QpGK/444gaLBXClO4gfrsX3zU?= =?us-ascii?Q?fpqgVrMA/XOz41qOARnUJedDjlI07rotAxBY0Ln2+DG4N4rJc69i0FKRd2Z+?= =?us-ascii?Q?ac05l3CZufftcvyhzLqIscIB9j/HmuJm4BbsDFEwZFYwaxwZguTv8KojM4iI?= =?us-ascii?Q?J0oI1E0dA4yzDrs5d81WD+TIKgEImjSjOXs0bp4sN7R3zAPZuTqj29XkQUyL?= =?us-ascii?Q?U9Y0HdQSXMTJ0hYCtMrb9p8voC3UvEoVZt2CAmZqNOZ44Lz7Jbj5Thy7+Oz4?= =?us-ascii?Q?6RQerwzHeCwgvCKcprzKhcl45qqP/Lxz2t4lU/H7jbdfzKsZhpr4/xUxyntz?= =?us-ascii?Q?qvfQOC88mzN9Mk3xxMKzi9Ig40x0Ud9mMkomvpg0mkaD8uJGtdUweQ7q+kvo?= =?us-ascii?Q?UOWx59UAcf9VoQBPr6K6LdBV16nuBoyHqKnzObiShDJHeyAwRUMOr87KQt9V?= =?us-ascii?Q?8YDiBULLgNScOuIsR2QNzcVM7+GBiiT/C8BDtTGN5jhvLdCPfOcruyLKx0zO?= =?us-ascii?Q?YXtYsCmXrtWMI8+pTd4OJPSOadpNkhcMuXEPKdd7uaT81yGz0/3DLZiOAxqW?= =?us-ascii?Q?V855mOqrJIeJ1QjBrvqfUiL6X4Pnf36r6tG8H/Gm7oj9L38sBrpyfgVXJj1Q?= =?us-ascii?Q?PlRwa5Ce844vrjjpwNcG/NlEH/LgyHdJjH+DbUCRggPBrSXDVQYInFr1Obwv?= =?us-ascii?Q?QG6Qoy5zh+cUioU04SL2/kcdgwD46Xq6+diU8WG5Xw/bChhW7mjswgClaR05?= =?us-ascii?Q?CKB4tFdMf4cdqncRfkQqchLeLBFwiLvaduBq/HVHb0j5LwwSkEEkTkfBXF5a?= =?us-ascii?Q?sPH+gUcYn++ll40aQ1cAGCkMTALSQP7/YQsHs3pd5hqgHTBZNvLeMblg6A7o?= =?us-ascii?Q?66/x+c66oFiuIS2CL1AmfS8agOGQxwqjCpKFxI34NmWdHB+KfYSYn+/IRY1X?= =?us-ascii?Q?Ou62dqlL/2nDrM3ymoKYJ+swlXIlUgkDKX3PffmThBH/OLRjqS9zCx6ea8ST?= =?us-ascii?Q?hwaW5oCOqj6UuNJBd26YU53GugluVvmxURgHx9Ns4jKJwEVCXSuKnzpkUveu?= =?us-ascii?Q?kUPTxUdTz/DFdeFtn69rSeg6Q77UZhtBpkyN7/cE1p4VF54Kb70wQH9Yg63R?= =?us-ascii?Q?afKS0qiSM0u2gyWcze/y9kAaGcCPkMqRWxg958v8PDVxgpvNDc8z8djyuiHg?= =?us-ascii?Q?tYYAu9webKB68BQu367/GSfiLhup4dK+CfM35S6e3bofbi5awwzIe9ePP3Ng?= =?us-ascii?Q?A1+TrWfYtrMq73wEGNzlqLCi91u7ENC8t8C9TMp3M9vWJNLyQw=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: KZNpDqqYCYF95aIv34NESBMeyXf9S2fOPg4EZG7FfcFAY5nu3/JWQSXphnyJ9/EnmlYdYlnt7J6IyDn/4f1ULCfTjdj2dHSpZYJaBF6Vq3yjx2EP0cUTIyvNn/5Z3dzwJbYqFTVmPddfO5crypQrijgFpvHn1Q8+CQwNWd+a7+cboRJYpT6kIqHyr7d2HWs8wH4UR4jjmaEdw4dGBO02mRJ9pd6Ky2mLlPGZeI7ydlyLBm32hbpz8lZsZNiPWsT4HY2nwK+/ghyULuXf/bY51iYXQbTA+fvS3NQtAQmoAQPWSKyc8chbsFbD8dhBmmQ2owHGELASBEGfrDs7HPdh+MIG5PZI+zI+x2RNkcyRGFvRQ5hibAzPNEjBL8tGDxu86TJmwEReytGlmzLAKJV44MhRId4j8LJincEuG53BXZgzSCZzXBT9ILVW3WxwAmZXl/6qzWByqjqg8eZjFsydUPJ9M05Mby0SF1EOhnuptRka2ecusMXBEZk7NlVZP73IIQx9O+a/UJlmWmlsKfJsBkf0xV7sKjI2HmHR/VnWKoZF+Sdr290yQVTLxk3gtP3WI9QUKo9wizS+lyUbdf5j/eip07ZQOckcOCd86TsXX/KG6zusgBY44VmIus3/zFjTQGcI8OXdunpRhRPn8i9asiJG5NZN5LQhUTTItK+InfQ= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:41.1224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd6c6f8d-e905-4ba8-3ef2-08dcf2ba808d X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB1904 X-BESS-ID: 1729616203-304983-12656-14405-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaWliZAVgZQ0NAwLdHIyCI1xc AkyTjZ0DQl0cQwzdQyxSIt2cwyKdFAqTYWAJKqLbhBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan16-191.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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: Oleksandr Kolomeiets Implements flow flush API Signed-off-by: Oleksandr Kolomeiets --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 13 ++++++ .../profile_inline/flow_api_profile_inline.c | 43 +++++++++++++++++++ .../profile_inline/flow_api_profile_inline.h | 4 ++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 38 ++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 7 +++ 5 files changed, 105 insertions(+) diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 7f1e311988..34f2cad2cd 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -253,6 +253,18 @@ static int flow_destroy(struct flow_eth_dev *dev __rte_unused, return profile_inline_ops->flow_destroy_profile_inline(dev, flow, error); } +static int flow_flush(struct flow_eth_dev *dev, uint16_t caller_id, struct rte_flow_error *error) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "profile_inline module uninitialized"); + return -1; + } + + return profile_inline_ops->flow_flush_profile_inline(dev, caller_id, error); +} + /* * Device Management API */ @@ -1047,6 +1059,7 @@ static const struct flow_filter_ops ops = { */ .flow_create = flow_create, .flow_destroy = flow_destroy, + .flow_flush = flow_flush, .flow_dev_dump = flow_dev_dump, }; diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index e47ef37c6b..1dfd96eaac 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -3636,6 +3636,48 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *fl return err; } +int flow_flush_profile_inline(struct flow_eth_dev *dev, + uint16_t caller_id, + struct rte_flow_error *error) +{ + int err = 0; + + flow_nic_set_error(ERR_SUCCESS, error); + + /* + * Delete all created FLM flows from this eth device. + * FLM flows must be deleted first because normal flows are their parents. + */ + struct flow_handle *flow = dev->ndev->flow_base_flm; + + while (flow && !err) { + if (flow->dev == dev && flow->caller_id == caller_id) { + struct flow_handle *flow_next = flow->next; + err = flow_destroy_profile_inline(dev, flow, error); + flow = flow_next; + + } else { + flow = flow->next; + } + } + + /* Delete all created flows from this eth device */ + flow = dev->ndev->flow_base; + + while (flow && !err) { + if (flow->dev == dev && flow->caller_id == caller_id) { + struct flow_handle *flow_next = flow->next; + err = flow_destroy_profile_inline(dev, flow, error); + flow = flow_next; + + } else { + flow = flow->next; + } + } + + return err; +} + static __rte_always_inline bool all_bits_enabled(uint64_t hash_mask, uint64_t hash_bits) { return (hash_mask & hash_bits) == hash_bits; @@ -4396,6 +4438,7 @@ static const struct profile_inline_ops ops = { .flow_destroy_locked_profile_inline = flow_destroy_locked_profile_inline, .flow_create_profile_inline = flow_create_profile_inline, .flow_destroy_profile_inline = flow_destroy_profile_inline, + .flow_flush_profile_inline = flow_flush_profile_inline, .flow_nic_set_hasher_fields_inline = flow_nic_set_hasher_fields_inline, /* * NT Flow FLM Meter API diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h index 2c76a2c023..c695842077 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.h @@ -38,6 +38,10 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); +int flow_flush_profile_inline(struct flow_eth_dev *dev, + uint16_t caller_id, + struct rte_flow_error *error); + int flow_dev_dump_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow, uint16_t caller_id, diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 5505198148..87b26bd315 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -569,6 +569,43 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, return flow; } +static int eth_flow_flush(struct rte_eth_dev *eth_dev, struct rte_flow_error *error) +{ + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + int res = 0; + /* Main application caller_id is port_id shifted above VDPA ports */ + uint16_t caller_id = get_caller_id(eth_dev->data->port_id); + + if (internals->flw_dev) { + res = flow_filter_ops->flow_flush(internals->flw_dev, caller_id, &flow_error); + rte_spinlock_lock(&flow_lock); + + for (int flow = 0; flow < MAX_RTE_FLOWS; flow++) { + if (nt_flows[flow].used && nt_flows[flow].caller_id == caller_id) { + /* Cleanup recorded flows */ + nt_flows[flow].used = 0; + nt_flows[flow].caller_id = 0; + } + } + + rte_spinlock_unlock(&flow_lock); + } + + convert_error(error, &flow_error); + + return res; +} + static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev, struct rte_flow *flow, FILE *file, @@ -600,6 +637,7 @@ static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev, static const struct rte_flow_ops dev_flow_ops = { .create = eth_flow_create, .destroy = eth_flow_destroy, + .flush = eth_flow_flush, .dev_dump = eth_flow_dev_dump, }; diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index cef655c5e0..12baa13800 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -253,6 +253,10 @@ struct profile_inline_ops { struct flow_handle *flow, struct rte_flow_error *error); + int (*flow_flush_profile_inline)(struct flow_eth_dev *dev, + uint16_t caller_id, + struct rte_flow_error *error); + int (*flow_dev_dump_profile_inline)(struct flow_eth_dev *dev, struct flow_handle *flow, uint16_t caller_id, @@ -309,6 +313,9 @@ struct flow_filter_ops { int (*flow_destroy)(struct flow_eth_dev *dev, struct flow_handle *flow, struct rte_flow_error *error); + + int (*flow_flush)(struct flow_eth_dev *dev, uint16_t caller_id, + struct rte_flow_error *error); }; void register_dev_flow_ops(const struct rte_flow_ops *ops); -- 2.45.0