Obtain resource usage of P4 program

I would like to know the switch resources usage for a P4 program, such as TCAM, SRAM, stage, SALU, etc. Are there any methods or tools available on BMv2 or Tofino that can implement this function.

For Tofino, there is a tool called P4 Insight that can display how much of different types of hardware resources are used, either total, or even broken down stage by stage. It may be available to you if you already have access to the Tofino SDE.

There is no such tool for BMv2 that I know about. Note that there is no TCAM in typical general purpose CPUs, so ternary matches are implemented without TCAM hardware, e.g. by linear search (there are many more complex algorithms that trade off higher performance for more memory, complexity of implementation, etc.).

1 Like