How to provide custom functions in v1model.p4

I want to design custom functions in v1model.p4 just like the hash provided in the p4 file. But I don’t really know how to add this function in source code. Is there any way to add my own code?

Hi,

My short answer was going to be: declare it in v1model.p4 (your own extern, since that is what you are looking for) and implement it in bmv2. But I found a more complete one.

If the steps have not changed, a better answer is provided here by Antonin Bas. That thread has a long discussion, so you can actually check the p4-macsec case they mention after his response. Which tried to achieve a similar thing to yours in terms of an extern implementation.

Cheers,

Thank you very much, it is very helpful to me!