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 9F6C045BCC; Wed, 30 Oct 2024 22:43:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F2E9434D4; Wed, 30 Oct 2024 22:41:30 +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 D70E743476 for ; Wed, 30 Oct 2024 22:40:21 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2171.outbound.protection.outlook.com [104.47.51.171]) by mx-outbound47-144.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nhi7to6p2CUEKDNRrpu/FviB6Ltai9s39SVa6bkOTmd8tQ7KTHo8uFRll1HH9/wTHyiKVrNOoO5Dx8yedPCOmxaQ5xT+aco0WtbymwiYBkoWsSvULJ5R4zxcYR35lQ4Lms/ZCLOTmSV4MinLqlGyKSljf/p8Igy5uPBg8tTU3oy0+OTPelduIzi8nqgWkMfoOwF/rO8OezqepTG1JBySFFhLOijnBnxPuST2pBJCSAPA5sPDgvwUmw57DG6fwCjHwF72549yGFD1+JQE0ED5Vm9jqOTBEcCGRSGemyuWqTGmx/dhovoKNDRe055v8PPK9xF9tXO/MYQH0IJt4l1G7Q== 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=zsNRRSNTWx2WgB/9dGfP/Z0bRQeQCLZt4aOaCu3Xtyk=; b=dCcbaWbWv2ctlLHmt15ASQIaIeCvpsK8wEGcj+491Lu0NeutRcC9ej8H7eAdC627szSJncKgQxaMbxPsRcETB9KQdwul3VZuxKoimNWs5zjzmTlgmrcdyC8b0UrW5qDLz9E/mLwPSvzuNIaieHUKiomD9OyGdFuSnyaN1Tv8clIwgcRE21hyp8hYBqSH4FMOeDgNC2QCMxjKX8DYfkaKbK4aivflgFlzaR136h9CmLDSnQm8OgcFVfgZeTsKe8uompsi8XMwB+BxbfZPyyNH/5h5b26rZNYE04h3yJOQFj/XLndzrxufgnj9XkTfyW8aNwKkvmuqY40aLtTaemzyDQ== 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=zsNRRSNTWx2WgB/9dGfP/Z0bRQeQCLZt4aOaCu3Xtyk=; b=EFS9BrEo9pQeYQk7YiiXJ6O9Gz2taosY5ko/118bChxD4QF+Set7pTccjmZ/qh+LFy9pTsaXcWM6JePpJx4BpgFHcNZ6FqlidXSfXn4O9uuLZT83i/k8tnoBB2KmLzOJ7Mdli61yaD1drIUeo+T9mRjhTm+wVS94hTk3Xzp2a3o= Received: from DUZPR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::11) by AM7P190MB0583.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:113::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 21:40:16 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::5e) by DUZPR01CA0007.outlook.office365.com (2603:10a6:10:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 26/80] net/ntnic: add cat module Date: Wed, 30 Oct 2024 22:38:33 +0100 Message-ID: <20241030213940.3470062-27-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AM7P190MB0583:EE_ X-MS-Office365-Filtering-Correlation-Id: c757881a-829b-428d-1967-08dcf92b7189 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800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ZaOE0rR1BvZlhpb1F2MEtudkt3RFZ1WHF2Q0dONDc1NEgvangrY3F1Nnh0?= =?utf-8?B?R0x1MU8vWGkwQ0RlVXgraUFqdy9NSll5Y29McjVxdG1NS2ViWUVsTlpBV0dw?= =?utf-8?B?OTNyVjQ0OVFJam93RTlvaEFoV2NiOXZ2NytnRHVwTi9xWUE9PQ==?= 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: v9wmxLZLWCr39s21nN7tNFDACofRrjro3c6YSIOAbf97WlK5Pelp3uq1kmHihYI3eAN96MQTztHssLPZEtinuFczNU7ICM5xZ91VYB7xVsvPdAI6VO89tweQF7Gga27sJ3HIzwiW2dlQuhqqCztvIm35LAkhv4i7J7vmNkx7iQZBV1IhaylpwycRsU56U04DM2Lyc4mhE59KPEyOfU0nea5fDBmHTlgecKfG2eQa9STKSiLCaXYO90F8RFBT+Zb/O+fF644NAnqNo63U3/OIGPPM+0ItA/ZuwCw/ia+dEF0lIVw+vZ7MgaIlR9RSwDWC+4+UHfirbgFiRjgEs/UEEEyVxjKvSfbtSvgwCaxe3by/ZyixpkwGt9IogocN7c/puckpigB6obybiSF/XuDOAomlucFTrVZ7fxm1lKfpGkrxrjYUWEvkaixSji4fMIJduEtz+t55I28llKlUhZL3dMOaiGk2Jvb3qrv6vGQofJtzGTsibkTzQwyOo2o5SJbYbJ2fl0yKVlODrRNKGStyd/7YqMCApQqf1A9uqfJzLk45VaAoPHyl47xjiGrSP2xycYs41HhUtKDeQZE2Kx2WODeDYzl/5wKjU9o5cXkruF3ZEte5VblStnMbMiiFPjP8DvWQx+Tk9sWZNaBccYdMFVoumFulGOp2uPGPqHO9Bkk= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:16.0519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c757881a-829b-428d-1967-08dcf92b7189 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: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0583 X-BESS-ID: 1730324418-312176-12713-40686-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGBpaWQGYGUNTMwjzF1CQpLc 3YMsUwycLUOMUgKcnMNMnIzMwk2dwsVak2FgD2IHwDQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan16-249.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Danylo Vodopianov The Categorizer module’s main purpose is to is select the behavior of other modules in the FPGA pipeline depending on a protocol check. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 24 ++ .../ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c | 267 ++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 165 +++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 47 +++ .../profile_inline/flow_api_profile_inline.c | 83 ++++++ 5 files changed, 586 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 1b45ea4296..87fc16ecb4 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -315,11 +315,35 @@ int hw_mod_cat_reset(struct flow_api_backend_s *be); int hw_mod_cat_cfn_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_cfn_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, int word_off, uint32_t value); +/* KCE/KCS/FTE KM */ +int hw_mod_cat_fte_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_fte_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); +/* KCE/KCS/FTE FLM */ +int hw_mod_cat_fte_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count); +int hw_mod_cat_fte_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value); +int hw_mod_cat_fte_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value); int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value); + int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value); + int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_cat_cot_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value); + int hw_mod_cat_cct_flush(struct flow_api_backend_s *be, int start_idx, int count); + int hw_mod_cat_kcc_flush(struct flow_api_backend_s *be, int start_idx, int count); int hw_mod_cat_exo_flush(struct flow_api_backend_s *be, int start_idx, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c index d266760123..9164ec1ae0 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_cat.c @@ -951,6 +951,97 @@ static int hw_mod_cat_fte_flush(struct flow_api_backend_s *be, enum km_flm_if_se return be->iface->cat_fte_flush(be->be_dev, &be->cat, km_if_idx, start_idx, count); } +int hw_mod_cat_fte_km_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_fte_flush(be, if_num, 0, start_idx, count); +} + +int hw_mod_cat_fte_flm_flush(struct flow_api_backend_s *be, enum km_flm_if_select_e if_num, + int start_idx, int count) +{ + return hw_mod_cat_fte_flush(be, if_num, 1, start_idx, count); +} + +static int hw_mod_cat_fte_mod(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int km_if_id, int index, + uint32_t *value, int get) +{ + const uint32_t key_cnt = (_VER_ >= 20) ? 4 : 2; + + if ((unsigned int)index >= (be->cat.nb_cat_funcs / 8 * be->cat.nb_flow_types * key_cnt)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + /* find KM module */ + int km_if_idx = find_km_flm_module_interface_index(be, if_num, km_if_id); + + if (km_if_idx < 0) + return km_if_idx; + + switch (_VER_) { + case 18: + switch (field) { + case HW_CAT_FTE_ENABLE_BM: + GET_SET(be->cat.v18.fte[index].enable_bm, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18 */ + case 21: + switch (field) { + case HW_CAT_FTE_ENABLE_BM: + GET_SET(be->cat.v21.fte[index].enable_bm[km_if_idx], value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_fte_km_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 0, index, &value, 0); +} + +int hw_mod_cat_fte_km_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 0, index, value, 1); +} + +int hw_mod_cat_fte_flm_set(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 1, index, &value, 0); +} + +int hw_mod_cat_fte_flm_get(struct flow_api_backend_s *be, enum hw_cat_e field, + enum km_flm_if_select_e if_num, int index, uint32_t *value) +{ + return hw_mod_cat_fte_mod(be, field, if_num, 1, index, value, 1); +} + int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) @@ -964,6 +1055,45 @@ int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->cat_cte_flush(be->be_dev, &be->cat, start_idx, count); } +static int hw_mod_cat_cte_mod(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= be->cat.nb_cat_funcs) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 18: + case 21: + switch (field) { + case HW_CAT_CTE_ENABLE_BM: + GET_SET(be->cat.v18.cte[index].enable_bm, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18/21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_cte_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value) +{ + return hw_mod_cat_cte_mod(be, field, index, &value, 0); +} + int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count) { int addr_size = (_VER_ < 15) ? 8 : ((be->cat.cts_num + 1) / 2); @@ -979,6 +1109,51 @@ int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->cat_cts_flush(be->be_dev, &be->cat, start_idx, count); } +static int hw_mod_cat_cts_mod(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value, int get) +{ + int addr_size = (be->cat.cts_num + 1) / 2; + + if ((unsigned int)index >= (be->cat.nb_cat_funcs * addr_size)) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 18: + case 21: + switch (field) { + case HW_CAT_CTS_CAT_A: + GET_SET(be->cat.v18.cts[index].cat_a, value); + break; + + case HW_CAT_CTS_CAT_B: + GET_SET(be->cat.v18.cts[index].cat_b, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18/21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_cts_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value) +{ + return hw_mod_cat_cts_mod(be, field, index, &value, 0); +} + int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) @@ -992,6 +1167,98 @@ int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count return be->iface->cat_cot_flush(be->be_dev, &be->cat, start_idx, count); } +static int hw_mod_cat_cot_mod(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t *value, int get) +{ + if ((unsigned int)index >= be->max_categories) { + INDEX_TOO_LARGE_LOG; + return INDEX_TOO_LARGE; + } + + switch (_VER_) { + case 18: + case 21: + switch (field) { + case HW_CAT_COT_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->cat.v18.cot[index], (uint8_t)*value, + sizeof(struct cat_v18_cot_s)); + break; + + case HW_CAT_COT_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->cat.v18.cot, struct cat_v18_cot_s, index, *value); + break; + + case HW_CAT_COT_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->cat.v18.cot, struct cat_v18_cot_s, index, *value, + be->max_categories); + break; + + case HW_CAT_COT_COPY_FROM: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memcpy(&be->cat.v18.cot[index], &be->cat.v18.cot[*value], + sizeof(struct cat_v18_cot_s)); + break; + + case HW_CAT_COT_COLOR: + GET_SET(be->cat.v18.cot[index].color, value); + break; + + case HW_CAT_COT_KM: + GET_SET(be->cat.v18.cot[index].km, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + /* end case 18/21 */ + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_cat_cot_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, + uint32_t value) +{ + return hw_mod_cat_cot_mod(be, field, index, &value, 0); +} + int hw_mod_cat_cct_flush(struct flow_api_backend_s *be, int start_idx, int count) { if (count == ALL_ENTRIES) 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 4ea9387c80..addd5f288f 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 @@ -22,6 +22,14 @@ struct hw_db_inline_resource_db { uint32_t nb_cot; + /* Items */ + struct hw_db_inline_resource_db_cat { + struct hw_db_inline_cat_data data; + int ref; + } *cat; + + uint32_t nb_cat; + /* Hardware */ struct hw_db_inline_resource_db_cfn { @@ -47,6 +55,14 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) 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)); + + if (db->cat == NULL) { + hw_db_inline_destroy(db); + return -1; + } + *db_handle = db; return 0; } @@ -56,6 +72,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->cat); free(db->cfn); @@ -70,6 +87,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct case HW_DB_IDX_TYPE_NONE: break; + case HW_DB_IDX_TYPE_CAT: + hw_db_inline_cat_deref(ndev, db_handle, *(struct hw_db_cat_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_COT: hw_db_inline_cot_deref(ndev, db_handle, *(struct hw_db_cot_idx *)&idxs[i]); break; @@ -80,6 +101,69 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct } } +/******************************************************************************/ +/* Filter */ +/******************************************************************************/ + +/* + * Setup a filter to match: + * All packets in CFN checks + * All packets in KM + * All packets in FLM with look-up C FT equal to specified argument + * + * Setup a QSL recipe to DROP all matching packets + * + * Note: QSL recipe 0 uses DISCARD in order to allow for exception paths (UNMQ) + * Consequently another QSL recipe with hard DROP is needed + */ +int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, + uint32_t qsl_hw_id) +{ + (void)ft; + (void)qsl_hw_id; + + const int offset = ((int)ndev->be.cat.cts_num + 1) / 2; + (void)offset; + + /* Select and enable QSL recipe */ + if (hw_mod_cat_cts_set(&ndev->be, HW_CAT_CTS_CAT_B, offset * cat_hw_id + 1, qsl_hw_id)) + return -1; + + if (hw_mod_cat_cts_flush(&ndev->be, offset * cat_hw_id, 6)) + return -1; + + if (hw_mod_cat_cte_set(&ndev->be, HW_CAT_CTE_ENABLE_BM, cat_hw_id, 0x8)) + return -1; + + if (hw_mod_cat_cte_flush(&ndev->be, cat_hw_id, 1)) + return -1; + + /* Make all CFN checks TRUE */ + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_SET_ALL_DEFAULTS, cat_hw_id, 0, 0)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_ENABLE, cat_hw_id, 0, 0x1)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_L3, cat_hw_id, 0, 0x0)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_INV, cat_hw_id, 0, 0x1)) + return -1; + + /* Final match: look-up_A == TRUE && look-up_C == TRUE */ + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_KM0_OR, cat_hw_id, 0, 0x1)) + return -1; + + if (hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_KM1_OR, cat_hw_id, 0, 0x3)) + return -1; + + if (hw_mod_cat_cfn_flush(&ndev->be, cat_hw_id, 1)) + return -1; + + return 0; +} + /******************************************************************************/ /* COT */ /******************************************************************************/ @@ -150,3 +234,84 @@ void hw_db_inline_cot_deref(struct flow_nic_dev *ndev __rte_unused, void *db_han db->cot[idx.ids].ref = 0; } } + +/******************************************************************************/ +/* CAT */ +/******************************************************************************/ + +static int hw_db_inline_cat_compare(const struct hw_db_inline_cat_data *data1, + const struct hw_db_inline_cat_data *data2) +{ + return data1->vlan_mask == data2->vlan_mask && + data1->mac_port_mask == data2->mac_port_mask && + data1->ptc_mask_frag == data2->ptc_mask_frag && + data1->ptc_mask_l2 == data2->ptc_mask_l2 && + data1->ptc_mask_l3 == data2->ptc_mask_l3 && + data1->ptc_mask_l4 == data2->ptc_mask_l4 && + data1->ptc_mask_tunnel == data2->ptc_mask_tunnel && + data1->ptc_mask_l3_tunnel == data2->ptc_mask_l3_tunnel && + data1->ptc_mask_l4_tunnel == data2->ptc_mask_l4_tunnel && + data1->err_mask_ttl_tunnel == data2->err_mask_ttl_tunnel && + data1->err_mask_ttl == data2->err_mask_ttl && data1->ip_prot == data2->ip_prot && + data1->ip_prot_tunnel == data2->ip_prot_tunnel; +} + +struct hw_db_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_cat_data *data) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_cat_idx idx = { .raw = 0 }; + int found = 0; + + idx.type = HW_DB_IDX_TYPE_CAT; + + for (uint32_t i = 0; i < db->nb_cat; ++i) { + int ref = db->cat[i].ref; + + if (ref > 0 && hw_db_inline_cat_compare(data, &db->cat[i].data)) { + idx.ids = i; + hw_db_inline_cat_ref(ndev, db, idx); + return idx; + } + + if (!found && ref <= 0) { + found = 1; + idx.ids = i; + } + } + + if (!found) { + idx.error = 1; + return idx; + } + + db->cat[idx.ids].ref = 1; + memcpy(&db->cat[idx.ids].data, data, sizeof(struct hw_db_inline_cat_data)); + + return idx; +} + +void hw_db_inline_cat_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->cat[idx.ids].ref += 1; +} + +void hw_db_inline_cat_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + db->cat[idx.ids].ref -= 1; + + if (db->cat[idx.ids].ref <= 0) { + memset(&db->cat[idx.ids].data, 0x0, sizeof(struct hw_db_inline_cat_data)); + db->cat[idx.ids].ref = 0; + } +} 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 0116af015d..38502ac1ec 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 @@ -36,12 +36,37 @@ struct hw_db_cot_idx { HW_DB_IDX; }; +struct hw_db_cat_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, }; /* Functionality data types */ +struct hw_db_inline_cat_data { + uint32_t vlan_mask : 4; + uint32_t mac_port_mask : 8; + uint32_t ptc_mask_frag : 4; + uint32_t ptc_mask_l2 : 7; + uint32_t ptc_mask_l3 : 3; + uint32_t ptc_mask_l4 : 5; + uint32_t padding0 : 1; + + uint32_t ptc_mask_tunnel : 11; + uint32_t ptc_mask_l3_tunnel : 3; + uint32_t ptc_mask_l4_tunnel : 5; + uint32_t err_mask_ttl_tunnel : 2; + uint32_t err_mask_ttl : 2; + uint32_t padding1 : 9; + + uint8_t ip_prot; + uint8_t ip_prot_tunnel; +}; + struct hw_db_inline_qsl_data { uint32_t discard : 1; uint32_t drop : 1; @@ -70,6 +95,16 @@ struct hw_db_inline_hsh_data { uint8_t key[MAX_RSS_KEY_LEN]; }; +struct hw_db_inline_action_set_data { + int contains_jump; + union { + int jump; + struct { + struct hw_db_cot_idx cot; + }; + }; +}; + /**/ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); @@ -84,4 +119,16 @@ 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_cat_idx hw_db_inline_cat_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_cat_data *data); +void hw_db_inline_cat_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx); +void hw_db_inline_cat_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_cat_idx idx); + +/**/ + +int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, uint32_t ft, + uint32_t qsl_hw_id); + #endif /* _FLOW_API_HW_DB_INLINE_H_ */ 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 7b932c7cc5..3cfeee2c25 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 @@ -21,6 +21,10 @@ #define NT_FLM_OP_UNLEARN 0 #define NT_FLM_OP_LEARN 1 +#define NT_FLM_VIOLATING_MBR_FLOW_TYPE 15 +#define NT_VIOLATING_MBR_CFN 0 +#define NT_VIOLATING_MBR_QSL 1 + static void *flm_lrn_queue_arr; static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) @@ -2346,6 +2350,67 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n /* * Flow for group 0 */ + struct hw_db_inline_action_set_data action_set_data = { 0 }; + (void)action_set_data; + + if (fd->jump_to_group != UINT32_MAX) { + /* Action Set only contains jump */ + action_set_data.contains_jump = 1; + action_set_data.jump = fd->jump_to_group; + + } else { + /* Action Set doesn't contain jump */ + action_set_data.contains_jump = 0; + + /* Setup COT */ + struct hw_db_inline_cot_data cot_data = { + .matcher_color_contrib = 0, + .frag_rcp = 0, + }; + struct hw_db_cot_idx cot_idx = + hw_db_inline_cot_add(dev->ndev, dev->ndev->hw_db_handle, + &cot_data); + fh->db_idxs[fh->db_idx_counter++] = cot_idx.raw; + action_set_data.cot = cot_idx; + + if (cot_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference COT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + } + + /* Setup CAT */ + struct hw_db_inline_cat_data cat_data = { + .vlan_mask = (0xf << fd->vlans) & 0xf, + .mac_port_mask = 1 << fh->port_id, + .ptc_mask_frag = fd->fragmentation, + .ptc_mask_l2 = fd->l2_prot != -1 ? (1 << fd->l2_prot) : -1, + .ptc_mask_l3 = fd->l3_prot != -1 ? (1 << fd->l3_prot) : -1, + .ptc_mask_l4 = fd->l4_prot != -1 ? (1 << fd->l4_prot) : -1, + .err_mask_ttl = (fd->ttl_sub_enable && + fd->ttl_sub_outer) ? -1 : 0x1, + .ptc_mask_tunnel = fd->tunnel_prot != + -1 ? (1 << fd->tunnel_prot) : -1, + .ptc_mask_l3_tunnel = + fd->tunnel_l3_prot != -1 ? (1 << fd->tunnel_l3_prot) : -1, + .ptc_mask_l4_tunnel = + fd->tunnel_l4_prot != -1 ? (1 << fd->tunnel_l4_prot) : -1, + .err_mask_ttl_tunnel = + (fd->ttl_sub_enable && !fd->ttl_sub_outer) ? -1 : 0x1, + .ip_prot = fd->ip_prot, + .ip_prot_tunnel = fd->tunnel_ip_prot, + }; + struct hw_db_cat_idx cat_idx = + hw_db_inline_cat_add(dev->ndev, dev->ndev->hw_db_handle, &cat_data); + fh->db_idxs[fh->db_idx_counter++] = cat_idx.raw; + + if (cat_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference CAT resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + nic_insert_flow(dev->ndev, fh); } @@ -2378,6 +2443,20 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) /* Check static arrays are big enough */ assert(ndev->be.tpe.nb_cpy_writers <= MAX_CPY_WRITERS_SUPPORTED); + /* COT is locked to CFN. Don't set color for CFN 0 */ + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, 0, 0); + + if (hw_mod_cat_cot_flush(&ndev->be, 0, 1) < 0) + goto err_exit0; + + /* Setup filter using matching all packets violating traffic policing parameters */ + flow_nic_mark_resource_used(ndev, RES_CAT_CFN, NT_VIOLATING_MBR_CFN); + + if (hw_db_inline_setup_mbr_filter(ndev, NT_VIOLATING_MBR_CFN, + NT_FLM_VIOLATING_MBR_FLOW_TYPE, + NT_VIOLATING_MBR_QSL) < 0) + goto err_exit0; + ndev->id_table_handle = ntnic_id_table_create(); if (ndev->id_table_handle == NULL) @@ -2412,6 +2491,10 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_group_handle_destroy(&ndev->group_handle); ntnic_id_table_destroy(ndev->id_table_handle); + hw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PRESET_ALL, 0, 0, 0); + hw_mod_cat_cfn_flush(&ndev->be, 0, 1); + hw_mod_cat_cot_set(&ndev->be, HW_CAT_COT_PRESET_ALL, 0, 0); + hw_mod_cat_cot_flush(&ndev->be, 0, 1); flow_nic_free_resource(ndev, RES_CAT_CFN, 0); hw_mod_tpe_reset(&ndev->be); -- 2.45.0