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 1044A45BC0; Tue, 29 Oct 2024 17:46:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14BF042F77; Tue, 29 Oct 2024 17:43:47 +0100 (CET) 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 A0F4442EE8 for ; Tue, 29 Oct 2024 17:43:22 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2240.outbound.protection.outlook.com [104.47.51.240]) by mx-outbound12-25.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V+Z8n4m/p/9MSJ9VPDYOXR7w7XfgqSpCv7WD45p1UkYM27Jvp/9cmL0OHf22PzGM8MWA5IXTzaIBUOI6J2HSmdKoZ0HgdQJipbxSEesjLcU+ev8W1DTkU8UD+gUesm8M1zZ5al3HzmJC5x0amU2pAJ84F1XvJw5NqSVzaIA4TGgMTfb8BorzFVjmHHSckwIdenCm/kcooHIoFmsk6JJTXWDrVgHLXHE0p7tRRaQP2n5UM8Or4xGfJpxyCNBS1WQsnRZTZ115hHDuIO8NPlnvNSmi4jPj/GJ+cj0/7Ynl4VUyHf/+GxaHMv0V2jtUuzmsJ3wHjdQvnofANcLV4z5eDw== 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=DKZbQsMHBrYd9PJ83TdPWkxhbwY8dg/1COUfgRwuyUk=; b=q0//dvC/AWxIf7KwZMIFt59ugk5pB3TU7Az8z3bhYrj6Y9fOhkIYvkN6RiEDKKXTrT6INQkZmt9F6lqJgUTe8NM9WiuJ1485PqgCdkneFoIaalqQuNDT3yK6bh7gOzaVvLkBjW9Adj1c7qE9nEwg4Utwn/HNpVSMGW+DsQC1+v3yEdTc0YsKbMUCDhmZszwuufXgtuKK33uhYe/O2mRAwcblxaqY1hIqPc9BZ6ANums6VpUkH3UXV7wn7t4dKQX99cfr3ydMNdbhSyWXtJivpzDkrvCeke9CzgpyY+2vzoMMIkrjY/ksdIhkXgJJgsh/OzTlRnJrddgGyiQMyLMPDQ== 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=DKZbQsMHBrYd9PJ83TdPWkxhbwY8dg/1COUfgRwuyUk=; b=ikCLYGDnW1bbNMDtFDQNVG7i70Z59+kiP9FuJIeDN4f1NK2sPKMjit7Uho8W3lvVdXaQClSV/VzFcUSpQYyzrm9VFFI59I03sKoPQjWqHsXDIMvefS4ppGXc9zgJbtnUXlRYQAGu9CE+OUti8a5iQevczApjC9V9IS4UcIpTdF0= Received: from DUZPR01CA0194.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::19) by AS8P190MB1063.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e4::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:16 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::d0) by DUZPR01CA0194.outlook.office365.com (2603:10a6:10:4b6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:16 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:16 +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 v4 27/86] net/ntnic: add SLC LR module Date: Tue, 29 Oct 2024 17:41:31 +0100 Message-ID: <20241029164243.1648775-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS8P190MB1063:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5d74120d-ac0d-4212-e29d-08dcf838c9b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UUp/cdcf+RUX1G1xe1F02JWVDdhbHcgESH6xCLmEnzd0+Qa18khbnDQNVY9e?= =?us-ascii?Q?wKZjq7/J38dnBKVoVzCifiy0chnKQfQwK4ZEWJjDu81OKOWAlb2LySzxCPRJ?= =?us-ascii?Q?v7B3pr48PdPYv4WjIsjnpx6PTK+yRyEL+2diLhfZonmdMVtn/B5XTeXBw/9J?= =?us-ascii?Q?kVnuN0OUL7ZRKJXLuHHbQRcsf3T9ffTOIu5/HnaAaEsSbLGL8TBwhB5NnCue?= =?us-ascii?Q?0Gjj8KWuqZG368dIJT2zkIKrE97yNoRHtJdJB/Y+cr2rU33hrDOiNY9GvbuW?= =?us-ascii?Q?SrlcaqxbwaY4Nbr6b+XzEF21KhqYcVYDGDQTCLz72py8pJJQRshh1El7TUD2?= =?us-ascii?Q?cEGvCjsgGxUj0ngU1z5R5Awq74GQPKFxnkQS8VTnBwM84CMltCqHf/ZDGTBV?= =?us-ascii?Q?23l53HoYk2uHqoChrPxWB2YwWAf1vhAjyzSyESgI7bcQrtOB4hzsqjAsZHD0?= =?us-ascii?Q?6Z4lYdIpPh6pA0FhRO00sPENFO0dhO81tm9K4F05Zjhb78Vh46hVr66c+6Gm?= =?us-ascii?Q?lVRtW2vzR85pavdlos/qvCKNwoKPSpMe/p11Oankvzk5FQtDrFtPqwNsjEHx?= =?us-ascii?Q?bD/MlZ3Vj3rPXSzLGGmdVQc+pvXXRImvfewXim4m8HC85CL9/VftjWs1PtZ/?= =?us-ascii?Q?INNcpn1eXmQWfbKmtfMWQThxVpf5j3+JnSqcH1TnYyV2wefNqT30HMz1kdcp?= =?us-ascii?Q?5kw+oFSLy3bbBryVf3WKs60lNZv+EdmdaudzA0qptH+MFg1IPWzsn4mofirj?= =?us-ascii?Q?jMgj/6a94WYbbUfeOkc15osI87TmchetAcH5g6S7q0VEQND+9NaKYdAK7bbQ?= =?us-ascii?Q?KNxiCmK62BLXaybqkiBbXnl70VKCgaNGez9AZmC+q95x90U4ex1wBYzxuZnA?= =?us-ascii?Q?delx9tQdVnnQXgHgMpbgqpQxtoRehfUlWxq1l4I0KQBhPOBhcuN1OZH2VQ2J?= =?us-ascii?Q?Y6HI6KcryHQ3gHkalTnCgiDZJ6k2e3S7NibFCdgjhIIxaFwD0iO/VG/j6SZk?= =?us-ascii?Q?My03Vjt6pLpO76DlRsQEXr09i9IR63R1svs2krTr2GjdCd/mFJUsE2/MImKI?= =?us-ascii?Q?aNyt7laA8T4lcQTpxPliQLSCpObB+41RHcpTWJHZOZI7sZToLst0e578aUPq?= =?us-ascii?Q?iR0Sx2fO5C5MtRXqwNKgHcqiCcmeu8NUiZpNvMkUdi6E3eMVjR905Zfa/UjP?= =?us-ascii?Q?fG3EdSSQPRxPdgqLmungN1+G6nT9v4rcScoIFPyPYglPN0NxZ5ym4IdngBrY?= =?us-ascii?Q?0B5rPFuS8aPgC6MlKx3g4xW7SUaBwWylWV0EjtMHXJ5/XPHIxHPXWmSwOQN1?= =?us-ascii?Q?BwD2UjkVVqPHkLP0qc329ziwc+KLBpDg+VHmE79LU3NKPhwhhRi114+vXaU1?= =?us-ascii?Q?BqKaOU4aNWXzdh7zBiwa+Y8VGFXbOitTEw+VLUbiQ/6kt/Bs+g=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)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: s3YOX7i8iVlLyZuz7HbC6xZvrYVT6xJH3Rw5ty7WqIcJls+ndajw70hwsgIFpjRUFZz+tcZsP4m6E+68z5uqQcCOuFqe16lY5hJNZ38jahcc/x7tnI+181/O6qK2Q0c2KwLnAtgBEWo3RSnMQv1Woe41ly7bj/JEVywLfnHYTb/v9RL4mtlMf8oxDGEk/q6F1AZD17gZltZywhERzOC5d7wqv2DjI+rIXgDOMc0wnet74NmqUl37zoKoa2xcHzA3zOxdc4jyJIeCt+5zU3zwqc9pJkYnlzp/Ojw4WC7gR+/fJGO/Yas6k8AOMWkWiL7KUSzH1WeN0OQksR+W/v1XZLltNv9bwVyLPVS80Z6r1QdhQtXqO2fTED3AdgMPdLBXP7AZGXM8PucJWpS94Mi6AR+SGdt3+6f1thIpAdbE7wBxXAxuS+7CCmwxqQp+gqhnD2vz5aUe6jGi/gYxep4Bl0tPNZT+EQvKaoGymwuW+bbQYNq5zRCQnCrLy30yo5q10ChrryFIxOLa2pBnxw6nzC+PpCFC/27Nohi56UPNwWiMo3XFUm7o53xZYTPN/eZXnGY5YHKDo57oLGOSGchKdu6Xq2tRVPDRGC7jfJTWEDEq0jubqd4mG9F6IHFFTustgMCa62uwE7EJ8lCAGBUcg9errQlf1CbcuD82CADqVDs= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:16.2771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d74120d-ac0d-4212-e29d-08dcf838c9b7 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1063 X-BESS-ID: 1730220199-303097-12758-29338-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.240 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGBubmQGYGUNTS0jDV0jApzT LN0sDYKNUyLS3V3CIpyTLR0DTZxMA4Wak2FgAlMnk4QgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan15-223.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 3ea4c73e24..d7491fce63 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 @@ -2276,18 +2276,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; } @@ -2449,6 +2469,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); @@ -2497,6 +2520,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