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 5081D45BC0; Tue, 29 Oct 2024 18:20:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 78E4B43308; Tue, 29 Oct 2024 18:18:32 +0100 (CET) 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 ADC9C42FC7 for ; Tue, 29 Oct 2024 18:18:24 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2239.outbound.protection.outlook.com [104.47.11.239]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 17:18:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BzbCZyUMuIAFfm5Tp9duuhV0E5BxEHI8/ky92Dwrqwt1AKI4lR3QhI5iqpt4Ci1fJKt3I1b6w1LA+nX1/Po8+IgR7RemBl4ExSfuRpZMCs8uWJg8Qye7na3nN4D2fIvNXo1rYeb88GQDuXGkO/7kpPBkl3nlgjotqzeZOrTcQ+LbJY6hkyBuwUAW96ywCGHI9/kHn8u3rBF40qtQyMI4rIgawCcr83ZxyaXG5TYM1tH3FSZlw/57b0St8aM32rvSaAz5kkIWeEZ2ocO93r7Ot1ff8cFRr1lH84xnPzvAvBoAm0k2rz6pE6OrRWxyDg9QN6ANXl/PALwkW47S2uUqLg== 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=+wtxSkmcEOThq9ZqHtlb0pDFUXaKoR+J0AaeKwL5jKI=; b=x9N7e0m/5hT2yGxWh+RTpcL68lA08DTWKvPjFl5r/9OPw3v+04wWMRDAF5iOqFxc9TrjKDZRE6MbJJHi+2TuI6HdYX9InzkEWeL1NmtLheNQVn4R8ZSJj6zJOQl7x0yFVEhjJemAf5YOuqTk30ty2tRiA1HkKRC+y1BeWjE/cgiaCyjhoude8b/Fsr/aoyfwnpzDAP96J6oi9zgtUYH7/nePdGG4GyiR/mS/4Fu0ZBkxmVb2GuYds+kuEwzzKmqLa+iMyVJmi8SWR62pMNg1m+t+Ff6x61JKrNEB4yBzaPzi8ng11D/4t+BM8YIwJh4SIlIIvB2uNKqIjJiOx0VZXQ== 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=+wtxSkmcEOThq9ZqHtlb0pDFUXaKoR+J0AaeKwL5jKI=; b=jXrecScuGyKF3nZ8HDMGz2HU61bwcMhS+uJR2A8p6PeLHhCwHcXUHfbX/H05QU91SGaw898x6zBdoGLqcPkWt0/c98pvyDlt8gE/RtdLf03QOT1XL/tHPRBdAiTn0mqoKs22/Tw4CgmSZGw470pLREd9jjYRVeQy6FRRExAm6zw= Received: from DUZPR01CA0195.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::26) by PA4P190MB1327.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:10d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Tue, 29 Oct 2024 16:44:13 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::df) by DUZPR01CA0195.outlook.office365.com (2603:10a6:10:4b6::26) 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:44:13 +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:44:13 +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, Danylo Vodopianov Subject: [PATCH v4 82/86] net/ntnic: add async flow create/delete API implementation Date: Tue, 29 Oct 2024 17:42:26 +0100 Message-ID: <20241029164243.1648775-83-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_|PA4P190MB1327:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d0b3929c-a530-4605-2bea-08dcf838ebb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Ojaqsvc0tRrqIieLT27SHRdTf4fkFad+2UBiSnvUJ7oxBPoqhyqiMbkFimUM?= =?us-ascii?Q?YZkPFxCkjU6mh4CUEN7AB+A+MK26WGUK3HCg7IXILYRwmH5nh81SfVHTT7QO?= =?us-ascii?Q?y5P8zyIinScb/qWCQpiqHXtIKryV43pv2RmUCPTVjfFv+fMXnADnH/QA9tnn?= =?us-ascii?Q?Ta8vSY+rIbUEWtrtbXyFKeduSvZN2shgOudspXczCNKhgPeGTd4/qY0S1kTT?= =?us-ascii?Q?PppfQZ90PfwsYgH8U1mFoWTKrjzDdwStF7p7DxW56NICwlJ7gmDb6Hb6EOLy?= =?us-ascii?Q?FINY+fgPZPzFXZEV0FxPa/rR3+XDUE+39TLYW+EP6zc/Br8mAOJ4Ptzt7GL5?= =?us-ascii?Q?DUKNHk4O9EKbjBCopnUWxc9c8bg3VeKEVIF6DKZYctiCgqahrNj/k/xkYIuH?= =?us-ascii?Q?DVbtrC3e1+EvQUkzg/j9ANitltFMgu994gS4XJxEIewaeNRmMR3UA3pCaX+H?= =?us-ascii?Q?hSUtjRGwW8y0rrpKtjUOtyWTPCYWfCyGW9WCU3Cb5pQTJNWOVLE7a7ctW+3J?= =?us-ascii?Q?9Vm8nNIEq9xpdqiaibO8wP4lo76RkK3pRGumdUUbC9u+YQ0V9OZZ01qTql+z?= =?us-ascii?Q?XJcCyqFlkvcjlHi00peOEhdNoaP0EZCCxkyq7AQQrhOMwaQqjPSFgDHw+apF?= =?us-ascii?Q?VNRlEyPn5g0uyfrOOvNRf/Up9zbe8TXsBt03THaXk5vLZNCEqMj/4UfTYHqV?= =?us-ascii?Q?PBpdXRs4ggQsBLao5jzJp/M11Q5ljeU0LpMsj64hK5YBCsV6xun/uPdRTW4G?= =?us-ascii?Q?06TS7mDJqWlieUMn4EG8Jyg9Xi1aPfWhEAvXF1I1xvvLYv5c/TV62q6IyN5d?= =?us-ascii?Q?gz7lKAgX+IL08aSDswchOlXS6+G8xWJdSw3AivvLXVpYw0HYnvTBR91+c97r?= =?us-ascii?Q?YwKubK3PT8fJ/0RM7x1QZheiFQ7/40B70eWZRtdR1O0p/XugDQvsMwzPYPu2?= =?us-ascii?Q?vbCD6iKSJoZNf5Vce30clXWLc1+HA4F+NvTAMpHXs9PxWzwMKaRG7kh//3qn?= =?us-ascii?Q?weWfdXbf2ciwQVFMgY58ZHiN5feVLPvFSNXxGg+PNZ3otEAjb1jpvtqcwj+7?= =?us-ascii?Q?ZCnZOxFBR0gSq/4YKA5xVMtqAgY4qXYC6nl8IIdWrFnNQ5d5i/9V6teN9eO8?= =?us-ascii?Q?XKgQo6gbt6PJaePtjwp/424+oCjprpFN8kgGIDN1ALBJnoN1mPWGP3sjmGGP?= =?us-ascii?Q?XOW7aZKsm1cORWXPKM9hAD+6a03f3WCnoFq7Cjsq7y5j2BbxObdUg+KtO82L?= =?us-ascii?Q?4bXTtY10DckxgRQXjM+JUSTuBzNq5k+UbJ0Nm3QX2iiHjG46DxmSavZ5w6jX?= =?us-ascii?Q?6RfQM3PTND3+cqC4jkQkpgVCr639GAGOcTe3dWfx9e1LlOBhwnmZSPs7kak+?= =?us-ascii?Q?YSw8E3BeDwXT8b+15nTizB6QPdb4fo47VyDZC65T6iquHDKyZA=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)(82310400026)(36860700013)(1800799024)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rHew8Be2Yg77yelCxHJFJuIlx7+fayIbvMuLaxCemAA3A8pEhJuK3OoNGdW7epcYsNQOM54DWBI+jzqZTsPFt62ZELToYEVIXeFOcg14PkShUDAAsueP4VA8+XIpnwQDCh5x27nTDNQwWr9BgSxQQM6KqRoC7zRQRBmP3Cm4r5Nkaraw6/qNFFKI+TnAckowsxOGY0jiJjtSKX2QMrn/AfQjw5X949ByioiUh9t8nDbgv9/vuaMvSr6H2bgLyMiGvVsYdmO7ui1nLTAu6khOOPqL6ncVjI9VNzUeunnnjQXKuf/ZY0wxqR/5zX/VvpNcz7S0YQRq+R6Tr83p2AoexVHpHs0i7qf9Wfbz8m/+i9MNl/M5ujDdnDKpmKEVXcNUaJhZZZleiNZsKQTtmvUU1fbCYbPRUimBjR1dtaP+ZU/OF5f7YB6ChK2zdhM0HGNv9KaP4opJw6ATQZvVXunz0hoc+8JhhrunJAX8KBSaSv54g8p4ffkBHVP/dU2JuEYpsWeT9Im2wRrcpEtSHsYWuXRtdrqvaK6BuiBI9V7LJpqFj61vxupWwzlnH9Gcm4s/3f1dF4cOjaW7lEWaXAVUpXlDOUtD1rfFe4wcQ37nV8+HibJ6Pv4wHjihSh7k4XMxEsZHv9QpMpcz6XwWqfKoksjrGbfYlJFa1Blq9E5xk50= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:44:13.3084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0b3929c-a530-4605-2bea-08dcf838ebb6 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: PA4P190MB1327 X-OriginatorOrg: napatech.com X-BESS-ID: 1730222301-311207-12668-29690-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.239 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobmZoYGQGYGUDQpKcXY1CLROM nIwDApydzS3NjY1NIsMdUoOcU42cQiSak2FgA7rmEqQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260064 [from cloudscan15-168.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: Danylo Vodopianov Inline profile was extended with async flow create and delete features implementation. async & destroy API was added to the flow filter ops. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/flow_api_engine.h | 36 +++ drivers/net/ntnic/nthw/flow_api/flow_api.c | 39 +++ .../profile_inline/flow_api_hw_db_inline.c | 13 + .../profile_inline/flow_api_hw_db_inline.h | 2 + .../profile_inline/flow_api_profile_inline.c | 248 +++++++++++++++++- .../profile_inline/flow_api_profile_inline.h | 14 + drivers/net/ntnic/ntnic_mod_reg.h | 15 ++ 7 files changed, 366 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 505fb8e501..6935ff483a 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -339,6 +339,12 @@ struct flow_handle { uint8_t flm_rqi; uint8_t flm_qfi; uint8_t flm_scrub_prof; + + /* Flow specific pointer to application template table cell stored during + * flow create. + */ + struct flow_template_table_cell *template_table_cell; + bool flm_async; }; }; }; @@ -347,8 +353,38 @@ struct flow_pattern_template { }; struct flow_actions_template { + struct nic_flow_def *fd; + + uint32_t num_dest_port; + uint32_t num_queues; }; + +struct flow_template_table_cell { + atomic_int status; + atomic_int counter; + + uint32_t flm_db_idx_counter; + uint32_t flm_db_idxs[RES_COUNT]; + + uint32_t flm_key_id; + uint32_t flm_ft; + + uint16_t flm_rpl_ext_ptr; + uint8_t flm_scrub_prof; +}; + struct flow_template_table { + struct flow_pattern_template **pattern_templates; + uint8_t nb_pattern_templates; + + struct flow_actions_template **actions_templates; + uint8_t nb_actions_templates; + + struct flow_template_table_cell *pattern_action_pairs; + + struct rte_flow_attr attr; + uint16_t forced_vlan_vid; + uint16_t caller_id; }; void km_attach_ndev_resource_management(struct km_flow_def_s *km, void **handle); diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 9689aece58..420f081178 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1115,6 +1115,43 @@ static int flow_configure(struct flow_eth_dev *dev, uint8_t caller_id, nb_queue, queue_attr, error); } +/* + * Flow Asynchronous operation API + */ + +static struct flow_handle * +flow_async_create(struct flow_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, struct flow_template_table *template_table, + const struct rte_flow_item pattern[], uint8_t pattern_template_index, + const struct rte_flow_action actions[], uint8_t actions_template_index, void *user_data, + 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 NULL; + } + + return profile_inline_ops->flow_async_create_profile_inline(dev, queue_id, op_attr, + template_table, pattern, pattern_template_index, actions, + actions_template_index, user_data, error); +} + +static int flow_async_destroy(struct flow_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, struct flow_handle *flow, + void *user_data, 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_async_destroy_profile_inline(dev, queue_id, op_attr, flow, + user_data, error); +} int flow_get_flm_stats(struct flow_nic_dev *ndev, uint64_t *data, uint64_t size) { const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); @@ -1151,6 +1188,8 @@ static const struct flow_filter_ops ops = { */ .flow_info_get = flow_info_get, .flow_configure = flow_configure, + .flow_async_create = flow_async_create, + .flow_async_destroy = flow_async_destroy, /* * Other diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 2fee6ae6b5..ffab643f56 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -393,6 +393,19 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct } } +struct hw_db_idx *hw_db_inline_find_idx(struct flow_nic_dev *ndev, void *db_handle, + enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size) +{ + (void)ndev; + (void)db_handle; + for (uint32_t i = 0; i < size; ++i) { + if (idxs[i].type == type) + return &idxs[i]; + } + + return NULL; +} + void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_idx *idxs, uint32_t size, FILE *file) { diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index c920d36cfd..aa046b68a7 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -287,6 +287,8 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct uint32_t size); const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size); +struct hw_db_idx *hw_db_inline_find_idx(struct flow_nic_dev *ndev, void *db_handle, + enum hw_db_idx_type type, struct hw_db_idx *idxs, uint32_t size); void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_idx *idxs, uint32_t size, FILE *file); void hw_db_inline_dump_cfn(struct flow_nic_dev *ndev, void *db_handle, FILE *file); 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 9c554ee7e2..d97206614b 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 @@ -3,7 +3,6 @@ * Copyright(c) 2023 Napatech A/S */ -#include "generic/rte_spinlock.h" #include "ntlog.h" #include "nt_util.h" @@ -64,6 +63,11 @@ #define POLICING_PARAMETER_OFFSET 4096 #define SIZE_CONVERTER 1099.511627776 +#define CELL_STATUS_UNINITIALIZED 0 +#define CELL_STATUS_INITIALIZING 1 +#define CELL_STATUS_INITIALIZED_TYPE_FLOW 2 +#define CELL_STATUS_INITIALIZED_TYPE_FLM 3 + struct flm_mtr_stat_s { struct dual_buckets_s *buckets; atomic_uint_fast64_t n_pkt; @@ -1034,6 +1038,17 @@ static int flm_flow_programming(struct flow_handle *fh, uint32_t flm_op) return 0; } +static inline const void *memcpy_or(void *dest, const void *src, size_t count) +{ + unsigned char *dest_ptr = (unsigned char *)dest; + const unsigned char *src_ptr = (const unsigned char *)src; + + for (size_t i = 0; i < count; ++i) + dest_ptr[i] |= src_ptr[i]; + + return dest; +} + /* * This function must be callable without locking any mutexes */ @@ -4345,6 +4360,9 @@ int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *fl { int err = 0; + if (flow && flow->type == FLOW_HANDLE_TYPE_FLM && flow->flm_async) + return flow_async_destroy_profile_inline(dev, 0, NULL, flow, NULL, error); + flow_nic_set_error(ERR_SUCCESS, error); if (flow) { @@ -5489,6 +5507,232 @@ int flow_configure_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id, return -1; } +struct flow_handle *flow_async_create_profile_inline(struct flow_eth_dev *dev, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct flow_template_table *template_table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error) +{ + (void)queue_id; + (void)op_attr; + struct flow_handle *fh = NULL; + int res, status; + + const uint32_t pattern_action_index = + (uint32_t)template_table->nb_actions_templates * pattern_template_index + + actions_template_index; + struct flow_template_table_cell *pattern_action_pair = + &template_table->pattern_action_pairs[pattern_action_index]; + + uint32_t num_dest_port = + template_table->actions_templates[actions_template_index]->num_dest_port; + uint32_t num_queues = + template_table->actions_templates[actions_template_index]->num_queues; + + uint32_t port_id = UINT32_MAX; + uint32_t packet_data[10]; + uint32_t packet_mask[10]; + struct flm_flow_key_def_s key_def; + + flow_nic_set_error(ERR_SUCCESS, error); + + struct nic_flow_def *fd = malloc(sizeof(struct nic_flow_def)); + + if (fd == NULL) { + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + error->message = "Failed to allocate flow_def"; + goto err_exit; + } + + memcpy(fd, template_table->actions_templates[actions_template_index]->fd, + sizeof(struct nic_flow_def)); + + res = interpret_flow_elements(dev, pattern, fd, error, + template_table->forced_vlan_vid, &port_id, packet_data, + packet_mask, &key_def); + + if (res) + goto err_exit; + + if (port_id == UINT32_MAX) + port_id = dev->port_id; + + { + uint32_t num_dest_port_tmp = 0; + uint32_t num_queues_tmp = 0; + + struct nic_flow_def action_fd = { 0 }; + prepare_nic_flow_def(&action_fd); + + res = interpret_flow_actions(dev, actions, NULL, &action_fd, error, + &num_dest_port_tmp, &num_queues_tmp); + + if (res) + goto err_exit; + + /* Copy FLM unique actions: modify_field, meter, encap/decap and age */ + memcpy_or(fd->mtr_ids, action_fd.mtr_ids, sizeof(action_fd.mtr_ids)); + memcpy_or(&fd->tun_hdr, &action_fd.tun_hdr, sizeof(struct tunnel_header_s)); + memcpy_or(fd->modify_field, action_fd.modify_field, + sizeof(action_fd.modify_field)); + fd->modify_field_count = action_fd.modify_field_count; + memcpy_or(&fd->age, &action_fd.age, sizeof(struct rte_flow_action_age)); + } + + status = atomic_load(&pattern_action_pair->status); + + /* Initializing template entry */ + if (status < CELL_STATUS_INITIALIZED_TYPE_FLOW) { + if (status == CELL_STATUS_UNINITIALIZED && + atomic_compare_exchange_strong(&pattern_action_pair->status, &status, + CELL_STATUS_INITIALIZING)) { + rte_spinlock_lock(&dev->ndev->mtx); + + fh = create_flow_filter(dev, fd, &template_table->attr, + template_table->forced_vlan_vid, template_table->caller_id, + error, port_id, num_dest_port, num_queues, packet_data, + packet_mask, &key_def); + + rte_spinlock_unlock(&dev->ndev->mtx); + + if (fh == NULL) { + /* reset status to CELL_STATUS_UNINITIALIZED to avoid a deadlock */ + atomic_store(&pattern_action_pair->status, + CELL_STATUS_UNINITIALIZED); + goto err_exit; + } + + if (fh->type == FLOW_HANDLE_TYPE_FLM) { + rte_spinlock_lock(&dev->ndev->mtx); + + struct hw_db_idx *flm_ft_idx = + hw_db_inline_find_idx(dev->ndev, dev->ndev->hw_db_handle, + HW_DB_IDX_TYPE_FLM_FT, + (struct hw_db_idx *)fh->flm_db_idxs, + fh->flm_db_idx_counter); + + rte_spinlock_unlock(&dev->ndev->mtx); + + pattern_action_pair->flm_db_idx_counter = fh->flm_db_idx_counter; + memcpy(pattern_action_pair->flm_db_idxs, fh->flm_db_idxs, + sizeof(struct hw_db_idx) * fh->flm_db_idx_counter); + + pattern_action_pair->flm_key_id = fh->flm_kid; + pattern_action_pair->flm_ft = flm_ft_idx->id1; + + pattern_action_pair->flm_rpl_ext_ptr = fh->flm_rpl_ext_ptr; + pattern_action_pair->flm_scrub_prof = fh->flm_scrub_prof; + + atomic_store(&pattern_action_pair->status, + CELL_STATUS_INITIALIZED_TYPE_FLM); + + /* increment template table cell reference */ + atomic_fetch_add(&pattern_action_pair->counter, 1); + fh->template_table_cell = pattern_action_pair; + fh->flm_async = true; + + } else { + atomic_store(&pattern_action_pair->status, + CELL_STATUS_INITIALIZED_TYPE_FLOW); + } + + } else { + do { + nt_os_wait_usec(1); + status = atomic_load(&pattern_action_pair->status); + } while (status == CELL_STATUS_INITIALIZING); + + /* error handling in case that create_flow_filter() will fail in the other + * thread + */ + if (status == CELL_STATUS_UNINITIALIZED) + goto err_exit; + } + } + + /* FLM learn */ + if (fh == NULL && status == CELL_STATUS_INITIALIZED_TYPE_FLM) { + fh = calloc(1, sizeof(struct flow_handle)); + + fh->type = FLOW_HANDLE_TYPE_FLM; + fh->dev = dev; + fh->caller_id = template_table->caller_id; + fh->user_data = user_data; + + copy_fd_to_fh_flm(fh, fd, packet_data, pattern_action_pair->flm_key_id, + pattern_action_pair->flm_ft, + pattern_action_pair->flm_rpl_ext_ptr, + pattern_action_pair->flm_scrub_prof, + template_table->attr.priority & 0x3); + + free(fd); + + flm_flow_programming(fh, NT_FLM_OP_LEARN); + + nic_insert_flow_flm(dev->ndev, fh); + + /* increment template table cell reference */ + atomic_fetch_add(&pattern_action_pair->counter, 1); + fh->template_table_cell = pattern_action_pair; + fh->flm_async = true; + + } else if (fh == NULL) { + rte_spinlock_lock(&dev->ndev->mtx); + + fh = create_flow_filter(dev, fd, &template_table->attr, + template_table->forced_vlan_vid, template_table->caller_id, + error, port_id, num_dest_port, num_queues, packet_data, + packet_mask, &key_def); + + rte_spinlock_unlock(&dev->ndev->mtx); + + if (fh == NULL) + goto err_exit; + } + + if (fh) { + fh->caller_id = template_table->caller_id; + fh->user_data = user_data; + } + + return fh; + +err_exit: + free(fd); + free(fh); + + return NULL; +} + +int flow_async_destroy_profile_inline(struct flow_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, struct flow_handle *flow, + void *user_data, struct rte_flow_error *error) +{ + (void)queue_id; + (void)op_attr; + (void)user_data; + + if (flow->type == FLOW_HANDLE_TYPE_FLOW) + return flow_destroy_profile_inline(dev, flow, error); + + if (flm_flow_programming(flow, NT_FLM_OP_UNLEARN)) { + NT_LOG(ERR, FILTER, "FAILED to destroy flow: %p", flow); + flow_nic_set_error(ERR_REMOVE_FLOW_FAILED, error); + return -1; + } + + nic_remove_flow_flm(dev->ndev, flow); + + free(flow); + + return 0; +} + static const struct profile_inline_ops ops = { /* * Management @@ -5513,6 +5757,8 @@ static const struct profile_inline_ops ops = { .flow_get_flm_stats_profile_inline = flow_get_flm_stats_profile_inline, .flow_info_get_profile_inline = flow_info_get_profile_inline, .flow_configure_profile_inline = flow_configure_profile_inline, + .flow_async_create_profile_inline = flow_async_create_profile_inline, + .flow_async_destroy_profile_inline = flow_async_destroy_profile_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 8a03be1ab7..b548142342 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 @@ -69,6 +69,20 @@ int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int flow_get_flm_stats_profile_inline(struct flow_nic_dev *ndev, uint64_t *data, uint64_t size); +/* + * RTE flow asynchronous operations functions + */ + +struct flow_handle *flow_async_create_profile_inline(struct flow_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct flow_template_table *template_table, const struct rte_flow_item pattern[], + uint8_t pattern_template_index, const struct rte_flow_action actions[], + uint8_t actions_template_index, void *user_data, struct rte_flow_error *error); + +int flow_async_destroy_profile_inline(struct flow_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, struct flow_handle *flow, + void *user_data, struct rte_flow_error *error); + int flow_info_get_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id, struct rte_flow_port_info *port_info, struct rte_flow_queue_info *queue_info, struct rte_flow_error *error); diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 92856b81d5..e8e7090661 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -310,6 +310,21 @@ struct profile_inline_ops { uint32_t nb_contexts, struct rte_flow_error *error); + /* + * RTE flow asynchronous operations functions + */ + + struct flow_handle *(*flow_async_create_profile_inline)(struct flow_eth_dev *dev, + uint32_t queue_id, const struct rte_flow_op_attr *op_attr, + struct flow_template_table *template_table, const struct rte_flow_item pattern[], + uint8_t rte_pattern_template_index, const struct rte_flow_action actions[], + uint8_t rte_actions_template_index, void *user_data, struct rte_flow_error *error); + + int (*flow_async_destroy_profile_inline)(struct flow_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct flow_handle *flow, void *user_data, + struct rte_flow_error *error); + int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); -- 2.45.0