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 8887645BCC; Wed, 30 Oct 2024 22:42:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F948433E6; Wed, 30 Oct 2024 22:40:38 +0100 (CET) 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 3FCA243445 for ; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2112.outbound.protection.outlook.com [104.47.17.112]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NCCOZLXhPXfcOPW586Ri/FlZeotL/guhdk45VCZifYJ1CWa0ieRsJppgSBJKHgO/X5A9rBX202m+NJ+QPxWJYQKWhy4i1xV5ztouOee5/3UMIGCnurDDFQMpeS96+QHc28SuX9imK55IvNLNpavbUl+UmFY9XdiiXqOL3SdV9DePtsxZ2zXE6mtw74sRY6JJAjBYRo0S/DWF4xtE5RI3QFXd2rELctZeYFKjQ9d0NHZnwt9yGEtTsfrhocj7UvtESX1QQ52In7+GDZ7ANIzGsWUKvdCnxbnX0u1MPCunNMx4AdUJE+84K3WzlyT+DSRKkehGE+qCst4aKn86VWO9cA== 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=NiaNpr4K+yb4xmlbVoaTPx57f5sditc32hQQ4J/nFMA=; b=m4/KTNL6qGSiH/OYgDLx7unSv71dRyK6cSj0qqXIdFx+Qj+ve0BXsWEYrrX2mugv5AzJfnsz1R3FJEuhnCHxajIYuztn+LxWZFCUWX13nmc8gz+dYYlSIdxPqcj6trLJAM4Fv24CEUjn9L30X/bz8mOxzGtRvbfHBzm9mkUUU3F8yO8x3gBJGvfTGri4dQpYtVj1lRzl3RQGxHaDpZ4OfHOW00cCCE/NNnzqg97zV8A8kKG8nXZwIdhHLFbrfJcSFYO7UStuQzpRorZsqP4KF7FsNACyZa6nNBz9ouf7mTIRikReD9jLrmQeWZks4RT7tgRIR9uE7RUre8lUDzit2g== 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=NiaNpr4K+yb4xmlbVoaTPx57f5sditc32hQQ4J/nFMA=; b=i20Sy1ymZTljVNZoJqmCb0NzUWTgE9wT2FBD3W4FmjlrGLwPCV/GzmeXKLhOMxMjy2KRItvfWX+HdtrHM3hdu4PAeJtIbKrBMa5Qv2GkbGldGbkqgroVK+lsal/bZZo6FQXTHv0IWVqkgXOHE3KdSn0doplpbA1Vsisx6/Uw43M= Received: from DUZPR01CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::20) by PA4P190MB1117.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:105::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:14 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::78) by DUZPR01CA0004.outlook.office365.com (2603:10a6:10:3c3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:40:14 +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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:13 +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, Danylo Vodopianov Subject: [PATCH v5 24/80] net/ntnic: add action modify filed Date: Wed, 30 Oct 2024 22:38:31 +0100 Message-ID: <20241030213940.3470062-25-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA4P190MB1117:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 59fa3be7-244a-4275-8af3-08dcf92b7036 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EQGxQQhd6zldjUa6VUiz3iSvvqJj8GFGQqpt8i9gFhDqpyU0F9NvfXD3nYw3?= =?us-ascii?Q?zBsfg6otAUn+L9M40wrvDqmowzoq4H5f9foVrrvU3HKgNByNj43BbqrVZU+M?= =?us-ascii?Q?STeZCRrOtM2aD7jTmZeuqG8er6Mq3tEGOJwFZ9U/7Rql3SE33Nxe0zuW6cbr?= =?us-ascii?Q?oFiMeFaXzn5mUL4RhLGNth0QGmSNU42k0vw7wqUphgAWILUvCNpumlFYRCHd?= =?us-ascii?Q?YFTbjpa0dNKpI/LXWpuCSVTnMLNFVT3wxiqIJLhzmB4WlH+yTWxX+nC9IRCF?= =?us-ascii?Q?RaS0xmNdySlHYPEYZynGvvsRPghreIgxqyxaGHXhvUqhX5w8vID4rW1h4a65?= =?us-ascii?Q?LFSLUIckXxiHcjfDt6KgAgV/EXZHIQTMO5tFjv5U9qyzGeiReQCq8MsrNRZP?= =?us-ascii?Q?vsjMgW9j2Pes2EluLnwtJA64QNamsOw/YFmfhgMC7dHovp4/qiSTNAzyUlpa?= =?us-ascii?Q?8eBsxKn8ejV2PCF30auI9TDI/F4Av3GtFqasbsEuLOVZr6aEzQT8AL2Ck8w1?= =?us-ascii?Q?sZ8RXZ27OovIVz0NBuuiKbcKjCYi8J7Yys0gbIfVbV0USbA9eC6v+h0z1Hdb?= =?us-ascii?Q?aSII9YQA3fFYiMN0vs9LsQKAnefiqyuCYDVqjb6Ec4ak/KEjFxyKRYNZ93bA?= =?us-ascii?Q?R5pzP026phmYfY9elOCtCDv5qRxDrinxgJ3cN0XfGnVMWwJ5UAw98XKlFf4g?= =?us-ascii?Q?N49QwBl8nY0FPwG0bXLLvddoj/22pRDYNgHgDb7aERF4CUvBsjTEZWNt/512?= =?us-ascii?Q?2Hn0oMHr9LILjXueGNCJmwOxAZqh9oXR5oJ48nUKT4I647Eq0hFzVPkpSxbC?= =?us-ascii?Q?NQqV+fo1WhnK4+SSteHd5FeGQxWtSd3MLSspBBV+WNgHMKM6loWuyA6bu4cW?= =?us-ascii?Q?aE0zp5VaJq2hLiAusQi1F20KlkFAkwolBPcs1njhfktPuC8hG/SqqbPHeBEr?= =?us-ascii?Q?RGOtpQ4a5tO3H9bGAMkRBo7gsS7kT/F8pYNCD12WND+NNQLi7pgmDcwntjKA?= =?us-ascii?Q?OZW9z7xLbWlut4e1R7a4OYsPBXoikQEIDZgxa5GSLFiEb+MzJE7DX41/+9bf?= =?us-ascii?Q?WMOIUF9nrHuBCoe2LjQfIECJ90zZ3Jdz+MhkDnyt4klF2kKYDFmtlbfTXCxj?= =?us-ascii?Q?7tHU2TEVKtsByLxnzXW0Siy7b6nKUEIdFwxUII3pudwj+6f9S7uC48O2E0lQ?= =?us-ascii?Q?9Gh1yqRL6DmA2GHw6CTLGj3cx0PfuJnwlHqT982EhgAPnBKAWaf4uplIe9Tn?= =?us-ascii?Q?/X3WKpS8aLUV95qc9H39ry2dfv6wdIchIc6Ps+2/C1uANJ9Na8Qulg3N3W2N?= =?us-ascii?Q?16g7gz/ig8tC03hkB7NVzFlMjHEK/iZUi587eNivkZax35YY+2ZqwnLKJdvp?= =?us-ascii?Q?Md0SQhhqvKunVQF4q8snMnhscqFOe/V3N9hKmr/jItC45wzyqA=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)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1ih7SOZuFn4oBFExSnR6Q+wh+V+LWaqFxU2TGCi6KG3ZBsb7QDdDEkWnaY/Xds0m/OrPFGM3pRHm2UchCHWQzjIRreqwQOEvpTjPQLZHKetgf0YTC+4Xd2a258WgL+0SrinE2m0f+cNpwx7hLXtOxlT4BxGks6iyChM0DAiCdVF++zugap5/Sy9s3w6Agov9tKapkIqAEpB2N1Hw7YyIdBmA/BQq4FNvK38yIUq8NFEkTuBjuqs5gCGIuvJjdGOoyDWme//rP2zxfMg2GISjyH0ufwTnP6t+IneVdDChtm92HRRRU6r8dEpgNqkE8gEU5DYQt8NvY8l5kusO9e2OWnhjCo//SzKpQrbnawYt+K2rXELqIIj+roLRJwc9i5FUSTR9zHguOeLadxv8kBXVTYzjJUR4cR5dmB2Ol4WePghmI81qr7uNRJBXqCNhqzcnnqnJRmNMITyRs7m3DdgZqf35mjbQVLbo2Kz3OcFHDy/04P2FvmrgkcMzttPQJAaV/RvhRxiMW/gQG0PXqA+59onR6Dy4itLN36nvwCpuq3zfYHZLt2Lirr3AArfp6sXCy1oB5v5m+ar4BJ6SFo4ojLq/67JhHjki/Oo1HJKJ7ffJfGrodhEz6/L5PWvkOtmFuuPG4SmvwdXSmjBSEwdYFBUGNuElKS0X9THicFs8y4U= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:13.8331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59fa3be7-244a-4275-8af3-08dcf92b7036 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: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1117 X-BESS-ID: 1730324415-312176-12708-40686-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpbGpkZAVgZQ0MjMKDUpxdIy1d DYMsU4OdUsMckoMdnIwiTF0AQokqhUGwsAqhWyYUEAAAA= X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-95.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, 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 From: Danylo Vodopianov Add possibility to use RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + doc/guides/nics/ntnic.rst | 1 + drivers/net/ntnic/include/flow_api_engine.h | 7 + drivers/net/ntnic/include/hw_mod_backend.h | 1 + .../profile_inline/flow_api_profile_inline.c | 181 ++++++++++++++++++ 5 files changed, 191 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 320d3c7e0b..4201c8e8b9 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -30,5 +30,6 @@ vlan = Y drop = Y jump = Y mark = Y +modify_field = Y port_id = Y queue = Y diff --git a/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index f2ce941fe9..63ad4d95f5 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -47,6 +47,7 @@ Features - Jumbo frame support. - Traffic mirroring. - VLAN filtering. +- Packet modification: NAT, TTL decrement, DSCP tagging Limitations ~~~~~~~~~~~ diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 13fad2760a..f6557d0d20 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -129,6 +129,10 @@ struct nic_flow_def { */ struct { uint32_t select; + uint32_t dyn; + uint32_t ofs; + uint32_t len; + uint32_t level; union { uint8_t value8[16]; uint16_t value16[8]; @@ -137,6 +141,9 @@ struct nic_flow_def { } modify_field[MAX_CPY_WRITERS_SUPPORTED]; uint32_t modify_field_count; + uint8_t ttl_sub_enable; + uint8_t ttl_sub_ipv4; + uint8_t ttl_sub_outer; /* * Key Matcher flow definitions diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 4f381bc0ef..6a8a38636f 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -140,6 +140,7 @@ enum frame_offs_e { DYN_L4_PAYLOAD = 8, DYN_TUN_L3 = 13, DYN_TUN_L4 = 16, + DYN_TUN_L4_PAYLOAD = 17, }; /* Sideband info bit indicator */ 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 f7a5d42912..4cadd3169b 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 @@ -323,6 +323,8 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, { unsigned int encap_decap_order = 0; + uint64_t modify_field_use_flags = 0x0; + *num_dest_port = 0; *num_queues = 0; @@ -461,6 +463,185 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_MODIFY_FIELD", dev); + { + /* Note: This copy method will not work for FLOW_FIELD_POINTER */ + struct rte_flow_action_modify_field modify_field_tmp; + const struct rte_flow_action_modify_field *modify_field = + memcpy_mask_if(&modify_field_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_modify_field)); + + uint64_t modify_field_use_flag = 0; + + if (modify_field->src.field != RTE_FLOW_FIELD_VALUE) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only src type VALUE is supported."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (modify_field->dst.level > 2) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only dst level 0, 1, and 2 is supported."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (modify_field->dst.field == RTE_FLOW_FIELD_IPV4_TTL || + modify_field->dst.field == RTE_FLOW_FIELD_IPV6_HOPLIMIT) { + if (modify_field->operation != RTE_FLOW_MODIFY_SUB) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only operation SUB is supported for TTL/HOPLIMIT."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (fd->ttl_sub_enable) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD TTL/HOPLIMIT resource already in use."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + fd->ttl_sub_enable = 1; + fd->ttl_sub_ipv4 = + (modify_field->dst.field == RTE_FLOW_FIELD_IPV4_TTL) + ? 1 + : 0; + fd->ttl_sub_outer = (modify_field->dst.level <= 1) ? 1 : 0; + + } else { + if (modify_field->operation != RTE_FLOW_MODIFY_SET) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD only operation SET is supported in general."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + if (fd->modify_field_count >= + dev->ndev->be.tpe.nb_cpy_writers) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD exceeded maximum of %u MODIFY_FIELD actions.", + dev->ndev->be.tpe.nb_cpy_writers); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + int mod_outer = modify_field->dst.level <= 1; + + switch (modify_field->dst.field) { + case RTE_FLOW_FIELD_IPV4_DSCP: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_DSCP_IPV4; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 1; + fd->modify_field[fd->modify_field_count].len = 1; + break; + + case RTE_FLOW_FIELD_IPV6_DSCP: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_DSCP_IPV6; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 0; + /* + * len=2 is needed because + * IPv6 DSCP overlaps 2 bytes. + */ + fd->modify_field[fd->modify_field_count].len = 2; + break; + + case RTE_FLOW_FIELD_GTP_PSC_QFI: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_RQI_QFI; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4_PAYLOAD + : DYN_TUN_L4_PAYLOAD; + fd->modify_field[fd->modify_field_count].ofs = 14; + fd->modify_field[fd->modify_field_count].len = 1; + break; + + case RTE_FLOW_FIELD_IPV4_SRC: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_IPV4; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 12; + fd->modify_field[fd->modify_field_count].len = 4; + break; + + case RTE_FLOW_FIELD_IPV4_DST: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_IPV4; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L3 : DYN_TUN_L3; + fd->modify_field[fd->modify_field_count].ofs = 16; + fd->modify_field[fd->modify_field_count].len = 4; + break; + + case RTE_FLOW_FIELD_TCP_PORT_SRC: + case RTE_FLOW_FIELD_UDP_PORT_SRC: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_PORT; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4 : DYN_TUN_L4; + fd->modify_field[fd->modify_field_count].ofs = 0; + fd->modify_field[fd->modify_field_count].len = 2; + break; + + case RTE_FLOW_FIELD_TCP_PORT_DST: + case RTE_FLOW_FIELD_UDP_PORT_DST: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_PORT; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4 : DYN_TUN_L4; + fd->modify_field[fd->modify_field_count].ofs = 2; + fd->modify_field[fd->modify_field_count].len = 2; + break; + + case RTE_FLOW_FIELD_GTP_TEID: + fd->modify_field[fd->modify_field_count].select = + CPY_SELECT_TEID; + fd->modify_field[fd->modify_field_count].dyn = + mod_outer ? DYN_L4_PAYLOAD + : DYN_TUN_L4_PAYLOAD; + fd->modify_field[fd->modify_field_count].ofs = 4; + fd->modify_field[fd->modify_field_count].len = 4; + break; + + default: + NT_LOG(ERR, FILTER, + "MODIFY_FIELD dst type is not supported."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + modify_field_use_flag = 1 + << fd->modify_field[fd->modify_field_count].select; + + if (modify_field_use_flag & modify_field_use_flags) { + NT_LOG(ERR, FILTER, + "MODIFY_FIELD dst type hardware resource already used."); + flow_nic_set_error(ERR_ACTION_UNSUPPORTED, error); + return -1; + } + + memcpy(fd->modify_field[fd->modify_field_count].value8, + modify_field->src.value, 16); + + fd->modify_field[fd->modify_field_count].level = + modify_field->dst.level; + + modify_field_use_flags |= modify_field_use_flag; + fd->modify_field_count += 1; + } + } + + break; + default: NT_LOG(ERR, FILTER, "Invalid or unsupported flow action received - %i", action[aidx].type); -- 2.45.0