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 D45F945BB4; Wed, 23 Oct 2024 19:02:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5299E42EC8; Wed, 23 Oct 2024 19:01:18 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id BAD7542EF8 for ; Wed, 23 Oct 2024 19:00:58 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2172.outbound.protection.outlook.com [104.47.17.172]) by mx-outbound21-18.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:00:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f3FMVckQog8c8ksIk35EmFr+mnKYWSXJLJuvySdigYISIdeBFc/clxKGnHXqw+E1WeYpuVI2Rh8nlBMKITgafhvCih631tpd9eVZcVOeyCg1FcJcIxRJHME2CxbVFq7e1+3x8jHZ3Wuy1P0jr2iHFd1UrmqB2KPu+VaJdt7wdzB67pchl+l5EGNQ0PFXM3tDeKfVV8VtVm/LBgVAwSRM0/pEvXLE2Nm0PkO+Yx+enzVu0cL2oJTx3tcC3JcHST7njYSqUqFeE8DZ2x4PEIZUkUe5p7EkJLzom67xWlPrerjMgxIVkYUkcbXuyGDoKUQ4Y3x/JkN5q0MccBzaSI0q/w== 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=P56V4f7d0IVHcTY7n1W6zX3ocwvsNfwLuJZWZFSC1cRBDKAssD35/Fbxb5lgNOWgLO+80YmhsHELOMK0egu+GCrp0TUkUxnuHtR8RP8vyBedI247mzI4tUeeniay7b3wpFFaBuuyZMvmqG57490cEwWthAuYEBxTe4QCSOUaU5wMLFnCR2m5oCkOu7qq7HaPiEwrgpJAMSEekk9b6gRzl/3c7FXagXfqF2fulSTkD2FwIoBq8PrgHmOEUNExiuSSTz+TADUXBPg2IlgTrok7bC0wOOOvlEvDfgPDizkIE/4nS2SFkUtSN2HK5dEqePn1b9wCvq9MssNwAEUu6Z+4gA== 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=ARKx09dvTmlGOa6CznL0gZ2NCNcxB5qkBXhs1KB+v+TGMcMZ2dFlMeEqst6ikdDVMnGQBmpVuUYvWHbSi37HtmueHOH4PC7NmF4h5zZ2VvyYomHcr8t19kQ61K1KZiirCUS3dBUkzHdjaLaZ9IBSDPuooX6hDQIHh4X7q2CGMWM= Received: from DU7PR01CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::21) by VI1P190MB0750.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:11d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Wed, 23 Oct 2024 17:00:55 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::9f) by DU7PR01CA0014.outlook.office365.com (2603:10a6:10:50f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Wed, 23 Oct 2024 17:00:55 +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 DB5PEPF00014B9E.mail.protection.outlook.com (10.167.8.171) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 17:00:54 +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 v3 15/73] net/ntnic: add item IPv4 Date: Wed, 23 Oct 2024 18:59:23 +0200 Message-ID: <20241023170032.314155-16-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241023170032.314155-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241023170032.314155-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9E:EE_|VI1P190MB0750:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 14178574-818c-4203-9b89-08dcf384421d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ppr9NuBUv6OetOIHfbQEAdvPPHyCcb10ckskeRieB1NMT2OcRB0pLREEIn/K?= =?us-ascii?Q?z1knYs58VDq4KGTo8uFST4CKyGA/9g0Q66e98krEdMRZPpUE70N0f7lm1Kf8?= =?us-ascii?Q?0pTptDWV1+nWepJx47qZkFOAFdJUWMvTS+mS9eTSf+3C1xMkqG2EOASSZh07?= =?us-ascii?Q?eyG5K/ePG1owgkxj7wXWbzCUj60H/oL6ImeM56ANUmr0Oq5BnxaDxn0XfnwW?= =?us-ascii?Q?DX5kTYPqPSohwQzq0GsYMZEMOWDC1weWFkhuVD+++ooiSwWb/UK752jFmpgl?= =?us-ascii?Q?3/vLoaGeIMzWkxlXctFj+zhHbzaaJTqARs5krPfv71G8c+sDeX0VQUB0RLK0?= =?us-ascii?Q?TcWbIhioXhDo0tdGWtdioJiCsf9/ocI4cEzctRoofSU16dXKdlZPASA+21PY?= =?us-ascii?Q?LxS36TOB/E38TxsQIn4U1/G/WGZvBtpGv5V4/jiBQSAM+8TW8WRu/u/+VFPA?= =?us-ascii?Q?WbNptjR7K+CRYarjk0df2izWFewweXYELk/lPqtI/PiRUNH88OG18sKFW5MN?= =?us-ascii?Q?I5pXWvjdvJh06vgQas/X6/Gja/9jNIWEhptj1opZWKBq15LV6kOmrmheyD4b?= =?us-ascii?Q?4Mj+8nu58tCPrH05opR7ceVlv4Ium+ViULJgaardISWcNR45nhYyNM9SmQ8G?= =?us-ascii?Q?EOr2idZ3B/922PzQZM+O9NwtvyuY/KXU4OtGpid0v3621ssSdXnu3+0MKZ+Z?= =?us-ascii?Q?XKCcYLc8vWo8j8OxjPeCb7ATQR2PYAeeNCjxTj5C2Vz/XdT2BrZ76Ni03KLe?= =?us-ascii?Q?q6JtTGt+ZlLIni8jgzERIQfCt5hJwUgClswkX+v0Y3/wx+KpPALibFgXKFhZ?= =?us-ascii?Q?K0956llyIiRCSqs0GdRkHBhEwRz/AdcC3rPlek5keQU5FI0Y1wnrGkF8TTK5?= =?us-ascii?Q?MypieNmpENxJhoSHJ36ICgF2QCzYNWFQYzRvmRyR8XK5yBLWjHNaDJ29HIT6?= =?us-ascii?Q?msOgPzlBKANlM1zfhiX8Mq3yEq1MSnnj6fswek+ad9NFH3vWrfrlmlNxDWsU?= =?us-ascii?Q?TDT/92OJALDlTOIpmaOTYxEpr49iGus0zFpIxSUpIJb4Rx7hFimhvi9BSUA4?= =?us-ascii?Q?5nqq83IvXWE20hD1eaz4KOMUzxGeumxe1UDpdOq3+VECeNPsqlhKIVr02Kq4?= =?us-ascii?Q?ypWqv8D68t2i+l1QIACKVBDFCRS4wjK9S1oXaJY+d5eNwISkj1GBz7f5UpJa?= =?us-ascii?Q?y9SNWkBYCI0dxn36G7iWdH0xuyumZz+EEzhP+D5uup8FaHxVYDPBhJqUAtdr?= =?us-ascii?Q?w3Z2e+wEdn0jLSprIQiHIHj+/5kvC9GO/9k9Nem30cVcfCe+e5xWKWlbERko?= =?us-ascii?Q?b5HYA1Re5y+zlM0ob6kmR9KCtowALCBGjyfsQAMcDz0253lksciGETj+0Cw4?= =?us-ascii?Q?ktdbSX4XM8nrhIYKO7GRwGjB/VCFfc1ph3X0Bai+/26BaYk2nA=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)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XrikjdZrwGwYcVZ+R+5G6s445pt/3TliVp1/45DUqajlpF0SVA/nq2jcx+uxZQLfnCTCw9JHr0eyPw798U0Bp2ev+bLq91D4aHxxjB1VHgLQ2YsbWsVitg8+rhUIpLtvnoP2m+4N3oDNdljUqYS1XYbK7zkPC2fn76WT+wzjVROOu3++y9eDQPtl3+UR2GCJCJ2Tx9kTjm4YtWhfb5ts25qnE5ezDraQ3ywGllK+B/2gb2JXpGkqJRilw9got0Om0lEgNZcD4cdKOd0RCidmZBvlusnB+HUAAAopBgkCWCscwV+nHIK/p1qW9EtFG16eK8YlwtP5LT51DNRrs1BvypjCZMnV+RNVgNPgrpgWdLiP23zqZesaZEU9PNlD7rG+vCCmxjGPwPLe3iwvhtx2mIyXKO+uQbdmiW+xD1f4uoQPKp8KJpJHiOALPPZY6kQQ910Jveb+5UB7Vtzt0D9R8QA1cwFk3dsYkE0+vWabUqXGOMFdZnNmRq0qMAWblyfNaQ1OjvKc5eak7kIlJsBqKYg97dSIJlImCjkneKrdvTVLcrlZSIOffaEYq9CHEVYypB5sIALLO0d9S2fFpPQkUu42yAK703Q3uER+rD+GM6TlnT0BDOGjntVnn512vTOX7+2/dS76JImyisxfeuZqfsZYLHuKQdN8wdc+C02+ZxQ= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:00:54.7893 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14178574-818c-4203-9b89-08dcf384421d 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: DB5PEPF00014B9E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1P190MB0750 X-BESS-ID: 1729702857-305394-16206-13620-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.172 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.259925 [from cloudscan13-54.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