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 938A245BC0; Tue, 29 Oct 2024 17:43:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 207A042EDA; Tue, 29 Oct 2024 17:43:07 +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 6392142EBB for ; Tue, 29 Oct 2024 17:42:58 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2170.outbound.protection.outlook.com [104.47.17.170]) by mx-outbound12-25.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:42:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z9E0SqAVzwIgUs9OULNmJARYQEjiGrUyIsqg1ryTjThF8Q56QGArDsnd8JAfTOvL/zzpT/yxv+VnQijTv85yQy94vV9QXgILM0Ap2hoi7fkTafQFCOKvBS69U96QGqxH4C3l953pMEd4zQgAme0oB5+/q39rz2aZiv0OpBEwPwJ0tALXhU2RcjTSF89wb3x7uLHLISuK0XorxuaLKQrwFRgvq65E8b0L4/ydvh3q4SZApqM8mvZaSx8aQUe8Ef4VPSpEDcCRYQB7B4WqiqmH39gw/QTz5oOzPTDenqMmKPm/n4S/xO+5ExtGgrM3Badjxri4L1gSKP8o6jJW0qukmg== 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=2Z0TKx9BCIc56PcqQyuHWH0layhoKQUWUFeXa+RfD3I=; b=MSwqwQMUB7N8YNqzpsByBoV3veEJ+1nLHB7CkY5EKSf+zWN0lWsh5sriTO1nUeFT5vLayxAtXRUDsPtbu+FHp5V7komkW4Xqnx1Y6gIKnw2Q3pjXne4m//P0SsXR7n2xyeRpbj/8SY7NrsuyruNTDhDdtRGoBiKUIMZgLycr7zvqaatXUpbBh1uMuzFfAFtgo6rsnRDhrMkHtNn77MeTrMsuFUHNbyZufncpWZCK9lWxQkSbdUVD3apAFQeFv5nYXzBP6gbo+vGolaPdog8aCLt3Ot8zKjEl08dhhF2YsXJyVQ5t0zdXleS4wpupkLm8xetrM0lEhNG+HAorR7Bduw== 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=2Z0TKx9BCIc56PcqQyuHWH0layhoKQUWUFeXa+RfD3I=; b=I6xfRVJ4CRDcHm4I7fQPC81YppooMj4rygKL5UsT8p8LAwagWNF4rJrYWf2lc8fnQ/4AY6kTQAM1YkQxlfi2hXuzJqED8cPiqlvg3J7+MFwFSNQqSsbi5jhHvTgNpUa9PeUOGxDAdUs8fE+FFfe92hubtNxIDZI83ePTOhmx74M= Received: from DUZPR01CA0191.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::20) by DBAP190MB0869.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1b0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:42:51 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::f5) by DUZPR01CA0191.outlook.office365.com (2603:10a6:10:4b6::20) 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:51 +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:51 +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 04/86] net/ntnic: add internal flow create/destroy API Date: Tue, 29 Oct 2024 17:41:08 +0100 Message-ID: <20241029164243.1648775-5-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_|DBAP190MB0869:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 86bf50a1-f0bf-4e0c-097b-08dcf838baab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026;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uM4ezB2R1hOegdrIVjQ6qPVo+X7PQn29Gf9+tvFn6khp8SHx?= =?us-ascii?Q?D9oW2ULjk/R61CDC5vAmMPTv8bs6hiSZluOLrUaMGcTUbcYGXQB7nG+Q58KZ?= =?us-ascii?Q?zfPMmptYRdCLK07Xp52IOX0Qhaz81gOsZPAq0f13RZegDas+pMFGGWLFYSuJ?= =?us-ascii?Q?7eiD7nj4rkUZZFhe9cZRQ9HaX+7+Yzb6D0hUJjXZ/SP2GH7fkgMagCQVex9Z?= =?us-ascii?Q?NEOWyPmHtfkoEDTt8xNrcuCA0pkIuEp0MVGHTpPmcF0RwbkVlOXJcGkeH/bl?= =?us-ascii?Q?Pon2dKX/Oi5jwF2H1+BUK5YZ0CuvcsbynayEM18EVC8LoitJPRMouZ46s9HO?= =?us-ascii?Q?AeVILJGQaTpN2KUV7rJdju70/IRHEj1t/JHgszt78Wq6wC6CF7G+7KHaJw23?= =?us-ascii?Q?d4kU6OHnM41DC6MG/Tl+NhCIK9BkPY0ErNKOZEJ6ibH1Ro0I7/ZVdf/ta41s?= =?us-ascii?Q?GhL8M4leygc2bAvn4PS6yzKknPBuREWDyl7rM+AMbBRtxjmN2ZUblSLipDuY?= =?us-ascii?Q?zgKLAO/E16UqdIphqXJ9cFbDgvDFUPx9cbGjQEY4rISmudfoMA=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: OA0KMBpNhNpAETbccMZ3gucrspv+mEEege6fdcktx4wMsDSEzSNLqrNrG+DGVvEjfblg//8AZRwHoZFjvdoIiJN+gxDnJUPAjSbjMXzRlWcIFEiJQlYuDu1RRkwIBU/FaTHSH8wK2RmyTGCypkRaGkhrbRzHbf2eyN7Q0owoQAchLwbJuDzWCc1KZOCoUbGWELN9aQ5CfmCv2QTalsU6/pbOt/dhe7VuG8kWOPUZ0H2Sl+gFD8GqQhQCjqSzIife2AsiopFmgNPEAD4mXJEMEfVz6AhjqBz8sC4C6LlImrjOBldUwdG1eU5TItC7n+B0Gap/BEjcXF5aAZiG0drWj+V3IIlySzDh1BYiFLRsFkr0Kvt0NBQqHxqk9pz9mxAzM3MdR0Blt/aaG8c4tIoNXtIr2d+DCr0PsFWYEFvpJCtXGtGtn7c3LRtdo/Vw0PSmvBPhrTxdbVDR2u+hksfjgJLF+5RUX9BdPRILPpAnyRz3GqNMbLpWIGqOQsxJ6sQ2YQ/hoVfLuSX4iRugemBl167SJeLVj1ae0nq7X231c1XXpYRI9XAF1WNGyGcbRUCYMJlLxdLCk8GAkmWOR9bQQktJt4xxrKCCg2Yg2Vj1EDwaROlMmKhmtIiGfielW0ORulLH0Dxc19VGblVi/TCzgTMN403htEid88hcO5UHQG4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:42:51.0739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86bf50a1-f0bf-4e0c-097b-08dcf838baab 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: DBAP190MB0869 X-BESS-ID: 1730220175-303097-12767-29293-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.170 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZmFkZAVgZQ0MLE1DLZIjHNON nMxDg1LSnN3CglKcnQ2MIoySzNJDFVqTYWAKpeF85BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan23-168.eu-central-1b.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 NT-specific flow filter API for creating/destroying a flow Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 39 +++++++++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 66 ++++++++++++++++++- drivers/net/ntnic/ntnic_mod_reg.h | 14 ++++ 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index f49aca79c1..d779dc481f 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -117,6 +117,40 @@ static struct flow_nic_dev *get_nic_dev_from_adapter_no(uint8_t adapter_no) return ndev; } +/* + * Flow API + */ + +static struct flow_handle *flow_create(struct flow_eth_dev *dev __rte_unused, + const struct rte_flow_attr *attr __rte_unused, + uint16_t forced_vlan_vid __rte_unused, + uint16_t caller_id __rte_unused, + const struct rte_flow_item item[] __rte_unused, + const struct rte_flow_action action[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return NULL; + } + + return NULL; +} + +static int flow_destroy(struct flow_eth_dev *dev __rte_unused, + struct flow_handle *flow __rte_unused, struct rte_flow_error *error __rte_unused) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + + return -1; +} /* * Device Management API @@ -604,6 +638,11 @@ static const struct flow_filter_ops ops = { * Device Management API */ .flow_get_eth_dev = flow_get_eth_dev, + /* + * NT Flow API + */ + .flow_create = flow_create, + .flow_destroy = flow_destroy, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 74cf360da0..b9d723c9dd 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -110,6 +110,13 @@ static inline uint16_t get_caller_id(uint16_t port) return MAX_VDPA_PORTS + port + 1; } +static int is_flow_handle_typecast(struct rte_flow *flow) +{ + const void *first_element = &nt_flows[0]; + const void *last_element = &nt_flows[MAX_RTE_FLOWS - 1]; + return (void *)flow < first_element || (void *)flow > last_element; +} + static int convert_flow(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], @@ -173,9 +180,17 @@ static int convert_flow(struct rte_eth_dev *eth_dev, } static int -eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow, - struct rte_flow_error *error) +eth_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *flow, struct rte_flow_error *error) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + static struct rte_flow_error flow_error = { .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; int res = 0; @@ -185,6 +200,20 @@ eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow if (!flow) return 0; + if (is_flow_handle_typecast(flow)) { + res = flow_filter_ops->flow_destroy(internals->flw_dev, (void *)flow, &flow_error); + convert_error(error, &flow_error); + + } else { + res = flow_filter_ops->flow_destroy(internals->flw_dev, flow->flw_hdl, + &flow_error); + convert_error(error, &flow_error); + + rte_spinlock_lock(&flow_lock); + flow->used = 0; + rte_spinlock_unlock(&flow_lock); + } + return res; } @@ -194,6 +223,13 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_action actions[], struct rte_flow_error *error) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return NULL; + } + 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; @@ -213,8 +249,12 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, attribute.caller_id = get_caller_id(eth_dev->data->port_id); if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE && attribute.attr.group > 0) { + void *flw_hdl = flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr, + attribute.forced_vlan_vid, attribute.caller_id, + match.rte_flow_item, action.flow_actions, + &flow_error); convert_error(error, &flow_error); - return (struct rte_flow *)NULL; + return (struct rte_flow *)flw_hdl; } struct rte_flow *flow = NULL; @@ -236,6 +276,26 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, rte_spinlock_unlock(&flow_lock); + if (flow) { + flow->flw_hdl = flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr, + attribute.forced_vlan_vid, attribute.caller_id, + match.rte_flow_item, action.flow_actions, + &flow_error); + convert_error(error, &flow_error); + + if (!flow->flw_hdl) { + rte_spinlock_lock(&flow_lock); + flow->used = 0; + flow = NULL; + rte_spinlock_unlock(&flow_lock); + + } else { + rte_spinlock_lock(&flow_lock); + flow->caller_id = attribute.caller_id; + rte_spinlock_unlock(&flow_lock); + } + } + return flow; } diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 457dc58794..ec8c1612d1 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -242,6 +242,20 @@ struct flow_filter_ops { int *rss_target_id, enum flow_eth_dev_profile flow_profile, uint32_t exception_path); + /* + * NT Flow API + */ + struct flow_handle *(*flow_create)(struct flow_eth_dev *dev, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid, + uint16_t caller_id, + const struct rte_flow_item item[], + const struct rte_flow_action action[], + struct rte_flow_error *error); + + int (*flow_destroy)(struct flow_eth_dev *dev, + struct flow_handle *flow, + struct rte_flow_error *error); }; void register_dev_flow_ops(const struct rte_flow_ops *ops); -- 2.45.0