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 5414E45BCC; Thu, 31 Oct 2024 00:14:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 212C343516; Thu, 31 Oct 2024 00:14:23 +0100 (CET) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 2B9144350E for ; Thu, 31 Oct 2024 00:14:22 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 23:14:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LSRymPejJ9fu56TpLo6pYo4dt+G/y5O2MF8eOZg7H+UZnn/n3BfjZy9vIzQyVCpg/bsH3npLSyQo0FWPyWcBRCwIUXk0CI1EP7tErGx53cS1Kc5wk5is/Bn+j1qHXlTRNJdJBpfJJ1FoILoHOJybjUdVJoVt3q3bJ5he4SabkHN2lBid7BaDK759pCc77izlTr8v+fSAdgmhCvvCl4L+n7O2jBGcNDwpEYwNkBPMUn2LINwXjPIDbxfsBZRC0Eq/wz24c17G8ETFoyJQ19j1SdUswJ4sGG6tOX37QhqppLzq2wsFOyEafBQDgCclif1a3593pvPqXoT+A5wC43hikQ== 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=u1+lqyF2TYSDFxmtI5VquH0j8TAKCcEQZC/u8yx7VJ4=; b=YWd9COyjRdpY+uSF/IO6TIpeExV+ZAYASgI2qwoc2d0byIMZLYPDX63Zl/SElFRNXaTjTixkxg/PLn69IiRe2LChQGZhtuQaEAUaKmDgmAf8qjNfzwSZQpYwQCHowV/ehVqgHnVvna7W+hWVXkyBLUjbLbEd1hijuUQya7n6Yi4xHzHjG6rnNeGZ0cQqB4CB/wU/gnj2WUE+Ru2OKG0PlFrIsN0EXGIJsm7DaFeP7idIJLqwf/vm+RZG79/vJzT2AJZFLrTG9zvQtUL7t5lSfjH2IbQYw1D+Ebzr+2hBifxb1tJ4MwuEFtIOya0qymgQ/4tNbfbSjueSqdIPbxOsHQ== 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=u1+lqyF2TYSDFxmtI5VquH0j8TAKCcEQZC/u8yx7VJ4=; b=D1uGCvGlfAjI5hLrWfqfNMJ4Wf60DdY3GU6VaZTgTKgBSbjNGc77aGY8wuvE971USMhFn1vLhOiMr0uLoAeBoPTXb1HuYORK+TFWI57OyVDVVGdY+IqIKXLEamX1ApFTu63sEZ/lrnGbK1zdBTJ/07IifNb1p524nQZLSAx+/bU= Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by DB8P190MB0667.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:12c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.18; Wed, 30 Oct 2024 21:41:09 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::87) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:41:09 +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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:41:09 +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 v5 78/80] net/ntnic: add async flow create/delete implementation Date: Wed, 30 Oct 2024 22:39:25 +0100 Message-ID: <20241030213940.3470062-79-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DB8P190MB0667:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: a820945c-73d0-4d7c-9d4b-08dcf92b914d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bOns7UahI1iAzPRgE2Dng2r5cQ6EteQIMwAsvt7TSGjkJSEvn7vnCXZTj0bq?= =?us-ascii?Q?8WTbK/+i1bZ/GqSRhtbOVQhh9sg8zXGV2HQHQcu4SyefUj/zwCttDZSJlNH0?= =?us-ascii?Q?ldMEaU6JGIzDugMmiOv18EZAdQj2atEZ3ditWZbd9sQPSYELAuX4kT3f6jID?= =?us-ascii?Q?i3yLYetFiItLYiTsPjgIerpf8hXk2aqoIznIsDd3biN8ooADCC1SnlWRLY+Z?= =?us-ascii?Q?Q/Dl47Am0B2YY4UUKbu7XRAHfh0Kl31C9wTnNeddvX4x33CZ4lJugHqfdWpt?= =?us-ascii?Q?NroW/uTh7CEMELv5NXo8cB7kRM7S7ORH2WPUAi902ZjUbTOe2UzW/7CxxaQk?= =?us-ascii?Q?jtsoXpq0gcnNF3THc0I7gajql4Yj7cnShPsa1mupqaqtvHedjrU2U3UiGDnF?= =?us-ascii?Q?iC01uVHEaJ1q69KHOSuH/7zKzvaP+9Jj415GL7l+3RXdZgeurxVgJBr8+k2c?= =?us-ascii?Q?2Ns5u2t7TSbLWpHDMRnLSSLZtJpRPffNg6JouApGyZdmjOb7f4JRIsAkeFkI?= =?us-ascii?Q?db3Oz0jcG26lYFlD+E5V8k6nl0jvI/FpIff14JFXbl4dkHPZw1ltpUVFon5n?= =?us-ascii?Q?6g6rQoYBYzXnSkCIpcInuHI5lYlwInrfiu6e7buVfAVGix2NebEdyriaUCga?= =?us-ascii?Q?wpc4hYGCDpSrm7lly9CLg179+z5+C9S+R18IqHHnAJhM1FGGBFXqfsbBkN8n?= =?us-ascii?Q?lR5lUh5NZSlu6EJ4oMo99bG/gsMuJA1phlJxPajSVNhc0yH6WBYu0Y/0ZFmb?= =?us-ascii?Q?U081uDJG5whVyzlcjo2ohBD5LpoXgh5c/UUyV3pALIAns6vYYL08p3s/HHuu?= =?us-ascii?Q?0N9bGyYGYANYsgNRJIyRmGgd8fu2iCogDIyGexmh7Mxcm/mFcoR5JVmzf/06?= =?us-ascii?Q?5+ASTIvHNDstpfGIcteJfXw87qhqS9jK0sCMyr3WBqseUrQL5iOi6svOr+Rf?= =?us-ascii?Q?K97g9r9l1hQyQkGZfG8HKG7y7L4IdSdiegMENr/di0wLV0Zl3MEKPx/oIMqZ?= =?us-ascii?Q?enffcXZUGi97GGOClUK69d01pKblVwitSQkeZWgYkFNZ8dhf5TOyrqnDPfkN?= =?us-ascii?Q?/FVKrSxC0cNEhWUi31Hr6LkMr/npdL9dCYjyy0RGSV2kYcHt/p3pxbjAYd+L?= =?us-ascii?Q?rlTSHZhToHGUMnc4f8iwtwvsPK7iraROnudxiqKbbhek3bMJ7r9fKzCF0nUx?= =?us-ascii?Q?oQbd8vsKFLdLjLsvOQEZ71DR0O9c8FwCQzMw72+EkCGK+Y5AcZQrXwAr4DPK?= =?us-ascii?Q?gdOrpktTKuhdLvJNOYi4QPiceZgmfXDvg0dg8qJnvGmE6QoSbttya1BZq4hA?= =?us-ascii?Q?1dLBnkw3CQt7iLaYszukuHGZViJ489Sc4do4bcx6wroaoXDyjQlLscIu3E38?= =?us-ascii?Q?KtfRiH6AeMCANweGpHw9GRPXtdAGqiuBiUAk3F4s3j22B/Nnnw=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)(376014)(36860700013)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zsMlP4ZcxKFrRPyhfCTixkSsr4vdfdMS6CZtbgaYBJmaktnXgqbdQjYaGQOGIrst+A1qiQUln2JriAaGooRZc0pytC4k04cueTWrorKq9KrVt7rFBmnRPceNSyjkyCIvR6euX7JKOUrSKm5E4BOvlA0ga0cvsb+hxUYyyUf/obYUOOXPSH7QYGy8EL8OwcuwGdh49kZ8ztGZkH1U4WlRwLboqFjO/BkDDX1vYyOCd6ybNibyB+V6hdthGI5Mv4ww7zDo55ccu5eKfbtLosuGTkDTGisfyZn4nB/bCeSyUZ+LjVwVAcVY2Mm/B86DOudxW7KIFkSosCM4gup9C9FtY2sfSk40VGZedd+MJCIGmXPOQb4wDQ0Hb72oEzF6l5bTmtCWwHrJw1uWabxfY1+bZ8ezhLk+dnMTNykco4nhk7/8qwo6ACzEMf9J2sg13pCxRXp0k6B4Fec+hXrMXcX06mfUrIqLHsEcunNgygPcVV9mYupkGYpT99NwifKaA9/Iq5rJBWYLGPcdlo7cl6BBVjW2GSWeKWrki8qt7oTChvfSi4Kb8NlDFbUmwPTgSIqx7mfCfmCtJYXzU7wt6VX9+L1a1c4fHjbPFD5d1C1dj/U4QMiEc2+sCGSjpZXlLfmMXOJQ47oYrD/V4ut9N6E1jl1QRTKk1Qu2/OjTusuLuRc= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:41:09.3491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a820945c-73d0-4d7c-9d4b-08dcf92b914d 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: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P190MB0667 X-OriginatorOrg: napatech.com X-BESS-ID: 1730330059-302901-12792-46844-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWpuaWQGYGUNTI1Cg1OcnMID nJODHFyMwiyTgp2cLCyNjAItkszdw8Tak2FgD955lXQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260092 [from cloudscan16-249.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: Danylo Vodopianov Inline profile was extended with async flow create and delete features implementation. async create and destroy was added to the flow filter ops. Signed-off-by: Danylo Vodopianov --- doc/guides/nics/ntnic.rst | 1 + doc/guides/rel_notes/release_24_11.rst | 1 + 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 ++ 9 files changed, 368 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index afdaf22e0b..fa6cd2b95c 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -70,6 +70,7 @@ Features - Flow aging support - Flow metering, including meter policy API. - Flow update. Update of the action list for specific flow +- Asynchronous flow support Limitations ~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 735a295f6e..13f7dada4b 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -167,6 +167,7 @@ New Features * Added age rte flow action support * Added meter flow metering and flow policy support * Added flow actions update support + * Added asynchronous flow support * **Added cryptodev queue pair reset support.** 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 ef8caefd9a..884a59a5de 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1077,6 +1077,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(); @@ -1113,6 +1150,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 f9133ad802..5d1244bddf 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 */ @@ -4341,6 +4356,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) { @@ -5485,6 +5503,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 @@ -5509,6 +5753,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