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 D3F6745BC0; Tue, 29 Oct 2024 18:17:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE07543067; Tue, 29 Oct 2024 18:16:46 +0100 (CET) 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 90CAD43245 for ; Tue, 29 Oct 2024 18:16:43 +0100 (CET) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2174.outbound.protection.outlook.com [104.47.51.174]) by mx-outbound43-199.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 17:16:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dmzMcbQ884aXyby5IyGRbrRgwkPnhW/GtS/FblEBa4jpT+Hxf5PcoMTBupurbpwkNWgvrXhvk0A9/c8w2KmDwa/bva2Jnfhyw5Ftl23rVw54mnhzhUVrVgWACZc15Dwa6x+OU4dpPKmw6DnWud4fDJpzeA571ei4s4hm4knMqAhCjTtAELWWgkn2s+X12sxwIxs5RnlMIpZlTvGLmU3FGFsYu5mt/ZwD4cMrLMvxZuCuQYPWVw7GCl/jxjLV/FfeQhm2iz+pnv7PcTrg+4+4pB1J9+nRaWH+hzR8jnWgLk68uG2kha6dW7uJoRbaCS6+YtHRvnt8KWsZwJ3VuLZfyg== 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=43zORsmdZ2HsdkpRuFB8HW4YacqDcSKzq8zaBgeshaw=; b=E+EtZvg6y4GoM82mB2g+tcwbI6OBElaKWxhIlnkJeiTXiWU28VH0Bx0WfNy5xJMBTe6Mr4w7AOkE9eyWv+lo526MiE4elbjh5IBvwkGOEGtCfwr5VOgSOqf2o/g77+Xkn30R2RUqOmfsr+c40imIRX9uv2/o0Y2VLURGbt3z4QVDw06KYEbvl4dmwRKgrJHPOsh4GC7yJZ56jqj3PoLq2UZ2FExXpdnSI5L2MiTM8mgwfqO4rnkXXcyJWVvDBnWVuFih9gqILQXZ34sui2+F17K4ga0MGAKZFcITRQi/4tsj92fbDsZC4P3GsrMk/hndF48G0YhT5Te0cGyqrWG/qA== 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=43zORsmdZ2HsdkpRuFB8HW4YacqDcSKzq8zaBgeshaw=; b=K5QDjC+Ga9GOQBl2QgApci9jC6levfsM08vd5Lsz04uS2aBf6jevejNqjwz2Gn3lc6x3x8bvl6grZEccOwNk7EOVEWfhwAIfaP8HAnZDdgaY3hlSKcejeUKeFivdg/atOdYbalrQ8x4N45bxIubwKHoSsTwDdYm2ObWNa9IknuE= Received: from DUZPR01CA0189.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::7) by AS4P190MB1878.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:505::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:48 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::fc) by DUZPR01CA0189.outlook.office365.com (2603:10a6:10:4b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:48 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:48 +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 v4 56/86] net/ntnic: add statistics poll Date: Tue, 29 Oct 2024 17:42:00 +0100 Message-ID: <20241029164243.1648775-57-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS4P190MB1878:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6239f52b-c77d-4847-6458-08dcf838dcdb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cNOc5U5pZAWXqa4Aepn1KB9v/uj2umUEPafQVtuIEu+3BL7gO8WBFESg5w53?= =?us-ascii?Q?MZcZ7Xne5sGm7v31rNGe2SAr6O6QOQ7z3Izb0eKPcmsA+94WM4Z54UyMlpf4?= =?us-ascii?Q?+pljFlSUZJjMlfTbAQwnygR6JZxWb+jJ1IckfVoaU2zr4Ei4zH9BgrV8ZMD2?= =?us-ascii?Q?Xbh+pjWhctlGEiL4sRknhNk7j4nvM8yRudk8b+IK7k6aA1iwZ6CXIosBri5j?= =?us-ascii?Q?99jUhRghrVehtpplpFqclZGbmj1DQkc+uC5xuPV8xFiNb6UXfrnLVQ+Jhz7w?= =?us-ascii?Q?5zwpweX6u5dwsJB+tgp946WzAWJIcPu8mzxefqufaUKPim7lSP9bDcPaivi3?= =?us-ascii?Q?o1mXDzb9461vq3f0VsGkwW35xnBIaIVCseEdlIb6frfjRxbMMeFFWzG8UMMk?= =?us-ascii?Q?HlXSf/iuAILPf2sFblat6hQ+wG7si822rMmdoN9DJYlOT2RSi9gjScKAs4hv?= =?us-ascii?Q?xOm7sUkQgebxBsNoHzZaQBSXXE/6XPQ0ec/AYO7dYka2WIdIZhiPrFVCVR3L?= =?us-ascii?Q?V57rOenmh5gcQQDR7FN7kmR1EsOgYjuArDsGPfYvGKpmxgvwZdh2TmGSjO8Q?= =?us-ascii?Q?8KXxqDaC4dTP69QtUsP+LwYZxVxNxcU1mOLyJ9xekOcpCSIfeUjUGIhI6zad?= =?us-ascii?Q?BYvdn0QWg9vPz9H7IadPH2Ovkm6A6bPaQ+TvLmAY+q1kT/dGwNZMu2Cmrsee?= =?us-ascii?Q?yptA/F3u5AJ9r8ELFlC+WH50NzFY2rdtVeWyA8AVw5lrHFArCZx9y93AkBLd?= =?us-ascii?Q?hQBoGUu3Ul7RSZpvg5IaQ8YBYU3/VCtdWSXyL8mvUs/0bFvrFR2F6s6rQCMg?= =?us-ascii?Q?VL9JGIop35ZlAI/zNbqjBf+2UFgTB+becMoS+P9YXe+HQIwzgD1x3f67QHqG?= =?us-ascii?Q?+DarLWOpz6bxZo15S/EAF6cTXZdvXfHHtjc/SEv98Yy6E/IyBTioS1XgA2yq?= =?us-ascii?Q?gaKTNcOEbolHFk5Rcft86MvYDiHgzU5YHTFRyrWQr/V/qQm+xEZ36Xd5yqfG?= =?us-ascii?Q?TfLBrrWMPY5WVVKx72zb/bgoxe5wW3RXplrr/kpIsB+fpRe2dj9SDotoZgQ5?= =?us-ascii?Q?2WkFSpvRlhTkBD91b4MJoBuW+Wq5RC/VbwgmAkNPdcvMroI4xjnSZkhJxGs1?= =?us-ascii?Q?1w9eYCfGSDDA46rgGsASs/2oBBJCTGRezW4Q8MqzYlW98WkdAtPsjKRqa7T4?= =?us-ascii?Q?rGObyOXTi0VvL1DjMarY48OTvmvOPe0tt9lSK3YlsuThVKoO+Ew+fY6lhrLO?= =?us-ascii?Q?hwHOEgn4GCCuCszXj2O2N9Zswp79HoxSexCJM3t9PRQVFvs9BqOuAv/c++dz?= =?us-ascii?Q?GaTMJ7I5GNK7fCauAhcBugRpKj4yN32HwLbycQcbTZ62zFxibGM5NmYAerRL?= =?us-ascii?Q?XYGAKf2d+3eB1ct+azGrRjk4mlACVOhib7czOowDriyquwOlRQ=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)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: lU1FaCvVk6snRGzz7qkTccS7Rka2fLpJWg4J2AC86o5wx/YtPP97A2Suzi3limqX6g1eB0TL54RWVzkCPLhdi4eCsHdqwVebuj2JAO9oCdXRXHxzAidc6WaHf9TI7ZTZaM8C63ahtfjJLwDE0xVlTR0/BvrcVBGNOJsP0GeZ1DLICTsAf1Y1G4G20LYTYaa58O71qzQHV2WO9zuCAi8MUDTg2Gc7zyJik2stgflbjSgW4OtQYqoR5uDRtYVfg3Vo8JR57OfFmJ5QZdSlB1TsaOUl2HWixZdjD8glNZUstcxvufFBelg0w9WNwEzhXu3WN+u8M8WWPvLeINS6gJxmYYx0cJEPo7nuJyi+dT41/ffQ0YWidKsA6tr+JA0Q0mbgI+q61fGbYPhBlboQ0mhb/JZZFJP2RM7vWK77qAuEGFCQnJau6GJhB3SH1Tgy8AOgReRvq8KZuiDZoh01+VApZeULimr23stu1TWkhIs4wtGVDQBB479IAjy9FrdNXfUBcFy7UVqULbWoBmZ6YZouwcdDtszbPyB14JqUfiqzBxlaAbXXPavo51dd4+wwtfPcRT3otL8RkgnF6ROywsVomr/GAe9Z8efOI0CWqPGYk10z4eDO4SHJst3e+1AI41QaCLv0sVDjFt7NU0BVTv0m7uoaizOF0BvJUmSxpMnX7Hs= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:48.3552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6239f52b-c77d-4847-6458-08dcf838dcdb 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB1878 X-OriginatorOrg: napatech.com X-BESS-ID: 1730222199-311207-12661-29597-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsbGZuYmQGYGUNTSxNwsLc3Mws QizTLVzMw02TLR1NwoyTDZOM3IyDApSak2FgCQy/rHQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260064 [from cloudscan16-169.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, 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 Mechanism which poll statistics module and update values with dma module. Signed-off-by: Danylo Vodopianov --- .../net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c | 343 ++++++++++++++++++ drivers/net/ntnic/include/ntdrv_4ga.h | 1 + drivers/net/ntnic/include/ntnic_stat.h | 78 ++++ .../net/ntnic/nthw/core/include/nthw_rmc.h | 5 + drivers/net/ntnic/nthw/core/nthw_rmc.c | 20 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 1 + drivers/net/ntnic/nthw/stat/nthw_stat.c | 128 +++++++ drivers/net/ntnic/ntnic_ethdev.c | 143 ++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 2 + 9 files changed, 721 insertions(+) diff --git a/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c b/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c index f733fd5459..3afc5b7853 100644 --- a/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c +++ b/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c @@ -16,6 +16,27 @@ #define DEFAULT_MAX_BPS_SPEED 100e9 +/* Inline timestamp format s pcap 32:32 bits. Convert to nsecs */ +static inline uint64_t timestamp2ns(uint64_t ts) +{ + return ((ts) >> 32) * 1000000000 + ((ts) & 0xffffffff); +} + +static int nt4ga_stat_collect_cap_v1_stats(struct adapter_info_s *p_adapter_info, + nt4ga_stat_t *p_nt4ga_stat, + uint32_t *p_stat_dma_virtual); + +static int nt4ga_stat_collect(struct adapter_info_s *p_adapter_info, nt4ga_stat_t *p_nt4ga_stat) +{ + nthw_stat_t *p_nthw_stat = p_nt4ga_stat->mp_nthw_stat; + + p_nt4ga_stat->last_timestamp = timestamp2ns(*p_nthw_stat->mp_timestamp); + nt4ga_stat_collect_cap_v1_stats(p_adapter_info, p_nt4ga_stat, + p_nt4ga_stat->p_stat_dma_virtual); + + return 0; +} + static int nt4ga_stat_init(struct adapter_info_s *p_adapter_info) { const char *const p_adapter_id_str = p_adapter_info->mp_adapter_id_str; @@ -203,9 +224,331 @@ static int nt4ga_stat_setup(struct adapter_info_s *p_adapter_info) return 0; } +/* Called with stat mutex locked */ +static int nt4ga_stat_collect_cap_v1_stats(struct adapter_info_s *p_adapter_info, + nt4ga_stat_t *p_nt4ga_stat, + uint32_t *p_stat_dma_virtual) +{ + (void)p_adapter_info; + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) + return -1; + + nthw_stat_t *p_nthw_stat = p_nt4ga_stat->mp_nthw_stat; + + const int n_rx_ports = p_nt4ga_stat->mn_rx_ports; + const int n_tx_ports = p_nt4ga_stat->mn_tx_ports; + int c, h, p; + + if (!p_nthw_stat || !p_nt4ga_stat) + return -1; + + if (p_nthw_stat->mn_stat_layout_version < 6) { + NT_LOG(ERR, NTNIC, "HW STA module version not supported"); + return -1; + } + + /* RX ports */ + for (c = 0; c < p_nthw_stat->m_nb_color_counters / 2; c++) { + p_nt4ga_stat->mp_stat_structs_color[c].color_packets += p_stat_dma_virtual[c * 2]; + p_nt4ga_stat->mp_stat_structs_color[c].color_bytes += + p_stat_dma_virtual[c * 2 + 1]; + } + + /* Move to Host buffer counters */ + p_stat_dma_virtual += p_nthw_stat->m_nb_color_counters; + + for (h = 0; h < p_nthw_stat->m_nb_rx_host_buffers; h++) { + p_nt4ga_stat->mp_stat_structs_hb[h].flush_packets += p_stat_dma_virtual[h * 8]; + p_nt4ga_stat->mp_stat_structs_hb[h].drop_packets += p_stat_dma_virtual[h * 8 + 1]; + p_nt4ga_stat->mp_stat_structs_hb[h].fwd_packets += p_stat_dma_virtual[h * 8 + 2]; + p_nt4ga_stat->mp_stat_structs_hb[h].dbs_drop_packets += + p_stat_dma_virtual[h * 8 + 3]; + p_nt4ga_stat->mp_stat_structs_hb[h].flush_bytes += p_stat_dma_virtual[h * 8 + 4]; + p_nt4ga_stat->mp_stat_structs_hb[h].drop_bytes += p_stat_dma_virtual[h * 8 + 5]; + p_nt4ga_stat->mp_stat_structs_hb[h].fwd_bytes += p_stat_dma_virtual[h * 8 + 6]; + p_nt4ga_stat->mp_stat_structs_hb[h].dbs_drop_bytes += + p_stat_dma_virtual[h * 8 + 7]; + } + + /* Move to Rx Port counters */ + p_stat_dma_virtual += p_nthw_stat->m_nb_rx_hb_counters; + + /* RX ports */ + for (p = 0; p < n_rx_ports; p++) { + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 0]; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].broadcast_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 1]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].multicast_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 2]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].unicast_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 3]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_alignment += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 4]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_code_violation += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 5]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_crc += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 6]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].undersize_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 7]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].oversize_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 8]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].fragments += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 9]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].jabbers_not_truncated += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 10]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].jabbers_truncated += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 11]; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_64_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 12]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_65_to_127_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 13]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_128_to_255_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 14]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_256_to_511_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 15]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_512_to_1023_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 16]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_1024_to_1518_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 17]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_1519_to_2047_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 18]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_2048_to_4095_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 19]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_4096_to_8191_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 20]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_8192_to_max_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 21]; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].mac_drop_events += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 22]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_lr += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 23]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].duplicate += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 24]; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_ip_chksum_error += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 25]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_udp_chksum_error += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 26]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_tcp_chksum_error += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 27]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_giant_undersize += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 28]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_baby_giant += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 29]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_not_isl_vlan_mpls += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 30]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_isl += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 31]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_vlan += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 32]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_isl_vlan += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 33]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_mpls += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 34]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_isl_mpls += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 35]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_vlan_mpls += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 36]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_isl_vlan_mpls += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 37]; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_no_filter += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 38]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_dedup_drop += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 39]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_filter_drop += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 40]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_overflow += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 41]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts_dbs_drop += + p_nthw_stat->m_dbs_present + ? p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 42] + : 0; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].octets_no_filter += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 43]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].octets_dedup_drop += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 44]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].octets_filter_drop += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 45]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].octets_overflow += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 46]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].octets_dbs_drop += + p_nthw_stat->m_dbs_present + ? p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 47] + : 0; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].ipft_first_hit += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 48]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].ipft_first_not_hit += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 49]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].ipft_mid_hit += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 50]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].ipft_mid_not_hit += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 51]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].ipft_last_hit += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 52]; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].ipft_last_not_hit += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 53]; + + /* Rx totals */ + uint64_t new_drop_events_sum = + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 22] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 38] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 39] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 40] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 41] + + (p_nthw_stat->m_dbs_present + ? p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 42] + : 0); + + uint64_t new_packets_sum = + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 7] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 8] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 9] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 10] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 11] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 12] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 13] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 14] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 15] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 16] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 17] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 18] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 19] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 20] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 21]; + + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].drop_events += new_drop_events_sum; + p_nt4ga_stat->cap.mp_stat_structs_port_rx[p].pkts += new_packets_sum; + + p_nt4ga_stat->a_port_rx_octets_total[p] += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_rx_port_counters + 0]; + p_nt4ga_stat->a_port_rx_packets_total[p] += new_packets_sum; + p_nt4ga_stat->a_port_rx_drops_total[p] += new_drop_events_sum; + } + + /* Move to Tx Port counters */ + p_stat_dma_virtual += n_rx_ports * p_nthw_stat->m_nb_rx_port_counters; + + for (p = 0; p < n_tx_ports; p++) { + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 0]; + + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].broadcast_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 1]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].multicast_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 2]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].unicast_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 3]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_alignment += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 4]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_code_violation += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 5]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_crc += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 6]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].undersize_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 7]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].oversize_pkts += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 8]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].fragments += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 9]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].jabbers_not_truncated += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 10]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].jabbers_truncated += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 11]; + + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_64_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 12]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_65_to_127_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 13]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_128_to_255_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 14]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_256_to_511_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 15]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_512_to_1023_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 16]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_1024_to_1518_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 17]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_1519_to_2047_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 18]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_2048_to_4095_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 19]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_4096_to_8191_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 20]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_8192_to_max_octets += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 21]; + + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].mac_drop_events += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 22]; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts_lr += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 23]; + + /* Tx totals */ + uint64_t new_drop_events_sum = + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 22]; + + uint64_t new_packets_sum = + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 7] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 8] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 9] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 10] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 11] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 12] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 13] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 14] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 15] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 16] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 17] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 18] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 19] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 20] + + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 21]; + + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].drop_events += new_drop_events_sum; + p_nt4ga_stat->cap.mp_stat_structs_port_tx[p].pkts += new_packets_sum; + + p_nt4ga_stat->a_port_tx_octets_total[p] += + p_stat_dma_virtual[p * p_nthw_stat->m_nb_tx_port_counters + 0]; + p_nt4ga_stat->a_port_tx_packets_total[p] += new_packets_sum; + p_nt4ga_stat->a_port_tx_drops_total[p] += new_drop_events_sum; + } + + /* Update and get port load counters */ + for (p = 0; p < n_rx_ports; p++) { + uint32_t val; + nthw_stat_get_load_bps_rx(p_nthw_stat, p, &val); + p_nt4ga_stat->mp_port_load[p].rx_bps = + (uint64_t)(((__uint128_t)val * 32ULL * 64ULL * 8ULL) / + PORT_LOAD_WINDOWS_SIZE); + nthw_stat_get_load_pps_rx(p_nthw_stat, p, &val); + p_nt4ga_stat->mp_port_load[p].rx_pps = + (uint64_t)(((__uint128_t)val * 32ULL) / PORT_LOAD_WINDOWS_SIZE); + } + + for (p = 0; p < n_tx_ports; p++) { + uint32_t val; + nthw_stat_get_load_bps_tx(p_nthw_stat, p, &val); + p_nt4ga_stat->mp_port_load[p].tx_bps = + (uint64_t)(((__uint128_t)val * 32ULL * 64ULL * 8ULL) / + PORT_LOAD_WINDOWS_SIZE); + nthw_stat_get_load_pps_tx(p_nthw_stat, p, &val); + p_nt4ga_stat->mp_port_load[p].tx_pps = + (uint64_t)(((__uint128_t)val * 32ULL) / PORT_LOAD_WINDOWS_SIZE); + } + + return 0; +} + static struct nt4ga_stat_ops ops = { .nt4ga_stat_init = nt4ga_stat_init, .nt4ga_stat_setup = nt4ga_stat_setup, + .nt4ga_stat_collect = nt4ga_stat_collect }; void nt4ga_stat_ops_init(void) diff --git a/drivers/net/ntnic/include/ntdrv_4ga.h b/drivers/net/ntnic/include/ntdrv_4ga.h index 1135e9a539..38e4d0ca35 100644 --- a/drivers/net/ntnic/include/ntdrv_4ga.h +++ b/drivers/net/ntnic/include/ntdrv_4ga.h @@ -16,6 +16,7 @@ typedef struct ntdrv_4ga_s { volatile bool b_shutdown; rte_thread_t flm_thread; pthread_mutex_t stat_lck; + rte_thread_t stat_thread; } ntdrv_4ga_t; #endif /* __NTDRV_4GA_H__ */ diff --git a/drivers/net/ntnic/include/ntnic_stat.h b/drivers/net/ntnic/include/ntnic_stat.h index ed24a892ec..0735dbc085 100644 --- a/drivers/net/ntnic/include/ntnic_stat.h +++ b/drivers/net/ntnic/include/ntnic_stat.h @@ -85,16 +85,87 @@ struct color_counters { }; struct host_buffer_counters { + uint64_t flush_packets; + uint64_t drop_packets; + uint64_t fwd_packets; + uint64_t dbs_drop_packets; + uint64_t flush_bytes; + uint64_t drop_bytes; + uint64_t fwd_bytes; + uint64_t dbs_drop_bytes; }; struct port_load_counters { + uint64_t rx_pps; uint64_t rx_pps_max; + uint64_t tx_pps; uint64_t tx_pps_max; + uint64_t rx_bps; uint64_t rx_bps_max; + uint64_t tx_bps; uint64_t tx_bps_max; }; struct port_counters_v2 { + /* Rx/Tx common port counters */ + uint64_t drop_events; + uint64_t pkts; + /* FPGA counters */ + uint64_t octets; + uint64_t broadcast_pkts; + uint64_t multicast_pkts; + uint64_t unicast_pkts; + uint64_t pkts_alignment; + uint64_t pkts_code_violation; + uint64_t pkts_crc; + uint64_t undersize_pkts; + uint64_t oversize_pkts; + uint64_t fragments; + uint64_t jabbers_not_truncated; + uint64_t jabbers_truncated; + uint64_t pkts_64_octets; + uint64_t pkts_65_to_127_octets; + uint64_t pkts_128_to_255_octets; + uint64_t pkts_256_to_511_octets; + uint64_t pkts_512_to_1023_octets; + uint64_t pkts_1024_to_1518_octets; + uint64_t pkts_1519_to_2047_octets; + uint64_t pkts_2048_to_4095_octets; + uint64_t pkts_4096_to_8191_octets; + uint64_t pkts_8192_to_max_octets; + uint64_t mac_drop_events; + uint64_t pkts_lr; + /* Rx only port counters */ + uint64_t duplicate; + uint64_t pkts_ip_chksum_error; + uint64_t pkts_udp_chksum_error; + uint64_t pkts_tcp_chksum_error; + uint64_t pkts_giant_undersize; + uint64_t pkts_baby_giant; + uint64_t pkts_not_isl_vlan_mpls; + uint64_t pkts_isl; + uint64_t pkts_vlan; + uint64_t pkts_isl_vlan; + uint64_t pkts_mpls; + uint64_t pkts_isl_mpls; + uint64_t pkts_vlan_mpls; + uint64_t pkts_isl_vlan_mpls; + uint64_t pkts_no_filter; + uint64_t pkts_dedup_drop; + uint64_t pkts_filter_drop; + uint64_t pkts_overflow; + uint64_t pkts_dbs_drop; + uint64_t octets_no_filter; + uint64_t octets_dedup_drop; + uint64_t octets_filter_drop; + uint64_t octets_overflow; + uint64_t octets_dbs_drop; + uint64_t ipft_first_hit; + uint64_t ipft_first_not_hit; + uint64_t ipft_mid_hit; + uint64_t ipft_mid_not_hit; + uint64_t ipft_last_hit; + uint64_t ipft_last_not_hit; }; struct flm_counters_v1 { @@ -147,6 +218,8 @@ struct nt4ga_stat_s { uint64_t a_port_tx_packets_base[NUM_ADAPTER_PORTS_MAX]; uint64_t a_port_tx_packets_total[NUM_ADAPTER_PORTS_MAX]; + + uint64_t a_port_tx_drops_total[NUM_ADAPTER_PORTS_MAX]; }; typedef struct nt4ga_stat_s nt4ga_stat_t; @@ -159,4 +232,9 @@ int nthw_stat_set_dma_address(nthw_stat_t *p, uint64_t stat_dma_physical, uint32_t *p_stat_dma_virtual); int nthw_stat_trigger(nthw_stat_t *p); +int nthw_stat_get_load_bps_rx(nthw_stat_t *p, uint8_t port, uint32_t *val); +int nthw_stat_get_load_bps_tx(nthw_stat_t *p, uint8_t port, uint32_t *val); +int nthw_stat_get_load_pps_rx(nthw_stat_t *p, uint8_t port, uint32_t *val); +int nthw_stat_get_load_pps_tx(nthw_stat_t *p, uint8_t port, uint32_t *val); + #endif /* NTNIC_STAT_H_ */ diff --git a/drivers/net/ntnic/nthw/core/include/nthw_rmc.h b/drivers/net/ntnic/nthw/core/include/nthw_rmc.h index b239752674..9c40804cd9 100644 --- a/drivers/net/ntnic/nthw/core/include/nthw_rmc.h +++ b/drivers/net/ntnic/nthw/core/include/nthw_rmc.h @@ -47,4 +47,9 @@ int nthw_rmc_init(nthw_rmc_t *p, nthw_fpga_t *p_fpga, int n_instance); void nthw_rmc_block(nthw_rmc_t *p); void nthw_rmc_unblock(nthw_rmc_t *p, bool b_is_secondary); +uint32_t nthw_rmc_get_status_sf_ram_of(nthw_rmc_t *p); +uint32_t nthw_rmc_get_status_descr_fifo_of(nthw_rmc_t *p); +uint32_t nthw_rmc_get_dbg_merge(nthw_rmc_t *p); +uint32_t nthw_rmc_get_mac_if_err(nthw_rmc_t *p); + #endif /* NTHW_RMC_H_ */ diff --git a/drivers/net/ntnic/nthw/core/nthw_rmc.c b/drivers/net/ntnic/nthw/core/nthw_rmc.c index 748519aeb4..570a179fc8 100644 --- a/drivers/net/ntnic/nthw/core/nthw_rmc.c +++ b/drivers/net/ntnic/nthw/core/nthw_rmc.c @@ -77,6 +77,26 @@ int nthw_rmc_init(nthw_rmc_t *p, nthw_fpga_t *p_fpga, int n_instance) return 0; } +uint32_t nthw_rmc_get_status_sf_ram_of(nthw_rmc_t *p) +{ + return (p->mp_reg_status) ? nthw_field_get_updated(p->mp_fld_sf_ram_of) : 0xffffffff; +} + +uint32_t nthw_rmc_get_status_descr_fifo_of(nthw_rmc_t *p) +{ + return (p->mp_reg_status) ? nthw_field_get_updated(p->mp_fld_descr_fifo_of) : 0xffffffff; +} + +uint32_t nthw_rmc_get_dbg_merge(nthw_rmc_t *p) +{ + return (p->mp_reg_dbg) ? nthw_field_get_updated(p->mp_fld_dbg_merge) : 0xffffffff; +} + +uint32_t nthw_rmc_get_mac_if_err(nthw_rmc_t *p) +{ + return (p->mp_reg_mac_if) ? nthw_field_get_updated(p->mp_fld_mac_if_err) : 0xffffffff; +} + void nthw_rmc_block(nthw_rmc_t *p) { /* BLOCK_STATT(0)=1 BLOCK_KEEPA(1)=1 BLOCK_MAC_PORT(8:11)=~0 */ diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index d61044402d..aac3144cc0 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -7,6 +7,7 @@ #include "flow_api_engine.h" #include "flow_api_nic_setup.h" +#include "ntlog.h" #include "ntnic_mod_reg.h" #include "flow_api.h" diff --git a/drivers/net/ntnic/nthw/stat/nthw_stat.c b/drivers/net/ntnic/nthw/stat/nthw_stat.c index 6adcd2e090..078eec5e1f 100644 --- a/drivers/net/ntnic/nthw/stat/nthw_stat.c +++ b/drivers/net/ntnic/nthw/stat/nthw_stat.c @@ -368,3 +368,131 @@ int nthw_stat_trigger(nthw_stat_t *p) return 0; } + +int nthw_stat_get_load_bps_rx(nthw_stat_t *p, uint8_t port, uint32_t *val) +{ + switch (port) { + case 0: + if (p->mp_fld_load_bps_rx0) { + *val = nthw_field_get_updated(p->mp_fld_load_bps_rx0); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + case 1: + if (p->mp_fld_load_bps_rx1) { + *val = nthw_field_get_updated(p->mp_fld_load_bps_rx1); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + default: + return -1; + } +} + +int nthw_stat_get_load_bps_tx(nthw_stat_t *p, uint8_t port, uint32_t *val) +{ + switch (port) { + case 0: + if (p->mp_fld_load_bps_tx0) { + *val = nthw_field_get_updated(p->mp_fld_load_bps_tx0); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + case 1: + if (p->mp_fld_load_bps_tx1) { + *val = nthw_field_get_updated(p->mp_fld_load_bps_tx1); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + default: + return -1; + } +} + +int nthw_stat_get_load_pps_rx(nthw_stat_t *p, uint8_t port, uint32_t *val) +{ + switch (port) { + case 0: + if (p->mp_fld_load_pps_rx0) { + *val = nthw_field_get_updated(p->mp_fld_load_pps_rx0); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + case 1: + if (p->mp_fld_load_pps_rx1) { + *val = nthw_field_get_updated(p->mp_fld_load_pps_rx1); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + default: + return -1; + } +} + +int nthw_stat_get_load_pps_tx(nthw_stat_t *p, uint8_t port, uint32_t *val) +{ + switch (port) { + case 0: + if (p->mp_fld_load_pps_tx0) { + *val = nthw_field_get_updated(p->mp_fld_load_pps_tx0); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + case 1: + if (p->mp_fld_load_pps_tx1) { + *val = nthw_field_get_updated(p->mp_fld_load_pps_tx1); + return 0; + + } else { + *val = 0; + return -1; + } + + break; + + default: + return -1; + } +} diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 3d02e79691..8a9ca2c03d 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -4,6 +4,9 @@ */ #include +#include + +#include #include #include @@ -25,6 +28,7 @@ #include "nt_util.h" const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL }; +#define THREAD_CREATE(a, b, c) rte_thread_create(a, &thread_attr, b, c) #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 @@ -67,6 +71,9 @@ const rte_thread_attr_t thread_attr = { .priority = RTE_THREAD_PRIORITY_NORMAL } uint64_t rte_tsc_freq; +static void (*previous_handler)(int sig); +static rte_thread_t shutdown_tid; + int kill_pmd; #define ETH_DEV_NTNIC_HELP_ARG "help" @@ -1407,6 +1414,7 @@ drv_deinit(struct drv_s *p_drv) /* stop statistics threads */ p_drv->ntdrv.b_shutdown = true; + THREAD_JOIN(p_nt_drv->stat_thread); if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE) { THREAD_JOIN(p_nt_drv->flm_thread); @@ -1626,6 +1634,87 @@ THREAD_FUNC adapter_flm_update_thread_fn(void *context) return THREAD_RETURN; } +/* + * Adapter stat thread + */ +THREAD_FUNC adapter_stat_thread_fn(void *context) +{ + const struct nt4ga_stat_ops *nt4ga_stat_ops = get_nt4ga_stat_ops(); + + if (nt4ga_stat_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "Statistics module uninitialized"); + return THREAD_RETURN; + } + + struct drv_s *p_drv = context; + + ntdrv_4ga_t *p_nt_drv = &p_drv->ntdrv; + nt4ga_stat_t *p_nt4ga_stat = &p_nt_drv->adapter_info.nt4ga_stat; + nthw_stat_t *p_nthw_stat = p_nt4ga_stat->mp_nthw_stat; + const char *const p_adapter_id_str = p_nt_drv->adapter_info.mp_adapter_id_str; + (void)p_adapter_id_str; + + if (!p_nthw_stat) + return THREAD_RETURN; + + NT_LOG_DBGX(DBG, NTNIC, "%s: begin", p_adapter_id_str); + + assert(p_nthw_stat); + + while (!p_drv->ntdrv.b_shutdown) { + nt_os_wait_usec(10 * 1000); + + nthw_stat_trigger(p_nthw_stat); + + uint32_t loop = 0; + + while ((!p_drv->ntdrv.b_shutdown) && + (*p_nthw_stat->mp_timestamp == (uint64_t)-1)) { + nt_os_wait_usec(1 * 100); + + if (rte_log_get_level(nt_log_ntnic) == RTE_LOG_DEBUG && + (++loop & 0x3fff) == 0) { + if (p_nt4ga_stat->mp_nthw_rpf) { + NT_LOG(ERR, NTNIC, "Statistics DMA frozen"); + + } else if (p_nt4ga_stat->mp_nthw_rmc) { + uint32_t sf_ram_of = + nthw_rmc_get_status_sf_ram_of(p_nt4ga_stat + ->mp_nthw_rmc); + uint32_t descr_fifo_of = + nthw_rmc_get_status_descr_fifo_of(p_nt4ga_stat + ->mp_nthw_rmc); + + uint32_t dbg_merge = + nthw_rmc_get_dbg_merge(p_nt4ga_stat->mp_nthw_rmc); + uint32_t mac_if_err = + nthw_rmc_get_mac_if_err(p_nt4ga_stat->mp_nthw_rmc); + + NT_LOG(ERR, NTNIC, "Statistics DMA frozen"); + NT_LOG(ERR, NTNIC, "SF RAM Overflow : %08x", + sf_ram_of); + NT_LOG(ERR, NTNIC, "Descr Fifo Overflow : %08x", + descr_fifo_of); + NT_LOG(ERR, NTNIC, "DBG Merge : %08x", + dbg_merge); + NT_LOG(ERR, NTNIC, "MAC If Errors : %08x", + mac_if_err); + } + } + } + + /* Check then collect */ + { + pthread_mutex_lock(&p_nt_drv->stat_lck); + nt4ga_stat_ops->nt4ga_stat_collect(&p_nt_drv->adapter_info, p_nt4ga_stat); + pthread_mutex_unlock(&p_nt_drv->stat_lck); + } + } + + NT_LOG_DBGX(DBG, NTNIC, "%s: end", p_adapter_id_str); + return THREAD_RETURN; +} + static int nthw_pci_dev_init(struct rte_pci_device *pci_dev) { @@ -1883,6 +1972,16 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) } } + pthread_mutex_init(&p_nt_drv->stat_lck, NULL); + res = THREAD_CTRL_CREATE(&p_nt_drv->stat_thread, "nt4ga_stat_thr", adapter_stat_thread_fn, + (void *)p_drv); + + if (res) { + NT_LOG(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++) { @@ -2073,6 +2172,48 @@ nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused) return 0; } +static void signal_handler_func_int(int sig) +{ + if (sig != SIGINT) { + signal(sig, previous_handler); + raise(sig); + return; + } + + kill_pmd = 1; +} + +THREAD_FUNC shutdown_thread(void *arg __rte_unused) +{ + while (!kill_pmd) + nt_os_wait_usec(100 * 1000); + + NT_LOG_DBGX(DBG, NTNIC, "Shutting down because of ctrl+C"); + + signal(SIGINT, previous_handler); + raise(SIGINT); + + return THREAD_RETURN; +} + +static int init_shutdown(void) +{ + NT_LOG(DBG, NTNIC, "Starting shutdown handler"); + kill_pmd = 0; + previous_handler = signal(SIGINT, signal_handler_func_int); + THREAD_CREATE(&shutdown_tid, shutdown_thread, NULL); + + /* + * 1 time calculation of 1 sec stat update rtc cycles to prevent stat poll + * flooding by OVS from multiple virtual port threads - no need to be precise + */ + uint64_t now_rtc = rte_get_tsc_cycles(); + nt_os_wait_usec(10 * 1000); + rte_tsc_freq = 100 * (rte_get_tsc_cycles() - now_rtc); + + return 0; +} + static int nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) @@ -2115,6 +2256,8 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, ret = nthw_pci_dev_init(pci_dev); + init_shutdown(); + NT_LOG_DBGX(DBG, NTNIC, "leave: ret=%d", ret); return ret; } diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 30b9afb7d3..8b825d8c48 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -186,6 +186,8 @@ void port_init(void); struct nt4ga_stat_ops { int (*nt4ga_stat_init)(struct adapter_info_s *p_adapter_info); int (*nt4ga_stat_setup)(struct adapter_info_s *p_adapter_info); + int (*nt4ga_stat_collect)(struct adapter_info_s *p_adapter_info, + nt4ga_stat_t *p_nt4ga_stat); }; void register_nt4ga_stat_ops(const struct nt4ga_stat_ops *ops); -- 2.45.0