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 A5E9745BCC; Wed, 30 Oct 2024 22:43:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50EF8434CF; Wed, 30 Oct 2024 22:41:29 +0100 (CET) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 46CB1434C2 for ; Wed, 30 Oct 2024 22:40:31 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2172.outbound.protection.outlook.com [104.47.17.172]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bQQp1UjRbzJynrvUGolGXovrxiZmIwB1acTnTBZdycO3Ik2vq/7kkg8+uiW/AfFnoetGFGeATJHGE1cThg/4iPQ5YoE1z4vT59Stfw7yoW3nnwXLiC0edYINLO4+HoMrX5awF0Yh0YwyA5chv9Z+AbldSNqaXCZqxDbhj3EfWx98ujcP4yNXrN1G9Z1+Jb8mCOK1uOCf9CUKWskzMiJouYDZUMzqHWqIBefDZhL/rBjZSFFjZMAkdiN1LZsAWvuFy6bUgwgNhIyeFX3XfgHEWZX6hjPvGNab4qmS471BHR3P7T2Uam3UVlhCWgLeTc8/R8nRWNt2+ewWsgrcTvXNWg== 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=c69klxs37gBcECm5daSDClNBQLrPAVqPAP0Ir/WhNGs=; b=g5tWGNUrbLMqKK7iOxa4rnrddYnR2gsWa/Q0kRoRtSZOKv9Ba9DVGgmT9FonNZ/Mu/6Ek0+F9VS209CxClchSHinNGuGvXi2pr0QW5FuyfMSnk+vNbYEnaH/4rh1DOSsxNlqJbXLTiapXUhmglWR+IbmlRNQcyY8jVQQk0aVeoUhKM9LDg9tCIw6fQ75zd6qq9AV+KO5GqCzpd9NaPquvfbgzyvXR6qzBZYCJMyoBWUK1i1P5O4yDxe4ys+XlGqiOsZX0ih1iqvqN6WUoFHgOpOzcl21goui5Z2CjfV+1oLs+D1pDvRXot4Du8l//+Rh9Xc0LjpSf6Psi5j3hzVONg== 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=c69klxs37gBcECm5daSDClNBQLrPAVqPAP0Ir/WhNGs=; b=qB1VbdO9ldafueGA3HFmFWW6Wvem7VLsKIuZHoH8/GlnxYx3a7CwPeJrJimSJCgT0wttNIlgzn4lPYWE0w9f4J1NWz4Z8wvHLsiYaDJTvCKsNrhbcCkWHfzakHOfetGJjpJjQ0yCKhSwIhzRK1c7GGXs8G8G+Bs1Kmgp+TYyuYI= Received: from DUZPR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::13) by VE1P190MB0927.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1b1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 21:40:24 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::f4) by DUZPR01CA0006.outlook.office365.com (2603:10a6:10:3c3::13) 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:24 +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:24 +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 34/80] net/ntnic: add FLM RCP module Date: Wed, 30 Oct 2024 22:38:41 +0100 Message-ID: <20241030213940.3470062-35-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-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|VE1P190MB0927:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: bad72b4a-91f0-4d7e-6d4f-08dcf92b764b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JsArJFdMLLogsiyUzcCFENeRC/bR1z2tPnzgcHQF1xHrzkTtNZ0WgM4iYE6p?= =?us-ascii?Q?b2ekVjkzo06iXNyP7Nnid038CsNVAXdxdxx7nk5h7HV+QXGxk4VCGqXIWil/?= =?us-ascii?Q?Ij2I3GQVYoBKkZGGaSld0AKMfak8Cene6FFuPJwxPQl25anINAx8hbrykSuS?= =?us-ascii?Q?UDs7HQNDtaiki3iYipoarosg6wGWbMhXbIANZRjp7C8jcmdac8S38iCpbC4Y?= =?us-ascii?Q?/41n4T5o/7y4VdyS1xlah1Ej5il4Iv5UcGhqMRY9eIWHO2iCUvnAYheLPS13?= =?us-ascii?Q?AZqH6zskiWfKzMvbzMv7ZGvzbRiD8Jm+HT3HILu8g/IQdCbJhrAu88YHqsl+?= =?us-ascii?Q?In763maC77XSzvUVkpPYYDuf3kLeg/zm+EcGPIEBpLc5Zj62UK3UscYe8ggb?= =?us-ascii?Q?8+QHqco+hpAxazHWPCDMWCETcv+KA2xvkYi3fcxFndVVu0UZknJ9ZCARyw0I?= =?us-ascii?Q?zPmC+tJBQaq+iDgMs2kjAbczYEvS5rXrHCnU1NSx6bpnZrlRr8/U+qrEUQjY?= =?us-ascii?Q?jI7P3loXI5zgL2PF2IGU6UzoFss49ndlt3dXyxeX+D4HD4cX5YMHDCQW3+Tt?= =?us-ascii?Q?mf200hHIS4X5Ijqgw1XMhx6eWYgNBcbg+xH6mUpALKigttrkYBYm4yt4UWcJ?= =?us-ascii?Q?8f/ohhfYMldtuKVDaA5ztkV0d5fNvxHqv4dX6w6u6g5jXiV9RqShc2VCDfxh?= =?us-ascii?Q?OSNXzVN4CsC+qqbNFXKHqoe8+nvaUGVUSbeonMeD5m2Xq4fqFdPunYaQcGrG?= =?us-ascii?Q?8DxPRSi+MtaBCRycRrkSPe6FaGWsCimkT2HapPBRtOeulLAr46GvRm/649wa?= =?us-ascii?Q?i9cw8wcKwT/8sQUD4PGOpQSaeXuVO0j4UBLdR9b+kaYggfqmPFmCbgUhU7Tk?= =?us-ascii?Q?J29jL/3xCEPSAiuIUctaPr1xqMw8PEgfeHsAENw5t3dHglXuLF4kQ85PAIiR?= =?us-ascii?Q?4ZU/rOhNwr5IVGzTJmb3YMPSaE/Dchua7f+bIRFuh6/waAQprBpnUsCWRfYX?= =?us-ascii?Q?Jw41REU1SBWPkOXbTF00vEln8vGudEGBN9OdiZ1wgSdInp0HcpR9ujTnC77d?= =?us-ascii?Q?weRUMdt/qa/8XthOd0PFE6QBAyqypCifew5vigmVKcYu09DFdnp1wLBYFlB2?= =?us-ascii?Q?BONYH6AXcqtmiP91E5bgH7fFHji4Sw9CWKA5v7xKbN0+1SFI2WrwhjGXt8WI?= =?us-ascii?Q?/qUes/6ktyT5+C50prLYvXS3Mp4tkKoXGlPIbc4T+bRXqh1PbmeZZXHgn0De?= =?us-ascii?Q?2TiytSjM0FlbdFTkilxiiq+cz2IDVCN+exksC/CXVokcDEbsgZrAK+0mLIUn?= =?us-ascii?Q?jjSFh+eAQmtakQ/uSU9/b3TMfXk/H73Jly4vCoAyqsvhRwGvnsNle1SPIhKS?= =?us-ascii?Q?5Yu7OIfq4pVLd9k0K8nnh2sKU7WZ7tbZgFIQFxLGFjQLbZvoBg=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)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +AFJueE6M7echc6+uZHLmGmA6UevdG4+yNQjbBgSMkG82lGpRnhB0YgRfJG+8uKg+K8RX8F022WBVRYH1PHNTgokUjkhKgOQFD7S0v1mvcHsTsiJZtmXtlEEt83dVM9/1BnP/rfP/BicV1Lv9EO58H9XnilHRNr93iCQ02/79KRdkMgz0u7X6cXQxqncR/mnil0P/PLlYZy6uEmfbYL5Xi7VdQIc9RcRCDmgEAlNaBzRTYj7VJltzVGlN2revRrcGWR+RPxUlnQ/LotvzufzmxrOBSpV139xcXMxnKLkf/XuabWzQLr9JQuCAynP1yB2xlr9Hm3miG4ppAOPT6O47gmvSIomhDpNQ2D1aFeexezW2lpV04iGbZdF5PymO3YLHqzPioUFXXTKfDfcfa40hSdo9f5lFJRAq9Cj43Y5RD5QxpKjRpcoMAoyGs4ZV9+wNbqg2su6XQHClZCJ6qSx0Ml4/f9rWVWd7AG7zsyz1FKvwCOo4U2i+RofKfvp7vS4qez1Ngu2HnM37Lgwu05N9ORoB0MIXyw/bOUgOja5X9Bs+hB4YpOSMvOJsqzncs/Cm7zJq7oUWQh72iCiG6F2JSH8+Gt8DbW59IACTyCpq5H9tV8z5OBJ4Cxjodkit9I1dFHQLwXYmW3fPgolswQfJldqhP73t7KXRO0hvtDSHQ0= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:24.0363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bad72b4a-91f0-4d7e-6d4f-08dcf92b764b 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: VE1P190MB0927 X-BESS-ID: 1730324427-304433-12632-44626-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.172 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWFiZmQGYGUDTVMDXJwCLNIM nELDnZwtjAyMjQ0MDCxCLFKDHZPCXNQqk2FgCuC+VzQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan20-80.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 Flow Matcher module is a high-performance stateful SDRAM lookup and programming engine which supported exact match lookup in line-rate of up to hundreds of millions of flows. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 4 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 133 ++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 195 +++++++++++++++++- .../profile_inline/flow_api_hw_db_inline.h | 20 ++ .../profile_inline/flow_api_profile_inline.c | 42 +++- 5 files changed, 390 insertions(+), 4 deletions(-) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index de662c4ed1..13722c30a9 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -683,6 +683,10 @@ int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int i uint32_t value); int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value); +int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value); int hw_mod_flm_scrub_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_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c index f5eaea7c4e..0a7e90c04f 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -579,3 +579,136 @@ int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int cou } return be->iface->flm_scrub_flush(be->be_dev, &be->flm, start_idx, count); } + +static int hw_mod_flm_rcp_mod(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->flm.v25.rcp[index], (uint8_t)*value, + sizeof(struct flm_v25_rcp_s)); + break; + + case HW_FLM_RCP_LOOKUP: + GET_SET(be->flm.v25.rcp[index].lookup, value); + break; + + case HW_FLM_RCP_QW0_DYN: + GET_SET(be->flm.v25.rcp[index].qw0_dyn, value); + break; + + case HW_FLM_RCP_QW0_OFS: + GET_SET(be->flm.v25.rcp[index].qw0_ofs, value); + break; + + case HW_FLM_RCP_QW0_SEL: + GET_SET(be->flm.v25.rcp[index].qw0_sel, value); + break; + + case HW_FLM_RCP_QW4_DYN: + GET_SET(be->flm.v25.rcp[index].qw4_dyn, value); + break; + + case HW_FLM_RCP_QW4_OFS: + GET_SET(be->flm.v25.rcp[index].qw4_ofs, value); + break; + + case HW_FLM_RCP_SW8_DYN: + GET_SET(be->flm.v25.rcp[index].sw8_dyn, value); + break; + + case HW_FLM_RCP_SW8_OFS: + GET_SET(be->flm.v25.rcp[index].sw8_ofs, value); + break; + + case HW_FLM_RCP_SW8_SEL: + GET_SET(be->flm.v25.rcp[index].sw8_sel, value); + break; + + case HW_FLM_RCP_SW9_DYN: + GET_SET(be->flm.v25.rcp[index].sw9_dyn, value); + break; + + case HW_FLM_RCP_SW9_OFS: + GET_SET(be->flm.v25.rcp[index].sw9_ofs, value); + break; + + case HW_FLM_RCP_MASK: + if (get) { + memcpy(value, be->flm.v25.rcp[index].mask, + sizeof(((struct flm_v25_rcp_s *)0)->mask)); + + } else { + memcpy(be->flm.v25.rcp[index].mask, value, + sizeof(((struct flm_v25_rcp_s *)0)->mask)); + } + + break; + + case HW_FLM_RCP_KID: + GET_SET(be->flm.v25.rcp[index].kid, value); + break; + + case HW_FLM_RCP_OPN: + GET_SET(be->flm.v25.rcp[index].opn, value); + break; + + case HW_FLM_RCP_IPN: + GET_SET(be->flm.v25.rcp[index].ipn, value); + break; + + case HW_FLM_RCP_BYT_DYN: + GET_SET(be->flm.v25.rcp[index].byt_dyn, value); + break; + + case HW_FLM_RCP_BYT_OFS: + GET_SET(be->flm.v25.rcp[index].byt_ofs, value); + break; + + case HW_FLM_RCP_TXPLM: + GET_SET(be->flm.v25.rcp[index].txplm, value); + break; + + case HW_FLM_RCP_AUTO_IPV4_MASK: + GET_SET(be->flm.v25.rcp[index].auto_ipv4_mask, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value) +{ + if (field != HW_FLM_RCP_MASK) + return UNSUP_VER; + + return hw_mod_flm_rcp_mod(be, field, index, value, 0); +} + +int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value) +{ + if (field == HW_FLM_RCP_MASK) + return UNSUP_VER; + + return hw_mod_flm_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 61492090ce..0ae058b91e 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 @@ -68,6 +68,9 @@ struct hw_db_inline_resource_db { } *cat; struct hw_db_inline_resource_db_flm_rcp { + struct hw_db_inline_flm_rcp_data data; + int ref; + struct hw_db_inline_resource_db_flm_ft { struct hw_db_inline_flm_ft_data data; struct hw_db_flm_ft idx; @@ -96,6 +99,7 @@ struct hw_db_inline_resource_db { uint32_t nb_cat; uint32_t nb_flm_ft; + uint32_t nb_flm_rcp; uint32_t nb_km_ft; uint32_t nb_km_rcp; @@ -164,6 +168,42 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + + db->nb_flm_ft = ndev->be.cat.nb_flow_types; + db->nb_flm_rcp = ndev->be.flm.nb_categories; + db->flm = calloc(db->nb_flm_rcp, sizeof(struct hw_db_inline_resource_db_flm_rcp)); + + if (db->flm == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) { + db->flm[i].ft = + calloc(db->nb_flm_ft, sizeof(struct hw_db_inline_resource_db_flm_ft)); + + if (db->flm[i].ft == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->flm[i].match_set = + calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_flm_match_set)); + + if (db->flm[i].match_set == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->flm[i].cfn_map = calloc(db->nb_cat * db->nb_flm_ft, + sizeof(struct hw_db_inline_resource_db_flm_cfn_map)); + + if (db->flm[i].cfn_map == NULL) { + hw_db_inline_destroy(db); + return -1; + } + } + db->nb_km_ft = ndev->be.cat.nb_flow_types; db->nb_km_rcp = ndev->be.km.nb_categories; db->km = calloc(db->nb_km_rcp, sizeof(struct hw_db_inline_resource_db_km_rcp)); @@ -222,6 +262,16 @@ void hw_db_inline_destroy(void *db_handle) free(db->cat); + if (db->flm) { + for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) { + free(db->flm[i].ft); + free(db->flm[i].match_set); + free(db->flm[i].cfn_map); + } + + free(db->flm); + } + if (db->km) { for (uint32_t i = 0; i < db->nb_km_rcp; ++i) free(db->km[i].ft); @@ -268,6 +318,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_tpe_ext_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_FLM_RCP: + hw_db_inline_flm_deref(ndev, db_handle, *(struct hw_db_flm_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_FLM_FT: hw_db_inline_flm_ft_deref(ndev, db_handle, *(struct hw_db_flm_ft *)&idxs[i]); @@ -324,6 +378,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_TPE_EXT: return &db->tpe_ext[idxs[i].ids].data; + case HW_DB_IDX_TYPE_FLM_RCP: + return &db->flm[idxs[i].id1].data; + case HW_DB_IDX_TYPE_FLM_FT: return NULL; /* FTs can't be easily looked up */ @@ -481,6 +538,20 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, return 0; } +static void hw_db_inline_setup_default_flm_rcp(struct flow_nic_dev *ndev, int flm_rcp) +{ + uint32_t flm_mask[10]; + memset(flm_mask, 0xff, sizeof(flm_mask)); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, flm_rcp, 0x0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, flm_rcp, 1); + hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, flm_rcp, flm_mask); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, flm_rcp, flm_rcp + 2); + + hw_mod_flm_rcp_flush(&ndev->be, flm_rcp, 1); +} + + /******************************************************************************/ /* COT */ /******************************************************************************/ @@ -1268,10 +1339,17 @@ void hw_db_inline_km_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_d void hw_db_inline_km_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx) { (void)ndev; - (void)db_handle; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; if (idx.error) return; + + db->flm[idx.id1].ref -= 1; + + if (db->flm[idx.id1].ref <= 0) { + memset(&db->flm[idx.id1].data, 0x0, sizeof(struct hw_db_inline_km_rcp_data)); + db->flm[idx.id1].ref = 0; + } } /******************************************************************************/ @@ -1359,6 +1437,121 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct km_rcp->ft[cat_offset + idx.id1].ref = 0; } } + +/******************************************************************************/ +/* FLM RCP */ +/******************************************************************************/ + +static int hw_db_inline_flm_compare(const struct hw_db_inline_flm_rcp_data *data1, + const struct hw_db_inline_flm_rcp_data *data2) +{ + if (data1->qw0_dyn != data2->qw0_dyn || data1->qw0_ofs != data2->qw0_ofs || + data1->qw4_dyn != data2->qw4_dyn || data1->qw4_ofs != data2->qw4_ofs || + data1->sw8_dyn != data2->sw8_dyn || data1->sw8_ofs != data2->sw8_ofs || + data1->sw9_dyn != data2->sw9_dyn || data1->sw9_ofs != data2->sw9_ofs || + data1->outer_prot != data2->outer_prot || data1->inner_prot != data2->inner_prot) { + return 0; + } + + for (int i = 0; i < 10; ++i) + if (data1->mask[i] != data2->mask[i]) + return 0; + + return 1; +} + +struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_rcp_data *data, int group) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_flm_idx idx = { .raw = 0 }; + + idx.type = HW_DB_IDX_TYPE_FLM_RCP; + idx.id1 = group; + + if (group == 0) + return idx; + + if (db->flm[idx.id1].ref > 0) { + if (!hw_db_inline_flm_compare(data, &db->flm[idx.id1].data)) { + idx.error = 1; + return idx; + } + + hw_db_inline_flm_ref(ndev, db, idx); + return idx; + } + + db->flm[idx.id1].ref = 1; + memcpy(&db->flm[idx.id1].data, data, sizeof(struct hw_db_inline_flm_rcp_data)); + + { + uint32_t flm_mask[10] = { + data->mask[0], /* SW9 */ + data->mask[1], /* SW8 */ + data->mask[5], data->mask[4], data->mask[3], data->mask[2], /* QW4 */ + data->mask[9], data->mask[8], data->mask[7], data->mask[6], /* QW0 */ + }; + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, idx.id1, 0x0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, idx.id1, 1); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_DYN, idx.id1, data->qw0_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_OFS, idx.id1, data->qw0_ofs); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_SEL, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_DYN, idx.id1, data->qw4_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_OFS, idx.id1, data->qw4_ofs); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_DYN, idx.id1, data->sw8_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_OFS, idx.id1, data->sw8_ofs); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_SEL, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_DYN, idx.id1, data->sw9_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_OFS, idx.id1, data->sw9_ofs); + + hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, idx.id1, flm_mask); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, idx.id1, idx.id1 + 2); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_OPN, idx.id1, data->outer_prot ? 1 : 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_IPN, idx.id1, data->inner_prot ? 1 : 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_DYN, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_OFS, idx.id1, -20); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_TXPLM, idx.id1, UINT32_MAX); + + hw_mod_flm_rcp_flush(&ndev->be, idx.id1, 1); + } + + return idx; +} + +void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->flm[idx.id1].ref += 1; +} + +void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + if (idx.id1 > 0) { + db->flm[idx.id1].ref -= 1; + + if (db->flm[idx.id1].ref <= 0) { + memset(&db->flm[idx.id1].data, 0x0, + sizeof(struct hw_db_inline_flm_rcp_data)); + db->flm[idx.id1].ref = 0; + + hw_db_inline_setup_default_flm_rcp(ndev, idx.id1); + } + } +} + /******************************************************************************/ /* FLM FT */ /******************************************************************************/ 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 a520ae1769..9820225ffa 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 @@ -138,6 +138,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_TPE, HW_DB_IDX_TYPE_TPE_EXT, + HW_DB_IDX_TYPE_FLM_RCP, HW_DB_IDX_TYPE_KM_RCP, HW_DB_IDX_TYPE_FLM_FT, HW_DB_IDX_TYPE_KM_FT, @@ -165,6 +166,22 @@ struct hw_db_inline_cat_data { uint8_t ip_prot_tunnel; }; +struct hw_db_inline_flm_rcp_data { + uint64_t qw0_dyn : 5; + uint64_t qw0_ofs : 8; + uint64_t qw4_dyn : 5; + uint64_t qw4_ofs : 8; + uint64_t sw8_dyn : 5; + uint64_t sw8_ofs : 8; + uint64_t sw9_dyn : 5; + uint64_t sw9_ofs : 8; + uint64_t outer_prot : 1; + uint64_t inner_prot : 1; + uint64_t padding : 10; + + uint32_t mask[10]; +}; + struct hw_db_inline_qsl_data { uint32_t discard : 1; uint32_t drop : 1; @@ -300,7 +317,10 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct /**/ +struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_rcp_data *data, int group); void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); +void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_inline_flm_ft_data *data); 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 46ea70df20..7a0cb1f9c4 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 @@ -101,6 +101,11 @@ static int flm_sdram_reset(struct flow_nic_dev *ndev, int enable) hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, 0x0); hw_mod_flm_control_flush(&ndev->be); + for (uint32_t i = 1; i < ndev->be.flm.nb_categories; ++i) + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, i, 0x0); + + hw_mod_flm_rcp_flush(&ndev->be, 1, ndev->be.flm.nb_categories - 1); + /* Wait for FLM to enter Idle state */ for (uint32_t i = 0; i < 1000000; ++i) { uint32_t value = 0; @@ -2657,8 +2662,8 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, struct rte_flow_error *error, uint32_t port_id, uint32_t num_dest_port, uint32_t num_queues, - uint32_t *packet_data, uint32_t *packet_mask __rte_unused, - struct flm_flow_key_def_s *key_def __rte_unused) + uint32_t *packet_data, uint32_t *packet_mask, + struct flm_flow_key_def_s *key_def) { struct flow_handle *fh = calloc(1, sizeof(struct flow_handle)); @@ -2691,6 +2696,31 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n * Flow for group 1..32 */ + /* Setup FLM RCP */ + struct hw_db_inline_flm_rcp_data flm_data = { + .qw0_dyn = key_def->qw0_dyn, + .qw0_ofs = key_def->qw0_ofs, + .qw4_dyn = key_def->qw4_dyn, + .qw4_ofs = key_def->qw4_ofs, + .sw8_dyn = key_def->sw8_dyn, + .sw8_ofs = key_def->sw8_ofs, + .sw9_dyn = key_def->sw9_dyn, + .sw9_ofs = key_def->sw9_ofs, + .outer_prot = key_def->outer_proto, + .inner_prot = key_def->inner_proto, + }; + memcpy(flm_data.mask, packet_mask, sizeof(uint32_t) * 10); + struct hw_db_flm_idx flm_idx = + hw_db_inline_flm_add(dev->ndev, dev->ndev->hw_db_handle, &flm_data, + attr->group); + fh->db_idxs[fh->db_idx_counter++] = flm_idx.raw; + + if (flm_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM RPC resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + /* Setup Actions */ uint16_t flm_rpl_ext_ptr = 0; uint32_t flm_ft = 0; @@ -2703,7 +2733,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n } /* Program flow */ - convert_fh_to_fh_flm(fh, packet_data, 2, flm_ft, flm_rpl_ext_ptr, + convert_fh_to_fh_flm(fh, packet_data, flm_idx.id1 + 2, flm_ft, flm_rpl_ext_ptr, flm_scrub, attr->priority & 0x3); flm_flow_programming(fh, NT_FLM_OP_LEARN); @@ -3271,6 +3301,12 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, 0, 0); + hw_mod_flm_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 0); + flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 1); + flow_nic_free_resource(ndev, RES_FLM_RCP, 0); + flow_group_handle_destroy(&ndev->group_handle); ntnic_id_table_destroy(ndev->id_table_handle); -- 2.45.0