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 E4AFC45B96; Mon, 21 Oct 2024 23:06:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F3E2406BB; Mon, 21 Oct 2024 23:05:47 +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 E94C940612 for ; Mon, 21 Oct 2024 23:05:38 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2168.outbound.protection.outlook.com [104.47.51.168]) by mx-outbound46-162.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:05:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pNAJTKcCO4efCWWMN6St3Ee5hPUJ/L9RAi01mQjmriUgEAvAZDKXPUsmg+QAKL/Ovob5ZA+MvEC8AQELGUL6fLVYrOPSW/w32Je1XmXnMl8vi9VSuVI3z6r9MfQDLU0K1oPS3zaGgIk6uVFcUwhmbci6UwOCzViwr0tkDuCOi08FfwGscl6MAtPo89pJQfqVbHx1zIjhWAWz36o4BZNR49SCDZJph//PIHGwq3vaZcMqnJ1mMOtu/6bVbBQIPKzwyXcSXv0/Ap213VaT9I8wt2tRrkQvFsfaU9LCteR2hQ5R9CnNpo8Kl8gBP+zz3yx1N1nA/G5QLPkI3zJsaDhRrA== 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=+cXO84BK0vqY0kL8b+MsrQxT5j9/Zz+3nMGjHLaDuJ4=; b=wRbxzm3iVsWN3TV2J9z9a80OM6Exq9kyp9tFzqrbdyuV3XnV8itXQSzc6eZx7BeglZg7FZBv3/G4q0vnxfY1/NyQaMo5FUHtTqTjV5ZDGwhrfB2rJjy6FYeFQiJPsVK98+NsW2V5DwVZPZ5197aOTkeUhJFDi2Lkx9UiWkrFu9Edjn/jO0YJqydzTCC7q3ZMb3fwhSqURsc4gD5sAwicDMZpj55YirQK0AhendSQnnwafhVJ46OdAfzHgMLc8SBe102WhB3lS0AT/cL2ljcDEARTCGvYzATZ+6w1US/FBNbM+1sZXYknzSpJQW4Vt0OWqvu9/AWBxZGY5tT3/qG5Ow== 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=+cXO84BK0vqY0kL8b+MsrQxT5j9/Zz+3nMGjHLaDuJ4=; b=J2alqs5LI560AusLsaou9f4hEBer78Z9+/lm8WeSR0VMZVa11+JcZgDkaU4XHgvGKwI+F780Q77G43VClHEeOwj8p3ojBlXjMGgqvRxtpjg+w3frQ1USOVrsB3HTQBFA5PbnsVbQ/bgcnefHrzfch+cMBwK7bZMIByB1S474RlY= Received: from AS9PR04CA0152.eurprd04.prod.outlook.com (2603:10a6:20b:48a::26) by DBAP190MB0855.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1ae::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 21:05:33 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::e0) by AS9PR04CA0152.outlook.office365.com (2603:10a6:20b:48a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 21:05:33 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 21:05:33 +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 v1 03/73] net/ntnic: add minimal create/destroy flow operations Date: Mon, 21 Oct 2024 23:04:05 +0200 Message-ID: <20241021210527.2075431-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241021210527.2075431-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A8:EE_|DBAP190MB0855:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 350a5bcd-3aa9-43d8-9cb4-08dcf2141a39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?R937Ri+FVrd142F2dLvT7TqrfU31Xj8YaNqACKhwu2bhTV9om5NQVzff7iTX?= =?us-ascii?Q?/KvUALNtvpzPimVBu6FbMZdeLS5qbKOPojkq/KkXbHJb5mFtAK7VCNPClqMa?= =?us-ascii?Q?EUnKLKKaZLfF0/1cDioUA/RzfaQ7EeDC0sehZ5Cd6xaItE3tMp63NbXkEf0v?= =?us-ascii?Q?elyG4XG5Wnm/A1gO1cHvzpi+IY5vU26ER+9QubYvFdaU5/idqr80bWA+pXiQ?= =?us-ascii?Q?7jnR02CrbIMzaGNgsG8AHC4yO5XpicuNqZ+gRFJxR9Chxoa3V9veySfwWh2h?= =?us-ascii?Q?OpfxWjxL9AMJVlAYSOzWPb6fMPmgTomVDPutAhXtNrKFzhaliClToB/wcV/m?= =?us-ascii?Q?Gff/N0h7Sz422Q73jgRxeKekO17nKFeGttpgbFdzK4H/XK7JTKlnvEf+AbQv?= =?us-ascii?Q?ob1inS2Kz+YD9nTQKhIECt49DuBJ1xW8iZse5DmI3jjgnB/4qtsLei440mdu?= =?us-ascii?Q?Lnn6sK+PIZkuuk+KKIu+AubsTfdLRq1R0DktfOr5ywKf1Aer+GREkXi7Me4q?= =?us-ascii?Q?BAPxJPosP0eevm2rvtk8Q60U+94BnxDhkxYqyl+H+SOU/wxGMUsJjEfXDTWV?= =?us-ascii?Q?7p4RztODpnnnsSmhyH+Om0YovH7Q1OL7mm4raOHHx8cgydQtQ2rtEmZuIBIJ?= =?us-ascii?Q?auCOPSKAo1n60yfGxTwRsIKusnx6Uez8WG/c5L8gPKXcEIbg/wSt1optaf5A?= =?us-ascii?Q?X1b7+XLD1utF3r4lJHyLJM39v3uIKv4A7t5sMC+joIoAfTRQnY1cDNDvwMea?= =?us-ascii?Q?zlXz0TiWxyPHOmi3YnekKepPoTtfbBXI7XB73SRsacHh78qXoDs9eMGLtjHJ?= =?us-ascii?Q?JZYd79DlhEKljWUDhxSxDgO2LsEWvdYeR+b5pPnBgxohX7hdkvlsvPjDrPO3?= =?us-ascii?Q?0A6Uuez/brpQqeTTQuAh8BBFzBYZyHVKJ5VJhwEbXgzqZMQktdcxrvswk8KX?= =?us-ascii?Q?XDGZbmHSpEyg6btqRZOm3eN8TxRQEoT7/RrcyM1njvObbCwY8kCb+kncjV4o?= =?us-ascii?Q?JRqiA6S6JUbWv3zMs1NIw+hJAFA9cPc5JKzlz9AePjk5UIOLO50RavGpvH+p?= =?us-ascii?Q?SgWnhhtvQXF3rCrrX/5vdZoQTMKEmAiShcqASDKmFOP8rVgc06gO8pZqsQYr?= =?us-ascii?Q?JYzUcR/tnEkVK2Iy/0wBZUkvKDhUGaMLtPIUyqcOWpfrDyFMgLvqzVyCz6+O?= =?us-ascii?Q?2/4TOdcJ9cDRytHJJFSGV+6Ko5cLB5C1QOPtRMHD+N/CaSXPM0KR/V4gfLbI?= =?us-ascii?Q?2eXZzsEqxpi5xPGv95UQD9HeEcQRJaBmnb0MS8ibKC/hiVB9xZAI8bp6fXZO?= =?us-ascii?Q?2d0Z+QIPKQ4ctw/aMq+sr7Z+DdI/X3YZ2ZTriDis0yrJTo6OA6qmH4a4wgVj?= =?us-ascii?Q?kk2G3oHz5FRLgqsJBJJH7O3/Faty4rx9Ng0E+jeibtQzV0pqsw=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)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vz8TRpk1OJKnMHpafCv9Fd0x6yf6cmRQTtH/yD2+vZl34gH6KogzShLNwaA/vSGUFyYXmymkFjAuu7ZyCCs6IGmpAc6DLTyAzhJDyl2StFTIaFIoKgA4EWMmSLtoO22O8yMbbexwBiuKf5FW/YddR/U+lLdf5EZaTa+CMTsCwboioaxMVmiE+7kgd3PElTa99JzHrU7U2N3tXIuBOF5yxzQD8Btr3I1xmQMYF3Sk5cIhF9kJdRq7iFKADXDFqlHiO1xU5lnDIlSY4er97/DAAmIIbdXavPpxS6RC38g0bPZgNMaLnzZ+CcT/2Hz/ETKJHWtT2dRUHZeNY+qedyTds7sLHCrMrIzInUkufWp0Q6tL1RVKrLcpG+CbM2Capynpc+6gYfzZ8cU+602l/XITlLc3x8z+qeSrhyjXge8CjxKiLHKzvmcCi5ZZlq24lhZbpbH5RU1oqf3brNIlxmIdda8bnBTpq+653pVgfpL1jRniey/O54jhBqxRMxYqd+DHtVekeZHeJXqB+17HKyHSTbOuWHDa29reaP9GpqnoCdUhVQVQLCIYsKnYiKWS6xPj+/V6YfWMGiVJw7BNvLRCyr9KBD9GSQlM08SiQO/SJ7eDXeQ8FzMZniV3g3Oboy6SWeOCcjZB03L5eWbggYdzmh6dRr6i9H7FA8ZmqeiowBM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:33.1612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 350a5bcd-3aa9-43d8-9cb4-08dcf2141a39 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB0855 X-BESS-ID: 1729544735-311938-13028-41183-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYGlkZAVgZQ0NIsycjQ0sTEws LQLDnRMgUILFJTklKSUs0MDRLT0pRqYwEjXCXtQQAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan10-204.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, 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 --- drivers/net/ntnic/include/create_elements.h | 51 ++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 223 +++++++++++++++++- drivers/net/ntnic/ntutil/nt_util.h | 3 + 3 files changed, 270 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 99eb993a4b..816ab0cd5c 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -4,16 +4,191 @@ */ #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, + const struct rte_flow_action actions[], + int max_elem, + uint32_t queue_offset) +{ + (void)action; + (void)actions; + (void)max_elem; + (void)queue_offset; + 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, struct rte_flow *flow, struct rte_flow_error *error) { (void)eth_dev; - (void)flow; - (void)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; } @@ -24,13 +199,47 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_action actions[], struct rte_flow_error *error) { - (void)eth_dev; - (void)attr; - (void)items; - (void)actions; - (void)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