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 B570B45BB4; Wed, 23 Oct 2024 19:04:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7371B42ECA; Wed, 23 Oct 2024 19:01:34 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id A690D42F35 for ; Wed, 23 Oct 2024 19:01:09 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2111.outbound.protection.outlook.com [104.47.17.111]) by mx-outbound42-14.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:01:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ixYyWfyMUq+7SSkiuAZHqJPReBpkgWKA9obGqhzyuY88Dpg3yrLiGRJXvXMgLz/+QJgHN1u1tx8WvrKN2yl0EXd0psQ8esVSbOZARSeVGslrfaKI+0g/3tBKPXw+zxJUyVkO/9sE4S5JoBvzRrVYZEULUlhJAHyDqnbt6cjbEmwuU2k689jm+D8ok5GvsT6VvFk06CLsMLBr49lPYb1Z4i0yQl0T2Mu7OCHs/m8qoplQOYyodJfnMcADbnBNMgLzG5Mb08C63/4JOac4Cs5FLhBD6Rw/p/z1xbY02+5Kg9YL3gzEwI0IndtMhm0bICsUbmeL3Twu+6Kbvb8Ny0Y1Jg== 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=we+NjWM05hbSG3JVBmkW/QH7hlC5brNsPexFANtsU/MMD9JAWp4EFV1+oPXDI97j/VdMyvFThnhLIPHft7sMbkhvEU8HhXWiexXsgJdalB9xnEdB/NYu9eUonPFxrbMiARsE4O5HhLldk6soI4SIoUM9rTDH9XCYBsPCwwK/LROY3ZjZbV/wyi7Er6UjBCvV6RAjTqIsWYtoJKSQXOat1NkrLyKhvBlt56lHl4iZTxqk9ZrGDME8neRxOvsnZ9VfTU1dsoG6dxscij52lDzdrSAJPjNLrEC2Lv0UFtwHjEDanyOqS3vvagTTVjTdf+RblAXGvN+3Y7dhhFKGnDHeZA== 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=NDY/WV9l5p5Q7DwEp2Pgpi+4sUt9wEAN7WvOTh1p4LrePPlrTZIsgCJwVmzclsFBqTgOKUL+4avMfKqTZIQi0ZysIVWb05Q//H6Zk9E7c+6sOfkptbpBYQNybT/Qy/B9SKPOTRS3j9B7FC22XQeLYTlQJkTQVydVML9MlNWZWJA= Received: from DU7PR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::6) by PR3P190MB0972.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:80::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Wed, 23 Oct 2024 17:01:06 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::3e) by DU7PR01CA0006.outlook.office365.com (2603:10a6:10:50f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.31 via Frontend Transport; Wed, 23 Oct 2024 17:01:06 +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 DB5PEPF00014B9E.mail.protection.outlook.com (10.167.8.171) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 17:01:05 +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 v3 27/73] net/ntnic: add SLC LR module Date: Wed, 23 Oct 2024 18:59:35 +0200 Message-ID: <20241023170032.314155-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241023170032.314155-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241023170032.314155-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9E:EE_|PR3P190MB0972:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 405ed9d4-a1f2-4463-8b5b-08dcf38448c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Rf0gGq8S9hK7mM/oQWXX8fMn2sNZG/vzbg3YMGrAD/pZSsPKh8c7z3LcGu5d?= =?us-ascii?Q?Af5vxpu/lor1qWSujTfhGBiHjoYo+vGVC3L0QfqlqQXAFsqPBj0oSM9AKvYo?= =?us-ascii?Q?vTjwcawFrKgZAoZ25gIlzmLwMLzrSfI+c/rm7exyMD9em1klxA2OmQliZP0s?= =?us-ascii?Q?Bj3IEinLHT9AZEgxPpHaGNc3wndHh0/6hN/zqFI1bGif1eCDiZU86zWnJ+Mv?= =?us-ascii?Q?tBsYi9gtAEq5eUbgGmxv2c0NpUJuezVbckUgkz4wWSSgE6TOo4L18dnSl3ae?= =?us-ascii?Q?DPAkzZdyZZLDxJHhDLDqQbV1SCHZ0843AscDGaXCpZQR8w7YHyY6oFh6+FdD?= =?us-ascii?Q?7lpers99v/D3Bj6EQ2dguHkvOBtnrq/86LozSL2706/xzHVujhhTgqpUY1xo?= =?us-ascii?Q?oO8haBWzooYUNonV/lg23bRmTypeDoCUApSO8UohnGyHtBVoBH0Hj594XoXD?= =?us-ascii?Q?WF03naEB+7E9mTxHI8YU/TRUvZwGS1t2e79evcGJU0bNBCCfPH7Hb+wNYqkV?= =?us-ascii?Q?tmt91xt4cs0CzESBolQr4RSnQz7TtfJtLB64DCcR4i61T7wPTMEb3dpVESED?= =?us-ascii?Q?udv1iAfPOEtR7cKUuhZvnTGohxLoALmdL1LAu86UCM3eW+BdudX4s0gpMwAU?= =?us-ascii?Q?Il9MzZVW1Qt9xojdWYYg7TIBS5+JNjvzAwJMBENpj/8FGYpSzfPn6OeGc92D?= =?us-ascii?Q?VjQkCIMdv0k/R7LldmdMQ9Sv+bMcVhKE7C2C4hQxOD22ioLsyId25KUIX5HK?= =?us-ascii?Q?DVCTs01RGwj+l4mmd/SW5hh5wmf+R85RJXaGRz3fizBes06bm3Kg8mUBtCfa?= =?us-ascii?Q?6G6RlVe+Y+zCpiaMQ3SEgvPpdPPG3TyF2uuvg//fR0lt1fes+C5ULE49nana?= =?us-ascii?Q?ajSnhU0/cnGSnsydCxO93cDH9SNZuHqTFEnBZ4jPfZ9oFzr0kn9+MWup+o6z?= =?us-ascii?Q?luti/+lbViAVn7CwF6StuPmq/1VgNooBRL2BxTC3PV8ShrwMdj+WUHIDw4ln?= =?us-ascii?Q?UyjtntC4XHxX6P3IwHqwCaDKDirlky7y/S+uICKRxl0GqdC807AoOPkgwc8X?= =?us-ascii?Q?9+KzC7VzaGqI/Q4BcCAYCSuDokzjwzrZ74vW9xxkkT5pEFDZWOsORXuNPbiv?= =?us-ascii?Q?c0hhq3xP1SEWF7jGbgP4Jslp/e1mSGKPsdSFWE7T5d8FW0JNm3xVyszDQRHm?= =?us-ascii?Q?J7rFaJChLytNKB1J59CTJ1yOEQAlTNqUZNtCESr2qk3KYQpl2zX5GBiMv4xL?= =?us-ascii?Q?5XdsyMjFOWdoaUUZUJe07EpQBp+N7NPPOzYDUpAddXdjo9v+hUHTyx8+TMSi?= =?us-ascii?Q?9asJrUpXp21LHY0uuyRWECjJeghO885SRKhjD2Q63M59YTkDSGBMws+8aar0?= =?us-ascii?Q?lZTvQ+wA2vSj9/dctvXRxaTpR6eC35BNvlLk4qBLlO8SMj0jWw=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)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MJQdp5eM1G0507S/POaK6qTSrM00/TPmaYDjn/SKh8Iu10yWkkxu8AheqABOghMawD/Tb9bK/VrPXeTqXIk510KB6KXVMH2zkz1TQv/hsgGJYNywzae6JYL0BXy2fxWTshOqWvvEjL8JLpMgxpAT5k1hxhmr1WcUtT4B40c6RazNXzuq3QqXJ+MYVkL47Q0WRaWwpqmkukuff72JpEvTiLY1XvPig7pQoW4oMjVxsCTCfvbPn8M8atzmdMD0H9ceAN9b98T0frWPqQ41LTxtQ1yDUm2NjRaEMflfqfsM99CFWtj/9wtsfUjaOxGHlqhl+Z3wOMPslQlF1REttfTvvg+gKmbweAyW8OnrVRCIgjUZE3O2KDtv3fvNi5rgYl68wFjXgHka8OffU+odLu2SSC7ks8H8epHKgEzdnIhJx2bOLe7eGDKcogn4mFLFlw24c0iZ/eqZkOhfL29Wom47veCV/MdcQHLGen/P5L8aWda0dIhcRDg+rnlMRsyzePz9jroX1VS0V2FrhCu5Ol1MaMZ97i1VuVWGncnt2Q2O6hcXvGXVXXk4PoUKH/1q32i3wSL5a6CQzd9K9poa/FukacXoF/3uyPAUW3+Abs9Ck8yMb8sW/DRPEbmtqlQ6eoY3fdgFjn3OILYldnAiL5QQtAimydye0LKQD8VeX3IorSM= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:01:05.8831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 405ed9d4-a1f2-4463-8b5b-08dcf38448c1 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: DB5PEPF00014B9E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB0972 X-BESS-ID: 1729702868-310766-12807-42093-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.111 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.259925 [from cloudscan15-19.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