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 3F12545B04; Thu, 10 Oct 2024 16:18:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1AA8E40E68; Thu, 10 Oct 2024 16:15:19 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 14E2F40DF8 for ; Thu, 10 Oct 2024 16:15:02 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2108.outbound.protection.outlook.com [104.47.30.108]) by mx-outbound20-48.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Oct 2024 14:14:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kGuA/jwoWNl9tE+Ucxq/VaxqgXbtoNGk2oBMk+SX5vcS+ZOMbzelNAbne1YYdsAOWrUfN8lfJWxxIa7p0LkE00g1wEjBYxrBdvy+Wc7c5e02WpXutvU0VcOPiMlUXhbJLqvgcLBEpu0DKrcE2TUOxZpRqYPRM+SRxiACnmc5u5Eg3a9CoWKUZsB6QrrsBUsM/5VUU07JZa1QZb333dqieRyI4NbRyE7DSgcgG7ybNCfv2k6PzVQQvkwjNm+41E/xjtnbp7DpwXGV3IwUW8BxbtfH6n7M0IahTlyKdzPOudymU3Yi8aIUzVEAcy+x/KUP663UZ32I0odNKOpGEqK+jQ== 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=MKo6vV/DHb/bykvEAnAPB826d7D7pvqbxt+CrY6wSD4=; b=LDqRCxbT9seNuXuu7Ty4a+iFb/T38z+L21jffIDea00QVsh13ZRoUTu/2qnX1n0XHl8CALlN6HlEb9t56YZct6Lg9O6NXaG9ouRvk++MGSf2TJVfzDoWB3rqCPfb+BrAtoHzyL5zLAlgumgIBgZjxBchhw0M2e5lCbD6NXu5xVz0r7o+9mOPiHu6rwQoINMvHyVSmrvrmcMah1QP4ZB8a4e9q61veCw24BuszOvq/yRPQTjnqTTBQmuV+smpIaKNipGroAyhXPU5XScSxr1wZR4lJ4sX/lLilxB+j6ulILL/e4mNJZjlGmOUWHIpjJSPDMWRnBGUu5SSkb/ACdVDvA== 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=MKo6vV/DHb/bykvEAnAPB826d7D7pvqbxt+CrY6wSD4=; b=hCwxlO0xcKGHYXS7zKGy2TlsNa7kDDkT69vOUdBEUHVeiJbMzi3fEVAx6EAVPvEls8+9iMgncJN2uSfdpyaZzigLWgRWrdctQHf02KiHJGmEEQPusCRkm16059ppEsKjYZs8uBhkkm5h86BEXbJKwrZMA/eVpbDtqjcPEoRCYwg= Received: from DU2PR04CA0081.eurprd04.prod.outlook.com (2603:10a6:10:232::26) by AS4P190MB2024.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:51c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Thu, 10 Oct 2024 14:14:53 +0000 Received: from DU6PEPF0000B61B.eurprd02.prod.outlook.com (2603:10a6:10:232:cafe::2a) by DU2PR04CA0081.outlook.office365.com (2603:10a6:10:232::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Thu, 10 Oct 2024 14:14:52 +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 DU6PEPF0000B61B.mail.protection.outlook.com (10.167.8.132) with Microsoft SMTP Server id 15.20.8048.13 via Frontend Transport; Thu, 10 Oct 2024 14:14:52 +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, Oleksandr Kolomeiets Subject: [PATCH v3 30/50] net/ntnic: add flow matcher (FLM) FPGA module Date: Thu, 10 Oct 2024 16:13:45 +0200 Message-ID: <20241010141416.4063591-31-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241010141416.4063591-1-sil-plv@napatech.com> References: <20241006203728.330792-2-sil-plv@napatech.com> <20241010141416.4063591-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B61B:EE_|AS4P190MB2024:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 49e85a5f-41b2-425e-28bb-08dce935e8dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IkPlT6g7UNkdy8X5IBM0WUx2HT+RfUwDxMVJhiJLYhYOXV/ba6GovqPsmGcb?= =?us-ascii?Q?7+Vi74u7alScV3mBkcnfuJ2k6kEv5lxBX85pYr34Gv5+OnZ2LsRV9pzgGzWk?= =?us-ascii?Q?LXluhlswpq0h2v8POju7aNn0CgAO49UOOtqVjQNqnHG2doXFNJMiTg+zdYNl?= =?us-ascii?Q?pvBIZCLuKr+t0YTmMy+1XIpqpaRtVEIduCL3CIxToA3ieFWra4DEHxYCj535?= =?us-ascii?Q?cNBYeGUZOWoiQrhbZ+SijyDSCrbAmEYZEwfiA+oarAd2WPyTAMq4NC39aH8X?= =?us-ascii?Q?9SuR/lSn4wEa95yEgACrwrtA6mtrsFY0jgPrJDlaGIJs6acyQpmA6CPlWUqe?= =?us-ascii?Q?R1jc7FjI6zuaHaIff9TAOwf9h90cDcXTy8aOG1c5nXCLKIUj7JAMABgHLQL3?= =?us-ascii?Q?S0n5mDv2c7Tja6clUqkx2zawxZ1LEzuzUydanrzt+2ZSh7vCdzrrNHDvYnFr?= =?us-ascii?Q?aAWs/Cp2xf1KMTQOJ7UAAokOw3CA6gM41TvSYZZ+oVUBQInrbwwbEivweC2K?= =?us-ascii?Q?VN2LhQNF/hPp2SdYhAMAZAkB0A7Nzxz+yWbS84BsTjKmVrtVkwtcX33Dks02?= =?us-ascii?Q?6aQTUWslrgSRwGvACLLT77y+8Qy4Vtq2NZWtTsaPGKT6U5kpx8Ob88cPsKQr?= =?us-ascii?Q?Gzdb0iZDMV4AzzRXOtJ/gTdmgAThJNaeqUYk0l5dr/6b6yDoHUSHzv9u+pC6?= =?us-ascii?Q?cubXWnPGJzQo92PwYmRi6CVFOtjunP6XYKrnhfDmQlJ6mpWtMx1itOo1mkwX?= =?us-ascii?Q?9KZAzs1P3lrgXkcevXo0adOo5SDBjQG99DQHq/OjdTVxPH3ggrrMQ/tcKz5S?= =?us-ascii?Q?0Ey+ut/fj4UTdgRe5ZftvGYT35D8dspRhwohvj6LmBz7S+T8p9fEnkTco261?= =?us-ascii?Q?+pb7iYej6XzGXAlnbvDs/WQAGY1z46+/CuMR3xpxw3DXWUBAfQt1EGiexI1A?= =?us-ascii?Q?tqnt9740J+RpTMCi9J3JHHCkfIIAo7Hk0P0/+XV51dAWxSO5p+MK8ZZAS7To?= =?us-ascii?Q?Z3jEtyPBLY1V7kHNuRjS9+JGDnf7abndMiRd5NvKpSUe+0YN0qzmzPGVxZcu?= =?us-ascii?Q?3TgDJLgZaNQjQDeVrH8vd2krwYpyK9D8xA1zhK7MSEjOHGP3/OqsC5V1q0EC?= =?us-ascii?Q?uqnDP79SPND6Qv+xgg7dzK5mZjLL1rraf37H/+7G+AfqdlnGQgeEtzVSaMWW?= =?us-ascii?Q?ixhJcAbQXKMYGH+FeuALVokio0gZ9SNpw9ajAvOkaD2rZHFZaIFbvO4VVyeI?= =?us-ascii?Q?ONwXEyTe4onNVZF9g6neeAenBfjWDqC9z+fZN1HAg75w+1sYqBUQzAi9pq2t?= =?us-ascii?Q?GgNuL396vqrhpHRhA4ut918iHk62DuXDnuyGGAxV2ooDY/ROi5tt9R0dU4PC?= =?us-ascii?Q?EDbmxQc2e1YjomoRfBf46Hcdrpxe?= 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)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /qRCXMHKtRpkFFEpyOJ+LBEejskBSvSqoLvp2yeg99jv6MuE6Pz8rpeB2dL+w1SxNcRvqaeeTCmg5SDElZok8X6jfKKc3Ty+cHc7LmtG4GJrIHL7zZ3xtgvAuSHeHemM5ir8IatSiTnljZrl9sNOXU+O1OP1uKPMYotMBOzAP43KvxTyXazGkhmI3HPA79L3lRKkp28BlxzLKenq3Q42lvI6fBpH9xGw90amOM7S4cHyJQscRvVyOJ2rqMJNXrC4VT5wvV4MfDyRkRjbdB+ZSULXNy7OTov1/aA72vjN1eiTbXjrYUouyc64lYUfHNU9E2LkJoczJW1L8yDZ9MEWC3BTuUTE60r2d5YW46/XcFxbMrotHfzeJJcFhEgFxNiU6j7+SKemUaqBQHTDmTnqLKHrBQgwpi5OpzoeE/8CNkOlAnlw62/UTdBwBAf4TWKZLpt3aXKsNlaxJKnYId2OyAPmYn7KiRs8QtyZiEmWBfjnUlMXaiQ+o6NhrRPhQrIHuJNrs202RUyaNrGILg1jO/20WgAWA2S50R4xVmvd752V73QhxAqV4FCWBclzWUvCCx54rw6YOhVnMa2IBjmMMEa123KIH9g1lFOS1j7PFChk0Vv+QaXGYamhCdIoGLEFoGdePwuu+oXnMyPZdb9Km4gJYYc0e8IItXvIqjA4t7A= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 14:14:52.6236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49e85a5f-41b2-425e-28bb-08dce935e8dc 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: DU6PEPF0000B61B.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB2024 X-BESS-ID: 1728569696-305168-12640-25889-2 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.30.108 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamppYGQGYGUNTcKMXY0NTCyN Iy1cIgzcLMPC012cLYLM3MODnNzDTFQqk2FgBoogonQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259630 [from cloudscan22-122.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Oleksandr Kolomeiets 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: Oleksandr Kolomeiets --- v3 * Remove newline characters from logs. * Modify macros according to new logging and fix braces --- drivers/net/ntnic/include/hw_mod_backend.h | 117 +++++++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 6 + .../nthw/flow_api/hw_mod/hw_mod_backend.c | 1 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 324 ++++++++++++++++++ 5 files changed, 449 insertions(+) create mode 100644 drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 0d1a585401..78e6d39437 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -370,6 +370,122 @@ struct flm_func_s { struct hw_mod_flm_v25_s v25; }; }; +enum hw_flm_e { + /* functions */ + HW_FLM_CONTROL_PRESET_ALL = 0, + HW_FLM_RCP_PRESET_ALL, + HW_FLM_FLOW_LRN_DATA, + HW_FLM_FLOW_INF_STA_DATA, + /* Control fields */ + HW_FLM_CONTROL_ENABLE = FIELD_START_INDEX, + HW_FLM_CONTROL_INIT, + HW_FLM_CONTROL_LDS, + HW_FLM_CONTROL_LFS, + HW_FLM_CONTROL_LIS, + HW_FLM_CONTROL_UDS, + HW_FLM_CONTROL_UIS, + HW_FLM_CONTROL_RDS, + HW_FLM_CONTROL_RIS, + HW_FLM_CONTROL_PDS, + HW_FLM_CONTROL_PIS, + HW_FLM_CONTROL_CRCWR, + HW_FLM_CONTROL_CRCRD, + HW_FLM_CONTROL_RBL, + HW_FLM_CONTROL_EAB, + HW_FLM_CONTROL_SPLIT_SDRAM_USAGE, + HW_FLM_STATUS_CALIB_SUCCESS, + HW_FLM_STATUS_CALIB_FAIL, + HW_FLM_STATUS_INITDONE, + HW_FLM_STATUS_IDLE, + HW_FLM_STATUS_CRITICAL, + HW_FLM_STATUS_PANIC, + HW_FLM_STATUS_CRCERR, + HW_FLM_STATUS_EFT_BP, + HW_FLM_STATUS_CACHE_BUFFER_CRITICAL, + HW_FLM_LOAD_BIN, + HW_FLM_LOAD_LPS, + HW_FLM_LOAD_APS, + HW_FLM_PRIO_LIMIT0, + HW_FLM_PRIO_FT0, + HW_FLM_PRIO_LIMIT1, + HW_FLM_PRIO_FT1, + HW_FLM_PRIO_LIMIT2, + HW_FLM_PRIO_FT2, + HW_FLM_PRIO_LIMIT3, + HW_FLM_PRIO_FT3, + HW_FLM_PST_PRESET_ALL, + HW_FLM_PST_BP, + HW_FLM_PST_PP, + HW_FLM_PST_TP, + HW_FLM_RCP_LOOKUP, + HW_FLM_RCP_QW0_DYN, + HW_FLM_RCP_QW0_OFS, + HW_FLM_RCP_QW0_SEL, + HW_FLM_RCP_QW4_DYN, + HW_FLM_RCP_QW4_OFS, + HW_FLM_RCP_SW8_DYN, + HW_FLM_RCP_SW8_OFS, + HW_FLM_RCP_SW8_SEL, + HW_FLM_RCP_SW9_DYN, + HW_FLM_RCP_SW9_OFS, + HW_FLM_RCP_MASK, + HW_FLM_RCP_KID, + HW_FLM_RCP_OPN, + HW_FLM_RCP_IPN, + HW_FLM_RCP_BYT_DYN, + HW_FLM_RCP_BYT_OFS, + HW_FLM_RCP_TXPLM, + HW_FLM_RCP_AUTO_IPV4_MASK, + HW_FLM_BUF_CTRL_LRN_FREE, + HW_FLM_BUF_CTRL_INF_AVAIL, + HW_FLM_BUF_CTRL_STA_AVAIL, + HW_FLM_STAT_LRN_DONE, + HW_FLM_STAT_LRN_IGNORE, + HW_FLM_STAT_LRN_FAIL, + HW_FLM_STAT_UNL_DONE, + HW_FLM_STAT_UNL_IGNORE, + HW_FLM_STAT_REL_DONE, + HW_FLM_STAT_REL_IGNORE, + HW_FLM_STAT_PRB_DONE, + HW_FLM_STAT_PRB_IGNORE, + HW_FLM_STAT_AUL_DONE, + HW_FLM_STAT_AUL_IGNORE, + HW_FLM_STAT_AUL_FAIL, + HW_FLM_STAT_TUL_DONE, + HW_FLM_STAT_FLOWS, + HW_FLM_STAT_STA_DONE, /* module ver 0.20 */ + HW_FLM_STAT_INF_DONE, /* module ver 0.20 */ + HW_FLM_STAT_INF_SKIP, /* module ver 0.20 */ + HW_FLM_STAT_PCK_HIT, /* module ver 0.20 */ + HW_FLM_STAT_PCK_MISS, /* module ver 0.20 */ + HW_FLM_STAT_PCK_UNH, /* module ver 0.20 */ + HW_FLM_STAT_PCK_DIS, /* module ver 0.20 */ + HW_FLM_STAT_CSH_HIT, /* module ver 0.20 */ + HW_FLM_STAT_CSH_MISS, /* module ver 0.20 */ + HW_FLM_STAT_CSH_UNH, /* module ver 0.20 */ + HW_FLM_STAT_CUC_START, /* module ver 0.20 */ + HW_FLM_STAT_CUC_MOVE, /* module ver 0.20 */ + HW_FLM_SCAN_I, /* module ver 0.22 */ + HW_FLM_SCRUB_PRESET_ALL, + HW_FLM_SCRUB_T, /* module ver 0.22 */ + HW_FLM_SCRUB_R, /* module ver 0.24 */ + HW_FLM_SCRUB_DEL, /* module ver 0.24 */ + HW_FLM_SCRUB_INF, /* module ver 0.24 */ +}; + +bool hw_mod_flm_present(struct flow_api_backend_s *be); +int hw_mod_flm_alloc(struct flow_api_backend_s *be); +void hw_mod_flm_free(struct flow_api_backend_s *be); +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_scan_flush(struct flow_api_backend_s *be); + +int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count); struct hsh_func_s { COMMON_FUNC_INFO_S; @@ -571,6 +687,7 @@ struct flow_api_backend_s { /* flow filter FPGA modules */ struct cat_func_s cat; struct km_func_s km; + struct flm_func_s flm; /* NIC attributes */ unsigned int num_phy_ports; diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index e37bb96331..9af7e3d813 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -50,6 +50,7 @@ sources = files( 'nthw/flow_api/flow_km.c', 'nthw/flow_api/hw_mod/hw_mod_backend.c', 'nthw/flow_api/hw_mod/hw_mod_cat.c', + 'nthw/flow_api/hw_mod/hw_mod_flm.c', 'nthw/flow_api/hw_mod/hw_mod_km.c', 'nthw/flow_filter/flow_nthw_cat.c', 'nthw/flow_filter/flow_nthw_csu.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index f8a2cc74ca..06451166c5 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -296,6 +296,12 @@ struct flow_nic_dev *flow_api_create(uint8_t adapter_no, const struct flow_api_b if (init_resource_elements(ndev, RES_FLM_FLOW_TYPE, ndev->be.cat.nb_flow_types)) goto err_exit; + if (init_resource_elements(ndev, RES_FLM_RCP, ndev->be.flm.nb_categories)) + goto err_exit; + + if (init_resource_elements(ndev, RES_SCRUB_RCP, ndev->be.flm.nb_scrub_profiles)) + goto err_exit; + /* may need IPF, COR */ /* check all defined has been initialized */ diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c index 5d81ffbed2..3e0b83df8c 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c @@ -19,6 +19,7 @@ static const struct { } module[] = { { "CAT", hw_mod_cat_alloc, hw_mod_cat_free, hw_mod_cat_reset, hw_mod_cat_present }, { "KM", hw_mod_km_alloc, hw_mod_km_free, hw_mod_km_reset, hw_mod_km_present }, + { "FLM", hw_mod_flm_alloc, hw_mod_flm_free, hw_mod_flm_reset, hw_mod_flm_present }, }; #define MOD_COUNT (ARRAY_SIZE(module)) 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 new file mode 100644 index 0000000000..8c1f3f2d96 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -0,0 +1,324 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include +#include + +#include "hw_mod_backend.h" + +#define _MOD_ "FLM" +#define _VER_ be->flm.ver + +bool hw_mod_flm_present(struct flow_api_backend_s *be) +{ + return be->iface->get_flm_present(be->be_dev); +} + +int hw_mod_flm_alloc(struct flow_api_backend_s *be) +{ + int nb; + _VER_ = be->iface->get_flm_version(be->be_dev); + NT_LOG(DBG, FILTER, "FLM MODULE VERSION %i.%i", VER_MAJOR(_VER_), VER_MINOR(_VER_)); + + nb = be->iface->get_nb_flm_categories(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(km_categories); + return COUNT_ERROR; + } + be->flm.nb_categories = (uint32_t)nb; + + nb = be->iface->get_nb_flm_size_mb(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_size_mb); + return COUNT_ERROR; + } + be->flm.nb_size_mb = (uint32_t)nb; + + nb = be->iface->get_nb_flm_entry_size(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_entry_size); + return COUNT_ERROR; + } + + be->flm.nb_entry_size = (uint32_t)nb; + + nb = be->iface->get_nb_flm_variant(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_variant); + return COUNT_ERROR; + } + + be->flm.nb_variant = (uint32_t)nb; + + nb = be->iface->get_nb_flm_prios(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_prios); + return COUNT_ERROR; + } + + be->flm.nb_prios = (uint32_t)nb; + + nb = be->iface->get_nb_flm_pst_profiles(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_pst_profiles); + return COUNT_ERROR; + } + + be->flm.nb_pst_profiles = (uint32_t)nb; + + if (_VER_ >= 22) { + nb = be->iface->get_nb_flm_scrub_profiles(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_scrub_profiles); + return COUNT_ERROR; + } + + be->flm.nb_scrub_profiles = (uint32_t)nb; + } + + nb = be->iface->get_nb_rpp_per_ps(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_rpp_clock); + return COUNT_ERROR; + } + + be->flm.nb_rpp_clock_in_ps = (uint32_t)nb; + + nb = be->iface->get_nb_flm_load_aps_max(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(flm_load_aps_max); + return COUNT_ERROR; + } + + be->flm.nb_load_aps_max = (uint32_t)nb; + + switch (_VER_) { + case 25: + if (!callocate_mod((struct common_func_s *)&be->flm, 38, &be->flm.v25.control, 1, + sizeof(struct flm_v25_control_s), &be->flm.v25.status, 1, + sizeof(struct flm_v25_status_s), &be->flm.v25.load_bin, 1, + sizeof(struct flm_v25_load_bin_s), &be->flm.v25.load_pps, 1, + sizeof(struct flm_v25_load_pps_s), &be->flm.v25.load_lps, 1, + sizeof(struct flm_v25_load_lps_s), &be->flm.v25.load_aps, 1, + sizeof(struct flm_v25_load_aps_s), &be->flm.v25.prio, 1, + sizeof(struct flm_v25_prio_s), &be->flm.v25.pst, + be->flm.nb_pst_profiles, sizeof(struct flm_v25_pst_s), + &be->flm.v25.rcp, be->flm.nb_categories, + sizeof(struct flm_v25_rcp_s), + &be->flm.v25.buf_ctrl, 1, sizeof(struct flm_v25_buf_ctrl_s), + &be->flm.v25.lrn_done, 1, sizeof(struct flm_v25_stat_lrn_done_s), + &be->flm.v25.lrn_ignore, 1, + sizeof(struct flm_v25_stat_lrn_ignore_s), + &be->flm.v25.lrn_fail, 1, sizeof(struct flm_v25_stat_lrn_fail_s), + &be->flm.v25.unl_done, 1, sizeof(struct flm_v25_stat_unl_done_s), + &be->flm.v25.unl_ignore, 1, + sizeof(struct flm_v25_stat_unl_ignore_s), + &be->flm.v25.rel_done, 1, sizeof(struct flm_v25_stat_rel_done_s), + &be->flm.v25.rel_ignore, 1, + sizeof(struct flm_v25_stat_rel_ignore_s), + &be->flm.v25.aul_done, 1, sizeof(struct flm_v25_stat_aul_done_s), + &be->flm.v25.aul_ignore, 1, + sizeof(struct flm_v25_stat_aul_ignore_s), + &be->flm.v25.aul_fail, 1, sizeof(struct flm_v25_stat_aul_fail_s), + &be->flm.v25.tul_done, 1, sizeof(struct flm_v25_stat_tul_done_s), + &be->flm.v25.flows, 1, sizeof(struct flm_v25_stat_flows_s), + &be->flm.v25.prb_done, 1, sizeof(struct flm_v25_stat_prb_done_s), + &be->flm.v25.prb_ignore, 1, + sizeof(struct flm_v25_stat_prb_ignore_s), + &be->flm.v25.sta_done, 1, sizeof(struct flm_v25_stat_sta_done_s), + &be->flm.v25.inf_done, 1, sizeof(struct flm_v25_stat_inf_done_s), + &be->flm.v25.inf_skip, 1, sizeof(struct flm_v25_stat_inf_skip_s), + &be->flm.v25.pck_hit, 1, sizeof(struct flm_v25_stat_pck_hit_s), + &be->flm.v25.pck_miss, 1, sizeof(struct flm_v25_stat_pck_miss_s), + &be->flm.v25.pck_unh, 1, sizeof(struct flm_v25_stat_pck_unh_s), + &be->flm.v25.pck_dis, 1, sizeof(struct flm_v25_stat_pck_dis_s), + &be->flm.v25.csh_hit, 1, sizeof(struct flm_v25_stat_csh_hit_s), + &be->flm.v25.csh_miss, 1, sizeof(struct flm_v25_stat_csh_miss_s), + &be->flm.v25.csh_unh, 1, sizeof(struct flm_v25_stat_csh_unh_s), + &be->flm.v25.cuc_start, 1, sizeof(struct flm_v25_stat_cuc_start_s), + &be->flm.v25.cuc_move, 1, sizeof(struct flm_v25_stat_cuc_move_s), + &be->flm.v25.scan, 1, sizeof(struct flm_v25_scan_s), + &be->flm.v25.scrub, be->flm.nb_scrub_profiles, + sizeof(struct flm_v25_scrub_s))) + return -1; + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +void hw_mod_flm_free(struct flow_api_backend_s *be) +{ + if (be->flm.base) { + free(be->flm.base); + be->flm.base = NULL; + } +} + +int hw_mod_flm_reset(struct flow_api_backend_s *be) +{ + /* Zero entire cache area */ + zero_module_cache((struct common_func_s *)(&be->flm)); + + NT_LOG(DBG, FILTER, "INIT FLM"); + hw_mod_flm_control_set(be, HW_FLM_CONTROL_SPLIT_SDRAM_USAGE, 0x10); + + hw_mod_flm_control_flush(be); + hw_mod_flm_scrub_flush(be, 0, ALL_ENTRIES); + hw_mod_flm_scan_flush(be); + hw_mod_flm_rcp_flush(be, 0, ALL_ENTRIES); + + return 0; +} + +int hw_mod_flm_control_flush(struct flow_api_backend_s *be) +{ + return be->iface->flm_control_flush(be->be_dev, &be->flm); +} + +static int hw_mod_flm_control_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_CONTROL_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(be->flm.v25.control, (uint8_t)*value, + sizeof(struct flm_v25_control_s)); + break; + + case HW_FLM_CONTROL_ENABLE: + GET_SET(be->flm.v25.control->enable, value); + break; + + case HW_FLM_CONTROL_INIT: + GET_SET(be->flm.v25.control->init, value); + break; + + case HW_FLM_CONTROL_LDS: + GET_SET(be->flm.v25.control->lds, value); + break; + + case HW_FLM_CONTROL_LFS: + GET_SET(be->flm.v25.control->lfs, value); + break; + + case HW_FLM_CONTROL_LIS: + GET_SET(be->flm.v25.control->lis, value); + break; + + case HW_FLM_CONTROL_UDS: + GET_SET(be->flm.v25.control->uds, value); + break; + + case HW_FLM_CONTROL_UIS: + GET_SET(be->flm.v25.control->uis, value); + break; + + case HW_FLM_CONTROL_RDS: + GET_SET(be->flm.v25.control->rds, value); + break; + + case HW_FLM_CONTROL_RIS: + GET_SET(be->flm.v25.control->ris, value); + break; + + case HW_FLM_CONTROL_PDS: + GET_SET(be->flm.v25.control->pds, value); + break; + + case HW_FLM_CONTROL_PIS: + GET_SET(be->flm.v25.control->pis, value); + break; + + case HW_FLM_CONTROL_CRCWR: + GET_SET(be->flm.v25.control->crcwr, value); + break; + + case HW_FLM_CONTROL_CRCRD: + GET_SET(be->flm.v25.control->crcrd, value); + break; + + case HW_FLM_CONTROL_RBL: + GET_SET(be->flm.v25.control->rbl, value); + break; + + case HW_FLM_CONTROL_EAB: + GET_SET(be->flm.v25.control->eab, value); + break; + + case HW_FLM_CONTROL_SPLIT_SDRAM_USAGE: + GET_SET(be->flm.v25.control->split_sdram_usage, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_control_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value) +{ + return hw_mod_flm_control_mod(be, field, &value, 0); +} + +int hw_mod_flm_scan_flush(struct flow_api_backend_s *be) +{ + return be->iface->flm_scan_flush(be->be_dev, &be->flm); +} + +int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->flm.nb_categories; + + if ((unsigned int)(start_idx + count) > be->flm.nb_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->flm_rcp_flush(be->be_dev, &be->flm, start_idx, count); +} + +int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->flm.nb_scrub_profiles; + + if ((unsigned int)(start_idx + count) > be->flm.nb_scrub_profiles) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + return be->iface->flm_scrub_flush(be->be_dev, &be->flm, start_idx, count); +} -- 2.45.0