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 3D1F045BB4; Wed, 23 Oct 2024 19:03:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 778E342F47; Wed, 23 Oct 2024 19:01:19 +0200 (CEST) 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 1700A42EF9 for ; Wed, 23 Oct 2024 19:00:59 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2112.outbound.protection.outlook.com [104.47.18.112]) by mx-outbound15-83.eu-central-1a.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=RGFtJArOyBCLxOP50brGDeGlZCvss+5yAFGSRlpuiW4oe8cWVAAeJVJ6KI86y1yQ2Fgb9pY/qUpJQxt35H0nv5yXciCMaXWX/1HF2aSu3JGwrPuUC1KXt5gDntulK+RXACIifT1aW9+B44lfanUvbTQ1tP3gquuPvAQ6TufsRkE7YFf3ai6ajnlBXFoJoIP0wGEm+5RmlXAi2d01snlYI4jFwXCpJ5iGBfAQ2nNcNZhjn3uTRIAOjReLbuoawXilIDjhWO4RO8Z3CtkTGa1M+cwei+EzxAKMhpSSEuQGgW4k7wXgFJclvqhFVtpN5v5Q27JWdiLq7cPc3NuAu6Y8Rg== 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=7WcEVqHR7FHK1OyxfOhvgIVsx57bx54UAkxU8NYdUe8=; b=SK6Ynbd682ne4JqqNYiamr4d8QENk8urdsGyTSDRwlhW70p0TwkF1K8ReRcjQnY2JuogtY1sQi3ME9jjQ1WrZvgF4Q2uKsd82KHcfn0WcXz9tW6XZNbmJWV9lrXR8FgG1imoAhWeZaZhaJGLK90oG3Um4/AAvqjQIqN0WUe0Xu0tgC38GEljnoyVYQQzsqKnBk0z9MPYDzxbQchthYvStu1C5Z4Haw+NZkhThj0fgTaId3IsDEK/Fi4qTEDjLXNhVZPnDiZEMwo8R4P43dGvmik0A5QuFBm4GQeXuqLBqkqRUW0pVcXOGZQoRPWS2I9xNRZ8dRTf6OLwv38BzTsWCw== 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=7WcEVqHR7FHK1OyxfOhvgIVsx57bx54UAkxU8NYdUe8=; b=U1/aLipboMhnJIMSTncVuxDf/w5UpAwnymskjz9+SoP4Go+0HOsMvG89kzNIxtQkvUaCD5WLqRVrDQOLWxpFupchduE7wC64RTFKl+M0702xiUlDqT8XEGcRmuGatswmxneDd+3+HRe/BUs6ZMYBs49t0ekgZSxGv4DKnuvoXRI= Received: from DU7PR01CA0020.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::25) by DB8P190MB0778.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:125::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.23; Wed, 23 Oct 2024 17:00:54 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::27) by DU7PR01CA0020.outlook.office365.com (2603:10a6:10:50f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Wed, 23 Oct 2024 17:00:54 +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 14/73] net/ntnic: add item eth Date: Wed, 23 Oct 2024 18:59:22 +0200 Message-ID: <20241023170032.314155-15-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_|DB8P190MB0778:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 53e1d491-f6ff-4fda-78a7-08dcf38441b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?R/qjIEtdl82nY7+DbTCNKHTGGIUVdU4TCx2xdVeZ0eBHvUtwmlcHqqY+DvD9?= =?us-ascii?Q?didBIXaQvJSFqZnaF4tVnYAUuZcPsNyvms4Gim7Ikih0RVQ3G2ReKxFOh0f9?= =?us-ascii?Q?lLWHjvyjR2kpimnSbcwEQnyCUUnSQvfCklTB3Y+HKZMaeLKwTJ971STrZ4NX?= =?us-ascii?Q?DlFJ9uwDE3i1AyyZNnl6wTqWF1p68GqG9E4Ej5H2qoPtID9iikI2DLkywwlg?= =?us-ascii?Q?kFWXIvUI3i7SGxA++5V3+6jnGxpGYIV4wEgUKDQ+oO+Fb7VokrOxOX+wzgTP?= =?us-ascii?Q?0JpLaO/sxrQcNaUWTC4S3sHhfmVCbyuGT1qKl6KqYtWtIC0ONFnRBb7jWagB?= =?us-ascii?Q?j2RfX0FvcrwVbdkbXs8w0of5iobLOlg0Dvys6ejvn7lRNiGRx1YMnvCIkeXo?= =?us-ascii?Q?RgfhgbrbTaxaZLlzxAW3ibOTJKl25NIHimmxvXstbjvmS101GeTTCm8KiCd4?= =?us-ascii?Q?8Bl6AbB6ds5o37zCmKTz7yjcogkiGnxyR3Udpzn86ejkvnuvCQizy5dTo9OU?= =?us-ascii?Q?6PHf6Q9XnVNwMKLTc1rxPzcFIQfDjO/20a1+e4vMK6s+RNdoiduKEgJjawzu?= =?us-ascii?Q?ErSgPTE8IiyHD3bm+ezHvFCARQyMbpT7ELh33Kp4GXr8zCBdWO4E2Wnk8d0G?= =?us-ascii?Q?fWEjaREavjyD7vYKHv6SobJZJApRw8W5+tI187jEqHi3luo42h8UZ44yPGpZ?= =?us-ascii?Q?lwRpHw8K/72myUI8Tg2IN+eaKfotqmIzPqOekqmltiLaZ94jY9ChOpb8OZMd?= =?us-ascii?Q?fyLRIt69KVKU49j+tSU/99zgAOeT5CrGRgA/c5Ao8zc3spD+cJLV0F6QOX0o?= =?us-ascii?Q?fi79lFdWIaoevlPB6PBJGL/b+KS8L2iAbTpJwFZVIJkJP4joBIR+0Ixustb0?= =?us-ascii?Q?xhoQg6hyMsOG9EVaQxBw5YB2IOIm+iv1hRuKmOoSlL74AaKqfNM+MAFA42/f?= =?us-ascii?Q?RNmnPJxEnIuu28/HR1jqnsMeoMRdTQWtNdHJnDBz4PNUAKvnIS8WX9WnW3NO?= =?us-ascii?Q?q3sZq0W/l9Bh01HVmsJJJSDaKCk7mkGuOMrn5ZXC0jg+TCpOW9FC9rxfP4YJ?= =?us-ascii?Q?TU31tm8vSvDjrPAFnQNYImLzud9qOnVyadERsRDajN1mkFMHqvs4GszPhiAY?= =?us-ascii?Q?wlgfR0ri9c99rVOxhJRfqLftHPz5qKY5q7Up88CkRJjzHbJg9iBXkfay/vly?= =?us-ascii?Q?54gfYWm8P2WDavao8/YfbEZka/WVbu0FuGq5mtvcRO/EdrednTlFXcC543Bu?= =?us-ascii?Q?dKWgr2CQKKSWaHZh9zrQ4tREa5jbSLuh6Qv5HCSIlhq14MPxUllZHeS1M3JA?= =?us-ascii?Q?B7YLOgjXzJiqki44hJZDxL8vCIpyFBHqznijcnYpIGtwhx+yaB8xfEefwPqS?= =?us-ascii?Q?fsq5aloBxiwMSk6W8dzWbfX1lzOKSz7ZpL3M1YdjCD57jYEsbg=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)(36860700013)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nXHUSxrKh5Bgw1npuZqZA2KjzS7CL10l7yfrutz5nqguYJ5OVskzWE4ZDYIn6jaB2ORAgDZa+Jl9nUruQMAUIXqVaV7yyzItCSvBRZgoKF/IcQLl1t0xsDeEts+Qt1YNaIk2qDUT8XGTuk6poysYOCKBT0s50eAR/+XzzWpu41dJEHrlTZa9YV7F+SclpuWtmlMhcEnU/hiCzNN2sRrhbe/TA5frL7a29VX03MAGipkQufVJR4cDQoZgJNx2g78w9Fm4vIhXcAy5mHYDoZGBOGluIdsIi9FGuMuPk1OO8Llsgi/QDeg1tczvDJxTbYvvHzk5EFXkPJS8gNH524N09aLlfUWdibD11j8TKtiu7lrIvqF/uyY8NbA5am9FPZZvGa5cvPblU1jFU8VYqHhSEc9lbTWEx9YI1zRDCQ/dij0MghmOnq/cK/+SD3Y767niF77KPTlXRcIJh+ST4OrX6zfOIu5+8d3GHlJI20wPdJ2h/mIGL6ZARnwNRJ47ongVKX2b2U0k+ilVBYBjuqNDa5QXspYmk1WShzRd7szOOUwXUfoHZWUYaxj6GfqkiZvgdGE/ymvGPKZCn0RvRimfoNnP+jOGvJIqaCqV2oweiuavT/rsZvR96M+eFCiQt1wEXJ41yJVtsWY5fiyPgW/LjfVKWgrTDMUwzgE87WOSnZY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:00:54.0862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53e1d491-f6ff-4fda-78a7-08dcf38441b9 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: DB8P190MB0778 X-BESS-ID: 1729702856-303923-12646-43786-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.112 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhaGlhZAVgZQMNEyNS3VOM3MIt EgKcnENM0w1cLMNCXNzMA8LcXIyNJQqTYWAKoAZldBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259925 [from cloudscan22-191.eu-central-1b.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 | 23 +++ .../profile_inline/flow_api_profile_inline.c | 180 ++++++++++++++++++ 3 files changed, 204 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 99b207a01c..0c22129fb4 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -120,6 +120,29 @@ 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, + DYN_L4 = 7, + DYN_L4_PAYLOAD = 8, + DYN_TUN_L3 = 13, + DYN_TUN_L4 = 16, +}; + +/* Sideband info bit indicator */ + enum km_flm_if_select_e { KM_FLM_IF_FIRST = 0, KM_FLM_IF_SECOND = 1 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 64168fcc7d..93f666a054 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) { @@ -484,6 +541,129 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev, switch (elem[eidx].type) { 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; + dev->ndev->adapter_no, dev->port); break; -- 2.45.0