[P4-dev] reserved word primitive_action_declaration

Antonin Bas antonin at barefootnetworks.com
Mon Nov 21 13:35:39 EST 2016


Two important things:
- P4 1.1 has been deprecated. We never fully made the transition from P4
1.0 (now referred to as P4_14) and the new P4_16 will be released very soon.
- As far as the P4_14 specification is concerned, we have decided to remove
the ability to declare hardware-specific primitive actions in the P4
program itself (please see an explanation in this Github thread:
However, there is another way to declare your own primitive actions, so
that the P4_14 compiler can be made aware of them. You need to declare them
in a JSON file like this:
https://github.com/p4lang/p4c-bm/blob/master/p4c_bm/primitives.json. I
recommend declaring your custom primitives in a separate file, e.g.
my_primitives.json. You can then provide this JSON file to a compiler
binary (p4-graphs or p4c-bmv2 support this, but not p4-validate
unfortunately) using "--primitives my_primitives.json". For example, when
compiling for bmv2:
p4c-bmv2 prog.p4 --primitives my_primitives.json --json prog.json
If you intend to run your P4 program in bmv2, you will of course need to
*implement* your new primitive action in C++. The easiest way to do that is
to modify the simple_switch target code in the bmv2 repo and add your new
primitive implementation there:
If that's what you are looking to do, you should probably read that thread
for more information:



On Sat, Nov 19, 2016 at 3:37 PM, Wu, Xiaoban <Xiaoban_Wu at student.uml.edu>

> Hi,
> I find that in the http://p4.org/wp-content/uploads/2016/03/p4_v1.1.pdf,
> there is a reserved word "primitive_action_declaration". But there is no
> detailed explanation on "primitive_action_declaration" in the spec.
> I want to know how to declare a customized primitive in a P4 program and
> how to allow such a primitive to be implemented with a customized hardware.
> Thank you very much.
> Best wishes,
> Xiaoban
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20161121/fbbc676a/attachment-0002.html>

More information about the P4-dev mailing list