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

need calrification #4

Closed
bijutalukdar opened this issue Jan 14, 2016 · 2 comments
Closed

need calrification #4

bijutalukdar opened this issue Jan 14, 2016 · 2 comments

Comments

@bijutalukdar
Copy link

Hi Antonin,
file register.p4
line 68, 69
modify_field_rng_uniform(meta.register_tmp, 100, 200);
register_write(my_register, register_idx, meta.register_tmp);

Could you please refer to some doc where I find what these functions are doing. Intuitively I can understand , but which parameter is getting written where is somewhat obscure to me.

Also I have seen these command used through cli at runtime to update the switch tables:

table_set_default m_table m_action
table_add m_table m_action aa:bb:cc:dd:ee:ff => 0

what does that do exactly. Again if there is any quick readme on that please share.

@antoninbas
Copy link
Member

Note that the code in the m_action in register.p4 is irrelevant to the demo itself and is just here to showcase what can be done with registers.
That being said:

  • modify_field_rng_uniform(hdrA.f1, a, b): generates a random integer between a and b and assigns it to field hdrA.f1
  • register_write(reg, idx, hdrA.f1): assigns the value of field hdrA.f1 (can also be a constant) to reg[idx].
  • register_read(hdrA.f1, reg, idx): assigns the value of reg[idx] to field hdrA.f1.

When you want to check exactly what a primitive is doing, you can directly refer to this file (https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch/primitives.h) which implements each standard primitive (usually only a few lines of code per primitive).

You can get some basic help for CLI commands by typing help <command> in the CLI itself. I believe these slides (http://p4.org/wp-content/uploads/2015/12/Nov-2015-P4-Bootcamp-Labs-Guide.pdf) from the 1st P4 bootcamp include more information on how to use the CLI. There is not yet a complete user guide on how to use the CLI.

@bijutalukdar
Copy link
Author

great help thanks a ton

Durbek-Gafur pushed a commit to Durbek-Gafur/P4-VCC that referenced this issue Sep 5, 2022
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