behavioral-model icon indicating copy to clipboard operation
behavioral-model copied to clipboard

What is the size of PHV?

Open DolarJoe opened this issue 1 year ago • 4 comments

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.

DolarJoe avatar Oct 03 '23 12:10 DolarJoe

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 avatar Oct 03 '23 14:10 jafingerhut

Two solutions I can imagine:

  • modify BMv2 source code to let you emit more than 512 bytes of header in a single pass
  • emit at most 512 bytes of headers in one pass, but recirculate packets that you want to add more than 512 bytes of headers to, adding at most 512 bytes on each pass.

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.

jafingerhut avatar Oct 03 '23 14:10 jafingerhut

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.

DolarJoe avatar Oct 26 '23 13:10 DolarJoe

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

github-actions[bot] avatar Apr 24 '24 00:04 github-actions[bot]