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 7D89D45BA3; Tue, 22 Oct 2024 18:58:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 291F840E1C; Tue, 22 Oct 2024 18:56:33 +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 2C09A40A77 for ; Tue, 22 Oct 2024 18:56:21 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2113.outbound.protection.outlook.com [104.47.17.113]) 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:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BpgMwKUg8c3vRsBSH5YTP3iXWlUAld2lfvmIDiV7LPzOEf3lAo8UzUdtXdmGWDK4nJvP04fjsXGCoj4aviCo+3PnvTj6BzgtjLohK810xACcYe+mEJvo/PavIPW27cCBpwpVuvaFlOVJGaKOjUgi14pCagBsj5XdfDW/U4s7gcbHwFIL3tm+EWt3qWstkftejdUpFWbD/yzERKZws6+9cNGiOYk7LVu1iY4M2/s8myJt8VRI6kjhLR5URhZJeC4eqTohWpH5HrxwR7+SNq7w9l3kZ0DavjOLyRsUPm9o8xzBGb6+xFWNWoRkvP+5y3LwaYu65Eod4bIzokP6RVrGQA== 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=j/Ey7qUYp3FUgLOJcQ6s1M6EHunMNoby3YY7ePKZntU=; b=GV8WQSB7qdxfKKx/05ti8UeFuhywPpC7NNuScyqferAZSLdHcoY/SEs0MDjd7C/VifBBxb2n+cyziQ+bO26lVFt/DpUHXFvMdbgEpo9lxch3GvvjMvsk0kN6AGTVK5F55qhNrQ1oKYPazY8tGmJ/lYHXQnOgBzNNVf5TZlr7Ll/l/sZ1X0N0JouSxsX7ItQsJNXPX6Kon0QG6LfvrrOI2kIX3go9P3OFcM9jlV24Ftbz6ODYd6z10lttXT3szD9tKWNyhuoth//wy/noP/NAjBqjTbqaVTMCVhmR+7f/7Z7TfRmlO7DeYSjBPEIy2Evlr56vSo1pvSQfSa5piNhOqA== 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=j/Ey7qUYp3FUgLOJcQ6s1M6EHunMNoby3YY7ePKZntU=; b=b61l1j5OA4hwzbXSKzYM5Ewtp/LvHDr/5mSkIgl30GkhbcqxqSF669B4OTwn/Y99/lMTNLXgp+lrWr0FPjN0TF+6tW2XMCXkrsKOEFIwf+Tx/GPotRkv8RkZLN4QbZgdOgUdU1qhWSeqCYN5o0NpnxBGJxPAV5H+y1xBH8OIgk8= Received: from DB9PR06CA0021.eurprd06.prod.outlook.com (2603:10a6:10:1db::26) by GVXP190MB1941.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:69::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Tue, 22 Oct 2024 16:56:16 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::f9) by DB9PR06CA0021.outlook.office365.com (2603:10a6:10:1db::26) 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:15 +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:15 +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 15/73] net/ntnic: add item IPv4 Date: Tue, 22 Oct 2024 18:54:32 +0200 Message-ID: <20241022165541.3186140-16-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_|GVXP190MB1941:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5836ba95-79be-4ad2-99b2-08dcf2ba715c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Sh/2fvyoVaKA10d+OI1S2Kt/zvQXQfXyqMilVv72kuRcPVKdld4NNdCX4Bkq?= =?us-ascii?Q?Y27NBkPwtMz45WEHukbI90JBMXHWjJGe8CISUYpXJT1DeuZFoRgNJff65mYm?= =?us-ascii?Q?2JSP+XPp0OmB0u/suTW669oMYRExBVozvN2fBJtb2KpDelyrKlkIx3t3jWEw?= =?us-ascii?Q?nkBf34VFQfWBZd4N2jTsMgQ/Rnae9hnfXdm/GkrOj215ZaRlLYO28+pzkWhv?= =?us-ascii?Q?CNQ7w9OSjEJCdh+x1xH+PiE7YyqhR5KS3MVlyF433KODabpyo+Qfmvxyt/7e?= =?us-ascii?Q?lZuzz5FV0snlYPkQSnRwlh5UcrAGisrrCrusqmrij8AJObZeFP9a0OT82bHH?= =?us-ascii?Q?EnJKV/Fa+p9tCoehmDM2gbzG93L1lbsv4+iWLCV/PpFrMRMQWGh2zYBDjw4Q?= =?us-ascii?Q?Fo/OH16hHehigp6vQyZldrB4kDcItrPxhcaDvHXBTYBxoxDHXI+GWC8oFPPf?= =?us-ascii?Q?Md72AGXvrTasma8E80aq8VpLB/KWY07DwEAqVMFzBpWDvvCVaxWimWLXzZ+6?= =?us-ascii?Q?lzqtj3fNq4S8EDAsqNlx65RlgShgKRO+WhDDGOP3rhC4agsu2h6H89kJys2Z?= =?us-ascii?Q?SPmt0yn6QVZONSl18pov2AAlwLtpcE0QLFIqJvXVKndb4+JqiAoQXOihndP2?= =?us-ascii?Q?0ZLNH2Btu8OqxzhjITMrLX9uKVgC34NeI1DImPChJsPcTeJyHNU98ugKczhK?= =?us-ascii?Q?nihD6Q8VcTE1ckgMXQORgqb3DtzMkXJr5Vk1Kh5L/yMUm7VHcY3z8TOU4QYC?= =?us-ascii?Q?pg7Xx3ALT32y2MXYpdR6+D/Z85J6BhOpAaN1Smbn9WDIGB2LauA7Iyf465mH?= =?us-ascii?Q?OcnfV+ibm9ShJGU4BUR1dqJvJiVDhGcaFT9dnMGdHdgAorFFC+Bv+QZhDyRY?= =?us-ascii?Q?5PJt2gki67iJEFj7cBILmdZquQSqJlJkOZGD3OZRu6je1kEOgQ+GIQfxJbwz?= =?us-ascii?Q?lQ99ADgerwLp6MPhzD8BrvHAImTiXq/Y9R6FfqgiRmavksN4sw8OilPacXA+?= =?us-ascii?Q?ZHA3QzkcupbIy6NkDswgVq2HMljgoxbcLn55XD3k16RGFMX4k7EVgU96QJxl?= =?us-ascii?Q?iXrJVtaHt0xLupQtPzf2B7zs9CLjqAr+Cxt3UWvztqwmHvnVPpA4l4B4CcZQ?= =?us-ascii?Q?IhCdvkruSk8iEH4upx3sKt6CuEsC6v/g6p1llPhzZyI9Ah5cp1T39DSyvvvY?= =?us-ascii?Q?/A1PkZOaWIV2HuMdDFb37Fd67eyBqyUrf8McsgJMLfXSOKRso6ftH5qjf47A?= =?us-ascii?Q?J7CZDR/Zn/RYUvkv/NFa26UfemUacxKd8MqEuYTf3NmI7+rh6RHMulCJXUK3?= =?us-ascii?Q?C2Xvcv6sXgXQxnPG+Eo92KhZhvodUaSsOg93Zp3YlIlRdirVX4V37JY+wKbg?= =?us-ascii?Q?euSZEC3+pO/EwwuSHvp8SMhCed2zFqMwmJfhui8qF1aCLCnNHA=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)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MEjSBCGBQyIyTgM+5GahdZxQDLYlfbl0zZGT/p1fD+PszZRxJHfacaf2LbASRFct71KBgJVGpWW0NzufY9oGASmRWGBD6BGZZwmCSKBGxrBGIMziEwwRUYVvfdkZoB4D/wFmIgfjIH4ZCfWlO+whyVXjX60BVZdIH3FqthiOw2BkRR1sJ9XPuEqT9LvnQymrgVj52LrrzyvpnC9x+Mn2GF7uIg14m5V5QWN/9fmG8/w+NfFHe058TuiQVNWf+CcK84AZ6vY01Ew3/zh0hg/Nddc4WDYdcqXKFzHRcF6hmYUu/DMQJeVT4tMoZVPqIgTEPbzCh7xAJc1ui6i8HoGvNIdz3O+zgUgrHCArcs/H1RhPDRuWP0JRSR39tDei5pKLzU+VIZvDxUHR0cLw3Fq8c7wtHT3B6OlQvUKdWTNpMFpCfvXvKqxPYbqA2VkPqJlHTMEQCeaG61eGvhkNUxbdlD8Y30O5z/UeO9mbVSLQF6iOVutsN/uwT+uiYrimKAVaag4HuVckdkbfSrlFLTadOgK8GbFXxnCJ2NqMr++Qwf1xFxggpFnTOLVZNZvqt7FWo46WYwmy1SwbY9R0Pa2PhRA9SM/KnZRVXKDhiHMDu6G+S/I7/tY2BsmbjaAynPdCSdAV5f0KeaDAiaf/1ybMKRps8m+VnD2AKzUJdJ6Q920= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:15.6063 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5836ba95-79be-4ad2-99b2-08dcf2ba715c 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: GVXP190MB1941 X-BESS-ID: 1729616180-304983-12651-14387-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZGRoZAVgZQ0MzY2MjIJMncPN UyzdTQHMhJTkmxMDU2M7Y0SE0yMlCqjQUANlzRv0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan13-40.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 possibility to use RTE_FLOW_ITEM_TYPE_IPV4 Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + .../profile_inline/flow_api_profile_inline.c | 162 ++++++++++++++++++ 2 files changed, 163 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 36b8212bae..bae25d2e2d 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -16,6 +16,7 @@ x86-64 = Y [rte_flow items] any = Y eth = Y +ipv4 = Y [rte_flow actions] drop = Y diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 93f666a054..d5d853351e 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -664,7 +664,169 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + + case RTE_FLOW_ITEM_TYPE_IPV4: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_IPV4", dev->ndev->adapter_no, dev->port); + { + const struct rte_flow_item_ipv4 *ipv4_spec = + (const struct rte_flow_item_ipv4 *)elem[eidx].spec; + const struct rte_flow_item_ipv4 *ipv4_mask = + (const struct rte_flow_item_ipv4 *)elem[eidx].mask; + + if (ipv4_spec == NULL || ipv4_mask == NULL) { + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + else + fd->l3_prot = PROT_L3_IPV4; + break; + } + + if (ipv4_mask->hdr.version_ihl != 0 || + ipv4_mask->hdr.type_of_service != 0 || + ipv4_mask->hdr.total_length != 0 || + ipv4_mask->hdr.packet_id != 0 || + (ipv4_mask->hdr.fragment_offset != 0 && + (ipv4_spec->hdr.fragment_offset != 0xffff || + ipv4_mask->hdr.fragment_offset != 0xffff)) || + ipv4_mask->hdr.time_to_live != 0 || + ipv4_mask->hdr.hdr_checksum != 0) { + NT_LOG(ERR, FILTER, + "Requested IPv4 field not support by running SW version."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (ipv4_spec->hdr.fragment_offset == 0xffff && + ipv4_mask->hdr.fragment_offset == 0xffff) { + fd->fragmentation = 0xfe; + } + + int match_cnt = (ipv4_mask->hdr.src_addr != 0) + + (ipv4_mask->hdr.dst_addr != 0) + + (ipv4_mask->hdr.next_proto_id != 0); + + if (match_cnt <= 0) { + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + else + fd->l3_prot = PROT_L3_IPV4; + break; + } + + if (qw_free > 0 && + (match_cnt >= 2 || + (match_cnt == 1 && sw_counter >= 2))) { + if (qw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of QW resources."); + flow_nic_set_error(ERR_FAILED, + error); + return -1; + } + + uint32_t *qw_data = &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = &packet_mask[2 + 4 - qw_counter * 4]; + + qw_mask[0] = 0; + qw_data[0] = 0; + + qw_mask[1] = ipv4_mask->hdr.next_proto_id << 16; + qw_data[1] = ipv4_spec->hdr.next_proto_id + << 16 & qw_mask[1]; + + qw_mask[2] = ntohl(ipv4_mask->hdr.src_addr); + qw_mask[3] = ntohl(ipv4_mask->hdr.dst_addr); + + qw_data[2] = ntohl(ipv4_spec->hdr.src_addr) & qw_mask[2]; + qw_data[3] = ntohl(ipv4_spec->hdr.dst_addr) & qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 4); + set_key_def_qw(key_def, qw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 4); + qw_counter += 1; + qw_free -= 1; + + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + else + fd->l3_prot = PROT_L3_IPV4; + break; + } + + if (ipv4_mask->hdr.src_addr) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohl(ipv4_mask->hdr.src_addr); + sw_data[0] = ntohl(ipv4_spec->hdr.src_addr) & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 12); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 12); + sw_counter += 1; + } + + if (ipv4_mask->hdr.dst_addr) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohl(ipv4_mask->hdr.dst_addr); + sw_data[0] = ntohl(ipv4_spec->hdr.dst_addr) & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 16); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 16); + sw_counter += 1; + } + + if (ipv4_mask->hdr.next_proto_id) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ipv4_mask->hdr.next_proto_id << 16; + sw_data[0] = ipv4_spec->hdr.next_proto_id + << 16 & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + any_count > 0 ? DYN_TUN_L3 : DYN_L3, 8); + set_key_def_sw(key_def, sw_counter, any_count > 0 + ? DYN_TUN_L3 : DYN_L3, 8); + sw_counter += 1; + } + + if (any_count > 0 || fd->l3_prot != -1) + fd->tunnel_l3_prot = PROT_TUN_L3_IPV4; + + else + fd->l3_prot = PROT_L3_IPV4; + } + + break; break; default: -- 2.45.0