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 1833245B96; Mon, 21 Oct 2024 23:07:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 116AE40DD1; Mon, 21 Oct 2024 23:06:00 +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 44C9A406FF for ; Mon, 21 Oct 2024 23:05:47 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2232.outbound.protection.outlook.com [104.47.11.232]) by mx-outbound8-87.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:05:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L7PFbFo/fPHP4R+5VYiNh5+/C64cvC+WQ9xSpDvxt83nIv+6mpaq6ad/58GnM5LJtb1jhOY9moScx9GQDmo39hhPO8C1uG9/VBTndMl0bh6tAbgr0KB3w7ZaFaYIuyq13d2tnKKt0uIBAiIYeMIDvOs9oNUVm1MOF6E4nll4QCiuTiosandYHn9JXKo5EsbIY3Wbg6AhALk3htWXtp4HhYwKOPjOPXQSH8jkcG7IfIKtXd3gPpZaq+ErzEyYisgFu8Wmav4O/2kQQC7uJZcFdhI3TiqFw0WQrN9F2SxXwHYthHMpJx+JXsBf2wPfinvHeW/q+/TkNMEM2NfCZJGzXw== 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=TStYFqk7L7OHqI9ZIMOrrGp8Agau+o0IHf9uEVMuLvQ=; b=K87a4pbX3tRmbvgaf5wCVlPiBirQiFvM2C2oKnO3X++a/ilP3NDlMcMfqXc2IcWTKHaa8RJCK3hVGEg0097cRyzWd8WuZpiBk61Z1zKmR58uEHVGB9m6Zyi7r2RwoLAx3SZwqc3S8p25HShGyHxh5M/b2pjDXece5XdtFYiYZxyZsppm1FN42zTQ5CC8nm5k++wqUdC10WHpa7OMKhnAbNaOt2mRLeEU5ciTWtvuxhzN7dTxPQ/tMv4dyCcMC2NbI8H2GsEOYCdsGOTVZgWF/OLT/xSIqpxfiUNONM3uTE8ahqR8QhTYPd3GK8o5oKltMPFZA9QJz7Kr9epQjqVTYQ== 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=TStYFqk7L7OHqI9ZIMOrrGp8Agau+o0IHf9uEVMuLvQ=; b=okClrdlYNjiiVcGrN0ZIT318mBd5M3iCfwcPFRdINdEXnubLUhvvpEKmr9L4ze1vwsfmn+jJDMNC9E8AbxjU9onciDe3rb4aI+v6Fn/5yPrFIPl/ZQ70uTPsVLueNfWgEi1iri1WpqsaogPz8BwmrrAHbuivgtZKuT3gJnI8O1M= Received: from AS9PR04CA0146.eurprd04.prod.outlook.com (2603:10a6:20b:48a::19) by AM0P190MB0787.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:192::15) 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:42 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::db) by AS9PR04CA0146.outlook.office365.com (2603:10a6:20b:48a::19) 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:42 +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:42 +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 15/73] net/ntnic: add item IPv4 Date: Mon, 21 Oct 2024 23:04:17 +0200 Message-ID: <20241021210527.2075431-16-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_|AM0P190MB0787:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 45084617-36f2-41ea-2194-08dcf2141fd0 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?2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ecOHnDg2zey?= =?us-ascii?Q?Cdwel5Jk3galupv5MBZe4W5vr8IGY2Cg8jg2tCIjoTQeCYnvXGjDy2NPucWw?= =?us-ascii?Q?CUxXho1D8AoARus5ZCeDSCZzZT7I4J1cXPIDS/baArb+nEQIOxUgwoGaN1qE?= =?us-ascii?Q?a3b707YYq1BTA9cjH2CVvdfH7Z8mOlLo9WshQnq8kv5cq7RavD+Yb2vZ9BuX?= =?us-ascii?Q?M90U4uzqheKkyqKzX/JXLnVOIZLFRlgMYQzqOSa9qguifjMqUjNRM8Kha/Ul?= =?us-ascii?Q?YNMa1meMSU6+v1O+CmGl+qDqkNgE+snLBzBcjbTjNuFzkhqa0aoQc2BznPb3?= =?us-ascii?Q?1TCX4OaSjCkxeWVRnuO0V+f0hBRtpU58FbWmz+apOHSN7wQ54FyaJUKJ+giA?= =?us-ascii?Q?sbqXSRyNa40B6nvBe+EjnghN/GBesckl3m8u+OC88d4bTVeASjWNSFwB9QiK?= =?us-ascii?Q?Wci5/J3AhhRu7QGyQKm1Rb/g4s5zp9cSDTB8yz+pZUuw9KFBIYhB+LDCyi9/?= =?us-ascii?Q?Bi2B7e5Fw1c+VHntBI+sqgR7NvWsT9HXlNvFroeOi9aZYnqQpQ=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: AXyTtcqMjMxEQDl9yX++9UlaNR0rv1ZJ4L5RhwY9yKFyxd7xxcREMVFBWVj0pKhrXBR8puNK3xhRcI/selJNXZXVZurGCoZOie4aZhclnpZuQKd3exthLiY9pCBaor5GzcUmtxjXUI+9DgLdUISU9YYVIJO49BHxqs5g93zkfQ/kkJ/Plyf+G6gres4xoKfrTYCu2cCVPf+Pdr+hKukyrnIfh9KCPLzpMrAIX3lF6dAouURJFzu/ELCuIFKrW32t7a2XL/xuGXC68JolozwO1Zvkxj+vkDwclzgQEhSitVhO3ZkFn8IPF9F2RWvGLkznhKRBRmxVqusasw16KxQfQqTDMWyOOkHv0QpDdLBDygaCDAIjTcYLFJaZu4MMZeUn6pmYGVeaU2yddLPgMrstUdFbiYCO/rcI1niKWO5RbSTwl1kcJoTo8U9h3sSIU5Il8PA4wBowaPCu1LdcQge3ILciZU7Q2HinUZWcZAOn8j3Eb0OstPN/krlQeLkj3LLTKU9m5/4MeH4RRfN/oJHXBppifScoINOwRI1+tXg9qC4/qZTyzcmLPkElZmThGbKz8stJMD/dQvZHXJ/tY3AdzFm/l2uznSMAWLDYJZzHXAKeNEEXQLQDHItihhzIqfssUlxhafpHJnIT915tiWULSIuRSLJk7l49uG7KD+wol4s= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:42.5363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45084617-36f2-41ea-2194-08dcf2141fd0 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: AM0P190MB0787 X-BESS-ID: 1729544744-302135-12912-42499-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.232 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZGRoZAVgZQ0NwyJS3Z0tgoNT HFJC3JIi3J0DTJyCDJIM0sOTE50cJCqTYWAFuDp0VBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan10-204.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 0f47f00e64..aa1b5cf15d 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 @@ -666,7 +666,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