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 2F51D45B04; Thu, 10 Oct 2024 16:20:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68F0540E01; Thu, 10 Oct 2024 16:15:39 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 2778640672 for ; Thu, 10 Oct 2024 16:15:13 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2113.outbound.protection.outlook.com [104.47.18.113]) by mx-outbound11-198.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Oct 2024 14:15:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yaVDAcK+iMyvF24YbKrZ8vQ2CgNcMwkmh7zlCcImZHMQ3Q5cCWc6NMHgs2BB5MNw9ZO6QOxNUJwJ4vjnMqrxeMjYuGEdZXOfA/UxQUtR3de7JvJbSCPo6SerI1UZAbppTXNIYpNPXEk1Nlhn2jdv1gbartLOJCixweYPDlKAgS1r24cHFnvAubTsMalLWmghrtYfpjP+1Kd18X/hVzVY8rn7IpLcB8zIephaFuKj8c5n1QbseajkC9LlMnE2aZml6tUtWGdUu0UORpsssM4b6WQyc8aJCTEwu6LVhueNEoHD6EuI/wW0XYHiFfgGnSI6FC1yw8JowNPOFunvSuf8HA== 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=nV0yxT7D0N00/n4qiszBQ2Zhl3ycIzbhz5J/lqQr/Ts=; b=SXFS46LojCW1C/UxeFglGDdPH+CJZcsx1xf1PWnVy/ZN4l8sztAb2oBzuzvMtRdjxY3905YqLGiu22t6ljANBWTOCSVN9M3M/ciNaHnImrRycKlylBqNXYCuxaqZF0N/xJTGfIQ3Gp78Fw5o826SKVQpyhLqdToqIE7nkRJvhhTmYSL+qvzAEUgXcLhingBCda0qY8cFGJN7eQchJENxNfyg82sa6vksHB3mT40j1FV9vNCpnt0Ku/QXd6ZMr1qGx4j1legJlPvbWPAfOJO8EO2OSNhOGlH4OvGjScMhYNY65VlxQlkUhQZaUqzydw49g5eH6j4tT4lC7e8ILR2U5A== 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=nV0yxT7D0N00/n4qiszBQ2Zhl3ycIzbhz5J/lqQr/Ts=; b=gpKiJyaUe26d3OHivJRGcm9Izrv/AEqcFvbJcbdYoE6hZyYwWxnRApG3PmVRc0D1jc1ksBHwrDdAKGGPdE4ra21R7HQNvYyLECCWepLOMlfiAOJQhUFj2UfhqG36QjFnQ5o+/Msb8SW2DTfxrDXCF5VSkD/6e13UX4oA8yXWYeI= Received: from DU2PR04CA0079.eurprd04.prod.outlook.com (2603:10a6:10:232::24) by AM7P190MB0598.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:11c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Thu, 10 Oct 2024 14:15:06 +0000 Received: from DU6PEPF0000B61B.eurprd02.prod.outlook.com (2603:10a6:10:232:cafe::f8) by DU2PR04CA0079.outlook.office365.com (2603:10a6:10:232::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Thu, 10 Oct 2024 14:15:06 +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 DU6PEPF0000B61B.mail.protection.outlook.com (10.167.8.132) with Microsoft SMTP Server id 15.20.8048.13 via Frontend Transport; Thu, 10 Oct 2024 14:15:06 +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 v3 42/50] net/ntnic: add init for virt queues in the DBS Date: Thu, 10 Oct 2024 16:13:57 +0200 Message-ID: <20241010141416.4063591-43-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241010141416.4063591-1-sil-plv@napatech.com> References: <20241006203728.330792-2-sil-plv@napatech.com> <20241010141416.4063591-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B61B:EE_|AM7P190MB0598:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 568f8962-d2cb-4a5f-6b6a-08dce935f0f6 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?BqSa8Dukl/1v6az8uxdVe7TrGXC3Rru5d266PsUbit1i7MVOQk1FlHt7Nrxi?= =?us-ascii?Q?o1S7wOQa4PTbREcxTL0+xkCdEXsqKker+pgdharTrpHIC92EVVtYBW/e/jTY?= =?us-ascii?Q?63Mr8nIVM0jEyr9JFvSpkgdkZI9vCI5a/T1vCkbloTenCcxSLM0ldOEpSwIq?= =?us-ascii?Q?Hgh6ckRbTnqzDrSsQ3ZefbL3AY8XKYTPaYjI0hIVdgEVOPHaAJAJ/lDzC7i0?= =?us-ascii?Q?ZvsZzz1+jp46eM+x2EPmg9sU+S0sRhKaMVZ46vB9ZhqXc7g2Eo9e90VeGRKh?= =?us-ascii?Q?f2t2Q9BWAfFbeEOE8vHbHkBoQuQ5NceqVkwuSrGluRNB0wSB7/mVRJHGWTup?= =?us-ascii?Q?o+qtSbNoj2wVOb62fef1CIEKBy8xcu5Pzus8cuweh6eo9ad28JXKhfhzfQvD?= =?us-ascii?Q?amWLB10befrqk3dNM1KQcJW20LaslitnBXaclUAtUhip1oBkiLsIuCTCeU04?= =?us-ascii?Q?JwIYLX8LRCADa63Y+zjUqUkKSgEESHXpHGLS0Tn/W7hOb3FSZMD87tXwaSB4?= =?us-ascii?Q?5qDQdn2+DE01pWTXLSdgpMPQ8UB9YvVTEZt9jMy+uyLwDygCG2nlVBFCImYV?= =?us-ascii?Q?WcesjMeZsAcWlSho3d0nAzg7/d4JZUL3JQxQt3jv6e75BfWJq9aN2caNh7hy?= =?us-ascii?Q?MwS5ZLQ0ADNzMwsTyMXusNoh/jZ5LCK9FcHdeq8x8sBAYz5uVRfaT16LWtTG?= =?us-ascii?Q?EpAXlqbCip96Eaw2KRk8/eyn04MvNLZQpB+by7GNXflZcUathvoREV8CA/Vu?= =?us-ascii?Q?y7tY3cuxFRWSN85+ZV4cPmMIMsnfwgAV6+mlP3LcP0DPVMEIyN5OhBVUl2Nj?= =?us-ascii?Q?8GwD80fOOsDPnaVuFjW2CWZzbuWYMZvi8avcSMJpm+pDLM7eYc9BhgH2hdV7?= =?us-ascii?Q?cgmluTyQOX7xIPPIutr1O0OEjR7h4LwcT6ZPs5Lmgojui3IV/uXhh8pOIzGd?= =?us-ascii?Q?e+zJIIpe2bLArtnZ7xgLG/sLIq/9oI5sgtnwVlNL2r59xEctg5zNiuPaQczE?= =?us-ascii?Q?/HqJhBoN3DuR2vTlMbndYhV/S8PKP8kJXS2nOzDn2vLFTWeHdDGBSrpawT29?= =?us-ascii?Q?+4fsl+oNmcBF0T/vzRorcDddfpyBL0/Wys+xrb4mLwOl9XXjfxhErP8lFvfQ?= =?us-ascii?Q?a7wsg4N8YCzT5xoymm/8888fCFkFz5AE6vfyI7tnmODs5Q2AiVd/PYhCB95Q?= =?us-ascii?Q?z7p9RMfGoTvfjR2rpWZLf0NUlIQ11MrYuvjJXVntAYdXUQ62Ri7G/pupVQTR?= =?us-ascii?Q?GqvB2bKY1u8SbMbp5u0dSIHYirvlj2m6q1Im7nz1CL2+5Wzh81s5mE1aPfEk?= =?us-ascii?Q?ziLrjAXIzvBjK/QB9y3nXZY2pY/PCfDsn8XdOY9aD6+hmOhAytpsQwomRcVA?= =?us-ascii?Q?6RU4nQM=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: 7tincC/Fe24FtbDLk34EBe+n0x9sP9g5hv3XyOfzLVdzCszTEWyyfDZjjZgP8eG9geZ0gYNs3B03ZlW5KcN+hLdNxrIT3B3oLAes/lzB+/0NE1Tz2b0bwnwmfRv3m1cLOGHyiXQsA72gGYLiONyXY2s2jYO2JGFNhNXi3JRBUtacdgZzmK33qZsHs8Lw89JDHH+cwTHuW6ta24F2BUxQRdY5+Q2v2+LGUCyc87wCQxvc1IMNGQYTOQJX1EufPKF2QK5uw6d0MW8glUExIngPIOBGQDeqAtOC7lEDqN9yUzXxPMQxNRX/Wb3FDBAVW8p2FYEDRhym+cxi7Hqc/8SI6ee2hbPp5++40cSmf85w7pLNFlJ3RwqbWtDbu+evcBON7mSi03gfFaJeUvw1RxhyHazK4VkZzOQS/q6KK40GCdrjIRb/7ip2B3R1s0iyoj1cKBJ3yrrYGf+uK8T5kJcOOQ1tqNfjNgn1aVZZz49yPWxDfH5ArWrkDE5EskLqwrrZY2yJuyKFnin2evhKfUymuKasmdkI5KjFl9H/m58VXQwcoa7mWg0z8DJL5Nhm87xPeqmopTj2Dgu/5KXpPph9tB6Rf6XlE1szhB/mNVpFvC5k8hCOnYKr+h03Qe2m6K8F6Sg9E4lea0VMQmmKCloJqjUB/mfM8T/TaoSUuccgubE= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 14:15:06.2331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 568f8962-d2cb-4a5f-6b6a-08dce935f0f6 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: DU6PEPF0000B61B.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0598 X-BESS-ID: 1728569708-303014-12781-25650-2 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.18.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYm5oaWQGYGUNTEONHM0izNIt Uk0cw4xSgp1TLZONXANDkl0SDV0NzcTKk2FgDikkJzQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259630 [from cloudscan21-174.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 DBS (DVIO Buffer System) module controls the scatter-gather buffer system that let's the host CPU interact with packets. Macros and Definitions: Defined constants for queue management and polling speeds. Data Structures: Added structures and arrays for RX and TX queue management. Procedures: Implemented initialization routines for setting up queues and configuring Direct Buffer Storage (DBS) in FPGA. Main Initialization: Allocates DBS modules, resets, and configures RX and TX queues. Signed-off-by: Danylo Vodopianov --- v3 * Remove newline characters from logs. --- drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 154 ++++++++++++++++++ drivers/net/ntnic/include/ntnic_dbs.h | 71 +++++++- drivers/net/ntnic/meson.build | 2 + drivers/net/ntnic/nthw/dbs/nthw_dbs.c | 135 +++++++++++++++ .../ntnic/nthw/supported/nthw_fpga_mod_defs.h | 1 + drivers/net/ntnic/ntnic_mod_reg.c | 11 +- drivers/net/ntnic/ntnic_mod_reg.h | 2 + 7 files changed, 374 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c create mode 100644 drivers/net/ntnic/nthw/dbs/nthw_dbs.c diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c new file mode 100644 index 0000000000..aa91be3923 --- /dev/null +++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c @@ -0,0 +1,154 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include + +#include "ntos_drv.h" +#include "ntnic_virt_queue.h" +#include "ntnic_mod_reg.h" +#include "ntlog.h" + +#define MAX_VIRT_QUEUES 128 + +#define LAST_QUEUE 127 +#define DISABLE 0 +#define ENABLE 1 +#define RX_AM_DISABLE DISABLE +#define RX_AM_ENABLE ENABLE +#define RX_UW_DISABLE DISABLE +#define RX_UW_ENABLE ENABLE +#define RX_Q_DISABLE DISABLE +#define RX_Q_ENABLE ENABLE +#define RX_AM_POLL_SPEED 5 +#define RX_UW_POLL_SPEED 9 +#define INIT_QUEUE 1 + +#define TX_AM_DISABLE DISABLE +#define TX_AM_ENABLE ENABLE +#define TX_UW_DISABLE DISABLE +#define TX_UW_ENABLE ENABLE +#define TX_Q_DISABLE DISABLE +#define TX_Q_ENABLE ENABLE +#define TX_AM_POLL_SPEED 5 +#define TX_UW_POLL_SPEED 8 + +enum nthw_virt_queue_usage { + NTHW_VIRTQ_UNUSED = 0 +}; + +struct nthw_virt_queue { + enum nthw_virt_queue_usage usage; +}; + +static struct nthw_virt_queue rxvq[MAX_VIRT_QUEUES]; +static struct nthw_virt_queue txvq[MAX_VIRT_QUEUES]; + +static void dbs_init_rx_queue(nthw_dbs_t *p_nthw_dbs, uint32_t queue, uint32_t start_idx, + uint32_t start_ptr) +{ + uint32_t busy; + uint32_t init; + uint32_t dummy; + + do { + get_rx_init(p_nthw_dbs, &init, &dummy, &busy); + } while (busy != 0); + + set_rx_init(p_nthw_dbs, start_idx, start_ptr, INIT_QUEUE, queue); + + do { + get_rx_init(p_nthw_dbs, &init, &dummy, &busy); + } while (busy != 0); +} + +static void dbs_init_tx_queue(nthw_dbs_t *p_nthw_dbs, uint32_t queue, uint32_t start_idx, + uint32_t start_ptr) +{ + uint32_t busy; + uint32_t init; + uint32_t dummy; + + do { + get_tx_init(p_nthw_dbs, &init, &dummy, &busy); + } while (busy != 0); + + set_tx_init(p_nthw_dbs, start_idx, start_ptr, INIT_QUEUE, queue); + + do { + get_tx_init(p_nthw_dbs, &init, &dummy, &busy); + } while (busy != 0); +} + +static int nthw_virt_queue_init(struct fpga_info_s *p_fpga_info) +{ + assert(p_fpga_info); + + nthw_fpga_t *const p_fpga = p_fpga_info->mp_fpga; + nthw_dbs_t *p_nthw_dbs; + int res = 0; + uint32_t i; + + p_fpga_info->mp_nthw_dbs = NULL; + + p_nthw_dbs = nthw_dbs_new(); + + if (p_nthw_dbs == NULL) + return -1; + + res = dbs_init(NULL, p_fpga, 0);/* Check that DBS exists in FPGA */ + + if (res) { + free(p_nthw_dbs); + return res; + } + + res = dbs_init(p_nthw_dbs, p_fpga, 0); /* Create DBS module */ + + if (res) { + free(p_nthw_dbs); + return res; + } + + p_fpga_info->mp_nthw_dbs = p_nthw_dbs; + + for (i = 0; i < MAX_VIRT_QUEUES; ++i) { + rxvq[i].usage = NTHW_VIRTQ_UNUSED; + txvq[i].usage = NTHW_VIRTQ_UNUSED; + } + + dbs_reset(p_nthw_dbs); + + for (i = 0; i < NT_DBS_RX_QUEUES_MAX; ++i) + dbs_init_rx_queue(p_nthw_dbs, i, 0, 0); + + for (i = 0; i < NT_DBS_TX_QUEUES_MAX; ++i) + dbs_init_tx_queue(p_nthw_dbs, i, 0, 0); + + set_rx_control(p_nthw_dbs, LAST_QUEUE, RX_AM_DISABLE, RX_AM_POLL_SPEED, RX_UW_DISABLE, + RX_UW_POLL_SPEED, RX_Q_DISABLE); + set_rx_control(p_nthw_dbs, LAST_QUEUE, RX_AM_ENABLE, RX_AM_POLL_SPEED, RX_UW_ENABLE, + RX_UW_POLL_SPEED, RX_Q_DISABLE); + set_rx_control(p_nthw_dbs, LAST_QUEUE, RX_AM_ENABLE, RX_AM_POLL_SPEED, RX_UW_ENABLE, + RX_UW_POLL_SPEED, RX_Q_ENABLE); + + set_tx_control(p_nthw_dbs, LAST_QUEUE, TX_AM_DISABLE, TX_AM_POLL_SPEED, TX_UW_DISABLE, + TX_UW_POLL_SPEED, TX_Q_DISABLE); + set_tx_control(p_nthw_dbs, LAST_QUEUE, TX_AM_ENABLE, TX_AM_POLL_SPEED, TX_UW_ENABLE, + TX_UW_POLL_SPEED, TX_Q_DISABLE); + set_tx_control(p_nthw_dbs, LAST_QUEUE, TX_AM_ENABLE, TX_AM_POLL_SPEED, TX_UW_ENABLE, + TX_UW_POLL_SPEED, TX_Q_ENABLE); + + return 0; +} + +static struct sg_ops_s sg_ops = { + .nthw_virt_queue_init = nthw_virt_queue_init +}; + +void sg_init(void) +{ + NT_LOG(INF, NTNIC, "SG ops initialized"); + register_sg_ops(&sg_ops); +} diff --git a/drivers/net/ntnic/include/ntnic_dbs.h b/drivers/net/ntnic/include/ntnic_dbs.h index 551c6ade43..a64d2a0aeb 100644 --- a/drivers/net/ntnic/include/ntnic_dbs.h +++ b/drivers/net/ntnic/include/ntnic_dbs.h @@ -8,12 +8,81 @@ #include "nthw_fpga_model.h" +#define NT_DBS_RX_QUEUES_MAX (128) +#define NT_DBS_TX_QUEUES_MAX (128) + /* * Struct for implementation of memory bank shadows */ -struct nthw_dbs_s; +struct nthw_dbs_s { + nthw_fpga_t *mp_fpga; + nthw_module_t *mp_mod_dbs; + int mn_instance; + + int mn_param_dbs_present; + + nthw_register_t *mp_reg_rx_control; + nthw_field_t *mp_fld_rx_control_last_queue; + nthw_field_t *mp_fld_rx_control_avail_monitor_enable; + nthw_field_t *mp_fld_rx_control_avail_monitor_scan_speed; + nthw_field_t *mp_fld_rx_control_used_write_enable; + nthw_field_t *mp_fld_rx_control_used_writer_update_speed; + nthw_field_t *mp_fld_rx_control_rx_queues_enable; + + nthw_register_t *mp_reg_tx_control; + nthw_field_t *mp_fld_tx_control_last_queue; + nthw_field_t *mp_fld_tx_control_avail_monitor_enable; + nthw_field_t *mp_fld_tx_control_avail_monitor_scan_speed; + nthw_field_t *mp_fld_tx_control_used_write_enable; + nthw_field_t *mp_fld_tx_control_used_writer_update_speed; + nthw_field_t *mp_fld_tx_control_tx_queues_enable; + + nthw_register_t *mp_reg_rx_init; + nthw_field_t *mp_fld_rx_init_init; + nthw_field_t *mp_fld_rx_init_queue; + nthw_field_t *mp_fld_rx_init_busy; + + nthw_register_t *mp_reg_rx_init_val; + nthw_field_t *mp_fld_rx_init_val_idx; + nthw_field_t *mp_fld_rx_init_val_ptr; + + nthw_register_t *mp_reg_tx_init; + nthw_field_t *mp_fld_tx_init_init; + nthw_field_t *mp_fld_tx_init_queue; + nthw_field_t *mp_fld_tx_init_busy; + + nthw_register_t *mp_reg_tx_init_val; + nthw_field_t *mp_fld_tx_init_val_idx; + nthw_field_t *mp_fld_tx_init_val_ptr; + +}; typedef struct nthw_dbs_s nthw_dbs_t; +nthw_dbs_t *nthw_dbs_new(void); +int dbs_init(nthw_dbs_t *p, nthw_fpga_t *p_fpga, int n_instance); +void dbs_reset(nthw_dbs_t *p); + +int set_rx_control(nthw_dbs_t *p, + uint32_t last_queue, + uint32_t avail_monitor_enable, + uint32_t avail_monitor_speed, + uint32_t used_write_enable, + uint32_t used_write_speed, + uint32_t rx_queue_enable); +int set_tx_control(nthw_dbs_t *p, + uint32_t last_queue, + uint32_t avail_monitor_enable, + uint32_t avail_monitor_speed, + uint32_t used_write_enable, + uint32_t used_write_speed, + uint32_t tx_queue_enable); +int set_rx_init(nthw_dbs_t *p, uint32_t start_idx, uint32_t start_ptr, uint32_t init, + uint32_t queue); +int get_rx_init(nthw_dbs_t *p, uint32_t *init, uint32_t *queue, uint32_t *busy); +int set_tx_init(nthw_dbs_t *p, uint32_t start_idx, uint32_t start_ptr, uint32_t init, + uint32_t queue); +int get_tx_init(nthw_dbs_t *p, uint32_t *init, uint32_t *queue, uint32_t *busy); + #endif /* _NTNIC_DBS_H_ */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 66d2770da7..3d9566a52e 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -24,9 +24,11 @@ includes = [ # all sources sources = files( 'adapter/nt4ga_adapter.c', + 'dbsconfig/ntnic_dbsconfig.c', 'link_mgmt/link_100g/nt4ga_link_100g.c', 'link_mgmt/nt4ga_link.c', 'nim/i2c_nim.c', + 'nthw/dbs/nthw_dbs.c', 'nthw/supported/nthw_fpga_9563_055_049_0000.c', 'nthw/supported/nthw_fpga_instances.c', 'nthw/supported/nthw_fpga_mod_str_map.c', diff --git a/drivers/net/ntnic/nthw/dbs/nthw_dbs.c b/drivers/net/ntnic/nthw/dbs/nthw_dbs.c new file mode 100644 index 0000000000..ed6e4b3088 --- /dev/null +++ b/drivers/net/ntnic/nthw/dbs/nthw_dbs.c @@ -0,0 +1,135 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include "ntlog.h" + +#include "nthw_drv.h" +#include "nthw_register.h" + +nthw_dbs_t *nthw_dbs_new(void) +{ + nthw_dbs_t *p = malloc(sizeof(nthw_dbs_t)); + + if (p) + memset(p, 0, sizeof(nthw_dbs_t)); + + return p; +} + +int dbs_init(nthw_dbs_t *p, nthw_fpga_t *p_fpga, int n_instance) +{ + nthw_module_t *mod = nthw_fpga_query_module(p_fpga, MOD_DBS, n_instance); + + if (p == NULL) + return mod == NULL ? -1 : 0; + + if (mod == NULL) { + NT_LOG(ERR, NTHW, "%s: DBS %d: no such instance", + p_fpga->p_fpga_info->mp_adapter_id_str, n_instance); + return -1; + } + + p->mp_fpga = p_fpga; + p->mn_instance = n_instance; + p->mp_mod_dbs = mod; + + p->mn_param_dbs_present = nthw_fpga_get_product_param(p_fpga, NT_DBS_PRESENT, 0); + + if (p->mn_param_dbs_present == 0) { + NT_LOG(WRN, NTHW, + "%s: DBS %d: logical error: module found but not flagged at present", + p->mp_fpga->p_fpga_info->mp_adapter_id_str, p->mn_instance); + } + + return 0; +} + +void dbs_reset(nthw_dbs_t *p) +{ + (void)p; +} + +int set_rx_control(nthw_dbs_t *p, + uint32_t last_queue, + uint32_t avail_monitor_enable, + uint32_t avail_monitor_speed, + uint32_t used_write_enable, + uint32_t used_write_speed, + uint32_t rx_queue_enable) +{ + nthw_field_set_val32(p->mp_fld_rx_control_last_queue, last_queue); + nthw_field_set_val32(p->mp_fld_rx_control_avail_monitor_enable, avail_monitor_enable); + nthw_field_set_val32(p->mp_fld_rx_control_avail_monitor_scan_speed, avail_monitor_speed); + nthw_field_set_val32(p->mp_fld_rx_control_used_write_enable, used_write_enable); + nthw_field_set_val32(p->mp_fld_rx_control_used_writer_update_speed, used_write_speed); + nthw_field_set_val32(p->mp_fld_rx_control_rx_queues_enable, rx_queue_enable); + nthw_register_flush(p->mp_reg_rx_control, 1); + return 0; +} + +int set_tx_control(nthw_dbs_t *p, + uint32_t last_queue, + uint32_t avail_monitor_enable, + uint32_t avail_monitor_speed, + uint32_t used_write_enable, + uint32_t used_write_speed, + uint32_t tx_queue_enable) +{ + nthw_field_set_val32(p->mp_fld_tx_control_last_queue, last_queue); + nthw_field_set_val32(p->mp_fld_tx_control_avail_monitor_enable, avail_monitor_enable); + nthw_field_set_val32(p->mp_fld_tx_control_avail_monitor_scan_speed, avail_monitor_speed); + nthw_field_set_val32(p->mp_fld_tx_control_used_write_enable, used_write_enable); + nthw_field_set_val32(p->mp_fld_tx_control_used_writer_update_speed, used_write_speed); + nthw_field_set_val32(p->mp_fld_tx_control_tx_queues_enable, tx_queue_enable); + nthw_register_flush(p->mp_reg_tx_control, 1); + return 0; +} + +int set_rx_init(nthw_dbs_t *p, uint32_t start_idx, uint32_t start_ptr, uint32_t init, + uint32_t queue) +{ + if (p->mp_reg_rx_init_val) { + nthw_field_set_val32(p->mp_fld_rx_init_val_idx, start_idx); + nthw_field_set_val32(p->mp_fld_rx_init_val_ptr, start_ptr); + nthw_register_flush(p->mp_reg_rx_init_val, 1); + } + + nthw_field_set_val32(p->mp_fld_rx_init_init, init); + nthw_field_set_val32(p->mp_fld_rx_init_queue, queue); + nthw_register_flush(p->mp_reg_rx_init, 1); + return 0; +} + +int get_rx_init(nthw_dbs_t *p, uint32_t *init, uint32_t *queue, uint32_t *busy) +{ + *init = nthw_field_get_val32(p->mp_fld_rx_init_init); + *queue = nthw_field_get_val32(p->mp_fld_rx_init_queue); + *busy = nthw_field_get_val32(p->mp_fld_rx_init_busy); + return 0; +} + +int set_tx_init(nthw_dbs_t *p, uint32_t start_idx, uint32_t start_ptr, uint32_t init, + uint32_t queue) +{ + if (p->mp_reg_tx_init_val) { + nthw_field_set_val32(p->mp_fld_tx_init_val_idx, start_idx); + nthw_field_set_val32(p->mp_fld_tx_init_val_ptr, start_ptr); + nthw_register_flush(p->mp_reg_tx_init_val, 1); + } + + nthw_field_set_val32(p->mp_fld_tx_init_init, init); + nthw_field_set_val32(p->mp_fld_tx_init_queue, queue); + nthw_register_flush(p->mp_reg_tx_init, 1); + return 0; +} + +int get_tx_init(nthw_dbs_t *p, uint32_t *init, uint32_t *queue, uint32_t *busy) +{ + *init = nthw_field_get_val32(p->mp_fld_tx_init_init); + *queue = nthw_field_get_val32(p->mp_fld_tx_init_queue); + *busy = nthw_field_get_val32(p->mp_fld_tx_init_busy); + return 0; +} diff --git a/drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h b/drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h index 5d6aac122c..b6be02f45e 100644 --- a/drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h +++ b/drivers/net/ntnic/nthw/supported/nthw_fpga_mod_defs.h @@ -16,6 +16,7 @@ #define MOD_UNKNOWN (0L)/* Unknown/uninitialized - keep this as the first element */ #define MOD_CAT (0x30b447c2UL) #define MOD_CSU (0x3f470787UL) +#define MOD_DBS (0x80b29727UL) #define MOD_FLM (0xe7ba53a4UL) #define MOD_GFG (0xfc423807UL) #define MOD_GMF (0x68b1d15aUL) diff --git a/drivers/net/ntnic/ntnic_mod_reg.c b/drivers/net/ntnic/ntnic_mod_reg.c index 8fe5193027..a03c97801b 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.c +++ b/drivers/net/ntnic/ntnic_mod_reg.c @@ -5,9 +5,18 @@ #include "ntnic_mod_reg.h" +static struct sg_ops_s *sg_ops; + +void register_sg_ops(struct sg_ops_s *ops) +{ + sg_ops = ops; +} + const struct sg_ops_s *get_sg_ops(void) { - return NULL; + if (sg_ops == NULL) + sg_init(); + return sg_ops; } static struct link_ops_s *link_100g_ops; diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index e9dff51935..5b97b3d8ac 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -105,7 +105,9 @@ struct sg_ops_s { int (*nthw_virt_queue_init)(struct fpga_info_s *p_fpga_info); }; +void register_sg_ops(struct sg_ops_s *ops); const struct sg_ops_s *get_sg_ops(void); +void sg_init(void); struct link_ops_s { int (*link_init)(struct adapter_info_s *p_adapter_info, nthw_fpga_t *p_fpga); -- 2.45.0