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 BBD5145BA3; Tue, 22 Oct 2024 18:56:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 772ED402BC; Tue, 22 Oct 2024 18:56:06 +0200 (CEST) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id EEEA140272 for ; Tue, 22 Oct 2024 18:56:03 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2241.outbound.protection.outlook.com [104.47.11.241]) by mx-outbound15-54.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FwxPiZkLtWz2SQkSBcE44ywxQXtS6GIrZBb3BpFHiorpM/xz0NcVeqRyj1HrI81o1wvn387ga+tMeCQWM0A7J0X8zmDZgzrWmCXQQdoF7t/JJuzpSKNU9EGEVgmgvT33tNASfpk6vIJwg7Xp2BE0KI4+JzJqxdXnduA5PD1k0LQhBy5yvdXiUE+lglC037uYsRcvHV6GFufeDxlaC44M1V4ATYQ1F1+2aiCE/vopCzk5aHVtVi1h83BGHnAbuizKfMOekmrjKEZ48M9g3DmTeCmjzRwS4qXnI1vDVkFdbnY8Df2E9xAf4UEXOJ5t1Yu/nskhqbNmMEs25GlqXpIK3g== 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=8QZRxv5IpNPnb1s1SXXS9HiAE8/H+JObuMbprksQF0c=; b=dluVYeT0VSUaHavmgbqdc9uJvCZ005AYK0JLca8j4WeQg7qzwVWlJSNrP1IbU2nuW2p/uGTcFZ/a0b4Mtg54NvOm6fBgL4zAJ4VrNdllvP3umks2+PrAcn681EXBlh0NyejhEEAnDK1ApXTqATIUdejeLjSyj4vFpJnCrP+QGpezcK1EVPJrLhn7ogwN96rUlMHhA5JUzbjvwdSHlX7d8Ajg4XkqoTlTVjSS/PVDxQWQ8bcMLMpN60kkoSHcv/KS7tdqQe/qyLKRGa5idAoOht8c19Z8yAvSiW41H/Kq3GPjB4QCJrFcpMzlczkky9BW00swHVeFoxr+82G8OyH4ig== 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=8QZRxv5IpNPnb1s1SXXS9HiAE8/H+JObuMbprksQF0c=; b=nyqOlZAwJ2ia9vLM1ZXfBBRBrEKpLXK8YDmwY6ozyRKcJYkyu9ABVLwlk7si67z8ZQaBa4J0oKpx8AGa8Il7ZlKmY2WzsnPjT01z5A4twkE/IVOMFtTC6C9LxTQfMq+ji7MV33rqZ+VLP2TnXQLBkdvoTQZW7YJEYAZXDVrYIBA= Received: from DB9PR06CA0023.eurprd06.prod.outlook.com (2603:10a6:10:1db::28) by DU0P190MB1932.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3bb::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 16:56:00 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::2e) by DB9PR06CA0023.outlook.office365.com (2603:10a6:10:1db::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 16:56:00 +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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:00 +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 Subject: [PATCH v2 03/73] net/ntnic: add minimal create/destroy flow operations Date: Tue, 22 Oct 2024 18:54:20 +0200 Message-ID: <20241022165541.3186140-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|DU0P190MB1932:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 98561a0e-4b1f-4592-d681-08dcf2ba685f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xSl+pGbsOytYSqUTsHKkfkWxWXpjBYl1qlJC40cltJ8kD4m3sOLytu0OY2We?= =?us-ascii?Q?4fzF66tENL9bOEwKCati7kpklg/9qh6KdHeGPIVb0994e/QL+w74AD5RaOeb?= =?us-ascii?Q?VyPd5dW93WUXCWiLh28lP75X4zTSRekXSgnD78Km7beaJnXLMrgmpP5vJ2YI?= =?us-ascii?Q?Un02voIld5tptZKLflMm6MBexAuqmLsTBWP9erWmJ9EToDA0+hcm1NWWugzX?= =?us-ascii?Q?Ja6jKNKUB8eJb+8LLajuFi9R73HgWR4Dw/+4YQZjxzUfj2QsKFSaIgYMoPHj?= =?us-ascii?Q?1lo8yPjV+73j8zA5rCVYdEa8eZdAirJ8H9ROV6+HIlbEIQrIptUEiJ0QWi/3?= =?us-ascii?Q?TTNhLBKPZJkj/vL4I1IENbUeLWvRqSJrl5dwMbKuUy4mlYUkuxTesjXYRG/W?= =?us-ascii?Q?khYEOBw6PpR8GV5MW3TL6DU9/pyeNZ25RBz9W4WQXsVOj0Z0rKa6cTNlft4j?= =?us-ascii?Q?pGWeKW5B0OujFBq4ACfS6ViNI+F6oA9kvsXyvMNOWOkVNGmNbW0VrqYlgmwZ?= =?us-ascii?Q?EqV6xpBVAsFB6gHo1CIFJZcJkxz4Ee6V0ggAX5QpPVqDn+LTlnApjL1t0T2o?= =?us-ascii?Q?1PrUeCOoiX4l/tctiesBMmuzBMgX1SRNNSfeWRNzcr0I9Jc0ZqjtaYnSuPg3?= =?us-ascii?Q?pGrFRhcunyMbNNxa0WOcq5ynNXllt/xvO8zISp/2Fy0IUHHUo2XZq+vglGtV?= =?us-ascii?Q?GcNjJwO7r09YApnMm0a1eFEBejq+frtacKdSiKJaLTOJJbfgmXcN+3kUDFc7?= =?us-ascii?Q?RKG4o3UcRZ/pwi0j5Q2dirvSfhNDrFodO2a0l6CdRNWnlcNR4AMfGdG0Eozv?= =?us-ascii?Q?7nJHrkyiti0P8WnNYTr0VlCYG38BtoOsmXf7TGF/iCOPpEC4o6C2un7x9QQs?= =?us-ascii?Q?AfbpGah2XD+j8/vczlX1ch1uJnXWfeiLGnjcn/+U08nnmq9OcRIkzLhhX98Z?= =?us-ascii?Q?2XOuqhw1bSjBq4YWUGSQ3HoOUEDJqG4fOtXPuVmmCs0D/5KbrRWrH16lnfRO?= =?us-ascii?Q?NKrfUc2zw4hCxbafEkemLPkz4igGYj7+1IsS3Xm2R2zkhul3M/qSLUXrnsbg?= =?us-ascii?Q?rIbwcO5qml8itujJ3dGHPyX0KsIjTckkx5nbmnypbGtve5xTW3afe6jiSvWr?= =?us-ascii?Q?SFfaMMXNGYPIdYWBjBm3Jz1VM3NFbkTiYkLgmQ/vsI+cWE9etxNy61QbDa+a?= =?us-ascii?Q?8m9EZhFNUNavfpO66yKGD9DGqiJp4i6iN/LGOmJiEAWXusXKmou5w+TK++Oj?= =?us-ascii?Q?HAqwTOs5216vLz1dv8kQ0IzSj+Evcodavq7avE1Q//HzxnYuzFLrQsyD5x6Q?= =?us-ascii?Q?IgilBQvXU3GvdnSu1k9XThYaid8/vZxY79saR+TaBO+tDzcxpRlgNljo0SHu?= =?us-ascii?Q?RfHr5UqSxTjKYoPkN4R7erynmgFWcsoIyUr8qnYdHf/W224F2A=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)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IBoxbbQy7Zg3FowUJB/eQgZ02GFH1Ge4gu4in1nABYkD1mda3B4uMra99XMQoX0T5szoKKqAZy1GayLBd1eKFVB0qAUOda03PAr5U1KVPdS4T8puTZlJCAkBJ9gnTUSi3JsXNRWo9a1LRWkV1zL71i99i25pUKmFSvFWS8EQUDg1P9H08BFzoXtNLbg1QKbQn0W8WQGPuhrgUYWvgWRy9sr5KdaexrgiOjJbjy0GP4CrqshGGkVi/9p4NKG2HPU7txo10KcvkZFu9w+Q929i1mlz3FzE1m+iJFNV5MQvaSyYJiSlbS0+FfYLUP/hBgkeCEdQpYKw38/KmIrIXCh8ZCnH8dfI/tvdaB8X2isk1z6p/UpFjEVHpxTmO2MJ7GDVIbOtmWIJIex6D/dP4sBQ9b//hRP7m8cDxvS9LEtSgtoPJMrQhYkrL9vo4C8A1Ha2BHa9S2jaIrqBzt7PbGeJh26bUD1JZTpZWVi/92aNsXxw7HGW1jSETUtx4BhTXabrkT9xTVQYyx2WPw27QeRTUftvsdQJ60osyKDoFMZhthQl3xJY6K8anOcQhzuFojCs4gO/BxD1CGW1AZIA5n4RYKwjN/u7/0ANnU3uvNYUMGPUPNWQNpk36oqjRVkxLrm/BTco3YP/suiQ/vFvzjpw0Kzr0w4PJQ0DL0Suh3LIq4k= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:00.6061 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98561a0e-4b1f-4592-d681-08dcf2ba685f 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0P190MB1932 X-BESS-ID: 1729616162-303894-12660-13497-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.241 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYmFuZAVgZQ0CDNMtUi1dw8yT gpKdXUwMA8xdzIxMTMKDkxzcjEONFAqTYWALuwYxRBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259901 [from cloudscan12-68.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 Add high level API with describes base create/destroy implementation Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/include/create_elements.h | 51 ++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 227 +++++++++++++++++- drivers/net/ntnic/ntutil/nt_util.h | 3 + 3 files changed, 274 insertions(+), 7 deletions(-) diff --git a/drivers/net/ntnic/include/create_elements.h b/drivers/net/ntnic/include/create_elements.h index 802e6dcbe1..179542d2b2 100644 --- a/drivers/net/ntnic/include/create_elements.h +++ b/drivers/net/ntnic/include/create_elements.h @@ -6,8 +6,59 @@ #ifndef __CREATE_ELEMENTS_H__ #define __CREATE_ELEMENTS_H__ +#include "stdint.h" #include "stream_binary_flow_api.h" #include +#define MAX_ELEMENTS 64 +#define MAX_ACTIONS 32 + +struct cnv_match_s { + struct rte_flow_item rte_flow_item[MAX_ELEMENTS]; +}; + +struct cnv_attr_s { + struct cnv_match_s match; + struct rte_flow_attr attr; + uint16_t forced_vlan_vid; + uint16_t caller_id; +}; + +struct cnv_action_s { + struct rte_flow_action flow_actions[MAX_ACTIONS]; + struct rte_flow_action_queue queue; +}; + +/* + * Only needed because it eases the use of statistics through NTAPI + * for faster integration into NTAPI version of driver + * Therefore, this is only a good idea when running on a temporary NTAPI + * The query() functionality must go to flow engine, when moved to Open Source driver + */ + +struct rte_flow { + void *flw_hdl; + int used; + + uint32_t flow_stat_id; + + uint16_t caller_id; +}; + +enum nt_rte_flow_item_type { + NT_RTE_FLOW_ITEM_TYPE_END = INT_MIN, + NT_RTE_FLOW_ITEM_TYPE_TUNNEL, +}; + +extern rte_spinlock_t flow_lock; +int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error); +int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr); +int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item items[], + int max_elem); +int create_action_elements_inline(struct cnv_action_s *action, + const struct rte_flow_action actions[], + int max_elem, + uint32_t queue_offset); + #endif /* __CREATE_ELEMENTS_H__ */ diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 445139abc9..74cf360da0 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -4,24 +4,237 @@ */ #include +#include "nt_util.h" +#include "create_elements.h" #include "ntnic_mod_reg.h" +#include "ntos_system.h" + +#define MAX_RTE_FLOWS 8192 + +#define NT_MAX_COLOR_FLOW_STATS 0x400 + +rte_spinlock_t flow_lock = RTE_SPINLOCK_INITIALIZER; +static struct rte_flow nt_flows[MAX_RTE_FLOWS]; + +int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error) +{ + if (error) { + error->cause = NULL; + error->message = rte_flow_error->message; + + if (rte_flow_error->type == RTE_FLOW_ERROR_TYPE_NONE || + rte_flow_error->type == RTE_FLOW_ERROR_TYPE_NONE) + error->type = RTE_FLOW_ERROR_TYPE_NONE; + + else + error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED; + } + + return 0; +} + +int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr) +{ + memset(&attribute->attr, 0x0, sizeof(struct rte_flow_attr)); + + if (attr) { + attribute->attr.group = attr->group; + attribute->attr.priority = attr->priority; + } + + return 0; +} + +int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item items[], + int max_elem) +{ + int eidx = 0; + int iter_idx = 0; + int type = -1; + + if (!items) { + NT_LOG(ERR, FILTER, "ERROR no items to iterate!"); + return -1; + } + + do { + type = items[iter_idx].type; + + if (type < 0) { + if ((int)items[iter_idx].type == NT_RTE_FLOW_ITEM_TYPE_TUNNEL) { + type = NT_RTE_FLOW_ITEM_TYPE_TUNNEL; + + } else { + NT_LOG(ERR, FILTER, "ERROR unknown item type received!"); + return -1; + } + } + + if (type >= 0) { + if (items[iter_idx].last) { + /* Ranges are not supported yet */ + NT_LOG(ERR, FILTER, "ERROR ITEM-RANGE SETUP - NOT SUPPORTED!"); + return -1; + } + + if (eidx == max_elem) { + NT_LOG(ERR, FILTER, "ERROR TOO MANY ELEMENTS ENCOUNTERED!"); + return -1; + } + + match->rte_flow_item[eidx].type = type; + match->rte_flow_item[eidx].spec = items[iter_idx].spec; + match->rte_flow_item[eidx].mask = items[iter_idx].mask; + + eidx++; + iter_idx++; + } + + } while (type >= 0 && type != RTE_FLOW_ITEM_TYPE_END); + + return (type >= 0) ? 0 : -1; +} + +int create_action_elements_inline(struct cnv_action_s *action __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + int max_elem __rte_unused, + uint32_t queue_offset __rte_unused) +{ + int type = -1; + + return (type >= 0) ? 0 : -1; +} + +static inline uint16_t get_caller_id(uint16_t port) +{ + return MAX_VDPA_PORTS + port + 1; +} + +static int convert_flow(struct rte_eth_dev *eth_dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct cnv_attr_s *attribute, + struct cnv_match_s *match, + struct cnv_action_s *action, + struct rte_flow_error *error) +{ + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + uint32_t queue_offset = 0; + + /* Set initial error */ + convert_error(error, &flow_error); + + if (!internals) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Missing eth_dev"); + return -1; + } + + if (internals->type == PORT_TYPE_OVERRIDE && internals->vpq_nb_vq > 0) { + /* + * The queues coming from the main PMD will always start from 0 + * When the port is a the VF/vDPA port the queues must be changed + * to match the queues allocated for VF/vDPA. + */ + queue_offset = internals->vpq[0].id; + } + + if (create_attr(attribute, attr) != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR, NULL, "Error in attr"); + return -1; + } + + if (create_match_elements(match, items, MAX_ELEMENTS) != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "Error in items"); + return -1; + } + + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { + if (create_action_elements_inline(action, actions, + MAX_ACTIONS, queue_offset) != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Error in actions"); + return -1; + } + + } else { + rte_flow_error_set(error, EPERM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Unsupported adapter profile"); + return -1; + } + + return 0; +} static int -eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow, + struct rte_flow_error *error) { + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; int res = 0; + /* Set initial error */ + convert_error(error, &flow_error); + + if (!flow) + return 0; return res; } -static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_item items[] __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_error *error __rte_unused) +static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) { + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; + + struct cnv_attr_s attribute = { 0 }; + struct cnv_match_s match = { 0 }; + struct cnv_action_s action = { 0 }; + + static struct rte_flow_error flow_error = { + .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; + uint32_t flow_stat_id = 0; + + if (convert_flow(eth_dev, attr, items, actions, &attribute, &match, &action, error) < 0) + return NULL; + + /* Main application caller_id is port_id shifted above VF ports */ + attribute.caller_id = get_caller_id(eth_dev->data->port_id); + + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE && attribute.attr.group > 0) { + convert_error(error, &flow_error); + return (struct rte_flow *)NULL; + } + struct rte_flow *flow = NULL; + rte_spinlock_lock(&flow_lock); + int i; + + for (i = 0; i < MAX_RTE_FLOWS; i++) { + if (!nt_flows[i].used) { + nt_flows[i].flow_stat_id = flow_stat_id; + + if (nt_flows[i].flow_stat_id < NT_MAX_COLOR_FLOW_STATS) { + nt_flows[i].used = 1; + flow = &nt_flows[i]; + } + + break; + } + } + + rte_spinlock_unlock(&flow_lock); return flow; } diff --git a/drivers/net/ntnic/ntutil/nt_util.h b/drivers/net/ntnic/ntutil/nt_util.h index 64947f5fbf..71ecd6c68c 100644 --- a/drivers/net/ntnic/ntutil/nt_util.h +++ b/drivers/net/ntnic/ntutil/nt_util.h @@ -9,6 +9,9 @@ #include #include "nt4ga_link.h" +/* Total max VDPA ports */ +#define MAX_VDPA_PORTS 128UL + #ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) RTE_DIM(arr) #endif -- 2.45.0