p4lang / behavioral-model

The reference P4 software switch
Apache License 2.0
538 stars 327 forks source link

What is the size of PHV? #1219

Open DolarJoe opened 1 year ago

DolarJoe commented 1 year ago

Hello,

I've hit a roadblock where I'm trying to create a custom header that is pretty large, around 1500 bytes. The largest i was able to get to was 512 bytes with IPv4+UDP headers. I was wondering if the trouble could be that bmv2 has too small of a PHV, but i couldn't find the size, or if it is configurable where to set it to a larger number.

jafingerhut commented 1 year ago

I am not sure exactly what you are trying to do, but if you have a P4 program that you are trying to run using simple_switch or simple_switch_grpc programs, and your deparser does emit statements on headers whose total length is over 512 bytes, that will cause an error, unless you change the BMv2 source code and recompile. More details here: https://github.com/p4lang/behavioral-model/issues/1123#issuecomment-1179778458

jafingerhut commented 1 year ago

Two solutions I can imagine:

The second approach is likely to be closer to what you would need to do on a real hardware device. I suspect most actual hardware devices will have a limit 512 or less in how much they allow you to prepend to a packet in a single pass.

DolarJoe commented 11 months ago

Thank you for your help. I have resorted to modifying BMv2 source code to allow me to emit enough in a single pass for my purposes.

I tried to implement your other suggestion first, however the program failed with the same assert error as #1123. The implementation worked fine if I either recirculated twice and added 256 bytes each time, or recirculated 3 times adding 128 bytes, and it would fail with 3 recirculations adding 256 bytes.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment, or this will be closed in 180 days