From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 984AA45AAF;
	Fri,  4 Oct 2024 17:13:07 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3B0E542E59;
	Fri,  4 Oct 2024 17:08:54 +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 DF72E42D7D
 for <dev@dpdk.org>; Fri,  4 Oct 2024 17:08:31 +0200 (CEST)
Received: from EUR05-AM6-obe.outbound.protection.outlook.com
 (mail-am6eur05lp2113.outbound.protection.outlook.com [104.47.18.113]) by
 mx-outbound22-159.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2
 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Fri, 04 Oct 2024 15:08:30 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=xhuewBTrHLivVYiEtOkTFoqq9R+KkpSsX8MOrJqzcAtkiKFtw8SfqBYnt90GsLk/Rl9pXJG/sPdy80anpuLDsjdDFAC7gwaoOaVVnqqK67ydl1qyoodm3EMsdU3v2la0dMhi1Lj+oSgwdhYPQKHVY79C4SQjXKYPjIA5gUgZGWbJGYI7/KcHjZ/5qeunR8bH17c6DT493K5oXy6MBU9X46EU0tX/X0nmkqHsTqcLF7AEa12z2Ys+P2slcymeZl73noShVw10+sJYwjLKbopl760H/y3/8guaqiLUvaut5O1l91DFFuVL8X3wF1BKOcF0rtJVNbjtRoIpg2kicBRwOQ==
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=xnYnin0spfMO0W/uJkkIxC38N7+rFzKTHek0Q8ZEjQU=;
 b=i0BTmRSoeTcBQs+CqUrSKs3Jw58Pjh4mlbB4phmi1EYcIp1qfR3IaIUMDLtmqXXziElHYpJheMnSbS+AkaaRssM9Ri7VjimKf7357IHuXKzTV7W5r5/0zeBvzRryjrO+9H14tutsvW6QBefr9mnCIWO26rFKlIfDbq1Ugen1JTTMQQnUSwEBPEjM/QhmNf600NxBUgZqx0IFhj//qpBJJlYyKbU0sGoy2P+ysQlMESJbzoGRPRfPwY8HxTxIsNGs5aXS82vUS2u7zPbPrzylOGRPxO0djE3BWI9unZNBB6ZbA8Dnu8a6mNu5gd15A+JW0pQHDzoCbpIYK5J+FfObJQ==
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=xnYnin0spfMO0W/uJkkIxC38N7+rFzKTHek0Q8ZEjQU=;
 b=oTX0r96AN/bfBoNxxj41+aHCn734TZWzOfBStc080FquHS4mhKu8AJC4aiJG14H5EdQoIzMRqfo+QhwTv627uhfYFdA2VEbk2YaDpKNheAVcNEX19afhHiFSXJb0IDrsA/x78OCNSjtpp3Lt7BICud2qsSkTUQkYl9+d9uj+3+0=
Received: from AM0PR02CA0023.eurprd02.prod.outlook.com (2603:10a6:208:3e::36)
 by DB9P190MB1698.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:331::16) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Fri, 4 Oct
 2024 15:08:29 +0000
Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com
 (2603:10a6:208:3e:cafe::93) by AM0PR02CA0023.outlook.office365.com
 (2603:10a6:208:3e::36) 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:29 +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:28
 +0000
From: Serhii Iliushyk <sil-plv@napatech.com>
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 <okl-plv@napatech.com>
Subject: [PATCH v1 28/31] net/ntnic: add slicer (SLC LR) FPGA module
Date: Fri,  4 Oct 2024 17:07:21 +0200
Message-ID: <20241004150749.261020-35-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_|DB9P190MB1698:EE_
Content-Type: text/plain
X-MS-Office365-Filtering-Correlation-Id: 326b6f5d-1e41-478f-29f4-08dce4866766
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
 ARA:13230040|1800799024|376014|36860700013|82310400026; 
X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?C/tFBKzI3An6X+u0Fu8UmmOoQjyuZwOL/NNQVsPBeCoA4MQoyTSuaTaYksjr?=
 =?us-ascii?Q?4BHY1USxoWXOOKuY7U0oFJPM+uG6ZvNvAVC0LVXxLf9l96+8JoXWS4Ry2sD+?=
 =?us-ascii?Q?O4chDsgoFgrLVJV8SMA5mkpcAULNoLY9tdQJeQl/kjKkwhgBR9ss00hbr0dJ?=
 =?us-ascii?Q?3ZmbzibtOKwdfYoa+XBQVpO+YOqvpwQTUR098LOifTeczZ+gV6Sozo0xQkWM?=
 =?us-ascii?Q?EQQjvckEbOCWGGrwPkh6DWqw1GF29BhsJa82wvysLJ9GaRwMh4CZPfLYGdR4?=
 =?us-ascii?Q?lewvzM9hr3mFzKI7vd/wZrvkwi7i6kBulxAf9Z7R6H+2a4SBAMavD94OL0AL?=
 =?us-ascii?Q?x2HMx2TISX3lRdkVwnrb7IZ7b0q9IzVmWu+f5V5OuaVzMW/U33y2+FhuZ+33?=
 =?us-ascii?Q?D1sm/+Pluwv+/DdkXFdL8AIzpikstjObgYQcB1VinJCsdXNInhyGXGC+Ywz9?=
 =?us-ascii?Q?J3CR4zWvufY7Gng+HbL4OgdrcpjePgo6WychyVnWNA8P5zVnkwoAgrvvTZ9m?=
 =?us-ascii?Q?XNGKMK4it0r7nHzsR1S6k4+U5l1GdH+j3+9hZKmHs0slTdjdG66ltib1nDhe?=
 =?us-ascii?Q?nqp4UZE+ARk+v9rw8wUfW33u7fwjLxYG21f1OV4MmMTtwmUuv8MItylE4rB4?=
 =?us-ascii?Q?biRNoSqzSIx477axsnGwwRKKbEEN+yfcqO0ilFtwrpT/Myod+guuh3/KKjKU?=
 =?us-ascii?Q?obDcDtHhFsIX1WagQgYG7FfbOtJAhSLxDoNwjz8lHmmGfp2gUnjCh2gyaZaB?=
 =?us-ascii?Q?SuUmpJolymssU6IwmD1l6xNmJ0N6OLIhMyd7UL9xtmHXBBTTCoqkRvcoUVH9?=
 =?us-ascii?Q?T/CfshHNuDesEQRZsJONZKFP0QcF0nyKMd3W9X8hRBGcyoatKNBzlFitUlWN?=
 =?us-ascii?Q?EZ5sw+uxu7CWm943Jjex4t8XNt9iF4wxuBH8SXcb03ioLMTq3dPjIPSSG1ks?=
 =?us-ascii?Q?pLjObnnWpzEcJ0GoIIMOoOtJtLt79HkvFArWyk9zk5jY67b5ztGYjUlXa/u6?=
 =?us-ascii?Q?y8aAglg40/h/7EjBCCKIDnhQkgRcxxU+RPXAKhZ1BaZK7lGT3C15tE22Ff/a?=
 =?us-ascii?Q?xpPjdT7kP+F7M/Vf69Yxh40OHr+e8IGaamJcrHDyaXHcu0+dimsF3mjATiVp?=
 =?us-ascii?Q?nqhxoUec6DOUgwCg6HUChZ1dIqfldaLMYLYPHaXje669g3aNsBmi3llSmbE/?=
 =?us-ascii?Q?3uGkafNT5pv96G7UD9+NVfZsvLUiQHW6Yk/MVxNsjBUGmjiTzP8hReVFHgw5?=
 =?us-ascii?Q?5dtTLmkgTS/9Xbt87QRTQorcrvzAUtMA2Kii6DpFH1Xu5sR/xUUS98ZHAQct?=
 =?us-ascii?Q?XdNKct4gPGAf9XUPFJgzRflbo61cnlmwrto5riixn1AJIhMJxdk0hxAnoo3F?=
 =?us-ascii?Q?omZcluZL/8R2aUAQae2xNiXtozv3?=
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)(376014)(36860700013)(82310400026);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: l/IZSSeSKtRnmmz6t5DbFA5IqOvVmswDaOOZ8RtueH4UzhoHnPMDOM8lVezyqIQojSoZTvzR2Ec+e9BPjZ2zYPYxvwcGCUFx3zy9IkFQWdx9Oz/mVsMJnSIP3/UDapPKvBs82JYEVRltbIYiu72Zsb/ofKyHWeiq1SS546Llb1zdx8rCfai887qL+DpNSoqIFJdtNveKKjuyhE43RHyv5XkscQnfVV9/A8vdHEzZfrEHZnMnJwz13abTZRM9Y1kXx4VfZUMMkQDHDKdBaq+CefvALIcV/nraNkMyin/qdBZ6TeBr+xXAeVPHHQcKx3kljhurvu1oXSh3WeTQd6KaIJjJve9h9iXqeaDFM87Qd8CkiFIE6czaE/1hqbsc+QClVJMKtovff98R0CJTbx1AmsdUVCKg8YrMM4t4kEiTK9Uh42oVY7DZH9mN9uUhSWUIM00PJp0YQ1YmvYJ8pWbVHCzGFhZBjswaDKiBYEXWN8LUHAiNxsU02+T+Cgo5Fkk7BKIpIGUaBHWV386w7cO/+NCXV67BP/KV3ywqd6hXjax8QIDT4ctiuzX6OP8MYIzYV5fiYxsTStM+ciasss/+fsUUxv77t1yT80k0w3kbCZwkVETUAm8YkeU4i1sPsdbJ8Q13DaduZy1/nm3Zk+kGxA==
X-OriginatorOrg: napatech.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 15:08:28.9548 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 326b6f5d-1e41-478f-29f4-08dce4866766
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: DB9P190MB1698
X-BESS-ID: 1728054510-305791-12643-33573-1
X-BESS-VER: 2019.1_20240924.1654
X-BESS-Apparent-Source-IP: 104.47.18.113
X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYGluZAVgZQ0DQ1Lc3Q1Mjc0D
 wRKGiclGhikJSclGZhYGppYGRknqxUGwsAMR6F40EAAAA=
X-BESS-Outbound-Spam-Score: 0.00
X-BESS-Outbound-Spam-Report: Code version 3.2,
 rules version 3.2.2.259494 [from 
 cloudscan18-37.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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Oleksandr Kolomeiets <okl-plv@napatech.com>

The Slicer for Local Retransmit module can cut of the head a packet
before the packet leaves the FPGA RX pipeline.
This is used when the TX pipeline is configured
to add a new head in the packet.

Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
 drivers/net/ntnic/include/hw_mod_backend.h    | 21 ++++++
 drivers/net/ntnic/meson.build                 |  1 +
 .../nthw/flow_api/hw_mod/hw_mod_backend.c     |  4 ++
 .../nthw/flow_api/hw_mod/hw_mod_slc_lr.c      | 65 +++++++++++++++++++
 4 files changed, 91 insertions(+)
 create mode 100644 drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c

diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h
index 13e0d1731e..b28192e682 100644
--- a/drivers/net/ntnic/include/hw_mod_backend.h
+++ b/drivers/net/ntnic/include/hw_mod_backend.h
@@ -7,6 +7,7 @@
 #define _HW_MOD_BACKEND_H_
 
 #include <stdbool.h>
+#include <string.h>
 
 #include "ntlog.h"
 
@@ -580,6 +581,25 @@ struct slc_lr_func_s {
 		struct hw_mod_slc_lr_v2_s v2;
 	};
 };
+enum hw_slc_lr_e {
+	/* functions */
+	HW_SLC_LR_RCP_PRESET_ALL = 0,
+	HW_SLC_LR_RCP_COMPARE,
+	HW_SLC_LR_RCP_FIND,
+	/* fields */
+	HW_SLC_LR_RCP_HEAD_SLC_EN = FIELD_START_INDEX,
+	HW_SLC_LR_RCP_HEAD_DYN,
+	HW_SLC_LR_RCP_HEAD_OFS,
+	HW_SLC_LR_RCP_TAIL_SLC_EN,
+	HW_SLC_LR_RCP_TAIL_DYN,
+	HW_SLC_LR_RCP_TAIL_OFS,
+	HW_SLC_LR_RCP_PCAP
+};
+bool hw_mod_slc_lr_present(struct flow_api_backend_s *be);
+int hw_mod_slc_lr_alloc(struct flow_api_backend_s *be);
+void hw_mod_slc_lr_free(struct flow_api_backend_s *be);
+int hw_mod_slc_lr_reset(struct flow_api_backend_s *be);
+int hw_mod_slc_lr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count);
 
 struct pdb_func_s {
 	COMMON_FUNC_INFO_S;
@@ -758,6 +778,7 @@ struct flow_api_backend_s {
 	struct flm_func_s flm;
 	struct hsh_func_s hsh;
 	struct qsl_func_s qsl;
+	struct slc_lr_func_s slc_lr;
 
 	/* NIC attributes */
 	unsigned int num_phy_ports;
diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build
index 02981ef987..4caee8ac41 100644
--- a/drivers/net/ntnic/meson.build
+++ b/drivers/net/ntnic/meson.build
@@ -54,6 +54,7 @@ sources = files(
         'nthw/flow_api/hw_mod/hw_mod_hsh.c',
         'nthw/flow_api/hw_mod/hw_mod_km.c',
         'nthw/flow_api/hw_mod/hw_mod_qsl.c',
+        'nthw/flow_api/hw_mod/hw_mod_slc_lr.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/hw_mod/hw_mod_backend.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c
index 4f16235a67..6b0ea2a4a6 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
@@ -22,6 +22,10 @@ static const struct {
 	{ "FLM", hw_mod_flm_alloc, hw_mod_flm_free, hw_mod_flm_reset, hw_mod_flm_present },
 	{ "HSH", hw_mod_hsh_alloc, hw_mod_hsh_free, hw_mod_hsh_reset, hw_mod_hsh_present },
 	{ "QSL", hw_mod_qsl_alloc, hw_mod_qsl_free, hw_mod_qsl_reset, hw_mod_qsl_present },
+	{
+		"SLC LR", hw_mod_slc_lr_alloc, hw_mod_slc_lr_free, hw_mod_slc_lr_reset,
+		hw_mod_slc_lr_present
+	},
 };
 #define MOD_COUNT (ARRAY_SIZE(module))
 
diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c
new file mode 100644
index 0000000000..d95352ec67
--- /dev/null
+++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_slc_lr.c
@@ -0,0 +1,65 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "hw_mod_backend.h"
+
+#define _MOD_ "SLC_LR"
+#define _VER_ be->slc_lr.ver
+
+bool hw_mod_slc_lr_present(struct flow_api_backend_s *be)
+{
+	return be->iface->get_slc_lr_present(be->be_dev);
+}
+
+int hw_mod_slc_lr_alloc(struct flow_api_backend_s *be)
+{
+	_VER_ = be->iface->get_slc_lr_version(be->be_dev);
+	NT_LOG(DBG, FILTER, "SLC LR MODULE VERSION  %i.%i\n", VER_MAJOR(_VER_), VER_MINOR(_VER_));
+
+	switch (_VER_) {
+	case 2:
+		if (!callocate_mod((struct common_func_s *)&be->slc_lr, 1, &be->slc_lr.v2.rcp,
+				be->max_categories, sizeof(struct slc_lr_v2_rcp_s)))
+			return -1;
+
+		break;
+
+	default:
+		return UNSUP_VER;
+	}
+
+	return 0;
+}
+
+void hw_mod_slc_lr_free(struct flow_api_backend_s *be)
+{
+	if (be->slc_lr.base) {
+		free(be->slc_lr.base);
+		be->slc_lr.base = NULL;
+	}
+}
+
+int hw_mod_slc_lr_reset(struct flow_api_backend_s *be)
+{
+	/* Zero entire cache area */
+	zero_module_cache((struct common_func_s *)(&be->slc_lr));
+
+	NT_LOG(DBG, FILTER, "INIT SLC LR RCP\n");
+	return hw_mod_slc_lr_rcp_flush(be, 0, be->max_categories);
+}
+
+int hw_mod_slc_lr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count)
+{
+	if (count == ALL_ENTRIES)
+		count = be->max_categories;
+
+	if ((unsigned int)(start_idx + count) > be->max_categories)
+		return INDEX_TOO_LARGE;
+
+	return be->iface->slc_lr_rcp_flush(be->be_dev, &be->slc_lr, start_idx, count);
+}
-- 
2.45.0