[P4-discuss] Doubts after my first try on p4lang

Andy Fingerhut andy.fingerhut at gmail.com
Thu Jun 22 22:24:50 EDT 2017


P4_14 is the name of the first version of the P4 language, originally
published in or near 2014.

P4_16 is the name of the second version of the P4 language, originally
published as a draft late in 2016, with version 1.0.0 published in May 2017.

The P4_14 language spec had a few corrections and clarifications published
only recently, to bring it closer to how the language actually was
implemented by multiple people.  However, the expectation is that P4_16
will represent the majority of future implementations of the language.

If you encounter a P4 program, the quickest way to tell whether you are
dealing with a P4_14 or P4_16 is that if you see bit<5> and bit<10> in
header definitions, or assignments inside of actions that look like C
assignments, then it is a P4_16 program.  If you see headers with
"field_name : 5" and "field_name : 10", and actions with
"modify_field(dest_field, value);" in them, then it is a P4_14 program.

I have a p4-guide repository here [1] that may help give something of an
overview of how the repositories relate to each other, and which are
'deprecated' or not (although their top level README should also state if
they are deprecated).

Going forward, the p4lang/p4c repository contains a compiler for both P4_14
and P4_16 programs.  The p4lang/behavioral-model repository contains the
source code for 'bmv2', which stands for behavioral model version 2, which
can emulate any P4_14 or P4_16 program after it has been compiled with
p4lang/p4c (or one of the older compilers that can only handle P4_14 source
code).  They are still in a state where some P4_16 features are not fully
implemented yet.

This may not address all of your questions, but it should be a good start.

[1] https://github.com/jafingerhut/p4-guide


On Thu, Jun 22, 2017 at 6:53 PM, Yousong Zhou <yszhou4tech at gmail.com> wrote:

> Hi, I have a few doubts and encountered several issues that I'd like
> to share with the list in the hope that it may help the project.
> I think there is a typo in the description of "Figure 10" of p4-16
> spec.  It says "Parameters are bound by the data plane", but it says
> also in a few other places that directionless parameters are to be
> bound the control plane though I still have no clue who the control
> plane is supposed to be and how that is actually done, but this is
> another issue...
> The other thing that doubts me is about the versioning scheme of
> p4lang specs.  Currently I see we have p4-16 as the current release
> and p4-14 as the previous release.  But
>  - p4-14 has version 1.0.4 > version 1.0.0 of p4-16
>  - p4-14 has date May 24, 2017 > May 22, 2017 of p4-16
> How is this so and I am curious about what the suffixes -14 and -16
> are for?  Maybe preparing a changelog can also help in the new release
> of a spec
> After reading "Example: a very simple switch" of p4-16, I thought then
> I should now have a fairly good working understanding of p4lang, but
> later when trying p4lang/tutorials I got struck with the impression
> that the lang must have changed significantly somehow....  The content
> and structure of .p4 files there are different and it took me a while
> to find core.p4 in p4lang/p4c which I do not know its relationship to
> bmv2 and p4c-bm...
> I have a few minor patches [1] while preparing and trying the
> copy-to-cpu example in tutorials.  But I am not sure whether those 3
> repos (bmv2, p4c-bm, tutorials) are still relevant or are they also to
> be deprecated
>  [1] https://github.com/yousong/build-scripts/commit/
> 91282702eafe1aa21a41d056ab00fda204c20d59#diff-
> ee344f88969e36b33e3d0479ee719d22R29
> Regards,
>                 yousong
> _______________________________________________
> P4-discuss mailing list
> P4-discuss at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-discuss_lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-discuss_lists.p4.org/attachments/20170622/0b799a6b/attachment-0002.html>

More information about the P4-discuss mailing list