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 8DD1345B96; Mon, 21 Oct 2024 23:06:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D937A4067B; Mon, 21 Oct 2024 23:05:45 +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 1322240613 for ; Mon, 21 Oct 2024 23:05:39 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2110.outbound.protection.outlook.com [104.47.11.110]) 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:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CLL3/hi6315B/d3vhE0xEkxn2ATtU2OVH8+Rqmj5H3HEymbA1R4JjPSp699QVi2Ecl6W2cojDUzP1cqF5X7wJo3YtILMAMtyxWTmKae0icAFQrABr7aNA8ltQuqIr4ACfMdiT6/15Xkyf/Rg2mnjotqqM7WJmir1FCPh7WCrCDZJTn0uLrM6jwiXOWrXoeucOLyamFEzH7TyWxID9QxQYGEFrowMhEZDeNfDDXgSxLK/PwMEBokDuhc+7Xrc+6UsuEGzIRRpQKhxVn+/KjmCNMRllFrQejf0642GjNX0ZXdJQLcuhKr+GaCx5uJooqd6+OIgfFj7RWK0w8FhJH4+XA== 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=1vfpzqXUi0TAEPg23Lof2Wc1b1Z4SF0l7lszzwN3D1o=; b=k+XSWMwdsFk6fX8uejGnutKYLtDF6Ij+SalAsgiWuFwI0XU/L63tP28HulCL7DLJgsuHAk4zGh+JI+mFP9mHSXoBRxU1IugsKmtKIrxVLi6ny3Pt3wZw0JfGszWzt+9xhY2OgzRbbU8BraNv/IdkiZ0L7Nx09Yxqgob0DWZsM1B5mCDDXhqwvx3NJlVb3kGG0V/vYSRzwizJD1V7uyUjU06RuIARDwnrwbhoU4wz86n9EmC6ij93WRNbJNQp2WIis96TIHai7MvK+dTtMO/EjKtzwCZ1yKVRn0anDK6IJHR3K0pbHGJ+duSnKvpS7lC9V5f1Hx582QpnnNnMMkvhfg== 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=1vfpzqXUi0TAEPg23Lof2Wc1b1Z4SF0l7lszzwN3D1o=; b=GARNXosQy+Xj2bga78AyV4g8DESMLSv4D6MCknM3dAF7UqAMpQoVBLzg2Tm5McWq0TbE+CfZ3Gu4++ixWBXZ0Hxzo4tt+yuH94D3KWFdEZ+zUrN8taOIcmVbaDGX99cOczQE7EJMwbb+QHJbSAEB6WM1DHxisEhmzOG1NfviO7A= Received: from AS9PR04CA0142.eurprd04.prod.outlook.com (2603:10a6:20b:48a::16) by DB9P190MB1179.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:221::16) 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:34 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::38) by AS9PR04CA0142.outlook.office365.com (2603:10a6:20b:48a::16) 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:34 +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:34 +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 04/73] net/ntnic: add internal flow create/destroy API Date: Mon, 21 Oct 2024 23:04:06 +0200 Message-ID: <20241021210527.2075431-5-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_|DB9P190MB1179:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b647938b-2b93-4246-5c33-08dcf2141aba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tSwmx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= =?us-ascii?Q?qc08rlaCYe8mKCFW06vp1Om+v3/SiDj+I6yzgvLm1Y6W73btgdSzcDyPfshu?= =?us-ascii?Q?dSAV4xNjAV7NGAbcRfkmX4BjDo3u/rHTiF4w463NNYKsC3CyPg/oUCWe38fQ?= =?us-ascii?Q?xmwQTn8GWOoUKkMxP9cvSUOwtixq2foR/6498e6tGHjQYPmJtAfqHg+ggWSR?= =?us-ascii?Q?cz+swFDF5Rujzr99GaHSfzlgBbs8kfdcbE6fH+DdPFjI+p8QFeqIsDdkdK20?= =?us-ascii?Q?AWCY87+bvxhjnqNR1/854J0e0yyWuUr2npmmktuhabLxfBL/khiK3TUT0mRa?= =?us-ascii?Q?IVZkGApo0x4JkpZ/GKieu1OSgK2MKDsdaBnhlnW7AMZWUwQebRn7yXC/W/3o?= =?us-ascii?Q?xJD2+DA2ohGuI3G+FZ+uP4sLgqYxQ8FTUAgFJj6d9hk59R6+gCgHPGL6dmOZ?= =?us-ascii?Q?LvZ7968fyghkpHvD8xvkWTDk+FaQf+6Hhk1b60Qxz4JoYhk8AHlLNQU/M8Iq?= =?us-ascii?Q?mPGU4lr3nBtYmMsqiuOlE7KFWwr1BoI7UOyJz4oxYGyw3kTFjw=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)(82310400026)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NTkc4xm9a5BfWb+loAwQDF3AYMakocCkfY4rjGrCZJZqAtx6hdpfEqrGALg+Z6HkCbb8XKQ8JQIbY70xHJOt0Oj8PwJCgVPi1tp1jQoDEi3A49g/fr0KLJZhbw9qwe1rDlz6Str9/dNRTQeL24Pedh6C6igjCa2UdTf3INfW+yzxTdRA5Et6q5x+JIgq+612ZkDz/VBcg+Yf+jeRgn3J8QAL4Z4ACXxOfaYpdrStIsfTnzrViUJFEHoXhZFaV9/huyZmOq4tWiwNkZ/B9ZX8gdlCAIRcFF6mFFFuJvTPjhYkQqi+8hrJSJjGUIb6VtqRl2tmtj7/1cJt2bvxYyQj4tXzjHQoPV8MwIbpu/mESM0+vqAAi5puokSKg1AnHcYo9W0s9TOgjJjKLSXkB+v+MxvSqcm3i8B8fIId96W383KmyNTeUpd35+TCMtlSdauMAwNa7vHGJH+1vI2gaWbxueXhWQ+d6DXZmAl+z0uNztrAVz+LHrX5G2/6BwQkGO9Zu/XksOZ1Mu019wYpBBPPzLIQ9qfDjIEh1qKqB5D9PNH48+uX5O69JO6NCj24oHBDJ4LlXMciHc3pPlmbPqhfH0sOp4DmKKB5cQDLg+7gzaKJwzo+C/5ELu+7crCPGONpJfMDTcQ7Zd9zQ/FsmLzJGg24a2/AxuDgjIXK5YvMV6U= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:34.0050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b647938b-2b93-4246-5c33-08dcf2141aba 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: DB9P190MB1179 X-BESS-ID: 1729544736-311938-13026-41137-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.110 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmamJsZAVgZQMNUs0dzUzDzNwC zZ1MjYMtUgzdTEIMksxTzJLNnczNhYqTYWALv4wB5BAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan9-212.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 NT specific flow filter API for create/destroy flow Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 49 +++++++++++++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 63 ++++++++++++++++++- drivers/net/ntnic/ntnic_mod_reg.h | 14 +++++ 3 files changed, 124 insertions(+), 2 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..776c8e4407 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -117,6 +117,50 @@ 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, + 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) +{ + (void)dev; + (void)attr; + (void)forced_vlan_vid; + (void)caller_id; + (void)item; + (void)action; + (void)error; + 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, struct flow_handle *flow, + struct rte_flow_error *error) +{ + (void)dev; + (void)flow; + (void)error; + 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 +648,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 816ab0cd5c..83ca52a2ad 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -114,6 +114,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[], @@ -179,7 +186,14 @@ static int convert_flow(struct rte_eth_dev *eth_dev, static int eth_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *flow, struct rte_flow_error *error) { - (void)eth_dev; + 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" }; @@ -190,6 +204,20 @@ eth_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *flow, struct rte_ 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; } @@ -199,6 +227,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; @@ -218,8 +253,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; @@ -241,6 +280,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