feat(loopback): --loopback switch mirrors REQ into REP on D2000's own RFM card memory; enables full-chain testing with x86 echo absent (2019Hz, hop 137us, fresh=100%, wkc0=0 verified with echo stopped)
This commit is contained in:
parent
3d0a3ce087
commit
9ee332d843
31
src/main.rs
31
src/main.rs
|
|
@ -156,6 +156,9 @@ struct Config {
|
|||
/// SM buffers stay 1400B; only the frame payload shrinks.
|
||||
rx_bytes: usize,
|
||||
tx_bytes: usize,
|
||||
/// Self-loop: mirror REQ into REP on D2000's own RFM card memory
|
||||
/// (x86 echo absent); full mailbox+mark protocol still exercised.
|
||||
loopback: bool,
|
||||
}
|
||||
|
||||
fn parse_args() -> Result<Config, String> {
|
||||
|
|
@ -189,6 +192,7 @@ fn parse_args() -> Result<Config, String> {
|
|||
dc_wphase_ns: 125_000,
|
||||
rx_bytes: 1400,
|
||||
tx_bytes: 1400,
|
||||
loopback: false,
|
||||
};
|
||||
let mut args = std::env::args().skip(1).peekable();
|
||||
if let Some(a) = args.peek() {
|
||||
|
|
@ -248,6 +252,7 @@ fn parse_args() -> Result<Config, String> {
|
|||
"--dc-wphase-ns" => { cfg.dc_wphase_ns = val("--dc-wphase-ns")?.parse().map_err(|_| "bad --dc-wphase-ns")?; },
|
||||
"--rx-bytes" => { cfg.rx_bytes = val("--rx-bytes")?.parse().map_err(|_| "bad --rx-bytes")?; },
|
||||
"--tx-bytes" => { cfg.tx_bytes = val("--tx-bytes")?.parse().map_err(|_| "bad --tx-bytes")?; },
|
||||
"--loopback" => cfg.loopback = true,
|
||||
"--el2202" => cfg.el2202 = true,
|
||||
"--el2202-dual" => {
|
||||
cfg.el2202 = true;
|
||||
|
|
@ -1671,7 +1676,7 @@ async fn run(cfg: &Config) -> Result<(), Box<dyn std::error::Error>> {
|
|||
// ---- rfm-async: event-driven forwarder, no tick ----
|
||||
if cfg.mode == Mode::RfmAsync {
|
||||
let rfm = rfm_ctx.take().expect("rfm not opened");
|
||||
return rfm_async_loop(&maindevice, station, rfm, cfg.duration_sec, cfg.fprd_gate_us, cfg.dc_discipline, &sd, cfg.dc_align, cfg.sync_offset_ns, cfg.dc_wphase_ns, cfg.rx_bytes, cfg.tx_bytes, cfg.quiet).await;
|
||||
return rfm_async_loop(&maindevice, station, rfm, cfg.duration_sec, cfg.fprd_gate_us, cfg.dc_discipline, &sd, cfg.dc_align, cfg.sync_offset_ns, cfg.dc_wphase_ns, cfg.rx_bytes, cfg.tx_bytes, cfg.quiet, cfg.loopback).await;
|
||||
}
|
||||
|
||||
// ---- rfm-lrw: single-frame read+write loop ----
|
||||
|
|
@ -2652,6 +2657,7 @@ async fn rfm_async_loop(
|
|||
rx_bytes: usize,
|
||||
tx_bytes: usize,
|
||||
quiet: bool,
|
||||
loopback: bool,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
use el6695_rt::rfm::*;
|
||||
println!("rfm-async: event-driven forwarding, no tick (Ctrl-C to stop)");
|
||||
|
|
@ -2997,6 +3003,29 @@ async fn rfm_async_loop(
|
|||
}
|
||||
barrier();
|
||||
mb.magic = MB_MAGIC;
|
||||
if loopback {
|
||||
// x86-less self-loop: mirror the REQ into the REP
|
||||
// mailbox exactly as the echo peer would (chunked
|
||||
// payload + streaming mark), so the full card-memory
|
||||
// mailbox path is exercised without the fiber peer.
|
||||
let rp = Mailbox::at(mem_ptr, MB_REP_OFF);
|
||||
rp.len = n as u32;
|
||||
rp.ts_ns = now_ns();
|
||||
rp.seq = req_seq;
|
||||
barrier();
|
||||
let rmk = mem_ptr.add(REP_MARK_OFF);
|
||||
for k in 0..MB_NCHUNK {
|
||||
let off = k * MB_CHUNK;
|
||||
let l = MB_CHUNK.min(n.saturating_sub(off));
|
||||
if l > 0 {
|
||||
dev_write(rp.payload.as_mut_ptr().add(off), &rx_buf[off..off + l]);
|
||||
}
|
||||
barrier();
|
||||
mark_store(rmk, mark_pack(req_seq, (k + 1) as u32));
|
||||
}
|
||||
barrier();
|
||||
rp.magic = MB_MAGIC;
|
||||
}
|
||||
}
|
||||
n_req += 1;
|
||||
cx2j_st.push(t0.elapsed().as_nanos() as i64);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user