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

P4_16 (or PSA) - Consider creating padding primitive #683

Open
jafingerhut opened this issue Oct 2, 2018 · 3 comments
Open

P4_16 (or PSA) - Consider creating padding primitive #683

jafingerhut opened this issue Oct 2, 2018 · 3 comments

Comments

@jafingerhut
Copy link
Collaborator

Many P4 targets impose the limitation that headers must be a multiple of 8 bits long.

PSA defines several data plane types such as PortId_t that are bit<W>, where the value of W is fixed for a single target, but can vary from one target to another. It need not be a multiple of 8 bits long.

Today there is no way to write P4 source code that includes such a field in a header definition and is portable across multiple targets with different bit widths for these fields, while satisfying the multiple-of-8-bits restriction that I suspect a large fraction of targets require.

PSA's current approach is to define additional types with similar, but different, names, where each is guaranteed to have a size that is a multiple of 8 bits by itself.

It may be useful to consider some kind of explicit padding constructs in the definition of P4 header types, where the size of the padding might vary from target to target, but no one need modify the P4 source code to adjust the size of the padding manually for each target.

@mihaibudiu
Copy link
Contributor

Or we could have an annotation @padded(8)

@cc10512
Copy link
Contributor

cc10512 commented Dec 1, 2018

If the padding is target specific it would be better to have a compiler option that specifies the padding and the size for the target. Or the size can simply be part of the backend for the target, in which case the option just signals to pad all headers (I can't imagine that we'll have a case in which some headers need to be aligned (padded) and some won't).

@jnfoster
Copy link
Collaborator

Marking this as PSA. I would propose that you prototype it there, and then bring it back to the LDWG group if it is working well.

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

No branches or pull requests

4 participants