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 0BB5345BB4; Wed, 23 Oct 2024 19:01:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1ADEE42EBD; Wed, 23 Oct 2024 19:00:52 +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 8D1E442EBD for ; Wed, 23 Oct 2024 19:00:46 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound15-83.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:00:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zKn2cuD40baZjv/r9KddMDv5ireERx6oRCt4MhcELOqhivvk15oQbTcP2HMuhQVLRZSAjBfB5+0DtKVMBkYHCXqfBcT+f+nuLslPU2m+2ymC1npa4dhiZYlQs2QY9jCvggA0qYM7gA8jHjPunkp8V0ZxwJeFohwhZTboB+ssMFGqvLe1ADEAN9/ZxF3BmrbIx0RYYqucxI3FmBzs+x0Am7FE5axaUla2ON2Q2tYUMaTfUqF1zksvYxP9pO45GtPjHNAmZ6mOwnrH8w7m+LgVVpTkYgFlbNdCOgUHdPp30bV7nIwjotd9NMrFUdK+0AVrapKEEz9YIPQZPrYs1Kdy6A== 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=uS1YE7yElgZGnOZwZC2aTclkSVGUYvW5fpV32NLVKSg92s+E0YZT9ASorAXU4k8vLSolEVvbP7jbP8yH8i40CbaIlDYULAOfxH0NuUztHM0c6yz+tb6XAxGipx9eEKURGOuMy1rtMfIPPLsW7RaHaD57TfNQQUMWHuU8LIbLV2kj8wuBXQBKJpt/hr6qdFofO0IBKs8ypZ3SW17X80gm3M8VSjJ4XkUUcGGhvfd1AOa/tj3USOm7kdRv61cDLFCd1PS+2vY/r+rnuh7WjVICoM+ewJWegepoOAz6bTElrsCHv1JOcu5ccmVK3glVPMSE67rl1gzcSlOWNv4SE6b9pg== 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=LHhhZsdbRbQjUpjp9DTV+dRSEcq/K2dQ5cl6viQV1NspMNyjOjQe1/UakUREJLj6Sj+B8L5UAS1v7TT9B4xC7+adNm3gF1ARSg6keIG8dYwCtiwfkqU81qhQVaj1q96HyRDU2qvRKAVxI5EQSHeHtJmD8jS28oE7noxgS4ET7Nk= Received: from DU7PR01CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::28) by DB9P190MB1748.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:33e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Wed, 23 Oct 2024 17:00:42 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::14) by DU7PR01CA0005.outlook.office365.com (2603:10a6:10:50f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Wed, 23 Oct 2024 17:00:42 +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 DB5PEPF00014B9E.mail.protection.outlook.com (10.167.8.171) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 17:00:42 +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 Subject: [PATCH v3 03/73] net/ntnic: add minimal create/destroy flow operations Date: Wed, 23 Oct 2024 18:59:11 +0200 Message-ID: <20241023170032.314155-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241023170032.314155-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241023170032.314155-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9E:EE_|DB9P190MB1748:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 039810ac-f738-416c-ee14-08dcf3843ad9 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?iYvz6XG5pzGmFfMg8DpisquwfAt1yYN/SR2nHPQQiFFOkaLaknfQQTl82pDW?= =?us-ascii?Q?GqQYH7nVeVurf6K6ZHE3MUnsXMBprs8fvva+ERN7o2u85jyvigpGYM7vZ8YP?= =?us-ascii?Q?F2Obe9XwMWkukqpMsoo8dfr5PqeemNqGIeFzsRJ1iWgxTmRcmXxUdFYBJ2x2?= =?us-ascii?Q?PxISWHCCj1nsxw4AyJYhthuUqvR5CghMzqjZAJTIJciCTXZ1T2uKkYIQALzh?= =?us-ascii?Q?zW6IMrKQ5mmWYrqL8PKYswEDRbjbTcqFR+cfV5akeZFBzTSVrTqDw6/psfyf?= =?us-ascii?Q?qpThYesCmF+ZBq5rWxmQ72S1md7ikpKm4dRByc6iW5MdjI1Ti3bpGxbSVuji?= =?us-ascii?Q?tdnejd13iKP1PieHSe9OFIFe5NA25ISpe2qU7peVOSpkuCu9XgkdpqCtV284?= =?us-ascii?Q?6AIs10+zJ91K93Nwk/N6oE+hDj7uYdwSYoxYmi5tx+YS+DfzozH262l19yzj?= =?us-ascii?Q?2j2cgaAbjiRCFEG+M0CpBO4f9/bdZA6BdHlWABml62CAnWsm2fQtF6trXPj9?= =?us-ascii?Q?M2dNREsSyTahOqbC11IYCf7o2AittwOcdNiMXRxD/TPQ98XyTAlfhS++/EeA?= =?us-ascii?Q?c+f1H1GPhAzY+BE6pBmBskK72zZjjNTo+aYz4rp/2F8Nzan5a7jrxDCGTijL?= =?us-ascii?Q?FXSRgZpKqGhedlhAl/YStbbmk/RXNwarM/K6ySwkMm90oMRYT7ppGOXTQnSX?= =?us-ascii?Q?gOQO+67nR4nwnsARvxF7cyp4YuOm/hTwJPFtHNI+5Dl9I0oDxP7whCWCyBE8?= =?us-ascii?Q?nGcrvV7OCsSxL0For5RlRpX7xT1Rhe8Use0ywhVCwO7hnGtSxbqovEtgJJ1V?= =?us-ascii?Q?uyUYL192HuSlegYBmQJWuoUt+dQQ263XoNIPWpGeRd933M9NrXyvoGu+OYLV?= =?us-ascii?Q?WWbkbn3YyHf73gSF/7drofRu3v6n9FJpuB6e5v7BuqtM7iivNdLyY7GjCx3k?= =?us-ascii?Q?fprOWLh0/blLnb+oJ5pflC599bVZusj65PrIjWcsAgWsT02zbrBF1qsAyvvu?= =?us-ascii?Q?mZgOp+35z9lmmUAj/7ngxNrD417RhA11rvfAz+s2Dx/E0yrE2gtnb/OhEeL1?= =?us-ascii?Q?zD6cdQN5xVIzR6vSc9l125E0geCr3TVf9dlwkJSjatL3KUO68aICOq/O6V1+?= =?us-ascii?Q?q5o4Hji59vZO2T6hqnFGByl7UZRAb2ToZ3RHYbguv7Set69C0A1Fpno8Caaf?= =?us-ascii?Q?QwRNJIwJctcW0enrDT85DJEOSvc9qkPhsxFA+6TdfrBbHJr0q/UC5IPPZMQU?= =?us-ascii?Q?JslUn3rTOEikCnoVGo1XK9U6rJAAVmxCXYV1qiS3k0pBo/GC1bPg18vpCoRi?= =?us-ascii?Q?L5ShyZnWSKNEeQ8KDtH1H3tXaFyLb1SVQYREwaGg8sAdIZlGbh7n1QCj3JkK?= =?us-ascii?Q?tdErza46YRg7NFyZ1FJ19NHPfv4Y4KPtrY5gRS5rRPTE59A1aQ=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: /r4qHJNHX1p71kxJ2BF5ezVk+ElJW9d0VryHSMmLUTKF2eBEwTtlfHHKR4NBXO+jaTtFFgypfuhXhsjgqw3ab5NbUP6/t6OUc4aSxVK8Pdc8nsow/AN8b8LMHPHDFuKmwFl7GxuXkyCXecrCv9MEunuaEPljAmmFiWnfpZnw/DHFC3HG7JXX4LLhp/6G6+Y+x2DI9wz8vVKq7WWeYjKVIFWyrnf6r15aNPzorWCtgulXH1KHkGMGVGQDDpc7ISGYfrNbE3CCxWDCP376E4rgXqeCfSDAgZ6ya6M80QE2oWy6ceE+mVsXIF07tnpf5w61eNtm5zLHflAcIDJ2OGJ/GHlZGPsM/JhrHHDKkRTO4ijwmPZld1Ur7E9h9nOPwbHti5FOwah6esD7IwwcQR072lFBgEl5Z9MF+/lrPOm6S74ViLxeWX0DHai91NYed2IGKD+9ouH+ohUEpNNxmWiM0rOTlfpPVM7UtN65jkfIj3rPzS80M8MNDq0e3sE+d6j6OWAfFOpxWS3kcm4MwXvlYbGhovv2SGQj5IDkMFrORfSueiuB1WMoyc5ckHJI4S6M9vPcAV1h7knSoYLvS5hHNxJdE2J6xyRT1pQlcE4qPWcsJbZrXeQM0d38GfD6qPOdZ8KH9BkHZ0xOQ3od4U3qX55nbPKFbJBTOvqf6PDQlw0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:00:42.6017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 039810ac-f738-416c-ee14-08dcf3843ad9 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: DB5PEPF00014B9E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1748 X-BESS-ID: 1729702845-303923-12645-44286-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 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.259925 [from cloudscan8-201.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