From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A69DD45BC0;
	Tue, 29 Oct 2024 17:45:03 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 5B7BE42F01;
	Tue, 29 Oct 2024 17:43:35 +0100 (CET)
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 EDF0642EBC
 for <dev@dpdk.org>; Tue, 29 Oct 2024 17:43:06 +0100 (CET)
Received: from EUR05-DB8-obe.outbound.protection.outlook.com
 (mail-db8eur05lp2113.outbound.protection.outlook.com [104.47.17.113]) by
 mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2
 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Tue, 29 Oct 2024 16:43:04 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=pa0bw0ri6/+FARscYcw8e1fcjl8RxMABa4Y5aL14WCYxN2JJhQOoeLuXEjbz1bkUbH4eUSXB0nfZoZGmB8o88pSe/Oldtl1VsCghW4e1tVz2Vp2EzmOazD8s1A0URIUOxeFpbmlEfzpZsTwjEXybziMczdTa2yo2SO3Wk+ftIgrMuZB8bkO72R+RHk9Gv+7aKj+7xUUTk9Ctj2Vu2w+l83qTxIoNWmt3HRlb4clIe5diRCFKkehDPy2w+n9aDFVYFAxjrMmLcz6AtrtRdC808w0bCN9ufVXCKzrXOyeNneubuD8H6gpxDUj48vHaB8Yqd/so34o6e6DIveIzOghK+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=YMvSXuHwJAkA6i3sWJzVaNRu1pH8npvmBQ+ET5Dh6WVN0B4mp/C+M+6I/a5PCwgcKykMkDO3iMetNxL1O3DKfcOiX1yy4dTZbNU6MGEoBMsiCN/XwJALvGb9CvQ2D/BVFicpSr1g9SNz8hEyI2hQ/JtMHdHEEwQ6qbaCMRmKmHwVc4n1eJ1fmGaPv4nxbjnFKpeghF5a9uJAOKiM37qtaoUdfRND+lyklLHxSJybm30Uxoktgt28Vjj5Za+O84iLO8ChzXKWxpLQ0as76r1JQTSkES7ccR4XdHcv2qzwWqXyQ0UgwIKlfiLCt2AMHIgymL3739DPthcEzdUSS2RJqg==
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=KDLEO8Dc20Rz+ozR2Pk29t4N9AsM36ranMTKoULQa8tBWu/RsBwHycMcrO36QZKKjewJJoW2iMx/MMhSOBJxGj/whKJzCOwPmX8PQ7VuWfU1yCD0xRxsvryXVh3OW4MRoBEf3/KDqY1H8TXvwl4USwQevjDMLK/WpXxRygpssPI=
Received: from DUZPR01CA0196.eurprd01.prod.exchangelabs.com
 (2603:10a6:10:4b6::23) by PA4P190MB1247.EURP190.PROD.OUTLOOK.COM
 (2603:10a6:102:106::17) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct
 2024 16:43:01 +0000
Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com
 (2603:10a6:10:4b6:cafe::38) by DUZPR01CA0196.outlook.office365.com
 (2603:10a6:10:4b6::23) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend
 Transport; Tue, 29 Oct 2024 16:43: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
 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft
 SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024
 16:43:01 +0000
From: Serhii Iliushyk <sil-plv@napatech.com>
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 v4 15/86] net/ntnic: add item IPv4
Date: Tue, 29 Oct 2024 17:41:19 +0100
Message-ID: <20241029164243.1648775-16-sil-plv@napatech.com>
X-Mailer: git-send-email 2.45.0
In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com>
References: <20241021210527.2075431-1-sil-plv@napatech.com>
 <20241029164243.1648775-1-sil-plv@napatech.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|PA4P190MB1247:EE_
Content-Type: text/plain
X-MS-Office365-Filtering-Correlation-Id: e5e38ed6-b3df-4155-85aa-08dcf838c0dc
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
 ARA:13230040|1800799024|36860700013|376014|82310400026; 
X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?kCytxtR29gbwyM+DCf9aan3Z0O+riPpU3ufS7dDCHJymg0ftc6wL/tSEQGR6?=
 =?us-ascii?Q?M4EyAYPjSZUwQy4HF9qLWYpU2XTgco7J/S5okV5k8DgO++fGyfbuyoRlUK0Y?=
 =?us-ascii?Q?/9YoTVIr2wHEA65H/3s3NkYVX0RnXoWy4jyapnSN3PLZTyvfeLWX/bkV39CF?=
 =?us-ascii?Q?wB7jKue30755p2eGMHuU/+dLOx5o+6OIU7GRrRxj4nHLB9ZVESY+fwM7oUG1?=
 =?us-ascii?Q?L3wwDO5CESoLNCE8glB17VJG/Q5WV2b+VmXnrsHmxhDfg6NktpOLh3+FwvXX?=
 =?us-ascii?Q?Jnf1YdGmkzCEkyqrPeD91DGm/G5amnBQ2u7n5sDgUMUfkBxmmcwavTgqT/lu?=
 =?us-ascii?Q?gmwvQxdr641yodx0TCHkYhInGFwVhzW9YVUW/bsmT6uuFo0VdqAF5vz24xPY?=
 =?us-ascii?Q?hU3T80xOkaWK5oHzLoeiI7qtSfRsHics+3dDWoXnC7ENxeIOJx2xiDn/Hwgx?=
 =?us-ascii?Q?1m7SVCyqpk443wfYwDzDMA0Vwjpzsh8zZGgsf/YtTUeoM7WnfCoNsTZ4llS0?=
 =?us-ascii?Q?/ekNPsbaZ56qBsP4XLpycVEGvyacL7WFkf70MIInwHPc0JGgi7kr2h3gCNkr?=
 =?us-ascii?Q?asS7W2yLC5MkcfSYDAM2Dsv2QuAxhCFeZ3THunJ6+4bW6CHjmweVrWW0D/qu?=
 =?us-ascii?Q?45K+1fTJMeCRy7FQgtjBX2eAIvtZl0PlBTZMCCdL8kvNfiXmB52grwS914Gx?=
 =?us-ascii?Q?YKvKCOj7fmXzx+dtIoQCA6unorJv/qJmsDa9cwAtNqK8CqBOKrrdDZaKHK4A?=
 =?us-ascii?Q?uz0xUvL4hL/fawhZ8/3pn9UIo6xxgl3ZY1++EbU0rTFceuqmmP8nsCAJJxdd?=
 =?us-ascii?Q?1uE8M/fJxsX7ITFnwxyMKoXdt5jIC0Mv7+yI2thsTco8FARQJkDqJWiTEN0Z?=
 =?us-ascii?Q?585bWh/ZYXMZjy++G++yQ2oTkEyDbzMEVM4gEXEqnP3KG0uVsmWSMZJO7wZV?=
 =?us-ascii?Q?PoMney9F1vdt+dVR49R055Df6Re0X8m3BuOF5wCi3RdqM7v/08ahqHXIII44?=
 =?us-ascii?Q?rDcdfW8mRQO0gPL7G9Op+tvbFE0sJbOdlNJbeeNAsC6NzfItMBmjP6G8HHUf?=
 =?us-ascii?Q?7SJ3q6iPjs6uPRxF9GEretKRKGRxYadeJgSEhA7kLXVnokHSCewqEBTN8UnX?=
 =?us-ascii?Q?C+XhyLqZKZE1EdyBtev5Mjz/sZCInzX6u8R6leaIB0CuZkb6ZfJ91WIrGZIM?=
 =?us-ascii?Q?4g6OW0QOiEbOABgGcme+flyu/C9iGRW15AH28u5P4mUnB9/ukTrPEZJ1l/dL?=
 =?us-ascii?Q?TT6m987H+Gux+HP1ffxv/lawV9hB9IpAyyUohg/yz8gEw/YIzNb4SvojW+v1?=
 =?us-ascii?Q?PtncPfXztJI6eb9/gEzKhtE93E/nYRn4AVrjPffZf8uT0MXyUySlxABc6lXJ?=
 =?us-ascii?Q?sHIC8C9luQWp/8ORZ7gyyUZv8yv5VT/pcSnsDsiKlqqtytT8Zg=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)(1800799024)(36860700013)(376014)(82310400026);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: g6GnljQ0szW00k7BfwtmXyTCoybzAVXfFwKPv3slwLh9A9uBBMnKD5ZuUGe/MeKUrcSYa44WbbL+95VeDt8M/vTSo5e0Ee2cgvHJMMzq6ai4XmuYQAy9WuRZC6G/VTWmC7hNKY5VJQjvp/Cdh7fvCvIo2R4s8dAsOKKXpD0QJ058nEJKLTOw5KBDqD4mjPI7UC6WGk8UoUu2ompLDQXKAcOwaIsPJbXoMdqtkhHAXYuQYMjVVUcKiSF848nZyXQf54WIQgnCRtuV3T5AcDyo1EmOH/1DI87IEVvCUopcHAEY+uU9EAFJfyWzKbWyR+u9w48eBYMJDoj1btOqU1gWAqe02TFzInCV9fovZ/PKQWsFPPkjAIJebAVr6QtghqENVw0kY64l9jXKp+3uWuPxlnxvzqoAPCwRLAbI9Q1b1Jo70DWR36Vzp3bgdRLSjBTpZ/iWH6o5a+igi+g2faiMVpPJ57ZxabLnfsn/hIsQfGvs/nOJYJjI0d64wBUauLwsQ/7DIQJgNVTldugnKNOFzLwnNoko63Z43wjFBZ4uU2c8McGoOFyoVSjKiQ7YOk//17nSjgI4HtWoWCLYQmiKfJRToODN/NSKDvAYwKX5N9M+Q38R1d8ggR0G0FhC7op+wZWel8o0RBYvv667PNNDNAJV33VAOnGiek2tm7jb21I=
X-OriginatorOrg: napatech.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:01.4646 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: e5e38ed6-b3df-4155-85aa-08dcf838c0dc
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: DU2PEPF00028D06.eurprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1247
X-BESS-ID: 1730220184-311207-12674-27823-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.260063 [from 
 cloudscan10-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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Add possibility to use RTE_FLOW_ITEM_TYPE_IPV4

Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
---
 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