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 233B545B04; Thu, 10 Oct 2024 16:18:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3143E40EA5; Thu, 10 Oct 2024 16:15:20 +0200 (CEST) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id A50AD4067D for ; Thu, 10 Oct 2024 16:15:01 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2107.outbound.protection.outlook.com [104.47.30.107]) 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:15:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tY/vomPRFZHYrtwCJhvdmnAaepEnsK3k1r8/rAt9bcFCh7VQ3jVCVjdriDE0qVFLHsDwNTDsklupjE1mDxqE3qUbGEHEK53nP7IyrwiZRvWjTQopXOE9048gCX1K//uAjE6bF4XSGp4FcJXz8a1FvzmSiaOrTvf0csyGSNEcegoCxp1And+FyBl54q7/6xGFVPSxIsFQhCI/V8JmIMufeICejBh2EVLT1GeT4BJy1bhs78jPuXetiTg2VK+O3+9x+WoXoJFAYNBInM5LZWF/NQ8FSCyr03uPaJfdJDXc/IE6YZAWx5IXHOl6xPpcuHpXlejYYku23w0WiGxrPdL5rg== 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=OjclqN0aDtNK8Hwy5N+k6fYh3Z16u/XAaT5r/ZzFqrE=; b=sXD4LvwF31Tb+iIQ4uKh+Z1tOg1jvvu6sCC06naNT1EO2LtP072AqGLe1fSZTNFwa+gp3rnXeNbZVwvwl2TTPRQdfmi7/qe3yaboNLw++1qThFajzVCO6dYFUwbYgaZ0hzIPjkYkeIoGrN3crh0Al6PlvSthevlIh+2l3K2PivcUb0Dp0oWiKUUXiteFUASISu6f/bMRG6ZczDXqzdMGWTu7ihPfWmYX2ASbE6yzjQYBL++ClBpCf6WMd67XCsRM3T+jNan56v4RYRmTmm72sqoDp5P0/vCgT43p1ER34eD2fx3fPt6fZ2aHey7hWam7e/t7meO4kV0iPI7zebNmNA== 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=OjclqN0aDtNK8Hwy5N+k6fYh3Z16u/XAaT5r/ZzFqrE=; b=k8uu9hgPzH6cvlA/ww6ld+zLz1xX6PB5YbvHdpkvETZc4ElifUc0uwHE4FqSXlAKKCo1QGx+L+++Eef/oTJggrxpmWuwSCgB7qdXn9ooQTwhYl/QoePXoiSTFh1vivup9/vfqF7a4aSg2G4bZE/Ev0GbDbSjczdqPcY917xT+qM= Received: from DU2PR04CA0071.eurprd04.prod.outlook.com (2603:10a6:10:232::16) by PA4P190MB1279.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 14:14:58 +0000 Received: from DU6PEPF0000B61B.eurprd02.prod.outlook.com (2603:10a6:10:232:cafe::89) by DU2PR04CA0071.outlook.office365.com (2603:10a6:10:232::16) 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:58 +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:58 +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 35/50] net/ntnic: add Tx Packet Editor (TPE) FPGA module Date: Thu, 10 Oct 2024 16:13:50 +0200 Message-ID: <20241010141416.4063591-36-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_|PA4P190MB1279:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 13c57cea-587e-4dc3-dcfb-08dce935ec19 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?zwNQOu6S925S4PbphnGFPtB7FGc7/vLTLn+3ze+dxSSs5fnYvsF1krk74/dl?= =?us-ascii?Q?vlx0dGBW9lH09O8ZPrzM9MQh04j/RDQVhZIwbqwlrEh6qepYW55oGghJOdJC?= =?us-ascii?Q?hCrM8hcvqczHcvRilFVNDjCc7h0ZaGzKhlyPOA/8Mb7dbPO3wFmdeDAz4/Sb?= =?us-ascii?Q?7SPtabDORcBGk0wgyt8EccUc2xP4oi0W2ipOlmtLVnQq6xi0/xwa3YRqr516?= =?us-ascii?Q?iOruGGkqt2tYG5BurRRzdqgelK8XL/6LMO2A8YhB6TolsMUDr4BEa3ez4Azo?= =?us-ascii?Q?ieIWCnpOro2uFBP8GaKFMorY6nhMkIN5B1fTgWEBHDYtv/SgdIU4BIR/MwZY?= =?us-ascii?Q?7THcPRFMsfv3ueBw75bp9qJDyDVwOCMH6bW6w8jc9G2qGHId6zT3jfhUUuSt?= =?us-ascii?Q?aaL+DO+LwTbUO34Tn4jYdQObKZrNUfN5OvNt7hzpizEsRSzXkgHnYjA3FDXa?= =?us-ascii?Q?o0pWi2oLR6zen0kfCNMANlSIJ2f9EcCMHPX17ZhGNZeujRFcG//Fxs04Rvwy?= =?us-ascii?Q?hWn7U/Z8f7BhvBqPlhL/kgvzJ+L6Hd3vxuKJlnfXX+nLdKM9HgJ8WTZzNB/o?= =?us-ascii?Q?6KYK60FZHdqiTciWg2S2jZdLTMDMeZGfQKzVYMt0k4BD3Nka5T6/Pjpy+jnA?= =?us-ascii?Q?eGFd4nj6/izK/th3iIPABISpTCnw9aBozu5NCQy5C4g8jQlybRt127hvD4Dd?= =?us-ascii?Q?HBjdSoNnFdzTIzk4wI1T9O05UEGZAnJcDHBaqoWP2hJ+ADE/ZvqKZ0TlB2LK?= =?us-ascii?Q?xGUtHGlSK65Sbt7vSk6anFwbFpDoA/GSNfHBlGibwY9Z7iDb8EOomEhHkX6x?= =?us-ascii?Q?Q2wWfCKP/GWaVSeO2DjsSAXy+en074dcHFR1UTr+mVo1qEvA+qf8/sPABIa9?= =?us-ascii?Q?1fFS6o5LemswP+GpElfEucSjya6WDRL9waCa5Q4xiPX3baWHun5/4QETphKK?= =?us-ascii?Q?i80bMP+xMR2h+lcUYPxEvJRrV8eD78OyrYcYbyHu+UPGAjrs1S8umqFSZr35?= =?us-ascii?Q?HcKnfP3afr/xKWJIP2Q8uKy3wOfJYVLqb1+bk3QvjkAWcFcd5QBmdZY/CVRs?= =?us-ascii?Q?VK8mLllMgqylC1Qhxr4wAc6sOe/y6rnEw55L9KTwM7PoJM9++PkTZl+cFNjh?= =?us-ascii?Q?YP29zM3DT5rqJ9zO3ApFgMmHFK/i33Ct2MckPsP+jKbbsZf86Dt3RckwhMGP?= =?us-ascii?Q?fX2mj2224isoan+Pnn0O30UBgWcuXhM2J9Ie5cl4zgZSUb6+sVBJ/wqj38jj?= =?us-ascii?Q?AQi+CBJV5Ldq26CcyTVr7gNxlpxK2AzAmrqNC4+7sFESMdqXgbwDCjju3dNu?= =?us-ascii?Q?KIPvnLjuUz1ZCwNOSsPSTFPFIpu9onZXBRiXBViUpz11feLJt7ET292mqrhw?= =?us-ascii?Q?W8KGi7LQeARKgqu0K1ei0HpBCekN?= 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: 4/vvnJ8ILIdD594zAOTIixqpMgWMBSRLCGyjAEoyuHnyQP7F9P5l+zHcZzhZTt0AVSHnv/clvSyKm7/ddJiybKE815Ar5p9n/+qDkLTbZyKrP/5BiZQJ6qxjVC0NNwZKHtokweyiJcamX5C9b0YQgaWV3jGd4xvypGhm1IIzwk64sYvmyriJ/PUEfN0YZoohjElYMdQvvOZBj3DUyV/OXN0n+5D1U0S2BWTD3LDuMp8dH/DIyXwhm7hnjJ7Gnf5v9W6CIUskc4dgf1ihmm/lYlCNBwXOeNJjhpapfH/jjpJy6G1eHe7V/xmI4tJox0S2XAHfpbav12U5nCUffDOAHcOcBjsZtIgBCNY0NLjDvLsXVpqurX/yd/Evc0xhvkPNAtry8zMstDXYeVPZSektbic9e1JON5dlUk3CN+aC9kTQCPqZkbmpXoPKNXRnKs/j5Uj+x1X0NRyKu/IbidISd2NM1EMpCRkl9Ddd0Lnzam5aYbF+WvYGpHaYSoSJ3hOgzySMDG/qRYEs+d6zjcQLpQwaI/HdzoXrflKCa6uHUGUYEY3K8/sXhbu/vmdw8sVR3sJtXHBjewQGN1cHaSjgjgTQRp2bAH1AP4SbwlSaByAWBtEij5N7z+yUsHwwObm5QcVQ+vcomH4otBtsjScSjj5H1BsyfSIqUvuUS6gotVo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 14:14:58.0768 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13c57cea-587e-4dc3-dcfb-08dce935ec19 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: PA4P190MB1279 X-BESS-ID: 1728569700-305168-12634-25893-1 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.30.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobG5iaGQGYGUDQlJcXAxCjFMD HNKC3JxMwkxcDSJMkkydgsJS3FEIiUamMB6T84XkIAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259630 [from cloudscan17-87.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 TX Packet Editor is a software abstraction module, that keeps track of the handful of FPGA modules that are used to edit packets in the TX pipeline. 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 | 80 +++++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 9 + .../nthw/flow_api/hw_mod/hw_mod_backend.c | 1 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c | 308 ++++++++++++++++++ 5 files changed, 399 insertions(+) create mode 100644 drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index b04ddbf638..34154c65f8 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -657,6 +657,85 @@ struct tpe_func_s { struct hw_mod_tpe_v3_s v3; }; }; +enum hw_tpe_e { + /* functions */ + HW_TPE_PRESET_ALL = 0, + HW_TPE_FIND, + HW_TPE_COMPARE, + /* Control fields */ + HW_TPE_RPP_RCP_EXP = FIELD_START_INDEX, + HW_TPE_IFR_RCP_IPV4_EN, + HW_TPE_IFR_RCP_IPV4_DF_DROP, + HW_TPE_IFR_RCP_IPV6_EN, + HW_TPE_IFR_RCP_IPV6_DROP, + HW_TPE_IFR_RCP_MTU, + HW_TPE_INS_RCP_DYN, + HW_TPE_INS_RCP_OFS, + HW_TPE_INS_RCP_LEN, + HW_TPE_RPL_RCP_DYN, + HW_TPE_RPL_RCP_OFS, + HW_TPE_RPL_RCP_LEN, + HW_TPE_RPL_RCP_RPL_PTR, + HW_TPE_RPL_RCP_EXT_PRIO, + HW_TPE_RPL_RCP_ETH_TYPE_WR, + HW_TPE_RPL_EXT_RPL_PTR, + HW_TPE_RPL_EXT_META_RPL_LEN, /* SW only */ + HW_TPE_RPL_RPL_VALUE, + HW_TPE_CPY_RCP_READER_SELECT, + HW_TPE_CPY_RCP_DYN, + HW_TPE_CPY_RCP_OFS, + HW_TPE_CPY_RCP_LEN, + HW_TPE_HFU_RCP_LEN_A_WR, + HW_TPE_HFU_RCP_LEN_A_OUTER_L4_LEN, + HW_TPE_HFU_RCP_LEN_A_POS_DYN, + HW_TPE_HFU_RCP_LEN_A_POS_OFS, + HW_TPE_HFU_RCP_LEN_A_ADD_DYN, + HW_TPE_HFU_RCP_LEN_A_ADD_OFS, + HW_TPE_HFU_RCP_LEN_A_SUB_DYN, + HW_TPE_HFU_RCP_LEN_B_WR, + HW_TPE_HFU_RCP_LEN_B_POS_DYN, + HW_TPE_HFU_RCP_LEN_B_POS_OFS, + HW_TPE_HFU_RCP_LEN_B_ADD_DYN, + HW_TPE_HFU_RCP_LEN_B_ADD_OFS, + HW_TPE_HFU_RCP_LEN_B_SUB_DYN, + HW_TPE_HFU_RCP_LEN_C_WR, + HW_TPE_HFU_RCP_LEN_C_POS_DYN, + HW_TPE_HFU_RCP_LEN_C_POS_OFS, + HW_TPE_HFU_RCP_LEN_C_ADD_DYN, + HW_TPE_HFU_RCP_LEN_C_ADD_OFS, + HW_TPE_HFU_RCP_LEN_C_SUB_DYN, + HW_TPE_HFU_RCP_TTL_WR, + HW_TPE_HFU_RCP_TTL_POS_DYN, + HW_TPE_HFU_RCP_TTL_POS_OFS, + HW_TPE_CSU_RCP_OUTER_L3_CMD, + HW_TPE_CSU_RCP_OUTER_L4_CMD, + HW_TPE_CSU_RCP_INNER_L3_CMD, + HW_TPE_CSU_RCP_INNER_L4_CMD, +}; +bool hw_mod_tpe_present(struct flow_api_backend_s *be); +int hw_mod_tpe_alloc(struct flow_api_backend_s *be); +void hw_mod_tpe_free(struct flow_api_backend_s *be); +int hw_mod_tpe_reset(struct flow_api_backend_s *be); + +int hw_mod_tpe_rpp_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_rpp_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_ins_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_rpl_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_rpl_ext_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_rpl_rpl_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_cpy_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_hfu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); + +int hw_mod_tpe_csu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); enum debug_mode_e { FLOW_BACKEND_DEBUG_MODE_NONE = 0x0000, @@ -816,6 +895,7 @@ struct flow_api_backend_s { struct qsl_func_s qsl; struct slc_lr_func_s slc_lr; struct pdb_func_s pdb; + struct tpe_func_s tpe; /* NIC attributes */ unsigned int num_phy_ports; diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 0415e5a5b2..e2eff3cf1e 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -56,6 +56,7 @@ sources = files( 'nthw/flow_api/hw_mod/hw_mod_pdb.c', 'nthw/flow_api/hw_mod/hw_mod_qsl.c', 'nthw/flow_api/hw_mod/hw_mod_slc_lr.c', + 'nthw/flow_api/hw_mod/hw_mod_tpe.c', 'nthw/flow_filter/flow_nthw_cat.c', 'nthw/flow_filter/flow_nthw_csu.c', 'nthw/flow_filter/flow_nthw_flm.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 96496b2758..34e84559eb 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -319,6 +319,15 @@ struct flow_nic_dev *flow_api_create(uint8_t adapter_no, const struct flow_api_b if (init_resource_elements(ndev, RES_FLM_RCP, ndev->be.flm.nb_categories)) goto err_exit; + if (init_resource_elements(ndev, RES_TPE_RCP, ndev->be.tpe.nb_rcp_categories)) + goto err_exit; + + if (init_resource_elements(ndev, RES_TPE_EXT, ndev->be.tpe.nb_rpl_ext_categories)) + goto err_exit; + + if (init_resource_elements(ndev, RES_TPE_RPL, ndev->be.tpe.nb_rpl_depth)) + goto err_exit; + if (init_resource_elements(ndev, RES_SCRUB_RCP, ndev->be.flm.nb_scrub_profiles)) goto err_exit; 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 0acc9612cd..a344d1a2f5 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 @@ -27,6 +27,7 @@ static const struct { hw_mod_slc_lr_present }, { "PDB", hw_mod_pdb_alloc, hw_mod_pdb_free, hw_mod_pdb_reset, hw_mod_pdb_present }, + { "TPE", hw_mod_tpe_alloc, hw_mod_tpe_free, hw_mod_tpe_reset, hw_mod_tpe_present }, }; #define MOD_COUNT (ARRAY_SIZE(module)) diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c new file mode 100644 index 0000000000..0d73b795d5 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c @@ -0,0 +1,308 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include + +#include "hw_mod_backend.h" + +#define _MOD_ "TPE" +#define _VER_ be->tpe.ver + +bool hw_mod_tpe_present(struct flow_api_backend_s *be) +{ + return be->iface->get_tpe_present(be->be_dev); +} + +int hw_mod_tpe_alloc(struct flow_api_backend_s *be) +{ + int nb; + _VER_ = be->iface->get_tpe_version(be->be_dev); + NT_LOG(DBG, FILTER, _MOD_ " MODULE VERSION %i.%i", VER_MAJOR(_VER_), VER_MINOR(_VER_)); + + nb = be->iface->get_nb_tpe_categories(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(tpe_categories); + return COUNT_ERROR; + } + + be->tpe.nb_rcp_categories = (uint32_t)nb; + + nb = be->iface->get_nb_tpe_ifr_categories(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(tpe_ifr_categories); + return COUNT_ERROR; + } + + be->tpe.nb_ifr_categories = (uint32_t)nb; + + nb = be->iface->get_nb_tx_cpy_writers(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(tx_cpy_writers); + return COUNT_ERROR; + } + + be->tpe.nb_cpy_writers = (uint32_t)nb; + + nb = be->iface->get_nb_tx_rpl_depth(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(tx_rpl_depth); + return COUNT_ERROR; + } + + be->tpe.nb_rpl_depth = (uint32_t)nb; + + nb = be->iface->get_nb_tx_rpl_ext_categories(be->be_dev); + + if (nb <= 0) { + COUNT_ERROR_LOG(tx_rpl_ext_categories); + return COUNT_ERROR; + } + + be->tpe.nb_rpl_ext_categories = (uint32_t)nb; + + switch (_VER_) { + case 3: + if (!callocate_mod((struct common_func_s *)&be->tpe, 10, &be->tpe.v3.rpp_rcp, + be->tpe.nb_rcp_categories, sizeof(struct tpe_v1_rpp_v0_rcp_s), + &be->tpe.v3.rpp_ifr_rcp, be->tpe.nb_ifr_categories, + sizeof(struct tpe_v2_rpp_v1_ifr_rcp_s), &be->tpe.v3.ifr_rcp, + be->tpe.nb_ifr_categories, sizeof(struct tpe_v2_ifr_v1_rcp_s), + + &be->tpe.v3.ins_rcp, be->tpe.nb_rcp_categories, + sizeof(struct tpe_v1_ins_v1_rcp_s), + + &be->tpe.v3.rpl_rcp, be->tpe.nb_rcp_categories, + sizeof(struct tpe_v3_rpl_v4_rcp_s), &be->tpe.v3.rpl_ext, + be->tpe.nb_rpl_ext_categories, + sizeof(struct tpe_v1_rpl_v2_ext_s), &be->tpe.v3.rpl_rpl, + be->tpe.nb_rpl_depth, sizeof(struct tpe_v1_rpl_v2_rpl_s), + + &be->tpe.v3.cpy_rcp, + be->tpe.nb_cpy_writers * be->tpe.nb_rcp_categories, + sizeof(struct tpe_v1_cpy_v1_rcp_s), + + &be->tpe.v3.hfu_rcp, be->tpe.nb_rcp_categories, + sizeof(struct tpe_v1_hfu_v1_rcp_s), + + &be->tpe.v3.csu_rcp, be->tpe.nb_rcp_categories, + sizeof(struct tpe_v1_csu_v0_rcp_s))) + return -1; + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +void hw_mod_tpe_free(struct flow_api_backend_s *be) +{ + if (be->tpe.base) { + free(be->tpe.base); + be->tpe.base = NULL; + } +} + +int hw_mod_tpe_reset(struct flow_api_backend_s *be) +{ + int err = 0; + + /* Zero entire cache area */ + zero_module_cache((struct common_func_s *)(&be->tpe)); + + NT_LOG(DBG, FILTER, "INIT TPE"); + err |= hw_mod_tpe_rpp_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_ins_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_rpl_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_rpl_ext_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_rpl_rpl_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_cpy_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_hfu_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_csu_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_rpp_ifr_rcp_flush(be, 0, ALL_ENTRIES); + err |= hw_mod_tpe_ifr_rcp_flush(be, 0, ALL_ENTRIES); + + return err; +} + +/* + * RPP_IFR_RCP + */ + +int hw_mod_tpe_rpp_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_ifr_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_ifr_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_rpp_ifr_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * RPP_RCP + */ + +int hw_mod_tpe_rpp_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rcp_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_rpp_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * IFR_RCP + */ + +int hw_mod_tpe_ifr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_ifr_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_ifr_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_ifr_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * INS_RCP + */ + +int hw_mod_tpe_ins_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rcp_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_ins_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * RPL_RCP + */ + +int hw_mod_tpe_rpl_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rcp_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_rpl_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * RPL_EXT + */ + +int hw_mod_tpe_rpl_ext_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rpl_ext_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rpl_ext_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_rpl_ext_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * RPL_RPL + */ + +int hw_mod_tpe_rpl_rpl_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rpl_depth; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rpl_depth) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_rpl_rpl_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * CPY_RCP + */ + +int hw_mod_tpe_cpy_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + const uint32_t cpy_size = be->tpe.nb_cpy_writers * be->tpe.nb_rcp_categories; + + if (count == ALL_ENTRIES) + count = cpy_size; + + if ((unsigned int)(start_idx + count) > cpy_size) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_cpy_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * HFU_RCP + */ + +int hw_mod_tpe_hfu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rcp_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_hfu_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} + +/* + * CSU_RCP + */ + +int hw_mod_tpe_csu_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count) +{ + if (count == ALL_ENTRIES) + count = be->tpe.nb_rcp_categories; + + if ((unsigned int)(start_idx + count) > be->tpe.nb_rcp_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + return be->iface->tpe_csu_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} -- 2.45.0