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 842AC45BA3; Tue, 22 Oct 2024 19:00:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CFB1C410D5; Tue, 22 Oct 2024 18:56:56 +0200 (CEST) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id 7CD9F40E2D for ; Tue, 22 Oct 2024 18:56:40 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2108.outbound.protection.outlook.com [104.47.18.108]) by mx-outbound15-54.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RtnjGooJ8ddb6vVNQFK4vNluGEXGIPDK3HGlYeoQDYA+g8MKUx5T3vE+ws6M57q09FtJikyDmbbkGa+W/yChMOzLGOm1BmoCNkf8gnnWqxDZUeno8CgqX412nuwEIv+7KpvOzNPkBDETKaE9EgNhe1FYaVd8sC4BN8nlQhk5985mMGUb0I0+TjRf8vDlPoaaQBpqivFfQVQ7Ql4iSgBcBXDxoTc5PLsRg1/uWY6/0KJYvA3/9U31h98x9pkBtSCPJgLAF04Io6ZtLMn5UXmh4Tc8Skt4tOs22ZAFFSenuBCSYrfvS5lrMUFrq4ghMid3+3x1KSLA0hWGP6AdahhWeA== 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=J1xDYt+shbeRS9rPvRc+9yPajp38UikpucfrrbS7jFg=; b=vnAz+szJHIa2gkPz+pN700v78veycRfWy9wyzba1SZHkOFoCViWqskTMank4Bc0Gw8wr29bXY+QoLiVnhNr5XF/U6hxxynUbuOXooKI1pE72fdWzus+hK8CYxY4GTuiwX03rKisfwYtoumPYkmvs4XpInZDua2OT98y2oUv39w3x8VNOFPzRc8fSJT8cVAcf3XFSt3QB9XclmxhMZdU0gv/fyCiyLZnqbzcO8adr5tEqPmCL1tnj2QXhFqqiJRtl4tPQR9iXj1PtMqjGZ0c5WuvvmgJqxNyVF73TPCKYA/VpF/CWKTSOfepr4tMqW8X53R8Zpy62X/2+32RrXOUv7w== 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=J1xDYt+shbeRS9rPvRc+9yPajp38UikpucfrrbS7jFg=; b=OG572kHCyY7pL3Enj2Ls2jhicVuF0WNf4JAsPTf2ZMXniwTP3WmV2se/mKwcWCcX66XDuRfJ7v7x674uN6mhL3NNeJrbijlLewFpl0XAO0XNLNYQA2SWeNZP1XiwEiAb3vU1RMsefuHsxdZkDDn48mVf7xqgvO4jznE2jK+oyKA= Received: from DB9PR06CA0014.eurprd06.prod.outlook.com (2603:10a6:10:1db::19) by AM9P190MB1201.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:264::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 16:56:35 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::8) by DB9PR06CA0014.outlook.office365.com (2603:10a6:10:1db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56:35 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:35 +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 v2 33/73] net/ntnic: add FLM module Date: Tue, 22 Oct 2024 18:54:50 +0200 Message-ID: <20241022165541.3186140-34-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|AM9P190MB1201:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 06b4337e-d6ff-491a-dcb9-08dcf2ba7d00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ot96XOKoPwmS1wexVIuaR3F/cVzXRLt8244uPUn689y8aD0Xq8hu+eu0e3Z7?= =?us-ascii?Q?zEpPEF94mD6kapblERGGjUW9bXmN3iCgW9LpvxPAkFiS2vkVoYg/pWeDGXWb?= =?us-ascii?Q?3lNJqwXd3BROOUJP+QNO8Adty62uS14r4R5wcTad9Ejcz40kC8ItSM8KUp1z?= =?us-ascii?Q?nOwLua7ctdbgT/oBO1uC6klWMuJZiFXQFoqiGQCCXiyFfeR79o8zDaEqtWlQ?= =?us-ascii?Q?Q9WbUajsy/2FMyGol9WdWB+iKPi9lgxPWHck7gWVwN63YoOo2cM7AtSSp8YQ?= =?us-ascii?Q?rcWYSJSrwCiBbYGVYlUCaRcvD44Xe9JgMK3IWgMtluRIYtXh0xhePjsTiZdP?= =?us-ascii?Q?2h+2DX4nZllKlR46GAgzErH1WdCgq6HsASS9OiuncQMdnnwNa/P3OXFCApTu?= =?us-ascii?Q?1Ff5CXNPv47nbGG8dn8H7rz0/Fw7kfQb1i6NDFkFIPYC/PKvLxTV8WgmqCW8?= =?us-ascii?Q?WKVbjdEwMUaPrhYDcZaMXsiHv/2ANx4u4qnUbedeSG1xOuYWY34v04Hy0mQ0?= =?us-ascii?Q?FSRzQGFsG1j37Z2D2lZUROP3jSr+UEruUEoTrlUju//ETwjvYxT7MRIG91NS?= =?us-ascii?Q?8KWN4xMlM4M/WxycvYN/ZU0+yEcWdHgOnxrqU5jpBBo/TniarUoYljk0uPVz?= =?us-ascii?Q?gOA6GSfNlul+qOfM5eWWHX68jMcL2pNYx3IYUJp5TH68HFeVaysEXe22cfA8?= =?us-ascii?Q?a0v/uAdKdQ6Fyu2bW4bHzu/YeFOf3lITtWOAIUm8fob4WP3Vr/NABFM92vY5?= =?us-ascii?Q?prOEQz/W/GbsWjdlQhAQpznhM1c1276Wkv70lDtS1LKDCWQmQ1IuMhMCqFke?= =?us-ascii?Q?mVcdedUNYos2V/UZhaXicBMcikZGsYWjEsRwpC/tgTRZ2vH8f03RAg7jmh1/?= =?us-ascii?Q?OHtdy+nMFbBH3Fz/xYKcnA1nvuWXR1wiGgL83iX6mzGO6bMd4SdoR68LZLPr?= =?us-ascii?Q?Ty7XogBD0/s8U6pmpUwLeKuS/E6qHcD5s7Y4LSRDN0//Q9E+RtUj0OJIHxUW?= =?us-ascii?Q?IaFxRW6DThdJklD2Mh2LdBKr3ld928YdO+1//Fcl0a6uF+Q6aAOaKbKbefVw?= =?us-ascii?Q?zFxzPpDgKcMZPaaog2o/s52kqLZqWSw9i0u6l5Y6x69vRfKPS6tZk/XCcLxI?= =?us-ascii?Q?SKn1weezdVGF4oseDQwBlQHKDDHjEMVeA15jHF905Q9P73fhfThPnA9tiCoE?= =?us-ascii?Q?HBogTr033K8/nyPGuNxpgL87alLQ4B6eqB8fvFz6JvZ5oI+MuvafZmBqp75g?= =?us-ascii?Q?G8WJz0oj9D1hBIlIULWmJLFgoZuGBjs75uvjYXxpck8Io0Fa8s2MJBDPRzk8?= =?us-ascii?Q?tdrwEbJ4LrTk7NptDKSBa6hJuKpoVdz6zVuIfmq2k+ue66obPMgX26C7BXvM?= =?us-ascii?Q?IGQlDWYgqGQc9b1/sxfKAYwL/3QMaPSDqeKY34d2vAHLQhm3RA=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)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aLkY+oA65SSH+Kmj6r4vbMJLWK9FFxQPmfLMucp1KdWEr5vVCBPR6g31scbrqececTdUqE52m6iJBnkMsclpluQtQSYkMRmBT/KCnw3TMBJMIqJ5BqEbHuZLizHlqtSFwoChvUFU3LnLpSpDxJ337XXOftZjvTQ3Re3OLDNN67fxJZMOok1Z8wKjNtDKuIlXgbF0+2/oX2PhOhzdjipl1lpiqIMVQl5sNpDxXdlDYnzEAeXp7nwYtYgbRdCPUrrSAvejcb58vxaNi1QqVdxWjAAI7JKh+fx7LR/rLElTFfscgMTRH0svrK/R5UwJgobIi6WDnEhoR90svgRsJAuAqUTSfdKU/qJaXpMmbdwYE6QBukHqybkumfnXxu1GS4j0eQHOHWplOwjK41AA1a4lj5Y3prE+lH3dIyovXmoXIhPdheY5bgpnolwUf900K97T7dSWN8XA+yFKhHcfPriZJCPZMTmQkt2lOWiYR14naamFLIEhzRSuiYxeEyENDwPp93slpWMNnkWaAr6KxBQqEUi9Q095HybcpcxUZtH7qwlyP2eSFnJnsxBBQ2JCYG6bAQTMtzgVXzADmkPrGm/KR5SGnn+1qxBhQ0XauzyGaYd4umDHJntw6yN8+CfHu3EPbbClQQRHHIkQYlppZMfo6RlrC6vEjrt2ggwxoLQ8twE= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:35.1690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06b4337e-d6ff-491a-dcb9-08dcf2ba7d00 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1201 X-BESS-ID: 1729616197-303894-12661-13482-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.108 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYmlgYmQGYGUNTAyNLEyCwtxc jCzDQpMc3MwMA4KSXZ3MQ8JcnCKDnNUqk2FgAIat3HQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259901 [from cloudscan20-3.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, 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 | 129 +++++++++ drivers/net/ntnic/ntutil/nt_util.h | 8 + 8 files changed, 1113 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 35ecea28b6..5ad2ceb4ca 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 { @@ -2355,11 +2478,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) { @@ -2508,6 +2631,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; } @@ -2515,7 +2657,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) { @@ -2809,6 +2951,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); } @@ -3029,6 +3186,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) @@ -3057,6 +3271,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..9e454e4c0f --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline_config.h @@ -0,0 +1,129 @@ +/* + * 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_ + +/* + * Per port configuration for IPv4 fragmentation and DF flag handling + * + * ||-------------------------------------||-------------------------||----------|| + * || Configuration || Egress packet type || || + * ||-------------------------------------||-------------------------|| Action || + * || IPV4_FRAGMENTATION | IPV4_DF_ACTION || Exceeding MTU | DF flag || || + * ||-------------------------------------||-------------------------||----------|| + * || DISABLE | - || - | - || Forward || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | DF_DROP || no | - || Forward || + * || | || yes | 0 || Fragment || + * || | || yes | 1 || Drop || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | DF_FORWARD || no | - || Forward || + * || | || yes | 0 || Fragment || + * || | || yes | 1 || Forward || + * ||-------------------------------------||-------------------------||----------|| + */ + +#define PORT_0_IPV4_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_0_IPV4_DF_ACTION IPV4_DF_DROP + +#define PORT_1_IPV4_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_1_IPV4_DF_ACTION IPV4_DF_DROP + + +/* + * Per port configuration for IPv6 fragmentation + * + * ||-------------------------------------||-------------------------||----------|| + * || Configuration || Egress packet type || || + * ||-------------------------------------||-------------------------|| Action || + * || IPV6_FRAGMENTATION | IPV6_ACTION || Exceeding MTU || || + * ||-------------------------------------||-------------------------||----------|| + * || DISABLE | - || - || Forward || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | DROP || no || Forward || + * || | || yes || Drop || + * ||-------------------------------------||-------------------------||----------|| + * || ENABLE | FRAGMENT || no || Forward || + * || | || yes || Fragment || + * ||-------------------------------------||-------------------------||----------|| + */ + +#define PORT_0_IPV6_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_0_IPV6_ACTION IPV6_DROP + +#define PORT_1_IPV6_FRAGMENTATION DISABLE_FRAGMENTATION +#define PORT_1_IPV6_ACTION IPV6_DROP + + +/* + * 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 + +/* + * This define sets the timeout resolution of aged flow scanner (scrubber). + * + * The timeout resolution feature is provided in order to reduce the number of + * write-back operations for flows without attached meter. If the resolution + * is disabled (set to 0) and flow timeout is enabled via age action, then a write-back + * occurs every the flow is evicted from the flow cache, essentially causing the + * lookup performance to drop to that of a flow with meter. By setting the timeout + * resolution (>0), write-back for flows happens only when the difference between + * the last recorded time for the flow and the current time exceeds the chosen resolution. + * + * The parameter value is a power of 2 in units of 2^28 nanoseconds. It means that value 8 sets + * the timeout resolution to: 2^8 * 2^28 / 1e9 = 68,7 seconds + * + * NOTE: This parameter has a significant impact on flow lookup performance, especially + * if full scanner timeout resolution (=0) is configured. + */ +#define NTNIC_SCANNER_TIMEOUT_RESOLUTION 8 + +#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