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 4EF7B45B96; Mon, 21 Oct 2024 23:09:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3CCF40EA5; Mon, 21 Oct 2024 23:06:24 +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 670DF40612 for ; Mon, 21 Oct 2024 23:06:03 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2172.outbound.protection.outlook.com [104.47.51.172]) by mx-outbound46-162.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:06:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qsL/IV7ZmcEScd/LvRNDSrioSvxhvAa3uF0tCNj+Mr0zCsYZSPnvpn0j8LFVfO/KjL5dUzfe2Jqg3OQwNYfCNfFGb7eK3nVqoEhFZl1vYwCXQalnJl/pRFXecGS7g2yHfmtOXHc7itIOQHLpYdW5uFkLuA66XefJRIhsKrpNFwEKwP82qo/Xu/GRLSlEO6FLRm1H1RUmSI7iZlzmiKo2psw8j4RcysxOLAwIs35j3UKmBF1yLHg9XxSgWDEAbHn/PcAxkebJLnDY4aR04DIHsbfqHyUEEyitiZ0zsQxUGOZtYuVWmWzvuxWxQFCichGeSZ3TSMQdLmhhdiwluEoWew== 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=f+r3XK47SrPYKuLUKsuQYReXHDbYGuK4JKnYIRfTgQM=; b=cq3fMeu0OioKBtD1DByCunNiKJeqjAA2jOOw1ddIM4g77V7909WIcgWyKfnyVR6zxupDw1Rs5qq/489fiR3oPDNb/L856lMayyFM083TwOcPu1O9FYSYZmFXC7lyvZBg6dbiMqJMZlGkh7F2Ttou4Y0uhsN2Yb36Bp7snXCQzFX9CaxfdcoSkJk62tR0I4GYR0Yzn+ErIUQgVgUlEWzASZgs9iMLtNlKvIO36xUE+HAxNMQaEXCWRl7qeZcAs2agx7+5hmouXAyz86aNjKCfzBRmuE0LNJK6q4t3E2butE8EV71zTlv/gpVazv6ibZP1LhxVKHiOXjONFY2mIDKmBg== 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=f+r3XK47SrPYKuLUKsuQYReXHDbYGuK4JKnYIRfTgQM=; b=V6Nqn4/gVnR6P43VGysSX9YeAGGk1Y72g2T8teeDlmstnb2lsW2qCPdlZJCGAjI7Ib8boxpFQYaoKLzlYPSHycYPft/1tDr+acHDnYrw0jW5D3fd9/EomUzRp0At56PiQdLx7BWU9mWTe7AkDgHqvjOpFcNP7ku10A0/lv9kwlw= Received: from AS9PR04CA0156.eurprd04.prod.outlook.com (2603:10a6:20b:48a::28) by AS4P190MB1733.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Mon, 21 Oct 2024 21:05:57 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::21) by AS9PR04CA0156.outlook.office365.com (2603:10a6:20b:48a::28) 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:05:57 +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:05:57 +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 35/73] net/ntnic: add learn flow queue handling Date: Mon, 21 Oct 2024 23:04:37 +0200 Message-ID: <20241021210527.2075431-36-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_|AS4P190MB1733:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: c28309ec-84ea-4282-e4c7-08dcf214288e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bb2HwOyar19wC2icLyy5psLfykuZnUrD08ZhypndOaRYCrvfR6ZkQ2NtuKe1?= =?us-ascii?Q?k6BhXrcD7eWTNnBhdTAHmVSbQOEi2CB5GUWMcoMBUvi9q28VsmByxqPmwU4n?= =?us-ascii?Q?MrtiJe6WIg3s7JpG4ZOU4kc7vQb+BQDDs+/b0d1JQKn7zeK7RWa1hYmfmKw1?= =?us-ascii?Q?BAqRqFSD0VgrDVFQUEHjU1OLg/myw39mX89CqqNmwAn9yU6wl5Z4XVUorkRL?= =?us-ascii?Q?YjxgQEKgtv3OW55EtRAZq6ZfjNt5dmrzYgOOgvsyzCAMst04/xl3PtMwp8sY?= =?us-ascii?Q?oZ5wPirUDW96IB8PksbStdMa88ib/my6EUuXFTXJ5oaMjcBORSS6GPCNahJ2?= =?us-ascii?Q?LeAh2/yqh4ZE0sKBqPMCbBtMnQfIMjC+JLyus2RulbNO879/pA2M+oXiAHfP?= =?us-ascii?Q?QNyNvIvsHowKKZqtjtK3izThQmXrGT+PxUvImMQK496m5HPYU9QtPelBhNLi?= =?us-ascii?Q?KjbRpSx96PQWqBgayl7wpMkrLLxbkMHFA3qXSodMn3tH5R9f7AXMI0Ygxl4t?= =?us-ascii?Q?I7WYJcWSs+AdSIRk5h3SEF65ZAHgbJR41ZEhcp2KxzL65d21QMFTxc4RIcdY?= =?us-ascii?Q?ZBa9CPvzHKM2DPpEzxd9XzB9ovhMQ2RE6TvG7yl00Gj+418tfa52kI97ZOPK?= =?us-ascii?Q?dPT+69z/4nEl9YD46kye+IZ2DeHFLKNA2EGSlkBseQ0in2LBtfWA2lQ9+qGz?= =?us-ascii?Q?i8OHRKjIdqbogkBhQOa5eOAC/IRY+8pFp1VoLsYLef+oPNCEMGuwQ2kCplZg?= =?us-ascii?Q?Lx+tmILoHB7fyYKgiVpKQTUFkvqsiF0hti6TiW6XjI43C0HmovLneTuMQToB?= =?us-ascii?Q?5U562DHEz0VFFOXJgqrw05dzGXOb9VD8/STpI9tQuNXWe0GJVHVFzy8wVrDQ?= =?us-ascii?Q?YbWSjippAXebi4Cm8i24Y4axbiQKQP+aHnu9a+lIm0TYErUEW1e0mFKJ/F9P?= =?us-ascii?Q?iiS8VNU3Z4ubpcgYMxuLzwYBTHMJyPQb1/BZDZ0HP5HkEz5F9y/RRQwvWDnO?= =?us-ascii?Q?mS8GdLJyvPIrQfAKIiTC7hhA9kM/rQ0Ox1C3WvQAVPAksPMRiP5t008GaLFZ?= =?us-ascii?Q?831wVYlwRQn4dZt4s3lwftIilKVLub01iuqacADqrRbqqfPKTC1NNVx2jiMt?= =?us-ascii?Q?YhFL7UcOiBNRa+0vlxfhrQuM0GNC4NuoG589zXSTezLG/YDO3efl0x/0OKCk?= =?us-ascii?Q?sH1xbpgwHQQatN9aHXPog+zbwi760At8kbuyaIAp36THo+7Lz/o8TMU+03qF?= =?us-ascii?Q?x6cuP8L6WVPQ+xsrAdldzUU/ZBBXO+vLgqfJmZBZsbRQhYtgMa8E/1eKaJSp?= =?us-ascii?Q?OurA+bttssg+EAcrLvEuy03lu/Q1l20UGOJkuUZW9xvOfBNXmUdcxH9Mzyof?= =?us-ascii?Q?zfut8YjlDOLDyq+44w46dgAZGsGMbtZ8DC2io4Tx7aIXaAiAwg=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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nTgU97x9OygTko7gbFDtWzJytfZy/c8i0YAnkLhwZhN/2t779uR29DwLlKZiXvp+JzqgEqIqsdoidfOh1PwWn093LAP78OdbaHsx5QWuhuTYGAO8HMebLDqEsdNGzng8JYnQPROpPcxWN+svkKRKZi9v0d98PQCFcmTKLcc2P9mse1KqCPmvYvEaUxcU6+aS45GRW8/WjiLB/pNbdqZtPuH7SgeSg+72kDToxMXPq+qSQjVZdFIo58Xosaj8+LIE5S1OUQ3vlJB7+60Au8wIQS36PKyqz8puWGgPxH4TvRStmEiXf8/tYxCv888lAjsYnf7F0DU/d2WLF0710gVEwDUabgXLEgjBNEP5m9T+9RL1P2GLvw9tK5iNZOK1FLQtzAI52AExt+Dehw0jDAgxonmM4pBxSUlKWIe7qVOSn8aIs5ldN4eQgHzvV0gdvLAmKIjvKYe1TR/5suKJ2FsG200Ax302KMNcq6yTq/hi8nooUtvtANn3M9sPo2VfaOJkYLhq+SychnGtU5SPK/eW+shyuI2D8rrybiGFVb6Oh+5KCEZcVgqSq1qXCIroIjbEQ/uk3HDY+E7VOXG3+950EuSlAl1xAIlavt5375Dq2Td15ikuONPk50Jo68Z2TrUDUsZ8nQe5b8ZjSdacvp3jn2Dy1ID09Z4dP9Lf9oDzHTo= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:57.1926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c28309ec-84ea-4282-e4c7-08dcf214288e 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: AS4P190MB1733 X-BESS-ID: 1729544759-311938-13020-41198-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.172 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGxiZGQGYGUNQk1cTMzNLIxM Lc0NTAONk4zcTYzMjQPDXRzDjVMsUwWak2FgCXacmAQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259883 [from cloudscan9-212.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 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 18d8573bb7..cbd26629cd 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 @@ -38,6 +38,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) @@ -4223,6 +4265,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