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 A3F0245BCC; Wed, 30 Oct 2024 22:41:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6981643283; Wed, 30 Oct 2024 22:40:29 +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 F14AB42E9A for ; Wed, 30 Oct 2024 22:40:11 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2177.outbound.protection.outlook.com [104.47.51.177]) 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:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UR6yZ0bI0UmJq2DlmDCEoDQzq9Uk5epUK+1mEW8BgMIzWHBfUpVMFSbc83M4/ecgZU/V3D6sK0+Fnda9JI1zllOWhNrI05xSXADkVtRz0zNtbnnQ0m3uBi3zF3aUOPAEVttq+QELcSs+rJnENRBYzPv7HSdRFGBDvvod5ZZ4YsbGCcmnbxVUh8LZi9kptSWKBUc+p97HkUxwrEkIjg9mQ8N+jxIQwFYOlK8kW+SHxb/lIAd8ejo+s8OtxNdagSkruPup2HobfEZ7Glngp7gfVlvtrUpCypWoJkGyGQn31vpGIOkltDkSH8VScaiu2xFHS6rufb0WR1TBBpAE7AObbQ== 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=hb59sJEvYrtN8y/jilsriaBMgVvgQYJ1I68HMnYeYUY=; b=uLvZ1fIRBqVZ5kHaRS7y0oI7hATOU/08bR2VYYJK3mzUiOrdOWKvUzheMux3Blt/PhdSRIOcc9FBIBddMrcDUChsRZY9r8TSUdam3+GST3OzA5vncN8bSutyYY9sxXhcG7Ugxzdx0YRE+25KX4ZGCCJaDOxMCAJgs9FzLM1VbiMDfh6yOvtCRUyt8lzMSy5PUpi/UpkMKJ3URPuGAqQvfpQMei5w/wUzrKm1VjU7j3y3xFcKH6AO5h6XIa/CiANesfBQUPCh5/PuBgmiNa9gj4bb/PeUov+lOrj06EAKyHtKfIOqDNoIdGTdIz4aNfJZDlxMcwqQJpE6jX9+2lbTYQ== 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=hb59sJEvYrtN8y/jilsriaBMgVvgQYJ1I68HMnYeYUY=; b=klM0a9HEpx3Ek5dp1ha8GDVCHa1icHZ8fz+GTAjqa8q7AcNh/M+6xBKnrJJ3tOp9ugV8Yi7nlRmQ9N4pbODmgjMiTONV/oh8id0ALG6T0wXmnvgOeVQWjaOrA9jdxfqp4oLZjvqzEA2Sqcm0bAn+LNHeT3Lh5c7+nrL/Rne0/uo= Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by GVXP190MB2073.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:157::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:05 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::6e) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) 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:05 +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:04 +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 Subject: [PATCH v5 14/80] net/ntnic: add item eth Date: Wed, 30 Oct 2024 22:38:21 +0100 Message-ID: <20241030213940.3470062-15-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_|GVXP190MB2073:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d8760c8c-c68e-48e0-8d7b-08dcf92b6ac8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TmTIxY3XKUIuMs2EuBppyRKWyIpx+roYsD/8UVpemmqMMNnSI3DtlwFMDp4r?= =?us-ascii?Q?B7X1XRgSC47YIQB6auwoGO7RR+36xBYEQcLzPskhvwxIna1vzmvx5Gl2LZ8G?= =?us-ascii?Q?spNdLX9oLuh1zq16OZrnNVNPDoAU/6E0RF9zYhr5K1ZTfma76jJDABnzf0aC?= =?us-ascii?Q?e3XFG65mAGljfjZWiqxSPZTvg11nPYzv0Qw2+TR4mFh+LVr3woLeZ625MxHO?= =?us-ascii?Q?tM6hTA80X/exlkKhQy1BtNX9nApHYyqG5h8CNQfd0U4ywsWZtnwuREJ8RPtc?= =?us-ascii?Q?hqcqe5At6VLbr8tWNpuJEoDhYgRUrBY6A57KvC3GQ2wRvOr4Sws574h2kcIn?= =?us-ascii?Q?7jRYkRTIuQuKuQ1saXe5Zb5l/MfGwRSMkC/0ANZJ+rePYw6e5JnXcNPLfQ8E?= =?us-ascii?Q?ZWhzKEEzebBVNpMgr/LKRMHvBA96pRA3kDO1dO4wTTcmvYNPN+kVWrM0ljOB?= =?us-ascii?Q?9h4ZCVv8ufjwe7S0MWLants+FT7BRmnJB3NzbWYrgxdfN7pKQmxI+uXO3kuQ?= =?us-ascii?Q?i911g0TTLGCbYAmlQsG00FV8+2pA1AgjtkcVKmAOn9P35fZLrq98BLspXo3e?= =?us-ascii?Q?VpFk1Q8c8ekJOlXmB5nxIBRFNUYjVGgAaVS3GQc6Xty0u8QH5mqIuiB2uqWt?= =?us-ascii?Q?U50+T9GOCfGym1eWI70Syyl1tISa4FA3lzcRbJ2JiSnxyMoElHS4X6yHdflB?= =?us-ascii?Q?07k5Q7O7MoPdYm2tTHFnJ6wfdyO1L0gUuukfMGycMY/21GM+8xEjj/14KDkY?= =?us-ascii?Q?yhlLl8+Mantk8qa9ZqPXlP2wNjYhAzAgf6MRz5aYVttUXj6Z9SDFhzir7hgY?= =?us-ascii?Q?GRmridmEyAd7OYfslEyPbRiJZ4nllbCgD7D8Sz5QxsSrqIwSym9XFa2PCGCy?= =?us-ascii?Q?f2OHMyZe5VFONv1ULXJ+YSEZaQ04vAtP2luLMSkqFINqJRp5y8jT+4QTV/hT?= =?us-ascii?Q?DihcbzIqhfO5+Wh2CCmAng7o1UgvOYjOHa8qHbuogYeerZz9gdg0TYSHPiGF?= =?us-ascii?Q?cyEAV4uWqhBXK2QnM62SngQi9pVkKBn/hskhzgEpiZJutFcWMWzm1DMhmna/?= =?us-ascii?Q?kHrHYafO3HeR+AHsE5AWirDOFPPEzySAIDFabL8TRhUA5Wo2NDov3WzMH6Iq?= =?us-ascii?Q?+Rwwy7sEKzIhMdDi1E4f8hN2Zo4+cSUH29kw+9cy6GiXueERpJGE5bnhmOhc?= =?us-ascii?Q?GbZtAlpVgsdCS0RHK7aXVtpw7ZXrRfS2+ZVQFzNrYXybYlSczcIdvnn32ZBy?= =?us-ascii?Q?Uq51UPg3ZQw2m5wSQEsEibelHqVZ3ePyNUwapARyHTLc4LV4P+eLc3pT4Uax?= =?us-ascii?Q?Iu+klyB2ZEkyFxCtyqJZPTa5m1RoyKHz6PijjO4lZfDcmkyeclKmrPqOmce5?= =?us-ascii?Q?/hEPjebt3EhBqp3OXkVLeqNPG1Zeb8aeaxmbqVDuU7E5vCrnJA=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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aYPWR/ZNkeMY2zxu4btLKp2vZVG/wI5zxem6AIF2r+JL6elE6p7zMN8C7Zb/YYO0RgXHZZlHXIkkau3gMXwNJ4mvIhqcmeXaCI2+ThPF7c8iALTaPN+xPHWEI5YinAQbPfWx1EWEVCTTtr7yj2d07uNBoCUJZDfVLOajWPQ9NlRCLUp3bjdm+9Sd3Vz3vBz37iiQlD7p9udUVVriqAmgkVdORKgnLM1eRc9drEYWYdo2kcPIMutMkVkOj+pY6x9q+7UY2bxpzFm8jl9qVOiN1joH9x02rFU7n5P9QHbyfnYxT1gzo3XbF79CF4eHfeoqAPhGtUh8WpRFqZkz5l4Fuco4DANjITWiQ5CovGPI0A/tLXwGFepxO967nllIya+fWkv2lZ+JU3iBhITszhOzZRlPz+FoS8XMRdq7SdQEUtPV7xSFCRKJ3CGObQAkmIom+WDcyrwQDU6hayj/Qh0+mM0RV5BZeJLTYxE1FDc9mRsURWM1XalG58aU9Fn4WHXcJEzoVUryQ443wdYNQgVCZHJitNycQfpgHXKSxW15+pa5UKm0zG6htATmE3iaNzpvK+Y+bwr4qqqug350Ig6cseWRSJVKCGxV40tCCgT8SUHdPNmxxtLPvdIMGtgg8WtsM1AGvqCASTYiQLq3G3sM31kGGDwpA7WzvfJBFjKWLNo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:04.7549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8760c8c-c68e-48e0-8d7b-08dcf92b6ac8 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: GVXP190MB2073 X-BESS-ID: 1730324409-302901-12792-43452-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuaWxuZAVgZQMDk50cwkydLAwt zCwDLFIMU41dwi0cjc2NDUPNHYzCRZqTYWALVgwiBBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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_ETH. Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + drivers/net/ntnic/include/hw_mod_backend.h | 12 ++ .../profile_inline/flow_api_profile_inline.c | 177 ++++++++++++++++++ 3 files changed, 190 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 372653695d..36b8212bae 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -15,6 +15,7 @@ x86-64 = Y [rte_flow items] any = Y +eth = Y [rte_flow actions] drop = Y diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 22430bb3db..0c22129fb4 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -120,6 +120,18 @@ enum { } \ } while (0) +static inline int is_non_zero(const void *addr, size_t n) +{ + size_t i = 0; + const uint8_t *p = (const uint8_t *)addr; + + for (i = 0; i < n; i++) + if (p[i] != 0) + return 1; + + return 0; +} + enum frame_offs_e { DYN_L2 = 1, DYN_L3 = 4, 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 1d949b3b91..8ac1165738 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 @@ -55,6 +55,36 @@ struct flm_flow_key_def_s { /* * Flow Matcher functionality */ +static inline void set_key_def_qw(struct flm_flow_key_def_s *key_def, unsigned int qw, + unsigned int dyn, unsigned int ofs) +{ + assert(qw < 2); + + if (qw == 0) { + key_def->qw0_dyn = dyn & 0x7f; + key_def->qw0_ofs = ofs & 0xff; + + } else { + key_def->qw4_dyn = dyn & 0x7f; + key_def->qw4_ofs = ofs & 0xff; + } +} + +static inline void set_key_def_sw(struct flm_flow_key_def_s *key_def, unsigned int sw, + unsigned int dyn, unsigned int ofs) +{ + assert(sw < 2); + + if (sw == 0) { + key_def->sw8_dyn = dyn & 0x7f; + key_def->sw8_ofs = ofs & 0xff; + + } else { + key_def->sw9_dyn = dyn & 0x7f; + key_def->sw9_ofs = ofs & 0xff; + } +} + static uint8_t get_port_from_port_id(const struct flow_nic_dev *ndev, uint32_t port_id) { struct flow_eth_dev *dev = ndev->eth_base; @@ -457,6 +487,11 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, uint32_t *packet_mask, struct flm_flow_key_def_s *key_def) { + uint32_t any_count = 0; + + unsigned int qw_counter = 0; + unsigned int sw_counter = 0; + *in_port_id = UINT32_MAX; memset(packet_data, 0x0, sizeof(uint32_t) * 10); @@ -472,6 +507,28 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, int qw_reserved_mac = 0; int qw_reserved_ipv6 = 0; + for (int eidx = 0; elem[eidx].type != RTE_FLOW_ITEM_TYPE_END; ++eidx) { + switch (elem[eidx].type) { + case RTE_FLOW_ITEM_TYPE_ETH: { + const struct rte_ether_hdr *eth_spec = + (const struct rte_ether_hdr *)elem[eidx].spec; + const struct rte_ether_hdr *eth_mask = + (const struct rte_ether_hdr *)elem[eidx].mask; + + if (eth_spec != NULL && eth_mask != NULL) { + if (is_non_zero(eth_mask->dst_addr.addr_bytes, 6) || + is_non_zero(eth_mask->src_addr.addr_bytes, 6)) { + qw_reserved_mac += 1; + } + } + } + break; + + default: + break; + } + } + int qw_free = 2 - qw_reserved_mac - qw_reserved_ipv6; if (qw_free < 0) { @@ -485,6 +542,126 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_ANY: NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ANY", dev->ndev->adapter_no, dev->port); + any_count += 1; + break; + + case RTE_FLOW_ITEM_TYPE_ETH: + NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_ETH", + dev->ndev->adapter_no, dev->port); + { + const struct rte_ether_hdr *eth_spec = + (const struct rte_ether_hdr *)elem[eidx].spec; + const struct rte_ether_hdr *eth_mask = + (const struct rte_ether_hdr *)elem[eidx].mask; + + if (any_count > 0) { + NT_LOG(ERR, FILTER, + "Tunneled L2 ethernet not supported"); + flow_nic_set_error(ERR_FAILED, error); + return -1; + } + + if (eth_spec == NULL || eth_mask == NULL) { + fd->l2_prot = PROT_L2_ETH2; + break; + } + + int non_zero = is_non_zero(eth_mask->dst_addr.addr_bytes, 6) || + is_non_zero(eth_mask->src_addr.addr_bytes, 6); + + if (non_zero || + (eth_mask->ether_type != 0 && 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_data[0] = ((eth_spec->dst_addr.addr_bytes[0] & + eth_mask->dst_addr.addr_bytes[0]) << 24) + + ((eth_spec->dst_addr.addr_bytes[1] & + eth_mask->dst_addr.addr_bytes[1]) << 16) + + ((eth_spec->dst_addr.addr_bytes[2] & + eth_mask->dst_addr.addr_bytes[2]) << 8) + + (eth_spec->dst_addr.addr_bytes[3] & + eth_mask->dst_addr.addr_bytes[3]); + + qw_data[1] = ((eth_spec->dst_addr.addr_bytes[4] & + eth_mask->dst_addr.addr_bytes[4]) << 24) + + ((eth_spec->dst_addr.addr_bytes[5] & + eth_mask->dst_addr.addr_bytes[5]) << 16) + + ((eth_spec->src_addr.addr_bytes[0] & + eth_mask->src_addr.addr_bytes[0]) << 8) + + (eth_spec->src_addr.addr_bytes[1] & + eth_mask->src_addr.addr_bytes[1]); + + qw_data[2] = ((eth_spec->src_addr.addr_bytes[2] & + eth_mask->src_addr.addr_bytes[2]) << 24) + + ((eth_spec->src_addr.addr_bytes[3] & + eth_mask->src_addr.addr_bytes[3]) << 16) + + ((eth_spec->src_addr.addr_bytes[4] & + eth_mask->src_addr.addr_bytes[4]) << 8) + + (eth_spec->src_addr.addr_bytes[5] & + eth_mask->src_addr.addr_bytes[5]); + + qw_data[3] = ntohs(eth_spec->ether_type & + eth_mask->ether_type) << 16; + + qw_mask[0] = (eth_mask->dst_addr.addr_bytes[0] << 24) + + (eth_mask->dst_addr.addr_bytes[1] << 16) + + (eth_mask->dst_addr.addr_bytes[2] << 8) + + eth_mask->dst_addr.addr_bytes[3]; + + qw_mask[1] = (eth_mask->dst_addr.addr_bytes[4] << 24) + + (eth_mask->dst_addr.addr_bytes[5] << 16) + + (eth_mask->src_addr.addr_bytes[0] << 8) + + eth_mask->src_addr.addr_bytes[1]; + + qw_mask[2] = (eth_mask->src_addr.addr_bytes[2] << 24) + + (eth_mask->src_addr.addr_bytes[3] << 16) + + (eth_mask->src_addr.addr_bytes[4] << 8) + + eth_mask->src_addr.addr_bytes[5]; + + qw_mask[3] = ntohs(eth_mask->ether_type) << 16; + + km_add_match_elem(&fd->km, + &qw_data[(size_t)(qw_counter * 4)], + &qw_mask[(size_t)(qw_counter * 4)], 4, DYN_L2, 0); + set_key_def_qw(key_def, qw_counter, DYN_L2, 0); + qw_counter += 1; + + if (!non_zero) + qw_free -= 1; + + } else if (eth_mask->ether_type != 0) { + if (sw_counter >= 2) { + NT_LOG(ERR, FILTER, + "Key size too big. Out of SW-QW 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] = ntohs(eth_mask->ether_type) << 16; + sw_data[0] = ntohs(eth_spec->ether_type) << 16 & sw_mask[0]; + + km_add_match_elem(&fd->km, &sw_data[0], + &sw_mask[0], 1, DYN_L2, 12); + set_key_def_sw(key_def, sw_counter, DYN_L2, 12); + sw_counter += 1; + } + + fd->l2_prot = PROT_L2_ETH2; + } + break; default: -- 2.45.0