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 1F65545BA3; Tue, 22 Oct 2024 18:59:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB3D540EF1; Tue, 22 Oct 2024 18:56:48 +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 728B940E22 for ; Tue, 22 Oct 2024 18:56:34 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2108.outbound.protection.outlook.com [104.47.17.108]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZaLOVycEUwVO3+DTRYJ6wnyaFFl3oAAngI/I6VQG3UGu2+Ln4f1xPjBnhr/7M1ea/eSzqVagl3Xw46mexwHs0AQcIiMqbGxUnzccoRFB72+2e9B1xvSA4doEqv/0AfKNFLsdAz7t/LvP6sUUNDjuv0Gx3zzJM4TrpFVnJdvuSxSQbN1xczOwItAkiLunMPeHKC7LWF7p3nYX1V9yfd1VsRC7hpvApDh6b/4xAFJ87VR5ONrMrl4QOUuY0FsHec9pEkwnldYwwbvPzWqf3u5tYrq5RJdRESLsZlis/GYnRykILhnLKog03qoEgeJgYktKWfLhmWyTY+zukZskEPGnJg== 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=eXtPeutlv85z4SrJFP4vi43QfKPinOwvXqpeSZL5mAE=; b=CqIlx6QkVigB7oF8dQ1phapol1mqdfHdSpBNDdyCud785PnQh9paNSxTSe1aSoybNd95qEUfwJ2ogBf6Igz/H8T9Q+euxbx+iCxQhPEoCjVO/qZxT9sxHWhGw/RSpHhqmT6LNKQvabAz7tXnOprD+upwWZzPt0XzmheXvnX95UUEkx+oeOyB2c4KzqCabRTue436Q87lk3r5bosqSSd6kobiAcU6ZvQcNQ2IJP4Sc4wXGm4B1cJYnOuJswrPli0DyVlRgUCgIgDhQKGL56WFCEFhQVnFZFbX2koCmc4Q9lWvz7a83c4GSNjxUuBCWtxxDU+ZBlFn53m+KaXDDVzxzQ== 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=eXtPeutlv85z4SrJFP4vi43QfKPinOwvXqpeSZL5mAE=; b=oYZeYDBEVdFa83nDmBiDQM3Bi+5o4WjEDGU1WKW2BA+GkPuAFH4QZEnZ/W8sGjqsZNHk2ES9e1exHgDxMRTWjIkYAEpy4kWnUcVUXa4ik2ccSSRSRXKgNyJ6FU4KAa6RE8CrJcVSBCofcuqabE3wnEDxxLN1KtPXJ7qI0uaPPZw= Received: from DB9PR06CA0019.eurprd06.prod.outlook.com (2603:10a6:10:1db::24) by GVXP190MB2177.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1fb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 16:56:29 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::b3) by DB9PR06CA0019.outlook.office365.com (2603:10a6:10:1db::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56: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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:29 +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, stephen@networkplumber.org, Danylo Vodopianov Subject: [PATCH v2 27/73] net/ntnic: add SLC LR module Date: Tue, 22 Oct 2024 18:54:44 +0200 Message-ID: <20241022165541.3186140-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|GVXP190MB2177:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 124a3cc7-d525-4d51-661d-08dcf2ba7980 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?qpOfMc88iaq5TTh9HNCswrmoK16eqADzruDFr0DiGZMqEXAdqrK1Uy44XBnc?= =?us-ascii?Q?wrEsEVJakTZxr7oJgIW5G0/EiG4pPHG/ngmfg7gKp9FC0akz7JNyn4b0Qk68?= =?us-ascii?Q?81R1CP/u2h/qaIaKAqLDLHisM27zGFZCScfbTub1Rv8gu1YRXgy3SGlGku0O?= =?us-ascii?Q?rVlRe5/9JadO9GX+4VrqSDR3YduU9/+WxJOlAO3p+ErRlhwToFB8opjnsujW?= =?us-ascii?Q?yQHRbSzEKMLH9pczT1ohy0rETMz9NE0kXiZUJ8LQzWnJW2Puae+2bdXDfkh2?= =?us-ascii?Q?QKYhJK4HW+XwbswKOJxnP+v7xTGaQUaszAxCjQ2IuuhYUy2NjNHz2ApeT6G/?= =?us-ascii?Q?QSINmuIJFq6kooR9KZx3rcJgFIEbUytTLIIgfHCx7Q9HtAy2KPhTn/jrcr0z?= =?us-ascii?Q?dIMjRESYzv1D4e9CsMZq7MqGWhYxh0zlzinG8p6xfKw2st7oC8MCQ+cU8aBK?= =?us-ascii?Q?llizeSKWzSzd6EFAg5hLt6yRYDaxlvmDX4evSQDIoh/q05cCXMLY1GH746Lp?= =?us-ascii?Q?U64ojwr4lKBSbafA2dbNHUMrz7pgF8gKx/Vs22XpKMhcyEDLSYLd/rAB7gCG?= =?us-ascii?Q?EP70CH+x0FFFhxF+uU6757+tD5ZBHrkjJ6Tix95FAU1hNSPfvGQzRG0frmET?= =?us-ascii?Q?A17RrcIfvrCfpwLVT46yviXRgPWDlsEYjQguBrAcvPGGnzTcQuuPqvo5fmW8?= =?us-ascii?Q?Mb0IwWz8rDFr2MyglXbmSG20Ztp23OZjOBOt9T8r6RwX+Eb6hcLG3M5sKp2I?= =?us-ascii?Q?wQbjcxPSVoeLiM4atgVg6adJw64yYUD58GrRJ3WLz4WICU9ClEYRw+8Z+F79?= =?us-ascii?Q?/cwVoOX+OZAcME/TEUz0hqwH76Nl6NGbqVbLDBsOsC9cJ8EvRsj0JKtSBTfg?= =?us-ascii?Q?RVnLzLnt+t4RhuKefP3oIQedYu2XpAOT8fVcg5UKDmG6jSpqfwgmRTNFKFWd?= =?us-ascii?Q?HVv0vJGvKWuD8pBR4fDCekV8RpQ3oBDd4OzpQGpjON8hIlLYfho2y0VI0oWK?= =?us-ascii?Q?QaLLdjlMHi8zn7JsHwPsU6ziJNeQDgzp3uOK7sqUxpPOQJ1xfaDoQEsfJqq6?= =?us-ascii?Q?oTV0mf4BjmsdoYUxtZnT6ytx5PQQRMXHfPz8BvHc4iE3ByAptX5/NAOMm5Jr?= =?us-ascii?Q?kcFZU6VFfFJ/mouuZ6VmPQ7g8SpvzzJSMWi7fB6XSvfbfiMOx1G2c7nXIljL?= =?us-ascii?Q?moycQTbI+LO/Bmku2/YGHMEUj5ddjQdw+Qmd/bJV+Lx46tQCo0BZ/xb+sRWl?= =?us-ascii?Q?OMeJBhafkDcIIWdn219lS+BxRRrKZh0A7esrYb7aCQFZpS8pLYuSWth4Sj63?= =?us-ascii?Q?Ch3nnI3NLbkGYaI5SAbD4ct8jVhThps0JmjLigksTgdQovul5R1zneTzlzV+?= =?us-ascii?Q?KTgmKEFz0m9UDeqVZzAGRX3rwDhNbTIV18CvVFVRAeutpiFfWw=3D=3D?= 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: zeegxIeYV9yTGpJhjTpgpgDdQa9zFLW7P83+b0c8GNVQI/j76kygTkEYm5Ah+qA6mJy7xPSN1Kkivjcp0f+vRcwrtYczVpTVfMvTNU6uD1I8r1XtO1r53QPJ/fWbo5l6Ho4+gpHTZZ/ma+OXUfP1CFfMWQxuKy6cwnsU419NWlb3xDq9LaoVvdx6oBpw+Yp5PlJad6sQm5clBC9618cU++HumCNvL0h3ZEo2KJrp48ngJTD9pfyBXCeqv5nfGHEL/r1weH4ISMNVzNrkzT2GXg2JtckAhFK4SYp87VNRvhkPwxKifRLFEPANba/DnbdTxmFyC0+lvhUkw6u7eybWRzZ+PXPOBkKBv9ss1EMDHRVMn8Jg89iSBYzPMI5VU5Pblz4CWIkSdcLQVgRNlvF3zuZRvCcHthZkSHQyraXB/6rRgBLjFmgKjARhnLoNCpkk3l6PSI0DQUNCd9dVYrLQYQTFKcZDEKkCSlcw8skEW25z82hPiBZb1tUKUNbk7K5z56b1iYWfnPLvV548VInFJTXXdhLu35ci/PYPYssbNDxXJ5rvwY9+yiIrdjGh8JoqMKF0aUR3Bsr+LUgtJDeMG05QA/loSnZ7buPk7ALcCa/YH0cT/RgTM26WrwRB6NjmiOhV8nq76t7Acyj7xcB+2jDsFT73n7Z+/JqrwEsYhFM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:29.3095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 124a3cc7-d525-4d51-661d-08dcf2ba7980 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2177 X-BESS-ID: 1729616193-304983-12652-14398-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.108 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGBubmQGYGUNQw1dwyKcXA1M gixSLZ3NLU0tzA2DzF2DDR1DLFwtjMQqk2FgADalEiQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259901 [from cloudscan12-68.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE_7582B META: Custom Rule 7582B 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE_7582B, 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: Danylo Vodopianov 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: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 2 + .../nthw/flow_api/hw_mod/hw_mod_slc_lr.c | 100 +++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 104 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 19 ++++ .../profile_inline/flow_api_profile_inline.c | 37 ++++++- 5 files changed, 257 insertions(+), 5 deletions(-) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 87fc16ecb4..2711f44083 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -697,6 +697,8 @@ 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); +int hw_mod_slc_lr_rcp_set(struct flow_api_backend_s *be, enum hw_slc_lr_e field, uint32_t index, + uint32_t value); struct pdb_func_s { COMMON_FUNC_INFO_S; 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 index 1d878f3f96..30e5e38690 100644 --- 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 @@ -66,3 +66,103 @@ int hw_mod_slc_lr_rcp_flush(struct flow_api_backend_s *be, int start_idx, int co return be->iface->slc_lr_rcp_flush(be->be_dev, &be->slc_lr, start_idx, count); } + +static int hw_mod_slc_lr_rcp_mod(struct flow_api_backend_s *be, enum hw_slc_lr_e field, + uint32_t index, uint32_t *value, int get) +{ + if (index >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 2: + switch (field) { + case HW_SLC_LR_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->slc_lr.v2.rcp[index], (uint8_t)*value, + sizeof(struct hw_mod_slc_lr_v2_s)); + break; + + case HW_SLC_LR_RCP_FIND: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + FIND_EQUAL_INDEX(be->slc_lr.v2.rcp, struct hw_mod_slc_lr_v2_s, index, + *value, be->max_categories); + break; + + case HW_SLC_LR_RCP_COMPARE: + if (!get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + if (*value >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + DO_COMPARE_INDEXS(be->slc_lr.v2.rcp, struct hw_mod_slc_lr_v2_s, index, + *value); + break; + + case HW_SLC_LR_RCP_HEAD_SLC_EN: + GET_SET(be->slc_lr.v2.rcp[index].head_slc_en, value); + break; + + case HW_SLC_LR_RCP_HEAD_DYN: + GET_SET(be->slc_lr.v2.rcp[index].head_dyn, value); + break; + + case HW_SLC_LR_RCP_HEAD_OFS: + GET_SET_SIGNED(be->slc_lr.v2.rcp[index].head_ofs, value); + break; + + case HW_SLC_LR_RCP_TAIL_SLC_EN: + GET_SET(be->slc_lr.v2.rcp[index].tail_slc_en, value); + break; + + case HW_SLC_LR_RCP_TAIL_DYN: + GET_SET(be->slc_lr.v2.rcp[index].tail_dyn, value); + break; + + case HW_SLC_LR_RCP_TAIL_OFS: + GET_SET_SIGNED(be->slc_lr.v2.rcp[index].tail_ofs, value); + break; + + case HW_SLC_LR_RCP_PCAP: + GET_SET(be->slc_lr.v2.rcp[index].pcap, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_slc_lr_rcp_set(struct flow_api_backend_s *be, enum hw_slc_lr_e field, uint32_t index, + uint32_t value) +{ + return hw_mod_slc_lr_rcp_mod(be, field, index, &value, 0); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index addd5f288f..b17bce3745 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -20,7 +20,13 @@ struct hw_db_inline_resource_db { int ref; } *cot; + struct hw_db_inline_resource_db_slc_lr { + struct hw_db_inline_slc_lr_data data; + int ref; + } *slc_lr; + uint32_t nb_cot; + uint32_t nb_slc_lr; /* Items */ struct hw_db_inline_resource_db_cat { @@ -55,6 +61,14 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + db->nb_slc_lr = ndev->be.max_categories; + db->slc_lr = calloc(db->nb_slc_lr, sizeof(struct hw_db_inline_resource_db_slc_lr)); + + if (db->slc_lr == NULL) { + hw_db_inline_destroy(db); + return -1; + } + db->nb_cat = ndev->be.cat.nb_cat_funcs; db->cat = calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_cat)); @@ -72,6 +86,7 @@ void hw_db_inline_destroy(void *db_handle) struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; free(db->cot); + free(db->slc_lr); free(db->cat); free(db->cfn); @@ -95,6 +110,11 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_inline_cot_deref(ndev, db_handle, *(struct hw_db_cot_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_SLC_LR: + hw_db_inline_slc_lr_deref(ndev, db_handle, + *(struct hw_db_slc_lr_idx *)&idxs[i]); + break; + default: break; } @@ -235,6 +255,90 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev __rte_unused, void *db_han } } +/******************************************************************************/ +/* SLC_LR */ +/******************************************************************************/ + +static int hw_db_inline_slc_lr_compare(const struct hw_db_inline_slc_lr_data *data1, + const struct hw_db_inline_slc_lr_data *data2) +{ + if (!data1->head_slice_en) + return data1->head_slice_en == data2->head_slice_en; + + return data1->head_slice_en == data2->head_slice_en && + data1->head_slice_dyn == data2->head_slice_dyn && + data1->head_slice_ofs == data2->head_slice_ofs; +} + +struct hw_db_slc_lr_idx hw_db_inline_slc_lr_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_slc_lr_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_slc_lr_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_SLC_LR; + + for (uint32_t i = 1; i < db->nb_slc_lr; ++i) { + int ref = db->slc_lr[i].ref; + + if (ref > 0 && hw_db_inline_slc_lr_compare(data, &db->slc_lr[i].data)) { + idx.ids = i; + hw_db_inline_slc_lr_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + db->slc_lr[idx.ids].ref = 1; + memcpy(&db->slc_lr[idx.ids].data, data, sizeof(struct hw_db_inline_slc_lr_data)); + + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_HEAD_SLC_EN, idx.ids, data->head_slice_en); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_HEAD_DYN, idx.ids, data->head_slice_dyn); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_HEAD_OFS, idx.ids, data->head_slice_ofs); + hw_mod_slc_lr_rcp_flush(&ndev->be, idx.ids, 1); + + return idx; +} + +void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->slc_lr[idx.ids].ref += 1; +} + +void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->slc_lr[idx.ids].ref -= 1; + + if (db->slc_lr[idx.ids].ref <= 0) { + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_PRESET_ALL, idx.ids, 0x0); + hw_mod_slc_lr_rcp_flush(&ndev->be, idx.ids, 1); + + memset(&db->slc_lr[idx.ids].data, 0x0, sizeof(struct hw_db_inline_slc_lr_data)); + db->slc_lr[idx.ids].ref = 0; + } +} + /******************************************************************************/ /* CAT */ /******************************************************************************/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index 38502ac1ec..ef63336b1c 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -40,10 +40,15 @@ struct hw_db_cat_idx { HW_DB_IDX; }; +struct hw_db_slc_lr_idx { + HW_DB_IDX; +}; + enum hw_db_idx_type { HW_DB_IDX_TYPE_NONE = 0, HW_DB_IDX_TYPE_COT, HW_DB_IDX_TYPE_CAT, + HW_DB_IDX_TYPE_SLC_LR, }; /* Functionality data types */ @@ -89,6 +94,13 @@ struct hw_db_inline_cot_data { uint32_t padding : 24; }; +struct hw_db_inline_slc_lr_data { + uint32_t head_slice_en : 1; + uint32_t head_slice_dyn : 5; + uint32_t head_slice_ofs : 8; + uint32_t padding : 18; +}; + struct hw_db_inline_hsh_data { uint32_t func; uint64_t hash_mask; @@ -119,6 +131,13 @@ struct hw_db_cot_idx hw_db_inline_cot_add(struct flow_nic_dev *ndev, void *db_ha void hw_db_inline_cot_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cot_idx idx); +struct hw_db_slc_lr_idx hw_db_inline_slc_lr_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_slc_lr_data *data); +void hw_db_inline_slc_lr_ref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx); +void hw_db_inline_slc_lr_deref(struct flow_nic_dev *ndev, void *db_handle, + struct hw_db_slc_lr_idx idx); + /**/ struct hw_db_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 5176464054..73fab083de 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -2277,18 +2277,38 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d return 0; } -static int setup_flow_flm_actions(struct flow_eth_dev *dev __rte_unused, - const struct nic_flow_def *fd __rte_unused, +static int setup_flow_flm_actions(struct flow_eth_dev *dev, + const struct nic_flow_def *fd, const struct hw_db_inline_qsl_data *qsl_data __rte_unused, const struct hw_db_inline_hsh_data *hsh_data __rte_unused, uint32_t group __rte_unused, - uint32_t local_idxs[] __rte_unused, - uint32_t *local_idx_counter __rte_unused, + uint32_t local_idxs[], + uint32_t *local_idx_counter, uint16_t *flm_rpl_ext_ptr __rte_unused, uint32_t *flm_ft __rte_unused, uint32_t *flm_scrub __rte_unused, - struct rte_flow_error *error __rte_unused) + struct rte_flow_error *error) { + /* Setup SLC LR */ + struct hw_db_slc_lr_idx slc_lr_idx = { .raw = 0 }; + + if (fd->header_strip_end_dyn != 0 || fd->header_strip_end_ofs != 0) { + struct hw_db_inline_slc_lr_data slc_lr_data = { + .head_slice_en = 1, + .head_slice_dyn = fd->header_strip_end_dyn, + .head_slice_ofs = fd->header_strip_end_ofs, + }; + slc_lr_idx = + hw_db_inline_slc_lr_add(dev->ndev, dev->ndev->hw_db_handle, &slc_lr_data); + local_idxs[(*local_idx_counter)++] = slc_lr_idx.raw; + + if (slc_lr_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference SLC LR resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + return -1; + } + } + return 0; } @@ -2450,6 +2470,9 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) if (hw_mod_cat_cot_flush(&ndev->be, 0, 1) < 0) goto err_exit0; + /* SLC LR index 0 is reserved */ + flow_nic_mark_resource_used(ndev, RES_SLC_LR_RCP, 0); + /* Setup filter using matching all packets violating traffic policing parameters */ flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); @@ -2498,6 +2521,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) hw_mod_cat_cot_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_CAT_CFN, 0); + hw_mod_slc_lr_rcp_set(&ndev->be, HW_SLC_LR_RCP_PRESET_ALL, 0, 0); + hw_mod_slc_lr_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_SLC_LR_RCP, 0); + hw_mod_tpe_reset(&ndev->be); flow_nic_free_resource(ndev, RES_TPE_RCP, 0); flow_nic_free_resource(ndev, RES_TPE_EXT, 0); -- 2.45.0