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 2094F45BC0; Tue, 29 Oct 2024 18:20:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9AEC4327F; Tue, 29 Oct 2024 18:18:25 +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 B199642FC7 for ; Tue, 29 Oct 2024 18:18:23 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2112.outbound.protection.outlook.com [104.47.18.112]) 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:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qOH8pLIl/vwUEPhRVJqNK93atZRbphvaGzgZ80nEMK206aJhiiw8pw/S9m0eMv8F0buSzw7HTkWgaB4ExHSCChMF/e1KioCMagIROkdsuildtcZFSHehdDl+nntFWHtKIfMqPNAJDevmxrddfn5hEHfYNfGduWCWHzSpVmPpcg5KvR/xqUEzhB6/D4nvEnGG3U73c0uQsTA5Vfbk3icJ9NKE9uoUMv5XvabayDO5T8F7EeuW2go3FNLd9ml34CCqbGk1u5iQDSrnJHkmNvi+PbzvvRw/Kf+vIS88YXxUAShTZN938HNfc7V+5ljTro0S6hvf08DidtNEmP9NrFZUFg== 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=NQN833FkBADCSxu2AJJnjLnHhrUCvOboP4Av8JMbFOQ=; b=pPTcnmK6R63ITTOqhzyP1dCUhmWQGrqZxbjKkXWFW2l8MU2If7STUz9viW0q5OG65bXfDzy1cPJBZKKT0mIlou4xRKMnJJMYlANpNZ1xRBfIinOJUVx3uZuSlmCxuBe4jGBCf5Md2Ksu4ls6p8tWszv7lvPI19DpNI9UHha3c3UMYKwQP87mxU79d1n0+a/6959WOgNQE8xAZRMA1Z3G3AJoHJl10+/XiddymK7ffvi4CzmzuM6hQArhcxmbwRFIr3R4wk1KpNNJRkA7gQI1H8Cpfy7cb+ihQZGrsPpLJPuCLTlbWQLdQadL4dr/Ip/84uPqymNvXZFXZ+Ikmh66lA== 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=NQN833FkBADCSxu2AJJnjLnHhrUCvOboP4Av8JMbFOQ=; b=g54CaI0KOSX3wLKxoDqk9if2M62TBT+dhJTzX+dmIjw/XwTHKayEWKqeSqZ6EqyWfF3sG95ncKnnJ4vsJcK8JTXU3Uzcp5Ex+7QVxVJXM5YE/7cgEHiCLmyHsUqKA+2Z2A2GaBwbaCG0vBinO1rnKf/r41qWv+lFa5JG5nlWBfk= Received: from DUZPR01CA0202.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::13) by GV1P190MB2020.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:5c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Tue, 29 Oct 2024 16:44:14 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::be) by DUZPR01CA0202.outlook.office365.com (2603:10a6:10:4b6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Tue, 29 Oct 2024 16:44:14 +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:14 +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 83/86] net/ntnic: add async template APIs implementation Date: Tue, 29 Oct 2024 17:42:27 +0100 Message-ID: <20241029164243.1648775-84-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_|GV1P190MB2020:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ce3d8071-1f7b-40fe-395d-08dcf838ec45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WNdMdd51je3Ept2HZnCRB1k9ONMDWCGpTtKXIp7u5XpRLHEXKJBuam1BSfIe?= =?us-ascii?Q?z/TsaVnFiLFfPbwOlIjOOQGjMwOVO3ztQagCwnXUQkrpDy4px8Ndf8gC/NaZ?= =?us-ascii?Q?bAyVBH2tcQhu3qr4mTtEJy9UtO+IlGIakya1MpqO0Q6XMutzNyooo+4fisbo?= =?us-ascii?Q?FpAP1e2/ejEHzdVNN8nf8UnHGpjFrJm0vqd2EYdGPM0tmAGHQQGK90qDZ/VO?= =?us-ascii?Q?NBCYjXOpYn8q+SeerEHtwTDUvj3ESXJXou4JmmbtAdXjx2fRFN3NxxC9DVHU?= =?us-ascii?Q?3ode0y2vYsYorsPBIM0A1Xu7XrSEDlnOG70u2YSmy+XwnAS/8G2bjQtzJedr?= =?us-ascii?Q?GMj+M5BzXzVOyydFT7yIFLYZWw35tOGdNxRff3lZiAzqYYSOgsA0XbbG9mXK?= =?us-ascii?Q?wvOh/HmzyP7cqhEP5KYYfAcKFPYbHBT8ulLMdz01qoqETJC5ZvYsnS4uA9Db?= =?us-ascii?Q?zwRVZefSDm45vaysVZa5728cJDLC9gi9KaxDXfnnaj1fgWi/znHh3sWI9wDK?= =?us-ascii?Q?SOG8v0WbrXvRIrGF4t+X5qx6l7D/hjDOagJMKRrSLmwCpAAVxMY+jjwS22Ro?= =?us-ascii?Q?1Aga2U8gDBcnf0AoHvjK/IY0IM6LkrcgYBhspMSmVirYdIEhwfKYwg0MdZO5?= =?us-ascii?Q?7dcuch7nu1TwZ0ifkC4S9xLuBQ/ojI/kyejvIL4eyFPNo0TaAFV+QJ9T/Z8L?= =?us-ascii?Q?9GB4ABGi5An4PmrhgftHtEb+CCq2ROPiqkSdH0UfiHbcR2QJjgBLDDWsSWft?= =?us-ascii?Q?yODT5rGgHOtSpkjkBRN/fHkByntBRog4YMl3E+2uehmdS7BOfx2RrvjFqUJb?= =?us-ascii?Q?1i68ETrtDmqVND28owlLX9yz0dm4o7r+5Dtl0zIhOSyKtFLNnAsA9ZkNJDck?= =?us-ascii?Q?sWIWnlX0hFpHIv49c9TyALPI5b3wVNV66r+wA8kRw8BNsQqCVWMEfR/W24p5?= =?us-ascii?Q?oSEbRW89dF057ibjaZX2dtceHrkuzfVOuzmq02dffc2k0wQup3DnMUEo0WJM?= =?us-ascii?Q?bL7oNJr3zMQLUENMeJqR6u3ozO+vpGLKnLL+xBjAx+0oP/cvKQvgA4WenXmz?= =?us-ascii?Q?pPcBwLG9heDtZ4tjrS7yrNg3drGLjTDRKxfLXT15e42Gk9CUDN7FzCSd2U98?= =?us-ascii?Q?K05CAtz3BNxgoe0FwkMZnKpdG0pCGBfrnCdUpoypQEWjgp6vnFiBwA5EEj77?= =?us-ascii?Q?9+JJxu9gQ6KtWOSXUt1bxykxqC04UD+J7re5vxXczu3Emb6yaH0IbGX/zLTL?= =?us-ascii?Q?KFYYeEB0fYVopBTCWl+uuP+5JPv2BJHU4x4+iPofP8oTBBCb6SQqjwhh0ubo?= =?us-ascii?Q?xxwztQehXvba9A1BOiG9/kQNUpPskt/uvc+qITQ1KTAsThJ6la2DWqh4mBRB?= =?us-ascii?Q?xkQxXPoDdgjvwyPhGAwF24Tln6lzs/aoSqFz3UZOfvpd6s1AEg=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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vMHpmWbj8Kk7c/KTZSvF450ldsZ27CstQBqSt9BTmqFqWwjnXYb8S9ezBHepknK+wwpFTh2Zfxbh3xFoqIkLT6RnAiO7FqfzpsesgzHBO+xBdT5iN+zQS9zf14UrN6L9N/uyLh/MhOYZIfJM7lO/zQK1j4SoYuZepFNnimLVsol2C49DJtXrZRCeipCpoj6IkPhKvD72SFiT1Nh99GiRXVWDrF03BJT91+K4jkHoMXv/tmxLSDSgCTIMa5CS7z0U82qlJNf+GERhl9lbMzyGNAfEV960M2gZDTQhkYSGtRMFVO20WJSgcZubqdUUPqzFbSs35XXf2v/5szobhAyEVemFCb5PsxLTCP9zgrUP8s7tHNfV2BQllGbqBOyhWp5Rx/mqnj43IRPlb+HCO1ClSL96bIOVfe52aW/ftPKWedtWtSUSTEafNbp5/pzEIuh5PioRJchonmSFHuF78XRR6+rcGZ7t2MfL46TTGIvvoDCPQzpV1R9/o5U7LnFPMd4hQWd2nqVOZl9rkD2JyXfleJ9kKFoT/cAYSj0xsc4SMAegz3JJBY3wQJpyaeJKFdBAWl8Phf9etYlrv58K20kbFJh2uPBLsft4bYjhiU4t9nn9PtIIG0KfgIs0dNtLhTglfUUOvF9aIKFT2N4YoVFIKztI6FAM6JFYRKq93RU2Jno= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:44:14.2459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce3d8071-1f7b-40fe-395d-08dcf838ec45 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: GV1P190MB2020 X-OriginatorOrg: napatech.com X-BESS-ID: 1730222300-311207-12675-28677-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWBhaGQGYGUNTM2DTNxDTV2M woNTXNwiQxJS3JyMDUJCnFPM3INCnRXKk2FgC8XO4BQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260064 [from cloudscan18-215.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 flow filter ops and inline API was exnteded with next APIs: 1. flow pattern template create 2. flow pattern template destroy 3. flow actions template create 4. flow actions template destroy 5. flow template table create 6. flow template table destroy Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/flow_api_engine.h | 1 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 104 ++++++++ .../profile_inline/flow_api_profile_inline.c | 225 ++++++++++++++++++ .../profile_inline/flow_api_profile_inline.h | 28 +++ drivers/net/ntnic/ntnic_mod_reg.h | 30 +++ 5 files changed, 388 insertions(+) diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 6935ff483a..8604dde995 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -350,6 +350,7 @@ struct flow_handle { }; struct flow_pattern_template { + struct nic_flow_def *fd; }; struct flow_actions_template { diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 420f081178..111129a9ac 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1119,6 +1119,104 @@ static int flow_configure(struct flow_eth_dev *dev, uint8_t caller_id, * Flow Asynchronous operation API */ +static struct flow_pattern_template * +flow_pattern_template_create(struct flow_eth_dev *dev, + const struct rte_flow_pattern_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_item pattern[], 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_pattern_template_create_profile_inline(dev, template_attr, + caller_id, pattern, error); +} + +static int flow_pattern_template_destroy(struct flow_eth_dev *dev, + struct flow_pattern_template *pattern_template, + 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_pattern_template_destroy_profile_inline(dev, + pattern_template, + error); +} + +static struct flow_actions_template * +flow_actions_template_create(struct flow_eth_dev *dev, + const struct rte_flow_actions_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_action actions[], const struct rte_flow_action masks[], + 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_actions_template_create_profile_inline(dev, template_attr, + caller_id, actions, masks, error); +} + +static int flow_actions_template_destroy(struct flow_eth_dev *dev, + struct flow_actions_template *actions_template, + 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_actions_template_destroy_profile_inline(dev, + actions_template, + error); +} + +static struct flow_template_table *flow_template_table_create(struct flow_eth_dev *dev, + const struct rte_flow_template_table_attr *table_attr, uint16_t forced_vlan_vid, + uint16_t caller_id, struct flow_pattern_template *pattern_templates[], + uint8_t nb_pattern_templates, struct flow_actions_template *actions_templates[], + uint8_t nb_actions_templates, 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_template_table_create_profile_inline(dev, table_attr, + forced_vlan_vid, caller_id, pattern_templates, nb_pattern_templates, + actions_templates, nb_actions_templates, error); +} + +static int flow_template_table_destroy(struct flow_eth_dev *dev, + struct flow_template_table *template_table, + 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_template_table_destroy_profile_inline(dev, template_table, + error); +} + 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, @@ -1188,6 +1286,12 @@ static const struct flow_filter_ops ops = { */ .flow_info_get = flow_info_get, .flow_configure = flow_configure, + .flow_pattern_template_create = flow_pattern_template_create, + .flow_pattern_template_destroy = flow_pattern_template_destroy, + .flow_actions_template_create = flow_actions_template_create, + .flow_actions_template_destroy = flow_actions_template_destroy, + .flow_template_table_create = flow_template_table_create, + .flow_template_table_destroy = flow_template_table_destroy, .flow_async_create = flow_async_create, .flow_async_destroy = flow_async_destroy, 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 d97206614b..89e7041350 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 @@ -5507,6 +5507,223 @@ int flow_configure_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id, return -1; } +struct flow_pattern_template *flow_pattern_template_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_pattern_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_item pattern[], struct rte_flow_error *error) +{ + (void)template_attr; + (void)caller_id; + uint32_t port_id = 0; + uint32_t packet_data[10]; + uint32_t packet_mask[10]; + struct flm_flow_key_def_s key_def; + + struct nic_flow_def *fd = allocate_nic_flow_def(); + + flow_nic_set_error(ERR_SUCCESS, error); + + if (fd == NULL) { + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + error->message = "Failed to allocate flow_def"; + return NULL; + } + + /* Note that forced_vlan_vid is unavailable at this point in time */ + int res = interpret_flow_elements(dev, pattern, fd, error, 0, &port_id, packet_data, + packet_mask, &key_def); + + if (res) { + free(fd); + return NULL; + } + + struct flow_pattern_template *template = calloc(1, sizeof(struct flow_pattern_template)); + + template->fd = fd; + + return template; +} + +int flow_pattern_template_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_pattern_template *pattern_template, + struct rte_flow_error *error) +{ + (void)dev; + flow_nic_set_error(ERR_SUCCESS, error); + + free(pattern_template->fd); + free(pattern_template); + + return 0; +} + +struct flow_actions_template * +flow_actions_template_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_actions_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_action actions[], + const struct rte_flow_action masks[], + struct rte_flow_error *error) +{ + (void)template_attr; + int res; + + uint32_t num_dest_port = 0; + uint32_t num_queues = 0; + + struct nic_flow_def *fd = allocate_nic_flow_def(); + + flow_nic_set_error(ERR_SUCCESS, error); + + if (fd == NULL) { + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + error->message = "Failed to allocate flow_def"; + return NULL; + } + + res = interpret_flow_actions(dev, actions, masks, fd, error, &num_dest_port, &num_queues); + + if (res) { + free(fd); + return NULL; + } + + /* Translate group IDs */ + if (fd->jump_to_group != UINT32_MAX) { + rte_spinlock_lock(&dev->ndev->mtx); + res = flow_group_translate_get(dev->ndev->group_handle, caller_id, + dev->port, fd->jump_to_group, &fd->jump_to_group); + rte_spinlock_unlock(&dev->ndev->mtx); + + if (res) { + NT_LOG(ERR, FILTER, "ERROR: Could not get group resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + free(fd); + return NULL; + } + } + + struct flow_actions_template *template = calloc(1, sizeof(struct flow_actions_template)); + + template->fd = fd; + template->num_dest_port = num_dest_port; + template->num_queues = num_queues; + + return template; +} + +int flow_actions_template_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_actions_template *actions_template, + struct rte_flow_error *error) +{ + (void)dev; + flow_nic_set_error(ERR_SUCCESS, error); + + free(actions_template->fd); + free(actions_template); + + return 0; +} + +struct flow_template_table *flow_template_table_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_template_table_attr *table_attr, uint16_t forced_vlan_vid, + uint16_t caller_id, + struct flow_pattern_template *pattern_templates[], uint8_t nb_pattern_templates, + struct flow_actions_template *actions_templates[], uint8_t nb_actions_templates, + struct rte_flow_error *error) +{ + flow_nic_set_error(ERR_SUCCESS, error); + + struct flow_template_table *template_table = calloc(1, sizeof(struct flow_template_table)); + + if (template_table == NULL) { + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + error->message = "Failed to allocate template_table"; + goto error_out; + } + + template_table->pattern_templates = + malloc(sizeof(struct flow_pattern_template *) * nb_pattern_templates); + template_table->actions_templates = + malloc(sizeof(struct flow_actions_template *) * nb_actions_templates); + template_table->pattern_action_pairs = + calloc((uint32_t)nb_pattern_templates * nb_actions_templates, + sizeof(struct flow_template_table_cell)); + + if (template_table->pattern_templates == NULL || + template_table->actions_templates == NULL || + template_table->pattern_action_pairs == NULL) { + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + error->message = "Failed to allocate template_table variables"; + goto error_out; + } + + template_table->attr.priority = table_attr->flow_attr.priority; + template_table->attr.group = table_attr->flow_attr.group; + template_table->forced_vlan_vid = forced_vlan_vid; + template_table->caller_id = caller_id; + + template_table->nb_pattern_templates = nb_pattern_templates; + template_table->nb_actions_templates = nb_actions_templates; + + memcpy(template_table->pattern_templates, pattern_templates, + sizeof(struct flow_pattern_template *) * nb_pattern_templates); + memcpy(template_table->actions_templates, actions_templates, + sizeof(struct rte_flow_actions_template *) * nb_actions_templates); + + rte_spinlock_lock(&dev->ndev->mtx); + int res = + flow_group_translate_get(dev->ndev->group_handle, caller_id, dev->port, + template_table->attr.group, &template_table->attr.group); + rte_spinlock_unlock(&dev->ndev->mtx); + + /* Translate group IDs */ + if (res) { + NT_LOG(ERR, FILTER, "ERROR: Could not get group resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + + return template_table; + +error_out: + + if (template_table) { + free(template_table->pattern_templates); + free(template_table->actions_templates); + free(template_table->pattern_action_pairs); + free(template_table); + } + + return NULL; +} + +int flow_template_table_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_template_table *template_table, + struct rte_flow_error *error) +{ + flow_nic_set_error(ERR_SUCCESS, error); + + const uint32_t nb_cells = + template_table->nb_pattern_templates * template_table->nb_actions_templates; + + for (uint32_t i = 0; i < nb_cells; ++i) { + struct flow_template_table_cell *cell = &template_table->pattern_action_pairs[i]; + + if (cell->flm_db_idx_counter > 0) { + hw_db_inline_deref_idxs(dev->ndev, dev->ndev->hw_db_handle, + (struct hw_db_idx *)cell->flm_db_idxs, + cell->flm_db_idx_counter); + } + } + + free(template_table->pattern_templates); + free(template_table->actions_templates); + free(template_table->pattern_action_pairs); + free(template_table); + + return 0; +} + 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, @@ -5757,6 +5974,14 @@ 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_pattern_template_create_profile_inline = flow_pattern_template_create_profile_inline, + .flow_pattern_template_destroy_profile_inline = + flow_pattern_template_destroy_profile_inline, + .flow_actions_template_create_profile_inline = flow_actions_template_create_profile_inline, + .flow_actions_template_destroy_profile_inline = + flow_actions_template_destroy_profile_inline, + .flow_template_table_create_profile_inline = flow_template_table_create_profile_inline, + .flow_template_table_destroy_profile_inline = flow_template_table_destroy_profile_inline, .flow_async_create_profile_inline = flow_async_create_profile_inline, .flow_async_destroy_profile_inline = flow_async_destroy_profile_inline, /* 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 b548142342..0dc89085ec 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 @@ -73,6 +73,34 @@ int flow_get_flm_stats_profile_inline(struct flow_nic_dev *ndev, uint64_t *data, * RTE flow asynchronous operations functions */ +struct flow_pattern_template *flow_pattern_template_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_pattern_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_item pattern[], struct rte_flow_error *error); + +int flow_pattern_template_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_pattern_template *pattern_template, + struct rte_flow_error *error); + +struct flow_actions_template *flow_actions_template_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_actions_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_action actions[], const struct rte_flow_action masks[], + struct rte_flow_error *error); + +int flow_actions_template_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_actions_template *actions_template, + struct rte_flow_error *error); + +struct flow_template_table *flow_template_table_create_profile_inline(struct flow_eth_dev *dev, + const struct rte_flow_template_table_attr *table_attr, uint16_t forced_vlan_vid, + uint16_t caller_id, + struct flow_pattern_template *pattern_templates[], uint8_t nb_pattern_templates, + struct flow_actions_template *actions_templates[], uint8_t nb_actions_templates, + struct rte_flow_error *error); + +int flow_template_table_destroy_profile_inline(struct flow_eth_dev *dev, + struct flow_template_table *template_table, + struct rte_flow_error *error); + 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[], diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index e8e7090661..eb764356eb 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -314,6 +314,36 @@ struct profile_inline_ops { * RTE flow asynchronous operations functions */ + struct flow_pattern_template *(*flow_pattern_template_create_profile_inline) + (struct flow_eth_dev *dev, + const struct rte_flow_pattern_template_attr *template_attr, uint16_t caller_id, + const struct rte_flow_item pattern[], struct rte_flow_error *error); + + int (*flow_pattern_template_destroy_profile_inline)(struct flow_eth_dev *dev, + struct flow_pattern_template *pattern_template, + struct rte_flow_error *error); + + struct flow_actions_template *(*flow_actions_template_create_profile_inline) + (struct flow_eth_dev *dev, + const struct rte_flow_actions_template_attr *template_attr, + uint16_t caller_id, const struct rte_flow_action actions[], + const struct rte_flow_action masks[], struct rte_flow_error *error); + + int (*flow_actions_template_destroy_profile_inline)(struct flow_eth_dev *dev, + struct flow_actions_template *actions_template, + struct rte_flow_error *error); + + struct flow_template_table *(*flow_template_table_create_profile_inline) + (struct flow_eth_dev *dev, const struct rte_flow_template_table_attr *table_attr, + uint16_t forced_vlan_vid, uint16_t caller_id, + struct flow_pattern_template *pattern_templates[], uint8_t nb_pattern_templates, + struct flow_actions_template *actions_templates[], uint8_t nb_actions_templates, + struct rte_flow_error *error); + + int (*flow_template_table_destroy_profile_inline)(struct flow_eth_dev *dev, + struct flow_template_table *template_table, + struct rte_flow_error *error); + 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[], -- 2.45.0