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 69B2545BA3; Tue, 22 Oct 2024 18:57:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7BD64068E; Tue, 22 Oct 2024 18:56:27 +0200 (CEST) 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 49FD340B8F for ; Tue, 22 Oct 2024 18:56:18 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GG5L5/+A6DcWkwQ8zn1VqqBJKCZCBeuBpYcQfCIQORWWpHfWLoUFhe3VecTzSskk2jWK1AFgsmJqjmSXpm6bV/uAkx74QtBiywj7ZWBqnDYS1jI8FEh7A51+x227FsEED2xdOhedOCsLdKMgMuAgJ6zvxdpyC3jC7WQ4othurdIfIQenXdj+479d06vnOgB5qdFH2XmDJNsHdBQ1HBqwUS5064gxDirFhgSLyjHBEH8unZug0ePnBPG2FOC+3Qs+vDann4eBqz5xF66pnOBqZogoqTpncFExWNJj5mOv9x8oLtxALCJWZw7scRlGBXwMf/hu2P4/xm9oajjJacFIzg== 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=cwWq9TqE9IW0BMrRmFnaLpGVRruxg0TvFHLMG5U0ICqM6WOGsDn64LxJv1cph9qJEjiojhGkHJfI6A6r83l8DJVidT4XK+zoQMCba0/0smOYo4xVpKak0ZGbMpzUAJJYuWVCbfFpPrZg54klzancOeOBKL7Q50n52RAlhFyUnLopmIHDrz0kcD68LADF9KDTLqNBuruRDPY+p9TokRrx6tsNStal3XXqj42T9zcRUzFdJjrpkVbFiBIlYvf7rPy2nJnsK9e5nNqpBI7vBU6u1DYFTY/o4fqKG7Dj/MxD6VcPj9zyy9Z8nrDMq9vx9IK8w9MGUuWXYiGm8QT0VlIh0w== 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=i+xdkMKZTbKR5A5sT+LL9Tu9a9IXogAtUt5vj2TTddgnUA9YreITGU7hguLdcgRp6f6ChzcNs+9QjC6zjrfMH1QMKFCkhldnnYTFxiL3wRwMCgFWDCTXYY8Lspz7Cm4W3FFym2f/ySOxusy8UZ+/2dsUh5YG/w6hrviW5XYeLrI= Received: from DB9PR06CA0005.eurprd06.prod.outlook.com (2603:10a6:10:1db::10) by DBAP190MB0886.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1b0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Tue, 22 Oct 2024 16:56:15 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::db) by DB9PR06CA0005.outlook.office365.com (2603:10a6:10:1db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56:15 +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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:14 +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 v2 14/73] net/ntnic: add item eth Date: Tue, 22 Oct 2024 18:54:31 +0200 Message-ID: <20241022165541.3186140-15-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|DBAP190MB0886:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 7364dfbc-a1fc-447b-ed4a-08dcf2ba70ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MurRzeJ/bfO2R5mcfZlxuERrHvw0okJ1VIpyXfxSTzK0s7ZMuLsJd3X0y6Pg?= =?us-ascii?Q?Sq8rbHRZ0CE8WZ99HFMoOc+gCV48OI1su0uCygLTHHFzg0CbQsUVp4cGWKju?= =?us-ascii?Q?juvBX4VnTvY1/1/8rWBcONsPxJNMDDeK/r4Npl8+l07RtCRfHWQxQOS9Hq34?= =?us-ascii?Q?HqvsaFAs3eyxkdrgikwf4iiT4E50Jf6vAMO1QwyYHN2kBYAU6sLhIMLtyGZT?= =?us-ascii?Q?GYgWcg7xY86JvnefobRBP0sc4vmBn+fP6tdxyDsz7O3djSBsU2gXqYJSVPSw?= =?us-ascii?Q?2xg8SW0kYLnNnw8zTPjxI2cG0Qn9XKxhQ7IDbxgabjECC0lOEWQ5Z0b0QSxh?= =?us-ascii?Q?WMACxAANrKE8rMznSvUCjIT4pPoD6PCemYCOwx44LoNHcb1jTq9O+8jl/T9a?= =?us-ascii?Q?rLZeTqvjeWL4hg64psMSZIGq5cAhMEsI6UIyHhDu9p5enaDZaxmvyPXVaa0n?= =?us-ascii?Q?9mWo1WBE03dvuztBI4f8dHbcvE6lDFLclui5ns7JHe+q+pt+8trbOZ+HQPD9?= =?us-ascii?Q?ixZvLdBxIH+7gvxKt7EZt7K/5c62zj0hFNYuJzAAl9W4EYEPebogea3lgmkd?= =?us-ascii?Q?K3m6rmS7rxne5LOsssciWnhNgblCXhYuZPBxSRRf2EehhQCT5KjTaIT2LeR0?= =?us-ascii?Q?EEKybIyEd37YdX3p4KDb8quG7jYd+bhNYMPzitKs0f6JzEvtNr6cfbM+N79J?= =?us-ascii?Q?kgOm19swGqv7ZlpJjBwvAgjRzCyD+NUcn1REoxijddcSyOoHiuyxK69OAkUJ?= =?us-ascii?Q?BOyYPgjPJiln3+CRYp/oZ531aYEMtmtFlavJTN5DX2gFNBWI47i5lSXTJW24?= =?us-ascii?Q?ZXjD8kThkN9objNB93Gy7kdsehx0HaO1WHR++TdDu2qhtVRFScqMPe5Vc3sl?= =?us-ascii?Q?ZW1Fhw3h9zeSx51+JcXxnwmsrwixDh1YbdwCgIZoI8pZyMn6e15eqMQippZ2?= =?us-ascii?Q?YfufZ8xI95I8eqfgnC7D+5MPziOxJtQSWnW5vAnNA0sKiCwJI/WYB6gPVDoO?= =?us-ascii?Q?6BgekWyhjKgQ3/F0HtbXZAX8knLr37nmg1L/pJKNGgtou7bRI8X3eXP8/3le?= =?us-ascii?Q?4WAF7pZb1hHuRQvSJGUN+b1FSwGT5OcNeQc1L8B2FtNBlT4sK3Lyc3qJsu2w?= =?us-ascii?Q?PUZZJNfsBMFId0vQXedumnGk3U4iGQBV6j+FejXpwuJzYUM/aE/8bBi302AY?= =?us-ascii?Q?MFj9ffhgLdlIyaiHfEAJqyURu1xrC007F2TnU/78j6DwErAy4vMpsSePkVUb?= =?us-ascii?Q?V7Hurb0SkpnxOnp7RWK9i/BDFJ6O3/Sr3q4V9wFzMEKYaagM5RU2omnW1VNX?= =?us-ascii?Q?VKdgf2zgGtyXq/AL0iXFH6KyF0tUadVicqPb59PNjwfw5VKsLAtUwp8RQNWN?= =?us-ascii?Q?hU8ppCc0oPKNZMbDQxED9FZnopnLvVuxFP7ogyK4jWylQY6sUw=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)(1800799024)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Hwqz6BT7a+vDz5jBP5JBKacByy5SdeugMoVKBrbW7pEqgBROU1JsFrZCPhFfiCYVja3klDE+zFmqckynFI+ONiCNUDtQY12DvwyOVYbgo4vLgOHXEwtOGDl4Pi2PrF7vSjYHyVzlz3ECxchKUji5U3YduztEVf29HECTzaz/reuvfbemATYMR2aIh7IgfGqt8CK+rTDvBW+OfJWgF8/kLFtN/JSw0cxtp6Kb1+QI2stfk5JBZ7kWuAcrCx+q8tyDWbj8Oy5FNCy4wGZ6uZohnoiBMq55+xdYYy02UAZPodabwP496tDfxR3/Q4OtyqpqF5KFdlkXvC6RdkFQIbBPWXn0LpBeHY+jxPY84/2We0dzV+oenMHkikuLq1Xwww9GgLcq8WQ47NNtPdBTZCYT4Mfq4zRUwpNKh9no+fiVnS8ntnArgKbaf5LVDRHK2pmKr/sEgNa2zuiqF0+P6dl67GMuCk9mPBnvVNBjhlzHvX/YhPZA3Y039sk/pVjVq0LYNpuyg1rfKKadwaKwwNh0U4aA5ihLSsxvsEOxBJxKuDqhHfjO5dVAN4XaynONgvjH1DQ2W/+hSHj210PgJwGhs+7afe+AXTr86O7DE0vcsxvrAmUzQtgG9Y6e1A6QJTrO7BCmdDkMCNrmlmat2O4+Goel3BYrZqpyRGH/x56kaE8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:14.9656 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7364dfbc-a1fc-447b-ed4a-08dcf2ba70ee 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB0886 X-BESS-ID: 1729616177-304983-12650-14385-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.174 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.259902 [from cloudscan23-254.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