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 9543945BC0; Tue, 29 Oct 2024 17:48:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2561942FCF; Tue, 29 Oct 2024 17:44:27 +0100 (CET) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 324C242ECF for ; Tue, 29 Oct 2024 17:43:35 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2106.outbound.protection.outlook.com [104.47.18.106]) by mx-outbound17-86.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kc4XgkjKtPdwQYHAkaZ8FpImIg+gekSwfGjiCdpg2nqzWKt029UG2Bf2uknDVz10TEENPNKf1ESWwnGHtJpa7d53ShuG1ul1ozx65AU4QuxN+IBazFRY9a/dKMOCCWVlFkCfH5qOjS4EHcGd1vvE2kE0kjsc+M6nRA+0tBDgjTo8cKbJDm4GKDryZFgYMziV3qM81jyCOk87aSNyCm+d/Ra2TNz6G5u1M3XCt9FyOJeSEj5RQ1jN7PZFfeJg4n3J3yAkgaiDjTGMqbtP3rs0LUFiYRweav6L1wvRZ+O7qThuBhKSdHW5KtwWCJVPu5JeKoNy/3tIMZ9ZPBzpn9Nxsg== 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=iMDWY52y96Pyh8S02wXgqTs7953c7zyRd0z1KwQ8cAw=; b=AXKVbwWHSwCdi1UqbS9yI3h0CesNjEcppM+ME4R676gR1ooATJfbEFs/VHQJNHmAjKcaY+b3fVhQGp6QAB0QSZW0XjHhLsOrE61G/0CvYHm9+kcBlrsCyElDt/0qd20MPObtFbugGfjTBWuVFx0m4Q5pMhSKIKIk1u2q4XEkOAA2+BpShxPNu3CzjSxnXwqnQmWBDA+ybps3NPP4guxTXoeiFaGkExzRjfae4iKv96U3AgnKjDLUAKtFKrButnfaBRMfsH7Ui3AVoPHn6eNKjd4TZPQjvD62pKN5jLsafbQ+MO5tCnRiT6IexlKst/6nk2da1s4p+UayKSHiw03Swg== 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=iMDWY52y96Pyh8S02wXgqTs7953c7zyRd0z1KwQ8cAw=; b=QP1FWPtM9n4LtsyI+Uea55WlzEmYyGFSbdvKIfi1mHU5rCXcTthHLaxYgBuEsVrd7gDLffPbaHGdFJlKKUbNIRqn04G6xaU4e9JdZLtYZk4ZxfrsYQHdPnVaPy1UKcPxH9SWs+LQN5bT0PRV+VWrkws4MSazyrIB7XIevEEzEjQ= Received: from DUZPR01CA0206.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::21) by AS1P190MB1773.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4a9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:30 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::fd) by DUZPR01CA0206.outlook.office365.com (2603:10a6:10:4b6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:30 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:29 +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 v4 38/86] net/ntnic: add flow flush Date: Tue, 29 Oct 2024 17:41:42 +0100 Message-ID: <20241029164243.1648775-39-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS1P190MB1773:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 56b955a0-1e17-4378-5c70-08dcf838d1cd 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?LoVrKx8cqpCgww9hLUSxnnDMohB/KhKJAutWxgxQDQ7NRbDr58qOzCW0WqJq?= =?us-ascii?Q?DqSXlPzUfX5EHEsQrjVLzKaol8y1tLQaP/AbTobjLJsfdEiM+vS07y2h1LU9?= =?us-ascii?Q?nEksGzcX3TEILDvoqjg29bDpDp1PNPYNDCtC/2kKVFo+WkqFqemBP1itQUpe?= =?us-ascii?Q?jPvm88bjucBKnW2IhDUi3f3aDqpzxBtTRUBjSOwPW0pS4SFQO3UpSsvYByej?= =?us-ascii?Q?G43v/WQvob2fT/SrFb6Lj6ynD+icFuCvK3tQRcHHP+TrIUKZ+uitqi+qyN0/?= =?us-ascii?Q?RjMISp23QNHUVnKhtC+2aJTxFRkRPlQ8QcUaCwsN9dQdQVE7Z3GIenJA8tHL?= =?us-ascii?Q?c82+ySEWyMwRZqzYub604qAy7NBXVpYnmFudGJGaju+xTZCObA6a/38V6TRL?= =?us-ascii?Q?RkgPZmYR81De735eTREzHwYJhuNFEZbS+odviwjzUIitOA2v+BzQEmhfSGaG?= =?us-ascii?Q?C5n6JKsyHM34P/g2nRXwQOk0fYOgz7XonU7ncy92qJUyEfvoGb57haaKA7QO?= =?us-ascii?Q?8k7999R3lcWerT7Leq/NuQB5DFHXI5SqTjIpER9T2b0YXYWfJavO7cw6FxiV?= =?us-ascii?Q?feQoL/Mff9S0XRFd36izyCgxcz0J2/7zcTEk4du4mO82WT3+211c4Wwvax+L?= =?us-ascii?Q?ho7QURF0a9u2lXtvn1DxsV09EY+VGpN49z+s2G5IE8Rpj7s/yora+9+YrfNe?= =?us-ascii?Q?GlANw7q42OIwVCUA3VxRzJje5IbVtFLdUUINbj0C6dwSJGFrVT2djhEdwTDb?= =?us-ascii?Q?W2XbjZNXpTHUXMEjhEbBukODNG40wLWbkx9xiWwIzhOeWhQcqQ9587dbw6x9?= =?us-ascii?Q?yhxgAdqFLnXbaOL5rGEjy09/kBGPDwmwEXI+S4c4uPeCy4sxfV8rL3lGQkuM?= =?us-ascii?Q?N2eeWUiOz3ceKzjo3VVOyoft0h6pJLLN9NV27905ps4QyIUUt4kXWYpgaE+w?= =?us-ascii?Q?nhfbGbUSVI46UJMFd1FkFae2+am6oa31Ueos4mwQAD/sRx4gv4kaNLZ+ezrt?= =?us-ascii?Q?FI8bX2yTtLqEB+v5hma3PCdG11RrV/OWUlyHhUFz5eQq/0eVqWBs9OJU84fD?= =?us-ascii?Q?qDiv6PndVv3sLhRFQAoQSX73XiKhExmsu/Smf4LiMZJSpZyZ+SLSkI5zyspv?= =?us-ascii?Q?rGkSNnYZDCErtG1Wv+OHOdWKunwyb4Nm8YabvkSpYQyF6+QNsBGWtZ2t3Dnc?= =?us-ascii?Q?jbEa5+k6qT1u2a93k+JztilCSkIQW1dlK/EgkDb1vBKdprka48xQ5OVteqIX?= =?us-ascii?Q?zA0ExDcq288SKchdmByawRccrOhsoER7ctSK18q1puD0i6MRD47HVpl+6sdO?= =?us-ascii?Q?SrsJ9jBTxoPOP967jK8sIK1YbmJ2b3DF4srlncoyk+jfuMJ2bZ3hkwkleqyM?= =?us-ascii?Q?caS4y8eCNEYmaVKyysDk0EcqxcM2p254PaxWBMnCdpZjP1UfXQ=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: 6HaeXAgY0AVXlokCXp9smMbG0LJIElscw1B+uMGrO12Rb76j6xFeVfAqSy9tJCen1jpzOYbe/tB+4J6o1AsD1LAmHuRfJ1v1UCWfBpqSTUOmGh8OFF62Ii3VMW0PVBfiGsBjCoZ4zuGlX9Gb4b54hvO1dlBcwWZMrj7wwVo93HshGsSfDy4cacNHGecyJyCNib9vaoQLUyXTyzIKwdWpj3gxy9HF0PNFlho0rQD90PtqtsHz8brIjSQOaRNhDrCkcSjtsZf+dQSvsfJ5h3HPSZudEJ+jJLBb4jc9IZhq9Sxl+/bqUcwya4svHngYhCOZBQbYUMZmKYlw1VeMOgthX/oGzeOtg2meG6bGJ2jpEMXgXnLte5C6Chcq1XmYv6iSGSZorx+9JFQ6dA8Fm+Vv+yh7JmpJ346UZpIzanpuyv+imwIpo1L4CoZLCXbsDSo06sD0rf3r3HIZx0JIgISqN2o6l9hbASdSp60Um8XzfZoIspr7rUcpUiTF4GFZ+65E5ohGeJA8Aq36toNdP8TW8AWN1lUKxEJqW0dBzbBk1ZHEoxIpbe5x8EnCQIcXDezt/Kay1NH42dmY0XcdQpdhFg2sxB7JEachClNAUU5VovZ8Hqg9KXX62dckPv0RwJAP0MzISpxrLD3kbSQ+pwWTg/LY3zPP/osLHEUEHvj+WO0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:29.8552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56b955a0-1e17-4378-5c70-08dcf838d1cd 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1P190MB1773 X-BESS-ID: 1730220212-304438-12710-30041-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaWliZAVgZQMMnUMtXELNnYwM AiNckszcTCMjnNOC3N0MDM3CI1zchMqTYWAGLc1q1BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan11-75.eu-central-1a.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 9727a28d45..af07819a0c 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 @@ -3635,6 +3635,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; @@ -4395,6 +4437,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 67a24a00f1..93d89d59f3 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -582,6 +582,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, @@ -613,6 +650,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