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 EF7F245B96; Mon, 21 Oct 2024 23:40:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D60EC40615; Mon, 21 Oct 2024 23:40:59 +0200 (CEST) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 682D5402F2 for ; Mon, 21 Oct 2024 23:40:57 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2113.outbound.protection.outlook.com [104.47.11.113]) by mx-outbound19-70.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:40:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Av4rDcFMD86sVb3fztMR+cwMQLT+JsPvySAjNDNWDEwZ8Rk2Sa9h5+PTl5dxbssEBh7+vPxe6tLq02Z7HE84e2Gh4cwTA8IDWqxCB5QiWZsUQ+CLSVZN0UAkpRW161I6Unua3woq1dB79I40KntXupWXM5zFTdVI1EU2YMbb6I5vS37YmeRMu768LGbcmufQwG8JYQrAJFWah1ZOvyRZvx0vxYDUv1d21T9aqRUus7n+0PRAV3NjZnDyjqD1KXSqeV3LEKb9OfxA1iENzBkxlMfuuv/cUDw9omi39otRnZa46Q7QJwnFJWSiVI9bBEDpZGyVttvBLQe+Uow+FP9DRQ== 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=IQmbirnv4NI3UAo+pG+6/Q/hr1BmsTw4Ff3t5seil6c=; b=nf2VQ4XyDoRzvnfruuXEKhBMnBm9+KgA1hC5MwhhDt0ZWFTjTyb+8KjbTZzuyE59AtcKof+oEA9JXbkwi5qf4cJHBGPNIpSHUJtZEfmknKy484jXY3qw9/zBW7/pR+rzoKdUB/eQzL0MMaByCJ4+467LfH4GMGkt2UPySUvnwl+FjW0Mm20Ft5MqgPVUO+TEhMQR4ZS/eW3FrC9vtYnzsVtg/UAxy+kw5i5O6ejJmMRIplDjvOXBgC9/B3iSQ5Q5noMZWdQtQSbGHWBpgBRcUJLTvwR+QdSqr9StGA/GjukxccV8vKGJboT4PxFIGP6k4qO36XklmQ8fnU6jy88ddA== 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=IQmbirnv4NI3UAo+pG+6/Q/hr1BmsTw4Ff3t5seil6c=; b=CECJfsqlb+Qo8Y3B4lYDzYjrwgL004Wo1n1oKBd+1arQ4eppMTUQ/tPutVbe6dcrqWHhCMEnWN3HQCBfS/eg8M/GbGXw0jUXgy54ezept+oxvLckJFz9TzkNTZt8AA76O95os+HXewUqPZdOoyLIvluUBmV57e5pANzEuQLdpWI= Received: from AS9PR04CA0150.eurprd04.prod.outlook.com (2603:10a6:20b:48a::23) by PA4P190MB1181.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:10f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 21:06:19 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::8b) by AS9PR04CA0150.outlook.office365.com (2603:10a6:20b:48a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 21:06:19 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 21:06:19 +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 v1 68/73] net/ntnic: add aged flow event Date: Mon, 21 Oct 2024 23:05:10 +0200 Message-ID: <20241021210527.2075431-69-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241021210527.2075431-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A8:EE_|PA4P190MB1181:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 93f4c2d6-1c3a-4f06-1393-08dcf21435a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BqzSQWyHmFbRk5ZvBi6KVuzyYJmvVuCAL13sh79Yt5hRDmqCA3aC7qMd/9yD?= =?us-ascii?Q?KupVJny8WVaKyIOzvsG7sW4VOnejS7TZhmIykqe4DKGZmH1NPqh8RCqxNJf6?= =?us-ascii?Q?YPmyx4HCBIQ0VNPx9NqovdToAPjooHeVYghL/FYloD5TiHDbscbbG2B6enTG?= =?us-ascii?Q?7aXt4wVlp6ve+OjeZaJl7E0aHTVK+zsI5Qg/fu1I6oaT7qpJDA1SPJKx8qez?= =?us-ascii?Q?uFL26zE+Law0i/agNNQNE+D6dxaAHkXlQrfyOqmO3EaRMlQ+OwMKEpKsryfP?= =?us-ascii?Q?95mJW+x448VODRFza0wjLKqEiG5bleW6e214RqsIYVfeeLEUFCOVKXyjEzNF?= =?us-ascii?Q?g4iuJdvGzEsGlxJnp1lFLU/Z6SJGIr50P0n3z/OhxhSdfIwTlQNQTrD9GcxG?= =?us-ascii?Q?EZZCE1bKTxQVedFjCLU0GXwdauy7hfldsoKYDcez3jHA2OCqwBHY/qqpPGLE?= =?us-ascii?Q?9k1b/Qq9pQs6NtPq+AxJ7hkgA+7fFqZAC8FXj4QAUuCkAEdGoO8Hn0tW+yOP?= =?us-ascii?Q?uWcTRDLyVqSqoXutbZlXBrGu5NH07xbPn5/CXmH3FgrUORpaeA7uA/h7+ee9?= =?us-ascii?Q?K/Ul1+QSfWhQJi0V//BkPBOA4D/3OQQDgY1fn0iXuaBpZQcM70B/u2mc7w/2?= =?us-ascii?Q?cZxIJe9MNsZRoUiL/p8WRmlSzbjf3MMlShB+8bzQXc7ZGQHN9+TbpkFR3go0?= =?us-ascii?Q?sRrLKH+1iR69L135ygoLS/4POVKyw72Nu12w1reHXx6EVgGKgX25Ftcb0QtW?= =?us-ascii?Q?00pLZ85TGBfn+ccvdNnatNM3EbYOCa5R+U8CBkkRFNp5BWbK7ZNe+Khl1BUz?= =?us-ascii?Q?07aJ0S+uUk8BdnTiAbS+wYiMpvpB9q+LY+/Zzn5XAuiDPWic67SObuAuNV00?= =?us-ascii?Q?TdjuFMKOXxXwKJI80jzdF04Wgb27tw1CXW0NsCDZkjhfCRORqFFi7vs5SVKy?= =?us-ascii?Q?QaKd8zdQVK/x6X9qEhisgj4bc8PzV9ohDRolhdCizC05oQZHoQcJceGuUI10?= =?us-ascii?Q?dYeM8USxh6eRly0CpkY8rXjv8rf3oS5VJMPDCXvoJkn9mxlTB5JttXHYomS4?= =?us-ascii?Q?XdWHpXzh4ofQySjar506Mv0nvieeIVDOd+AJTU5lUJMxsSKZNsoEijs9AOVN?= =?us-ascii?Q?4c4KPRV/mztnM4kV9c6+ef/TqP3dzqkNLHnHka6ON9cKHtwg6bhTlf+lOolO?= =?us-ascii?Q?GDklnozoGRbnJvVNe08SU0GRu3utpoOSj7Iwo/szVt75JBEeAV0KrGPc33hJ?= =?us-ascii?Q?6z3iLqblVUwthVFemF5uDnkgMizyWVgHEuAsxzUgk6UCnQqWX5G4dmTf90qE?= =?us-ascii?Q?cLSy2L4x4A+aqQTC5i43ITjaH33mjQT+bxAkqlCEWUyXXptcptTmzzcPy3nw?= =?us-ascii?Q?mII05DEZlZ/zUHJbcs73C0+CPkNNWxG3fDDZruT1VdKg/CXzhQ=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)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: msslAeGi56q3+noDq7CE07QLWkKwtrvOol/dof4LjNA5M/+IQ5m+bQJRcKJiDgg4wwBBvGVuG98Rcw8tqDHGDNAaACP9UZ8dzCsOHEk2G8Z8XVppe02CAUxJG79Dgd7cnbdjlJnoktMrnpntLMbd7qyGDnmBDb0CH8MVQuj+jKR0kqXoDWoahxs1aP2TJ2pHmnnt/fycEcD7vSF6aztwRGfzKOTWTYCn3TPMwwkiumXkA/QjoRnOG8g4fsj8Ov+5pUZbAuxx6ZYUeEhcFC1Uar0+ZEN2W9c0HDEK/RhWETBOfMMIrw/b3sgW7I0u0vyti3i71ZT6jCapKM9pedeEPydKpTTh/6fRzjL/mQzaUNAaMgUxH4ELX4iQBYE8X+O0DBng/Yn7rmRsiQ/MLUjXTiqrtMtDKC7yg9K22DZi/gQSzMoUHgecAqObb0nnh75Os6lEhPY9QP4QWRH9AsRm+k+heMd86Jhb5nBxIb380npORLclZCNIz0++foUAqnWp4rwqg1ziUTnYcBZY6z7WMHEJjOFCl0sl6jczYZqLALeBYeMz0tCqHpeV66VQs82jR+aPlEZ+YoXANVGn20LbUfm3Wy7Pbi5R0MidQiqlMhaWqHqgDy55wzC93+b0XNTiQq32OYmBZQWkcq9ezyYZVo5MsSb62UKN0vfG+N8nsw0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:06:19.1614 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93f4c2d6-1c3a-4f06-1393-08dcf21435a7 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1181 X-OriginatorOrg: napatech.com X-BESS-ID: 1729546856-304934-12655-46856-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmRoamQGYGUDTFPM3MwMDCzN jM3CLJLCnZwizJwDLFLDEl2SjV2NjIQqk2FgAMKmj8QgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan10-204.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 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 1022583c4f..fc192ff05d 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 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 f4308ff3de..72e79b2f86 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" @@ -19,6 +20,13 @@ #include "flow_api_profile_inline.h" #include "ntnic_mod_reg.h" +#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 @@ -70,14 +78,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