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

Is register support saving 128 bits value ? #2055

Closed
kphf1995cm opened this issue Oct 14, 2019 · 5 comments
Closed

Is register support saving 128 bits value ? #2055

kphf1995cm opened this issue Oct 14, 2019 · 5 comments

Comments

@kphf1995cm
Copy link

typedef bit<128> IPv6Address;
register(100) port_ipv6;
I can not save 128 bits IPv6 address in register?

@ChrisDodd
Copy link
Contributor

register needs a type argument. So at the least you would need

register<bit<128>>(100) port_ipv6;

however, I don't know if bmv2-ss supports such wide registers.

@kphf1995cm
Copy link
Author

register(100) port_ipv6;
This is what I write.
I can pass p4c compile, but when I push json program to bmv2, I can not save 128 bits IPv6 address in register

@jafingerhut
Copy link
Contributor

You say "this is what I write": register(100) port_ipv6.

Chris is saying that is incorrect P4_16 for the register you want. You should write something like this instead:
register<bit<128>>(100) port_ipv6

If you do not change your P4 program to look like that, you will never achieve your goal.

I have tested 128-bit wide registers in p4c and simple_switch using a line like the above, and it seems to be working as desired.

@jafingerhut
Copy link
Contributor

I do not know what the maximum width of register supported by p4c plus simple_switch is, but I have also tested up to 1024-bit wide register array elements, and it all seems to be working.

@antoninbas
Copy link
Member

There is no hard limit on bmv2 register values. The code uses arbitrary-precision numbers.

The Thrift RPC service for bmv2 however is limited to 64-bit registers: https://github.com/p4lang/behavioral-model/blob/master/thrift_src/standard.thrift#L159. Which means that the runtime_CLI is also limited to 64-bit registers.

The P4Runtime API does not have this limitation, but there is no implementation yet for bmv2: p4lang/PI#376

antoninbas pushed a commit to p4lang/behavioral-model that referenced this issue Oct 26, 2019
* Add runtime_CLI docs on table_add and a few other commands

* Additional implementation notes on registers in simple_switch
Some of this material comes from this comment by Antonin Bas:
p4lang/p4c#2055 (comment)

* Add missing backquote markup
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

4 participants