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 9990545B96; Mon, 21 Oct 2024 23:08:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6822240E54; Mon, 21 Oct 2024 23:06:22 +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 2D44040DD5 for ; Mon, 21 Oct 2024 23:06:00 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2177.outbound.protection.outlook.com [104.47.17.177]) by mx-outbound8-87.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:05:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A0q4LfmagAa4uYjDnbJyrWw25vsNGr7MIEMARfB91DVhAe7ACuxh283bKDS+0wspoSNcBMLan2vWTDQg70aQMhfOQ5x1rKSUkxf8vFMpFm7uIGQbCHZDKXb2XAKh9v1R3ZEm5T8trE8n98oVN6hAoppFQdJ5NGYIGkHtBtsiRRBEcKA14d2YmpycQkXnbTm0WJBCCJ72+UZlc5YXLCvvHf3piWuy72pTz5nzGjxvfriL2fScvXtOImH95VYiqd6fGk0Mh9/69XbPf5C28OMY2OneoAl80HeWl6wv23q4oGOdjDvvWZdaJgl6/P2p0qPfL2xS8OFfK6KMCoapvugUqQ== 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=vu8ATeaid5DiS9fFfHAtfHMx4mxG8kF4W9PLrBLqN00=; b=Alq3PyS6v64seoiJCEpnUjB4yLF1Su7i5TdJUrpMeru1EyWxXoaUuJzb6WN30jGk9yx10W+ZSF02+x9SnB08/cNExvj7Rc3mph0292hF9U7OrbrUvb3mjTSF75gmpghxi6I7RnEMfCVA4/VgOIrFtTMR8ZKoVAHj7tLd4NPvJqlKqiGd9twFW9JNocDJ67gJAln3baiOxuVSDnxHX1phaPtm5WK3R5r/8sNtJHbOBGtBH+OAt6nMDcXl9wCF56flljLKnNQXFAxT3SvWupDfY/R08y6ZFbsQwZu4gXEUaZ8hUxD3TMJF+bF9RQNVHD67zmuHSo2GcxdSAY+KCeQcnw== 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=vu8ATeaid5DiS9fFfHAtfHMx4mxG8kF4W9PLrBLqN00=; b=ag6cEEesAdm0NrPP0FXEwUtWL495o+MoGmEYWR/d72yjR1vIOxsxP8M6Pgfm9xiRP7BRIMRo1vEFyNr+fMbuJ33HvJGXfSWvQY6cwbe2INVMqqqtOZ/Wd4ge+geb2qidi8560KmFB3vYxHgeAulPXSSVshzNAX4ijdPbOnHcS6g= Received: from AS9PR04CA0154.eurprd04.prod.outlook.com (2603:10a6:20b:48a::17) by AS1P190MB1702.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:48c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 21:05:52 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::b4) by AS9PR04CA0154.outlook.office365.com (2603:10a6:20b:48a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 21:05:52 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 21:05:52 +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, Danylo Vodopianov Subject: [PATCH v1 27/73] net/ntnic: add SLC LR module Date: Mon, 21 Oct 2024 23:04:29 +0200 Message-ID: <20241021210527.2075431-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241021210527.2075431-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A8:EE_|AS1P190MB1702:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d28e4b1d-ea57-44e3-b873-08dcf2142598 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tv1ThbxAfIAnHSLAOcl2jSl9KP/Jw8VKERwtmL8jQmbAbrzVdrBZUKgjcH6j?= =?us-ascii?Q?GpLqEcScORXaM2KoXq1nGydaXebddi2HjKmnkewumA3rbAa8ICz6oHqaePFz?= =?us-ascii?Q?CMYMPHi7qQU4D+7rPtJGieVhBwlO6a648RlN+6dPCn3MMrd56GcicW67Amr6?= =?us-ascii?Q?6ogagKHlL0NU5U4VrGm9fqctN29HwX3Naqtuo27zLW+ojytxuDdD5Ef23RgM?= =?us-ascii?Q?Dl/o0dG5dgSRVohXvTaACCzPoZzOgJn7F7qBUQd/zcWmd6Mt3prKn5mqwFbY?= =?us-ascii?Q?HMdjC5AVW/HUc93lB72DWVK1aylo7OzrQeS4l+FV3QgKiVokTJfFbJPMk1Vh?= =?us-ascii?Q?1SdreNgjhszymF7EROtUYt+V90xeYAuJO6RSUGi6qHBZSccHPup/FDmMQgmX?= =?us-ascii?Q?zFAhLLVInF5E5c312OmKeBCAeO4q4ikH51t2+qu6E0RHThyv/gDMQAL9lOP5?= =?us-ascii?Q?PRkObvG/+DGRoTEuuL95t87WtVmvcqL66/hFZahioHkAWyCYm4ctBf3Rzmsj?= =?us-ascii?Q?JCH436apQ/ZdXWcKJVuHadr87CjAB/09EeAETTUlOvSCTXys0rY2Ceoo/cw6?= =?us-ascii?Q?Nx6Q0FtjYqYeIoHjrg399CWaE4+QO4Cs3bS73hYFwEXiJFVTrKIxzS8HxkPZ?= =?us-ascii?Q?wZbWfAsGySinGV+eHQ+1ZIfBvGP/1KWTirVlYE0SxCFkC6cewidO9jBQS7Nb?= =?us-ascii?Q?XoWnKA5ld+GsOdNema4LKVGqPUJNa0eFSHpfhn0YnKvF+aL53JwTwly2Pg6S?= =?us-ascii?Q?PePAlFf34VkzstjdcQvZqVpMfHANFjpcVL7XtWgcFjdgBkqzMBuQyBZC134e?= =?us-ascii?Q?vISm1iGoaK3cBRdwA9ioyOTu7RK09g8lBod6B3PjKOaiNHbuRRpnIT4Zmn4v?= =?us-ascii?Q?qEobTPXtZ3bh1wzHMqY2M2c+2u0FwfJo3YPQtM1Hs6FvwfQEOYoKtRl5ZEwo?= =?us-ascii?Q?zYzHX+g+Diu7rkLjlTLhlWJf+eB9rU2jGSiPHtMutBgxAf8QR/7v6OsmI4UJ?= =?us-ascii?Q?wqJ4hM0fK24TG9QhX07BLx7cBuSgl2Wu800cF8VFnpnojSQvqWiSvhmQcoiP?= =?us-ascii?Q?aLi8NeBYNOVnSRvafbqycqnxMtEHQ7gringHZHKNdcRkDpHuB5sYQB+kUYrz?= =?us-ascii?Q?3ha4Ex5cLZKx45QgbDeKJVgPK3BowRfXvfWIMd4NC7L/aIgQDwO6/2/l14Id?= =?us-ascii?Q?YS/+ZVaToZ1brRTDTiMv78trh37wpQp7mJ8YWRXOImeelNDRg7lbOYpKEOXi?= =?us-ascii?Q?/DdBxieOi+2sRy3PUiF8ga12SyyMmGukq8h859/VzF9ajJyAc6CJigqqeipS?= =?us-ascii?Q?u+PqdnDRqrGE5OlkIczqBg8m9ji19kVyKPpeG4XA9OS2+BU+rUAtbRI8ov3s?= =?us-ascii?Q?Zui5bNm647C+fdlMN4sLAwRhuk5Q32AqIUaLvt9TGdoFMSPz3A=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)(376014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qTuruSvjYU1Fiv93V0dfJRQjk1lHlyvvuPBbYFQ371++FWvTJ8/10sYl0Rude6D6URf6hGgWjoQnKSN4dRZcFvH2d7Au60a2QV42OZLkQB3C4pwg8UYjjhNtNy9N4EruUOsxrELod9wc/2zW7MaAiyGpN3P+YO8qc0h5Ei+iLqor1290Is1BWZ2W8sqQvrj8sQeA4/rRr2j+yKL78SgW27Za9pNVhBv5jg/NBuDSzyD71zJ2aAZY0iZ4Ld4ci0HLYuoM5SmnshInthBzZtucoQ+Gl+ve2BLq+jwnJk3vTf64BYDMBGkamK9U3oCBAvbqcOV6GfBID0eqFFpzBZsLNnGLcCPhy6MUik0ljBOuRgvHyWRG2uHz4HpzMH8HIa8aYjN8fQ3h0qJ4o+ze+yNj7td9UF+LBvomSi6g6KDrmd2PXlDfumoZa0SRYHmiJbfrCm0J+CLjh72DprXMdCykWdFL2KNHADLdouCUNK6FoGwPe0SNdqABJ5HeCv0vObnoxSO75gcstEQUBQaetnRHT05hiAvfeUbd9mc9QdbcZXK+VvSOc8C0KoUP369nW8KuiGUZPQw+EEnER9qUmCdu8sFCbQM3AqJq/rgZi1mct9ECtN8SrxkQ1YmiFIIwAWnPeG+A4HbEgIrtQcFN6c/V0cK/Fjbq94cW5u68BnITgnk= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:52.2238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d28e4b1d-ea57-44e3-b873-08dcf2142598 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1P190MB1702 X-BESS-ID: 1729544754-302135-12910-43227-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGxqaWQGYGUNQo1TDR3NDU2D jZwMjYzCg52cLQzMDI1CzFyCzFxCDZSKk2FgCfIU9eQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan10-204.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 | 27 +++++ 5 files changed, 252 insertions(+) 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 4d5bcbef49..35edd2d1a3 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 @@ -19,7 +19,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 { @@ -54,6 +60,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)); @@ -71,6 +85,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); @@ -94,6 +109,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; } @@ -234,6 +254,90 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev, void *db_handle, struct h } } +/******************************************************************************/ +/* 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 f7babec3b4..c2a0273aa2 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 @@ -2302,6 +2302,26 @@ static int setup_flow_flm_actions(struct flow_eth_dev *dev, (void)hsh_data; (void)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; } @@ -2469,6 +2489,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); @@ -2517,6 +2540,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