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 C8BBD45BCC; Wed, 30 Oct 2024 22:42:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8789343489; Wed, 30 Oct 2024 22:40:36 +0100 (CET) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 0DF6943386 for ; Wed, 30 Oct 2024 22:40:18 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2171.outbound.protection.outlook.com [104.47.17.171]) by mx-outbound11-85.eu-central-1a.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=SYXAMwKhNJxc1pqtC/Qyq9flbKxNbqNaGoaOevH2VzTqLE8I8Hbj7PMtiU1OcMpsy2ooa1JA33TvQTrBjwIje0PqwjrS208o/7YhiHHQwh7xNVqdgU1uKTkiu6EX7GeKiVOXdoP0zf6KfRzCqewMfd9tVsUpn0lRxmx8jBYXfyGDz5Zv4Fa/3/5j91ld/dnuAxDpfmYMAt0fONDh9F/f6xOPtMNFwRPvM1SvVoOLhW9QygwBdRF18fwYNfdx0M9DpYMXd8clvwzylhqZw+lOOmqZ98vCj2L3dPW5nVy4NLUBbI3o1hjakC5FzDDulkAO5VbFleYDqUBGlCMfHTTedA== 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=nNgZ/fcx45i8Y4C7RjEyVTBsI7Yex/iPyjd/zBxj2G0=; b=pNycjyI444YzYRMqqWjUvGwT7F4rRrfF8nXfjNSpYZ7okjOmnehZvr9kI+Dy3fYAc8iuJLiYImBTE48WCMG2J7S8trVzKrH9AMnOrM5Dz0YrIlYIuHKnYM5zKF8ojJKL5GUU7YJedbjUVLpTk41fKiI+PvcGeM8pqstfgmP9pXkngUJV295IT/J2KNMFvsIws98EwAWY34QlWIDvcx6yOZ++wcOy1fVridqqqp22xqgaT74bL0dQOUlTt8oiO9ox/Ag76SA0dP2Ae3jA8J2J/TuTwjU8REb7EDjncHuUYAb9vWTQ3HtQAPbOnF48TNB9Fal6lnqf6LASmNtLMtdMLg== 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=nNgZ/fcx45i8Y4C7RjEyVTBsI7Yex/iPyjd/zBxj2G0=; b=QBRKaP9NYgiB/NnkZOaOgeEwxSpYjK6D1/+utKrAjUDrPbtl++95r+RRVUHalTUK9kys2DVl+NXO+eb7PXQdUr/hJCwSkH/TyMSyVmkMdJVZNKPXN5wcYBs/wb5Twq/fbZQq1alv3VS2kzlWeyTKS2CO7KfPjkFHGS6cAkM9E8s= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by GV1P190MB1946.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:55::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Wed, 30 Oct 2024 21:40:11 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::b) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:11 +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:10 +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 21/80] net/ntnic: add action VLAN Date: Wed, 30 Oct 2024 22:38:28 +0100 Message-ID: <20241030213940.3470062-22-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_|GV1P190MB1946:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b33e3c8b-49bc-469c-14c8-08dcf92b6e7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3eAVSodzOEE0dXELMwhI4o1RCjZGMmDx+etO9tcu23v5eEGum6hC0Ip1EVYt?= =?us-ascii?Q?0RSa21tcr3gVMC15e47sDu40JmYC8BzB30Z/T2JS72HW0g3wuplbXgml3q5V?= =?us-ascii?Q?0f9uKtptZ21YvIQowHKlLnRmEi+3NlLt3FCVU5p4CYpd4zcsZqkoIQFqkX66?= =?us-ascii?Q?iH9vipUz0SJRIYkBdnJruGG1zl/Zh+HHpSF3vYphmhuEED7RCKcLpd5lUMKx?= =?us-ascii?Q?IEVa4dHLwDhSxid0AVfGplAhVGLVWlARQpa2UMio3OBizClCCGp7p8grPuFZ?= =?us-ascii?Q?xpcXUSwXiRktFktXZwrE1LyIZfcf4A397ZRJj1tP3rS5HI769vuKrbvnsNjx?= =?us-ascii?Q?j6qE773BDJzhC+kEIMOzM0Dd+eaUcTb6egT5J8AB090L+jtvIxf45kdCcqbG?= =?us-ascii?Q?MLdkwm6F7AVc5g3a6s0yrbydzGmzx6j+hjGgQp2/zj1geYOncnhnCtWYXGJe?= =?us-ascii?Q?rmXGCCWVPFm6u08jUJozAU297mZT4vo2dhVsDxl4z1RS2B+bkx4PVoHwNWTm?= =?us-ascii?Q?4GUC1vqo+xiV3zFEBSfDQJwhF18lMEiAsQXGm7bkWPjfj5pZfCysE2XKcoVE?= =?us-ascii?Q?/q9dnwTXPuk7z76ZBp5XD3Ngm/ZhhrhYegNBNduOe9XbPreOhuZuV65xHC2F?= =?us-ascii?Q?6728/5Fbo3bJil/yEoNRJ8ug2qRLup2xSUhIH+n0FbgMZ577fyYpkU2jPHjT?= =?us-ascii?Q?dWi12cmLzbopmz1AU0xsOLpt1xIw8kwIEPiKsD5HPEEt76owSbIv9unBROkw?= =?us-ascii?Q?qvzb3JuIj0WtmyzkjNkd4IIElQzyS92o9LICjKAyNW85Vim7+YBl5F0epLvU?= =?us-ascii?Q?36lOEqqctXZkFCtlJ+rDFIDqphI/9g0Yq2/YWtmh7AxYfjU7OdzaEOyUfzH1?= =?us-ascii?Q?YA2lPD4nDReotOoR3MgEN/yGVfpFbTTDstichFrw7UbxqJP7EDMsNddF0+Lw?= =?us-ascii?Q?iIan2J16B5f3tU3Wa4xSUdvcccZR1jCmGibSBGnoSEUNvlefxSyZOptJ7FpG?= =?us-ascii?Q?EZcYSESMHlzE3+Ju3kZwBnIPyinfp96GAiZeWZsJ5mcdsO3Fo5aQMuZ+VURb?= =?us-ascii?Q?jwN4rZuwBe8z1X2+0PxkW+4vxB/NkREvLOG1ZEByUroe9B9JChB5Gam060et?= =?us-ascii?Q?+lTWqa20XYNocOI0dopsgI5JxRZGVlOUwQ9Cnrjgf4WZfxxlWX2kN9fcr74d?= =?us-ascii?Q?XWNYgD/Q0Pfzw/f8bHukUGEagLVUApXdNJHyGF+XPDw2+ic8OL8bt/p7/OwE?= =?us-ascii?Q?O2jkf7g4unfgyVaKvlElsP8dgnoxVNijwyvgUPdG2bmy3HaGTuaopibNsr3m?= =?us-ascii?Q?emLGTp5L54ZN0GTJwgXoWQJQQETqr7plR6byxogiIRtk1nxuvpOC2Irftrja?= =?us-ascii?Q?CNwuPjS9qA+65ImlmwqJG++VCj1F1mzR/TIRAM+FlzCTVMWiIQ=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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1vMMattNUHtIFKNJaDlrekGIXvkuErMZIQFrdPGTXRFay+GCQlscDLD2oBdn3KzAL/ac9vqZJF21tA2hZNZqlYxIkwhWEBhM882Yk5/5KVpwo8fPDSiNwNPmBZOAwnQtOk0L9RKDSZq3rxlrKiEk+6ABWX6OayKdC9/6WZdSbI8lh3+/j2vR1TKIWGq5Krnsl7hnnwBOr47lqWn/sn9Fjr/Ezq12bVNuX0yrteMC+yPlUIJxrhgiGqrINHX7MKN/nIOFTarzZGUNJCNu9HyaaiJRT6yvlkyv4Q1WH9/L8cEO4vF75dv2cFHslgM5Lwiz5lvPb9zxaNgOgVAjzVBH5M+bio4hp7Ixj4acYPTiJ9zlAz3FrQFkKtEQh8FNOWVw0LnzFrRdyE6fG1cOhH3po0pPMh/dJ6VCp36fCI4WIFL25Ew7F4wGQH1cezkWEs9xuDsuFsIQgjGvlgKgmD2OGVFu3UxA/LfwHHZSKCBgMWtzNz0kiXaBCHF2Myw6W8qvLUwsd7TF0QFBpFYQcLXnCj4mnzNfE4fi0+2h/fP+/mZHlclM3FGFXUNVTdBL8DblE1msF7gScvItVkm2fYITXajGnek2PdQCgMHzbZdVEjZ9Bc6YDKvLknOTRiTnmO/fgouifwrqhHg+BdZo8uUEBTMTXbLjac/pDysehH0+Gew= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:10.9269 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b33e3c8b-49bc-469c-14c8-08dcf92b6e7b 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: GV1P190MB1946 X-BESS-ID: 1730324415-302901-12794-43460-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqaGRqZAVgZQ0Cg1zdTA0iTFws IszcDQwCwp1dDA1CLVyDAtJTHRzMRSqTYWAGNMPqtBAAAA 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_ITEM_TYPE_VLAN. Signed-off-by: Danylo Vodopianov --- doc/guides/nics/features/ntnic.ini | 1 + doc/guides/nics/ntnic.rst | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 1 + .../profile_inline/flow_api_profile_inline.c | 95 +++++++++++++++++++ 4 files changed, 98 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index e3c3982895..8b4821d6d0 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -21,6 +21,7 @@ ipv4 = Y port_id = Y tcp = Y udp = Y +vlan = Y [rte_flow actions] drop = Y diff --git a/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index d43706b2ee..f2ce941fe9 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -46,6 +46,7 @@ Features - Scattered and gather for TX and RX. - Jumbo frame support. - Traffic mirroring. +- VLAN filtering. Limitations ~~~~~~~~~~~ diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index a1aa74caf5..82ac3d0ff3 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -134,6 +134,7 @@ static inline int is_non_zero(const void *addr, size_t n) enum frame_offs_e { DYN_L2 = 1, + DYN_FIRST_VLAN = 2, DYN_L3 = 4, DYN_L4 = 7, DYN_L4_PAYLOAD = 8, 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 4c3844e9b8..627d32047b 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 @@ -504,6 +504,20 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, return -1; } + if (implicit_vlan_vid > 0) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = 0x0fff; + sw_data[0] = implicit_vlan_vid & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, DYN_FIRST_VLAN, 0); + set_key_def_sw(key_def, sw_counter, DYN_FIRST_VLAN, 0); + sw_counter += 1; + + fd->vlans += 1; + } + int qw_reserved_mac = 0; int qw_reserved_ipv6 = 0; @@ -664,6 +678,87 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ITEM_TYPE_VLAN: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_VLAN", + dev->ndev->adapter_no, dev->port); + { + const struct rte_vlan_hdr *vlan_spec = + (const struct rte_vlan_hdr *)elem[eidx].spec; + const struct rte_vlan_hdr *vlan_mask = + (const struct rte_vlan_hdr *)elem[eidx].mask; + + if (vlan_spec == NULL || vlan_mask == NULL) { + fd->vlans += 1; + break; + } + + if (!vlan_mask->vlan_tci && !vlan_mask->eth_proto) + break; + + if (implicit_vlan_vid > 0) { + NT_LOG(ERR, FILTER, + "Multiple VLANs not supported for implicit VLAN patterns."); + flow_nic_set_error(ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM, + error); + return -1; + } + + if (sw_counter < 2) { + uint32_t *sw_data = &packet_data[1 - sw_counter]; + uint32_t *sw_mask = &packet_mask[1 - sw_counter]; + + sw_mask[0] = ntohs(vlan_mask->vlan_tci) << 16 | + ntohs(vlan_mask->eth_proto); + sw_data[0] = ntohs(vlan_spec->vlan_tci) << 16 | + ntohs(vlan_spec->eth_proto); + sw_data[0] &= sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1, + DYN_FIRST_VLAN, 2 + 4 * fd->vlans); + set_key_def_sw(key_def, sw_counter, DYN_FIRST_VLAN, + 2 + 4 * fd->vlans); + sw_counter += 1; + + } else if (qw_counter < 2 && qw_free > 0) { + uint32_t *qw_data = &packet_data[2 + 4 - qw_counter * 4]; + uint32_t *qw_mask = &packet_mask[2 + 4 - qw_counter * 4]; + + qw_data[0] = ntohs(vlan_spec->vlan_tci) << 16 | + ntohs(vlan_spec->eth_proto); + qw_data[1] = 0; + qw_data[2] = 0; + qw_data[3] = 0; + + qw_mask[0] = ntohs(vlan_mask->vlan_tci) << 16 | + ntohs(vlan_mask->eth_proto); + qw_mask[1] = 0; + qw_mask[2] = 0; + qw_mask[3] = 0; + + qw_data[0] &= qw_mask[0]; + qw_data[1] &= qw_mask[1]; + qw_data[2] &= qw_mask[2]; + qw_data[3] &= qw_mask[3]; + + km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4, + DYN_FIRST_VLAN, 2 + 4 * fd->vlans); + set_key_def_qw(key_def, qw_counter, DYN_FIRST_VLAN, + 2 + 4 * fd->vlans); + qw_counter += 1; + qw_free -= 1; + + } else { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW resources."); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + fd->vlans += 1; + } + + 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); -- 2.45.0