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 C49B645BB4; Wed, 23 Oct 2024 19:04:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F50D42FA7; Wed, 23 Oct 2024 19:01:35 +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 6056E42F19 for ; Wed, 23 Oct 2024 19:01:09 +0200 (CEST) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2041.outbound.protection.outlook.com [104.47.11.41]) by mx-outbound15-83.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:01:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=COLkfgckC2IrcDofOW2Pts9MnNI2jSpGy4c0u3Lg3uol2peC5SWj4NJtmyt+HmnrDqy7vsuS2bVdauBxRIstAoBFVxB55ucsy9kzmy2tk/4MISkiBWOJDkuUWIKrCqpZE6mvckEIQKbcmu34Wv/llLsLJIXvOwKcP+wyZ7RBMXVLOPDqXPKZJdXBayHlQkYjz86DQNAHbI/I3dAj73xYJI0xGGSubg86hahQkIumeVfevt51Ib42/GzlFcpzFvQyNMdiH3hp36B6Th+7QbZfsz9ObWE4q0Ugp0AYK81BMRFnUOR8/zoDq3XkLGLw1I2o5s+Yp1L2+F8pbZ8UqrYtxw== 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=JStiuNE8+WoHECGUJb/V9ITdmiW6nmPVhzstaM8uG8Q=; b=TsYe18aOdyiA4iCfoobbeAvBcN0UNfZQtE+zSL2pTNSUy+9ertKnC2zEcpvfr/2i3gdfCInJ260ReoibSgtS4X51cOsLPzfaIVN7y0FXtIj9hXiwCJGtLoPjIxpnyo8JpSnm0rFjvaVFeai2rdwQp0HOrxvjbl1W5T49A5s4hN5Kk7sb0KFZZBof2F1ycE36Vv6//CR+N133+R2S6AwDZfpAA393C7dMpmaYpzhMYzLJWzs6b0WKjAW0/Pp//S6cqOoM4UFoAKg8Q5nVkXMJmIEmNUDrdWyfMQy3r3biuISCYowdx+ApuC3fbuoA8qi9q4yUZiPORcb77PPB5RHcZA== 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=JStiuNE8+WoHECGUJb/V9ITdmiW6nmPVhzstaM8uG8Q=; b=bOLwZhrKCEJ/SWCBATNwbss/kijjcbS2VtwPc0LvZJwf2mj+Tm1BgSVoCjyHReZgOsYIEVqGl+X/Lth2qr8FKRMU5/J+X14aYfhdJDqIoNORDxP2RQZfFn/x129vnBD9AZ7iDAnXm1uT6cqRrPfxn+ydMaltWZYKMJhotECh7jw= Received: from DU7PR01CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::21) by AM9P190MB1250.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:272::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Wed, 23 Oct 2024 17:01:05 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::87) by DU7PR01CA0014.outlook.office365.com (2603:10a6:10:50f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Wed, 23 Oct 2024 17:01:05 +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 26/73] net/ntnic: add cat module Date: Wed, 23 Oct 2024 18:59:34 +0200 Message-ID: <20241023170032.314155-27-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9E:EE_|AM9P190MB1250:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ad6d5f7-143b-4f73-1a84-08dcf384484f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024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JsbktPWTh6Q05yellyZkl6K3dUbitkemlBcDJzdkp0Q1crWE9uYzQx?= =?utf-8?B?eWJhaTBudlRHTjRkWVI5NFMwSzRvVW0yWHV2QTJHa1JqTWVFSEJzVkVOTnlj?= =?utf-8?B?VUF6ZTF2MGdoUkUvQzhKZWswa1BObTYvcVdEbzdTajdpcVE9PQ==?= 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)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: glaTKwoGvzfUT8JSGJKgHnRFp4n1LPvEH+epnvthltekcfvtFp80ilcDPobl0lks+CiMh8wO3yj8QkhWkZxFBgeWIQLSBCOZYj7dQa22S8BCBB0BHy6Ww+AlRHkhHOeThnf/2rkzvqb9m0JRHSY610Tca88/KgckzXDdoGqRt4G7RB1M4WALfr4JvdN4LcfHy8so4oSUiUshLpjoz+kAJlv81FBNOEVDvuEvBRQtfnF5CWKvM+Jx908aetON+RaAY7aqTznzv7yzTf8vvgpWoegneh8umipjQzn1bhjV5AuR3+sO01Z6O40ErF0U74hJ60RJ72gWa2mg2WinxKv/AMx4pZ9OG8Sn6T06gzfTcEyDHukFs1nsmCsK/D+dCUmkQtIzXLNQTKB0FClipafiqfi3vSopPODbl9b6l8QsZKJK7A5BwG7Xv/EFHqmyhEziMJSIE0pDaC0o8V07rN4IX6r4Lc0Zk9qWGymhDfpgl7quI8FxlUA86drpEU9SzYSatGxUBia0fxl6E0lOIPXk+WX5kioSxjdro6nIOGWar0QHzYjpbv/7sIPsri7zJV4tL+S0SFnMjTZg928/1NbOXIBJIhWAe49JydbWhwCA7IJuHgemdP2fVS8tGGEXPzdzTlrfgesr//xqbd4BZfcZfK3PZn68HbfkUXSnoaUBwEw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:01:05.0706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ad6d5f7-143b-4f73-1a84-08dcf384484f 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: AM9P190MB1250 X-BESS-ID: 1729702867-303923-12645-44306-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.41 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbGBpaWQGYGUDQ52cw01cAwxS Qlzcg4OcU40djCxNzYIDnJJCUxOSXJRKk2FgA4UoY6QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 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.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 9fc4908975..5176464054 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) @@ -2347,6 +2351,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); } @@ -2379,6 +2444,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) @@ -2413,6 +2492,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