-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support to read & write Register by PI #376
Comments
😃 Can I make a pull request if I finish this function? |
Go for it! Please note that you must be a member of P4.org for us to accept your contribution. |
Thanks, @cc10512 I found this work is a little hard, Is there anyone going to do this work? BTW, how to become a member of P4.org? Thanks |
Feel free to ask for guidance if you need help. Use the p4-dev mailing list or the Slack channel and people will be happy to help. To become a member, see https://p4.org/join/ |
Hi, I am trying to read and write the registers of a p4 switch (which uses the Behavioral Model) from an external Python controller through P4Runtime. Although this issue is still open, given that two years have passed since then, I was wondering if nowadays there is a way of doing this or I should still rely on thrift to modify registers. What is the best way to write a control plane program that needs access to registers while using the P4Runtime? Should I go hybrid? |
This issue is still open, because no one has implemented the feature. Volunteers are welcome. It isn't necessarily easy to understand the source code without some skill, patience, and time. Another possibility is to inject packets from the controller with headers that your P4 program has been written so that it writes and/or reads the desired registers, and if reading is then sent back to the controller with the read data in it. |
For ONOS controller, I have developed a draft version for Read & Write P4 register (BMv2). For your reference: Welcome to coorperate and contribute, and we can sign our name and e-mails to this feature. |
@MaoJianwei The open source p4c compiler today will include instances of register extern objects in the P4Info files that it generates. See for example this test program: https://github.com/p4lang/p4c/blob/master/testdata/p4_16_samples/flowlet_switching-bmv2.p4 and its expected p4info output file: https://github.com/p4lang/p4c/blob/master/testdata/p4_16_samples_outputs/flowlet_switching-bmv2.p4.p4info.txt That file was last modified in 2020-Apr, and I believe that p4c back end writing registers to p4info files has been working for longer than that. I may not understand all of your descriptions of problems at the links you give, but wanted to ensure that you knew that at least that part has been working well for quite some time now. The main part missing with the latest versions of the open source P4 development tools (but I have no knowledge of what ONOS requires), is the support for P4Runtime API register read/write messages. |
FYI, for anyone interested in developing changes to the code that add this feature, there is an every-2-weeks "PSA implementation status" meeting where developers interested in adding features and fixing issues in the open source P4 development tools meet to share status and ask questions of each other. Announcements of meeting times are sent to the p4-arch email list, which you can join here: https://lists.p4.org/list/p4-arch.lists.p4.org |
Can we now read values from registers through PI? |
This issue is still open, it has not been implemented |
Are there any updates on the state of this? |
If someone had either volunteered in their free time, or been paid to as part of their job, to implement this, I am pretty sure this issue would have been updated and/or closed as completed. To my knowledge no one has chosen to implement this yet. |
@rickycraft If this might be an issue you would be interested in volunteering to implement, please ask if you are looking for technical tips on going about it. If you are interested in a workaround of the lack of this feature, one that uses PacketIn and PacketOut packets that perform the register reads/writes on behalf of the controller, and return read results in packets from the switch back to the controller, see this example P4 program and PTF test: https://github.com/jafingerhut/p4-guide/tree/master/ptf-tests/registeraccess |
@jafingerhut unfortunatly i don't have the knoledge to implement this feature nor the time to learn how to do it. Regarding the workaround, i will probably send a digest to the controller when is necessary, for my usecase is more efficient than a packet in/out. |
@jafingerhut Im interested in giving it a try. Been working with p4 for the past few months for school and have gotten ok at it, Im thinking this will be a nice summer project. Maybe tinker with it here and there until then in between my coursework and give it full attention starting mid May. Whatever tips and info you can provide I appreciate, I dont know what I dont know yet so throw at me what you think is relevant. I found this question because I wanted to populate a register of powers of 10 without having to manually type it out in my p4 code, i.e. load it at runtime from the cli with some generated shell/python commands. And then I found this. |
I am not sure, but I suspect that this talk by Antonin Bas on the open source implementation of the P4Runtime API in simple_switch / behavioral-model could be a good introduction: “P4 Runtime implementation in P4.org projects”: https://www.youtube.com/watch?v=YGdcZ6PYiUo |
Hi, @ShivamPatelShivamPatel , you are welcome to implement this feature, and I have implemented a prototype here: As mentioned here: #376 (comment) |
Hi, After reading this thread, I am still wondering whether the support for write/read operation of p4runtime to the register complete ? Or we need to implement by ourself follow the example provide by @MaoJianwei ? I actually find the read support from the p4runtime_lib. However, I did not see any write support API. Best Regards, |
As far as I know, the code changes described by this issue have not been completed by anyone. |
HI, There may be another way to reset the register via the thrift port. I have been discussing it with my advisor and we decided to make an example Our code will be published once our research project is published. The easiest way is that we use the simple_switch_cli to connect to the P4 Runtime and the simple_switch_cli can run at the same time. However, it Best Regards, |
Hello! |
No change in status -- as far as I know, no one has made the decision to implement this feature yet. |
Thank you for the prompt response. I tested my code with smple_switch and used the Simple_switch_cli and I was able to read the registers. Is there something similar to the simple_switch_CLI tool that works for P4 stratum? |
simple_switch_CLI makes a TCP connection to the simple_switch_grpc process on a port where simple_switch_grpc communicates via a Thrift-based protocol that is custom to simple_switch_grpc, not using the P4Runtime API. If you connect to the simple_switch_grpc process on a TCP port where it is listening as a P4Runtime API server, then even though there are P4Runtime API messages defined to read and write P4 register externs via the P4Runtime API protocol, the simple_switch_grpc process does not implement the correct behavior for responding to those messages. That is why this issue exists, and has not been closed. If you want to make a Thrift connection to simple_switch_grpc, and send the same Thrift-based messages used by simple_switch_CLI to read and write registers, yes, you should be able to read and write registers that way. |
Updated status as of 2024-Nov-20:
So far no one has volunteered (nor been paid) to implement this feature. If you are interested in implementing it, please let us know by replying in a comment on this issue.
Note: To implement this fully generally would require supporting many P4 types of values as the element type of a P4 register array in the P4Runtime API, e.g. not just elements of type
bit<W>
, but also many other P4 types such asint<W>
, enum values (both serializable and non-serializable kinds of enums), header types, struct types, header_union types, etc.However, it would be quite useful if the implementation supported only type
bit<W>
as the element type of a register array -- that would be more than the implementation supports now, which is no types at all.As a suggestion for a sequence that successive more general implementations might support, from smallest subset and easier, to larger subsets and more work:
bit<W>
only - This would be a great starting point on which to build.int<W>
In short, if you think you would be interested in implementing only the first one or two of these possibilities, but not the rest, that would be far more useful than the current state of affairs, where none are supported.
Original issue text created on 2018-Jun-08 by MaoJianwei:
Hi,
I found PI doesn't support to read & write Register.
Are there something blocking this work, and Is any team doing this work?
Thanks
The text was updated successfully, but these errors were encountered: