diff --git a/Cargo.toml b/Cargo.toml index 278c0aa..7011754 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,8 @@ homepage = "https://www.ingonyama.com" repository = "https://github.com/ingonyama-zk/blaze" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +qdma = [] [dependencies] libc = "0.2.126" @@ -38,3 +40,4 @@ serde-hex = "0.1.0" thiserror = "1.0" num-bigint = "0.4" num-traits = "0.2.15" +memmap2 = "0.7.1" diff --git a/parse_log_to_csv.py b/parse_log_to_csv.py new file mode 100644 index 0000000..b4bdfa4 --- /dev/null +++ b/parse_log_to_csv.py @@ -0,0 +1,45 @@ +import csv +import re + +log_file = "test.log" +output_file = "output.csv" + +# Regular expression patterns to match timestamps and values +timestamp_pattern = r"\[(.*?)\]" +value_pattern = r"value:\s+(.*?)$" + +data = [] + +# Read the log file +with open(log_file, "r") as file: + lines = file.readlines() + + # Iterate over each line in the log file + for i in range(len(lines)): + line = lines[i] + if "===" in line and "api values" in line: + values = [] + for j in range(i+1, len(lines)): + inner_line = lines[j] + if "value:" in inner_line: + value_match = re.search(value_pattern, inner_line) + if value_match: + value = value_match.group(1) + values.append(value) + elif "===" in inner_line and "api values" in inner_line: + break + if len(values) == 3: + timestamp_match = re.search(timestamp_pattern, line) + if timestamp_match: + timestamp = timestamp_match.group(1) + data.append([timestamp] + values) + +# Write the data to a CSV file +with open(output_file, "w", newline="") as csv_file: + writer = csv.writer(csv_file) + writer.writerow(["Timestamp", "ADDR_HIF2CPU_C_NOF_ELEMENTS_PENDING_ON_DMA_FIFO", "ADDR_HIF2CPU_C_NOF_RESULTS_PENDING_ON_DMA_FIFO", "ADDR_HIF2CPU_C_MAX_RECORDED_PENDING_RESULTS"]) # Write header row + + # Write data rows + writer.writerows(data) + +print("CSV file created successfully.") \ No newline at end of file diff --git a/src/driver_client/dclient.rs b/src/driver_client/dclient.rs index df8229c..5ca1b69 100755 --- a/src/driver_client/dclient.rs +++ b/src/driver_client/dclient.rs @@ -11,6 +11,7 @@ use crate::{ error::*, utils::{deserialize_hex, open_channel, AccessFlags}, }; +use memmap2::{MmapMut}; use serde::Deserialize; use std::{fmt::Debug, os::unix::fs::FileExt, thread::sleep, time::Duration}; @@ -96,7 +97,10 @@ pub struct DriverClient { /// Read only channel from core using DMA bus. pub dma_c2h_read: std::fs::File, /// Read and write file descriptor for working with a register space that uses AXI-lite protocol. + #[cfg(not(feature = "qdma"))] pub ctrl: std::fs::File, + #[cfg(feature = "qdma")] + pub ctrl: MmapMut, } impl DriverClient { @@ -117,6 +121,7 @@ impl DriverClient { /// /// let dclient = DriverClient::new("0", DriverConfig::driver_client_c1100_cfg()); /// ``` + #[cfg(not(feature = "qdma"))] pub fn new(id: &str, cfg: DriverConfig) -> Self { DriverClient { cfg, @@ -126,6 +131,24 @@ impl DriverClient { } } + #[cfg(feature = "qdma")] + pub fn new(bus: &str, device: &str, function: &str, cfg: DriverConfig) -> Self { + use memmap2::MmapOptions; + + let device_id = &format!("{}{}{}", bus, device, function); + let mode = "-MM-0"; + + let ctrl_fd = open_channel(&format!("'/sys/bus/pci/devices/0000:{}:{}.{}/resource2", bus, device, function), AccessFlags::RdwrMode); + let ctrl = unsafe { MmapOptions::new().len(128 * 1024 * 1024).map_mut(&ctrl_fd) }; + + DriverClient { + cfg, + dma_h2c_write: open_channel(&format!("/dev/qdma{}{}", device_id, mode), AccessFlags::WrMode), + dma_c2h_read: open_channel(&format!("/dev/qdma{}{}", device_id, mode), AccessFlags::RdMode), + ctrl: ctrl.unwrap(), + } + } + // ==== DFX ==== /// Method for checking decouple status. pub fn get_dfx_decoupling(&self) -> Result { @@ -136,6 +159,7 @@ impl DriverClient { } /// Setup decouple signal to isolate the user logic during reconfiguration, protecting the shell from spurious signals. + #[cfg(not(feature = "qdma"))] pub fn set_dfx_decoupling(&self, signal: u8) -> Result<()> { self.ctrl .write_all_at( @@ -323,6 +347,7 @@ impl DriverClient { /// FIREWALL_ADDR::STATUS, /// ); /// ``` + #[cfg(not(feature = "qdma"))] pub fn ctrl_read_u32 + Copy>( &self, base_address: u64, @@ -349,6 +374,7 @@ impl DriverClient { /// * `offset`: an enum which represent the specific offset for given `base_address`. /// /// returns: u64 + #[cfg(not(feature = "qdma"))] pub fn ctrl_read_u64 + Copy>( &self, base_address: u64, @@ -398,6 +424,7 @@ impl DriverClient { /// 32, /// ); /// ``` + #[cfg(not(feature = "qdma"))] pub fn ctrl_write_u32 + Copy>( &self, base_address: u64, @@ -428,6 +455,7 @@ impl DriverClient { /// * `offset`: an enum which represent the specific offset for given `base_address`. /// * `data`: a byte slice containing the data to be written. /// + #[cfg(not(feature = "qdma"))] pub fn ctrl_write + Copy>( &self, base_address: u64,