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 DB76945BCC; Wed, 30 Oct 2024 22:40:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BCB04341A; Wed, 30 Oct 2024 22:40:14 +0100 (CET) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id D18AD4327C for ; Wed, 30 Oct 2024 22:40:02 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:39:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wpInexilSEnn1X9pnDS+Bo5ugqKERc2tfAOlDm98QbUiZVMe9l3jKFOyEtqCvLCvI9/C5WxgIZIN5LUF7zO9E0ZxTY2G5H0HuyAZcbUQhYdtHabIUdr/QRIrlEtIxiv4IwRiZ5Mdo9J72cxYJXQUvOEe8zQrAvPwpOH5PD/xRoSaO8r9ZpInZAiv7N6DM3sECZjeJRrLlCF7Fj9FtNpMhTtZDtXVLt76LiXb7ic/soNMX0T7F2RunZy9etPXIIx8ZCsD1htNclcAlKCFFPs2XveP0aZUeLT9loH4KyzPb0Sd5Z5IlZMU/vbEXLexVGihXi9yZc9Apd1vdRdBBBLYmw== 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=uqg0DeA27PrwyteJ1FLoUoSxCiLLLKnpAcGKsB3n6hg=; b=M69bFbguQxHBXFKGM8MTGB85jQ4YAEEibBWoYVJ6MF0V8d0LBeusaF9OnV8IOdRuT0067Y3n5qq0o0E3+2T6m8tVOvXg4elImhJEfQg/SteLmztf+paCfFzcT8JGfJfKrQB+gtEwdIRJd5GICuuQMVRegaSnch7gvrmF3o2DC+NJWts38cuuAH0cl5LJYHzLOU26UsydCtxR0cxNe2B1ac/uzDm4+Tkw8LzYREcwAKdaDoTwWsCZRXTcnhcUZ0VIPKpUiW9M1bF5lZmmB5ImRZGWxvqCE76T6bOwvDdmrM9+zOxskg2uSP8tjxJI2jvGhvhzm6yRnbPM37L5GrkhoA== 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=uqg0DeA27PrwyteJ1FLoUoSxCiLLLKnpAcGKsB3n6hg=; b=C0lDkSQQ6gvULyjPMDHKc7gZs30CiV1ydnRBqNTsWI5buS0kFnQDOEMIzXM4wBrgKYu2wy2ji945AE1kKhxTFdCV2hSQn1O3cYDBo+BQHEgrtfhEcVyY2Bn6TBLn98IkVWQm4/GMJDXOM9698XOAIbi/TvfU4JEgtHDxsHuKcR0= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by GVXP190MB2148.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1db::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:39:56 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::5e) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) 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:56 +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:55 +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 04/80] net/ntnic: add internal functions for create/destroy Date: Wed, 30 Oct 2024 22:38:11 +0100 Message-ID: <20241030213940.3470062-5-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_|GVXP190MB2148:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f4b8fe1b-eaf5-4896-03d5-08dcf92b658f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VHA++OLSzVMvg//5//ZKYuUmaA+nkH39OqWUEOWC62J3NzzF6XV+jzQRBVeO?= =?us-ascii?Q?Eq3tZzjcMLd5bVm6rMmAglKlzdOMFLKY94LOzTDHLH6EIovQuND+Gj5HGHq/?= =?us-ascii?Q?NDE6OiYzZAXNAW1gG0kYVl33xfvQVpi6n/THYCiQYO5vkQxrsLW8Ialo1izd?= =?us-ascii?Q?tgT92YFBYJz2foeCJ4JsGNR4Q49K4wVTvbHVu3T0kBa2QFoNlJ2I/dBAc1rN?= =?us-ascii?Q?C58H5TSNyMeRTVLsR7CMv2PXzf6/4O++oFAmbygFg6jBW1ImzfGb87K2Tpo+?= =?us-ascii?Q?Ue7GFC0acoJlYpMM5VkMO/xGHvL6wMVg+G9Z0rgMjYB/NC6g70tmfYPN9VP8?= =?us-ascii?Q?SQCXwbgiVJBMv6DZiS3x25jfdU2I4sMvCWB1WHmyVknLex8CM0mTqh7xtuSy?= =?us-ascii?Q?rnlAYxDhceX1b9trZlYeN7RlRMJqvxsTTnQaqLzcW2VDOxguIhnqDnFyMB76?= =?us-ascii?Q?9CMl7qdoDA2wAEk+HgPa+t4zm38MS3aDe08kENXZ4yK6W2PtTeA1h8+OzjRH?= =?us-ascii?Q?6Xh0SJH6IdnSdr7/Grp79iK6p+Twli6zJ81y+n2cdu9lU5++lxjUmMiAkvgj?= =?us-ascii?Q?vsHPRIL0+UMAxcemGpFv5YinFJMYihr47VW+47Oeaz3xYN9sUASp1s5P4Ine?= =?us-ascii?Q?kKEh7PY1Cp1uD7ON2Hrn6Vc9gtAITsmczaEq1oUV3310X323YBNH71JFkhpH?= =?us-ascii?Q?2AyWglofsSPGkYCvjp8XjhvLL9u4XKAM2KjsbbPpfmKiOTwAcHZthr6vVkNY?= =?us-ascii?Q?RZvdf+XX2KJ2KuTO+YXH6gxCmx8Q/b83eejg4Vd/P8woN2mW3DslMonfeKhA?= =?us-ascii?Q?g46efU4OoKv55Kb0vvLtJYoaAhpVmKmgPi20FdUCkfzyWxGHR64J0iG7RKiK?= =?us-ascii?Q?PUixjd65JXouQilIPI1y9ROJUxNY2ulMYs2Eukj5fOMoEZY9ClnzYBv8ZkxJ?= =?us-ascii?Q?fyM4yWf/vG7LMZE5b3bson0gyxg31dihf6pZMcgQ/oHMya/NOo4LodmzLYZy?= =?us-ascii?Q?cqBIp6O9jYvp2/tBleimaSes8BqT+13USlTxv3Wh8QXqbT0LRkBXFPlNkJWO?= =?us-ascii?Q?kGQ3EAS3pr/OlEF5hW1juCKjLHQAy2DEXejm0vU7lLMllWRAP44Bpt5nukdE?= =?us-ascii?Q?RfutLQ73NmYi5r/0rMqkQq6wiCvO2airkb90cASfK3mWEzRsudlp97/SwiuP?= =?us-ascii?Q?x+TFxXWo5lfr3/2Yv0CMrt6HQkCOuwFNEnIxA3GQMBOgKsRK26JdUow+kbaP?= =?us-ascii?Q?OhycHfDC9aiFCpAFnGAAJZF9RCKLSG/M4WY/cFLSL3AAf7Bg4t9ylbYFUlNt?= =?us-ascii?Q?k6RzODP0j1I2c/B+1AASlK/tI0SB1Uz0IqINv8Eb4+uEMfNAUY+oQglCk8KK?= =?us-ascii?Q?yMF2MDFTaTtCU/sfkWwXhsnjreXYRCV5EfTML16889Xa8c6Kiw=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)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qLfZirX5bBL1LI7LaCrRUxsKXJAFHAiftFsLBR5Kee1E8XHbtQ2OXKjZ4O1X/hebNm3eoo6vT06835z4T4Pd9ZZ8eLGN79xJ4ddEnlhGlFKZ8t3uu2dGLwCTLgq9fDA7CrtR0NUFeK/IESntf8sXzSwI1QpkJhuC54V8LWQYdRI37lRoGeMAYI+QQttMDbDJF9mDlUd3V/t1XiWeyF0cl17bqYu7Z2b2lLsB5+Cx74Y/g/etIAxJejTL9q5aCOyHlBrSJdUmMg5pDutd1gWw8LjQ9eLdkhfO0KU6CMnHQoqyhPxhlIjlqr0II3QEel+x2pOjyjYV9sdRto2jLf0M+adL8bw7zVs9H3m3uNNJ1MT6rojTrYQRKOBy8Nzuh5a59FMpKpmk8M6y7JXsBs7Xmsq1gzNsm25pBM0SAfhpVY0YucvB+oe+joN3Zpi8AXIhMhFJHA1NMcsxEQ5l9ihGwp+ag9VnKc089vPQNNVXXZ71mQt31TnopwvaJfkGzPFNzTKFtPaeAtL/Vg6cc6MUoHEnvaIOVjpb/WVUa5xRAZTVsyIOWc44hzPa1TBpYJfqOEjAnDVde37p2RiQNib5RH194chIiDm50NVSs6E9smmGUHfLJkmyvTUK2ucPQnaEBJ4nBHJ1k+tPMwvclDcZaxO42GTP9uWq7yJHJ3yRiqo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:55.9892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4b8fe1b-eaf5-4896-03d5-08dcf92b658f 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: GVXP190MB2148 X-BESS-ID: 1730324399-304433-12638-44607-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZm5mZAVgZQ0DjJ3CTFONHA3C TVwsIy2cTQwDTZwjQtOdnCwMLCLNlSqTYWAOHJz8hBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 functions 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 7716a9fc82..acfcad2064 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 @@ -572,6 +606,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