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 F0AC845A68; Tue, 22 Oct 2024 20:29:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3189406BB; Tue, 22 Oct 2024 20:29:25 +0200 (CEST) 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 283A940BA0 for ; Tue, 22 Oct 2024 20:29:23 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2171.outbound.protection.outlook.com [104.47.51.171]) by mx-outbound40-26.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 18:29:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CB9Xrkf36loW+20Lq1EYaSxcK/jGp6i+NyTs+inRNsZQVgwwK1ZhC7OtxPsn3dmEjvZoOh8F37SIbEgBzUj09xcNlKJvzHdtI0a/P0oOStsWb+G7im2hbcY+wT0+vNbnNbX/twbLxv+fxqjW72Hi3A2SlKXYSMbd+ExPQ8TK5qIi8OjyJV2HwS1YrZRvY9pgHNQrsjUNiGmQkKPrDhiKJUNzHFXOIVRnMrQV/b+8zoJcFqWEVD5BcJ9BE7Q7sHNajBSmXY+Ys4LtVZDfZRPm+nAfGp2GxJxV7m+cUKCPcJeriPpqk8Xe55cdWT5g6C9vq22WX4QaMx0m72HtNCN1Sw== 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=hGq7bAYflN9jEat7hTG3O1nT5Q73WNSGtoguQYlUQDI=; b=NdVrFTpgAlNh5pAcar+S/o71IVe/PQdaJx4EQvNKmNAy6zF46oJ5zDA6vWMt98C7cET+NREhtocuZRwpYU5M08zec9E6CIl2DefY+duPSI5vZFUvYLMiQbgWzneVu1ecWGLskU2Dftr+2/JTx4rEIwVeeGqQkW3BsVBCea4CtIbMjf4d2F4W8qZnUTOxhGOzdjql9FzYJLNf9nxqwfB7/rOKlJ0BUAc4evVDBXFQ6rmOq1OD5eboVGL0S3HwlcaXKdqlUn6/mg3sWue5TM+rvfZURTJ1hpc9CVM0vPQ3TOm48faNEp6+knOho2n8vsB2famkUD60KAo/pUyT6aGiJg== 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=hGq7bAYflN9jEat7hTG3O1nT5Q73WNSGtoguQYlUQDI=; b=loRkOvjnz/fhjLtjLpbyChKzMs6fycAFiDjOCplKmdOCJYOGpvduROu3LYkI0y8WVWS5I/5TlT+yxXu2kTewdDMLVkljN4IXaTogNItRc7IAXlt/i4ru3TqFgpAT/FQL3i+l01R6Id+M+o1m/b/aYp0WnxYrzSvGiCNMVHTpgxk= Received: from DB9PR06CA0016.eurprd06.prod.outlook.com (2603:10a6:10:1db::21) by DB8P190MB0763.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:122::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 16:57:17 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::45) by DB9PR06CA0016.outlook.office365.com (2603:10a6:10:1db::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:57: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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:57: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 v2 68/73] net/ntnic: add aged flow event Date: Tue, 22 Oct 2024 18:55:25 +0200 Message-ID: <20241022165541.3186140-69-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|DB8P190MB0763:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 86b9a88b-9264-49d1-4003-08dcf2ba95aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3GolqxSeMkQXSoJSKyDkaw3jrJKM4pBYMmCrsgqbYUelRwKcGRAxJkOOzrh5?= =?us-ascii?Q?WP1Kzpd3IguB4pAFG7qc4gmggX5NqivwChznfJCrTAb+UAnyH1sEueQjLw5+?= =?us-ascii?Q?o+ZyoAjNz2TMsSJE1q1gVS/dmT1SyAL7hlII0wdmm8+9uQMzQSiFyg/RjbXp?= =?us-ascii?Q?R5j0lRUfGlSieLTkKr5i5EblJdMIY2RrHGWsRD0a8aMzxma0E0v/CIDizti0?= =?us-ascii?Q?+V5RyPeVrlVSWumhmuvK724+LwyIlJjUWTpxXLIYhpCphsvksbTl1JP7E+py?= =?us-ascii?Q?DtIafHxzPq2U0e7pmV5XeHPEmU1NRUX59s3596WRdK3Gsq0b0D2DQ94UgJ5g?= =?us-ascii?Q?I05bEXCPOHcW4npAVLpKmAEEB5EuJXfsVyH4go6ldP2bbvm2SFoCc3r6PfD3?= =?us-ascii?Q?NwibWMKe7TCFaICwLGFnxF71BFIH6uc7eYeo73RlNk0ftMHBgds6G7eNQIFK?= =?us-ascii?Q?IMkkjKMN8A5FjK9kGEA9DoukzV+QquC8flXFsb30VUQLBbKVCrZ8hdkSkbKp?= =?us-ascii?Q?X1OK63N3bwWUDjeAuhI4TlSAgVWeXZYM5XMhHD1l4ur/pSyHIzWNYn86jXBs?= =?us-ascii?Q?9OaHRPyhpuegpR1+RbrqGuNEfB9/ml1J1IqsTki7bBprsRppW41Cvd0ZvI3u?= =?us-ascii?Q?3TBstHU700LMu4wA4ObFwqg4ViD+FMpUtFJAvXrzrhNHDhF8wEibxXAlxhBA?= =?us-ascii?Q?LZ8X50GBtL0/xBXr/ythTumqQd/Km0wrr87TK47CdFTl0liVC+EUz3US9+tO?= =?us-ascii?Q?XJDGh+aw8tgti7MvZhlcYSDPHCRtfS4hUZsseouoqHUmtu17oX5kJSk5iWcZ?= =?us-ascii?Q?NsHKE/Uu1Yd6CFSwjKFmvv/5pWS2dIOX3PBWulloBSY9atFAQCEDJVTeKCQv?= =?us-ascii?Q?GDwaSqUKUUEygeY/iXcYojsxWQmwJyITuGI3U2CtalRSCCZwZCAaTqCAs6/J?= =?us-ascii?Q?YYBE6cMAj7/GLkC9AJI5CzNCbV8D/qJBkuXRKSzzdeHrsR0QixQvYPjBySmE?= =?us-ascii?Q?l+k1cEj7n3oW23isI41ty9JoLsTb9adIlkKwqjyTvKQAhhPoWz94nY7RX7rm?= =?us-ascii?Q?fLjlS0lV1vt2AgfYm2sRopYAkIsJ6ZFmbfoYAY+JtdYdWa1OuxDKqYTalDFL?= =?us-ascii?Q?tgSNgbGMg3ssh7pKF0wp/j5SA1Xuuvzsbuf2sBs92eCSTql9CU/gh3yAUxt9?= =?us-ascii?Q?32SNdNZpoQSgy1F5JmVKadvwpCstMFPVI5Dyfd5sUMWCDcNtrcsG/xNzXC4w?= =?us-ascii?Q?mssXwdaVbj0o06Y8/cYnaYGhlFYba9RJKZnifemcE+3vsd6guwgSRXg9TCyS?= =?us-ascii?Q?w7wQI6jKotmqgqgEm9gz9r4gyzdQwyeDgOBGYMiyhVnGYkL6B1l1935UWWuJ?= =?us-ascii?Q?xlxSwOgGrOHK39Gm3Dj3RJxlFbmOKW0iZKWQe6g2HplG+/xI3Q=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EeGxJuhq+KPl+BvmKvgwsghtg3LORuad78hG+cc5DOmNJYQ4N6AGyn2qRp49ccxFcF3tbt0AnkKOZKJ3J6rx5wKOiMvEW40+UE6fcv3snKGDAuZC6lXP9ZQ2+FMQEwuGwOimXI+UxdOweP1Tc/zVMOgIuiKV8o3w7zh+hcm/iw5bkBXK+tlJiHjKW/BzXH8dxgy9baEK/BrWnTR+phAYipDQxVMl9M7Z8ZTSnmejJJztT8gOilUF1neSfbv0i5DELLS79RTDBHPWiQ/n/w1ivPey/9QQUVhtmi4iVQ9nfb3kxmJG5G7iPnoeCVh3DdpURafs6JSVonwyJPgKWFK0g8E2+iiGKz+t35sVk8U/fR7AMGj8V7Rz+iMepTat3lWzm/wpWc8jotxtZLJSfctmZCQscCz8iopLDb5aFvu4a/VvQWOOrSCVWbUYDZLo/TeC/Z1ushPH0G+u9iWCX2M0lbQfZ8fGiGd4pPxyCD3wt6IHQQ9GV6ThK0O6x819kN7BhpbIeADkLbv8QtiSSjj6R+CI/bOKKVAkxE5bn+XxBY3lYkLla/o3EHtd9aZF95a6dVzGRcirfDUNg2Q0Azezdqg1n9swkO0cNfqH4skZE/TY8CkP5WiryyxJj2LqoLDZh52ANZHlYcPqp2Z1jHJDVim4GOkysQguyd5dLRjzgMM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:57:16.5444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86b9a88b-9264-49d1-4003-08dcf2ba95aa 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P190MB0763 X-OriginatorOrg: napatech.com X-BESS-ID: 1729621761-310266-12658-16857-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmRoYmQGYGUNTI0DgpxdzAyC gl2cwgMTHJPC0lNc3UwDQl2SAt0cTcTKk2FgDpYle+QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259903 [from cloudscan21-45.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 Port thread was extended with new age event callback handler. LRN, INF, STA registers getter setter was added. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 7 + .../net/ntnic/nthw/flow_api/flow_id_table.c | 16 +++ .../net/ntnic/nthw/flow_api/flow_id_table.h | 3 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 75 +++++++++++ .../flow_api/profile_inline/flm_age_queue.c | 28 ++++ .../flow_api/profile_inline/flm_age_queue.h | 12 ++ .../flow_api/profile_inline/flm_evt_queue.c | 20 +++ .../flow_api/profile_inline/flm_evt_queue.h | 1 + .../profile_inline/flow_api_profile_inline.c | 121 ++++++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 16 +++ 10 files changed, 299 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 9cd9d92823..92e1205640 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -688,6 +688,9 @@ int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, 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_buf_ctrl_update(struct flow_api_backend_s *be); +int hw_mod_flm_buf_ctrl_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value); + int hw_mod_flm_stat_update(struct flow_api_backend_s *be); int hw_mod_flm_stat_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value); @@ -695,6 +698,10 @@ int hw_mod_flm_lrn_data_set_flush(struct flow_api_backend_s *be, enum hw_flm_e f const uint32_t *value, uint32_t records, uint32_t *handled_records, uint32_t *inf_word_cnt, uint32_t *sta_word_cnt); +int hw_mod_flm_inf_sta_data_update_get(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *inf_value, uint32_t inf_size, + uint32_t *inf_word_cnt, uint32_t *sta_value, + uint32_t sta_size, uint32_t *sta_word_cnt); 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/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c index 5635ac4524..a3f5e1d7f7 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c @@ -129,3 +129,19 @@ void ntnic_id_table_free_id(void *id_table, uint32_t id) pthread_mutex_unlock(&handle->mtx); } + +void ntnic_id_table_find(void *id_table, uint32_t id, union flm_handles *flm_h, uint8_t *caller_id, + uint8_t *type) +{ + struct ntnic_id_table_data *handle = id_table; + + pthread_mutex_lock(&handle->mtx); + + struct ntnic_id_table_element *element = ntnic_id_table_array_find_element(handle, id); + + *caller_id = element->caller_id; + *type = element->type; + memcpy(flm_h, &element->handle, sizeof(union flm_handles)); + + pthread_mutex_unlock(&handle->mtx); +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.h b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h index e190fe4a11..edb4f42729 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.h +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h @@ -20,4 +20,7 @@ uint32_t ntnic_id_table_get_id(void *id_table, union flm_handles flm_h, uint8_t uint8_t type); void ntnic_id_table_free_id(void *id_table, uint32_t id); +void ntnic_id_table_find(void *id_table, uint32_t id, union flm_handles *flm_h, uint8_t *caller_id, + uint8_t *type); + #endif /* FLOW_ID_TABLE_H_ */ 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 1845f74166..996abfb28d 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 @@ -712,6 +712,52 @@ int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int i return hw_mod_flm_rcp_mod(be, field, index, &value, 0); } + +int hw_mod_flm_buf_ctrl_update(struct flow_api_backend_s *be) +{ + return be->iface->flm_buf_ctrl_update(be->be_dev, &be->flm); +} + +static int hw_mod_flm_buf_ctrl_mod_get(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *value) +{ + int get = 1; /* Only get supported */ + + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_BUF_CTRL_LRN_FREE: + GET_SET(be->flm.v25.buf_ctrl->lrn_free, value); + break; + + case HW_FLM_BUF_CTRL_INF_AVAIL: + GET_SET(be->flm.v25.buf_ctrl->inf_avail, value); + break; + + case HW_FLM_BUF_CTRL_STA_AVAIL: + GET_SET(be->flm.v25.buf_ctrl->sta_avail, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_buf_ctrl_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t *value) +{ + return hw_mod_flm_buf_ctrl_mod_get(be, field, value); +} + int hw_mod_flm_stat_update(struct flow_api_backend_s *be) { return be->iface->flm_stat_update(be->be_dev, &be->flm); @@ -887,3 +933,32 @@ int hw_mod_flm_lrn_data_set_flush(struct flow_api_backend_s *be, enum hw_flm_e f return ret; } + +int hw_mod_flm_inf_sta_data_update_get(struct flow_api_backend_s *be, enum hw_flm_e field, + uint32_t *inf_value, uint32_t inf_size, + uint32_t *inf_word_cnt, uint32_t *sta_value, + uint32_t sta_size, uint32_t *sta_word_cnt) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_FLOW_INF_STA_DATA: + be->iface->flm_inf_sta_data_update(be->be_dev, &be->flm, inf_value, + inf_size, inf_word_cnt, sta_value, + sta_size, sta_word_cnt); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c index cdc7223d51..51126dfded 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.c @@ -15,6 +15,21 @@ static struct rte_ring *age_queue[MAX_EVT_AGE_QUEUES]; static RTE_ATOMIC(uint16_t) age_event[MAX_EVT_AGE_PORTS]; +__rte_always_inline int flm_age_event_get(uint8_t port) +{ + return rte_atomic_load_explicit(&age_event[port], rte_memory_order_seq_cst); +} + +__rte_always_inline void flm_age_event_set(uint8_t port) +{ + rte_atomic_store_explicit(&age_event[port], 1, rte_memory_order_seq_cst); +} + +__rte_always_inline void flm_age_event_clear(uint8_t port) +{ + rte_atomic_flag_clear_explicit(&age_event[port], rte_memory_order_seq_cst); +} + void flm_age_queue_free(uint8_t port, uint16_t caller_id) { struct rte_ring *q = NULL; @@ -90,6 +105,19 @@ struct rte_ring *flm_age_queue_create(uint8_t port, uint16_t caller_id, unsigned return q; } +void flm_age_queue_put(uint16_t caller_id, struct flm_age_event_s *obj) +{ + int ret; + + /* If queues is not created, then ignore and return */ + if (caller_id < MAX_EVT_AGE_QUEUES && age_queue[caller_id] != NULL) { + ret = rte_ring_sp_enqueue_elem(age_queue[caller_id], obj, FLM_AGE_ELEM_SIZE); + + if (ret != 0) + NT_LOG(DBG, FILTER, "FLM aged event queue full"); + } +} + int flm_age_queue_get(uint16_t caller_id, struct flm_age_event_s *obj) { int ret; diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.h index 9ff6ef6de0..27154836c5 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_age_queue.h @@ -12,6 +12,14 @@ struct flm_age_event_s { void *context; }; +/* Indicates why the flow info record was generated */ +#define INF_DATA_CAUSE_SW_UNLEARN 0 +#define INF_DATA_CAUSE_TIMEOUT_FLOW_DELETED 1 +#define INF_DATA_CAUSE_NA 2 +#define INF_DATA_CAUSE_PERIODIC_FLOW_INFO 3 +#define INF_DATA_CAUSE_SW_PROBE 4 +#define INF_DATA_CAUSE_TIMEOUT_FLOW_KEPT 5 + /* Max number of event queues */ #define MAX_EVT_AGE_QUEUES 256 @@ -20,8 +28,12 @@ struct flm_age_event_s { #define FLM_AGE_ELEM_SIZE sizeof(struct flm_age_event_s) +int flm_age_event_get(uint8_t port); +void flm_age_event_set(uint8_t port); +void flm_age_event_clear(uint8_t port); void flm_age_queue_free(uint8_t port, uint16_t caller_id); struct rte_ring *flm_age_queue_create(uint8_t port, uint16_t caller_id, unsigned int count); +void flm_age_queue_put(uint16_t caller_id, struct flm_age_event_s *obj); int flm_age_queue_get(uint16_t caller_id, struct flm_age_event_s *obj); unsigned int flm_age_queue_count(uint16_t caller_id); unsigned int flm_age_queue_get_size(uint16_t caller_id); diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c index 98b0e8347a..db9687714f 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.c @@ -138,6 +138,26 @@ static struct rte_ring *flm_evt_queue_create(uint8_t port, uint8_t caller) return q; } +int flm_sta_queue_put(uint8_t port, bool remote, struct flm_status_event_s *obj) +{ + struct rte_ring **stat_q = remote ? stat_q_remote : stat_q_local; + + if (port >= (remote ? MAX_STAT_RMT_QUEUES : MAX_STAT_LCL_QUEUES)) + return -1; + + if (stat_q[port] == NULL) { + if (flm_evt_queue_create(port, remote ? FLM_STAT_REMOTE : FLM_STAT_LOCAL) == NULL) + return -1; + } + + if (rte_ring_sp_enqueue_elem(stat_q[port], obj, FLM_STAT_ELEM_SIZE) != 0) { + NT_LOG(DBG, FILTER, "FLM local status queue full"); + return -1; + } + + return 0; +} + int flm_inf_queue_get(uint8_t port, bool remote, struct flm_info_event_s *obj) { int ret; diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.h index 238be7a3b2..3a61f844b6 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_evt_queue.h @@ -48,5 +48,6 @@ enum { #define FLM_STAT_ELEM_SIZE sizeof(struct flm_status_event_s) int flm_inf_queue_get(uint8_t port, bool remote, struct flm_info_event_s *obj); +int flm_sta_queue_put(uint8_t port, bool remote, struct flm_status_event_s *obj); #endif /* _FLM_EVT_QUEUE_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 7efdb76600..21d8ed4ca9 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 @@ -8,6 +8,7 @@ #include "hw_mod_backend.h" #include "flm_age_queue.h" +#include "flm_evt_queue.h" #include "flm_lrn_queue.h" #include "flow_api.h" #include "flow_api_engine.h" @@ -20,6 +21,13 @@ #include "ntnic_mod_reg.h" #include +#define DMA_BLOCK_SIZE 256 +#define DMA_OVERHEAD 20 +#define WORDS_PER_STA_DATA (sizeof(struct flm_v25_sta_data_s) / sizeof(uint32_t)) +#define MAX_STA_DATA_RECORDS_PER_READ ((DMA_BLOCK_SIZE - DMA_OVERHEAD) / WORDS_PER_STA_DATA) +#define WORDS_PER_INF_DATA (sizeof(struct flm_v25_inf_data_s) / sizeof(uint32_t)) +#define MAX_INF_DATA_RECORDS_PER_READ ((DMA_BLOCK_SIZE - DMA_OVERHEAD) / WORDS_PER_INF_DATA) + #define NT_FLM_MISS_FLOW_TYPE 0 #define NT_FLM_UNHANDLED_FLOW_TYPE 1 #define NT_FLM_OP_UNLEARN 0 @@ -71,14 +79,127 @@ static uint32_t flm_lrn_update(struct flow_eth_dev *dev, uint32_t *inf_word_cnt, return r.num; } +static inline bool is_remote_caller(uint8_t caller_id, uint8_t *port) +{ + if (caller_id < MAX_VDPA_PORTS + 1) { + *port = caller_id; + return true; + } + + *port = caller_id - MAX_VDPA_PORTS - 1; + return false; +} + +static void flm_mtr_read_inf_records(struct flow_eth_dev *dev, uint32_t *data, uint32_t records) +{ + for (uint32_t i = 0; i < records; ++i) { + struct flm_v25_inf_data_s *inf_data = + (struct flm_v25_inf_data_s *)&data[i * WORDS_PER_INF_DATA]; + uint8_t caller_id; + uint8_t type; + union flm_handles flm_h; + ntnic_id_table_find(dev->ndev->id_table_handle, inf_data->id, &flm_h, &caller_id, + &type); + + /* Check that received record hold valid meter statistics */ + if (type == 1) { + switch (inf_data->cause) { + case INF_DATA_CAUSE_TIMEOUT_FLOW_DELETED: + case INF_DATA_CAUSE_TIMEOUT_FLOW_KEPT: { + struct flow_handle *fh = (struct flow_handle *)flm_h.p; + struct flm_age_event_s age_event; + uint8_t port; + + age_event.context = fh->context; + + is_remote_caller(caller_id, &port); + + flm_age_queue_put(caller_id, &age_event); + flm_age_event_set(port); + } + break; + + case INF_DATA_CAUSE_SW_UNLEARN: + case INF_DATA_CAUSE_NA: + case INF_DATA_CAUSE_PERIODIC_FLOW_INFO: + case INF_DATA_CAUSE_SW_PROBE: + default: + break; + } + } + } +} + +static void flm_mtr_read_sta_records(struct flow_eth_dev *dev, uint32_t *data, uint32_t records) +{ + for (uint32_t i = 0; i < records; ++i) { + struct flm_v25_sta_data_s *sta_data = + (struct flm_v25_sta_data_s *)&data[i * WORDS_PER_STA_DATA]; + uint8_t caller_id; + uint8_t type; + union flm_handles flm_h; + ntnic_id_table_find(dev->ndev->id_table_handle, sta_data->id, &flm_h, &caller_id, + &type); + + if (type == 1) { + uint8_t port; + bool remote_caller = is_remote_caller(caller_id, &port); + + pthread_mutex_lock(&dev->ndev->mtx); + ((struct flow_handle *)flm_h.p)->learn_ignored = 1; + pthread_mutex_unlock(&dev->ndev->mtx); + struct flm_status_event_s data = { + .flow = flm_h.p, + .learn_ignore = sta_data->lis, + .learn_failed = sta_data->lfs, + }; + + flm_sta_queue_put(port, remote_caller, &data); + } + } +} + static uint32_t flm_update(struct flow_eth_dev *dev) { static uint32_t inf_word_cnt; static uint32_t sta_word_cnt; + uint32_t inf_data[DMA_BLOCK_SIZE]; + uint32_t sta_data[DMA_BLOCK_SIZE]; + + if (inf_word_cnt >= WORDS_PER_INF_DATA || sta_word_cnt >= WORDS_PER_STA_DATA) { + uint32_t inf_records = inf_word_cnt / WORDS_PER_INF_DATA; + + if (inf_records > MAX_INF_DATA_RECORDS_PER_READ) + inf_records = MAX_INF_DATA_RECORDS_PER_READ; + + uint32_t sta_records = sta_word_cnt / WORDS_PER_STA_DATA; + + if (sta_records > MAX_STA_DATA_RECORDS_PER_READ) + sta_records = MAX_STA_DATA_RECORDS_PER_READ; + + hw_mod_flm_inf_sta_data_update_get(&dev->ndev->be, HW_FLM_FLOW_INF_STA_DATA, + inf_data, inf_records * WORDS_PER_INF_DATA, + &inf_word_cnt, sta_data, + sta_records * WORDS_PER_STA_DATA, + &sta_word_cnt); + + if (inf_records > 0) + flm_mtr_read_inf_records(dev, inf_data, inf_records); + + if (sta_records > 0) + flm_mtr_read_sta_records(dev, sta_data, sta_records); + + return 1; + } + if (flm_lrn_update(dev, &inf_word_cnt, &sta_word_cnt) != 0) return 1; + hw_mod_flm_buf_ctrl_update(&dev->ndev->be); + hw_mod_flm_buf_ctrl_get(&dev->ndev->be, HW_FLM_BUF_CTRL_INF_AVAIL, &inf_word_cnt); + hw_mod_flm_buf_ctrl_get(&dev->ndev->be, HW_FLM_BUF_CTRL_STA_AVAIL, &sta_word_cnt); + return inf_word_cnt + sta_word_cnt; } diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 263b3ee7d4..6cac8da17e 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -26,6 +26,7 @@ #include "ntnic_vfio.h" #include "ntnic_mod_reg.h" #include "nt_util.h" +#include "profile_inline/flm_age_queue.h" #include "profile_inline/flm_evt_queue.h" #include "rte_pmd_ntnic.h" @@ -1816,6 +1817,21 @@ THREAD_FUNC port_event_thread_fn(void *context) } } + /* AGED event */ + /* Note: RTE_FLOW_PORT_FLAG_STRICT_QUEUE flag is not supported so + * event is always generated + */ + int aged_event_count = flm_age_event_get(port_no); + + if (aged_event_count > 0 && eth_dev && eth_dev->data && + eth_dev->data->dev_private) { + rte_eth_dev_callback_process(eth_dev, + RTE_ETH_EVENT_FLOW_AGED, + NULL); + flm_age_event_clear(port_no); + do_wait = false; + } + if (do_wait) nt_os_wait_usec(10); -- 2.45.0