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 4AFBD45BCC; Wed, 30 Oct 2024 23:16:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 676AD434C5; Wed, 30 Oct 2024 23:15:59 +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 858FA43400 for ; Wed, 30 Oct 2024 23:15:55 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 22:15:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yX+5GT3zdBE/u3RZHQMfo4vEpARSofHZ6tIIp4Kuf0Pg5OTXd8WVfMNSaYak1GfqNYjymx3guZBIqpvUXQes3OoXfrEJJIM0YBHrJG3cPUnFmS0YpzxuCvEW5+4yooL4IG43mbPMzu2WsOsxAiDhXWNq9vMA56joisI2o43yPKPJJU5yZYdD0lL+0SRwFUcYa68iijUSdOGHd20XbP2ayoLbNnZJSxjkO2KPfHE1vlaZtb0N+5uVx84/VDM4S9hIn7QBsUk18RcT2we8md0P6gFwUZME1HeM+APBqn0zoPdJiZoZbkVL41sztF+p7H3F58pCSsBPYRAsfVyCqgCVlg== 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=azcq8M9WM30M/bK65XCFt50rhsSJGS+tgELFK6DluKM=; b=wb+X/Nb1aP/5W7kKdCcQOkwnrr9yCvx208HAdlQMtH4BLi9xqqOyrAwK2lN5CNrkzf5jf5WINFc7W1e9gKSDaw/YXs3nJPLtGjjmvhK/O0R1s/rxvJYDs8CVZUpmfLJgGtoDIYN5RtMBcw6R2/XlcoY/rltg5DA3Xm5/ixngUabalBsoWj05W8v/p6DuKKXq2/PsHJXG1WEyJR+N2Rwbr0pzDi9WQrN5rSRk3+6gUC1y26IMf/PmoRrMmpVdb4h+wsMcps9G4dahUnpquBkL/e47UWBg83koPAIeSUqNBw7V+rYW+ZjxFtjTcLn9BSIC1ulw6KuA7SMHeBgXQkTIhw== 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=azcq8M9WM30M/bK65XCFt50rhsSJGS+tgELFK6DluKM=; b=fKdqb8nHA47ZXoV+Gc0NzifAaAfgpXUtOjMOSK2m/NN3eWnKEzcwbhqmiRFxUgW+HPt9jc/2v3jPwxB0tI6iG9EmumJf1X1cPV12kkdphLBYMTz6nzF9Ln5RZbstgiPdc0gIO+9dVMs4E2WrXYQugdDHi4LU4r4U3AfU5KfkYGg= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by AS4P190MB1928.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:514::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:41:10 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::12) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) 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:10 +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:10 +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 79/80] net/ntnic: add async template implementation Date: Wed, 30 Oct 2024 22:39:26 +0100 Message-ID: <20241030213940.3470062-80-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_|AS4P190MB1928:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ca90f828-583d-4a33-ac15-08dcf92b91bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BYGjXqbi+bXItaYFnIHRPAszsrIUqLArsGlkjNljAhrX4+xSZ58Rt/a+XrD1?= =?us-ascii?Q?cqGmB0SGZNxWW4JuZSxK/DIWb02EnLaEhEhpZdxFVnDPwxzZ728jsqhKOWIu?= =?us-ascii?Q?xpBcMe1Y5u5J5x/1hkNIHw9fYfVQIe0h9n+CfIy4AL1wbiyscEugCiKduBuo?= =?us-ascii?Q?Rt4IOHb9qac4EFUUS1sp+YEKvL33nKTj747sx0EugOILvz/s16bVcK5eI47W?= =?us-ascii?Q?6rrogCEG8Tc0dWvodcZZbEkq9hyvwJQr8lLM933drtADQeK74aeMKVKyIxUa?= =?us-ascii?Q?ZWnBPbt98yZpSRW0SBCOJvMvKfrc7L4AG1stBKx4pK4po/1c2egox/6qkSZK?= =?us-ascii?Q?nFHJu6qWSlfz65/6S4pFSTyx94j6vQ1pv4j5sTLadbMaci4jthiXYxLms7PZ?= =?us-ascii?Q?glh1SawJDJdISW3m9/A06goNDlj394ROsjUgl1RTc7EcCdQHV/LcbAi0JiQJ?= =?us-ascii?Q?4qoFNT0ss6hZp5LhDxxhICUOhCGg8sp7VOmO7BAVeWeviSKIHbVlEfRW7Ym3?= =?us-ascii?Q?5ROCkX2BnvK1xg4Df6V2cr4mTmuWeQillb27HLqTkBkhvvTo0+2Ry5gkxGgD?= =?us-ascii?Q?v6x2w262oqE9NVC7e9FKDvHeVzcX+lucG2XiiBW3p+OFD3rs8lw/GKDl0kJA?= =?us-ascii?Q?TcBCLcgyHmeZvmgnjRxUXpysf8IvNsPer9TC7n1asXM3e3QxRp4NPRrJouyd?= =?us-ascii?Q?tvZne4o9AFNERNkV/qrgTIc7bpCwyRt+S70lhh4QFnZyaesTtVjaaz+OQwMo?= =?us-ascii?Q?I0XyXE+2botPrn7HQiCcbP26qXYBt+eNo+ldRvONBoch9Bjfxp/mnkNkNcR9?= =?us-ascii?Q?rpmXwCvuonrYii9xgRnJjQS8sGeimuVyOOdZtodYq7XLlPUpcmI50oZP/Qwp?= =?us-ascii?Q?jvTzlPDS8NEoMXBZs6rjTxYnI6Q8tYxmyx1iE19SNoFzMdDkSX2CuehA7Xh/?= =?us-ascii?Q?q0UhR1x63GKtZXNc9FRQL+WK06WysAa5s5tLI5mcoci+R+ZZRFgmUxjsr05R?= =?us-ascii?Q?gTxOW+xQiYW8dDbarAkZPzagof2bzki/tIKDYDqI0oEizzORwmyN+MNCPpXe?= =?us-ascii?Q?/YygLKR//Nd0dKQDTl2rVX/jZ4c2mEUID+INTzp6Q7DPzA7xNQSUqrARCVub?= =?us-ascii?Q?aBvFG71h7edG+EYGds5lWG2jtBK/1s4IDk3vreQRwG3f8i/I58qPuv+r9V5h?= =?us-ascii?Q?FlSY1RYgo0MQo/yOmGO35F6VfzIRB3PgKRO7rniXP8qjzKbIHl6eqRQ9EakL?= =?us-ascii?Q?9ryAtguBRkOa9IxwWrojM66DjaewXTgliUAscHLN/w2K+S28PREXVy+LkgLf?= =?us-ascii?Q?oLG0u1QWyI7TDGMtT0Ugz9KxXhBcudEj8liFJo+mzMNh/w/BsJ9kOo38d7cI?= =?us-ascii?Q?Wk9yVjFUxuPYj9ezoGKp10dtCh/DYFAn/oWauD9gXKfoelDdKQ=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)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: x/nTiqe895PrGMH+AAQJ1sZcWggJZn4d2qS5eLOlCOV5FsYax7m+fVS3fQqjiImumWTuejmgGVA+iQ+AvV3uO8G1QrF+9n8C+sydspYm1G9isojbJcflhVw7OPxCtSbtol91vpyi+55f1okMZWQ6RDXdepoL+DDjqlbHvYz8vnx46vWeJ/P5xdy812Z+rj9b7Osk2LExmAdSg6rzc6nP00EovYq4smkAhlDsUSFWAEnztWLJyi3zDajaaA9p5IN8dfse1dWW98tSy9eXdXenz27oRlzhpwQOdcQBOzONYL591lu+OZRo3nUYLoxmxp11GeZU/bqPs+UEC7QdoD8qJ1GPKpbs8cotzx66sWjFGxDa8T248MRIK86nUkaHIyFB9+WoHYGduLO5T6xSzWwGnMI43PkYhV38IlESUyZtWDb6YykVBoB4eqbexqxN2eYvw71HjEIY+62dk+1MEIxxWmMz7zoyDYOvyCYFQL4aYAjzOSNB94Tch5XIB5p9bOwjNpz1XAC5nE9R2Iz9CAAF6soehZh9+A5tXpeTeFSDQins7w1/pU7t3pwP/z0uEALugZUrTg80nZHhD9j/dBFKJ+tJBsf0mCzQ6HUKqEBqjCMGlmJXiKaCZ23ZqmXZBmTWbCSJ1c6dp6qNgIzQSmTduAvlreadroRwRtCIYFK+NnM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:41:10.0835 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca90f828-583d-4a33-ac15-08dcf92b91bd 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: AS4P190MB1928 X-OriginatorOrg: napatech.com X-BESS-ID: 1730326552-304433-12634-46110-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWBhaGQGYGUNQi0SjFwNwsJS nF0NjEwNAkOTHNONksKdkyNTHRPC3JRKk2FgAyARhwQgAAAA== 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 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 884a59a5de..98b6e49755 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1081,6 +1081,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, @@ -1150,6 +1248,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 5d1244bddf..9fd943365f 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 @@ -5503,6 +5503,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, @@ -5753,6 +5970,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