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 15E0445BCC; Wed, 30 Oct 2024 22:43:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E26A43492; Wed, 30 Oct 2024 22:41:28 +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 C666C434A8 for ; Wed, 30 Oct 2024 22:40:29 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bgftTJnZ5jwlAgl8o8yDq3kiC09YCcZSeB61aGuKHksxkw5E+SdeDS53g0LfMJCw7dnHuKTqYx4tz8ch0q3dVBW6JJveZYwI8NZbq5ZfNme9afLwh+2eV/ECY4rCta3EN9pS8MiICHeHdun4DJNrhspl1yoUWng7uOMl1Ooue6UffNzthF8RkRyUMR/m5/08nVTB1OJT0jMy8731sHCbH2oERbXL+5qp3tC8WW3jbszEnUcIlnobOvuNPLLqQ/Ut8+ONKX1ojJawMutiMYVA+LMqhJl53oBFB90OtXHvlTvClrdclmQw5o9KbI+L+1GYoJrJVLQD7eIjGGT4ccLUQw== 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=aabmSIsZx/e8QWelEOlWDUGCoNPaM5uSwxo71EVDJo4=; b=odMKKL0NPYoANYdUhuX/uZQ0bcAFlusgv9i+DfIRmi/XpVVSuxJ1wZ+6eSGZl3v6C0VSVc6cXgyrZeSynyn2bN7K7nfBVPtab5jMP7bXS+ZRjlXSWFMO9Qn76DIQGr80883JLLtjV+MMGYHZLyuTzG+gkKrcLnylWlmt6Kg/vFifyB//BrnrM7+llCf0A3LQYjgJXduRZoDNvxfxGTyjiXv0qsRvSYTxFAEPQeoBtLz3yW9vN4Vony5gERcHxVhEBoNaz8iRwJy2xoIDLxVS35IDI7d9JaMB2444QKynNkEnWo5gwVdv2zarFakXZc8N/Nics+jLEqFJrbEHnWPaQQ== 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=aabmSIsZx/e8QWelEOlWDUGCoNPaM5uSwxo71EVDJo4=; b=TEEkAnDaua5Ln8La3Qy/RCqkCKz8rTIXJYAZJ98IGsn9S+imhRK7ZAtPsbdPjRLBsE6LQ6l/BoG83aI5myO+9vYZtzwugCxaHp9zhX5rwzLZnfXWP+r0UJg78E+fTdlqTKcQ2jRZI/uatFOi+LKhjwchwvb3KIEu2PHiofSTU6o= Received: from DUZPR01CA0003.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::15) by AM7P190MB0582.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:122::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:23 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::49) by DUZPR01CA0003.outlook.office365.com (2603:10a6:10:3c3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:23 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40:23 +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, Danylo Vodopianov Subject: [PATCH v5 33/80] net/ntnic: add FLM module Date: Wed, 30 Oct 2024 22:38:40 +0100 Message-ID: <20241030213940.3470062-34-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM7P190MB0582:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6014a27d-30be-4ed7-24b5-08dcf92b75c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?U6OblBs7OhB10GdF3KosC6HGUsOXg9VKrifpH8evelE1ZCBEu4QHkM2zjCR4?= =?us-ascii?Q?HY0wl8OlxTTTAl5XIdU3pXw5qpPJa7+Ytn0pni51hfThXMhsO4ULRhjsSUbo?= =?us-ascii?Q?xGAXevjPMSRNGbeGSvFeznntI3+yQ8WCTZi7nUbFqgNAe68o3qeU7UQ10lPH?= =?us-ascii?Q?yFKeerQDNlb9G4KFBw9JX4vgjEOYqlTRth/VEcWZXdPei+rzwsYFiNRGQo7q?= =?us-ascii?Q?iF3te4CLzEkD7HNB1IweRX3rUTsTrR/UHSgnkOGF7Fm1BcXVZq7P9vIko8eu?= =?us-ascii?Q?qlTqs5Y6yfGGquXKc5fZgpy19MLf1/PS+v1q9sSssxmcnZZvDF2gY9L8eqsw?= =?us-ascii?Q?dy5xTcJEQLFpTyB28ibjOWsHMNuDci8X1dHxuqOe14aruiLL7pkiHGOzIvNv?= =?us-ascii?Q?ShDTknLo8f+Fbmeyv1G2sDFny4Howzkqy27UGeeDwn8oGdFuErtUzqEsfmPB?= =?us-ascii?Q?dgZVLjL87mo4nj+8zkkzrKXENjMXNHntD0ILZDjJqDKFy8olTN670SErQ8+B?= =?us-ascii?Q?5frrCAm9lf/33CqYi7sk1VV4xxE1PmUillbuvoZQRzCcw9+o2YATPrmhqaQb?= =?us-ascii?Q?bm6vZ4fmRL22t7leTM1Ueu0kpjlJ7R0JZMbha6idA02kYpBB8lk6uPNOFb7n?= =?us-ascii?Q?2mO5ypO+x0SR5bNtqxSR/MOcLe2/77coCPBTjctxGIe7ZT9GHRpp828K2UY6?= =?us-ascii?Q?p7kmM879mdFypqyXc+VmW5REuGlZaqeuk+hbVLiNhYzQHPRGjAJNoAuKRMPn?= =?us-ascii?Q?M/TvL1JL0ncPM5VwzLFeqRYUtzjGiTtGKyzc4p7Jk0tn7cuuov8/3SuPMoWw?= =?us-ascii?Q?vpAzMpd+uS+Y0J2jUJ92KqVnhCkWcD7DE/a/XghmVneriwpzZa5YlCDPM0sj?= =?us-ascii?Q?bUMbXjzAK5xGOCmtLdyMMvhVmBhDLaG6pOxuXjt5E8ceXZtsjHuEZpKqf2Dy?= =?us-ascii?Q?alzIoHR1YeWckd8kYG5MmFSd2FtbVZ5O30GKBDMiMISsKxlVVcBks93zUfgq?= =?us-ascii?Q?hNavBzpVcNFZD6RXsfULSOxZoVVd6x6FQe99pvM8Y5hcLikCoU6TnHQ8CCIC?= =?us-ascii?Q?qcQSxjVC/2HdbBKwH7RjyLT7jO5KKfUVIPiwUYonErVk6PY4QbOLBhen5waP?= =?us-ascii?Q?k8M23LlRgXcA/PBRBpofgPSC/AorYII+ZqvnPVdRZ37kUpaoSUwxTR7qfcad?= =?us-ascii?Q?34EvNp06vggpapuEzk46X16VKl5fFU7tKKlRLec2RH5hhZZXP5EfY7oDzT00?= =?us-ascii?Q?4g5uleohnybwfuQ3xwuwPJQcyFu94sO1cOSScsvnGxY84g3VN/BVtZ3AtbBW?= =?us-ascii?Q?Yh2wTtl7uw0ybusFOcDOIfF3h7JZSDyRItJbuWzX3KpePnZJ+9oa3C98qLpA?= =?us-ascii?Q?wpV5MLM62/AgHkOEgWCQZ9oyipeMSDdyXGE/bSWftMjZxRIzGA=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nQ/DiCh1c5h0Y6lnYftd8TnKByCZ9orqzPZX8Y6iscSYBhVVO6RaOE274Apnen7WLRLD5SKJ23PxdUsiBQ+a2Y39WjcgPcQ/E+D6zZM7506PADVM34qJAvmVoV3p2RbfsSfReQQMXeuQ0XtaJFpLn8Yua/+MMjWMcf9acb0bYsrxuaFLNlChqE3rZfzAs3eGl0QBJI0kIqfp/9xnMS4Iz5KPnNzTCoY5BZIn11sAdfarsvn29SWqy+f+ZfKJ42IzSmpo+RY35e08+fZjz1K7E7SOFIWu54X/Kn1P1GI/PytaGo7MtxdsaV7nLOVMUfcXgpvqyHSXowDRz4bShwWo1fO7BFIYWL+LO3EEnTKoxi2I/p+rgfafYtVDbRqlecteZAvyc5L5+vLgcQBUtiffHkpQTAIETrUB4GvxUfyDZ1M5TjAvZFuNzyBZFpVM/El9oZO+H5Y2DbxaquwqcyZoyz2gmXp4g50SXqolVAzB+rlt63MTWGX8Qv9NtPb1rWt4Eskygv0upsqJp19+AT768cdIE2FSDrX8jK888D1Fbz2A+x3hqkFgRvag7SG29EuHqXfp+IYut3JnzP2LgWfJSHp9VaJkpD1K6MlxhPffIcmLk6karoeC37HNry19VLJuZA6thP9id5lMFfge57humo54WF5X993Az71HrcDDod4= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:23.1301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6014a27d-30be-4ed7-24b5-08dcf92b75c1 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0582 X-BESS-ID: 1730324425-302901-12791-43467-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYGlgaGQGYGUNTY0tw4xSTJ1D zJ1MQy0cwgzdjIyNAy0SLVwNTUzMDCUKk2FgD43J/4QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Danylo Vodopianov The Flow Matcher module is a high-performance stateful SDRAM lookup and programming engine which supported exact match lookup in line-rate of up to hundreds of millions of flows. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 42 +++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c | 190 +++++++++++++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 257 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 234 ++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 33 +++ .../profile_inline/flow_api_profile_inline.c | 224 ++++++++++++++- .../flow_api_profile_inline_config.h | 58 ++++ drivers/net/ntnic/ntutil/nt_util.h | 8 + 8 files changed, 1042 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index e16dcd478f..de662c4ed1 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -367,6 +367,18 @@ int hw_mod_cat_cfn_flush(struct flow_api_backend_s *be, int start_idx, int count int hw_mod_cat_cfn_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, int word_off, uint32_t value); /* KCE/KCS/FTE KM */ +int hw_mod_cat_kce_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kce_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kce_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); +int hw_mod_cat_kcs_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kcs_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kcs_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); int hw_mod_cat_fte_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, int start_idx, int count); int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, @@ -374,6 +386,18 @@ int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, int hw_mod_cat_fte_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, enum km_flm_if_select_e if_num, int index, uint32_t *value); /* KCE/KCS/FTE FLM */ +int hw_mod_cat_kce_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kce_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kce_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); +int hw_mod_cat_kcs_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_kcs_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_kcs_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); int hw_mod_cat_fte_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, int start_idx, int count); int hw_mod_cat_fte_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, @@ -384,10 +408,14 @@ int hw_mod_cat_fte_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, uint32_t value); +int hw_mod_cat_cte_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value); int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, uint32_t value); +int hw_mod_cat_cts_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value); int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cot_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, @@ -638,7 +666,21 @@ int hw_mod_flm_reset(struct flow_api_backend_s *be); int hw_mod_flm_control_flush(struct flow_api_backend_s *be); int hw_mod_flm_control_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); +int hw_mod_flm_status_update(struct flow_api_backend_s *be); +int hw_mod_flm_status_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value); + int hw_mod_flm_scan_flush(struct flow_api_backend_s *be); +int hw_mod_flm_scan_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); + +int hw_mod_flm_load_bin_flush(struct flow_api_backend_s *be); +int hw_mod_flm_load_bin_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); + +int hw_mod_flm_prio_flush(struct flow_api_backend_s *be); +int hw_mod_flm_prio_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); + +int hw_mod_flm_pst_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value); int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c index 9164ec1ae0..985c821312 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c @@ -902,6 +902,95 @@ static int hw_mod_cat_kce_flush(struct flow_api_backend_s *be, enum km_flm_if_se return be->iface->cat_kce_flush(be->be_dev, &be->cat, km_if_idx, start_idx, count); } +int hw_mod_cat_kce_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kce_flush(be, if_num, 0, start_idx, count); +} + +int hw_mod_cat_kce_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kce_flush(be, if_num, 1, start_idx, count); +} + +static int hw_mod_cat_kce_mod(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int km_if_id, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= (be->cat.nb_cat_funcs / 8)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + /* find KM module */ + int km_if_idx = find_km_flm_module_interface_index(be, if_num, km_if_id); + + if (km_if_idx < 0) + return km_if_idx; + + switch (_VER_) { + case 18: + switch (field) { + case HW_CAT_KCE_ENABLE_BM: + GET_SET(be->cat.v18.kce[index].enable_bm, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18 */ + case 21: + switch (field) { + case HW_CAT_KCE_ENABLE_BM: + GET_SET(be->cat.v21.kce[index].enable_bm[km_if_idx], value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_kce_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 0, index, &value, 0); +} + +int hw_mod_cat_kce_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 0, index, value, 1); +} + +int hw_mod_cat_kce_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 1, index, &value, 0); +} + +int hw_mod_cat_kce_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kce_mod(be, field, if_num, 1, index, value, 1); +} + /* * KCS */ @@ -925,6 +1014,95 @@ static int hw_mod_cat_kcs_flush(struct flow_api_backend_s *be, enum km_flm_if_se return be->iface->cat_kcs_flush(be->be_dev, &be->cat, km_if_idx, start_idx, count); } +int hw_mod_cat_kcs_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kcs_flush(be, if_num, 0, start_idx, count); +} + +int hw_mod_cat_kcs_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_kcs_flush(be, if_num, 1, start_idx, count); +} + +static int hw_mod_cat_kcs_mod(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int km_if_id, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= be->cat.nb_cat_funcs) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + /* find KM module */ + int km_if_idx = find_km_flm_module_interface_index(be, if_num, km_if_id); + + if (km_if_idx < 0) + return km_if_idx; + + switch (_VER_) { + case 18: + switch (field) { + case HW_CAT_KCS_CATEGORY: + GET_SET(be->cat.v18.kcs[index].category, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18 */ + case 21: + switch (field) { + case HW_CAT_KCS_CATEGORY: + GET_SET(be->cat.v21.kcs[index].category[km_if_idx], value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_kcs_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 0, index, &value, 0); +} + +int hw_mod_cat_kcs_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 0, index, value, 1); +} + +int hw_mod_cat_kcs_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 1, index, &value, 0); +} + +int hw_mod_cat_kcs_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_kcs_mod(be, field, if_num, 1, index, value, 1); +} + /* * FTE */ @@ -1094,6 +1272,12 @@ int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int i return hw_mod_cat_cte_mod(be, field, index, &value, 0); } +int hw_mod_cat_cte_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value) +{ + return hw_mod_cat_cte_mod(be, field, index, value, 1); +} + int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count) { int addr_size = (_VER_ < 15) ? 8 : ((be->cat.cts_num + 1) / 2); @@ -1154,6 +1338,12 @@ int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int i return hw_mod_cat_cts_mod(be, field, index, &value, 0); } +int hw_mod_cat_cts_get(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value) +{ + return hw_mod_cat_cts_mod(be, field, index, value, 1); +} + int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c index 8c1f3f2d96..f5eaea7c4e 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -293,11 +293,268 @@ int hw_mod_flm_control_set(struct flow_api_backend_s *be, enum hw_flm_e field, u return hw_mod_flm_control_mod(be, field, &value, 0); } +int hw_mod_flm_status_update(struct flow_api_backend_s *be) +{ + return be->iface->flm_status_update(be->be_dev, &be->flm); +} + +static int hw_mod_flm_status_mod(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_STATUS_CALIB_SUCCESS: + GET_SET(be->flm.v25.status->calib_success, value); + break; + + case HW_FLM_STATUS_CALIB_FAIL: + GET_SET(be->flm.v25.status->calib_fail, value); + break; + + case HW_FLM_STATUS_INITDONE: + GET_SET(be->flm.v25.status->initdone, value); + break; + + case HW_FLM_STATUS_IDLE: + GET_SET(be->flm.v25.status->idle, value); + break; + + case HW_FLM_STATUS_CRITICAL: + GET_SET(be->flm.v25.status->critical, value); + break; + + case HW_FLM_STATUS_PANIC: + GET_SET(be->flm.v25.status->panic, value); + break; + + case HW_FLM_STATUS_CRCERR: + GET_SET(be->flm.v25.status->crcerr, value); + break; + + case HW_FLM_STATUS_EFT_BP: + GET_SET(be->flm.v25.status->eft_bp, value); + break; + + case HW_FLM_STATUS_CACHE_BUFFER_CRITICAL: + GET_SET(be->flm.v25.status->cache_buf_critical, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_status_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value) +{ + return hw_mod_flm_status_mod(be, field, value, 1); +} + int hw_mod_flm_scan_flush(struct flow_api_backend_s *be) { return be->iface->flm_scan_flush(be->be_dev, &be->flm); } +static int hw_mod_flm_scan_mod(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value, + int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_SCAN_I: + GET_SET(be->flm.v25.scan->i, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_scan_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_scan_mod(be, field, &value, 0); +} + +int hw_mod_flm_load_bin_flush(struct flow_api_backend_s *be) +{ + return be->iface->flm_load_bin_flush(be->be_dev, &be->flm); +} + +static int hw_mod_flm_load_bin_mod(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_LOAD_BIN: + GET_SET(be->flm.v25.load_bin->bin, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_load_bin_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_load_bin_mod(be, field, &value, 0); +} + +int hw_mod_flm_prio_flush(struct flow_api_backend_s *be) +{ + return be->iface->flm_prio_flush(be->be_dev, &be->flm); +} + +static int hw_mod_flm_prio_mod(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value, + int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_PRIO_LIMIT0: + GET_SET(be->flm.v25.prio->limit0, value); + break; + + case HW_FLM_PRIO_FT0: + GET_SET(be->flm.v25.prio->ft0, value); + break; + + case HW_FLM_PRIO_LIMIT1: + GET_SET(be->flm.v25.prio->limit1, value); + break; + + case HW_FLM_PRIO_FT1: + GET_SET(be->flm.v25.prio->ft1, value); + break; + + case HW_FLM_PRIO_LIMIT2: + GET_SET(be->flm.v25.prio->limit2, value); + break; + + case HW_FLM_PRIO_FT2: + GET_SET(be->flm.v25.prio->ft2, value); + break; + + case HW_FLM_PRIO_LIMIT3: + GET_SET(be->flm.v25.prio->limit3, value); + break; + + case HW_FLM_PRIO_FT3: + GET_SET(be->flm.v25.prio->ft3, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_prio_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_prio_mod(be, field, &value, 0); +} + +int hw_mod_flm_pst_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->flm.nb_pst_profiles; + + if ((unsigned int)(start_idx + count) > be->flm.nb_pst_profiles) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->flm_pst_flush(be->be_dev, &be->flm, start_idx, count); +} + +static int hw_mod_flm_pst_mod(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_PST_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->flm.v25.pst[index], (uint8_t)*value, + sizeof(struct flm_v25_pst_s)); + break; + + case HW_FLM_PST_BP: + GET_SET(be->flm.v25.pst[index].bp, value); + break; + + case HW_FLM_PST_PP: + GET_SET(be->flm.v25.pst[index].pp, value); + break; + + case HW_FLM_PST_TP: + GET_SET(be->flm.v25.pst[index].tp, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value) +{ + return hw_mod_flm_pst_mod(be, field, index, &value, 0); +} + int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index dec96fce85..61492090ce 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -9,6 +9,14 @@ #include "flow_api_hw_db_inline.h" #include "rte_common.h" +#define HW_DB_FT_LOOKUP_KEY_A 0 + +#define HW_DB_FT_TYPE_KM 1 +#define HW_DB_FT_LOOKUP_KEY_A 0 +#define HW_DB_FT_LOOKUP_KEY_C 2 + +#define HW_DB_FT_TYPE_FLM 0 +#define HW_DB_FT_TYPE_KM 1 /******************************************************************************/ /* Handle */ /******************************************************************************/ @@ -59,6 +67,23 @@ struct hw_db_inline_resource_db { int ref; } *cat; + struct hw_db_inline_resource_db_flm_rcp { + struct hw_db_inline_resource_db_flm_ft { + struct hw_db_inline_flm_ft_data data; + struct hw_db_flm_ft idx; + int ref; + } *ft; + + struct hw_db_inline_resource_db_flm_match_set { + struct hw_db_match_set_idx idx; + int ref; + } *match_set; + + struct hw_db_inline_resource_db_flm_cfn_map { + int cfn_idx; + } *cfn_map; + } *flm; + struct hw_db_inline_resource_db_km_rcp { struct hw_db_inline_km_rcp_data data; int ref; @@ -70,6 +95,7 @@ struct hw_db_inline_resource_db { } *km; uint32_t nb_cat; + uint32_t nb_flm_ft; uint32_t nb_km_ft; uint32_t nb_km_rcp; @@ -173,6 +199,13 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) } *db_handle = db; + + /* Preset data */ + + db->flm[0].ft[1].idx.type = HW_DB_IDX_TYPE_FLM_FT; + db->flm[0].ft[1].idx.id1 = 1; + db->flm[0].ft[1].ref = 1; + return 0; } @@ -235,6 +268,11 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_tpe_ext_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_FLM_FT: + hw_db_inline_flm_ft_deref(ndev, db_handle, + *(struct hw_db_flm_ft *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_KM_RCP: hw_db_inline_km_deref(ndev, db_handle, *(struct hw_db_km_idx *)&idxs[i]); break; @@ -286,6 +324,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_TPE_EXT: return &db->tpe_ext[idxs[i].ids].data; + case HW_DB_IDX_TYPE_FLM_FT: + return NULL; /* FTs can't be easily looked up */ + case HW_DB_IDX_TYPE_KM_RCP: return &db->km[idxs[i].id1].data; @@ -307,6 +348,61 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, /* Filter */ /******************************************************************************/ +/* + * lookup refers to key A/B/C/D, and can have values 0, 1, 2, and 3. + */ +static void hw_db_set_ft(struct flow_nic_dev *ndev, int type, int cfn_index, int lookup, + int flow_type, int enable) +{ + (void)type; + (void)enable; + + const int max_lookups = 4; + const int cat_funcs = (int)ndev->be.cat.nb_cat_funcs / 8; + + int fte_index = (8 * flow_type + cfn_index / cat_funcs) * max_lookups + lookup; + int fte_field = cfn_index % cat_funcs; + + uint32_t current_bm = 0; + uint32_t fte_field_bm = 1 << fte_field; + + switch (type) { + case HW_DB_FT_TYPE_FLM: + hw_mod_cat_fte_flm_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, fte_index, + ¤t_bm); + break; + + case HW_DB_FT_TYPE_KM: + hw_mod_cat_fte_km_get(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, fte_index, + ¤t_bm); + break; + + default: + break; + } + + uint32_t final_bm = enable ? (fte_field_bm | current_bm) : (~fte_field_bm & current_bm); + + if (current_bm != final_bm) { + switch (type) { + case HW_DB_FT_TYPE_FLM: + hw_mod_cat_fte_flm_set(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index, final_bm); + hw_mod_cat_fte_flm_flush(&ndev->be, KM_FLM_IF_FIRST, fte_index, 1); + break; + + case HW_DB_FT_TYPE_KM: + hw_mod_cat_fte_km_set(&ndev->be, HW_CAT_FTE_ENABLE_BM, KM_FLM_IF_FIRST, + fte_index, final_bm); + hw_mod_cat_fte_km_flush(&ndev->be, KM_FLM_IF_FIRST, fte_index, 1); + break; + + default: + break; + } + } +} + /* * Setup a filter to match: * All packets in CFN checks @@ -348,6 +444,17 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, if (hw_mod_cat_cte_flush(&ndev->be, cat_hw_id, 1)) return -1; + /* KM: Match all FTs for look-up A */ + for (int i = 0; i < 16; ++i) + hw_db_set_ft(ndev, HW_DB_FT_TYPE_KM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, i, 1); + + /* FLM: Match all FTs for look-up A */ + for (int i = 0; i < 16; ++i) + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_A, i, 1); + + /* FLM: Match FT=ft_argument for look-up C */ + hw_db_set_ft(ndev, HW_DB_FT_TYPE_FLM, cat_hw_id, HW_DB_FT_LOOKUP_KEY_C, ft, 1); + /* Make all CFN checks TRUE */ if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_SET_ALL_DEFAULTS, cat_hw_id, 0, 0)) return -1; @@ -1252,6 +1359,133 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct km_rcp->ft[cat_offset + idx.id1].ref = 0; } } +/******************************************************************************/ +/* FLM FT */ +/******************************************************************************/ + +static int hw_db_inline_flm_ft_compare(const struct hw_db_inline_flm_ft_data *data1, + const struct hw_db_inline_flm_ft_data *data2) +{ + return data1->is_group_zero == data2->is_group_zero && data1->jump == data2->jump && + data1->action_set.raw == data2->action_set.raw; +} + +struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp = &db->flm[data->jump]; + struct hw_db_flm_ft idx = { .raw = 0 }; + + idx.type = HW_DB_IDX_TYPE_FLM_FT; + idx.id1 = 0; + idx.id2 = data->group & 0xff; + + if (data->is_group_zero) { + idx.error = 1; + return idx; + } + + if (flm_rcp->ft[idx.id1].ref > 0) { + if (!hw_db_inline_flm_ft_compare(data, &flm_rcp->ft[idx.id1].data)) { + idx.error = 1; + return idx; + } + + hw_db_inline_flm_ft_ref(ndev, db, idx); + return idx; + } + + memcpy(&flm_rcp->ft[idx.id1].data, data, sizeof(struct hw_db_inline_flm_ft_data)); + flm_rcp->ft[idx.id1].idx.raw = idx.raw; + flm_rcp->ft[idx.id1].ref = 1; + + return idx; +} + +struct hw_db_flm_ft hw_db_inline_flm_ft_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp = &db->flm[data->group]; + struct hw_db_flm_ft idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_FLM_FT; + idx.id1 = 0; + idx.id2 = data->group & 0xff; + + /* RCP 0 always uses FT 1; i.e. use unhandled FT for disabled RCP */ + if (data->group == 0) { + idx.id1 = 1; + return idx; + } + + if (data->is_group_zero) { + idx.id3 = 1; + return idx; + } + + /* FLM_FT records 0, 1 and last (15) are reserved */ + /* NOTE: RES_FLM_FLOW_TYPE resource is global and it cannot be used in _add() and _deref() + * to track usage of FLM_FT recipes which are group specific. + */ + for (uint32_t i = 2; i < db->nb_flm_ft; ++i) { + if (!found && flm_rcp->ft[i].ref <= 0 && + !flow_nic_is_resource_used(ndev, RES_FLM_FLOW_TYPE, i)) { + found = 1; + idx.id1 = i; + } + + if (flm_rcp->ft[i].ref > 0 && + hw_db_inline_flm_ft_compare(data, &flm_rcp->ft[i].data)) { + idx.id1 = i; + hw_db_inline_flm_ft_ref(ndev, db, idx); + return idx; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + memcpy(&flm_rcp->ft[idx.id1].data, data, sizeof(struct hw_db_inline_flm_ft_data)); + flm_rcp->ft[idx.id1].idx.raw = idx.raw; + flm_rcp->ft[idx.id1].ref = 1; + + return idx; +} + +void hw_db_inline_flm_ft_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_ft idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error && idx.id3 == 0) + db->flm[idx.id2].ft[idx.id1].ref += 1; +} + +void hw_db_inline_flm_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_ft idx) +{ + (void)ndev; + (void)db_handle; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_inline_resource_db_flm_rcp *flm_rcp; + + if (idx.error || idx.id2 == 0 || idx.id3 > 0) + return; + + flm_rcp = &db->flm[idx.id2]; + + flm_rcp->ft[idx.id1].ref -= 1; + + if (flm_rcp->ft[idx.id1].ref > 0) + return; + + flm_rcp->ft[idx.id1].ref = 0; + memset(&flm_rcp->ft[idx.id1], 0x0, sizeof(struct hw_db_inline_resource_db_flm_ft)); +} /******************************************************************************/ /* HSH */ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 18d959307e..a520ae1769 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -32,6 +32,10 @@ struct hw_db_idx { HW_DB_IDX; }; +struct hw_db_match_set_idx { + HW_DB_IDX; +}; + struct hw_db_action_set_idx { HW_DB_IDX; }; @@ -106,6 +110,13 @@ struct hw_db_tpe_ext_idx { HW_DB_IDX; }; +struct hw_db_flm_idx { + HW_DB_IDX; +}; +struct hw_db_flm_ft { + HW_DB_IDX; +}; + struct hw_db_km_idx { HW_DB_IDX; }; @@ -128,6 +139,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_TPE_EXT, HW_DB_IDX_TYPE_KM_RCP, + HW_DB_IDX_TYPE_FLM_FT, HW_DB_IDX_TYPE_KM_FT, HW_DB_IDX_TYPE_HSH, }; @@ -211,6 +223,17 @@ struct hw_db_inline_km_ft_data { struct hw_db_action_set_idx action_set; }; +struct hw_db_inline_flm_ft_data { + /* Group zero flows should set jump. */ + /* Group nonzero flows should set group. */ + int is_group_zero; + union { + int jump; + int group; + }; + struct hw_db_action_set_idx action_set; +}; + /**/ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); @@ -277,6 +300,16 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct /**/ +void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); + +struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data); +struct hw_db_flm_ft hw_db_inline_flm_ft_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_ft_data *data); +void hw_db_inline_flm_ft_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_ft idx); +void hw_db_inline_flm_ft_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_flm_ft idx); + int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, uint32_t qsl_hw_id); 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 07801b42ff..46ea70df20 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 @@ -11,6 +11,7 @@ #include "flow_api.h" #include "flow_api_engine.h" #include "flow_api_hw_db_inline.h" +#include "flow_api_profile_inline_config.h" #include "flow_id_table.h" #include "stream_binary_flow_api.h" @@ -47,6 +48,128 @@ static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) return -1; } +/* + * Flow Matcher functionality + */ + +static int flm_sdram_calibrate(struct flow_nic_dev *ndev) +{ + int success = 0; + uint32_t fail_value = 0; + uint32_t value = 0; + + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_PRESET_ALL, 0x0); + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_SPLIT_SDRAM_USAGE, 0x10); + hw_mod_flm_control_flush(&ndev->be); + + /* Wait for ddr4 calibration/init done */ + for (uint32_t i = 0; i < 1000000; ++i) { + hw_mod_flm_status_update(&ndev->be); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_CALIB_SUCCESS, &value); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_CALIB_FAIL, &fail_value); + + if (value & 0x80000000) { + success = 1; + break; + } + + if (fail_value != 0) + break; + + nt_os_wait_usec(1); + } + + if (!success) { + NT_LOG(ERR, FILTER, "FLM initialization failed - SDRAM calibration failed"); + NT_LOG(ERR, FILTER, + "Calibration status: success 0x%08" PRIx32 " - fail 0x%08" PRIx32, + value, fail_value); + return -1; + } + + return 0; +} + +static int flm_sdram_reset(struct flow_nic_dev *ndev, int enable) +{ + int success = 0; + + /* + * Make sure no lookup is performed during init, i.e. + * disable every category and disable FLM + */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, 0x0); + hw_mod_flm_control_flush(&ndev->be); + + /* Wait for FLM to enter Idle state */ + for (uint32_t i = 0; i < 1000000; ++i) { + uint32_t value = 0; + hw_mod_flm_status_update(&ndev->be); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_IDLE, &value); + + if (value) { + success = 1; + break; + } + + nt_os_wait_usec(1); + } + + if (!success) { + NT_LOG(ERR, FILTER, "FLM initialization failed - Never idle"); + return -1; + } + + success = 0; + + /* Start SDRAM initialization */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_INIT, 0x1); + hw_mod_flm_control_flush(&ndev->be); + + for (uint32_t i = 0; i < 1000000; ++i) { + uint32_t value = 0; + hw_mod_flm_status_update(&ndev->be); + hw_mod_flm_status_get(&ndev->be, HW_FLM_STATUS_INITDONE, &value); + + if (value) { + success = 1; + break; + } + + nt_os_wait_usec(1); + } + + if (!success) { + NT_LOG(ERR, FILTER, + "FLM initialization failed - SDRAM initialization incomplete"); + return -1; + } + + /* Set the INIT value back to zero to clear the bit in the SW register cache */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_INIT, 0x0); + hw_mod_flm_control_flush(&ndev->be); + + /* Enable FLM */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, enable); + hw_mod_flm_control_flush(&ndev->be); + + int nb_rpp_per_ps = ndev->be.flm.nb_rpp_clock_in_ps; + int nb_load_aps_max = ndev->be.flm.nb_load_aps_max; + uint32_t scan_i_value = 0; + + if (NTNIC_SCANNER_LOAD > 0) { + scan_i_value = (1 / (nb_rpp_per_ps * 0.000000000001)) / + (nb_load_aps_max * NTNIC_SCANNER_LOAD); + } + + hw_mod_flm_scan_set(&ndev->be, HW_FLM_SCAN_I, scan_i_value); + hw_mod_flm_scan_flush(&ndev->be); + + return 0; +} + + + struct flm_flow_key_def_s { union { struct { @@ -2354,11 +2477,11 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, const struct nic_flow_def *fd, const struct hw_db_inline_qsl_data *qsl_data, const struct hw_db_inline_hsh_data *hsh_data, - uint32_t group __rte_unused, + uint32_t group, uint32_t local_idxs[], uint32_t *local_idx_counter, - uint16_t *flm_rpl_ext_ptr __rte_unused, - uint32_t *flm_ft __rte_unused, + uint16_t *flm_rpl_ext_ptr, + uint32_t *flm_ft, uint32_t *flm_scrub __rte_unused, struct rte_flow_error *error) { @@ -2507,6 +2630,25 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, return -1; } + /* Setup FLM FT */ + struct hw_db_inline_flm_ft_data flm_ft_data = { + .is_group_zero = 0, + .group = group, + }; + struct hw_db_flm_ft flm_ft_idx = empty_pattern + ? hw_db_inline_flm_ft_default(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data) + : hw_db_inline_flm_ft_add(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data); + local_idxs[(*local_idx_counter)++] = flm_ft_idx.raw; + + if (flm_ft_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM FT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + + if (flm_ft) + *flm_ft = flm_ft_idx.id1; + return 0; } @@ -2514,7 +2656,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n const struct rte_flow_attr *attr, uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, struct rte_flow_error *error, uint32_t port_id, - uint32_t num_dest_port __rte_unused, uint32_t num_queues __rte_unused, + uint32_t num_dest_port, uint32_t num_queues, uint32_t *packet_data, uint32_t *packet_mask __rte_unused, struct flm_flow_key_def_s *key_def __rte_unused) { @@ -2808,6 +2950,21 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n km_write_data_match_entry(&fd->km, 0); } + /* Setup FLM FT */ + struct hw_db_inline_flm_ft_data flm_ft_data = { + .is_group_zero = 1, + .jump = fd->jump_to_group != UINT32_MAX ? fd->jump_to_group : 0, + }; + struct hw_db_flm_ft flm_ft_idx = + hw_db_inline_flm_ft_add(dev->ndev, dev->ndev->hw_db_handle, &flm_ft_data); + fh->db_idxs[fh->db_idx_counter++] = flm_ft_idx.raw; + + if (flm_ft_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM FT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + nic_insert_flow(dev->ndev, fh); } @@ -3024,6 +3181,63 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) NT_VIOLATING_MBR_QSL) < 0) goto err_exit0; + /* FLM */ + if (flm_sdram_calibrate(ndev) < 0) + goto err_exit0; + + if (flm_sdram_reset(ndev, 1) < 0) + goto err_exit0; + + /* Learn done status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_LDS, 0); + /* Learn fail status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_LFS, 1); + /* Learn ignore status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_LIS, 1); + /* Unlearn done status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_UDS, 0); + /* Unlearn ignore status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_UIS, 0); + /* Relearn done status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_RDS, 0); + /* Relearn ignore status */ + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_RIS, 0); + hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_RBL, 4); + hw_mod_flm_control_flush(&ndev->be); + + /* Set the sliding windows size for flm load */ + uint32_t bin = (uint32_t)(((FLM_LOAD_WINDOWS_SIZE * 1000000000000ULL) / + (32ULL * ndev->be.flm.nb_rpp_clock_in_ps)) - + 1ULL); + hw_mod_flm_load_bin_set(&ndev->be, HW_FLM_LOAD_BIN, bin); + hw_mod_flm_load_bin_flush(&ndev->be); + + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT0, + 0); /* Drop at 100% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT0, 1); + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT1, + 14); /* Drop at 87,5% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT1, 1); + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT2, + 10); /* Drop at 62,5% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT2, 1); + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_LIMIT3, + 6); /* Drop at 37,5% FIFO fill level */ + hw_mod_flm_prio_set(&ndev->be, HW_FLM_PRIO_FT3, 1); + hw_mod_flm_prio_flush(&ndev->be); + + /* TODO How to set and use these limits */ + for (uint32_t i = 0; i < ndev->be.flm.nb_pst_profiles; ++i) { + hw_mod_flm_pst_set(&ndev->be, HW_FLM_PST_BP, i, + NTNIC_FLOW_PERIODIC_STATS_BYTE_LIMIT); + hw_mod_flm_pst_set(&ndev->be, HW_FLM_PST_PP, i, + NTNIC_FLOW_PERIODIC_STATS_PKT_LIMIT); + hw_mod_flm_pst_set(&ndev->be, HW_FLM_PST_TP, i, + NTNIC_FLOW_PERIODIC_STATS_BYTE_TIMEOUT); + } + + hw_mod_flm_pst_flush(&ndev->be, 0, ALL_ENTRIES); + ndev->id_table_handle = ntnic_id_table_create(); if (ndev->id_table_handle == NULL) @@ -3052,6 +3266,8 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) #endif if (ndev->flow_mgnt_prepared) { + flm_sdram_reset(ndev, 0); + flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h new file mode 100644 index 0000000000..8ba8b8f67a --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h @@ -0,0 +1,58 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_PROFILE_INLINE_CONFIG_H_ +#define _FLOW_API_PROFILE_INLINE_CONFIG_H_ + +/* + * Statistics are generated each time the byte counter crosses a limit. + * If BYTE_LIMIT is zero then the byte counter does not trigger statistics + * generation. + * + * Format: 2^(BYTE_LIMIT + 15) bytes + * Valid range: 0 to 31 + * + * Example: 2^(8 + 15) = 2^23 ~~ 8MB + */ +#define NTNIC_FLOW_PERIODIC_STATS_BYTE_LIMIT 8 + +/* + * Statistics are generated each time the packet counter crosses a limit. + * If PKT_LIMIT is zero then the packet counter does not trigger statistics + * generation. + * + * Format: 2^(PKT_LIMIT + 11) pkts + * Valid range: 0 to 31 + * + * Example: 2^(5 + 11) = 2^16 pkts ~~ 64K pkts + */ +#define NTNIC_FLOW_PERIODIC_STATS_PKT_LIMIT 5 + +/* + * Statistics are generated each time flow time (measured in ns) crosses a + * limit. + * If BYTE_TIMEOUT is zero then the flow time does not trigger statistics + * generation. + * + * Format: 2^(BYTE_TIMEOUT + 15) ns + * Valid range: 0 to 31 + * + * Example: 2^(23 + 15) = 2^38 ns ~~ 275 sec + */ +#define NTNIC_FLOW_PERIODIC_STATS_BYTE_TIMEOUT 23 + +/* + * This define sets the percentage of the full processing capacity + * being reserved for scan operations. The scanner is responsible + * for detecting aged out flows and meters with statistics timeout. + * + * A high scanner load percentage will make this detection more precise + * but will also give lower packet processing capacity. + * + * The percentage is given as a decimal number, e.g. 0.01 for 1%, which is the recommended value. + */ +#define NTNIC_SCANNER_LOAD 0.01 + +#endif /* _FLOW_API_PROFILE_INLINE_CONFIG_H_ */ diff --git a/drivers/net/ntnic/ntutil/nt_util.h b/drivers/net/ntnic/ntutil/nt_util.h index 71ecd6c68c..a482fb43ad 100644 --- a/drivers/net/ntnic/ntutil/nt_util.h +++ b/drivers/net/ntnic/ntutil/nt_util.h @@ -16,6 +16,14 @@ #define ARRAY_SIZE(arr) RTE_DIM(arr) #endif +/* + * Windows size in seconds for measuring FLM load + * and Port load. + * The windows size must max be 3 min in order to + * prevent overflow. + */ +#define FLM_LOAD_WINDOWS_SIZE 2ULL + #define PCIIDENT_TO_DOMAIN(pci_ident) ((uint16_t)(((unsigned int)(pci_ident) >> 16) & 0xFFFFU)) #define PCIIDENT_TO_BUSNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 8) & 0xFFU)) #define PCIIDENT_TO_DEVNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 3) & 0x1FU)) -- 2.45.0