Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions codegen/rust/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ impl<'a> ControlGenerator<'a> {
.collect();

let dump = quote! {
// TODO find a way to only allocate the string when probe is active.
// Cannot simply return reference to string created within probe.
let dump = format!(#dump_fmt, #(#dump_args,)*);
softnpu_provider::action!(|| (&dump));
softnpu_provider::action!(|| format!(#dump_fmt, #(#dump_args,)*));
};

for arg in &action.parameters {
Expand Down
20 changes: 8 additions & 12 deletions codegen/rust/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ impl<'a> PipelineGenerator<'a> {
softnpu_provider::parser_dropped!(||());
return Vec::new();
}
let dump = format!("\n{}", parsed.dump());
softnpu_provider::parser_accepted!(||(&dump));
softnpu_provider::parser_accepted!(|| format!("\n{}", parsed.dump()));

//
// Calculate parsed header size
Expand All @@ -412,19 +411,18 @@ impl<'a> PipelineGenerator<'a> {

#egress_ports

let dump = format!(
let dump = || format!(
"{}\negress:\n{}",
parsed.dump(),
#egress_meta_var.dump(),
);

if ports.is_empty() {
softnpu_provider::ingress_dropped!(||(&dump));
softnpu_provider::ingress_dropped!(|| dump());
return Vec::new();
}

let dump = format!("\n{dump}");
softnpu_provider::ingress_accepted!(||(&dump));
softnpu_provider::ingress_accepted!(|| format!("\n{}", dump()));

//
// Run output of ingress block through egress block on each
Expand Down Expand Up @@ -473,8 +471,7 @@ impl<'a> PipelineGenerator<'a> {
softnpu_provider::parser_dropped!(||());
return Vec::new();
}
let dump = format!("\n{}", parsed.dump());
softnpu_provider::parser_accepted!(||(&dump));
softnpu_provider::parser_accepted!(|| format!("\n{}", parsed.dump()));

//
// Calculate parsed header size
Expand All @@ -499,19 +496,18 @@ impl<'a> PipelineGenerator<'a> {

#egress_ports

let dump = format!(
let dump = || format!(
"{}\negress:\n{}",
parsed.dump(),
#egress_meta_var.dump(),
);

if ports.is_empty() {
softnpu_provider::ingress_dropped!(||(&dump));
softnpu_provider::ingress_dropped!(|| dump());
return Vec::new();
}

let dump = format!("\n{dump}");
softnpu_provider::ingress_accepted!(||(&dump));
softnpu_provider::ingress_accepted!(|| format!("\n{}", dump()));

//
// Run output of ingress block through egress block on each
Expand Down
22 changes: 10 additions & 12 deletions lang/p4rs/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,20 @@ pub fn key_matches(selector: &BigUint, key: &Key) -> bool {
Key::Exact(x) => {
let hit = selector == &x.value;
if !hit {
let dump = format!("{:x} != {:x}", selector, x.value);
crate::p4rs_provider::match_miss!(|| &dump);
crate::p4rs_provider::match_miss!(|| format!(
"{:x} != {:x}",
selector, x.value
));
}
hit
}
Key::Range(begin, end) => {
let hit = selector >= &begin.value && selector <= &end.value;
if !hit {
let dump = format!(
crate::p4rs_provider::match_miss!(|| format!(
"begin={} end={} sel={}",
begin.value, end.value, selector
);
crate::p4rs_provider::match_miss!(|| &dump);
));
}
hit
}
Expand All @@ -256,17 +257,15 @@ pub fn key_matches(selector: &BigUint, key: &Key) -> bool {
let selector_v6 = selector.to_u128().unwrap();
let hit = selector_v6 & mask == key & mask;
if !hit {
let dump = format!(
crate::p4rs_provider::match_miss!(|| format!(
"{:x} & {:x} == {:x} & {:x} | {:x} == {:x}",
selector_v6,
mask,
key,
mask,
selector_v6 & mask,
key & mask
);
//println!("{}", dump);
crate::p4rs_provider::match_miss!(|| &dump);
));
}
hit
}
Expand All @@ -283,16 +282,15 @@ pub fn key_matches(selector: &BigUint, key: &Key) -> bool {
let selector_v4: u32 = selector.to_u32().unwrap();
let hit = selector_v4 & mask == key & mask;
if !hit {
let dump = format!(
crate::p4rs_provider::match_miss!(|| format!(
"{:x} & {:x} == {:x} & {:x} | {:x} = {:x}",
selector_v4,
mask,
key,
mask,
selector_v4 & mask,
key & mask
);
crate::p4rs_provider::match_miss!(|| &dump);
));
}
hit
}
Expand Down
Loading