[P4-dev] Few questions on the working of P4

Antoine Kaufmann antoinek at cs.washington.edu
Wed Jun 24 15:06:18 EDT 2015


Just two minor comments on this:

1) One could argue that this approach provides more flexibility over the
not listing the action, because it allows the compiler to optimize based
on this information. If your target does not care and you want the
flexibility to add all the actions on table entries  you can always just
list all of them in there and achieve the same goal.

2) Another PL analogy for this would be static typing: the list of
possible actions constrains what "values" can be added to the table. For
the control plane program populating the tables this enables compile
time detection of mistakes such as trying to use the wrong action when
adding an entry. Further, I would assume that this could also enable
the development of static checkers for P4 programs to catch a bunch of
errors, such as generating packet formats that cannot actually be
deparsed at the end of the pipeline, etc.

Cheers
Antoine

On Wed, Jun 24 11:27, Leo Alterman wrote:
> > For the second question, my guess is that the possible actions will help
> to hint the compiler to provision some necessary resources on specific
> targets. If this is the case, then this requirement should be made optional
> because in some other platforms, this is not necessary at all and could
> even hurt the potential flexibility.  Correct me if I’m wrong.
> 
> More importantly, it provides guarantees about the control flow and
> behavior of a P4 program (to both the compiler and programmer). Looking at
> a P4 table, you can map out exactly which parts of the packet may be
> modified and how.
> 
> By analogy: computers can technically jump to any point in instruction
> memory, but C limits program flow using function call semantics. This hurts
> flexibility but helps us reason about the code immensely. Similarly, P4
> makes guarantees about the actions a table can execute and from this you
> can reason about what a given match action table may do to a packet.
> 
> ~Leo
> 
> On Wed, Jun 24, 2015 at 11:13 AM, Haoyu song <haoyu.song at huawei.com> wrote:
> 
> >  For the second question, my guess is that the possible actions will help
> > to hint the compiler to provision some necessary resources on specific
> > targets. If this is the case, then this requirement should be made optional
> > because in some other platforms, this is not necessary at all and could
> > even hurt the potential flexibility.  Correct me if I’m wrong.
> >
> >
> >
> > -Haoyu
> >
> >
> >
> > *From:* P4-dev [mailto:p4-dev-bounces at p4.org] *On Behalf Of *Anubhav Nidhi
> > *Sent:* Tuesday, June 23, 2015 6:49 PM
> > *To:* p4-dev at p4.org
> > *Subject:* [P4-dev] Few questions on the working of P4
> >
> >
> >
> > Hi,
> >
> >      I am new to P4. After reading the P4 specification paper and trying
> > out the example given here
> > <https://github.com/p4lang/p4factory/tree/master/targets/simple_router>,
> > I have following questions regarding P4
> >
> > 1.    Do you have any code/repository which generates the JSON version of
> > the P4 compiler output?
> >
> > 2.    Also just want to make sure I understand how the table entries
> > work. Right now the example given in simple router here
> > <https://github.com/p4lang/p4factory/tree/master/targets/simple_router> says
> > that to enter a rule like drop packet with ip.dest = A1, I need to manually
> > enter a entry in a table e.g. add_entry table1 10.0.0.10 32 *_drop*. Is
> > the manually entering the table entry true? If that is the case and I need
> > to enter the action-name (name given in action specification) manually in
> > the table, then what is the purpose of mentioning the possible actions used?
> >
> >
> >
> > Thanks,
> >
> > Archie
> >
> >
> >
> > _______________________________________________
> > P4-dev mailing list
> > P4-dev at p4.org
> > Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> > Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
> >

> _______________________________________________
> P4-dev mailing list
> P4-dev at p4.org
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/


-- 
Antoine Kaufmann
<antoinek at cs.washington.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150624/19d2c051/attachment.asc>


More information about the P4-dev mailing list