Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pna direction with register read #3224

Merged
merged 6 commits into from
Apr 20, 2022

Conversation

kamleshbhalui
Copy link
Contributor

Extract packet direction for PNA from an input port, By creating a Register extern network_port_mask, which will be initialized by P4SDE.
The direction metadata should be replaced by a register read from network_port_mask register and ANDing it with mask for input port

istd.direction => network_port_mask.read(0) & (32w0x1 << istd.input_port)

@@ -96,6 +92,11 @@ p4c_add_xfail_reason("dpdk"
testdata/p4_16_samples/pna-example-mirror-packet-error3.p4
)

p4c_add_xfail_reason("dpdk"
"declaration not found"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this supposed to fail with p4c-dpdk only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is failing may be due to some bug in compiler frontend. I am just recording this test for fixing it later.

}

const IR::Node* DirectionToRegRead::preorder(IR::DpdkAsmProgram *p) {
uniqueNames(p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many spaces

}
// "network_port_mask" name is used in dpdk for initialzing direction port mask
// make sure no such decls exist with that name
if (mng1.newName(registerInstanceName) != registerInstanceName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's best if you add a new api to the name generator to check whether a name is in use.
This works too, but it is a bit ugly.

backends/dpdk/dpdkMetadata.h Show resolved Hide resolved
usedNames.insert(decl->name);
}

if (usedNames.count(registerInstanceName))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works if usedNames contains everything you need to check for. I was hoping that you'd add a new method MinimalNameGenerator::nameIsUsed(cstring name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants