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 D9EAA45AD8; Mon, 7 Oct 2024 21:39:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0339341149; Mon, 7 Oct 2024 21:35:57 +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 A045240E16 for ; Mon, 7 Oct 2024 21:35:34 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound9-155.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 07 Oct 2024 19:35:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C/J9K34j8nTzcc2JjE/orP5MI4WCsBVcy4R1mXr2ti1smIQzxn6pMCBKUmW8XDtDOsBKFhZUhSK7mM7Vo/Erq1gA7IDhbeMOAIAWUYaPWN6WV23mYySMtP0K69FwzrIUBaCBY/qTJDmsR39ONQ2Ao+fs/rP68vUEiAAHPSQZ9nocK96qSt2asQFz/sTjLTfJxp1F1Iils8hK0cKTUJJuMjW+a9LElldF+fCVG2gISkmPq240oDspCB1toZX/WZXcfxGtnCnj+xoZSAAvNUpNtvxOiUldXG01dhq5WLS1gP3Tfyjvv49cZ02z35cHnS8oDmEgtLFHnanZdez3UA/O5Q== 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=gG4S9P0v+Wn4fPrLWhrTE51oeiQPiTJ57gaHuUdq1yo6f+AA2tmki0qY+X17iCBqMrz3kIObXIwj87OcUTsBfjpJ4o5GfUbUwKnXlBi8g3kdptHYFAqMbCi5SMjrSKeeuJPMGLD7Oq26/8FyExhhiCbWzEpO9BMuaFpGgwgHkw0bLE18hLiGm6+OTPVgQmbvwCTCBWB1mSwsjwyilGwqNxPqa8+ZF9K1UEtmjo6BuD2UMierPGBXzR1e52aExlP3f6wF46jQ77fn3eyQ0qCsFTpT6eB4TauHGSShAXjAxuu4m8IXJBFGBstBAHOn26YHU+08GS8uzJdmBkvWSld6kw== 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=NV7fLfF7S0IvXutuSdApw8ivwwNl5SsqEJFu6e1uc1t9sZUYXP5aV9xTGdGvBODaB6kAZDAIu8hbUes4bfrNkqYq6cmHCsk+Fj6cI9p/oqSSkLgp/yiFUJNo+fSZV2TFYF9I9m9cmFXNgpu9+/pa44a9gwqRTCJcdnYx1Ocopv4= Received: from DB9PR05CA0005.eurprd05.prod.outlook.com (2603:10a6:10:1da::10) by AM9P190MB1170.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:26a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Mon, 7 Oct 2024 19:35:31 +0000 Received: from DB1PEPF000509EC.eurprd03.prod.outlook.com (2603:10a6:10:1da:cafe::cb) by DB9PR05CA0005.outlook.office365.com (2603:10a6:10:1da::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.34 via Frontend Transport; Mon, 7 Oct 2024 19:35:31 +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 DB1PEPF000509EC.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server id 15.20.8048.13 via Frontend Transport; Mon, 7 Oct 2024 19:35:31 +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 v2 35/50] net/ntnic: add Tx Packet Editor (TPE) FPGA module Date: Mon, 7 Oct 2024 21:34:11 +0200 Message-ID: <20241007193436.675785-36-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241007193436.675785-1-sil-plv@napatech.com> References: <20241006203728.330792-2-sil-plv@napatech.com> <20241007193436.675785-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509EC:EE_|AM9P190MB1170:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 7c438197-3d78-4531-d52e-08dce70734a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?T8jRs/JzSE/sqSPQ6uCaIx8uBEYqt6Q5VYg1JFEnDuZ2131NHMFHJT1XUAC3?= =?us-ascii?Q?jrIsW0ccu9WhjD9fzuiD0aEKtNV/2Psx0OFmRcWicZ8DrsuvjHR7mM17MBk4?= =?us-ascii?Q?BT0EsaBS6m2I/F9MxJpnmwWrAMcSOYvdrV7R+z0TfFvzhWQoPmPda2HITgEG?= =?us-ascii?Q?dDseEAcdzYSUYyr8KR7/dHP8Dmq4kbKb/Sk3RE+roX06ZEjeO0n4R3K097Bh?= =?us-ascii?Q?AfTC9EXHGSm5W+h3ye3vTQ3gjRJNJGvKySxutyNxu8a2w3d8m3LmAe0xHYyX?= =?us-ascii?Q?D4lSKKqd/P22QuJkYXaE12KGZ9rC2mlPGlUfvRaWDJSyoUFxNVmG9tYRK2lQ?= =?us-ascii?Q?H11lpcPQ38mCbOCwm6Z0PR3pSTiV0MGOhdjy7j4XD7LfCVtS0rg/onQhKO7j?= =?us-ascii?Q?amsxgOa50sdea8bpE6jkfuXCd9AS0e0nobCmkiCdXSuXfFAdN+KinlOHde56?= =?us-ascii?Q?sa3+UsH6fTBNvlp1of78Dl6iFj7QI0WdvX7IywDA4Bw+Et4hQexhf6I7ovim?= =?us-ascii?Q?l++JIyldbXJ/8JPyOoxI2gFWMNmWAMP865ddoo6VXCMfxzkpWnU9cRJurRJU?= =?us-ascii?Q?QxJ1B9navh2KH44HBFUu9wzq+Jdu3RPGXIXVw2YQYN929eUJ+TIMR34VPA/q?= =?us-ascii?Q?+QIsspTJbax/s486t+pnh5uISpsMNFAw6iOpEpeMxdPqDgAX2h3PzuikHZXS?= =?us-ascii?Q?hJmZ9sAHdkalWZKSDzNZKt2gdot7kJTehEOCxC/OaJTCY7b/L2k4PFPr+wm/?= =?us-ascii?Q?kQkZYXHxD6vke3ILFVu2B6l0Q9tn5r/IvFqje5/iIZO4pBiNXSLnNCL10U/a?= =?us-ascii?Q?2Yih++WohuHdRHyzs0nPPYAcHa9judWupYlkI5IGM2qqGLdR95dk0Y5VPej9?= =?us-ascii?Q?/ET0YuQPfgEtHfZF52YEuq2twVS0aNCw/zu9tT3u11dMXHS+pg1M4VGnbw3S?= =?us-ascii?Q?Ty1tQFzR36ebXupraICJzcjNm804YmyWnt6WZbOPUr8Eo3Sfg7Rj2P06cWia?= =?us-ascii?Q?B5YHg3GOTKQdy65cb6HPkIYl/hINqB/b7OrPt6lSZjXgxpyzmp4bgWCSWcQ3?= =?us-ascii?Q?Nwgr0CDD9e/Nxen0j7QU1KYPlkqM1tNuUwbLGL8zIpUOpHSViU+CFdfCJB7h?= =?us-ascii?Q?nDccWQm9aELKuYd7RrVoFEoWSr0O7E3To71CYNS4jF8t8J0cC80RIRciFZff?= =?us-ascii?Q?UZ9rhFQE9P3gaokUhmjB0DspxVfLumNnrkfYbBkFHLMBsFZrnGoJ3yAGQURH?= =?us-ascii?Q?UPRA7Wer+t5ewd7hv7C6AD07OnqP/ZPE0/swOhY9p182GIJOu+54ZrkQA42/?= =?us-ascii?Q?qIqO8vZ3nyQ1Od87g1K6ARJDVAPX1IgFp3YDTbO33PLJ4nE6vPfLFauSJlkz?= =?us-ascii?Q?qeLlom4ml4ajgE46Z3gFr2lI6bhf?= 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)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: P9e8lyS9hFOpnMprlMLR1NWk8X+cDxVeiRs1Ao+4DS6Kw27fR215LGlfxDmtriMxUyrbIOb3Dqtw9SKvYy1D2VDmq5nVUay/zrkWSRF9fP0LRs4MV8sqkVAhpJOvXDMg0ekZwrLWErsOJhJikE9//W69dKALziu547pEWU8gCq3aH6ZPSphq7I0vvy7lKVLx1mx2q9c0P8w+lRx0Rx+3dRI67nNhDf4j7FuN9ca1Pc7IQq9AO2AtnM20t4tIKFndbrS8SFJJZD0hfExKGNKaaElngvKrkDewACtdRzhbLA3qQmLK/JoG6QFM69Uuqd6gFzQen+OLzzNiETyGj5upvN9oZWem5l6VSsiNFE2CZfeSbBk1k3BCW/ndHkmydQVexWCwuwjyqkle8tOw16j+LyuCu84XNFt0NUdwHWQP5+T+XzoVzF1IV6yN3RJe7+SCrGK5XzevQPYa2lQloGtb6jbTepnPBLGwonw926y9coFT6L4JQuObFLQRxUeLRBEleeoLfr3NS4QDpnlZR1zoHYM/SOw/+I0OEJ/ygMNjGsjuM85idbq0Eh+o//96vMni6tNwbrfrD8WL1shWHlg1OVZ8BpONB3KRcoypyHh11dyhF+CG0fL4HrIj3QvjsFCMeakp//vz59TwnSXbGWPAnQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2024 19:35:31.0688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c438197-3d78-4531-d52e-08dce70734a7 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: DB1PEPF000509EC.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1170 X-BESS-ID: 1728329733-302459-3371-3620-1 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.17.104 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.259566 [from cloudscan22-232.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