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 3A0E045BA3; Tue, 22 Oct 2024 18:57:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F29E40B8D; Tue, 22 Oct 2024 18:56:24 +0200 (CEST) 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 A889B40A70 for ; Tue, 22 Oct 2024 18:56:15 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2112.outbound.protection.outlook.com [104.47.18.112]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zLsAG/T2oU07R5XxvFVCeQEXBoSd+O53KWoiRXbSMO9d5Y2faaN2DO9WV1tnOh/rkD6lXOKhU/Q+21ibjdDLn9k3slt73Ar90UsIyneO7fJipZ7v3yrqE7PqHWs3R70w3/1c5+XPIPeKiTlMGwahuq8XzEaNMvGaxIgPbFh4Uq9+gZO8Fa5lyDKD9Juk3OkYPWHveVKnBj43uMBBv3UYlIHlRGXMqGt4VkD7e9SnZDwfccXP2wqYDOgsNbyHqYIXhT7Fq3lPJqeZ6wrXWUfOEs+Qq6qou7HBa6xVtYLWCC01VNQClPd8F/o3TQZRbhQ3L0h3B8kXf3Sfvn+blJAoyw== 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=KBOG38GXjFrT55fpF3Ro5ERX42Y3o3c31tM2HQOdOO7/LxjDydgO8YYFDgwXQ22uIVZkntRnU58pYq9MaWcNJJCfQiOcCD7MLWSxR21lPBN0zSAnYUdt7ov3WGVR3T0T8cs1e7Zt1AOm/0+NIDTKxNxXlVDKDp1WtmTN/5sOrucsNL5BUrNS2VHwTMlGu0VD5Rb0GdQ8AeV6Bd6vLY/hRPx7gVor7oQvGMDtFEqcnS1GOHxWDsCGeKzBlv1XqqKj0qtqSqjRZVOmTQh4t3m4/k2eBtLr3D3sIp9O6HgTD8V0ftQQyemvjTp9BHMlLoRPsZ4iha95xCLeSLW+UN/hFQ== 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=YkuoY8+Tj3nqmBNEbda46N2ItSt5cNc6aIg/YLX5G4RHtFtUjvax7wGCpJ++Zv5RSW6iErN2xpdveTqd0pMuZv3qvM+8ZS5qorNorKAzAU6bkvVgk8f380Di7gSQmzuE+zAruijhmozjXBeTHXhBhi0qE0WJCG1PluYmIHcipQ8= Received: from DB9PR06CA0008.eurprd06.prod.outlook.com (2603:10a6:10:1db::13) by PA2P190MB2102.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:40b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 16:56:01 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::ba) by DB9PR06CA0008.outlook.office365.com (2603:10a6:10:1db::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56:01 +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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:01 +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 v2 04/73] net/ntnic: add internal flow create/destroy API Date: Tue, 22 Oct 2024 18:54:21 +0200 Message-ID: <20241022165541.3186140-5-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|PA2P190MB2102:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: cf43e356-8aa8-4862-5bf4-08dcf2ba68c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WYZ+Ct+3gsctU329co980tHKHnl91iPHxz73hewKlD2uzjrqwLp+dBUYxTE/?= =?us-ascii?Q?w2AlA+ROHPr39G/Bz2ve1klK7KAL7XCwSpyBFZlR82R4Jb9nBhoNc4QrbRJL?= =?us-ascii?Q?5QJ2YCqGFKwSB4FP7D33b/7J3MqdfVrKAiTpHWzSzsT0KuyO9LAOfGdGe64K?= =?us-ascii?Q?zAguon9Lox95vD77X+Ws8N15fXqeKP+1iIik9FSBdck5c2LBMKzbyGVbBOHg?= =?us-ascii?Q?liw2k3hXxeHgWhs/WIcfYqTWM+RPb2Y7Mw3cQvuLgNWaAdqy5fRbwnWAnbFI?= =?us-ascii?Q?rNJwbQssQYRzWd25aA5y77kfnFIZiurvEeWvq17oJZ6UU5slFjlS5BONN2OP?= =?us-ascii?Q?a0WnjZj1gWg8/9T6J2JHzvUYT43dii9JX8uBtN+EWvbVnC2nticnDrMe4Yjp?= =?us-ascii?Q?0Zo6i/T6ZjYZR1qG5/fkPZILrMZ0feTIpv2VdbLoyvaGVPrqYHfEg6DkuPt0?= =?us-ascii?Q?ZG9X3KCl88/9+2MpHc1xpaPROf2KEBR2AUdZV7hDKogryiyzHxnRgBNRu9CE?= =?us-ascii?Q?EhCQYBouJIsPjJPgfKNVFazRX6xi/yfo030jWd6uuwtLNKyJ0mugzpH8lw2F?= =?us-ascii?Q?VwVAzgAEegdX6xGSLnzaNQ+aPTHzj7zouOLd6KhOq48KSCsO+iF1G1+Iw/9+?= =?us-ascii?Q?M4K19qDIE60MuoegvMQH63IgjZIbdmW1+5YcKV+H4FqGag+Agu7x8Y05FUIH?= =?us-ascii?Q?ljkZ2uzIzE9QaoRNqJcmsN6allsRSBYbb2eE2SuEjsxxjliyCu3vTcqDozKC?= =?us-ascii?Q?Cm9aFsPxFqWjwKcZoTEkOeRs2Hyt3SDDP/+mTeGhCk8ta6F8j797zkQMlCIF?= =?us-ascii?Q?jLqOkWEhhCYpmN+2+zBKXpJDbSr8MdBjUymXdqvFj4cDICU5QVaAqOt7D4/2?= =?us-ascii?Q?QD954SOLtxftFdcmzMATPGeTlqzzkPD9AsNYaFKfGqAA/4skFgPBcMNgThml?= =?us-ascii?Q?xrpGvzOGxWheNJBcTP0Vxs6rHCIu+Z8W/R+DTdnd4Q6G5r/4FZzl0KxbbjIR?= =?us-ascii?Q?THmf+2qVfrpIZ27IGGsq4arnhaQ2mLLSJ0S2lN7acsgeZymJF14kAXWqA1zl?= =?us-ascii?Q?prXP4MRbEIbjk9H7Z3QtO0maDF39cl4mrocM7GjimAHdrFIaEUIGyUPQHSD3?= =?us-ascii?Q?d2FW+SY//a9uLgr+Sgfht92Je4y0C44628ms2ApffVIr7vLRoHnd3sZeSHbh?= =?us-ascii?Q?/CIHa6PnOPJwldFiqhRlR7HKapXwVp9V92Gg4VWkn1MnC04lmd+gEd7SnF1V?= =?us-ascii?Q?9NvNJ8l3ZDGhV4FKWXVaYzffty6H9w02uqVHnviYFdDDtaW2kzvH2AkZf7qZ?= =?us-ascii?Q?nyYifn7EMruam9032IUg5rjb/lTVnVArecxiK97FEYECUrMeNsqLDSa/bIB2?= =?us-ascii?Q?QUMk506ren0gdw4fCLLGQUCXFQbQhg19gEA8QX3WM2c6Rk4tkg=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)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: hN21BxDRVMtlExxvbfSl+3Ud6sDlLGuqcqJZsNeahoz6Q+YDLFUxyLTJO0io1hZS5GQR1Y9DiWghWWyMmFxQ9E2VFzQfzsg7dxp1N9GWaXDSiVLRo1hDFEMePzTr9vxusM3VlX4IAEZ76XxFo/3Sb8ZSnOG9ugGm4otO2NPSKit41GqU1g7901uIuDr5pvrQv1Olbiw28sFEvrjOi3V6SZITy6vXHkbaIKHSxilc78VCUs3yK4HqQAnJ4TsApjxisvQYAeiFmerWoQQiiyf8G0Q4kketIT+zaHooi8P2TMOX0PgrJJhofoVPb5FQfH/zHAdHEAlNBXl+Wn3HxogMj+az5wF+xkikSc187Q4uOWt/zGkyWH9t5YmdBZIhEbZrTR0swbObuAO9+vzoLy34X9FLg9TC6WTNHyqX3HmXiZrqKbbpyIxd8kJCo9SCUBGwc5/gX1qpIdx3/u4vhSpmd7pMM0LeOV0dKfKfyA8IZUVcQRX7ZQZCHxa916XZ0QqWC/M23ZdNy2yoqdw7YIGHOwMJiGgfknBS1P6rwhLPz1o18pHLPKo4/svq9EyTCRI7feUDkdOJdfQU9l/rEBWrNvsSgMY2vvMaj2rkhOTn9CWZooMOfX95+8vBPzAFG8kCWb+IY1GOcX6yjG41SYHoOTSg36IKv3z9awbIW8z7WH4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:01.2624 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf43e356-8aa8-4862-5bf4-08dcf2ba68c6 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2P190MB2102 X-BESS-ID: 1729616163-304983-12654-14368-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.112 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.259902 [from cloudscan12-62.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 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