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

Brief description of P4 architecture that this compiler implements? #54

Open
jafingerhut opened this issue Nov 5, 2024 · 1 comment

Comments

@jafingerhut
Copy link

jafingerhut commented Nov 5, 2024

Thanks for releasing this! I finally got around to trying it out briefly today, and had some questions about the architecture that is implemented.

I see #include of a core.p4 file in a few files, and softnpu.p4 in some others.

Are the struct fields named port specially recognized by the implementation when they are in structs named ingress_meta or egress_meta somehow? Or that are the 2nd parameter or 3rd parameter of the ingress or egress controls of the SoftNPU package?

I see an action defined as action drop() { } in some code examples, but it is empty. Is the action name drop somehow specially recognized by the compiler? What effects does invoking that action have, if so?

Are there any other architectures besides SoftNpu that x4c supports?

@rcgoodfellow
Copy link
Collaborator

Hey Andy. Thanks for checking out x4c.

I see #include of a core.p4 file in a few files, and softnpu.p4 in some others.

The loose idea here was that core.p4 has stuff that does not vary across architectures, and softnpu.p4 is specifically what is needed by the softnpu architecture. However, we're only now getting around to implementing an architecture beyond softnpu, so the distinction is more in anticipation of things to come rather than any constraints that exist today.

Are the struct fields named port specially recognized by the implementation when they are in structs named ingress_meta or egress_meta somehow? Or that are the 2nd parameter or 3rd parameter of the ingress or egress controls of the SoftNPU package?

The egress_metaedata_t and ingress_metadata_t types, along with the port member within those types, are expected by the softnpu architecture (but not necessarily other architectures or back ends). For example, see this part of the softnpu Rust code generation that depends on ingress_metadata_t and is initializing the output port to be filled in later by other generated code.

let mut ingress_metadata = ingress_metadata_t{
port: {
let mut x = bitvec![mut u8, Msb0; 0; 16];
x.store_le(port);
x
},
..Default::default()
};

I see an action defined as action drop() { } in some code examples, but it is empty. Is the action name drop somehow specially recognized by the compiler? What effects does invoking that action have, if so?

This is just an artifact of these examples. drop is not specially recognized by the compiler.

Are there any other architectures besides SoftNpu that x4c supports?

We'll be adding an Xsight X2 backend soon!

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

No branches or pull requests

2 participants