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 DB5034414A; Mon, 3 Jun 2024 18:20:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E78A542ED0; Mon, 3 Jun 2024 18:18:54 +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 C830F42EB7 for ; Mon, 3 Jun 2024 18:18:49 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2238.outbound.protection.outlook.com [104.47.11.238]) by mx-outbound23-246.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 03 Jun 2024 16:18:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mqCwNyjrQl9iRGks/D3AyzKmi7HwL3UuBcZkScBxpRNmFH1Hr4+szK60iivvhtC8S1SvXLaEE+Nx2g9uv6gLs30I46OqTUOjAdXM3KLQKYhmSH/eMOm7xUQPhRE9WopCXwyNmsEeD0fAdwu9iUP12kKOcHfyfbG3K1s2mQrXJQWyrrOOBB/8ZCUJObY+i95IP+OJqm/84CsR+K+IwasdLKB3wdsEMJy83gfDANNMZP5rfw+NBXykPthRfvqFRGdDDqFbnTwK3N/ypIIorn7rZRfiicX/CE1C7Ghf+GoqoHT/3eClOD5HZBCeEtPqd+yHy1H4PCTDf2bf4suIZ4YyPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=AjjT33uCXd1iUwF3ihC0HksEnhOj7wFpN9TSWWK8F/E=; b=Yf7u+T/wpQ9q+njuGK6PlFRH36U0PMk48GV9quwj9BqTeAfZ7UN0UjuOKJfjK8GomkO6/OQHI8K246X4HQiTM3xzEavFirb1NQ4gg4OPhtdTMzyMX5z8rFRL+arxLYHUpMd1O3qVsRgrY0vY+jSdtfjE6mkBXNFM+/OWxDbPdX0NPsCCF0sYLTyAlhLnvImrSZfllzN1p99oGvE7PV3ub7OZ008crdSSZOQOzSqBrnXzK9N04/BRbjuxEIQDnTFvkz26+WZnNBb7Rk172Ok3rKjAycrOq1bm+wJ5OCX50jkvts4yYRYNVLw38pvh7JGdXtbJyBlbqyltVhNvBbElpQ== 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=AjjT33uCXd1iUwF3ihC0HksEnhOj7wFpN9TSWWK8F/E=; b=FNNDaNzCzbOjioOldtSfDzoqEsABUHQgkM6Ag/HSmt7JAyCO/Sp0sroV3FnkO04dW5L0GGlICp+XWgtO6br248lqlVRChd2ulKDcPReKFS+NCAOzhUUXzEQlUHXXKGK2AHTHWdffmnhshXhm6R5bJkWV7VJJj2R+ampyuO10psM= Received: from AM6P191CA0092.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::33) by VI1P190MB0798.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:122::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Mon, 3 Jun 2024 16:18:37 +0000 Received: from AMS0EPF00000196.eurprd05.prod.outlook.com (2603:10a6:209:8a:cafe::b4) by AM6P191CA0092.outlook.office365.com (2603:10a6:209:8a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.29 via Frontend Transport; Mon, 3 Jun 2024 16:18:36 +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 AMS0EPF00000196.mail.protection.outlook.com (10.167.16.217) with Microsoft SMTP Server id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 16:18:36 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com Subject: [PATCH v3 08/17] net/ntnic: add interfaces for flow API engine Date: Mon, 3 Jun 2024 18:18:05 +0200 Message-ID: <20240603161822.59552-8-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240603161822.59552-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240603161822.59552-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000196:EE_|VI1P190MB0798:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 893c284e-4981-4394-fbb1-08dc83e8d297 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|36860700004|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7inl38Q2bHwojQr06twtA8sjEAxQRuKxFV3yb5VLLiQQB5vVssyKLOn4lRGp?= =?us-ascii?Q?KLAVG7VK54RJcrAjNaZtcSuGvjQfpoCiOfIJbk5SDTfuLVASwyI4tvq/Wa9m?= =?us-ascii?Q?PsHgCWXxF8banmvT3VVT+DovH9/f7wdhOIdXzCofl0B52HznRLhkadD9ZDCg?= =?us-ascii?Q?zW4yB7eQMUP61XIr9oscD7F89mOY/UVidOvHpI2CxJiVyR+/YDCc75MFRLcC?= =?us-ascii?Q?0B49pJPiBcwi55CwoOYRmjqCAaCQ/oir8U5gU22XLqQhoOsh0UN/ibKUNdmd?= =?us-ascii?Q?VBN6o4zMlASSqa5Hx8zhXyHva6NuBn+oX8zGp+EH+kgGo0Urvs8xfAlOh5jq?= =?us-ascii?Q?3+lqGbkuGiJ3NfYquFmLZQlQ3a/RKuQLiZHZrYG2z2awndRvbPsauXJnkaEE?= =?us-ascii?Q?w290Bqu9g/0yt2Y89juce6pZW+FAcMXe9IfCI/09gkE4Cc3KktdXYy4RZbqR?= =?us-ascii?Q?kaaksePFrQ2J2kJ9vt1/G33xl+EjSMB6n6vKnXdMxQK9NV6yuPa20RNIM3fL?= =?us-ascii?Q?MxmHpMbHL47EHv3ur3eAIv+0a3lbGRPfgS0TO2jWJC6RVWcffXEKDzigPuk2?= =?us-ascii?Q?m89UqLW6A85yWyrL/p38ctaqeGN8eOKpK22HqY+ngQFcsSDH9UWzm+3KIQbN?= =?us-ascii?Q?EnjYViAQq+rhE8pIpkWmcy4nGJYsVAFU6dTu5NAzcFpJ/snI9KlTItLw1FDd?= =?us-ascii?Q?Yxh5BzPn+g11C+MidROyKCTeBJ68yk+dJqJ3X9U8KQDMD599CQ3TGNXjXtML?= =?us-ascii?Q?Re3w3yOlKlD6yUrNytHVtPAv9043XvHi/+uQDdjZ0kddpHi9M7axqWGw2/ay?= =?us-ascii?Q?BX3UUMvMK971UmCc9aR2reNlR0Owuu4Etv2r4C5bQVJX/7HZozDtuFJL0Pq3?= =?us-ascii?Q?AM+7BVJiOMB7y7PBJtJGSJyJKFW53Yz0hGoc1WyyJ+YLYxtP0tukEK4cWspn?= =?us-ascii?Q?v7quJg+4GtBkfIcu5fMSBdbtbm/pI9b2qG5E4LZ6/Iz355t/IR/AlpBwmX7H?= =?us-ascii?Q?hgdzejB6MLuEn63dG9a41P5hRfWzu5TQfmYaO4gLKQpE6S8DeMPmiju4niI6?= =?us-ascii?Q?nYu3FGs5dLp61ngksllX20+n6WLncfFax6esKrICb+M1cIzoUKoyFrusLy+U?= =?us-ascii?Q?m/bE3aKsqz30RImaikG6xKeY28/nSpQY/lulKZRJ5YPo4bdEO9pF5+gbxSzu?= =?us-ascii?Q?Iw9NFPBKG8Ry2BO2DXhDKn7as/01tio0dNYxQ68B6ae0A5umEZXAN8tVUqOw?= =?us-ascii?Q?k0IxdOdA7DOyVoOmeYDvWEuDh4x3u3rGEhloLse6NCxt4yT69s+Uyyn4Md6W?= =?us-ascii?Q?+eRdZo5YoRqisD0jrx77kugl9bYPMcmYDzP1C0QilIUSziWnAPwcM/l3167T?= =?us-ascii?Q?37rocAU=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:(13230031)(376005)(36860700004)(82310400017)(1800799015); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nZpwktJoFbwtIkrMC1OcQJB1Ovu/7pQyemlT0ptaVVgGbGg7u3F4hAdsB+O7SXTbQwsbcyn0o6U+7K+fauDTwHDiXIZL8ZES0qcKC0H2za4f6iDJIkBn4FrI7BQw5wgIORS8bfK4ZmehuYVKG/AOBDV4Y5Y8/5yfrZsaR8x25oHwEA0Ufwel19T1qamf34fi1TmoIj+iUid5f44Lgio9Gqk2A7fUTB/79Pp52Fk+sAxKfrbgaf6+Ay3yDkWvD5bqpxAb1U5hAIZqodt7+5S0V24n8RIig+sh6ZdmskigCTUBwPxkmTItklF58x+Emh1eLKy8L1K28o/X5UJKvFhq8/mf5HL+U0tJhAoJ5jRjUBQ2402fxifSVjLgoKUBxcSH1gLeSD2ux30FYZF+JIL3iyx7zlEcPJMXX0D9YuLdTFlW51wRTPzSpa7scUogfIwY4esOC0DpZJy/M4sYbZs3TggCmv+q8zchAuaV0Ukd4pMxZ11gwwTum6vfk/ZRNO45AUWUMW1JkBR9R1H9OWvR37W7AVinsNhTzl5dKPnfkyF3U7+AQZD4xjGKpF4II52iJHxxCgV0hczvZzBP/q6lbVBVC2k3rQhMgmbgry6ZqC9H3hWVcVuJ3F1WHJSHjwjE70MUD2UYjRhs9N/jpw6CZw== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 16:18:36.7344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 893c284e-4981-4394-fbb1-08dc83e8d297 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: AMS0EPF00000196.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1P190MB0798 X-BESS-ID: 1717431519-306134-12662-9919-2 X-BESS-VER: 2019.1_20240530.1612 X-BESS-Apparent-Source-IP: 104.47.11.238 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsYmZubmQGYGUNTCODnVODnFKM 3ENNEwLdEsycA4zSwpycLUwCAx2cjMTKk2FgBd922sQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256698 [from cloudscan12-49.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 ntnic basic flow filter functionality. Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/include/flow_api.h | 89 ++ drivers/net/ntnic/include/flow_api_actions.h | 13 + drivers/net/ntnic/include/flow_api_engine.h | 46 + drivers/net/ntnic/include/flow_filter.h | 15 + drivers/net/ntnic/include/hw_mod_backend.h | 70 ++ drivers/net/ntnic/include/nt4ga_filter.h | 16 + .../ntnic/include/stream_binary_flow_api.h | 946 ++++++++++++++++++ 7 files changed, 1195 insertions(+) create mode 100644 drivers/net/ntnic/include/flow_api.h create mode 100644 drivers/net/ntnic/include/flow_api_actions.h create mode 100644 drivers/net/ntnic/include/flow_api_engine.h create mode 100644 drivers/net/ntnic/include/flow_filter.h create mode 100644 drivers/net/ntnic/include/hw_mod_backend.h create mode 100644 drivers/net/ntnic/include/nt4ga_filter.h create mode 100644 drivers/net/ntnic/include/stream_binary_flow_api.h diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h new file mode 100644 index 0000000000..4ccdbcde14 --- /dev/null +++ b/drivers/net/ntnic/include/flow_api.h @@ -0,0 +1,89 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_H_ +#define _FLOW_API_H_ + +#include +#include +#include + +#include "ntlog.h" + +#include "flow_api_actions.h" +#include "flow_api_engine.h" +#include "hw_mod_backend.h" +#include "stream_binary_flow_api.h" + +/* + * Flow NIC and Eth port device management + */ + +struct hw_mod_resource_s { + uint8_t *alloc_bm; /* allocation bitmap */ + uint32_t *ref; /* reference counter for each resource element */ + uint32_t resource_count;/* number of total available entries */ +}; + +struct flow_eth_dev { + struct flow_nic_dev *ndev; /* NIC that owns this port device */ + uint8_t port; /* NIC port id */ + uint32_t port_id; /* App assigned port_id - may be DPDK port_id */ + + struct flow_queue_id_s rx_queue[FLOW_MAX_QUEUES + 1]; /* 0th for exception */ + int num_queues; /* VSWITCH has exceptions sent on queue 0 per design */ + + int rss_target_id; /* QSL_HSH index if RSS needed QSL v6+ */ + struct flow_eth_dev *next; +}; + +enum flow_nic_hash_e { + HASH_ALGO_ROUND_ROBIN = 0, + HASH_ALGO_5TUPLE, +}; + +/* registered NIC backends */ +struct flow_nic_dev { + uint8_t adapter_no; /* physical adapter no in the host system */ + uint16_t ports; /* number of in-ports addressable on this NIC */ + enum flow_eth_dev_profile + flow_profile; /* flow profile this NIC is initially prepared for */ + int flow_mgnt_prepared; + + struct hw_mod_resource_s res[RES_COUNT];/* raw NIC resource allocation table */ + void *km_res_handle; + void *kcc_res_handle; + + void *flm_mtr_handle; + void *group_handle; + void *hw_db_handle; + void *id_table_handle; + + /* statistics */ + uint32_t flow_stat_id_map[MAX_COLOR_FLOW_STATS]; + + uint32_t flow_unique_id_counter; + /* linked list of all flows created on this NIC */ + struct flow_handle *flow_base; + /* linked list of all FLM flows created on this NIC */ + struct flow_handle *flow_base_flm; + pthread_mutex_t flow_mtx; + + /* NIC backend API */ + struct flow_api_backend_s be; + /* linked list of created eth-port devices on this NIC */ + struct flow_eth_dev *eth_base; + pthread_mutex_t mtx; + + /* pre allocated default QSL Drop */ + int default_qsl_drop_index; + /* pre allocated default QSL Discard */ + int default_qsl_discard_index; + + /* next NIC linked list */ + struct flow_nic_dev *next; +}; + +#endif diff --git a/drivers/net/ntnic/include/flow_api_actions.h b/drivers/net/ntnic/include/flow_api_actions.h new file mode 100644 index 0000000000..f62cda5dc5 --- /dev/null +++ b/drivers/net/ntnic/include/flow_api_actions.h @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_ACTIONS_H_ +#define _FLOW_ACTIONS_H_ + +#include + +#define MAX_COLOR_FLOW_STATS 0x400 + +#endif /* _FLOW_ACTIONS_H_ */ diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h new file mode 100644 index 0000000000..2fb43beac0 --- /dev/null +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -0,0 +1,46 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_ENGINE_H_ +#define _FLOW_API_ENGINE_H_ + +#include +#include + +#include "hw_mod_backend.h" +#include "stream_binary_flow_api.h" + +/* + * Resource management + * These are free resources in FPGA + * Other FPGA memory lists are linked to one of these + * and will implicitly follow them + */ +enum res_type_e { + RES_QUEUE, + RES_CAT_CFN, + RES_CAT_COT, + RES_CAT_EXO, + RES_CAT_LEN, + RES_KM_FLOW_TYPE, + RES_KM_CATEGORY, + RES_HSH_RCP, + RES_PDB_RCP, + RES_QSL_RCP, + RES_QSL_QST, + RES_SLC_RCP, + RES_SLC_LR_RCP, + RES_IOA_RCP, + RES_ROA_RCP, + RES_FLM_FLOW_TYPE, + RES_FLM_RCP, + RES_TPE_RCP, + RES_TPE_EXT, + RES_TPE_RPL, + RES_COUNT, + RES_INVALID +}; + +#endif /* _FLOW_API_ENGINE_H_ */ diff --git a/drivers/net/ntnic/include/flow_filter.h b/drivers/net/ntnic/include/flow_filter.h new file mode 100644 index 0000000000..53f77a9b60 --- /dev/null +++ b/drivers/net/ntnic/include/flow_filter.h @@ -0,0 +1,15 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef __FLOW_FILTER_HPP__ +#define __FLOW_FILTER_HPP__ + +#include "flow_api.h" +#include "nthw_fpga_model.h" + +int flow_filter_init(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, int adapter_no); +int flow_filter_done(struct flow_nic_dev *dev); + +#endif /* __FLOW_FILTER_HPP__ */ diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h new file mode 100644 index 0000000000..ab3ce1f469 --- /dev/null +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -0,0 +1,70 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _HW_MOD_BACKEND_H_ +#define _HW_MOD_BACKEND_H_ + +#include +#include +#include + +#include "ntlog.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define COMMON_FUNC_INFO_S \ + int ver; \ + void *base; \ + unsigned int alloced_size; \ + int debug + +struct common_func_s { + COMMON_FUNC_INFO_S; +}; + +struct flm_func_s { + COMMON_FUNC_INFO_S; + uint32_t nb_categories; + uint32_t nb_size_mb; + uint32_t nb_entry_size; + uint32_t nb_variant; + uint32_t nb_prios; + uint32_t nb_pst_profiles; + uint32_t nb_scrub_profiles; + uint32_t nb_rpp_clock_in_ps; + uint32_t nb_load_aps_max; +}; + +struct tpe_func_s { + COMMON_FUNC_INFO_S; + uint32_t nb_rcp_categories; + uint32_t nb_ifr_categories; + uint32_t nb_cpy_writers; + uint32_t nb_rpl_depth; + uint32_t nb_rpl_ext_categories; +}; + +struct flow_api_backend_s { + void *be_dev; + /* flow filter FPGA modules */ + struct flm_func_s flm; + struct tpe_func_s tpe; + + /* NIC attributes */ + unsigned int num_phy_ports; + unsigned int num_rx_ports; + + /* flow filter resource capacities */ + unsigned int max_categories; + unsigned int max_queues; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _HW_MOD_BACKEND_H_ */ diff --git a/drivers/net/ntnic/include/nt4ga_filter.h b/drivers/net/ntnic/include/nt4ga_filter.h new file mode 100644 index 0000000000..8d1abbd2ee --- /dev/null +++ b/drivers/net/ntnic/include/nt4ga_filter.h @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef NT4GA_FILTER_H_ +#define NT4GA_FILTER_H_ + +typedef struct nt4ga_filter_s { + int n_intf_cnt; + int n_queues_per_intf_cnt; + + struct flow_nic_dev *mp_flow_device; +} nt4ga_filter_t; + +#endif /* NT4GA_FILTER_H_ */ diff --git a/drivers/net/ntnic/include/stream_binary_flow_api.h b/drivers/net/ntnic/include/stream_binary_flow_api.h new file mode 100644 index 0000000000..096a349cc0 --- /dev/null +++ b/drivers/net/ntnic/include/stream_binary_flow_api.h @@ -0,0 +1,946 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _STREAM_BINARY_FLOW_API_H_ +#define _STREAM_BINARY_FLOW_API_H_ + +#include /* uint16_t, uint32_t, uint64_t */ +#include /* snprintf */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint16_t be16_t;/* 16-bit big-endian */ +typedef uint32_t be32_t;/* 32-bit big-endian */ +typedef uint64_t be64_t;/* 64-bit big-endian */ + +/* Max length for socket name, interface name, etc. */ +#define MAX_PATH_LEN 128 + +/* Max RSS hash key length in bytes */ +#define MAX_RSS_KEY_LEN 40 + +/** NT specific MASKs for RSS configuration **/ +#define NT_ETH_RSS_IPV4_MASK \ + (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \ + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV4_UDP) + +#define NT_ETH_RSS_IPV6_MASK \ + (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_IPV6_EX | \ + RTE_ETH_RSS_IPV6_TCP_EX | RTE_ETH_RSS_IPV6_UDP_EX | RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV6_UDP) + +#define NT_ETH_RSS_IP_MASK \ + (NT_ETH_RSS_IPV4_MASK | NT_ETH_RSS_IPV6_MASK | RTE_ETH_RSS_L3_SRC_ONLY | \ + RTE_ETH_RSS_L3_DST_ONLY) + +/* List of all RSS flags supported for RSS calculation offload */ +#define NT_ETH_RSS_OFFLOAD_MASK \ + (RTE_ETH_RSS_ETH | RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP | \ + RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_L2_SRC_ONLY | RTE_ETH_RSS_L2_DST_ONLY | \ + RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY | RTE_ETH_RSS_L3_SRC_ONLY | \ + RTE_ETH_RSS_L3_DST_ONLY | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_LEVEL_MASK | \ + RTE_ETH_RSS_IPV4_CHKSUM | RTE_ETH_RSS_L4_CHKSUM | RTE_ETH_RSS_PORT | RTE_ETH_RSS_GTPU) + +/* + * Flow frontend for binary programming interface + */ + +#define FLOW_MAX_QUEUES 128 + +#define RAW_ENCAP_DECAP_ELEMS_MAX 16 + +/* + * Partial flow mark and special flow marks + */ +#define FLOW_MARK_LACP 0x7fffffff +#define FLOW_MARK_MAX 0x7ffffffe +/* + * Flow eth dev profile determines how the FPGA module resources are + * managed and what features are available + */ +enum flow_eth_dev_profile { + FLOW_ETH_DEV_PROFILE_VSWITCH = 0, + FLOW_ETH_DEV_PROFILE_INLINE = 1, +}; + +/* + * Flow rule attributes + */ +struct flow_attr { + uint32_t group; /* Priority group. */ + uint32_t priority; /* Rule priority level within group. */ + uint16_t forced_vlan_vid; /* Forced VLAN VID that filter must match. Ignored if 0. */ + uint16_t caller_id; /* Unique ID of caller application. */ +}; + +struct flow_queue_id_s { + int id; + int hw_id; +}; + +/* NT Private rte flow items. */ + +/* NT Private rte flow actions. */ + +enum flow_elem_type { + FLOW_ELEM_TYPE_END, + FLOW_ELEM_TYPE_ANY, + FLOW_ELEM_TYPE_ETH, + FLOW_ELEM_TYPE_VLAN, + FLOW_ELEM_TYPE_IPV4, + FLOW_ELEM_TYPE_IPV6, + FLOW_ELEM_TYPE_SCTP, + FLOW_ELEM_TYPE_TCP, + FLOW_ELEM_TYPE_UDP, + FLOW_ELEM_TYPE_ICMP, + FLOW_ELEM_TYPE_ICMP6, + FLOW_ELEM_TYPE_VXLAN, + FLOW_ELEM_TYPE_GTP, + FLOW_ELEM_TYPE_GTP_PSC, + FLOW_ELEM_TYPE_PORT_ID, + FLOW_ELEM_TYPE_TAG, + FLOW_ELEM_TYPE_VOID, + + /* + * not associated with a RTE_ITEM..., but rather + * an restoration API device specific extension + */ + FLOW_ELEM_TYPE_TUNNEL +}; + +enum flow_action_type { /* conf structure */ + FLOW_ACTION_TYPE_END, /* -none- : End tag for action list */ + FLOW_ACTION_TYPE_POP_VLAN, /* -none- : Pops outer vlan tag */ + FLOW_ACTION_TYPE_PUSH_VLAN, /* struct flow_action_push_vlan : Push VLAN TAG */ + FLOW_ACTION_TYPE_SET_VLAN_VID, /* struct flow_action_set_vlan_vid : Set VLAN VID */ + FLOW_ACTION_TYPE_SET_VLAN_PCP, /* struct flow_action_set_vlan_pcp : Set VLAN PCP */ + /* -none- : Decapsulate outer most VXLAN tunnel from matched flow */ + FLOW_ACTION_TYPE_VXLAN_DECAP, + FLOW_ACTION_TYPE_VXLAN_ENCAP, /* struct flow_action_vxlan_encap */ + FLOW_ACTION_TYPE_DROP, /* -none- : Drop packets of this flow */ + FLOW_ACTION_TYPE_COUNT, /* struct flow_action_count : Used for "query" flow function */ + /* struct flow_action_mark : Used to tag a flow in HW with a MARK */ + FLOW_ACTION_TYPE_MARK, + /* struct flow_action_tag : Used to tag a flow in HW with a TAG */ + FLOW_ACTION_TYPE_SET_TAG, + /* struct flow_action_port_id : Destination port ID - HW port ID */ + FLOW_ACTION_TYPE_PORT_ID, + FLOW_ACTION_TYPE_RSS, /* struct flow_action_rss : */ + FLOW_ACTION_TYPE_QUEUE, /* struct flow_action_queue : */ + FLOW_ACTION_TYPE_JUMP, /* struct flow_action_jump : */ + /* struct flow_action_meter : Used to set MBR record ids in FLM learn records */ + FLOW_ACTION_TYPE_METER, + FLOW_ACTION_TYPE_RAW_ENCAP, /* struct flow_action_raw_encap : */ + FLOW_ACTION_TYPE_RAW_DECAP, /* struct flow_action_raw_decap : */ + FLOW_ACTION_TYPE_MODIFY_FIELD, /* struct flow_action_modify_field : */ + + /* + * -none- : not associated with a RTE_ACTION..., + * but rather an restoration API device specific extension + */ + FLOW_ACTION_TYPE_TUNNEL_SET +}; + +#pragma pack(1) +struct ether_addr_s { + uint8_t addr_b[6]; +}; +#pragma pack() + +static inline void flow_ether_format_addr(char *buf, uint16_t size, + const struct ether_addr_s *eth_addr) +{ + snprintf(buf, size, "%02X:%02X:%02X:%02X:%02X:%02X", eth_addr + ->addr_b[0], + eth_addr + ->addr_b[1], eth_addr + ->addr_b[2], eth_addr + ->addr_b[3], + eth_addr + ->addr_b[4], eth_addr + ->addr_b[5]); +} + +/* + * IPv4 Header + */ +#pragma pack(1) +struct ipv4_hdr_s { + uint8_t version_ihl; + uint8_t tos; + be16_t length; + be16_t id; + be16_t frag_offset; + uint8_t ttl; + uint8_t next_proto_id; + be16_t hdr_csum; + be32_t src_ip; + be32_t dst_ip; +}; +#pragma pack() +/* + * IPv6 Header + */ +#pragma pack(1) +struct ipv6_hdr_s { + be32_t vtc_flow;/* IP version, traffic class & flow label */ + be16_t payload_len; /* IP packet length - includes ip header */ + uint8_t proto; + uint8_t hop_limits; + uint8_t src_addr[16]; + uint8_t dst_addr[16]; +}; +#pragma pack() + +/* + * SCTP Header + */ +#pragma pack(1) +struct sctp_hdr_s { + be16_t src_port; + be16_t dst_port; + be32_t tag; /* Validation tag */ + be32_t cksum; +}; +#pragma pack() + +/* + * TCP Header + */ +#pragma pack(1) +struct tcp_hdr_s { + be16_t src_port; + be16_t dst_port; + be32_t sent_seq; + be32_t recv_ack; + uint8_t data_off; + uint8_t tcp_flags; + be16_t rx_win; + be16_t cksum; + be16_t tcp_urp; +}; +#pragma pack() + +/* + * UDP Header + */ +#pragma pack(1) +struct udp_hdr_s { + be16_t src_port; + be16_t dst_port; + be16_t len; + be16_t cksum; +}; +#pragma pack() + +/* + * ICMP Header + */ +#pragma pack(1) +struct icmp_hdr_s { + uint8_t type; + uint8_t code; + be16_t cksum; + be16_t ident; + be16_t seq_nb; +}; +#pragma pack() +/* + * FLOW_ELEM_TYPE_ETH specification + */ +#pragma pack(1) +struct flow_elem_eth { + struct ether_addr_s d_addr; /* DMAC */ + struct ether_addr_s s_addr; /* SMAC */ + be16_t ether_type; /* Frame type */ +}; +#pragma pack() + +/* + * FLOW_ELEM_TYPE_VLAN specification + */ +#pragma pack(1) +struct flow_elem_vlan { + be16_t tci; /* Tag control information */ + be16_t inner_type; /* Inner EtherType or TPID */ +}; +#pragma pack() + +/* + * FLOW_ELEM_TYPE_IPV4 specification + */ +struct flow_elem_ipv4 { + struct ipv4_hdr_s hdr; +}; + +/* + * FLOW_ELEM_TYPE_IPV6 specification + */ +struct flow_elem_ipv6 { + struct ipv6_hdr_s hdr; +}; + +/* + * FLOW_ELEM_TYPE_SCTP specification + */ +struct flow_elem_sctp { + struct sctp_hdr_s hdr; +}; + +/* + * FLOW_ELEM_TYPE_TCP specification + */ +struct flow_elem_tcp { + struct tcp_hdr_s hdr; +}; + +/* + * FLOW_ELEM_TYPE_UDP specification + */ +struct flow_elem_udp { + struct udp_hdr_s hdr; +}; + +/* + * FLOW_ELEM_TYPE_ICMP specification + */ +struct flow_elem_icmp { + struct icmp_hdr_s hdr; +}; + +/* + * FLOW_ELEM_TYPE_ICMP6 specification + */ +#pragma pack(1) +struct flow_elem_icmp6 { + uint8_t type; /**< ICMPv6 type. */ + uint8_t code; /**< ICMPv6 code. */ + be16_t checksum;/**< ICMPv6 checksum. */ +}; +#pragma pack() + +/* + * FLOW_ELEM_TYPE_GTP specification + */ +#pragma pack(1) +struct flow_elem_gtp { + uint8_t v_pt_rsv_flags; + uint8_t msg_type; + be16_t msg_len; + be32_t teid; +}; +#pragma pack() + +/* + * FLOW_ELEM_TYPE_GTP_PSC specification + */ +#pragma pack(1) +struct flow_elem_gtp_psc { + uint8_t hdr_len; + uint8_t pdu_type; + uint8_t qfi; +}; +#pragma pack() + +/* + * FLOW_ELEM_TYPE_VXLAN specification (RFC 7348) + */ +#pragma pack(1) +struct flow_elem_vxlan { + uint8_t flags; /* Normally 0x08 (I flag) */ + uint8_t rsvd0[3]; + uint8_t vni[3]; + uint8_t rsvd1; +}; +#pragma pack() +/* + * FLOW_ELEM_TYPE_PORT_ID specification + */ +struct flow_elem_port_id { + uint32_t id; /* HW port no */ +}; + +/* + * FLOW_ELEM_TYPE_TAG specification + */ +struct flow_elem_tag { + uint32_t data; + uint8_t index; +}; + +/* + * FLOW_ELEM_TYPE_ANY specification + */ +struct flow_elem_any { + uint32_t num; /* *< Number of layers covered. */ +}; + +struct flow_elem { + enum flow_elem_type type; /* element type */ + const void *spec; /* Pointer to element specification structure */ + const void *mask; /* Bitmask applied to spec - same type */ +}; + +/* Note: Keep in sync with the rte_eth_hash_function structure defined in rte_ethdev.h */ +enum nt_eth_hash_function { + NT_ETH_HASH_FUNCTION_DEFAULT = 0, + NT_ETH_HASH_FUNCTION_TOEPLITZ, + NT_ETH_HASH_FUNCTION_SIMPLE_XOR, + NT_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, + NT_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT, + NT_ETH_HASH_FUNCTION_MAX, +}; + +struct flow_action_rss { + enum nt_eth_hash_function func; + /* + * UNUSED; rte_flow_action_rss->level is used to set + * RTE_ETH_RSS_LEVEL_OUTERMOST & RTE_ETH_RSS_LEVEL_INNERMOST + * bits at 'flow_action_rss->types' below + */ + uint32_t level; + uint64_t types; /* Specific RSS hash types (see like RTE_ETH_RSS_*) */ + uint32_t key_len; /* Hash key length in bytes supported for Toeplitz */ + uint32_t queue_num; /* Number of entries in queue */ + const uint8_t *key; /* Hash key supported for Toeplitz */ + const uint16_t *queue; /* Queue indices to use */ +}; + +/* + * FLOW_ACTION_TYPE_PUSH_VLAN + * Push a new vlan TAG + */ +struct flow_action_push_vlan { + be16_t ethertype; +}; + +/* + * FLOW_ACTION_TYPE_SET_VLAN_VID + */ +struct flow_action_set_vlan_vid { + be16_t vlan_vid; +}; + +/* + * FLOW_ACTION_TYPE_SET_VLAN_PCP + */ +struct flow_action_set_vlan_pcp { + uint8_t vlan_pcp; /* *< VLAN priority. */ +}; + +/* + * FLOW_ACTION_TYPE_VXLAN_ENCAP specification + * Valid flow definition: + * + * - ETH / IPV4 / UDP / VXLAN / END + * - ETH / IPV6 / UDP / VXLAN / END + * - ETH / VLAN / IPV4 / UDP / VXLAN / END + */ +struct flow_action_vxlan_encap { + /* Encapsulating vxlan tunnel definition */ + struct flow_elem *vxlan_tunnel; +}; + +/* + * FLOW_ACTION_TYPE_COUNT specification + */ +struct flow_action_count { + uint32_t id; /* HW port no */ +}; + +/* + * FLOW_ACTION_TYPE_COUNT specification (query) + */ +struct flow_query_count { + uint32_t reset : 1; + uint32_t hits_set : 1; + uint32_t bytes_set : 1; + + uint32_t tcp_flags : 9; + + uint32_t reserved : 20; + uint64_t hits; + uint64_t bytes; +}; + +/* + * FLOW_ACTION_TYPE_MARK specification + */ +struct flow_action_mark { + uint32_t id; /* mark flow with this ID */ +}; + +/* + * FLOW_ACTION_TYPE_TAG specification + */ +struct flow_action_tag { + uint32_t data; /* tag flow with this value */ + uint32_t mask; /* bit-mask applied to "data" */ + uint8_t index; /* index of tag to set */ +}; + +/* + * FLOW_ACTION_TYPE_PORT_ID specification + */ +struct flow_action_port_id { + uint32_t __rte_flags; /* not used but to be binary compatible with rte flow */ + uint32_t id; +}; + +/* + * FLOW_ACTION_TYPE_QUEUE + */ +struct flow_action_queue { + uint16_t index; +}; + +/* + * FLOW_ACTION_TYPE_JUMP + */ +struct flow_action_jump { + uint32_t group; +}; + +/* + * FLOW_ACTION_TYPE_METER + */ +struct flow_action_meter { + uint32_t mtr_id; +}; + +/* + * FLOW_ACTION_TYPE_RAW_ENCAP + */ +struct flow_action_raw_encap { + uint8_t *data; + uint8_t *preserve; + size_t size; + struct flow_elem items[RAW_ENCAP_DECAP_ELEMS_MAX]; + int item_count; +}; + +/* + * FLOW_ACTION_TYPE_RAW_DECAP + */ +struct flow_action_raw_decap { + uint8_t *data; + size_t size; + struct flow_elem items[RAW_ENCAP_DECAP_ELEMS_MAX]; + int item_count; +}; + +/* + * Field IDs for MODIFY_FIELD action. + */ +enum flow_field_id { + FLOW_FIELD_START = 0, /* Start of a packet. */ + FLOW_FIELD_MAC_DST, /* Destination MAC Address. */ + FLOW_FIELD_MAC_SRC, /* Source MAC Address. */ + FLOW_FIELD_VLAN_TYPE, /* 802.1Q Tag Identifier. */ + FLOW_FIELD_VLAN_ID, /* 802.1Q VLAN Identifier. */ + FLOW_FIELD_MAC_TYPE, /* EtherType. */ + FLOW_FIELD_IPV4_DSCP, /* IPv4 DSCP. */ + FLOW_FIELD_IPV4_TTL, /* IPv4 Time To Live. */ + FLOW_FIELD_IPV4_SRC, /* IPv4 Source Address. */ + FLOW_FIELD_IPV4_DST, /* IPv4 Destination Address. */ + FLOW_FIELD_IPV6_DSCP, /* IPv6 DSCP. */ + FLOW_FIELD_IPV6_HOPLIMIT, /* IPv6 Hop Limit. */ + FLOW_FIELD_IPV6_SRC, /* IPv6 Source Address. */ + FLOW_FIELD_IPV6_DST, /* IPv6 Destination Address. */ + FLOW_FIELD_TCP_PORT_SRC,/* TCP Source Port Number. */ + FLOW_FIELD_TCP_PORT_DST,/* TCP Destination Port Number. */ + FLOW_FIELD_TCP_SEQ_NUM, /* TCP Sequence Number. */ + FLOW_FIELD_TCP_ACK_NUM, /* TCP Acknowledgment Number. */ + FLOW_FIELD_TCP_FLAGS, /* TCP Flags. */ + FLOW_FIELD_UDP_PORT_SRC,/* UDP Source Port Number. */ + FLOW_FIELD_UDP_PORT_DST,/* UDP Destination Port Number. */ + FLOW_FIELD_VXLAN_VNI, /* VXLAN Network Identifier. */ + FLOW_FIELD_GENEVE_VNI, /* GENEVE Network Identifier. */ + FLOW_FIELD_GTP_TEID, /* GTP Tunnel Endpoint Identifier. */ + FLOW_FIELD_TAG, /* Tag value. */ + FLOW_FIELD_MARK,/* Mark value. */ + FLOW_FIELD_META,/* Metadata value. */ + FLOW_FIELD_POINTER, /* Memory pointer. */ + FLOW_FIELD_VALUE, /* Immediate value. */ + FLOW_FIELD_IPV4_ECN, /* IPv4 ECN. */ + FLOW_FIELD_IPV6_ECN, /* IPv6 ECN. */ + FLOW_FIELD_GTP_PSC_QFI, /* GTP QFI. */ + FLOW_FIELD_METER_COLOR, /* Meter color marker. */ +}; + +/* + * Field description for MODIFY_FIELD action. + */ +struct flow_action_modify_data { + enum flow_field_id field; /* Field or memory type ID. */ + union { + struct { + /* Encapsulation level or tag index. */ + uint32_t level; + /* Number of bits to skip from a field. */ + uint32_t offset; + }; + /* + * Immediate value for FLOW_FIELD_VALUE, presented in the + * same byte order and length as in relevant rte_flow_item_xxx. + */ + uint8_t value[16]; + /* + * Memory address for FLOW_FIELD_POINTER, memory layout + * should be the same as for relevant field in the + * rte_flow_item_xxx structure. + */ + void *pvalue; + }; +}; + +/* + * Operation types for MODIFY_FIELD action. + */ +enum flow_modify_op { + FLOW_MODIFY_SET = 0, + FLOW_MODIFY_ADD, + FLOW_MODIFY_SUB, +}; + +/* + * FLOW_ACTION_TYPE_MODIFY_FIELD + */ +struct flow_action_modify_field { + enum flow_modify_op operation; + struct flow_action_modify_data dst; + struct flow_action_modify_data src; + uint32_t width; +}; + +struct flow_action { + enum flow_action_type type; + const void *conf; +}; + +enum flow_error_e { + FLOW_ERROR_NONE, + FLOW_ERROR_SUCCESS, + FLOW_ERROR_GENERAL +}; + +struct flow_error { + enum flow_error_e type; + const char *message; +}; + +enum flow_lag_cmd { + FLOW_LAG_SET_ENTRY, + FLOW_LAG_SET_ALL, + FLOW_LAG_SET_BALANCE, +}; + +/* + * Tunnel definition for DPDK RTE tunnel helper function support + */ +struct tunnel_cfg_s { + union { + struct { + uint32_t src_ip;/* BE */ + uint32_t dst_ip;/* BE */ + } v4; + struct { + uint8_t src_ip[16]; + uint8_t dst_ip[16]; + } v6; + struct { + uint64_t src_ip[2]; + uint64_t dst_ip[2]; + } v6_long; + }; + int ipversion; + uint16_t s_port;/* BE */ + uint16_t d_port;/* BE */ + int tun_type; +}; + +struct flow_eth_dev; /* port device */ +struct flow_handle; + +struct flow_pattern_template; +struct flow_actions_template; +struct flow_template_table; + +/* + * Device Management API + */ +int flow_reset_nic_dev(uint8_t adapter_no); + +struct flow_eth_dev *flow_get_eth_dev(uint8_t adapter_no, + uint8_t hw_port_no, + uint32_t port_id, + int alloc_rx_queues, + struct flow_queue_id_s queue_ids[], + int *rss_target_id, + enum flow_eth_dev_profile flow_profile, + uint32_t exception_path); + +int flow_eth_dev_add_queue(struct flow_eth_dev *eth_dev, struct flow_queue_id_s *queue_id); + +int flow_delete_eth_dev(struct flow_eth_dev *eth_dev); + +int flow_get_tunnel_definition(struct tunnel_cfg_s *tun, uint32_t flow_stat_id, uint8_t vport); + +/* + * NT Flow API + */ +int flow_validate(struct flow_eth_dev *dev, + const struct flow_elem item[], + const struct flow_action action[], + struct flow_error *error); + +struct flow_handle *flow_create(struct flow_eth_dev *dev, + const struct flow_attr *attr, + const struct flow_elem item[], + const struct flow_action action[], + struct flow_error *error); + +int flow_destroy(struct flow_eth_dev *dev, struct flow_handle *flow, struct flow_error *error); + +int flow_flush(struct flow_eth_dev *dev, uint16_t caller_id, struct flow_error *error); + +int flow_actions_update(struct flow_eth_dev *dev, + struct flow_handle *flow, + const struct flow_action action[], + struct flow_error *error); + +int flow_query(struct flow_eth_dev *dev, + struct flow_handle *flow, + const struct flow_action *action, + void **data, + uint32_t *length, + struct flow_error *error); + +int flow_dev_dump(struct flow_eth_dev *dev, + struct flow_handle *flow, + uint16_t caller_id, + FILE *file, + struct flow_error *error); + +int flow_get_aged_flows(struct flow_eth_dev *dev, + void **context, + uint32_t nb_contexts, + struct flow_error *error); + +/* + * NT Flow asynchronous operations API + */ +struct flow_port_info { + /* maximum number of queues for asynchronous operations. */ + uint32_t max_nb_queues; + /* maximum number of counters. see RTE_FLOW_ACTION_TYPE_COUNT */ + uint32_t max_nb_counters; + /* maximum number of aging objects. see RTE_FLOW_ACTION_TYPE_AGE */ + uint32_t max_nb_aging_objects; + /* maximum number traffic meters. see RTE_FLOW_ACTION_TYPE_METER */ + uint32_t max_nb_meters; + /* maximum number connection trackings. see RTE_FLOW_ACTION_TYPE_CONNTRACK */ + uint32_t max_nb_conn_tracks; + uint32_t supported_flags; /* port supported flags (RTE_FLOW_PORT_FLAG_*). */ +}; + +struct flow_queue_info { + uint32_t max_size; /* maximum number of operations a queue can hold. */ +}; + +struct flow_op_attr { + /* when set, the requested action will not be sent to the HW immediately. */ + uint32_t postpone : 1; +}; + +struct flow_port_attr { + /* number of counters to configure. see RTE_FLOW_ACTION_TYPE_COUNT */ + uint32_t nb_counters; + /* number of aging objects to configure. see RTE_FLOW_ACTION_TYPE_AGE */ + uint32_t nb_aging_objects; + /* number of traffic meters to configure. see RTE_FLOW_ACTION_TYPE_METER */ + uint32_t nb_meters; + /* number of connection trackings to configure. see RTE_FLOW_ACTION_TYPE_CONNTRACK */ + uint32_t nb_conn_tracks; + uint32_t flags; /* Port flags (RTE_FLOW_PORT_FLAG_*). */ +}; + +struct flow_queue_attr { + uint32_t size; /* number of flow rule operations a queue can hold. */ +}; + +struct flow_pattern_template_attr { + /** + * Relaxed matching policy. + * - If 1, matching is performed only on items with the mask member set + * and matching on protocol layers specified without any masks is skipped. + * - If 0, matching on protocol layers specified without any masks is done + * as well. This is the standard behaviour of Flow API now. + */ + uint32_t relaxed_matching : 1; + /* Flow direction for the pattern template. At least one direction must be specified. */ + uint32_t ingress : 1; /* pattern valid for rules applied to ingress traffic. */ + uint32_t egress : 1; /* pattern valid for rules applied to egress traffic. */ + uint32_t transfer : 1; /* pattern valid for rules applied to transfer traffic. */ + uint32_t reserved : 28; + uint16_t caller_id; /* Unique ID of caller application. */ +}; + +struct flow_actions_template_attr { + /* Flow direction for the actions template. At least one direction must be specified. */ + uint32_t ingress : 1; /* action valid for rules applied to ingress traffic. */ + uint32_t egress : 1; /* action valid for rules applied to egress traffic. */ + uint32_t transfer : 1; /* action valid for rules applied to transfer traffic. */ + uint32_t reserved : 29; + uint16_t caller_id; /* Unique ID of caller application. */ +}; + +struct async_flow_attr { + /* priority group. */ + uint32_t group; + /* rule priority level within group. */ + uint32_t priority; + /* the rule in question applies to ingress traffic (non-"transfer"). */ + uint32_t ingress : 1; + /* the rule in question applies to egress traffic (non-"transfer"). */ + uint32_t egress : 1; + /* + * managing "transfer" flows requires that the user + * communicate them through a suitable port. + */ + uint32_t transfer : 1; + uint32_t reserved : 29; /* reserved, must be zero. */ +}; + +struct flow_template_table_attr { + /* flow attributes to be used in each rule generated from this table. */ + struct async_flow_attr flow_attr; + uint32_t nb_flows; /* maximum number of flow rules that this table holds. */ + uint16_t forced_vlan_vid; /* Forced VLAN VID that filter must match. Ignored if 0. */ + uint16_t caller_id; /* Unique ID of caller application. */ +}; + +enum flow_op_status { + FLOW_OP_SUCCESS,/* the operation was completed successfully. */ + FLOW_OP_ERROR, /* the operation was not completed successfully. */ +}; + +struct flow_op_result { + /* returns the status of the operation that this completion signals. */ + enum flow_op_status status; + void *user_data;/* the user data that will be returned on the completion events. */ +}; + +struct flow_indir_action_conf { + uint32_t ingress : 1; /* action valid for rules applied to ingress traffic. */ + uint32_t egress : 1; /* action valid for rules applied to egress traffic. */ + /* action is valid for ransfer traffic; otherwise, for non-transfer traffic. */ + uint32_t transfer : 1; +}; + +int flow_info_get(struct flow_eth_dev *dev, struct flow_port_info *port_info, + struct flow_queue_info *queue_info, struct flow_error *error); + +int flow_configure(struct flow_eth_dev *dev, uint8_t caller_id, + const struct flow_port_attr *port_attr, uint16_t nb_queue, + const struct flow_queue_attr *queue_attr[], struct flow_error *error); + +struct flow_pattern_template * +flow_pattern_template_create(struct flow_eth_dev *dev, + const struct flow_pattern_template_attr *template_attr, + const struct flow_elem pattern[], struct flow_error *error); + +int flow_pattern_template_destroy(struct flow_eth_dev *dev, + struct flow_pattern_template *pattern_template, + struct flow_error *error); + +struct flow_actions_template * +flow_actions_template_create(struct flow_eth_dev *dev, + const struct flow_actions_template_attr *template_attr, + const struct flow_action actions[], const struct flow_action masks[], + struct flow_error *error); + +int flow_actions_template_destroy(struct flow_eth_dev *dev, + struct flow_actions_template *actions_template, + struct flow_error *error); + +struct flow_template_table *flow_template_table_create(struct flow_eth_dev *dev, + const struct flow_template_table_attr *table_attr, + struct flow_pattern_template *pattern_templates[], uint8_t nb_pattern_templates, + struct flow_actions_template *actions_templates[], uint8_t nb_actions_templates, + struct flow_error *error); + +int flow_template_table_destroy(struct flow_eth_dev *dev, + struct flow_template_table *template_table, + struct flow_error *error); + +struct flow_handle * +flow_async_create(struct flow_eth_dev *dev, uint32_t queue_id, const struct flow_op_attr *op_attr, + struct flow_template_table *template_table, const struct flow_elem pattern[], + uint8_t pattern_template_index, const struct flow_action actions[], + uint8_t actions_template_index, void *user_data, struct flow_error *error); + +int flow_async_destroy(struct flow_eth_dev *dev, uint32_t queue_id, + const struct flow_op_attr *op_attr, struct flow_handle *flow, + void *user_data, struct flow_error *error); + +int flow_push(struct flow_eth_dev *dev, uint32_t queue_id, struct flow_error *error); + +int flow_pull(struct flow_eth_dev *dev, uint32_t queue_id, struct flow_op_result res[], + uint16_t n_res, struct flow_error *error); + +/* + * NT Flow FLM Meter API + */ +int flow_mtr_supported(struct flow_eth_dev *dev); + +uint64_t flow_mtr_meter_policy_n_max(void); + +int flow_mtr_set_profile(struct flow_eth_dev *dev, uint32_t profile_id, uint64_t bucket_rate_a, + uint64_t bucket_size_a, uint64_t bucket_rate_b, uint64_t bucket_size_b); + +int flow_mtr_set_policy(struct flow_eth_dev *dev, uint32_t policy_id, int drop); + +int flow_mtr_create_meter(struct flow_eth_dev *dev, uint8_t caller_id, uint32_t mtr_id, + uint32_t profile_id, uint32_t policy_id, uint64_t stats_mask); + +int flow_mtr_probe_meter(struct flow_eth_dev *dev, uint8_t caller_id, uint32_t mtr_id); + +int flow_mtr_destroy_meter(struct flow_eth_dev *dev, uint8_t caller_id, uint32_t mtr_id); + +int flm_mtr_adjust_stats(struct flow_eth_dev *dev, uint8_t caller_id, uint32_t mtr_id, + uint32_t adjust_value); + +uint32_t flow_mtr_meters_supported(struct flow_eth_dev *dev, uint8_t caller_id); + +void flm_setup_queues(void); +void flm_free_queues(void); +uint32_t flm_lrn_update(struct flow_eth_dev *dev, uint32_t *inf_cnt); + +uint32_t flm_mtr_update_stats(struct flow_eth_dev *dev, uint32_t *inf_cnt); +void flm_mtr_read_stats(struct flow_eth_dev *dev, + uint8_t caller_id, + uint32_t id, + uint64_t *stats_mask, + uint64_t *green_pkt, + uint64_t *green_bytes, + int clear); + +uint32_t flm_update(struct flow_eth_dev *dev); + +/* + * Config API + */ +int flow_set_mtu_inline(struct flow_eth_dev *dev, uint32_t port, uint16_t mtu); + +#ifdef __cplusplus +} +#endif + +#endif /* _STREAM_BINARY_FLOW_API_H_ */ -- 2.45.0