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 E850445BA3; Tue, 22 Oct 2024 19:00:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4AC0B410FB; Tue, 22 Oct 2024 18:57:01 +0200 (CEST) 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 131C940E72 for ; Tue, 22 Oct 2024 18:56:45 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2177.outbound.protection.outlook.com [104.47.51.177]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gb+7Qj14/yfLO8yczfP3qcbyZaduGK4xa62LndnKVNF+1+76SzXNUEJlfn6yMMX87vhs/HeAfrGZXMn08MrPYt/V+CuJGoU5glx+ldiqUykQwvLRKhbz8bpVLj4d8N+LerEz0SiReC7tRJLTc+iTWQy3b4MXDyE7BY/O1Dwe3avubPb9jVo5y7RVLMeqt75W8mG6mEGshFGIXxNVs8/ENgmPuvjSlmsrQDVlHs1lrpjRjNzF2XMdyKGCSFM+CZ9Pc23ZjbLK98csdW2Fv7ASORJgfvm3AgQFj+Ww11vAHw7Ym+aBL7NpvpVGZp2KjNHE0Zpcl04xocRJrW+p+j6riA== 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=1YWSEbQucR9yxz0Z2VhZVYwmCjFhf1meBg0cLUdjad4=; b=jh/HAioxIiIYYzJ1TfTOtMwt1becs4Of2nhifzm6lZ6GN6Z+1hqrT3ZkuC/8ML40TnKDj+W7zTszKg+XlqrZdNnWKTYrQuIQG5iSKAZghd6l7vPbE13JBHQKBVPvpApZfcaYt4MvKwGL7yIFhB7tQJEaijpOTdNtSeTdSpBVNNxWSpivpXBXU/nEzPC3trkTv+RcQlm17JIOhCgZJ4P7x1C4OvgkboU4kbeiG5b6rdIW2SINF+uBb9uXAdvXYAuGnaTPSwgKHzFv6MjRuqR0H72I1JpjQq8iT2BGYYyOG6h9qKNct5El1zpS+uJDHO6ES2ATqy4HFrt7lSDQwfk1lg== 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=1YWSEbQucR9yxz0Z2VhZVYwmCjFhf1meBg0cLUdjad4=; b=OtJsbcuykODRG0EbsjxQdZg+HvSGqJ0eaGGJ/1ICcxpHeRl0xtQ6ZbIu+CFQibWpPVBg7R5RugqIRGO4HYwQlB4R9ooh/wZDqpKeZcgOrCDz41zNAUhO3jQKaK9n5uVSOYlMrJnRGNLT8npjeVPK+0sBqUcdU6DYlsL0KGaxYW4= Received: from DB9PR06CA0003.eurprd06.prod.outlook.com (2603:10a6:10:1db::8) by AM8P190MB0979.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Tue, 22 Oct 2024 16:56:37 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::de) by DB9PR06CA0003.outlook.office365.com (2603:10a6:10:1db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 16:56:37 +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:56:37 +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 35/73] net/ntnic: add learn flow queue handling Date: Tue, 22 Oct 2024 18:54:52 +0200 Message-ID: <20241022165541.3186140-36-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_|AM8P190MB0979:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5eb72e15-cd12-451b-e21a-08dcf2ba7e49 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nl5inwUutuGF5AhDDflbb4PZy5XNnIOHc6SkdLpIq+GGBSnF2P3g2PMPyocv?= =?us-ascii?Q?Qv3c0fynyNP+7qH2xuURmoH5aPQoc2BLN6QBHGRgWXy7I5ZPonpcbq2mnz4m?= =?us-ascii?Q?Tb2YhwrZv+F+93y4oGxKGGhvcp5m+VfXo5ozmCDie8F7kcddIuNbqNfCuPDs?= =?us-ascii?Q?0EuBKCSIou13IVhdLL/3F1n/B7OeqE6exb3HHnxuFAtpAZnR6ub5Nn5TyFHW?= =?us-ascii?Q?XCEiJf7g4FaYAqH41wJQV8A+k40FR1eL2n6wIAHL8aVulGcx+A8w1eY5vpLY?= =?us-ascii?Q?ZUBn12bBzUCE+dLMfddl6Eaq12SlNASjPTUU0qKYb84pC8k4PKCwaEn1Flzz?= =?us-ascii?Q?h2OYUEvU9sspoNx67K+MQ4TBLsgo2XkVtseuoR++bpoFg7oV3u/8qMM0wtEC?= =?us-ascii?Q?WZvnLpP8PZJoVLV8SSvBte71vPjPgdIA7qF9pFbGgggIHr6fw1KMEeG1kq9v?= =?us-ascii?Q?Jg/T3eMR2+scCoeq8KELb40V4mqU2gCsvVH6wdgvxh2z9ZPbmrWyx9lhwvTt?= =?us-ascii?Q?j0iknwjQBk8kVVqhkR1cICHpIicwaXsTwZ1cgZM5wyBuj351LSSIWF3wAd+U?= =?us-ascii?Q?hotFm5z1IwAu3cW24bjMe5TVLxZbmUXtalT7IUfLAEICdHlam9y+/KV3ifO/?= =?us-ascii?Q?ZfZUiKUcx1fqEQF0yqgWkiVeenEpiYBwL5UNlVMgCo8bKkL9Db6LZdAQVpme?= =?us-ascii?Q?mtumAycCRpn/hBgkWa5ExuktDP1G2mVWXF/bX7Ndrq/hYORZo3lE8v6cHDQk?= =?us-ascii?Q?C8V9y5aZAjekxnf9i5cnXjQ8d3hEGMMbKOSa5qPjB/bZqjCyXoJOoxp9cqkI?= =?us-ascii?Q?Ov4WRv/GGIAmsDZMHN9CMJ2/B/MPaWXQqG7nb1Dz4c8uKL6ERrJjFS7Ah9lT?= =?us-ascii?Q?fYntlnkcdDt3zv1FI+p7X3OmEVceKItTgs1icIuuMthTLR7wTu8odfpsSb39?= =?us-ascii?Q?LPTk7zFJDbToPqQTAvQrfsW3SIKOgqXQ+xFPeWz5nhg0nOZ+sXt8Y9N0fJVd?= =?us-ascii?Q?z+MmltFlEvabwR6K7W+3j+FJBpVvFeFkJl2fjISQrDkcsSfwOuoqJNmGDEYD?= =?us-ascii?Q?ex0cXOeUqUedys2Qe5MZNLfNZ4dO64ng+2S9/ZmvHa7aeIqxfSTP3EL19Dnw?= =?us-ascii?Q?QozxOrI1pJpoSjzWNql4T0ic0wlA3SStlHrbuholurWtmI3MxTopV78BIYOM?= =?us-ascii?Q?Atnhi7tvk/x0f8j7dOaMIthbFgLjExV/q1Lt2qateTBDK2NqZVxKOYDTcYCv?= =?us-ascii?Q?Xpp3tZPivGNPVsv+85QFBfecMs5Lv85SDx67Wwek0VDc6gmsU59ssWV2IGon?= =?us-ascii?Q?MrrcUqB3noDMVYxfl73J3D/eenn2/JIs4jvz+M8MEEtRtlNc8UbIxFPlEyTC?= =?us-ascii?Q?Lg+H2ykNik8AX2tPn5sTDdVieaGFoyUSQavrAHhwy10LgTd1Tg=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)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: skwuZdWtOLrB2XWnlFRgODiFIgvcqJs4l7BIoLeWNTkqyhAPpvz4UeZtTHH2hfG7NttPtSDapEl+rA7jE43Ud2w7C2x9blpxp6ziNsvdMJVv5ELP5yDbmO3hbw/Q70kIxmPrcCElpsDxcqDRBL88MrZhIUnvHJBAV9NDNS9H5CaP89g8GuUO9aHrcPKofPurfcaIfz9yhZ8igUJn1hbnwt/Bs7TB6aK3prm+FLNrb1R+z7YQISGFiQcwkYZ/KaUYGz/4/Y23/zuLq7/+kw1dt2QbCUVhoVzSZ9XCY3zzBT40IqdbjZsKV56D2Y3w9o+mi3xTWqOU5R8K/dYMABswfk04idlLLHhF9L13/EvOguAR64/CbisP+Ir4yRa6qboItGiCByYOV4tP3tlHL69+p4egwdpfNwvcCfr4et/yAhfD4KW217zbHASjqbZg64UaHikgUeR4F4oxKWfeiOXiPj4jMagjL2DHGcqBiuVJCTY6TzCFyZfov+zjTasBJqSKqmaZA7sfzQ1VQUHbnCf8dyK1VTTutT63Lh6SVLBQeAFuaAlgJX8QloljKIJKpYFVIM6B1ZkVBUE4BnIHUFhSICkij0ElWPtkKVkvHXGDJODIje3x2SpaSMBH3NE8700uFkT++f0DEk4KQl66d/TG/xILCCgbWxYYXkmRI76bh44= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:37.2627 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5eb72e15-cd12-451b-e21a-08dcf2ba7e49 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: AM8P190MB0979 X-BESS-ID: 1729616199-304983-12655-14403-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGxiZGQGYGUDTFwjA5xdIgOd XQNDkpKc3SNMkiydDcONkg0STN0CLVXKk2FgDAyNAGQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan23-115.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 Implements thread for handling flow learn queue Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 5 + drivers/net/ntnic/include/ntdrv_4ga.h | 1 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 33 +++++++ .../flow_api/profile_inline/flm_lrn_queue.c | 42 +++++++++ .../flow_api/profile_inline/flm_lrn_queue.h | 11 +++ .../profile_inline/flow_api_profile_inline.c | 48 ++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 94 +++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 7 ++ 8 files changed, 241 insertions(+) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 13722c30a9..17d5755634 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -688,6 +688,11 @@ 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_lrn_data_set_flush(struct flow_api_backend_s *be, enum hw_flm_e field, + 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_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count); struct hsh_func_s { diff --git a/drivers/net/ntnic/include/ntdrv_4ga.h b/drivers/net/ntnic/include/ntdrv_4ga.h index 8017aa4fc3..8ebdd98db0 100644 --- a/drivers/net/ntnic/include/ntdrv_4ga.h +++ b/drivers/net/ntnic/include/ntdrv_4ga.h @@ -14,6 +14,7 @@ typedef struct ntdrv_4ga_s { char *p_drv_name; volatile bool b_shutdown; + rte_thread_t flm_thread; } ntdrv_4ga_t; #endif /* __NTDRV_4GA_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 0a7e90c04f..f4c29b8bde 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,3 +712,36 @@ 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_lrn_data_set_flush(struct flow_api_backend_s *be, enum hw_flm_e field, + const uint32_t *value, uint32_t records, + uint32_t *handled_records, uint32_t *inf_word_cnt, + uint32_t *sta_word_cnt) +{ + int ret = 0; + + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_FLOW_LRN_DATA: + ret = be->iface->flm_lrn_data_flush(be->be_dev, &be->flm, value, records, + handled_records, + (sizeof(struct flm_v25_lrn_data_s) / + sizeof(uint32_t)), + inf_word_cnt, sta_word_cnt); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return ret; +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c index ad7efafe08..6e77c28f93 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.c @@ -13,8 +13,28 @@ #include "flm_lrn_queue.h" +#define QUEUE_SIZE (1 << 13) + #define ELEM_SIZE sizeof(struct flm_v25_lrn_data_s) +void *flm_lrn_queue_create(void) +{ + static_assert((ELEM_SIZE & ~(size_t)3) == ELEM_SIZE, "FLM LEARN struct size"); + struct rte_ring *q = rte_ring_create_elem("RFQ", + ELEM_SIZE, + QUEUE_SIZE, + SOCKET_ID_ANY, + RING_F_MP_HTS_ENQ | RING_F_SC_DEQ); + assert(q != NULL); + return q; +} + +void flm_lrn_queue_free(void *q) +{ + if (q) + rte_ring_free(q); +} + uint32_t *flm_lrn_queue_get_write_buffer(void *q) { struct rte_ring_zc_data zcd; @@ -26,3 +46,25 @@ void flm_lrn_queue_release_write_buffer(void *q) { rte_ring_enqueue_zc_elem_finish(q, 1); } + +read_record flm_lrn_queue_get_read_buffer(void *q) +{ + struct rte_ring_zc_data zcd; + read_record rr; + + if (rte_ring_dequeue_zc_burst_elem_start(q, ELEM_SIZE, QUEUE_SIZE, &zcd, NULL) != 0) { + rr.num = zcd.n1; + rr.p = zcd.ptr1; + + } else { + rr.num = 0; + rr.p = NULL; + } + + return rr; +} + +void flm_lrn_queue_release_read_buffer(void *q, uint32_t num) +{ + rte_ring_dequeue_zc_elem_finish(q, num); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h index 8cee0c8e78..40558f4201 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flm_lrn_queue.h @@ -8,7 +8,18 @@ #include +typedef struct read_record { + uint32_t *p; + uint32_t num; +} read_record; + +void *flm_lrn_queue_create(void); +void flm_lrn_queue_free(void *q); + uint32_t *flm_lrn_queue_get_write_buffer(void *q); void flm_lrn_queue_release_write_buffer(void *q); +read_record flm_lrn_queue_get_read_buffer(void *q); +void flm_lrn_queue_release_read_buffer(void *q, uint32_t num); + #endif /* _FLM_LRN_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 719f5fcdec..0b8ac26b83 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 @@ -39,6 +39,48 @@ static void *flm_lrn_queue_arr; +static void flm_setup_queues(void) +{ + flm_lrn_queue_arr = flm_lrn_queue_create(); + assert(flm_lrn_queue_arr != NULL); +} + +static void flm_free_queues(void) +{ + flm_lrn_queue_free(flm_lrn_queue_arr); +} + +static uint32_t flm_lrn_update(struct flow_eth_dev *dev, uint32_t *inf_word_cnt, + uint32_t *sta_word_cnt) +{ + read_record r = flm_lrn_queue_get_read_buffer(flm_lrn_queue_arr); + + if (r.num) { + uint32_t handled_records = 0; + + if (hw_mod_flm_lrn_data_set_flush(&dev->ndev->be, HW_FLM_FLOW_LRN_DATA, r.p, r.num, + &handled_records, inf_word_cnt, sta_word_cnt)) { + NT_LOG(ERR, FILTER, "Flow programming failed"); + + } else if (handled_records > 0) { + flm_lrn_queue_release_read_buffer(flm_lrn_queue_arr, handled_records); + } + } + + return r.num; +} + +static uint32_t flm_update(struct flow_eth_dev *dev) +{ + static uint32_t inf_word_cnt; + static uint32_t sta_word_cnt; + + if (flm_lrn_update(dev, &inf_word_cnt, &sta_word_cnt) != 0) + return 1; + + return inf_word_cnt + sta_word_cnt; +} + static int rx_queue_idx_to_hw_id(const struct flow_eth_dev *dev, int id) { for (int i = 0; i < dev->num_queues; ++i) @@ -4219,6 +4261,12 @@ static const struct profile_inline_ops ops = { .flow_create_profile_inline = flow_create_profile_inline, .flow_destroy_profile_inline = flow_destroy_profile_inline, .flow_nic_set_hasher_fields_inline = flow_nic_set_hasher_fields_inline, + /* + * NT Flow FLM Meter API + */ + .flm_setup_queues = flm_setup_queues, + .flm_free_queues = flm_free_queues, + .flm_update = flm_update, }; void profile_inline_init(void) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index a509a8eb51..bfca8f28b1 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -24,6 +24,11 @@ #include "ntnic_mod_reg.h" #include "nt_util.h" +const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL }; +#define THREAD_CTRL_CREATE(a, b, c, d) rte_thread_create_internal_control(a, b, c, d) +#define THREAD_JOIN(a) rte_thread_join(a, NULL) +#define THREAD_FUNC static uint32_t +#define THREAD_RETURN (0) #define HW_MAX_PKT_LEN (10000) #define MAX_MTU (HW_MAX_PKT_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN) @@ -120,6 +125,16 @@ store_pdrv(struct drv_s *p_drv) rte_spinlock_unlock(&hwlock); } +static void clear_pdrv(struct drv_s *p_drv) +{ + if (p_drv->adapter_no > NUM_ADAPTER_MAX) + return; + + rte_spinlock_lock(&hwlock); + _g_p_drv[p_drv->adapter_no] = NULL; + rte_spinlock_unlock(&hwlock); +} + static struct drv_s * get_pdrv_from_pci(struct rte_pci_addr addr) { @@ -1240,6 +1255,13 @@ eth_dev_set_link_down(struct rte_eth_dev *eth_dev) static void drv_deinit(struct drv_s *p_drv) { + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "profile_inline module uninitialized"); + return; + } + const struct adapter_ops *adapter_ops = get_adapter_ops(); if (adapter_ops == NULL) { @@ -1251,6 +1273,22 @@ drv_deinit(struct drv_s *p_drv) return; ntdrv_4ga_t *p_nt_drv = &p_drv->ntdrv; + fpga_info_t *fpga_info = &p_nt_drv->adapter_info.fpga_info; + + /* + * Mark the global pdrv for cleared. Used by some threads to terminate. + * 1 second to give the threads a chance to see the termonation. + */ + clear_pdrv(p_drv); + nt_os_wait_usec(1000000); + + /* stop statistics threads */ + p_drv->ntdrv.b_shutdown = true; + + if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { + THREAD_JOIN(p_nt_drv->flm_thread); + profile_inline_ops->flm_free_queues(); + } /* stop adapter */ adapter_ops->deinit(&p_nt_drv->adapter_info); @@ -1359,6 +1397,43 @@ static const struct eth_dev_ops nthw_eth_dev_ops = { .promiscuous_enable = promiscuous_enable, }; +/* + * Adapter flm stat thread + */ +THREAD_FUNC adapter_flm_update_thread_fn(void *context) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, NTNIC, "%s: profile_inline module uninitialized", __func__); + return THREAD_RETURN; + } + + struct drv_s *p_drv = context; + + struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv; + struct adapter_info_s *p_adapter_info = &p_nt_drv->adapter_info; + struct nt4ga_filter_s *p_nt4ga_filter = &p_adapter_info->nt4ga_filter; + struct flow_nic_dev *p_flow_nic_dev = p_nt4ga_filter->mp_flow_device; + + NT_LOG(DBG, NTNIC, "%s: %s: waiting for port configuration", + p_adapter_info->mp_adapter_id_str, __func__); + + while (p_flow_nic_dev->eth_base == NULL) + nt_os_wait_usec(1 * 1000 * 1000); + + struct flow_eth_dev *dev = p_flow_nic_dev->eth_base; + + NT_LOG(DBG, NTNIC, "%s: %s: begin", p_adapter_info->mp_adapter_id_str, __func__); + + while (!p_drv->ntdrv.b_shutdown) + if (profile_inline_ops->flm_update(dev) == 0) + nt_os_wait_usec(10); + + NT_LOG(DBG, NTNIC, "%s: %s: end", p_adapter_info->mp_adapter_id_str, __func__); + return THREAD_RETURN; +} + static int nthw_pci_dev_init(struct rte_pci_device *pci_dev) { @@ -1369,6 +1444,13 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) /* Return statement is not necessary here to allow traffic processing by SW */ } + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "profile_inline module uninitialized"); + /* Return statement is not necessary here to allow traffic processing by SW */ + } + nt_vfio_init(); const struct port_ops *port_ops = get_port_ops(); @@ -1597,6 +1679,18 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) return -1; } + if (profile_inline_ops != NULL && fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { + profile_inline_ops->flm_setup_queues(); + res = THREAD_CTRL_CREATE(&p_nt_drv->flm_thread, "ntnic-nt_flm_update_thr", + adapter_flm_update_thread_fn, (void *)p_drv); + + if (res) { + NT_LOG_DBGX(ERR, NTNIC, "%s: error=%d", + (pci_dev->name[0] ? pci_dev->name : "NA"), res); + return -1; + } + } + n_phy_ports = fpga_info->n_phy_ports; for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) { diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 1069be2f85..27d6cbef01 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -256,6 +256,13 @@ struct profile_inline_ops { int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev, int hsh_idx, struct nt_eth_rss_conf rss_conf); + + /* + * NT Flow FLM queue API + */ + void (*flm_setup_queues)(void); + void (*flm_free_queues)(void); + uint32_t (*flm_update)(struct flow_eth_dev *dev); }; void register_profile_inline_ops(const struct profile_inline_ops *ops); -- 2.45.0