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 EE9CB45AAF; Fri, 4 Oct 2024 17:14:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4653942E71; Fri, 4 Oct 2024 17:09:04 +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 2926342DCA for ; Fri, 4 Oct 2024 17:08:37 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2177.outbound.protection.outlook.com [104.47.51.177]) by mx-outbound8-201.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 04 Oct 2024 15:08:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g5GuerCIykJlc1ZVjDjniyi7snf+w7IhKrITadaRyfkFNCSeK6RnN2CTLnAc7BYq5RAtpUkgdm9x95tVoEb4+hO1F6gkXugYdPe8pMzuntFqwpN+pKb5t+3wfaO8doitPhos/6AuAT7ultu8R2uA+VxzCjPkLvoBR72kBlWGHyMqBbFyibrvz8ZUKirqBvSiLYBsaLq3TSfoWATuUG1LUtCGFzKaWouOMXjvlpjWBfF6Pn62L8BLbdkwccSMVxuXVieuoIqJRugM6cugxoPMIbweU9gTH5XVMaJ0LBhvRavB4EPIcGPRLeR+ZT5P8QNwZXB4GMhyoPhLJXqW/fGyyQ== 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=9BfyTFh5vxHFO7lBWXD/Jh0Xl1ubneUH5YV7A7jcPpU=; b=m/i2WubOsodYsURinoSa84JxgydUvhWnF4hfUwlEvMcUdkrYZM/QucCPVZNVf9q6a3Zq+tmo9jITlSBOCL5byBVikw1N8bww35/zE20esDUd6wt3qlCEmLzbe+MSiCht/TsUUjUaCRZqztkJcZGXig9xqoMIsdbCxOVD0Oi1OG9DqZ5fq8Rp7MRsZnbp4QsDr9bFGovGWf0AbYsxmr5f5oGxINknj0w2u3bAVIBs5Y7rZlaGlQfCEtayK78zdmog1u12GAgld1MZfTRak6Nmcbob2Ox0RZv9/a3ttnx5pD5izLfU0VfTwGb9JMl1WXjY2q496mpsjpmaEQyvDwWJxQ== 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=9BfyTFh5vxHFO7lBWXD/Jh0Xl1ubneUH5YV7A7jcPpU=; b=ZTeugzlNHP1S0TkKHfPX9lZZJp3YTEKxh1QPSlvS81yH5jqRffIaWfyMUBueQ6Vl+bSBxOe1w1niPGIApN/cqpEbMNWLQVkwHJJ7HRSfRNetKSKDVUqMjvsA0ZvC6Qr/OUACnxOhc9MIJlD4hoJOJwjGe9usP49kr9+DzRAzy7w= Received: from AM0PR02CA0012.eurprd02.prod.outlook.com (2603:10a6:208:3e::25) by DBAP190MB0998.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1a6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22; Fri, 4 Oct 2024 15:08:30 +0000 Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com (2603:10a6:208:3e:cafe::40) by AM0PR02CA0012.outlook.office365.com (2603:10a6:208:3e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Fri, 4 Oct 2024 15:08:30 +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 AMS0EPF000001AC.mail.protection.outlook.com (10.167.16.152) with Microsoft SMTP Server id 15.20.7918.13 via Frontend Transport; Fri, 4 Oct 2024 15:08:30 +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 v1 30/31] net/ntnic: add Tx Packet Editor (TPE) FPGA module Date: Fri, 4 Oct 2024 17:07:23 +0200 Message-ID: <20241004150749.261020-37-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241004150749.261020-1-sil-plv@napatech.com> References: <20241004150749.261020-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001AC:EE_|DBAP190MB0998:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 993cc94b-813e-4633-96e8-08dce4866835 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2ldDDYbumWfksQi4/bLiYW3Qrt0Azf/zxguYaXlHjbnsDyLSchYuU2IH3ruL?= =?us-ascii?Q?w5H5+f4OTzuCDZ/hjSosnffqd3O1mE6ab5ezKw7/xTJuHb6poJG0rKH1a9oy?= =?us-ascii?Q?2qcmcrwnCrpyBLdk3ostxAXM80yBt9RzB5DsC2lt/bMModk4KmYMlr6TWrMt?= =?us-ascii?Q?ByFTMskGKYoJxEfItP2pMj9VmrKWiMNblMs2v1zT4/380vxLWDAyxe3D1PVX?= =?us-ascii?Q?pJd88cMcIenpvgImthwhZfF7gH4T0IjactuksMRARlvwSsr2xhd+84nU0fFk?= =?us-ascii?Q?4MP9kWuABZCd5KASF1+3e7/ZOUjB707a+yfCgxWSDebGIHvUqDzDnWLto0Lr?= =?us-ascii?Q?YPdOePatDMgGfyiyaaw8vGwMN++xEt1GhX0fwVn4WZhZ86stdtHhMVavF50e?= =?us-ascii?Q?xregR+iaUrlQRB1dQ3/IyLJU5eCjZGsZiPmpzfwfnulQkPRvbvqcQeOd3Zih?= =?us-ascii?Q?7TCkoIPBDbm02EsUTktnrOPwE79blL16fB4JskIZZHFUPwnaLUN5GZ8C5QMT?= =?us-ascii?Q?ya6rhwoXYVnr/uqBZLZcnRP7bBsdSZxQK1xJ5Jsq5Z2Pyi6GXzfyGFmVX/L7?= =?us-ascii?Q?xSMjmn/1Gk2JshLDxBVgp4e3EbGYZ2OwJ4x5dYlLOVzqOMkIzX3grPlKX6s+?= =?us-ascii?Q?a+6FBd0HMYPrQncH7PgNbejFm9ZIDu9by9JSpj63Z0rkF0uQfWmSkzUKU3GJ?= =?us-ascii?Q?7UjqaQiLjyrfhPcXiIc5eGVJNfrn8b8xbSau3mWFeH4qX4K5zwlvVSUSjQ6F?= =?us-ascii?Q?y6MIQL6ySZyJY/wpsKt0C3lkN/V/8IL2mMbAULFv8TpKoPRa8r4R9w30brpt?= =?us-ascii?Q?MpCHIQtkKZ9BJKXDXTGcXMmB7gyq9W3pWUAemNdNJH7VXA2hGLdS/tK18hQ7?= =?us-ascii?Q?Q+fTG+iI+eY2g6f5YOmQE2Q6V3e1Cx0OReMrJ5YS9+ZTUi3UteWlfuGehzus?= =?us-ascii?Q?Zi9lZ1nPhbMcW6Zqnuk1/OsL4YV//RDic61EaNzFdWvxNKXXH/cnco6MLS1Q?= =?us-ascii?Q?ydFTcwMz11xp+kvGC6kX7TC8EKfYdWI5ECK9JxElQ9vOXxdk0b/PZA5ME9TL?= =?us-ascii?Q?DiJhxKls29faoCEB9hdKuZapPDr2040+gdHrqb6/y+s3RBxSWZM5XRMIstcM?= =?us-ascii?Q?laDlLtquanhTVFmPPy+Klg7U3uHJ2FQSiAT0I12lVRZ38BapqttiaUYUOxq1?= =?us-ascii?Q?vOWcAsJbA5Ru0AdrAUcXpz3vJrOkQAoPN8OJXeYOHPXuSGtTTBAj/UQgvB6v?= =?us-ascii?Q?unQKdP5qb0oir7b4SpbGgqsKXXiDAgfR7C39Mvji3TdGq559P26PvG+fsSJ1?= =?us-ascii?Q?5iHgaGWijuJ1bM8k228GN8+LdzLc4FVXpsrZ4DAq4yF4ZKOQdpyMQpi7E0Xo?= =?us-ascii?Q?h6Ys5BIk3gYxiDxhz6rKbJAuifoq?= 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)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UcIOErAAoGDrRPl84TVyA3nWsLmacohUUlw+yenLj84oj6UDepKcxYK1UAC4nTkQw3cPoIAxPdsjMffPqLox8i4qARAM7vQ2X3JIRYmGZYQSnyb7YVnWnkkJqyi5SXXU51h6mWK7iqJTRY5/FCXyeBDryBXKcZ1uOfDRZQLc2t6SksybpJVDfuDQIXLOSL8/f/4p+Vj8AmTcij6BVYEBWbZKyrdAXdzJcBspNoc/zeJ1/VoEVfA5oMqaWXcNLBEFql6MOmqtut+faUtXwLLmxgIFMEKigE466PM2hnNL/PNRFsEczMPFmD5KhhkZjfAHnDJc6a7Hn3X7RLrZPZS7bxSyElhCYUlhbIUYhbLP+BCQvU+gKevxRxcxcyY+Ez5jZvVm9nsCkzYJwpy1iTGqPyigsSs1bb7LVopRHLF6tF7ySGuEW1V5+NtdSMvigdNZvpcktwZK/cZv3D4Jj+HmjLma/736HsoOc4k+nr33fIRAZcr6lWPN1IQbgiJ8lfEZV60LUnRlq7DCyrjQUkqR2gSw66hcgNF6lR+IfUJNF6dvHdNqM8IkGeNizytqIiTzW6BZaWXjoveAXAFyAQHTXo1G1hA1vQ4M4IGyUzh24ASH457+oB7HllhLEM7SyoHlVUoEEWF35TbvkXYZ68AvIg== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 15:08:30.3142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 993cc94b-813e-4633-96e8-08dce4866835 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB0998 X-BESS-ID: 1728054512-302249-12646-31683-2 X-BESS-VER: 2019.1_20240924.1654 X-BESS-Apparent-Source-IP: 104.47.51.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGhpamQGYGUNTEyNQ41dDczM QwMTnFxNDEPC3FxCzZIDXJIsksydjMUqk2FgBHgfz0QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259494 [from cloudscan20-7.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 --- 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 | 277 ++++++++++++++++++ 5 files changed, 368 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 9644639131..cfd5150e59 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -654,6 +654,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, @@ -813,6 +892,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 03946fb52f..9d47aed061 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 118e49f539..13e98ea9ba 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..180deefd72 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_tpe.c @@ -0,0 +1,277 @@ +/* + * 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\n", VER_MAJOR(_VER_), VER_MINOR(_VER_)); + + nb = be->iface->get_nb_tpe_categories(be->be_dev); + + if (nb <= 0) + return COUNT_ERROR(tpe_categories); + + be->tpe.nb_rcp_categories = (uint32_t)nb; + + nb = be->iface->get_nb_tpe_ifr_categories(be->be_dev); + + if (nb <= 0) + return COUNT_ERROR(tpe_ifr_categories); + + be->tpe.nb_ifr_categories = (uint32_t)nb; + + nb = be->iface->get_nb_tx_cpy_writers(be->be_dev); + + if (nb <= 0) + return COUNT_ERROR(tx_cpy_writers); + + be->tpe.nb_cpy_writers = (uint32_t)nb; + + nb = be->iface->get_nb_tx_rpl_depth(be->be_dev); + + if (nb <= 0) + return COUNT_ERROR(tx_rpl_depth); + + be->tpe.nb_rpl_depth = (uint32_t)nb; + + nb = be->iface->get_nb_tx_rpl_ext_categories(be->be_dev); + + if (nb <= 0) + return COUNT_ERROR(tx_rpl_ext_categories); + + 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: + 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\n"); + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + 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) + return INDEX_TOO_LARGE; + + return be->iface->tpe_csu_rcp_flush(be->be_dev, &be->tpe, start_idx, count); +} -- 2.45.0