[P4-dev] reserved word primitive_action_declaration

Wu, Xiaoban Xiaoban_Wu at student.uml.edu
Mon Nov 21 20:02:40 EST 2016


Dear Antonin,


Thank you very much for your reply.


Best wishes,

Xiaoban

________________________________
From: Antonin Bas <antonin at barefootnetworks.com>
Sent: Monday, November 21, 2016 1:35:39 PM
To: Wu, Xiaoban
Cc: p4-dev at lists.p4.org
Subject: Re: [P4-dev] reserved word primitive_action_declaration

Hi,

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: https://github.com/p4lang/p4-hlir/issues/17)
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: https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch/primitives.cpp. If that's what you are looking to do, you should probably read that thread for more information: http://lists.p4.org/pipermail/p4-dev_lists.p4.org/2016-May/000308.html

Best,

Antonin

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

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<mailto:P4-dev at lists.p4.org>
http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org



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


More information about the P4-dev mailing list