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 E0E3245BCC; Wed, 30 Oct 2024 22:40:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 216A9433D0; Wed, 30 Oct 2024 22:40:12 +0100 (CET) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 0DA8D4334B for ; Wed, 30 Oct 2024 22:40:02 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2235.outbound.protection.outlook.com [104.47.51.235]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ek2M2TaSsNyf82l0ttn6R6dS+J3Eeq/CxPEGkSGlZDDFA8vmeBeylgMx66kfjutmL65B/QRMaXPczcH09Pt88BmgOJeRFIiTQDo/1cmW8aAKeJr8pHch5aML5LCcWJ91MdP2Ecck8HemzqD3r7pyQHtDI9eKMuTLMzowD5QHjEHsOx9fwAMk9GLe2E8Qi0NOJ3FGY06E8G6/5nmNrFpYY9V9Sk4ftPF7rr9hqxywRv7ph3Sugw7bgOt8Zg7Q/0iPBsJ4Mv8m/jeybN2Z21AUTwh/zMca9iLZ2bNMJxivcWWglF9q0y9a52+qQL96MgkmCfrYFVFlXnERlFPJWcTcwA== 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=oBUpTYwQRzziaH/IZcLtaCTbuLVz19dex4XL0Ti1mts=; b=ZVQLhhMR1zvDu3esK2axSe8ysxphXLJdSuMh/Ihe8EG+4/bOWRYEfZ/UjWbNTnqEaRG481BBG27T2/2lNNZr1/E9LRTRsk1EOZHDpjHgcBh3LV2l/x/xxCviot+aVk1roSVbhBdg1iP0xmBQng62DUZOGhazP8oLjrNPKTJfH/NJAnAcZx5XGpBuDbrN4rc7+cFG1u4aWwQH80JyWWodr/UW0Tj22tJTD/Brve6p3JkBdmhJgME0kCvOfgV/Ir1M1l8afB4usLJ1EBdwb2uPL9RxhxYKtzNCuGvIOu19nZ1RVj4ShMb9EOAkkzP++GYVjH4kIIl3yzMHAqQmA938Lg== 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=oBUpTYwQRzziaH/IZcLtaCTbuLVz19dex4XL0Ti1mts=; b=IVRZCCT7k5QJDu0UbNpr66WwS79Wsz8x+gzbREgzeacEjTlwceHPgUgfZmx1edZe9/GwRuXM4fbTtS20LV8pz36Y0u3K3t+OdCtbwhMJZWJb/OO3E/5btZdZ9AdXZP+aLc1wOEaEnVdS69Vtbbhjk+ogpcEEjjibtxKP6aYm91c= Received: from DUZPR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::6) by GV1P190MB1995.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:5a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Wed, 30 Oct 2024 21:39:55 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::61) by DUZPR01CA0013.outlook.office365.com (2603:10a6:10:3c3::6) 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:39:55 +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:39:54 +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 v5 03/80] net/ntnic: add minimal create/destroy flow operations Date: Wed, 30 Oct 2024 22:38:10 +0100 Message-ID: <20241030213940.3470062-4-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_|GV1P190MB1995:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: be7b66be-33db-4e4c-a9b8-08dcf92b64d2 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?GouLVwW9lD4Lw11N4DfwqJ09w2C/d0yJXDf05l8Vh7HBkC7yU7VeoDMAUavo?= =?us-ascii?Q?Cf3mpY8lOLN52JWLWhaaqEqET66W6C3gXTLlEKY/Ey4S93ZSeNZZTy5240y7?= =?us-ascii?Q?w/UA1VuEd135504Jq1ZxvGBR3L4QDub/QWNzRvZr+1wFCX/HleM677jNdY8V?= =?us-ascii?Q?XTH+pSsffiOZriA503Uj7/Ujh+v/56gxqa4vNw3rORBe/aH72juGiopwzzYI?= =?us-ascii?Q?0NJZUlYUCbAUE4+puD0z2nbFu7vqCBsbVNEW7zyBP663/O/1CZQroSYdPUUo?= =?us-ascii?Q?ylPas6o9m9iiVxO1ysBOiGju55VDade6OGT71+5qBuD3NE/ZDghCCj9dA5mL?= =?us-ascii?Q?rIzeUY0vZUSqT8ceELQnD3pjHjOIC3cUU7fEpUUsNZQc6m3mDXesJ7zt/Eby?= =?us-ascii?Q?bT/v3ArFovXga2HgL0h1sxumzAEpLlzv6jBpkkpLoQKvGnk95htr47yV9aqu?= =?us-ascii?Q?/fLEHm54HjjB6m32t4hN+Wr1u4kNfyB2VQ2ievWjhXvOElfFSh9buSxetJEF?= =?us-ascii?Q?4/5sV7570F9lMxAId4v5oFB7aZ1+lHi6VtQwEz0KtU8LE6GzvB1cbQWn6S9P?= =?us-ascii?Q?f/+zZKfkf51nOESq0Py8YQmQJiZ/1M2i+USdX1IRgVO4FvKylRTWboL/3t3+?= =?us-ascii?Q?zUthZtoG3PHP9gPnuxNzszwOkpiSpFqwY0yC/JtGTDvldV4WCHbYjj4NCAgZ?= =?us-ascii?Q?KXnPbYjXaGXR/ZpXIVcx9S4Tnsya9xSTa9uoTKZVyDw93HG6cFBy0iqeGgyV?= =?us-ascii?Q?OQevXzytQga3wdp4nXK1O+IFLUO991pvWtA+i2pZi1YWgCBRfChyUqruJP+q?= =?us-ascii?Q?POixs1RbrL6BhLLEmz2Z3F4IzIRQ4f+VCbISrNj7YWZMBpX3SnJ8XHLYHDGM?= =?us-ascii?Q?u63LTKSDsDr7gs6hXMm9vtdryKntCzTCVIuA8V+j36XEXQX0bGiZnJk2+M5W?= =?us-ascii?Q?Sw6aLOynEPyHM8t+kVqCKJodShqxmpFtDlmbwnNUjo6kyhMPtMtR0iBeEPKh?= =?us-ascii?Q?qcm9b3VC1fvT1tR3DixL94b2Y4uEygXUlW59HnGbJeRv9bdoRRyog/S1KsPw?= =?us-ascii?Q?DRelqBXgulfr8oBkX56nMpprPfRhdmr7Rl9ad+eSjusSCVlNQ9SOiqLSBz4t?= =?us-ascii?Q?CldaccQu1f/npzFjn/l3QueLdHrl6zsMiIl4Za+sJq87F3HpVht22RRDjDbE?= =?us-ascii?Q?0FyfLbpbvKvUfFG9cMHkAHniX34b9/ueAYvJWfsNBwsSc2c/c81JVrfHyUI0?= =?us-ascii?Q?rEqCe1pNn6QSwQ17NdIg0SOkk9ti0i1DKIy70kh5vzmxohlob5ybtU8vXQ+/?= =?us-ascii?Q?Z/Foj6ybAarbKAkwhsQvtToUePU2acPPv/TOjauzNiQl7VIG6K4RMje6IbsM?= =?us-ascii?Q?TEKmeV/4FXnx5ImZBUSRIQJgdCcKeKjRGclrA/F0aeK9xRhH/Q=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: Rzzq7HVoPvye+qXRmqR683NuB4VBwKpDkqbh5DRXN3vsl49wdyF/rOJZYwBgk8VUA7If0+vQm84fs9ZIdrPU3e1iZEYSLsg+qoUaq/0Wg5xZ9WiGZZuzx1z0qsgFbBhrjbsscUmpw5LZAz9mFSFq+RnTWtnMlksT+J70cTMH2cv4X92YTJp7Bulta37lBpI+sh6bwI72NFMkXYg2xi7kigGBhRsl9Zqdsp8/Zw2xcfZy2mc24HKiAATnzV4dV5t6QfPDY6QkhDs49hejfHh367dHBDazJ5Ko90qdTxXJ6Q7hGoBdoT3hMSfFqQwHjpz5Iy5CVtqiBWUnln0BpukL5n6mHqIZrPHD+PSyPDET1/r/YUEhG+VuN/g2Yz8PM1/vBxJrtHfx6bBuTAIG4ODjFRrGGTI83v7dlJL2Ihc5ko4/FLuBMsYqMkQq/vW13kw8lZipaDscuQJ/R9D7eJ6OvD671hoLObq3x59QjwgItXRdZatLPbgew5dbC8mRhoAAULpToyryteqCZ6Rzw3KMuSG1S+phiWJ272hQEDV9kg5/+nhh1L9m+athtFd6KoKR1Rn16/4XvtRK0lcG6pQ907j9iCuW6EKbkq/fsvC5N3zSns6gLf5CVxn8+8nmtMkwGcJEzupcgzpbCadv2UNA8e3+gcZMYnRTmwMLseJqIX8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:54.7392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be7b66be-33db-4e4c-a9b8-08dcf92b64d2 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: GV1P190MB1995 X-BESS-ID: 1730324398-302901-12799-43447-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.235 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYm5kZAVgZQMMUizcDU2Dg5Kd kgMSkl2cgiLckozdzE0NLA2MI8NSVVqTYWAALuCbJBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.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 flow 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