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 41B9C45BC0; Tue, 29 Oct 2024 17:45:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BAB442F09; Tue, 29 Oct 2024 17:43: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 59A5542EDB for ; Tue, 29 Oct 2024 17:43:07 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2170.outbound.protection.outlook.com [104.47.17.170]) by mx-outbound12-25.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D+TQm+Qm1Can27WeCsKhSatn77K1Bo4Yq8+nWGhxrKnJY6gfUDHo1hJ/OCf0RGglUHwqjOZuOPsYukPF68a1YPH8WiX+0gBToVSJ3sgcLLW16v7Y1QJvHeMiz0VZBqkpuGGF3tRmxLYPNupkYNgpWQzVS7G0BH6zvZHSoxNU0Ytr7Qawc1zPvnr/6ysOTlpw15/uwsIs2j+0MQldzyn9Hfb1jJ+4dkpPnYR2nKwCwNED/yeSVfOgaGPrNYqfvuF3cUyOo1rQzXwgjmD5hkQ90eKepmX7Ky+SLBEJQ6OarPmeRDziHF1jxUmeoLwq8pfcUok2msn0dKH6OVTZNCaAjQ== 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=M/2lRHQ80FW29JeJ3y9noBGFLxVERI+Gk4A6DJkaEfyh1TR5Va8iL/CVzR7t+NsK2Jk/tfL4UNfaX6kDHbvhUuqGgUdokz8FoxaPX56tcRMk0AxMHCWfGNVluuEZyKfDwvOUjGh7VlyeAjAU+o7f/tQhdVOZ50ZG98AgUPGyuPX2FuQ0jLfCPcsXcwMaGo1y+2otzhcP2otN4wJ1XzyMCtlrkha8Itn/f+qnr8y/Wc//p6LkrDuX29yBYwVpNJJen+tdRYCOFnsCxL+OP0SBzbmZkQUyzhwWe7ajIWuP5rUYG9tS+T7/bWFDNg+B9KZq5rXcvWk1+brNV1o7Qc0EYw== 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=N1b/7UmypGc+VwH0R5rjRhQY9rHkkqY5G/v9E36k5thEOgHpC6l4fxI5JZiWf2n5znfwznEHVjStPwSYjvpo2RP5GVIiwVc6mNJ/UV4sw9fnQho/NWovU6K37Oug5efLo8Mk23Xfjnsqjwp2YO9Cr/OEj5Ao/Q0hn9qSP3j+9Gk= Received: from DUZPR01CA0199.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::28) by AM7P190MB0615.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:11e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:00 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::32) by DUZPR01CA0199.outlook.office365.com (2603:10a6:10:4b6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:00 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:00 +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 v4 14/86] net/ntnic: add item eth Date: Tue, 29 Oct 2024 17:41:18 +0100 Message-ID: <20241029164243.1648775-15-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM7P190MB0615:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 16a11a32-6d25-40f5-3e98-08dcf838c033 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?R9tLetmEsVKzbkWxW4oXsULCKRcwuIo/9hgAtQEL7bvkCCcZEtZ519uQaVck?= =?us-ascii?Q?+MHku0zxUXezyo2KX81S8LPR4DEtzHkunX5/1p0c2V//Akhvs8hb/aMuj9qJ?= =?us-ascii?Q?QSaraKe89o9j4J4h0htg+sZ77YnSSRq4tg2hBWClj0SbSaR7KRx00K7tHJkI?= =?us-ascii?Q?34qDz4XvH+WHPoidNgO82vrPiLT/X2b6nbBsmnt3/oGUEn9mmhepfuLd6L3H?= =?us-ascii?Q?mvLZZT4BUSYKbH5CQGwLhMGJijpq7JCuUVKCHxP0qWLTJny2LVL/ETIaVaN6?= =?us-ascii?Q?HV12SUI7cughD/Wlo3O2qODnScHVBbyp7pQB4aHNWVS+rTUmNBUY3xtrVZt1?= =?us-ascii?Q?yL+kyfVpdYp+9I0lLRAd9itMNzjjVo8fP/zOkMF9OuDxqV5GbTRQMyATeoFE?= =?us-ascii?Q?9H9HcFFRGvneB75P1JqRMEF2KyRa6g7yfeZYytEIAA5g1w44LlpE+JEbKAjK?= =?us-ascii?Q?13HynG41hDrCaTSH4KwyVVqdrs8lMzxcbrz40o0Lc5AxXcqAPKui0fTUcAQB?= =?us-ascii?Q?vkDf/vXRJIUmIUfz8/ES9DIxE1uj0m46gwCBDn2P0G4PlYPO4ZSmzb+7CSfK?= =?us-ascii?Q?9RU2xYXFhCOFuYhqBBvTO0yvVq0Dhc+UPmJeFbK8iOFRB0deFRp6VkQ9w7y2?= =?us-ascii?Q?sSfV4FwU9JV/WP0byHPvJqddvf+YEl+FNH8KWDhFe1YNUrZlMTojTkHqi/jA?= =?us-ascii?Q?hPCzdMwvDArD4xCOxl+LfZfPNNLyeUWOLyw/93/SlVb41omV279my1Vxu1L9?= =?us-ascii?Q?Ki+EHTirVrsStTNHMD907Zpc8CXrBQBh4ExrrdUpC5E25IcvS/aKSAF9OC0D?= =?us-ascii?Q?hluGGYkUui4l7/hDA9PaS1UqWVJAfUbb01gKSGH+S9hzfG5m02T8E0g7OdCt?= =?us-ascii?Q?kEngBIt3zE3h08ZOqKPQm40XmzeGkOcM3wKI3AgJqllWRtoWXIpaMmcwDinY?= =?us-ascii?Q?afe7l8GAkvPT8cch3LQOwVdNkUdf9q1hji4JWz8GUCwaZPs0IT/D8V10enJT?= =?us-ascii?Q?A5/5HBFaqfkXX1BGIfkbQ48sJJ1bndgPxlIY5ZzlZ9prvnBh7G1VgG9D5GIM?= =?us-ascii?Q?tG8xD07p9m6Ru7ValFTLNzrR/mnu9fgn8NylbR4ipXQpWsXD918+venci0Vw?= =?us-ascii?Q?49q2t6MR8cfvqbfvhLUzj2QnNzL9uifCdanKPnrLP8yIKKAyKxdl06FNe3p9?= =?us-ascii?Q?GIogLMdB72aCjAuv3xieqDoJLaNe2c8mCw4yYXhctdtd4KG4l6AkwbADKpqm?= =?us-ascii?Q?4MGSMfasNJiXfUmxQY4OVTjbLBtN19bQ/TSR0A9iWZ6vsbaFIJloJfi82Iju?= =?us-ascii?Q?OhZdUYTlopjqpO0J9iymFh+78yh+Vrb6/K9b3IsiDROYEP1mJ3pNwWcTgWTn?= =?us-ascii?Q?fbohuGChicBGXBOUrtW+BRbT2kFXp36y6UPxqBegM/BvkzsRSQ=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: aqBk2uMVXrHVMzqgnvo0xXfpsZ6RuD+bgT4sfsW2baFCrYkVKMumDXO1iUR6Ns1Z86JQpnPd9pBG6bXbMyRmr/QG33RrgwpeFF96e8DZgbZIZ6SIFpZ3hiiqZ9QZtuwzuaKBzxMlc+SyZhm2iEpbH5ZAKOIHY4SzA5MIKyjWRx63nhWq0DlNFUd2X8gheuYDqVO5xyNCMQ7O0uX73NSagGV4P9EbBW0vRe8AVJWy9XMYhZlhtzJF7qN8aVJBgwAWqj60CGFUuGhxF2gv15q6fxmDh/Uvd2PtMdWGTSdCfIxGDCIGa2yFfBHm9v6QPYVKTU5g95IowyFQ1sTET892DuDTDS+zlAX+xkLpBW4Hszu1F/9YpynvlDoSp7lfE8le37GQi9QqPqqs3FWzOlCi9lUPJj1dCOxNXJF4c1IlNZ6p9ZdxSndkvSQuR/KOlIRuqCDR4IH5QAkcD5y14420eMRVmzskeH5IStDGUN+XPVpeAZ9yOsI4GkhliR4Y9kT/cOlJgQtpRwVRxWdBxpgcvxDSHaMfKDLITe9v8gxlZWPJyg8SmK2mpV0BFsGVqP0KZr9VO7XqyKBwqdbpND1b9wJdT2+kkFhN5al7d9j0VxX6uAPLXZ8p3lBeFTOso+MwE5kBKPvpOE3OJ97pxuauLrfs3voe0ukNecF8JnHQ5oI= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:00.3552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16a11a32-6d25-40f5-3e98-08dcf838c033 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0615 X-BESS-ID: 1730220183-303097-12765-29322-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.170 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.260063 [from cloudscan19-218.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