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 0FD2E45BC0; Tue, 29 Oct 2024 17:43:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1E8542ECA; Tue, 29 Oct 2024 17:43:03 +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 6398E42EB4 for ; Tue, 29 Oct 2024 17:42:56 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2110.outbound.protection.outlook.com [104.47.11.110]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iSJ0q5yNR5hqHzLuZ08OOfQVsEB6qJBDm8QBbyu7Dbec4ppRLkDw3vHW/YIIF0zHFVYr79hAOpfJFao53+aZIDupOHlmxfOsg4/EpumcpAazSvVBJvqak531bGX1YYIL/5NiuCNk1gqhvcbQXu7a8+oU2xVGb4CPsdYKZmV1Gmxpgk92bTfI7TNeJZFSze7Al/BBCFYbgg6JP7Wsjz6kbJhescj3+L6hlYgpKivCyFetVsUV8BLlLMj9NXNjW8C4rol3Y1EXq+po8xpLHXEbMEvaCaWzS6B8WNpux/EcYP/G2Fm0lTWXPg5/eHI925DHHppErJ1WUdYN3TlWRiVIMw== 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=yet0blS3UjyOgBoI13jCxYteIbP1sNsBYRrwACcw8qTPEYoBMPCt2+1QGblATlzDBGH8gxItc4d6khTXmO3bE7PNjePUhIA+QHT6WGkQRqBSunztIw+CZCJ/2Sir2JvDYl2nXsGPZkmpIcpeWi0mYdbWpedCTk2DQCZIO8F1lQBynfBuZayJbXEgeM11K9wUufj1wyOVotBdZnRdGSau44nsACgZzWG/xp2w/kHNatF4S9Clm6agR4sG6AwH/4vX61vTrhStKvAGCpUJzA6OGLQ9UZR6aFUUqLAtCZwXay9SpEij6Bw+cci/C72lHK8RMwnL5LWHybr14mEsMkhwsw== 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=LKgwIhzju4bDIbdnsLGJtWqGZSxPwxBWUKThoLCBOeHURduGaCQULVN12mB5U2kmJuBixl9GdHxtWu5CypboxvnC596VL5XeIeprWn8B0xn2hwO9KJmiohdCNbHKSRQxpS9BLLZ9eQ909oOD+ymLlOzXUc6YRfd0nrCEp1y7SzE= Received: from DUZPR01CA0197.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::11) by DBAP190MB1014.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1ac::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Tue, 29 Oct 2024 16:42:50 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::96) by DUZPR01CA0197.outlook.office365.com (2603:10a6:10:4b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:42:50 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:42:50 +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 v4 03/86] net/ntnic: add minimal create/destroy flow operations Date: Tue, 29 Oct 2024 17:41:07 +0100 Message-ID: <20241029164243.1648775-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|DBAP190MB1014:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 00591388-0413-40ec-98c0-08dcf838ba38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6PBl7YpKd/EvPEpp6zJcK8qVwMG/ob/EY775c7gV18xAC4GhJvx6YxlRU9ai?= =?us-ascii?Q?jmoxLqVPs4FC7rwQ8M+xxZDtNgvut8ZKY7xZbqQ+icO26yUPl4n/QK6D/IFt?= =?us-ascii?Q?yva75psWt7yFBxU0eshrBwHDM+mmr86VMSKVCwTYH5LZq/iLhZ6L22r4hvM9?= =?us-ascii?Q?Al4QkyU5Miy4XUZMAIYep4oAZSLCy/2TkTZwpkhL26Icq6AaBC5wPMV3QPUY?= =?us-ascii?Q?B+86QcwQ4+Gx5aRKjcYKP1gPa5Rg5KlwwjQ0K/KH+99RtYxYyy5mCdf4JHvQ?= =?us-ascii?Q?n/cDbo4p/WFGoS0YPNPQsQFugHVZn0vzUU5cPkgSYe9FKGtSHG4ZZSHm35lt?= =?us-ascii?Q?E9h/b6uidHr1IzLDl5PnHpeTyxXYWiTEbHftgDvrR/DD1zHRGtQWKOm1XCWv?= =?us-ascii?Q?AJ/rP+HHBDDIwb0ppDaEOTbjHALAprdO5Q0OLxDocdm4duX5osbqUZJngmP8?= =?us-ascii?Q?kdzKurCmaFLd5OWAjjDo4NdVjeepP1BJQvRD2RJzK8PZiU7hvj++LKEWXjOd?= =?us-ascii?Q?FtlSHXjl1lo2frQ5NiCK5Be1pb+kV2SDpfjwtI1lfqlWif4f/w6CVfvvju8R?= =?us-ascii?Q?YfBFaxflIlQknmFARgu55jR+ZMaOFpfFLz/Iobx5WFd2F0HFemSnZ0iffWk0?= =?us-ascii?Q?yL2nHMe4nRWzJhYc8QDry9lHMrzuVzAd47P8yu4b8MpPW9eRjRkPoyKEQ9cr?= =?us-ascii?Q?ilxwf5UdYhTwYqsEj4C+yARqCMrSuBQxbt4IHvm4gR283+tLUOZ495K/izUC?= =?us-ascii?Q?CASx4yHIM2G/7i9eY+zA3vBKG6OHbTjBvo8VdTHA0bOU8PRirix6WSY72oTc?= =?us-ascii?Q?x6cTWiFsgPkLZSC5hj8qQI5cnYMoEJxwoX13Dc71HbmIpQe6ESViIOvxgIpB?= =?us-ascii?Q?1ef7vNA6R0I/XhrR8U3DWByckPfOoNouVIik3qRANLrmIvJfQBbTqS5crL8S?= =?us-ascii?Q?IJ5BUOVh6hobRPSy8Iw3p5mchzm9ZelbA3+ufLQBAPD5ev/bz4auquuCW4JZ?= =?us-ascii?Q?u1vlOVW1BZ8ylTU7kdFWcRsLJse6FJDETCEfuiMp1GKDZBf1uOIqSHnfFZB6?= =?us-ascii?Q?60y90k+5IF0kBMlUUNLICCIUWzVqomtKsalohasWVBYfiM8LVAhYmwCL5o5O?= =?us-ascii?Q?4FNb27OaUU5dvRFRFISIC8Ef8k+siLZg8F2tQHnloWcosGeSILW/IP0C6EXG?= =?us-ascii?Q?ivIx8dssa42Dyxy+mYvt/RxolpiIkFCCXhyP9olowPUjgzjBK5eOSIhhto7Q?= =?us-ascii?Q?H5pD7lqW1uydHGwSfZnoZRqNi64TM5/kv1+BA0U712Ejdx/SObuehMvQTVix?= =?us-ascii?Q?sgXDYlTzI2Vs/ydKm056Z+3RMEPIEYzsPNEV+Kk0jULJ0PPNoCXmfE9YOGDY?= =?us-ascii?Q?GaK3M+UC1FdmXfBnLYP47VhszgRHz3EY1Xgy+RxbbysiCwZlqw=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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VIIHUMxz5GYkq8SfSx2gw2/zyYzrNeaPb2AoSF/o/1UBR0AQjSlHvbpQho0nGfuuQSs/V2+Jbe6XyyWLX76a3VM9UZf/8kKRr9NXRTi+rTqqHkCdRc0Vf8Nal5ld90pIPJ7pJd6HQ6FMIiwq/zRuHmMNZfr2dcVW5JBPtT80Rc0wmVZMuTyJV8vtL+JDjI2rejaK0KBE7d1+DPWBG3J3tPd08oRoM8sOzRm0R7RVV0eMntKSNvf7fyZOqhG8IosGhVDe7FoMUYMj9LFdhlg4yGdZ5+iKRHHt+Hs67HluSJ+85Xe0s15Y/F2CpApo0KH3iz0pVwilIjQhcY6rZaWBpwOZOln8l+UORz4yJHQNuaOL4Z408AEpeSQVlq7RyTqE6tKTLxNPQJSzyvmUS/jHmPaRUi1KOYqzeTZc/MTcV6gWQbIlt3YdEFXXSODuy3GOVpcyFgSJ9XELJfkLnKTHMOFgJxv+uiOytW6eZZSHwneBSMweOkQ5+qNyjXyn0EEdhcyOEQuprj1IKRNkTTKNb8waeTnLPmcLmtmgCrvRAVVCWMnJEwoXBi0jPjg4VR6Si0vDCWp2WayCI0poAzJd7DONFNtVDNy7DXyejR+WzonoC50pI1JPqNQ8nuColyDfLTfjtQbANA70b8uMNrbGJ6bsEuGl4AuF7xLLCNh+PxM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:50.3239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00591388-0413-40ec-98c0-08dcf838ba38 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB1014 X-BESS-ID: 1730220172-311207-12665-27814-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.110 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.260063 [from cloudscan14-53.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