-
Notifications
You must be signed in to change notification settings - Fork 892
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
How to implement getting data from multiple registers with potentially fewer packets #635
Comments
Most network devices have the ability to recirculate packets, giving you another chance to do whatever you want to the packet. This includes the v1model architecture, which will start over at ingress processing again for packets after they are recirculated. I am not sure what you plan to do with these 4*n register read results, but for example, if you want to take the n values from one register and add them up, you can also consider maintaining one register with the individual N data items, and a separate register with their sum, and keep the one containing the sum up to date whenever you modify an item in the register with N items. Then you do not need to read all N to get the sum. That technique only works if it is straightforward to keep the value you want updated easily, e.g. if you want the max of N elements, it is not easy to update it when the largest of the N values decreases, without reading all of the N-1 others to find out if one of them became the new maximum value. |
Ok, thank you, I just want to read these 4 registers n times in as few packets as possible to get the result because these 4 registers are storing my 4 sum values, after listening to your suggestion I feel that recirculate packets is a good option, but do you think that modifying the customized header to satisfy the one time packet processing to read it n times in a specific condition, this is not a better option? |
It is not clear to me what the customized header format has to do with the number of times you read a register in a single pass of processing. |
Thank you for your reply, because I use a custom header to store the data, the number of times the data is read varies and determines the length of the header, this number of times n up to 4 times, so I want to adapt the number of times the register data is read by modifying the entries of the custom header to give me enough entries to store the read results |
If n is the number of times you want to access a register, or in general repeat any block of code that does anything at all, you can do it with P4 code like this:
If that is too repetitive to type, you can write a little program that prints out the P4 source code of interest for you, e.g. like in an example shown here that uses a Python program to print P4 source code: https://github.com/jafingerhut/p4-guide/blob/master/code-generation/README.md |
ok,Thank you very much.I think I can finish my work |
I want to read the data of 4 registers many times when a specific condition is reached in a packet processing, these data are just different indexes, but because my customized header data has only 4 items, I can only read these 4 registers once, and to read n times, I need 4*n items or n packets, how can I achieve this function while minimizing the traffic on the network link? How can I do this while minimizing the traffic on the network link?
ps: I checked the clone feature and found that cloned packets can only be processed in the egress stage, while my table and other features are in the ingress stage, is there any potential problem with this? If I define 4 global registers, I would have to write multiple lines of similar p4runtime rules code, which would make the code redundant.
Hope there is a better solution
The text was updated successfully, but these errors were encountered: